
    }-jV
                         d dl mZ d dlmZ 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 ddl
mZ  ej        e          Z G d de          ZdS )    )metadata)TYPE_CHECKING)version   )HfQuantizer   )PreTrainedModel)
AqlmConfig)replace_with_aqlm_linear)is_accelerate_availableis_aqlm_availablelogging)QuantizationConfigMixinc                   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 )AqlmHfQuantizerzS
    Quantizer of the AQLM method. Enables the loading of prequantized models.
    Tr
   quantization_configc                 <     t                      j        |fi | d S )N)super__init__)selfr   kwargs	__class__s      f/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/transformers/quantizers/quantizer_aqlm.pyr   zAqlmHfQuantizer.__init__*   s)    ,7777777    c                 z    t                      st          d          t                      st          d          d S )NzGUsing `aqlm` quantization requires Accelerate: `pip install accelerate`zDUsing `aqlm` quantization requires AQLM: `pip install aqlm[gpu,cpu]`)r   ImportErrorr   )r   argsr   s      r   validate_environmentz$AqlmHfQuantizer.validate_environment-   sJ    &(( 	ighhh "" 	fdeee	f 	fr   modelr	   c                 H    t          || j        j        | j                   d S )N)modules_to_not_convertr   )r   r   linear_weights_not_to_quantize)r   r   r   s      r   $_process_model_before_weight_loadingz4AqlmHfQuantizer._process_model_before_weight_loading4   s7    
 	!#'#;#Z $ 8	
 	
 	
 	
 	
 	
r   returnc                     t          j        t          j         d                    t          j        d          k    }|rdS t                              dt          j         d           d           dS )Naqlmz1.0.2Tz$Currently installed `aqlm` version (zw) doesn't support training. If you wish to train a quantized model, please update `aqlm` with `pip install aqlm>=1.0.2`F)r   parser   loggerwarning)r   aqlm_supports_trainings     r   is_trainablezAqlmHfQuantizer.is_trainable?   s|    !(x/?/G/G!H!HGMZaLbLb!b! 	4NN Ix7G7O7O  I  I  I   5r   c                     dS )NT )r   s    r   is_serializablezAqlmHfQuantizer.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f f f	
 	
 	
 	
 	
 d    X      r   r   N)	importlibr   typingr   	packagingr   baser   modeling_utilsr	   utils.quantization_configr
   integrationsr   utilsr   r   r   r   
get_loggerr/   r(   r   r-   r   r   <module>rA      s                                  7000000666666 3 3 3 3 3 3 G G G G G G G G G G ? ? ? ? ? ? 
	H	%	%) ) ) ) )k ) ) ) ) )r   