Ë
    §Ùbi0   ã                  ól   — d dl mZ d dlmZmZ d dlmZmZmZ d dl	m
Z
 d dlmZ e G d„ de
«      «       Zy)	é    )Úannotations)Ú	dataclassÚfield)ÚLiteralÚOptionalÚUnion)ÚLycorisConfig)ÚPeftTypec                  ó   ‡ — e Zd ZU dZ edddi¬«      Zded<    edddi¬«      Zded	<    ed
ddi¬«      Zded<    ed
ddi¬«      Z	ded<    edddi¬«      Z
ded<    edddi¬«      Zded<    edddi¬«      Zded<    edddi¬«      Zded<    edddi¬«      Zded<    edddi¬«      Zded <    ed!dd"i¬«      Zd#ed$<    eddd%i¬«      Zd&ed'<    eddd(i¬«      Zded)<    eddd*i¬«      Zd+ed,<   ˆ fd-„Zˆ xZS ).Ú
LoKrConfiga¨  
    Configuration class of [`LoKrModel`].

    Args:
        r (`int`):
            LoKr rank.
        alpha (`int`):
            The alpha parameter for LoKr scaling.
        rank_dropout (`float`):
            The dropout probability for rank dimension during training.
        module_dropout (`float`):
            The dropout probability for disabling LoKr modules during training.
        use_effective_conv2d (`bool`):
            Use parameter effective decomposition for Conv2d with ksize > 1 ("Proposition 3" from FedPara paper).
        decompose_both (`bool`):
            Perform rank decomposition of left kronecker product matrix.
        decompose_factor (`int`):
            Kronecker product decomposition factor.
        rank_dropout_scale ('bool)
            Whether to scale the rank dropout while training, defaults to `False`.
        target_modules (`Optional[Union[List[str], str]]`):
            The names of the modules to apply the adapter to. If this is specified, only the modules with the specified
            names will be replaced. When passing a string, a regex match will be performed. When passing a list of
            strings, either an exact match will be performed or it is checked if the name of the module ends with any
            of the passed strings. If this is specified as 'all-linear', then all linear/Conv1D modules are chosen,
            excluding the output layer. If this is not specified, modules will be chosen according to the model
            architecture. If the architecture is not known, an error will be raised -- in this case, you should specify
            the target modules manually.
        exclude_modules (`Optional[Union[List[str], str]]`):
            The names of the modules to not apply the adapter. When passing a string, a regex match will be performed.
            When passing a list of strings, either an exact match will be performed or it is checked if the name of the
            module ends with any of the passed strings.
        init_weights (`bool`):
            Whether to perform initialization of adapter weights. This defaults to `True`. Use "lycoris" to initialize
            weights in the style of the LYCORIS repository. Passing `False` is discouraged.
        layers_to_transform (`Union[List[int], int]`):
            The layer indices to transform. If a list of ints is passed, it will apply the adapter to the layer indices
            that are specified in this list. If a single integer is passed, it will apply the transformations on the
            layer at this index.
        layers_pattern (`Optional[Union[List[str], str]]`):
            The layer pattern name, used only if `layers_to_transform` is different from `None`. This should target the
            `nn.ModuleList` of the model, which is often called `'layers'` or `'h'`.
        rank_pattern (`dict`):
            The mapping from layer names or regexp expression to ranks which are different from the default rank
            specified by `r`. For example, `{'^model.decoder.layers.0.encoder_attn.k_proj': 16}`.
        alpha_pattern (`dict`):
            The mapping from layer names or regexp expression to alphas which are different from the default alpha
            specified by `alpha`. For example, `{'^model.decoder.layers.0.encoder_attn.k_proj': 16}`.
        modules_to_save (`Optional[List[str]]`):
            List of modules apart from adapter layers to be set as trainable and saved in the final checkpoint.
    é   Úhelpz	LoKr rank)ÚdefaultÚmetadataÚintÚrz
LoKr alphaÚalphag        z:The dropout probability for rank dimension during trainingÚfloatÚrank_dropoutzBThe dropout probability for disabling LoKr modules during trainingÚmodule_dropoutFzhUse parameter effective decomposition for Conv2d 3x3 with ksize > 1 ("Proposition 3" from FedPara paper)ÚboolÚuse_effective_conv2dz<Perform rank decomposition of left kronecker product matrix.Údecompose_bothéÿÿÿÿz'Kronecker product decomposition factor.Údecompose_factorzRank dropout scaleÚrank_dropout_scaleNa
  List of module names or regex expression of the module names to replace with LoKr.For example, ['q', 'v'] or '.*decoder.*(SelfAttention|EncDecAttention).*(q|v)$' This can also be a wildcard 'all-linear' which matches all linear/Conv1D layers except the output layer.zOptional[Union[list[str], str]]Útarget_moduleszRList of module names or regex expression of the module names to exclude from LoKr.Úexclude_modulesTzÚWhether to initialize the weights of the LoKr layers with their default initialization. Can be True, False or 'lycoris'.Default is True. Don't change this setting to False, except if you know exactly what you're doing.zUnion[bool, Literal['lycoris']]Úinit_weightszàThe layer indexes to transform, is this argument is specified, PEFT will transform only the layers indexes that are specified inside this list. If a single integer is passed, PEFT will transform only the layer at this index.zOptional[Union[list[int], int]]Úlayers_to_transformzíThe layer pattern name, used only if `layers_to_transform` is different to None and if the layer pattern is not in the common layers pattern. This should target the `nn.ModuleList` of the model, which is often called `'layers'` or `'h'`.Úlayers_patterna  List of modules apart from LoKr layers to be set as trainable and saved in the final checkpoint. For example, in Sequence Classification or Token Classification tasks, the final layer `classifier/score` are randomly initialized and as such need to be trainable and saved.zOptional[list[str]]Úmodules_to_savec                ó”  •— t         ‰|   «        t        j                  | _        t        | j                  t        «      rt        | j                  «      n| j                  | _        t        | j                  t        «      rt        | j                  «      n| j                  | _	        | j                  r| j                  st        d«      ‚y y )NzRWhen `layers_pattern` is specified, `layers_to_transform` must also be specified. )ÚsuperÚ__post_init__r
   ÚLOKRÚ	peft_typeÚ
isinstancer   ÚlistÚsetr   r!   r    Ú
ValueError)ÚselfÚ	__class__s    €úR/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/peft/tuners/lokr/config.pyr%   zLoKrConfig.__post_init__Œ   sŸ   ø€ Ü‰ÑÔÜ!Ÿ™ˆŒä(2°4×3FÑ3FÌÔ(MŒC×#Ñ#Ô$ÐSW×SfÑSfð 	Ôô *4°D×4HÑ4HÌ$Ô)OŒC×$Ñ$Ô%ÐUY×UiÑUið 	Ôð ×Ò t×'?Ò'?ÜÐqÓrÐrð (@Ðó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r   r   r   r   r   r   r   r   r    r!   r"   r%   Ú__classcell__)r-   s   @r.   r   r      sÉ  ø… ñ2ñh ˜1¨°Ð'<Ô=€A€sÓ=Ù˜q¨F°LÐ+AÔB€Eˆ3ÓBÙØ˜vÐ'cÐdô€L%ó ñ "Ø˜vÐ'kÐlô€NEó ñ "'ØàÐ~ð
ô"Ð˜$ó ñ !ØØÐXÐYô€NDó ñ "¨"¸Ð@iÐ7jÔkÐcÓkÙ$¨U¸fÐFZÐ=[Ô\Ð˜Ó\Ù6;Øàð wð
ô7€NÐ3ó ñ 8=ØØÐnÐoô8€OÐ4ó ñ 5:Øàðuð
ô5€LÐ1ó ñ <AØàð  wð
ô<ÐÐ8ó ñ 7<Øàð nð
ô7€NÐ3ó ñ ,1Øàð vð
ô,€OÐ(ó ÷sð sr/   r   N)Ú
__future__r   Údataclassesr   r   Útypingr   r   r   Úpeft.tuners.lycoris_utilsr	   Ú
peft.utilsr
   r   © r/   r.   ú<module>r<      s:   ðõ #ç (ß +Ñ +å 3Ý ð ôsó só ñsr/   