Ë
    S^(h¸  ã                   óJ   — d Z ddlmZmZmZmZ  e«       rddlmZ 	 	 	 	 dd„Zy)z?AQLM (Additive Quantization of Language Model) integration fileé   )ÚACCELERATE_MIN_VERSIONÚis_accelerate_availableÚis_aqlm_availableÚis_torch_availableé    Nc                 ó`  — t        «       st        d«      ‚t        «       st        dt        › d�«      ‚|€g }ddlm} ddlm} | j                  «       D �]I  \  }}|€g }|j                  |«       t        |t        j                  «      rËdj                  |«      d	z   |vrµ |«       5  |j                  }	|j                  }
 ||	|
|j                   du|j"                  |j$                  |j&                  |j(                  ¬
«      | j*                  |<   d}t-        |«      | j*                  |   _        | j*                  |   j1                  d«       ddd«       t3        t5        |j7                  «       «      «      dkD  rt9        |||||¬«      \  }}|j;                  d«       �ŒL | |fS # 1 sw Y   ŒYxY w)ao  
    Public method that recursively replaces the Linear layers of the given model with AQLM quantized layers.
    `accelerate` is needed to use this method. Returns the converted model and a boolean that indicates if the
    conversion has been successfull or not.

    Args:
        model (`torch.nn.Module`):
            The model to convert, can be any `torch.nn.Module` instance.
        quantization_config (`AqlmConfig`):
            The quantization config object that contains the quantization parameters.
        linear_weights_not_to_quantize (`list[str]`, *optional*):
            A list of nn.Linear weights to not convert. If a parameter path is in the list (e.g. `lm_head.weight`), the corresponding module will not be
            converted.
        current_key_name (`list`, *optional*):
            A list that contains the current key name. This is used for recursion and should not be passed by the user.
        has_been_replaced (`bool`, *optional*):
            A boolean that indicates if the conversion has been successful or not. This is used for recursion and
            should not be passed by the user.
    zIAQLM is not available. Please install it with `pip install aqlm[cpu,gpu]`zDAQLM requires Accelerate to be installed: `pip install 'accelerate>=z'`Nr   )Úinit_empty_weights)ÚQuantizedLinearú.z.weight)ÚbiasÚin_group_sizeÚout_group_sizeÚnum_codebooksÚnbits_per_codebookTF)Úquantization_configÚlinear_weights_not_to_quantizeÚcurrent_key_nameÚhas_been_replacedéÿÿÿÿ)r   Ú
ValueErrorr   r   Ú
accelerater	   Úaqlmr
   Únamed_childrenÚappendÚ
isinstanceÚnnÚLinearÚjoinÚin_featuresÚout_featuresr   r   r   r   r   Ú_modulesÚtypeÚ
source_clsÚrequires_grad_ÚlenÚlistÚchildrenÚreplace_with_aqlm_linearÚpop)Úmodelr   r   r   r   r	   r
   ÚnameÚmoduler   r    Ú_s               ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/integrations/aqlm.pyr(   r(      s²  € ô4 ÔÜÐdÓeÐeä"Ô$ÜØRÔSiÐRjÐjlÐmó
ð 	
ð &Ð-Ø)+Ð&å-Ý$à×,Ñ,Ó.ó $!‰ˆˆfØÐ#Ø!ÐØ×Ñ Ô%ä�fœbŸi™iÔ(à�x‰xÐ(Ó)¨IÑ5Ð=[Ñ[Ù'Ó)ñ ?Ø"(×"4Ñ"4�KØ#)×#6Ñ#6�Lá+:Ø#Ø$Ø#Ÿ[™[°Ð4Ø&9×&GÑ&GØ':×'IÑ'IØ&9×&GÑ&GØ+>×+QÑ+Qô,�E—N‘N 4Ñ(ð )-Ð%ô 7;¸6³l�E—N‘N 4Ñ(Ô3à—N‘N 4Ñ(×7Ñ7¸Ô>÷%?ô& Œt�F—O‘OÓ%Ó&Ó'¨!Ò+Ü#;ØØ$7Ø/MØ!1Ø"3ô$Ñ ˆAÐ ð 	×Ñ˜RÖ ðI$!ðJ Ð#Ð#Ð#÷;?ð ?ús   Â&B&F$Æ$F-	)NNNF)	Ú__doc__Úutilsr   r   r   r   Útorch.nnr   r(   © ó    r.   ú<module>r4      s0   ðñ Bç jÓ jñ ÔÝð
 Ø#'ØØôM$r3   