+
    QV-j  ã                   óª   € ^RI Ht ^RIHtHt ^RIHtHt ]! 4       '       d   ^ RIt^ RI	H
t
 ]P                  ! ]4      t ! R R]4      tR	R R lltR# )
é   )ÚConversionOps)Úget_module_from_nameÚshould_convert_module)Úis_torch_availableÚloggingNc                   ó<   a € ] tR t^t o R tRV 3R lR lltRtV tR# )ÚQuantoQuantizec                ó   € Wn         R # )N©Úhf_quantizer)Úselfr   s   &&Úq/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/integrations/quanto.pyÚ__init__ÚQuantoQuantize.__init__   s   € Ø(Öó    Nc                óþ   <€ V ^8„  d   QhRS[ S[S[S[P                  ,          3,          RS[P
                  P                  R,          RS[R,          RS[S[,          R,          RS[ S[S[P                  3,          /# )r   Ú
input_dictÚmodelNÚfull_layer_nameÚmissing_keysÚreturn)ÚdictÚstrÚlistÚtorchÚTensorÚnnÚModule)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚQuantoQuantize.__annotate__   sx   ø€ ÷ ñ á™™d¡5§<¡<Õ0Ð0Õ1ðñ �x‰x�‰ Õ%ðñ ˜t�ð	ñ
 ™3•i $Õ&ðñ 
‰c‘5—<‘<ÐÕ	 ñr   c                óJ  € \        VP                  4       4      ^ ,          w  rgV^ ,          p^RIHp V! W#V4       \	        W#4      w  r–\
        P                  ! V	P                  P                  4      V	n        \
        P                  ! V	P                  P                  4      V	n	        V	P                  4        RV	P                  n        RV	n        VP                  R^4      ^ ,          p
VP                  V
 R24       VP                  V
 R24       VP                  V
 R24       / # )é    )Ú_load_parameter_into_modelFTÚ.z.weightz.input_scalez.output_scale)ÚtupleÚitemsÚmodeling_utilsr%   r   r   ÚonesÚinput_scaleÚshapeÚoutput_scaleÚfreezeÚweightÚrequires_gradÚ_is_hf_initializedÚrsplitÚdiscard)r   r   r   r   r   ÚkwargsÚ_Úvaluer%   ÚmoduleÚmodule_names   &&&&&,     r   ÚconvertÚQuantoQuantize.convert   sô   € ô ˜×)Ñ)Ó+Ó,¨QÕ/‰ˆØ�a•ˆå?á" 5¸5ÔAÜ(¨Ó@‰	ˆä"ŸZšZ¨×(:Ñ(:×(@Ñ(@ÓAˆÔÜ#Ÿjšj¨×)<Ñ)<×)BÑ)BÓCˆÔà�‰ŒØ&+ˆ�‰Ô#Ø$(ˆÔ!ð &×,Ñ,¨S°!Ó4°QÕ7ˆØ×Ñ ˜}¨GÐ4Ô5Ø×Ñ ˜}¨LÐ9Ô:Ø×Ñ ˜}¨MÐ:Ô;Øˆ	r   r   )NNN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r9   Ú__static_attributes__Ú__classdictcell__)r    s   @r   r	   r	      s   ø‡ € ò)÷÷ ð r   r	   c                óH   € V ^8„  d   QhR\         \        ,          R,          /# )r   Úmodules_to_not_convertN)r   r   )r   s   "r   r!   r!   >   s   € ÷ 9ñ 9ô !¤�I¨Õ,ñ9r   c                ó’  € ^ RI HpHpHpHpHpHp RVRVRVRV/p	RRRVRV/p
RpV P                  4        EF[  w  rÍ\        WÂ4      '       g   K  \        P                  ! R4      ;_uu_ 4        Rp\        V\        P                  4      '       dd   V! VP                  VP                  VP                   RJVP"                  P$                  W‘P&                  ,          W¡P(                  ,          R	7      pM\        V\        P                  P*                  4      '       dV   VP(                  eH   V! VP,                  VP.                  VP0                  VP                   RJW¡P(                  ,          R
7      pVe   RpV P3                  WÎ4       RRR4       EK^  	  V'       g   \4        P7                  R4       V #   + '       g   i     EK‘  ; i)a‘  
Public method that recursively replaces the Linear layers of the given model with Quanto quantized layers.
Returns the converted model and a boolean that indicates if the conversion has been successful or not.

Args:
    model (`torch.nn.Module`):
        The model to convert, can be any `torch.nn.Module` instance.
    quantization_config (`QuantoConfig`, defaults to `None`):
        The quantization config object that contains the quantization parameters.
    modules_to_not_convert (`list`, *optional*, defaults to `None`):
        A list of modules to not convert. If a module name is in the list (e.g. `lm_head`), it will not be
        converted.
)Ú
QLayerNormÚQLinearÚqfloat8Úqint2Úqint4Úqint8Úfloat8Úint8Úint4Úint2NFÚmeta)Úin_featuresÚout_featuresÚbiasÚdtypeÚweightsÚactivations)rT   Tz½You are loading your model using quanto but no linear modules were found in your model. Please double check your model architecture, or submit an issue on github if you think this is a bug.)Úoptimum.quantorD   rE   rF   rG   rH   rI   Únamed_modulesr   r   ÚdeviceÚ
isinstancer   ÚLinearrO   rP   rQ   r/   rR   rS   rT   Ú	LayerNormÚnormalized_shapeÚepsÚelementwise_affineÚset_submoduleÚloggerÚwarning)r   Úquantization_configrB   rD   rE   rF   rG   rH   rI   Ú	w_mappingÚ	a_mappingÚhas_been_replacedr8   r7   Ú
new_modules   &&&            r   Úreplace_with_quanto_layersrf   >   s|  € ÷$ Q×Pà˜7 F¨E°6¸5À&È%ÐP€IØ�t˜X w°¸Ð>€IàÐØ$×2Ñ2×4ÑˆÜ$ [×IÒIÙÜ�\Š\˜&×!Õ!ØˆJÜ˜&¤"§)¡)×,Ò,Ù$Ø &× 2Ñ 2Ø!'×!4Ñ!4ØŸ™¨DÐ0Ø Ÿ-™-×-Ñ-Ø%×&AÑ&AÕBØ )×*IÑ*IÕ Jô‘
ô ˜F¤E§H¡H×$6Ñ$6×7Ò7Ð<O×<[Ñ<[Ò<gÙ'Ø×+Ñ+Ø—J‘JØ×-Ñ-Ø—K‘K tÐ+Ø )×*IÑ*IÕ Jô�
ð Ò%Ø$(Ð!Ø×#Ñ# KÔ<÷+ "Ò!ñ  5÷4 Ü�‰ðô	
ð €L÷= "×!Ñ!ús   Á,DF4Æ4G)NN)Úcore_model_loadingr   Úquantizers.quantizers_utilsr   r   Úutilsr   r   r   Útorch.nnr   Ú
get_loggerr;   r_   r	   rf   © r   r   Ú<module>rm      sH   ðõ /ß Uß /ñ ×ÒÛÝà	×	Ò	˜HÓ	%€ô �]ô  ÷F9ñ 9r   