
    fThK                         S SK JrJr  SSKJr  \(       a  SSKJr  SSK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Optional   )HfQuantizer   )PreTrainedModel)is_auto_round_availableis_torch_availablelogging)QuantizationConfigMixinNc                      ^  \ rS rSrSrSrS/rS\4U 4S jjrS r	SS jr
SS jrSS jr\SS	\S
   4S jj5       rSS jrSrU =r$ )AutoRoundQuantizer    zG
Quantizer of the AutoRound method. (https://arxiv.org/pdf/2309.05516)
T
auto_roundquantization_configc                 (   > [         TU ]  " U40 UD6  g N)super__init__)selfr   kwargs	__class__s      d/var/www/auris/envauris/lib/python3.13/site-packages/transformers/quantizers/quantizer_auto_round.pyr   AutoRoundQuantizer.__init__)   s    ,77    c                 f    UR                  SS 5      U l        [        5       (       d  [        S5      eg )N
device_mapzbLoading an AutoRound quantized model requires auto-round library (`pip install 'auto-round>=0.5'`))getr   r	   ImportError)r   argsr   s      r   validate_environment'AutoRoundQuantizer.validate_environment,   s2     **\48&((t  )r   c                 V    Uc%  [         R                  n[        R                  S5        U$ )NzSLoading the model in `torch.bfloat16`. To overwrite it, set `torch_dtype` manually.)torchbfloat16loggerinfo)r   torch_dtypes     r   update_torch_dtype%AutoRoundQuantizer.update_torch_dtype3   s$    ..KKKmnr   modelr   c                     UR                   R                  S:w  a  [        R                  S5        SSKJnJn  U R                  (       a#  U" U R                  5      nU" X5      u  pX`l	        g g )N	input_idszRAutoRound offers only limited support for models that are not strictly text-based.r   )convert_hf_modelinfer_target_device)
r   main_input_namer&   warning"auto_round.inference.convert_modelr.   r/   pre_quantizedr   used_backends)r   r+   r   r.   r/   target_devicer4   s          r   $_process_model_before_weight_loading7AutoRoundQuantizer._process_model_before_weight_loading9   sS    ??**k9NNop\/@M#3E#I E!. r   c                 l    U R                   (       a  SSKJn  U" XR                  5        g [	        S5      e)Nr   )	post_initz+AutoRound only sports pre-quantized models.)r3   r2   r9   r4   
ValueError)r   r+   r   r9   s       r   #_process_model_after_weight_loading6AutoRoundQuantizer._process_model_after_weight_loadingC   s(    De//0JKKr   c                     g)NF )r   r+   s     r   is_trainableAutoRoundQuantizer.is_trainableK   s    r   c                     g)NTr>   )r   safe_serializations     r   is_serializable"AutoRoundQuantizer.is_serializableO   s    r   )r   r4   )r(   torch.dtypereturnrE   )r+   r   r   )__name__
__module____qualname____firstlineno____doc__requires_calibrationrequired_packagesr   r   r!   r)   r6   r;   propertyr   r?   rC   __static_attributes____classcell__)r   s   @r   r   r       se    
  %8,C 8/L (+<"=   r   r   )typingr   r   baser   modeling_utilsr   utilsr	   r
   r   utils.quantization_configr   r$   
get_loggerrG   r&   r   r>   r   r   <module>rW      sH    +  0 H H ? 			H	%1 1r   