
    h'                     j    S SK r S SKrS SKJrJr  S SKJrJr  S SKJ	r	  SSK
Jr  \ " S S5      5       rg)	    N)	dataclassfield)AnyOptional)is_bitsandbytes_available   )flatten_dictc                   b   \ rS rSr% Sr\" \R                  R                  \	R                  S   5      S\" S5      *  SS0S9r\\S	'   \" S
SS0S9r\\S'   \" SSS0S9r\\S'   \" SSSS/S.S9r\\   \S'   \" SSS0S9r\\S'   \" \SS0S9r\\\4   \S'   \" \SS0S9r\\\4   \S'   \" \SS0S9r\\\4   \S'   \" SSS0S9r\\S '   \" S!SS"0S9r\\S#'   \" S$SS%0S9r\\S&'   \" SSS'0S9r\\S('   \" S)SS*0S9r\\S+'   \" S,S-/ S.QS.S9r\\S/'   \" S0SS10S9r \!\S2'   \" S
SS30S9r"\\S4'   \" S5SS60S9r#\\S7'   \" S8SS90S9r$\%\S:'   \" S;SS<0S9r&\%\S='   \" SSS>0S9r'\\S?'   \" S@SSA0S9r(\!\SB'   \" SCSSD0S9r)\%\SE'   \" SFSSG0S9r*\%\SH'   \" SISSJ0S9r+\%\SK'   \" SLSSM0S9r,\%\SN'   \" SOSSP0S9r-\%\SQ'   \" SSSR0S9r.\\SS'   \" S8SST0S9r/\%\SU'   \" SSSV0S9r0\\   \SW'   \" S0SSX0S9r1\!\SY'   \" SZSS[0S9r2\\S\'   \" S]SS^0S9r3\4\\4   \S_'   \" S@SS`0S9r5\!\Sa'   Sb r6Sc r7Sdr8g)eAlignPropConfig   a  
Configuration class for the [`AlignPropTrainer`].

Using [`~transformers.HfArgumentParser`] we can turn this class into
[argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the
command line.

Parameters:
    exp_name (`str`, *optional*, defaults to `os.path.basename(sys.argv[0])[: -len(".py")]`):
        Name of this experiment (defaults to the file name without the extension).
    run_name (`str`, *optional*, defaults to `""`):
        Name of this run.
    seed (`int`, *optional*, defaults to `0`):
        Random seed for reproducibility.
    log_with (`str` or `None`, *optional*, defaults to `None`):
        Log with either `"wandb"` or `"tensorboard"`. Check
        [tracking](https://huggingface.co/docs/accelerate/usage_guides/tracking) for more details.
    log_image_freq (`int`, *optional*, defaults to `1`):
        Frequency for logging images.
    tracker_kwargs (`dict[str, Any]`, *optional*, defaults to `{}`):
        Keyword arguments for the tracker (e.g., `wandb_project`).
    accelerator_kwargs (`dict[str, Any]`, *optional*, defaults to `{}`):
        Keyword arguments for the accelerator.
    project_kwargs (`dict[str, Any]`, *optional*, defaults to `{}`):
        Keyword arguments for the accelerator project config (e.g., `logging_dir`).
    tracker_project_name (`str`, *optional*, defaults to `"trl"`):
        Name of project to use for tracking.
    logdir (`str`, *optional*, defaults to `"logs"`):
        Top-level logging directory for checkpoint saving.
    num_epochs (`int`, *optional*, defaults to `100`):
        Number of epochs to train.
    save_freq (`int`, *optional*, defaults to `1`):
        Number of epochs between saving model checkpoints.
    num_checkpoint_limit (`int`, *optional*, defaults to `5`):
        Number of checkpoints to keep before overwriting old ones.
    mixed_precision (`str`, *optional*, defaults to `"fp16"`):
        Mixed precision training.
    allow_tf32 (`bool`, *optional*, defaults to `True`):
        Allow `tf32` on Ampere GPUs.
    resume_from (`str`, *optional*, defaults to `""`):
        Path to resume training from a checkpoint.
    sample_num_steps (`int`, *optional*, defaults to `50`):
        Number of sampler inference steps.
    sample_eta (`float`, *optional*, defaults to `1.0`):
        Eta parameter for the DDIM sampler.
    sample_guidance_scale (`float`, *optional*, defaults to `5.0`):
        Classifier-free guidance weight.
    train_batch_size (`int`, *optional*, defaults to `1`):
        Batch size for training.
    train_use_8bit_adam (`bool`, *optional*, defaults to `False`):
        Whether to use the 8bit Adam optimizer from `bitsandbytes`.
    train_learning_rate (`float`, *optional*, defaults to `1e-3`):
        Learning rate.
    train_adam_beta1 (`float`, *optional*, defaults to `0.9`):
        Beta1 for Adam optimizer.
    train_adam_beta2 (`float`, *optional*, defaults to `0.999`):
        Beta2 for Adam optimizer.
    train_adam_weight_decay (`float`, *optional*, defaults to `1e-4`):
        Weight decay for Adam optimizer.
    train_adam_epsilon (`float`, *optional*, defaults to `1e-8`):
        Epsilon value for Adam optimizer.
    train_gradient_accumulation_steps (`int`, *optional*, defaults to `1`):
        Number of gradient accumulation steps.
    train_max_grad_norm (`float`, *optional*, defaults to `1.0`):
        Maximum gradient norm for gradient clipping.
    negative_prompts (`str` or `None`, *optional*, defaults to `None`):
        Comma-separated list of prompts to use as negative examples.
    truncated_backprop_rand (`bool`, *optional*, defaults to `True`):
        If `True`, randomized truncation to different diffusion timesteps is used.
    truncated_backprop_timestep (`int`, *optional*, defaults to `49`):
        Absolute timestep to which the gradients are backpropagated. Used only if `truncated_backprop_rand=False`.
    truncated_rand_backprop_minmax (`tuple[int, int]`, *optional*, defaults to `(0, 50)`):
        Range of diffusion timesteps for randomized truncated backpropagation.
    push_to_hub (`bool`, *optional*, defaults to `False`):
        Whether to push the final model to the Hub.
r   Nz.pyhelpzJName of this experiment (defaults to the file name without the extension).)defaultmetadataexp_name zName of this run.run_namez Random seed for reproducibility.seedz)Log with either 'wandb' or 'tensorboard'.wandbtensorboard)r   choiceslog_with   zFrequency for logging images.log_image_freqz:Keyword arguments for the tracker (e.g., `wandb_project`).)default_factoryr   tracker_kwargsz&Keyword arguments for the accelerator.accelerator_kwargszKKeyword arguments for the accelerator project config (e.g., `logging_dir`).project_kwargstrlz$Name of project to use for tracking.tracker_project_namelogsz2Top-level logging directory for checkpoint saving.logdird   zNumber of epochs to train.
num_epochsz2Number of epochs between saving model checkpoints.	save_freq   z:Number of checkpoints to keep before overwriting old ones.num_checkpoint_limitfp16zEMixed precision training. Possible values are 'fp16', 'bf16', 'none'.)r'   bf16nonemixed_precisionTzAllow `tf32` on Ampere GPUs.
allow_tf32z*Path to resume training from a checkpoint.resume_from2   z"Number of sampler inference steps.sample_num_stepsg      ?z#Eta parameter for the DDIM sampler.
sample_etag      @z Classifier-free guidance weight.sample_guidance_scalezBatch size for training.train_batch_sizeFz;Whether to use the 8bit Adam optimizer from `bitsandbytes`.train_use_8bit_adamgMbP?zLearning rate.train_learning_rateg?zBeta1 for Adam optimizer.train_adam_beta1g+?zBeta2 for Adam optimizer.train_adam_beta2g-C6?z Weight decay for Adam optimizer.train_adam_weight_decayg:0yE>z!Epsilon value for Adam optimizer.train_adam_epsilonz&Number of gradient accumulation steps.!train_gradient_accumulation_stepsz,Maximum gradient norm for gradient clipping.train_max_grad_normz<Comma-separated list of prompts to use as negative examples.negative_promptszJIf `True`, randomized truncation to different diffusion timesteps is used.truncated_backprop_rand1   zjAbsolute timestep to which the gradients are backpropagated. Used only if `truncated_backprop_rand=False`.truncated_backprop_timestep)r   r-   zFRange of diffusion timesteps for randomized truncated backpropagation.truncated_rand_backprop_minmaxz+Whether to push the final model to the Hub.push_to_hubc                 j    0 nU R                   R                  5        H	  u  p#X1U'   M     [        U5      $ )N)__dict__itemsr	   )selfoutput_dictkeyvalues       V/home/james-whalen/.local/lib/python3.13/site-packages/trl/trainer/alignprop_config.pyto_dictAlignPropConfig.to_dict   s3    ----/JC$ 0K((    c                 \    U R                   (       a  [        5       (       d  [        S5      eg g )NzfYou need to install bitsandbytes to use 8bit Adam. You can install it with `pip install bitsandbytes`.)r2   r   ImportError)rC   s    rG   __post_init__AlignPropConfig.__post_init__   s0    ##,E,G,GF  -H#rJ    )9__name__
__module____qualname____firstlineno____doc__r   ospathbasenamesysargvlenr   str__annotations__r   r   intr   r   r   dictr   r   r   r   r   r!   r#   r$   r&   r*   r+   boolr,   r.   r/   floatr0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r=   r>   tupler?   rH   rM   __static_attributes__rO   rJ   rG   r   r      s   KZ   !-mU<fgHc  "8K/LMHcMa63U*VWD#W#ESZ\iRjkHhsm   V=\4]^NC^%*VW&NDcN  */0X'Y*S#X  &+gh&NDcN  !&evGm>n o#o&:n1opFCpC6;W2XYJY18l/mnIsn %V%ab!#  ![/
OS  TV=[4\]J]R6;g2hiKi!"@d7efcfcV=b4cdJd#(Hj?k#l5l!!v?Y6Z[c[ %)f g!  "'tvGW>X!YY#C6C^:_`e`#EVE`<abeb%*46KmBn%oUo %dfFi=j kk-2V%MN.%s  "'sfFt=u!vv&+XY'hsm  %*fg%T  (- /
(  7<\
7"E#s(O  ev?l6mnKn)rJ   r   )rU   rX   dataclassesr   r   typingr   r   transformersr   corer	   r   rO   rJ   rG   <module>rg      s5    
 
 (   2  f f frJ   