+
    œ°³jØ  ã                   óÚ   € ^ RI HtHt ^RIHt ^RIHt ]'       d   ^RIHt ^RI	H
t
 ^RIHtHtHtHtHt ^RI	Ht ]! 4       '       d   ^ RIt]P&                  ! ]4      t ! R	 R
]4      tR# )é    )ÚTYPE_CHECKINGÚOptional)ÚHfQuantizer)Úget_module_from_name)ÚPreTrainedModel)ÚFPQuantConfig)Úis_fp_quant_availableÚis_qutlass_availableÚis_torch_availableÚis_torch_xpu_availableÚlogging©ÚQuantizationConfigMixinNc                   óÄ   a a€ ] tR t^"t oRtRtRtV3R lV 3R lltR tV3R lR lt	V3R	 lR
 lt
V3R lR lt]RV3R lR ll4       tR tR tR tV3R ltRtVtV ;t# )ÚFPQuantHfQuantizerz„
Quantizer for the FP-Quant method. Enables the loading of prequantized models and in-flight quantization of full-precision models.
FTc                ó    <€ V ^8„  d   QhRS[ /# )é   Úquantization_configr   )ÚformatÚ__classdict__s   "€Úk/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/quantizers/quantizer_fp_quant.pyÚ__annotate__ÚFPQuantHfQuantizer.__annotate__+   s   ø€ ÷ 8ñ 8Ñ,Cñ 8ó    c                ó*   <€ \         SV `  ! V3/ VB  R # ©N)ÚsuperÚ__init__)Úselfr   ÚkwargsÚ	__class__s   &&,€r   r   ÚFPQuantHfQuantizer.__init__+   s   ø€ Ü‰ÒÐ,Ñ7°Ô7r   c                óò  € \         P                  P                  4       '       g   \        4       '       g   \	        R 4      h\        4       '       g(   V P                  P                  '       g   \        R4      hV P                  P                  '       du   V P                  P                  R8X  dZ   \         P                  P                  4       '       d6   \         P                  P                  4       ^ ,          ^	8  d   \        R4      hV P                  P                  '       d   \        P                  R4       \        4       '       g   \        R4      hVf(   V P                  P                  '       g   \        R4      h\        V\         4      '       dd   V P                  P                  '       g&   \#        V4      ^8”  d   RVP%                  4       9   g   R	VP%                  4       9   d   \        R
4      hR# R# )z]FPQuant quantization is only supported on GPU or Intel XPU. Please use a different quantizer.a€  Using `fp_quant` with real quantization requires a **Blackwell GPU** and qutlass: `git clone https://github.com/IST-DASLab/qutlass.git && cd qutlass && pip install --no-build-isolation .`. You can use `FPQuantConfig(pseudoquantization=True, ...)` to use Triton-based pseudo-quantization. It doesn't provide any speedups but emulates the quantization behavior of the real quantization.Únvfp4zäNVFP4 pseudoquantization requires a GPU with compute capability >= 9.0 (Hopper or newer) because the Triton kernel uses the `fp8e4nv` type. Please use `forward_dtype='mxfp4'` instead, or use a GPU with compute capability >= 9.0.zŠUsing pseudo-quantization for FP-Quant. This doesn't provide any speedups but emulates the quantization behavior of the real quantization.zGUsing `fp_quant` quantization requires fp_quant: `pip install fp_quant`NzyYou are attempting to load a FPQuant model without setting device_map. Please set device_map comprised of 'cuda' devices.ÚcpuÚdiskz±You are attempting to load a FPQuant model with a device_map that contains a CPU or disk device. This is not supported. Please remove the CPU or disk device from the device_map.)ÚtorchÚcudaÚis_availabler   ÚNotImplementedErrorr
   r   ÚpseudoquantizationÚImportErrorÚforward_dtypeÚget_device_capabilityÚ
ValueErrorÚloggerÚwarningr	   Ú
isinstanceÚdictÚlenÚvalues)r   Ú
device_mapr    s   &&,r   Úvalidate_environmentÚ'FPQuantHfQuantizer.validate_environment.   s—  € Ü�z‰z×&Ñ&×(Ò(Ô1G×1IÒ1IÜ%Øoóð ô $×%Ò%¨d×.FÑ.F×.Y×.YÐ.YÜð Sóð ð
 ×$Ñ$×7×7Ð7Ø×(Ñ(×6Ñ6¸'ÔAÜ—
‘
×'Ñ'×)Ò)Ü—
‘
×0Ñ0Ó2°1Õ5¸Ô9äð?óð ð ×#Ñ#×6×6Ð6Ü�N‰Nð ]ôô %×&Ò&ÜÐgÓhÐhàÒ d×&>Ñ&>×&Q×&QÐ&QÜðFóð ô ˜
¤D×)Ò)à×,Ñ,×?×?Ð?Ü˜
“O aÔ'Ø˜Z×.Ñ.Ó0Ô0Ø˜Z×.Ñ.Ó0Ô0ä ðhóð ñ 1ñ *r   c                ó"   <€ V ^8„  d   QhRRRR/# )r   Údtypeztorch.dtypeÚreturn© )r   r   s   "€r   r   r   ^   s   ø€ ÷ ñ  -ð °Mñ r   c                ó‚   € V\         P                  8w  d*   \        P                  R V R24       \         P                  pV# )zSetting dtype to zP, but only bfloat16 is supported right now. Overwriting torch_dtype to bfloat16.)r'   Úbfloat16r0   Úwarning_once)r   r:   s   &&r   Úupdate_dtypeÚFPQuantHfQuantizer.update_dtype^   s9   € Ø”E—N‘NÔ"Ü×ÑØ# E 7Ð*zÐ{ôô —N‘NˆEØˆr   c                ó*   <€ V ^8„  d   QhRRRS[ RS[/# )r   Úmodelr   Ú
param_namer;   )ÚstrÚbool)r   r   s   "€r   r   r   f   s$   ø€ ÷ ñ Ð.?ð ÉSð Ñ_cñ r   c                ó`   € ^ RI Hp \        W4      w  rV\        WT4      '       d
   VR9   d   R# R# )r   )ÚFPQuantLinearTF)ÚweightÚqweightÚdqweight)Úfp_quantrH   r   r2   )r   rC   rD   r    rH   ÚmoduleÚtensor_names   &&&,   r   Úparam_needs_quantizationÚ+FPQuantHfQuantizer.param_needs_quantizationf   s+   € Ý*ä2°5ÓEÑˆÜ�f×,Ò,°Ð@aÔ1aáár   c                ó   <€ V ^8„  d   QhRR/# ©r   rC   r   r<   )r   r   s   "€r   r   r   p   s   ø€ ÷ 
ñ 
à ñ
r   c                óR   € ^ RI Hp ^RIHp V! VV! V P                  4      R7       R# )r   )Úreplace_with_fp_quant_linear)Úadapt_fp_quant_config)Úfp_quant_linear_configN)rL   rT   Úintegrations.fp_quantrU   r   )r   rC   r    rT   rU   s   &&,  r   Ú$_process_model_before_weight_loadingÚ7FPQuantHfQuantizer._process_model_before_weight_loadingp   s#   € õ
 	:åAá$ØÙ#8¸×9QÑ9QÓ#R÷	
r   c                ó.   <€ V ^8„  d   QhRS[ R,          /# rR   )r   )r   r   s   "€r   r   r      s   ø€ ÷ ñ ¡(Ð+<Õ"=ñ r   c                ól   € V P                   P                  pV'       g   \        P                  R 4       V# )z²You are attempting to train a model with FPQuant quantization. This is only supported when `store_master_weights=True`. Please set `store_master_weights=True` to train the model.)r   Ústore_master_weightsr0   r1   )r   rC   Ú	trainables   && r   Úis_trainableÚFPQuantHfQuantizer.is_trainable~   s0   € à×,Ñ,×AÑAˆ	ßÜ�N‰Nð Eôð Ðr   c                ó   € R # )Tr<   )r   s   &r   Úis_serializableÚ"FPQuantHfQuantizer.is_serializable‡   s   € Ùr   c                ó   € ^RI Hp V! V 4      # )r   )ÚFpQuantQuantize)rW   rd   )r   rd   s   & r   Úget_quantize_opsÚ#FPQuantHfQuantizer.get_quantize_opsŠ   s   € Ý;á˜tÓ$Ð$r   c                óÊ   € ^RI Hp ^RIHp V P                  '       dE   V P
                  P                  '       d   V! R.RV! V 4      .R7      .# V! R.RV! V 4      .R7      .# . # )r   )ÚWeightConverter)ÚFpQuantDeserializez	.dqweight)Úsource_patternsÚtarget_patternsÚ
operationsz.qweight)Úcore_model_loadingrh   rW   ri   Úpre_quantizedr   r+   )r   rh   ri   s   &  r   Úget_weight_conversionsÚ)FPQuantHfQuantizer.get_weight_conversions�   sy   € Ý8Ý>à××ÐØ×'Ñ'×:×:Ð:á#Ø)4¨Ø(3Ù$6°tÓ$<Ð#=ôðð ñ $Ø)3¨Ø(2Ù$6°tÓ$<Ð#=ôðð ð ˆ	r   c                ó$   <€ V ^8„  d   Qh/ R;R&   # )r   r   r   r<   )r   r   s   "€r   r   r   "   s   ø‡ ‚ ð )Ñ(ò r   r<   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_calibrationÚis_qat_trainabler   r7   r@   rO   rX   Úpropertyr^   ra   re   ro   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r!   r   s   @@r   r   r   "   sv   ù‡ € ñð !ÐØÐ÷8ó 8ò.÷`ð ÷ð ÷
ð 
ð ÷ñ ó ðòò%ò
÷[ … r   r   )Útypingr   r   Úbaser   Úquantizers_utilsr   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   r   r   r   r   r'   Ú
get_loggerrr   r0   r   r<   r   r   Ú<module>r…      sP   ð÷ +å Ý 2÷ Ý0Ý9ç tÕ tÝ ?ñ ×ÒÛà	×	Ò	˜HÓ	%€ôB˜ö Br   