§
    ‚Š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	 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)Ú
SpQRConfig)Úreplace_with_spqr_linear)Úis_accelerate_availableÚis_spqr_availableÚis_torch_availableÚlogging)ÚQuantizationConfigMixinNc                   ón   ‡ — e Zd ZU dZdZded<   defˆ fd„Zd„ Zdd
„Z		 	 dd„Z
ed„ ¦   «         Zd„ Zˆ xZS )ÚSpQRHfQuantizerzS
    Quantizer of the SpQR 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_spqr.pyr   zSpQRHfQuantizer.__init__*   s)   ø€ Ø�‰ŒÔÐ,Ð7Ð7°Ð7Ð7Ð7Ð7Ð7ó    c                 óÔ   — t           j                             ¦   «         st          d¦  «        ‚t	          ¦   «         st          d¦  «        ‚t          ¦   «         st          d¦  «        ‚d S )Nz,GPU is required to run SpQR quantized model.zGUsing `spqr` quantization requires Accelerate: `pip install accelerate`zFUsing `spqr` quantization requires SpQR: `pip install spqr_quant[gpu]`)ÚtorchÚcudaÚis_availableÚRuntimeErrorr
   ÚImportErrorr   )r   Úargsr   s      r   Úvalidate_environmentz$SpQRHfQuantizer.validate_environment-   sp   € ÝŒz×&Ò&Ñ(Ô(ð 	OÝÐMÑNÔNÐNå&Ñ(Ô(ð 	iÝÐgÑhÔhÐhå Ñ"Ô"ð 	hÝÐfÑgÔgÐgð	hð 	hr   Údtypeútorch.dtypeÚreturnc                 óD   — |t           j        k    rt          d¦  «        ‚|S )NzdYou cannot use any type other than torch.float16 for SpQR. Please set it totorch.float16 explicitly.)r   Úfloat16Ú
ValueError)r   r"   s     r   Úupdate_dtypezSpQRHfQuantizer.update_dtype7   s+   € Ø•E”MÒ!Ð!ÝØvñô ð ð ˆr   Úmodelr   c                 ó”   — |                       || j        j        |j        ¦  «        | _        t	          || j        | j        ¬¦  «         d S )N)r   Úmodules_to_not_convert)Úget_modules_to_not_convertr   r+   Ú_keep_in_fp32_modulesr	   )r   r)   r   s      r   Ú$_process_model_before_weight_loadingz4SpQRHfQuantizer._process_model_before_weight_loading>   s^   € ð
 '+×&EÒ&EØ�4Ô+ÔBÀEÔD_ñ'
ô '
ˆÔ#õ 	!ØØ $Ô 8Ø#'Ô#>ð	
ñ 	
ô 	
ð 	
ð 	
ð 	
r   c                 ó   — dS )NF© ©r   s    r   Úis_trainablezSpQRHfQuantizer.is_trainableL   s   € àˆur   c                 ó   — dS )NTr0   r1   s    r   Úis_serializablezSpQRHfQuantizer.is_serializableP   s   € Øˆtr   )r"   r#   r$   r#   )r)   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úrequires_calibrationÚ__annotations__r   r   r!   r(   r.   Úpropertyr2   r4   Ú__classcell__)r   s   @r   r   r   "   sÑ   ø€ € € € € € ðð ð  ÐØ%Ð%Ð%Ñ%ð8Ð,Cð 8ð 8ð 8ð 8ð 8ð 8ðhð hð hðð ð ð ð
à ð
ð 
ð 
ð 
ð ðð ñ „Xððð ð ð ð ð ð r   r   )Útypingr   Úbaser   Úmodeling_utilsr   Úutils.quantization_configr   Úintegrationsr	   Úutilsr
   r   r   r   r   r   Ú
get_loggerr5   Úloggerr   r0   r   r   ú<module>rE      s  ðð !Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð ð ð 7Ø0Ð0Ð0Ð0Ð0Ð0Ø6Ð6Ð6Ð6Ð6Ð6à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?ð ÐÑÔð Ø€L€L€Là	ˆÔ	˜HÑ	%Ô	%€ð/ð /ð /ð /ð /�kñ /ô /ð /ð /ð /r   