Ë
    HêñiÍ	  ã                   ó¬   — d dl mZ ddlmZ erddlmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZ  e
«       rd d	lZ ej                  e«      Z G d
„ de«      Zy	)é    )ÚTYPE_CHECKINGé   )ÚHfQuantizeré   )ÚPreTrainedModel)Ú
VptqConfig)Úis_accelerate_availableÚis_torch_availableÚis_vptq_availableÚlogging)ÚQuantizationConfigMixinNc                   óf   ‡ — e Zd ZU dZdZded<   defˆ fd„Zd„ Z	 	 dd„Z	e
defd	„«       Zd
„ Zˆ xZS )ÚVptqHfQuantizerzS
    Quantizer of the VPTQ method. Enables the loading of prequantized models.
    Tr   Úquantization_configc                 ó&   •— t        ‰| �  |fi |¤Ž y )N)ÚsuperÚ__init__)Úselfr   ÚkwargsÚ	__class__s      €úh/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/transformers/quantizers/quantizer_vptq.pyr   zVptqHfQuantizer.__init__)   s   ø€ Ü‰ÑÐ,Ñ7°Ó7ó    c                 óª   — t        «       st        d«      ‚t        «       st        d«      ‚t        j                  j                  «       st        d«      ‚y )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_environmentz$VptqHfQuantizer.validate_environment,   sG   € Ü&Ô(ÜÐgÓhÐhä Ô"ÜÐeÓfÐfä�z‰z×&Ñ&Ô(ÜÐMÓNÐNð )r   c                 óº   — ddl m} | j                  || j                  j                  |j
                  «      | _         ||| j                  | j                  ¬«       y )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_loadingz4VptqHfQuantizer._process_model_before_weight_loading6   sR   € õ
 	<à&*×&EÑ&EØ�4×+Ñ+×BÑBÀE×D_ÑD_ó'
ˆÔ#ñ 	!ØØ $× 8Ñ 8Ø#'×#>Ñ#>ö	
r   Úreturnc                  ó   — y)NF© ©r   s    r   Úis_trainablezVptqHfQuantizer.is_trainableF   s   € àr   c                  ó   — y)NTr+   r,   s    r   Úis_serializablezVptqHfQuantizer.is_serializableJ   s   € Ør   )r'   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úrequires_calibrationÚ__annotations__r   r   r    r(   ÚpropertyÚboolr-   r/   Ú__classcell__)r   s   @r   r   r   !   sV   ø… ñð  ÐØ%Ó%ð8Ð,Cõ 8òOð
à ó
ð  ð˜dò ó ðör   r   )Útypingr   Úbaser   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   r   r   r   r   Ú
get_loggerr0   Úloggerr   r+   r   r   ú<module>r@      sJ   ðõ !å ñ Ý0Ý6ç [Ó [Ý ?ñ ÔÛà	ˆ×	Ñ	˜HÓ	%€ô*�kõ *r   