+
    QV-j=  ã                   óâ   € ^ 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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)Útqdm)ÚHfQuantizer)Úget_module_from_name)ÚPreTrainedModel)ÚHiggsConfig)Úis_accelerate_availableÚis_flute_availableÚis_hadamard_availableÚis_torch_availableÚlogging©ÚQuantizationConfigMixinNc                   óÈ   a a€ ] tR t^#t o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
]V3R lR l4       tR tV3R lR ltR tV3R ltRtVtV ;t# )ÚHiggsHfQuantizerz€
Quantizer of the HIGGS method. Enables the loading of prequantized models and in-flight quantization of full-precision models.
Fc                ó    <€ V ^8„  d   QhRS[ /# )é   Úquantization_configr   )ÚformatÚ__classdict__s   "€Úx/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/quantizers/quantizer_higgs.pyÚ__annotate__ÚHiggsHfQuantizer.__annotate__+   s   ø€ ÷ 8ñ 8Ñ,Cñ 8ó    c                ó*   <€ \         SV `  ! V3/ VB  R # )N)ÚsuperÚ__init__)Úselfr   ÚkwargsÚ	__class__s   &&,€r   r   ÚHiggsHfQuantizer.__init__+   s   ø€ Ü‰ÒÐ,Ñ7°Ô7r   c                ó¾  € \         P                  P                  4       '       g   \        R 4      h\	        4       '       g   \        R4      h\        4       '       g   \        R4      h\        4       '       g   \        R4      hVf   \        R4      h\        V\        4      '       d8   RVP                  4       9   g   RVP                  4       9   d   \        R4      hR# R# )	zNHIGGS quantization is only supported on GPU. Please use a different quantizer.zHUsing `higgs` quantization requires Accelerate: `pip install accelerate`zLUsing `higgs` quantization requires FLUTE: `pip install flute-kernel>=0.3.0`zbUsing `higgs` quantization requires fast_hadamard_transform: `pip install fast_hadamard_transform`NzwYou are attempting to load a HIGGS model without setting device_map. Please set device_map comprised of 'cuda' devices.ÚcpuÚdiskz¯You are attempting to load a HIGGS 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_availableÚNotImplementedErrorr	   ÚImportErrorr
   r   Ú
ValueErrorÚ
isinstanceÚdictÚvalues)r   Ú
device_mapr   s   &&,r   Úvalidate_environmentÚ%HiggsHfQuantizer.validate_environment.   sÍ   € Ü�z‰z×&Ñ&×(Ò(Ü%Ð&vÓwÐwä&×(Ò(ÜÐhÓiÐiä!×#Ò#ÜÐlÓmÐmä$×&Ò&ÜØtóð ð ÒÜðFóð ô ˜
¤D×)Ò)Ø˜
×)Ñ)Ó+Ô+¨v¸×9JÑ9JÓ9LÔ/LÜ ðhóð ñ 0Mñ *r   c                ó"   <€ V ^8„  d   QhRRRR/# )r   Údtypeztorch.dtypeÚreturn© )r   r   s   "€r   r   r   I   s   ø€ ÷ ñ  -ð °Mñ r   c                óx   € V\         P                  8w  d%   V\         P                  8w  d   \        R V R24      hV# )zInvalid `dtype` zS. HIGGS quantization only supports `dtype=torch.float16` or `dtype=torch.bfloat16`.)r%   Úfloat16Úbfloat16r*   )r   r2   s   &&r   Úupdate_dtypeÚHiggsHfQuantizer.update_dtypeI   s:   € Ø”E—M‘MÔ! e¬u¯~©~Ô&=ÜØ" 5 'Ð)|Ð}óð ð ˆr   c                ó   <€ V ^8„  d   QhRR/# ©r   Úmodelr   r4   )r   r   s   "€r   r   r   s   s   ø€ ÷ 
ñ 
à ñ
r   c                óº   € ^RI Hp V P                  WP                  P                  VP
                  4      V n        V! VV P                  V P                  R7       R# )r   )Úreplace_with_higgs_linear)r   Úmodules_to_not_convertN)Úintegrationsr>   Úget_modules_to_not_convertr   r?   Ú_keep_in_fp32_modules)r   r<   r   r>   s   &&, r   Ú$_process_model_before_weight_loadingÚ5HiggsHfQuantizer._process_model_before_weight_loadings   sP   € õ
 	=à&*×&EÑ&EØ×+Ñ+×BÑBÀE×D_ÑD_ó'
ˆÔ#ñ 	"ØØ $× 8Ñ 8Ø#'×#>Ñ#>÷	
r   c                ó   <€ V ^8„  d   QhRR/# r;   r4   )r   r   s   "€r   r   r   „   s   ø€ ÷ Zñ ZÐ9Jñ Zr   c                óB  € ^ RI HpHp ^ RIHp ^RIHp / pVP                  4        UU	u/ uF  w  r‰\        W–4      '       g   K  W‰bK  	  p
pp	\        V
P                  4       RRR7       EF+  w  r‰V	P                  P                  V9  d4   V! V	P                  P                  R7      WyP                  P                  &   WyP                  P                  ,          V	n        VP                  V P                  P                   V,          4      V	n        V! V	P                  P"                  V	P$                  P"                  V	P                   R7      w  V	P                  n        V	n        V	P                   P'                  4       V P                  P                   V&   EK.  	  R	# u up	pi )
r   )ÚTuneMetaDataÚmaybe_tune_and_repack)Úmake_workspace_streamk©ÚHiggsLinearzRepacking HIGGS modulesF)ÚdescÚleave)Údevice)ÚweightÚscalesÚmetadataN)Ú
flute.tunerG   rH   Úflute.utilsrI   r@   rK   Únamed_modulesr+   r   ÚitemsrO   rN   Ú	workspaceÚ	from_dictr   Útune_metadataÚdatarP   Úto_dict)r   r<   r   rG   rH   rI   rK   Úflute_workspacesÚnameÚmoduleÚflute_moduless   &&,        r   Ú#_process_model_after_weight_loadingÚ4HiggsHfQuantizer._process_model_after_weight_loading„   sC  € ßBÝ6å.àÐØ:?×:MÑ:MÔ:OÔsÑ:O©,¨$ÔS]Ð^d×Srœ˜šÑ:OˆÑsÜ  ×!4Ñ!4Ó!6Ð=VÐ^c×dÐd‰LˆDð �}‰}×#Ñ#Ð+;Ô;Ù9OÐW]×WdÑWd×WkÑWkÔ9lÐ §¡×!5Ñ!5Ñ6Ø/·±×0DÑ0DÕEˆFÔð $0×#9Ñ#9¸$×:RÑ:R×:`Ñ:`ÐaeÕ:fÓ#gˆFÔ Ù7LØ—}‘}×)Ñ)Ø—}‘}×)Ñ)Ø×-Ñ-ô8Ñ4ˆF�M‰MÔ Ô 4ð
 <B×;OÑ;O×;WÑ;WÓ;YˆD×$Ñ$×2Ñ2°4Ô8ó eùó ts   ªFÁFc                ó    <€ V ^8„  d   QhRS[ /# )r   r3   )Úbool)r   r   s   "€r   r   r   ž   s   ø€ ÷ ñ ™dñ r   c                ó   € R # )Fr4   ©r   s   &r   Úis_trainableÚHiggsHfQuantizer.is_trainable�   s   € ár   c                ó   € R # )Tr4   rd   s   &r   Úis_serializableÚ HiggsHfQuantizer.is_serializable¡   s   € Ùr   c                ó*   <€ V ^8„  d   QhRRRS[ RS[/# )r   r<   r   Ú
param_namer3   )Ústrrb   )r   r   s   "€r   r   r   ¤   s$   ø€ ÷ ñ Ð.?ð ÉSð Ñ_cñ r   c                ó`   € ^RI Hp \        W4      w  rV\        WT4      '       d
   VR8X  d   R# R# )r   rJ   rO   TF)r@   rK   r   r+   )r   r<   rk   r   rK   r]   Útensor_names   &&&,   r   Úparam_needs_quantizationÚ)HiggsHfQuantizer.param_needs_quantization¤   s*   € Ý.ä2°5ÓEÑˆÜ�f×*Ò*¨{¸hÔ/Fáár   c                ó"   € ^RI Hp V! V4      pV# )r   )Údequantize_higgs)r@   rr   )r   r<   rr   s   && r   Ú_dequantizeÚHiggsHfQuantizer._dequantize®   s   € Ý3á  Ó'ˆØˆr   c                ó$   <€ V ^8„  d   Qh/ R;R&   # )r   r   r   r4   )r   r   s   "€r   r   r   #   s   ø‡ ‚ ð 'Ñ&ò r   )r?   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_calibrationr   r/   r8   rC   r_   Úpropertyre   rh   ro   rs   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r    r   s   @@r   r   r   #   sr   ù‡ € ñð !Ð÷8ó 8ò÷6ð ÷T
ð 
÷"Zð Zð2 ÷ó ðò÷ð ò÷W … r   r   )Útypingr   Úutils.loggingr   Úbaser   Úquantizers_utilsr   Úmodeling_utilsr   Úutils.quantization_configr   Úutilsr	   r
   r   r   r   r   r%   Ú
get_loggerrv   Úloggerr   r4   r   r   Ú<module>rŠ      sS   ðõ !å  Ý Ý 2÷ Ý0Ý7ç sÕ sÝ ?ñ ×ÒÛà	×	Ò	˜HÓ	%€ôO�{ö Or   