ó
    >:jQR  ã                  ó(  • S SK Jr  S SKrS SKJr  S SKJr  S SKJrJ	r	  S SK
r
S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  SSKJr  SSKJr  SSKJr  SSKJrJrJ r           SS jr!    S             SS jjr" " S S\5      r#g)é    )ÚannotationsN)Úcontextmanager)Úpartial)ÚOptionalÚUnion)Ú	LoraLayer)Ú	LoraModel)Ú	BaseTuner)ÚDUMMY_TARGET_MODULES)Úset_peft_model_state_dicté   )Úloraé   )ÚXLoraClassifier)ÚXLoraConfig)ÚXLoraConv2dLayerÚXLoraEmbeddingLayerÚXLoraLinearLayerc           	     óê  • Sn/ nSnU R                  5        GHÖ  n[        U[        R                  5      (       a  UR                  [        [        UR                  5      5         R                  R                  n[        UUUR                  UUS9nUR                  U5        UR                  Ul
        US-  nM¢  [        U[        R                  5      (       av  UR                  [        [        UR                  5      5         R                  n[        UUUR                  UUS9nUR                  U5        UR                  Ul
        US-  nGM7  [        U[        R                  5      (       d  GMY  UR                  [        [        UR                  5      5         R                  R                  n[!        UUUR                  UUS9nUR                  U5        UR                  Ul
        US-  nGMÙ     X54$ )z'
Returns the number of swapped layers.
r   N)ÚmodelÚtargetÚtarget_forwardÚlayer_numberÚconfigr   )ÚmodulesÚ
isinstancer   ÚLinearÚlora_AÚnextÚiterÚweightÚdevicer   ÚforwardÚappendÚ	EmbeddingÚlora_embedding_Ar   ÚConv2dr   )ÚbaseÚ
xloramodelr   Útotal_swappedÚ
all_layersr"   ÚmoduleÚ	new_layers           ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/peft/tuners/xlora/model.pyÚconvert_layers_to_xlorar/   $   s¥  € ð €MØ€Jà€FØ—,‘,—.ˆä�fœdŸk™k×*Ñ*Ø—]‘]¤4¬¨V¯]©]Ó(;Ó#<Ñ=×DÑD×KÑKˆFÜ(Ø ØØ%Ÿ~™~Ø*ØñˆIð ×Ñ˜iÔ(Ø&×.Ñ.ˆFŒNØ˜QÑŠMÜ˜¤§¡×/Ñ/Ø×,Ñ,¬T´$°v×7NÑ7NÓ2OÓ-PÑQ×XÑXˆFÜ+Ø ØØ%Ÿ~™~Ø*ØñˆIð ×Ñ˜iÔ(Ø&×.Ñ.ˆFŒNØ˜QÑ‹MÜ˜¤§¡×,Ô,Ø—]‘]¤4¬¨V¯]©]Ó(;Ó#<Ñ=×DÑD×KÑKˆFÜ(Ø ØØ%Ÿ~™~Ø*ØñˆIð ×Ñ˜iÔ(Ø&×.Ñ.ˆFŒNØ˜QÑ‹MñK !ðN Ð"Ð"ó    c                óF  • SSK Jn  SSKJn	  SSKJn
  SSKJn  UR                  U5      u  pÇUc  U
" 5       nXR                  ;  aG  U	R                  " U4UUS.UD6nSUl        XÐR                  U'   U R                  U R                  U5        U" U4X6S	.UD6n0 nUR                  5        H…  nUnUR                  S
5      (       a  UR                  S5      (       aG  UUR!                  S5      S-   S nUR                  S
5      (       d  M/  UR                  S5      (       a  MG  S
U-   nUU   UU'   M‡     UR#                  SS5      n[%        U UUUS9n['        UR(                  5      S:”  a  [+        SUR(                   35      e[-        U S5      (       a  U R/                  XS9  gg)zï
This method emulates the behavior of `PeftModel.from_pretrained`. Updates to `PeftModel.from_pretrained` may need
to be reflected here.

All params pertain to the adapter (adapter name, model id, `i` is the adapter number in 0 indexing).
r   )Ú	PeftModel)Ú
LoraConfig)Úinfer_device)Úload_peft_weightsN)Úephemeral_gpu_offloadÚ	subfolderF)r"   r7   zmodel.zmodel.model.Ú.r   Úignore_mismatched_sizes)Úadapter_namer9   zSGot unexpected keys! Please raise an issue and tag @EricLBuehler.

unexpected_keys=Ú_cast_adapter_dtype)r:   Úautocast_adapter_dtype)Úpeft.peft_modelr2   Úpeft.tuners.lora.configr3   Úpeft.utils.otherr4   Úpeft.utils.save_and_loadr5   Ú_split_kwargsÚpeft_configÚfrom_pretrainedÚinference_modeÚinject_adapterr   ÚkeysÚ
startswithÚfindÚgetr   ÚlenÚunexpected_keysÚ
ValueErrorÚhasattrr;   )Ú
lora_modelr:   Úmodel_idÚtorch_devicer6   r<   r7   Úkwargsr2   r3   r4   r5   Úhf_hub_download_kwargsÚlora_peft_configÚadapter_weightsÚnew_adapter_weightsÚold_keyÚkeyr9   Úload_results                       r.   Ú_load_adapter_into_lora_modelrY   Z   sÄ  € õ  *Ý2Ý-Ý:à%.×%<Ñ%<¸VÓ%DÑ"ÐØÑÙ#“~ˆà×1Ñ1Ó1à%×5Ò5Øð
à"7Øñ
ð %ñ	
Ðð +0ÐÔ'Ø/?×Ñ˜|Ñ,Ø×!Ñ! *×"2Ñ"2°LÔAá'¨Ðu¸ÑuÐ^tÑu€OØÐà"×'Ñ'Ö)ˆØˆà—>‘> (×+Ñ+°C·N±NÀ>×4RÑ4RØ�c—h‘h˜s“m aÑ'Ð)Ð*ˆCð —>‘> (×+Ó+°C·N±NÀ>×4RÓ4Rð ˜‰nˆØ#2°7Ñ#;Ð˜CÓ ñ *ð %Ÿj™jÐ)BÀEÓJÐÜ+ØØØ!Ø 7ñ	€Kô ˆ;×&Ñ&Ó'¨!Ó+ÜØcÐdo×dÑdð  dAð  Bó
ð 	
ô ˆzÐ0×1Ñ1Ø×&Ñ&°LÐ&Òpð 2r0   c                  ó"  ^ • \ rS rSrSr   S             SS jjrS rS r\S 5       r	SU 4S jjr
\S 5       r SS	 jr SS
 jr SS jrS r\S 5       rS rSS jrSS jrS S jrS!S jrS"S jrS#S jrS rS rS rS$S jrSrU =r$ )%Ú
XLoraModeléœ   a•  
Creates an X-LoRA (Mixture of LoRA experts), model from a pretrained transformers model. Currently, this X-LoRA
implementation only works with models with a transformer architecture.

The method is described in detail in https://huggingface.co/papers/2402.07148.

Args:
    model ([`torch.nn.Module`]): The model to be adapted.
    config ([`XLoraConfig`]): The configuration of the Lora model.
    adapter_name (`str`): The name of the adapter, does not affect the LoRA adapter names.

Returns:
    `torch.nn.Module`: The X-LoRA model.

Example:
    ```py
    >>> from transformers import AutoModelForCausalLM, AutoConfig, BitsAndBytesConfig
    >>> from peft import LoraConfig, PeftModel, get_peft_model, prepare_model_for_kbit_training

    >>> model_config = AutoConfig.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1")
    >>> config = XLoraConfig(
    ...     task_type="CAUSAL_LM",
    ...     hidden_size=model_config.hidden_size,
    ...     xlora_depth=4,
    ...     adapters={
    ...         "adapter_1": "./path/to/the/checkpoint/",
    ...         "adapter_2": "./path/to/the/checkpoint/",
    ...         "adapter_n": "./path/to/the/checkpoint/",
    ...     },
    ... )
    >>> int8_config = BitsAndBytesConfig(load_in_8bit=True)
    >>> model = AutoModelForCausalLM.from_pretrained(
    ...     "mistralai/Mistral-7B-Instruct-v0.1",
    ...     trust_remote_code=True,
    ...     attn_implementation="flash_attention_2",
    ...     device_map="cuda:0",
    ...     torch_dtype=torch.bfloat16,
    ...     quantization_config=int8_config,
    ... )
    >>> model = prepare_model_for_kbit_training(4)
    >>> xlora_model = get_peft_model(model, config)
    ```
c                óô  • [         R                  R                  U 5        [        U[        5      (       a  X#   nOUn[
        R
                  " U5      n	[        U	l        SU	l        SU	l	        [        XU5      n
X€l        X l        Un[        UR                  S5      (       a&  UR                  R                  (       a  [!        S5      eUR"                  R%                  5       n[        U R                  S5      (       a9  ['        UR"                  R%                  5       U R                  R(                  5      nOUR"                  R%                  5       n[        U R                  S5      (       a?  [+        U5       H/  u  nu  pïn[-        SU R                  [/        U5      UUUUUS.UD6  M1     O=[+        U5       H.  u  nu  pï[-        SU R                  [/        U5      UUUUSS.UD6  M0     U R                  R1                  [3        UR"                  R5                  5       5      5        U R7                  5         [9        UU U5      u  nn[;        UR"                  5      n[=        XUUU5      nUU l        SU l         SU l!        g)	aƒ  
Create a new X-LoRA model

Args:
    model (`nn.Module`):
        Base model to apply X-LoRA to.
    config: ([`XLoraConfig`]):
        X-LoRA configuration object.
    adapter_name: (`str`):
        Adapter name for the X-LoRA adapter.
    torch_device (`str`, *optional*, defaults to None):
        (For loading the LoRA adapters) The device to load the adapter on. If `None`, the device will be
        inferred.
    ephemeral_gpu_offload (`bool`, *optional*, defaults to `False`):
        (For loading the LoRA adapters) Whether to use ephemeral GPU offloading for partially loaded modules.
        Defaults to `False`.
    autocast_adapter_dtype (`bool`, *optional*, defaults to `True`):
        (For loading the LoRA adapters) Whether to autocast the adapter dtype. Defaults to `True`. Right now,
        this will only cast adapter weights using float16 and bfloat16 to float32, as this is typically
        required for stable training, and only affect select PEFT tuners.
    kwargs: (`optional`):
        (For loading the LoRA adapters) Additional arguments to modify the way the adapter is loaded, e.g. the
        token for Hugging Face Hub.
NÚnoneÚ	use_cachez`use_cache` must be FalseÚ_subfolders)rN   r:   rO   rP   r6   r<   r7   F© )"ÚnnÚModuleÚ__init__r   ÚdictÚcopyr   Útarget_modulesÚlayer_replicationÚbiasr	   Úxlora_configrN   rM   r   r_   rL   ÚadaptersÚitemsÚzipr`   Ú	enumeraterY   ÚstrÚset_adapterÚlistrF   Ú_maybe_freeze_all_adaptersr/   rJ   r   Úinternal_xlora_classifierÚinternal_xlora_scalingsÚdisabled)Úselfr   r   r:   rP   r6   r<   rQ   ÚconfÚbase_lora_configrN   rB   Úadapters_itemsÚiÚ_adapter_namerO   r7   r*   r"   Ú	n_classesÚxlora_classifiers                        r.   rd   ÚXLoraModel.__init__É   s;  € ôF 	�	‰	×Ñ˜4Ô ä�fœd×#Ñ#ØÑ'‰DàˆDô  Ÿ9š9 T›?ÐÜ*>ÐÔ'à-1ÐÔ*Ø &ÐÔÜ˜u¸ÓEˆ
à ÔØ$Œàˆä�5—<‘< ×-Ñ-°%·,±,×2H×2HÜÐ8Ó9Ð9à$×-Ñ-×3Ñ3Ó5ˆÜ�4×$Ñ$ m×4Ñ4Ü  ×!5Ñ!5×!;Ñ!;Ó!=¸t×?PÑ?P×?\Ñ?\Ó]‰Nà(×1Ñ1×7Ñ7Ó9ˆNä�4×$Ñ$ m×4Ñ4Ü;DÀ^Ö;TÑ7�Ñ,�M¨iÜ-ð 	Ø#Ÿ™Ü!$ Q£Ø%Ø!-Ø*?Ø+AØ'ñ	ð ô	ò <Uô 1:¸.Ö0IÑ,�Ñ,�MÜ-ð 	Ø#Ÿ™Ü!$ Q£Ø%Ø!-Ø*?Ø+AØ"ñ	ð ô	ñ 1Jð 	�‰×#Ñ#¤D¨×)=Ñ)=×)BÑ)BÓ)DÓ$EÔFà×'Ñ'Ô)ä 7ØØØó!
Ñˆ�vô ˜×,Ñ,Ó-ˆ	Ü*¨5¸yÈ-ÐY_Ó`Ðð *:ˆÔ&Ø'+ˆÔ$àˆ�r0   c                ó¬   • U R                  5         U R                  R                  (       d)  U R                  5        H  u  pSU;   d  M  SUl        M     g g )NÚlora_F)Úevalrj   Úuse_trainable_adaptersÚnamed_parametersÚrequires_grad)rv   ÚnameÚparams      r.   rr   Ú%XLoraModel._maybe_freeze_all_adapters5  sC   € Ø�	‰	ŒØ× Ñ ×7×7Ø#×4Ñ4Ö6‘�Ø˜d•?Ø*/�EÖ'ò  7ð 8r0   c                óh   • SUS'   U R                   R                  " U0 UD6nU R                  5         U$ )NFr_   )rN   Úgeneraterr   )rv   ÚargsrQ   Úress       r.   r‰   ÚXLoraModel.generate<  s6   € Ø#ˆˆ{ÑØ�o‰o×&Ò&¨Ð7°Ñ7ˆà×'Ñ'Ô)Øˆ
r0   c              /  ó–  ^ ^^#   • S m/ mUUU 4S jnT R                   (       d$  T R                  R                  R                  USS9n S v •  T R                   (       d*  T H  nUR	                  5         M     WR	                  5         g g ! T R                   (       d*  T H  nUR	                  5         M     WR	                  5         f f = f7f)Nc                ó   • X2S'   X4$ )NÚscalingsra   )r   rŠ   rQ   r�   s       r.   Úscalings_injection_hookÚFXLoraModel._enable_peft_forward_hooks.<locals>.scalings_injection_hookE  s   € à!)�:ÑØ�<Ðr0   c                óz  >• US   nUS   nUR                  U5        TR                  R                  " U0 UD6nTR                  5        H|  n [	        U [
        5      (       d  M  [        TUS9n[        U S0 5      n[        U4S jUR                  5        5       5      (       a  M[  U R                  USS9nTR                  U5        M~     [        R                  " 5          TR                  R                  5          UR!                  5       n	SU	S'   SU	S	'    TR                  R"                  R$                  " U0 U	D6n
T H  nUR'                  5         M      TR                  R)                  5          S S S 5        TR                  " US
W
0UD6nUTl        / mTR                  5        HE  n [	        U [
        5      (       d  M  [        TUS9nU R                  USS9nTR                  U5        MG     g ! T H  nUR'                  5         M     f = f! TR                  R)                  5         f = f! , (       d  f       NÂ= f)Nr   r   )r�   Ú_forward_pre_hooksc              3  ó*   >#   • U  H  oTL v •  M
     g 7f©Nra   )Ú.0Úvalr�   s     €r.   Ú	<genexpr>ÚNXLoraModel._enable_peft_forward_hooks.<locals>._pre_forward.<locals>.<genexpr>Z  s   øé € Ð]ÒE\¸cÐ"9Õ9ÒE\ùs   ƒT©Úwith_kwargsÚoutput_hidden_statesÚreturn_dictÚresult)Úupdaters   Úmake_dummy_scalingsr   r   r   r   ÚgetattrÚanyÚvaluesÚregister_forward_pre_hookr$   ÚtorchÚno_gradrN   Údisable_adapter_layersrf   r   r#   ÚremoveÚenable_adapter_layersrt   )r,   rŠ   rQ   Ú	args_realÚkwargs_realÚdummy_scalingsÚpre_forwardÚexisting_hooksÚhandleÚscaling_pass_kwargsÚbase_outputÚxlora_scalingsÚhook_handlesr�   rv   s               €€€r.   Ú_pre_forwardÚ;XLoraModel._enable_peft_forward_hooks.<locals>._pre_forwardL  s  ø€ ð ˜Q™ˆIØ˜q™'ˆKØ×Ñ˜vÔ&à!×;Ñ;×OÒOÐQZÐjÐ^iÑjˆNàŸ,™,ž.�Ü˜f¤i×0Ó0Ü")Ð*AÈNÑ"[�KÜ%,¨VÐ5IÈ2Ó%N�NÜÔ]À^×EZÑEZÔE\Ó]×]Ñ]ñ !Ø#×=Ñ=¸kÐW[Ð=Ð\�FØ ×'Ñ'¨Ö/ñ )ô —’•Ø—‘×6Ñ6Ô8ð<Ø*5×*:Ñ*:Ó*<Ð'ØBFÐ'Ð(>Ñ?Ø9=Ð'¨Ñ6ð,Ø&*§o¡o×&;Ñ&;×&CÒ&CÀYÐ&fÐReÑ&f˜ó '3˜FØ"ŸM™MžOò '3ð —O‘O×9Ñ9Õ;÷ !ð  "×;Ò;ÐQZÐjÀ;ÐjÐ^iÑjˆNà+9ˆDÔ(ð ˆLØŸ,™,ž.�Ü˜f¤i×0Ó0Ü")Ð*AÈNÑ"[�KØ#×=Ñ=¸kÐW[Ð=Ð\�FØ ×'Ñ'¨Ö/ò	 )øó '3˜FØ"ŸM™MžOò '3ûð —O‘O×9Ñ9Õ;ú÷ !•ús<   ÃH,Ã:HÄ&G/Ä;HÅH,Ç/H
È
HÈH)È)H,È,
H:Trš   )ru   rN   r   r¤   r¨   )rv   Úgenerate_argsÚgenerate_kwargsr´   Úforward_handler¯   r³   r�   s   `     @@r.   Ú_enable_peft_forward_hooksÚ%XLoraModel._enable_peft_forward_hooksC  sŸ   úé € ò	 ð
 ˆ÷1	0ðf �}�}Ø!Ÿ_™_×2Ñ2×LÑLÈ\ÐgkÐLÐlˆNð	(Ûà—=—=Û*�FØ—M‘M–Oñ +à×%Ñ%Õ'ð !ø�4—=—=Û*�FØ—M‘M–Oñ +à×%Ñ%Õ'ð !üs   …AC	Á	B	 Á<C	Â	=CÃC	c                ó~   >•  [         TU ]  U5      $ ! [         a     US:X  a  e [        U R                  U5      s $ f = f)z1Forward missing attributes to the wrapped module.rN   )ÚsuperÚ__getattr__ÚAttributeErrorr¡   rN   )rv   r…   Ú	__class__s     €r.   r½   ÚXLoraModel.__getattr__‹  sC   ø€ ð	2Ü‘7Ñ& tÓ,Ð,øÜó 	2Ø�|Ó#ØÜ˜4Ÿ?™?¨DÓ1Ò1ð	2ús   ƒ ’'<»<c                ó   • U $ r•   ra   )rB   Ú_model_configs     r.   Ú_prepare_adapter_configÚ"XLoraModel._prepare_adapter_config”  s
   € ð Ðr0   c                ó   • g r•   ra   ©rv   s    r.   Ú _mark_only_adapters_as_trainableÚ+XLoraModel._mark_only_adapters_as_trainable�  s   € ¸r0   c                ó   • SU l         g ©NF©ru   rÆ   s    r.   r©   Ú XLoraModel.enable_adapter_layers£  s	   € Øˆ�r0   c                ó   • SU l         g )NTrË   rÆ   s    r.   r§   Ú!XLoraModel.disable_adapter_layersª  s	   € Øˆ�r0   c                ó   • g r•   ra   )rv   Úlora_configr:   r   Útarget_nameÚparentÚcurrent_keys          r.   Ú_create_and_replaceÚXLoraModel._create_and_replace­  s   € ð 	r0   c                ó   • grÊ   ra   )rÐ   rW   s     r.   Ú_check_target_module_existsÚ&XLoraModel._check_target_module_exists¹  s   € ð r0   c                ó:   • U R                   R                  " U0 UD6$ r•   )rN   r   )rv   rŠ   rQ   s      r.   r#   ÚXLoraModel.forward¾  s   € Ø�‰×$Ò$ dÐ5¨fÑ5Ð5r0   c                ó<   • U R                   nXR                  l        g)z’
Sparsely select the specified top_k LoRA experts instead of the default dense method. Set to None to use dense.
This is reflected in the config.
N)rs   r   Ú
top_k_lora©rv   ÚvalueÚ
classifiers      r.   Úset_topk_loraÚXLoraModel.set_topk_loraÁ  s   € ð
 '+×&DÑ&Dˆ
Ø',×ÑÕ$r0   c                ó<   • U R                   nXR                  l        g)z�
Set the global LoRA weight, a scalar to multiply the output of each LoRA adapter by. This is by default 1. This
is reflected in the config.
N©rs   r   Úglobal_scaling_weight)rv   r!   rß   s      r.   Úset_global_scaling_weightÚ$XLoraModel.set_global_scaling_weightÉ  s   € ð
 '+×&DÑ&Dˆ
Ø28×ÑÕ/r0   c                ó>   • U R                   nUR                  U5        g)z³
Set the scaling pass value, the value to set the scalings to during the scaling pass. If the value is None, the
scaling pass value will be 1/n where n is the number of adapters.
N)rs   Ú _set_override_scaling_pass_valuerÝ   s      r.   Úset_scaling_pass_valueÚ!XLoraModel.set_scaling_pass_valueÑ  s   € ð
 '+×&DÑ&Dˆ
Ø×3Ñ3°EÕ:r0   c                óF   • U R                   nUR                  R                  $ )z
Get the global LoRA weight.
rã   ©rv   rß   s     r.   Úget_global_scaling_weightÚ$XLoraModel.get_global_scaling_weightÙ  s!   € ð '+×&DÑ&Dˆ
Ø× Ñ ×6Ñ6Ð6r0   c                ó   • U R                   $ )z˜
Returns the latest scalings prediction, or None if no scalings have been predicted. The tensor is of shape
(batch_size, seq_len, n_layers, n_classes).
)rt   rÆ   s    r.   Úget_latest_scalingsÚXLoraModel.get_latest_scalingsà  s   € ð
 ×+Ñ+Ð+r0   c                óN   • U R                   nUR                  R                  5       $ )a  
Returns a shallow (only copying the list itself not the tensors) copy of the list containing the scalings log.
Editing the list does not change the underlying log. The tensors are of shape (batch_size, seq_len, n_layers,
n_classes). The seq_len dim may vary with input dimension.
)rs   Úlog_scalingsrf   rì   s     r.   Úget_scalings_logÚXLoraModel.get_scalings_logç  s$   € ð '+×&DÑ&Dˆ
Ø×&Ñ&×+Ñ+Ó-Ð-r0   c                ó*   • U R                   nSUl        g)z
Enable scalings logging.
TN©rs   Úscalings_loggingrì   s     r.   Úenable_scalings_loggingÚ"XLoraModel.enable_scalings_loggingð  s   € ð '+×&DÑ&Dˆ
Ø&*ˆ
Õ#r0   c                ó*   • U R                   nSUl        g)z5
Disable scalings logging, without clearing the log.
FNr÷   rì   s     r.   Údisable_scalings_loggingÚ#XLoraModel.disable_scalings_logging÷  s   € ð '+×&DÑ&Dˆ
Ø&+ˆ
Õ#r0   c                óP   • U R                   nUR                  R                  5         g)z
Clear the scalings log.
N)rs   ró   Úclearrì   s     r.   Úclear_scalings_logÚXLoraModel.clear_scalings_logþ  s!   € ð '+×&DÑ&Dˆ
Ø×Ñ×%Ñ%Õ'r0   c                ó:   • U R                   nUR                  5       $ )zÝ
Returns bucketed scalings, bucketed by seq_len. Each value consists of the positions (the first) and the
associated tensors. The positions are paired with the associated tensors and give the position in the scaling
log.
)rs   Ú_get_bucketed_scalingsrì   s     r.   Úget_bucketed_scalings_logÚ$XLoraModel.get_bucketed_scalings_log  s   € ð '+×&DÑ&Dˆ
Ø×0Ñ0Ó2Ð2r0   )ru   rs   rt   rN   rj   )NFT)r   ú	nn.Moduler   z*Union[dict[str, XLoraConfig], XLoraConfig]r:   ro   rP   úOptional[str]r6   Úboolr<   r  ÚreturnÚNone)r…   ro   )r	  r
  )rÞ   zOptional[int])r!   Úfloat)rÞ   zfloat | None)r	  r  )r	  zOptional[torch.Tensor])r	  zlist[torch.Tensor])r	  z/dict[int, tuple[list[int], list[torch.Tensor]]])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rd   rr   r‰   r   r¹   r½   ÚstaticmethodrÃ   rÇ   r©   r§   rÔ   r×   r#   rà   rå   ré   rí   rð   rô   rù   rü   r   r  Ú__static_attributes__Ú__classcell__)r¿   s   @r.   r[   r[   œ   s  ø† ñ*ðb '+Ø&+Ø'+ðjàðjð ;ðjð ð	jð
 $ðjð  $ðjð !%ðjð 
õjòX0òð ñE(ó ðE(÷N2ð ñó ððô <ðôðôò
ð ñó ðò6ô-ô9ô;ô7ô,ô.ò+ò,ò(÷3ò 3r0   r[   )r(   r  r)   r  r   r   r	  ztuple[int, torch.device | None])NFTN)rN   r	   r:   ro   rO   ro   rP   r  r6   r  r<   r  r7   r  )$Ú
__future__r   rf   Ú
contextlibr   Ú	functoolsr   Útypingr   r   r¥   Útorch.nnrb   Úpeft.tuners.lora.layerr   Úpeft.tuners.lora.modelr	   Úpeft.tuners.tuners_utilsr
   Úpeft.utils.constantsr   r@   r   Ú r   rß   r   r   r   Úlayerr   r   r   r/   rY   r[   ra   r0   r.   Ú<module>r     sÐ   ðõ #ã Ý %Ý ß "ã Ý å ,Ý ,Ý .Ý 5Ý >å Ý 'Ý ß JÑ Jð3#Ø
ð3#àð3#ð ð3#ð %ô	3#ðt #'Ø"'Ø#'Ø#ð?qØð?qàð?qð ð?qð  ð	?qð
  ð?qð !ð?qð õ?qôDp3�õ p3r0   