Ë
    ä©Ñh¼  ã                   ó<   — d Z ddlmZ ddlmZ ddlmZ 	 	 	 	 dd„Zy)z9VPTQ (Vector Post-Training Quantization) integration fileé    N)Úinit_empty_weights)ÚVQuantLinearc                 óF  — |r|ndg}| j                  «       D ]w  \  }}|€g }|j                  |«       dj                  |«      }|j                  }|j                  }	t        |t        j                  «      rÐ||vrÌ||	v s|d   |v rÁ|	j                  |d«      xs |j                  |d   d«      }
t        «       5  |j                  }|j                  }t        |||
d   |
d   |
d   |
d   |
d	   |
d
   |
d   |
d   |
d   dd|j                  du¬«      | j                  |<   d}| j                  |   j                  d«       ddd«       t!        t#        |j%                  «       «      «      dkD  rt'        |||||¬«      \  }}|j)                  d«       Œz | |fS # 1 sw Y   ŒYxY w)aw  
    Public method that recursively replaces the Linear layers of the given model with VPTQ quantized layers.
    `accelerate` is needed to use this method. Returns the converted model and a boolean that indicates if the
    conversion has been successful or not.

    Args:
        model (`torch.nn.Module`):
            The model to convert, can be any `torch.nn.Module` instance.
        quantization_config (`VptqConfig`):
            The quantization config object that contains the quantization parameters.
        modules_to_not_convert (`list[`str`]`, *optional*, defaults to `["lm_head"]`):
            Names of the modules to not convert in `VQuantLinear`. In practice we keep the `lm_head` in full precision
            for numerical stability reasons.
        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.
    Úlm_headNú.éÿÿÿÿÚvector_lensÚnum_centroidsÚnum_res_centroidsÚ	group_numÚ
group_sizeÚoutlier_sizeÚindices_as_floatÚenable_normÚenable_permTF)r	   r
   r   r   r   r   r   r   r   Úis_indice_packedÚenable_proxy_errorÚbiasr   )Úquantization_configÚmodules_to_not_convertÚcurrent_key_nameÚhas_been_replaced)Únamed_childrenÚappendÚjoinÚshared_layer_configÚconfig_for_layersÚ
isinstanceÚnnÚLinearÚgetr   Úin_featuresÚout_featuresr   r   Ú_modulesÚrequires_grad_ÚlenÚlistÚchildrenÚreplace_with_vptq_linearÚpop)Úmodelr   r   r   r   ÚnameÚmoduleÚ
layer_namer   r   Úlayer_paramsr"   r#   Ú_s                 ú\/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/transformers/integrations/vptq.pyr)   r)      sõ  € ñ6 8NÑ3ÐT]ÐS^Ðà×,Ñ,Ó.ó 2!‰ˆˆfØÐ#Ø!ÐØ×Ñ Ô%Ø—X‘XÐ.Ó/ˆ
Ø1×EÑEÐØ/×AÑAÐô vœrŸy™yÔ)ØÐ"8Ñ8ØÐ 1Ñ1Ð7GÈÑ7KÐObÑ7bà,×0Ñ0°¸TÓBò ÐFY×F]ÑF]Ø  Ñ$ dóGˆLô $Ó%ñ ;Ø$×0Ñ0Ø%×2Ñ2ä'3ØØ Ø ,¨]Ñ ;Ø".¨Ñ"?Ø&2Ð3FÑ&GØ*¨;Ñ7Ø+¨LÑ9Ø!-¨nÑ!=Ø%1Ð2DÑ%EØ ,¨]Ñ ;Ø ,¨]Ñ ;Ø%)Ø',ØŸ™¨DÐ0ô(—‘˜tÑ$ð  %)Ð!ð —‘˜tÑ$×3Ñ3°EÔ:÷/;ô0 ŒtF—O‘OÓ%Ó&Ó'¨!Ò+Ü#;ØØ$7Ø'=Ø!1Ø"3ô$Ñ ˆAÐ ð 	×Ñ˜RÖ ðe2!ðf Ð#Ð#Ð#÷E;ð ;ús   Â9BFÆF 	)NNNF)Ú__doc__Útorch.nnr   Ú
accelerater   Úvptqr   r)   © ó    r1   ú<module>r8      s'   ðñ <å Ý )Ý ð
 ØØØôP$r7   