
    bi                    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)
PeftConfig)PeftTypec                  V    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 <    fd!Z xZS )"
PolyConfiga  
    This is the configuration class to store the configuration of a [`PolyModel`].
        - [Polytropon (Poly)](https://huggingface.co/papers/2202.13914)
        - [Multi-Head Routing (MHR)](https://huggingface.co/papers/2211.03831)

    Args:
        r (`int`): Attention dimension of each Lora in Poly.
        target_modules (`Union[List[str],str]`): The names of the modules to apply Poly to.
        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.
        modules_to_save (`List[str]`): List of modules apart from Poly layers to be set as trainable
            and saved in the final checkpoint.
        init_weights (bool): Whether to perform initialization of Poly weights.
        poly_type (`Literal["poly"]`): The variant of the Poly module to use. Currently, only "poly"
            is supported.
        n_tasks (`int`): The number of tasks in a multitasking scenario.
        n_skills (`int`): The number of skills (LoRA) in each Poly layer.
        n_splits (`int`): The number of splits within each LoRA of a Poly layer. A value greater
            than 1 indicates the use of Multi-Head Routing (MHR).
       helpzLora attention dimension)defaultmetadataintrNzList of module names or regex expression of the module names to replace with Poly.For example, ['q', 'v'] or '.*decoder.*(SelfAttention|EncDecAttention).*(q|v)$' zOptional[Union[list[str], str]]target_moduleszRList of module names or regex expression of the module names to exclude from Poly.exclude_modulesa  List of modules apart from Poly 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_saveTzWhether to initialize the weights of the Poly layers with their default initialization. Don't change this setting, except if you know exactly what you're doing.boolinit_weightspolyzDType of Poly modules to be used. Currently only "poly" is supported.zLiteral['poly']	poly_type   z)Number of tasks in multitasking scenario.n_tasks   z+Number of skills (LoRA) in each Poly layer.n_skillsz2Number of splits within each LoRA of a Poly layer.n_splitsc                X   t         |           t        j                  | _        t        | j                  t              rt        | j                        n| j                  | _        t        | j                  t              rt        | j                        | _	        y | j                  | _	        y )N)
super__post_init__r
   POLY	peft_type
isinstancer   listsetr   )self	__class__s    R/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/peft/tuners/poly/config.pyr!   zPolyConfig.__post_init___   s    !(243F3F(MC##$SWSfSf 	 *4D4H4H$)OC$$% 	UYUiUi 	    )__name__
__module____qualname____doc__r   r   __annotations__r   r   r   r   r   r   r   r   r!   __classcell__)r(   s   @r)   r   r      s3   . 10J'KLAsL6; _
7N3  8=no8O4  ,1 v
,O(  N
L$  "'`a"I  EFGS  GHHc  NOHc 

 
r*   r   N)
__future__r   dataclassesr   r   typingr   r   r   peft.configr	   
peft.utilsr
   r    r*   r)   <module>r7      s7    # ( + + "  N
 N
 N
r*   