ó
    qyüiÍ	  ã                   óÀ   • S SK Jr  SSKJr  \(       a  SSKJr  SSKJr  SSKJ	r	J
r
JrJr  SSKJr  \
" 5       (       a  S S	Kr\R                  " \5      r " S
 S\5      rg	)é    )ÚTYPE_CHECKINGé   )ÚHfQuantizeré   )ÚPreTrainedModel)Ú
VptqConfig)Úis_accelerate_availableÚis_torch_availableÚis_vptq_availableÚlogging)ÚQuantizationConfigMixinNc                   óv   ^ • \ rS rSr% SrSrS\S'   S\4U 4S jjrS r	  SS jr
\S	\4S
 j5       rS rSrU =r$ )ÚVptqHfQuantizeré!   zK
Quantizer of the VPTQ method. Enables the loading of prequantized models.
Tr   Úquantization_configc                 ó(   >• [         TU ]  " U40 UD6  g )N)ÚsuperÚ__init__)Úselfr   ÚkwargsÚ	__class__s      €Úc/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/quantizers/quantizer_vptq.pyr   ÚVptqHfQuantizer.__init__)   s   ø€ Ü‰ÒÐ,Ñ7°Ó7ó    c                 óÈ   • [        5       (       d  [        S5      e[        5       (       d  [        S5      e[        R                  R                  5       (       d  [        S5      eg )NzGUsing `vptq` quantization requires Accelerate: `pip install accelerate`zEUsing `vptq` quantization requires VPTQ>=0.0.4: `pip install -U vptq`z,GPU is required to run VTPQ quantized model.)r	   ÚImportErrorr   ÚtorchÚcudaÚis_availableÚRuntimeError)r   Úargsr   s      r   Úvalidate_environmentÚ$VptqHfQuantizer.validate_environment,   sP   € Ü&×(Ñ(ÜÐgÓhÐhä ×"Ñ"ÜÐeÓfÐfä�z‰z×&Ñ&×(Ñ(ÜÐMÓNÐNð )r   c                 ó²   • SSK Jn  U R                  XR                  R                  UR
                  5      U l        U" UU R                  U R                  S9  g )Nr   )Úreplace_with_vptq_linear)r   Úmodules_to_not_convert)Úintegrationsr%   Úget_modules_to_not_convertr   r&   Ú_keep_in_fp32_modules)r   Úmodelr   r%   s       r   Ú$_process_model_before_weight_loadingÚ4VptqHfQuantizer._process_model_before_weight_loading6   sP   € õ
 	<à&*×&EÑ&EØ×+Ñ+×BÑBÀE×D_ÑD_ó'
ˆÔ#ñ 	!ØØ $× 8Ñ 8Ø#'×#>Ñ#>ó	
r   Úreturnc                 ó   • g)NF© ©r   s    r   Úis_trainableÚVptqHfQuantizer.is_trainableF   s   € àr   c                 ó   • g)NTr/   r0   s    r   Úis_serializableÚVptqHfQuantizer.is_serializableJ   s   € Ør   )r&   )r*   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_calibrationÚ__annotations__r   r   r"   r+   ÚpropertyÚboolr1   r4   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r   !   s[   ø‡ ñð  ÐØ%Ó%ð8Ð,C÷ 8òOð
à ô
ð  ð˜dó ó ð÷ð r   r   )Útypingr   Úbaser   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   r   r   r   r   Ú
get_loggerr6   Úloggerr   r/   r   r   Ú<module>rH      sK   ðõ !å ö Ý0Ý6ç [Ó [Ý ?ñ ×ÑÛà	×	Ò	˜HÓ	%€ô*�kõ *r   