
    h9%                     F    S SK r S SKJrJr  S SKJr  \ " S S5      5       rg)    N)	dataclassfield)Optionalc                      \ rS rSr% Sr\" 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'   \" 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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(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/'   \" S0S1S2S0/S.S9r\\	S3'   \" SSS40S9r\\	S5'   \" SS/ SQS.S9r \\   \	S6'   S7 r!S8r"g)9ModelConfig   u  
Configuration class for the models.

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:
    model_name_or_path (`str` or `None`, *optional*, defaults to `None`):
        Model checkpoint for weights initialization.
    model_revision (`str`, *optional*, defaults to `"main"`):
        Specific model version to use. It can be a branch name, a tag name, or a commit id.
    dtype (`Literal["auto", "bfloat16", "float16", "float32"]` or `None`, *optional*, defaults to `None`):
        Override the default `torch.dtype` and load the model under this dtype. Possible values are

            - `"bfloat16"`: `torch.bfloat16`
            - `"float16"`: `torch.float16`
            - `"float32"`: `torch.float32`
            - `"auto"`: Automatically derive the dtype from the model's weights.

    trust_remote_code (`bool`, *optional*, defaults to `False`):
        Whether to allow for custom models defined on the Hub in their own modeling files. This option should only
        be set to `True` for repositories you trust and in which you have read the code, as it will execute code
        present on the Hub on your local machine.
    attn_implementation (`str` or `None`, *optional*, defaults to `None`):
        Which attention implementation to use. You can run `--attn_implementation=flash_attention_2`, in which case
        you must install this manually by running `pip install flash-attn --no-build-isolation`.
    use_peft (`bool`, *optional*, defaults to `False`):
        Whether to use PEFT for training.
    lora_r (`int`, *optional*, defaults to `16`):
        LoRA R value.
    lora_alpha (`int`, *optional*, defaults to `32`):
        LoRA alpha.
    lora_dropout (`float`, *optional*, defaults to `0.05`):
        LoRA dropout.
    lora_target_modules (`Union[str, list[str]]` or `None`, *optional*, defaults to `None`):
        LoRA target modules.
    lora_target_parameters (`Union[str, list[str]]` or `None`, *optional*, defaults to `None`):
        List of target parameters for LoRA.
    lora_modules_to_save (`list[str]` or `None`, *optional*, defaults to `None`):
        Model layers to unfreeze & train.
    lora_task_type (`str`, *optional*, defaults to `"CAUSAL_LM"`):
        Task type to pass for LoRA (use `"SEQ_CLS"` for reward modeling).
    use_rslora (`bool`, *optional*, defaults to `False`):
        Whether to use Rank-Stabilized LoRA, which sets the adapter scaling factor to `lora_alpha/√r`, instead of
        the original default value of `lora_alpha/r`.
    use_dora (`bool`, *optional*, defaults to `False`):
        Enable [Weight-Decomposed Low-Rank Adaptation (DoRA)](https://huggingface.co/papers/2402.09353). This
        technique decomposes the updates of the weights into two parts, magnitude and direction. Direction is
        handled by normal LoRA, whereas the magnitude is handled by a separate learnable parameter. This can
        improve the performance of LoRA, especially at low ranks. Right now, DoRA only supports linear and Conv2D
        layers. DoRA introduces a bigger overhead than pure LoRA, so it is recommended to merge weights for
        inference.
    load_in_8bit (`bool`, *optional*, defaults to `False`):
        Whether to use 8 bit precision for the base model. Works only with LoRA.
    load_in_4bit (`bool`, *optional*, defaults to `False`):
        Whether to use 4 bit precision for the base model. Works only with LoRA.
    bnb_4bit_quant_type (`str`, *optional*, defaults to `"nf4"`):
        Quantization type (`"fp4"` or `"nf4"`).
    use_bnb_nested_quant (`bool`, *optional*, defaults to `False`):
        Whether to use nested quantization.
Nhelpz,Model checkpoint for weights initialization.)defaultmetadatamodel_name_or_pathmainzSSpecific model version to use. It can be a branch name, a tag name, or a commit id.model_revisionzGOverride the default `torch.dtype` and load the model under this dtype.)autobfloat16float16float32)r	   choicesdtypeFzWhether to allow for custom models defined on the Hub in their own modeling files. This option should only be set to `True` for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine.trust_remote_codezWhich attention implementation to use. You can run `--attn_implementation=flash_attention_2`, in which case you must install this manually by running `pip install flash-attn --no-build-isolation`.attn_implementationz!Whether to use PEFT for training.use_peft   zLoRA R value.lora_r    zLoRA alpha.
lora_alphag?zLoRA dropout.lora_dropoutzLoRA target modules.lora_target_modulesz#List of target parameters for LoRA.lora_target_parametersz!Model layers to unfreeze & train.lora_modules_to_save	CAUSAL_LMz?Task type to pass for LoRA (use 'SEQ_CLS' for reward modeling).lora_task_typeu   Whether to use Rank-Stabilized LoRA, which sets the adapter scaling factor to `lora_alpha/√r`, instead of the original default value of `lora_alpha/r`.
use_rsloraa  Enable Weight-Decomposed Low-Rank Adaptation (DoRA). This technique decomposes the updates of the weights into two parts, magnitude and direction. Direction is handled by normal LoRA, whereas the magnitude is handled by a separate learnable parameter. This can improve the performance of LoRA, especially at low ranks. Right now, DoRA only supports linear and Conv2D layers. DoRA introduces a bigger overhead than pure LoRA, so it is recommended to merge weights for inference.use_dorazHWhether to use 8 bit precision for the base model. Works only with LoRA.load_in_8bitzHWhether to use 4 bit precision for the base model. Works only with LoRA.load_in_4bitnf4zQuantization type.fp4bnb_4bit_quant_typez#Whether to use nested quantization.use_bnb_nested_quanttorch_dtypec                    U R                   (       a  U R                  (       a  [        S5      eU R                  (       a=  U R                  (       d,  [
        R                  " S[        5        U R                  U l        [        U R                  S5      (       a/  [        U R                  5      S:X  a  U R                  S   U l	        g g g )Nz8You can't use 8 bit and 4 bit precision at the same timez^`torch_dtype` is deprecated and will be removed in version 0.27.0, please use `dtype` instead.__len__   r   )r$   r%   
ValueErrorr*   r   warningswarnDeprecationWarninghasattrr   len)selfs    R/home/james-whalen/.local/lib/python3.13/site-packages/trl/trainer/model_config.py__post_init__ModelConfig.__post_init__   s    !2!2WXXDJJMMp" ))DJ4++Y77C@X@X<Y]^<^'+'?'?'BD$ =_7    )r   r   )#__name__
__module____qualname____firstlineno____doc__r   r   r   str__annotations__r   r   r   boolr   r   r   intr   r   floatr   listr   r   r!   r"   r#   r$   r%   r(   r)   r*   r6   __static_attributes__ r8   r5   r   r      s   =~ ).HI)   opNC  !]A
E8C=  $ E
t  */ r
*#  =>Hd  /*FC  -(J   /*L%  05010$s),  38?@3HT#Y/  16=>1(49-   [\NC   G
J   c
	Hd 	 deL$  deL$   %.E5>J   "'?@"$ 
 "']A
"K# Cr8   r   )r/   dataclassesr   r   typingr   r   rE   r8   r5   <module>rH      s/     (  tC tC tCr8   