
    Z j~
                         S SK Jr  SSKJr  \(       a  SSKJr  SSKJrJr  SSK	J
r
  \R                  " \5      r " S S	\5      rg
)    )TYPE_CHECKING   )HfQuantizer   )PreTrainedModel)is_auto_round_availablelogging)QuantizationConfigMixinc                   p   ^  \ 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	\4S
 j5       rS rSrU =r$ )AutoRoundQuantizer   zO
Quantizer of the AutoRound method. (https://huggingface.co/papers/2309.05516)
Tquantization_configc                 (   > [         TU ]  " U40 UD6  g )N)super__init__)selfr   kwargs	__class__s      }/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/quantizers/quantizer_auto_round.pyr   AutoRoundQuantizer.__init__%   s    ,77    c                 d    UR                  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(   s0     **\2&((t  )r   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_nameloggerwarning"auto_round.inference.convert_modelr!   r"   pre_quantizedr   used_backends)r   modelr   r!   r"   target_devicer(   s          r   $_process_model_before_weight_loading7AutoRoundQuantizer._process_model_before_weight_loading/   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.)r'   r&   r.   r(   
ValueError)r   r)   r   r.   s       r   #_process_model_after_weight_loading6AutoRoundQuantizer._process_model_after_weight_loading9   s(    De//0JKKr   returnc                     g)NF r   s    r   is_trainableAutoRoundQuantizer.is_trainableA   s    r   c                     g)NTr4   r5   s    r   is_serializable"AutoRoundQuantizer.is_serializableE   s    r   )r   r(   )r)   r   )__name__
__module____qualname____firstlineno____doc__requires_calibrationr
   r   r   r+   r0   propertyboolr6   r9   __static_attributes____classcell__)r   s   @r   r   r      sR    
  8,C 8/L d   r   r   N)typingr   baser   modeling_utilsr   utilsr   r	   utils.quantization_configr
   
get_loggerr;   r$   r   r4   r   r   <module>rK      s9    !  0 4 ? 
		H	%* *r   