§
    ‚ŠtjÍ	  ã                   ó¶   — 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d	S )é    )ÚTYPE_CHECKINGé   )ÚHfQuantizeré   )ÚPreTrainedModel)Ú
VptqConfig)Úis_accelerate_availableÚis_torch_availableÚis_vptq_availableÚlogging)ÚQuantizationConfigMixinNc                   ól   ‡ — 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          ¦   «         j        |fi |¤Ž d S )N)ÚsuperÚ__init__)Úselfr   ÚkwargsÚ	__class__s      €úd/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/quantizers/quantizer_vptq.pyr   zVptqHfQuantizer.__init__)   s)   ø€ Ø�‰ŒÔÐ,Ð7Ð7°Ð7Ð7Ð7Ð7Ð7ó    c                 óÔ   — t          ¦   «         st          d¦  «        ‚t          ¦   «         st          d¦  «        ‚t          j                             ¦   «         st          d¦  «        ‚d S )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,   sp   € Ý&Ñ(Ô(ð 	iÝÐgÑhÔhÐhå Ñ"Ô"ð 	gÝÐeÑfÔfÐfåŒz×&Ò&Ñ(Ô(ð 	OÝÐMÑNÔNÐNð	Oð 	Or   Úmodelr   c                 ó˜   — ddl m} |                      || j        j        |j        ¦  «        | _         ||| j        | j        ¬¦  «         d S )Nr   )Úreplace_with_vptq_linear)r   Úmodules_to_not_convert)Úintegrationsr#   Úget_modules_to_not_convertr   r$   Ú_keep_in_fp32_modules)r   r!   r   r#   s       r   Ú$_process_model_before_weight_loadingz4VptqHfQuantizer._process_model_before_weight_loading6   ss   € ð
 	<Ð;Ð;Ð;Ð;Ð;à&*×&EÒ&EØ�4Ô+ÔBÀEÔD_ñ'
ô '
ˆÔ#ð 	!Ð ØØ $Ô 8Ø#'Ô#>ð	
ñ 	
ô 	
ð 	
ð 	
ð 	
r   Úreturnc                 ó   — dS )NF© ©r   s    r   Úis_trainablezVptqHfQuantizer.is_trainableF   s   € àˆur   c                 ó   — dS )NTr+   r,   s    r   Úis_serializablezVptqHfQuantizer.is_serializableJ   s   € Øˆtr   )r!   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úrequires_calibrationÚ__annotations__r   r   r    r(   ÚpropertyÚboolr-   r/   Ú__classcell__)r   s   @r   r   r   !   sÉ   ø€ € € € € € ðð ð  ÐØ%Ð%Ð%Ñ%ð8Ð,Cð 8ð 8ð 8ð 8ð 8ð 8ðOð Oð Oð
à ð
ð 
ð 
ð 
ð  ð˜dð ð ð ñ „Xððð ð ð ð ð ð r   r   )Útypingr   Úbaser   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   r   r   r   r   Ú
get_loggerr0   Úloggerr   r+   r   r   ú<module>r@      sñ   ðð !Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð ð ð 7Ø0Ð0Ð0Ð0Ð0Ð0Ø6Ð6Ð6Ð6Ð6Ð6à [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?ð ÐÑÔð Ø€L€L€Là	ˆÔ	˜HÑ	%Ô	%€ð*ð *ð *ð *ð *�kñ *ô *ð *ð *ð *r   