+
    QV-j0  ã                   ó¢   € ^ RI Ht ^RIHt ^RIHt ^RIHt ]'       d   ^RIH	t	 ^RI
Ht ^RIHt ]! 4       '       d   ^ RIt ! R	 R
]4      tR# )é    )ÚTYPE_CHECKING)Úis_fouroversix_available)ÚHfQuantizer)Úget_module_from_name)ÚPreTrainedModel)ÚFourOverSixConfig)Úis_torch_availableNc                   óÈ   a a€ ] tR t^t oRtRtV 3R ltR tV3R lV 3R lltV3R lR lt	V3R	 lR
 lt
V3R lR ltR t]V3R lR l4       tR tR tV3R ltRtVtV ;t# )ÚFourOverSixHfQuantizerz$
FP4 quantization with fouroversix.
Fc                ó*   <€ \         SV `  ! V3/ VB  R # ©N)ÚsuperÚ__init__)ÚselfÚquantization_configÚkwargsÚ	__class__s   &&,€Ú~/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/quantizers/quantizer_fouroversix.pyr   ÚFourOverSixHfQuantizer.__init__   s   ø€ Ü‰ÒÐ,Ñ7°Ô7ó    c                ó<   € \        4       '       g   \        R 4      hR# )zXUsing `fouroversix` requires fouroversix: `pip install fouroversix --no-build-isolation`N)r   ÚImportError)r   Úargsr   s   &*,r   Úvalidate_environmentÚ+FourOverSixHfQuantizer.validate_environment    s    € Ü'×)Ò)ÜØjóð ñ *r   c                ó.   <€ V ^8„  d   QhRRRS[ RRRS[/# )é   Úmodelr   Ú
param_nameÚparamztorch.TensorÚreturn)ÚstrÚfloat)ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú#FourOverSixHfQuantizer.__annotate__&   s9   ø€ ÷ Dñ Dà ðDñ ðDð ð	Dñ
 
ñDr   c                ó¬   <€ ^ RI Hp \        W4      w  rVVP                  \	        V4      4      '       d   VP                  V4      # \        SV `  WV4      # ©r   )ÚQuantizedModule)Úfouroversixr*   r   Úis_quantized_module_typeÚtypeÚget_element_sizer   Úparam_element_size)r   r   r   r    r*   ÚmoduleÚtensor_namer   s   &&&&   €r   r/   Ú)FourOverSixHfQuantizer.param_element_size&   sM   ø€ õ 	0ä2°5ÓEÑˆà×3Ñ3´D¸³L×AÒAØ×*Ñ*¨;Ó7Ð7ä‰wÑ)¨%¸UÓCÐCr   c                ó*   <€ V ^8„  d   QhRRRS[ RS[/# )r   r   r   r   r!   )r"   Úbool)r$   r%   s   "€r   r&   r'   5   s.   ø€ ÷ 
wñ 
wà ð
wñ ð
wñ
 
ñ
wr   c                óˆ   € ^ RI Hp \        W4      w  rVVP                  \	        V4      4      ;'       d    WeP
                  9   # r)   )r+   r*   r   r,   r-   Úparameters_to_quantize)r   r   r   r   r*   r0   r1   s   &&&,   r   Úparam_needs_quantizationÚ/FourOverSixHfQuantizer.param_needs_quantization5   s:   € õ 	0ä2°5ÓEÑˆà×7Ñ7¼¸V»ÓE×vÐvÈ+×YvÑYvÑJvÐvr   c                ó   <€ V ^8„  d   QhRR/# ©r   r   r   © )r$   r%   s   "€r   r&   r'   A   s   ø€ ÷ 8ñ 8à ñ8r   c                ój  € ^ RI HpHp ^RIHp V! VV! V P
                  4      4       V P                  '       dz   V P
                  P                  '       g\   VP                  4        FE  w  rxVP                  \        V4      4      '       g   K'  VP                   F  p	\        W‰4       K  	  KG  	  R# R# R# )r   )r*   Úquantize_model)Úadapt_fouroversix_configN)r+   r*   r=   Úintegrations.fouroversixr>   r   Úpre_quantizedÚkeep_master_weightsÚnamed_modulesr,   r-   r6   Údelattr)
r   r   Ú
device_mapr   r*   r=   r>   Ú_r0   Úparameter_names
   &&&,      r   Ú$_process_model_before_weight_loadingÚ;FourOverSixHfQuantizer._process_model_before_weight_loadingA   s�   € ÷ 	@åGáØÙ$ T×%=Ñ%=Ó>ô	
ð ××Ð d×&>Ñ&>×&R×&RÐ&RØ"×0Ñ0Ö2‘	�Ø"×;Ñ;¼DÀ»L×IÔIØ*0×*GÔ*G˜Ü Ö7ó +Hó 3ñ 'SÑr   c                ó   <€ V ^8„  d   QhRR/# r:   r;   )r$   r%   s   "€r   r&   r'   X   s   ø€ ÷ ñ Ð9Jñ r   c                ó   € V# r   r;   )r   r   r   s   &&,r   Ú#_process_model_after_weight_loadingÚ:FourOverSixHfQuantizer._process_model_after_weight_loadingX   s   € Øˆr   c                ó   € R # )Tr;   ©r   s   &r   Úis_serializableÚ&FourOverSixHfQuantizer.is_serializable[   s   € Ùr   c                ó    <€ V ^8„  d   QhRS[ /# )r   r!   )r4   )r$   r%   s   "€r   r&   r'   _   s   ø€ ÷ <ñ <™dñ <r   c                ó.   € V P                   P                  # r   )r   rA   rN   s   &r   Úis_trainableÚ#FourOverSixHfQuantizer.is_trainable^   s   € à×'Ñ'×;Ñ;Ð;r   c                ó   € ^RI Hp V! V 4      # )r   )ÚFourOverSixQuantize)r?   rV   )r   rV   s   & r   Úget_quantize_opsÚ'FourOverSixHfQuantizer.get_quantize_opsb   s   € ÝBá" 4Ó(Ð(r   c                óœ   € ^ RI Hp \        V P                  R4      '       d*   V P                  P                  pVP                  V4      pV# . # )a†  
Return weight conversions for loading pre-quantized checkpoints of
other pre-quantized models (not fouroversix models). After first use,
the pre_quantized_model_config_type attribute is set to None to ensure
subsequent calls (e.g., during save_pretrained) return an empty list
since, by then, the model will be saved with our framework's format
so weight conversions are no longer needed.
)ÚWeightConversionsÚpre_quantized_model_config_type)r+   rZ   Úhasattrr   r[   Úget_weight_conversions)r   rZ   Úmodel_config_typeÚweight_conversionss   &   r   r]   Ú-FourOverSixHfQuantizer.get_weight_conversionsg   sP   € õ 	2ô �4×+Ñ+Ð-N×OÒOØ $× 8Ñ 8× XÑ XÐØ!2×!IÑ!IØ!ó"Ðð &Ð%àˆ	r   c                ó$   <€ V ^8„  d   Qh/ R;R&   # )r   r   r   r;   )r$   r%   s   "€r   r&   r'      s   ø‡ ‚ ð -Ñ,ò r   r;   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_calibrationr   r   r/   r7   rG   rK   rO   ÚpropertyrS   rW   r]   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r   r%   s   @@r   r   r      ss   ù‡ € ñð !Ðõ8ò÷Dó D÷
wð 
w÷8ð 8÷.ð òð ÷<ó ð<ò)ò
÷e … r   r   )Útypingr   Úutils.import_utilsr   Úbaser   Úquantizers_utilsr   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   Útorchr   r;   r   r   Ú<module>ru      s=   ðÝ  å 9Ý Ý 2÷ Ý0Ý=õñ
 ×ÒÛôf˜[ö fr   