ó
    qyüi  ã            	       ó¢   • S SK Jr  SSKJr  \(       a  SSKJr  SSKJr  SSKJ	r	J
r
  \
R                  " \5      rSS	S
SSSSSS.r " S S\5      rg)é    )ÚTYPE_CHECKINGé   )ÚHfQuantizeré   )ÚPreTrainedModel)ÚQuarkConfig)Úis_quark_availableÚloggingzweight_quantizer.scalezbias_quantizer.scalezinput_quantizer.scalezoutput_quantizer.scalezweight_quantizer.zero_pointzbias_quantizer.zero_pointzinput_quantizer.zero_pointzoutput_quantizer.zero_point)Úweight_scaleÚ
bias_scaleÚinput_scaleÚoutput_scaleÚweight_zero_pointÚbias_zero_pointÚinput_zero_pointÚoutput_zero_pointc                   ó~   ^ • \ rS rSr% SrSrS\S'   U 4S jrS rSS
 jr	SS	S\
S\4S jrS r\S 5       rS rSrU =r$ )ÚQuarkHfQuantizeré*   z7
Quark quantizer (https://quark.docs.amd.com/latest/).
Tr   Úquantization_configc                 óJ   >• [         TU ]  " U40 UD6  UR                  U l        g )N)ÚsuperÚ__init__Újson_export_config)Úselfr   ÚkwargsÚ	__class__s      €Úd/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/quantizers/quantizer_quark.pyr   ÚQuarkHfQuantizer.__init__2   s$   ø€ Ü‰ÒÐ,Ñ7°Ò7à"5×"HÑ"HˆÕó    c                 ó8   • [        5       (       d  [        S5      eg )Nz¥Loading a Quark quantized model requires the `quark` library but it was not found in the environment. Please refer to https://quark.docs.amd.com/latest/install.html.)r	   ÚImportError)r   Úargsr   s      r   Úvalidate_environmentÚ%QuarkHfQuantizer.validate_environment7   s#   € Ü!×#Ñ#Üð xóð ð $r    Úmodelr   c                 óœ   • SSK Jn  U" UU R                  R                  U R                  R
                  U R                  R                  S9  U$ )Nr   )Ú_map_to_quark)Úpack_methodÚcustom_mode)Úquark.torch.export.apir(   r   Úquant_configr   r)   r*   )r   r&   r   r(   s       r   Ú$_process_model_before_weight_loadingÚ5QuarkHfQuantizer._process_model_before_weight_loading=   sD   € Ý8áØØ×$Ñ$×1Ñ1Ø×/Ñ/×;Ñ;Ø×0Ñ0×<Ñ<ò		
ð ˆr    Ú
param_nameÚreturnc                 ó   • g)NT© )r   r&   r/   r   s       r   Úparam_needs_quantizationÚ)QuarkHfQuantizer.param_needs_quantizationI   s   € Ør    c                 ó   • g©NFr2   ©r   s    r   Úis_serializableÚ QuarkHfQuantizer.is_serializableL   s   € Ør    c                 ó   • gr6   r2   r7   s    r   Úis_trainableÚQuarkHfQuantizer.is_trainableO   s   € àr    c           
      óš   • SSK Jn  SSKJn  / n[        R                  5        H$  u  pEUR                  U" U/UU" U 5      /S95        M&     U$ )Nr   )ÚWeightConverter)ÚQuarkDeserialize)Úsource_patternsÚtarget_patternsÚ
operations)Úcore_model_loadingr>   Úintegrations.quarkr?   ÚCHECKPOINT_KEYSÚitemsÚappend)r   r>   r?   Ú
convertersÚ
source_keyÚ
target_keys         r   Úget_weight_conversionsÚ'QuarkHfQuantizer.get_weight_conversionsS   sV   € Ý8Ý9ð ˆ
Ü&5×&;Ñ&;Ö&=Ñ"ˆJØ×ÑÙØ%/ LØ$.Ù 0°Ó 6Ð7ñöñ '>ð Ðr    )r   )r&   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_calibrationÚ__annotations__r   r$   r-   ÚstrÚboolr3   r8   Úpropertyr;   rK   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r   *   se   ø‡ ñð  ÐØ&Ó&õIò
ô
ðÐ.?ð ÈSð Ð_cô òð ñó ð÷ð r    r   N)Útypingr   Úbaser   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   Ú
get_loggerrM   ÚloggerrE   r   r2   r    r   Ú<module>r`      sZ   ðõ !å ö Ý0Ý7ç /ð 
×	Ò	˜HÓ	%€ð -Ø(Ø*Ø,Ø6Ø2Ø4Ø6ñ	€ô>�{õ >r    