+
    QV-jñ  ã                   ó  € ^RI Ht ^RI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]P                  P                  4      t ! R	 R
]	P"                  4      tRR R lltR# )é   )ÚConversionOps)Ú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# )ÚEetqQuantizec                ó   € Wn         R # ©N©Úhf_quantizer)Úselfr   s   &&Úo/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/integrations/eetq.pyÚ__init__ÚEetqQuantize.__init__   s   € Ø(Öó    Nc                óž   <€ V ^8„  d   QhRS[ S[S[S[P                  ,          3,          RS[R,          RS[ S[S[P                  3,          /# )r   Ú
input_dictÚfull_layer_nameNÚreturn)ÚdictÚstrÚlistÚtorchÚTensor)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚEetqQuantize.__annotate__   sP   ø€ ÷ Sñ SÙ™s¡D©¯©Õ$6Ð6Õ7ðSÙJMÐPTÍ*ðSá	‰c‘5—<‘<ÐÕ	 ñSr   c                óv  € \        VP                  4       4      ^ ,          w  rEV^ ,          pVP                  p\        P                  ! V4      P                  4       P                  4       p\        P                  V\        P                  R4      w  rxVP                  V4      pVP                  V4      pW'V R2V/# )é    FÚ_scales)ÚtupleÚitemsÚdevicer   ÚtÚ
contiguousÚcpuÚeetq_kernels_hubÚquant_weightsÚint8Úto)	r   r   r   ÚkwargsÚ_ÚvalueÚvalue_deviceÚint8_weightÚscaless	   &&&,     r   ÚconvertÚEetqQuantize.convert   sœ   € ô ˜×)Ñ)Ó+Ó,¨QÕ/‰ˆØ�a•ˆà—|‘|ˆÜ—g’g˜e“n×/Ñ/Ó1×5Ñ5Ó7ˆÜ.×<Ñ<¸[Ì%Ï*É*ÐV[Ó\Ñˆà!—n‘n \Ó2ˆØ—‘˜<Ó(ˆà°Ð0AÀÐ.IÈ6ÐRÐRr   r   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r2   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s   ø‡ € ò)÷S÷ Sð Sr   r   c                   óD   a € ] tR t^/t o ]RR l4       t]R 4       tRtV tR# )ÚEetqLinearMMFunctionNc                óv   € V P                  WW44       \        P                  WV4      pVe   WT,           pV# TpV# r
   )Úsave_for_backwardr(   Úw8_a16_gemm)ÚctxÚxÚweightr1   ÚbiasÚoutputs   &&&&& r   ÚforwardÚEetqLinearMMFunction.forward0   sC   € ð 	×Ñ˜a¨Ô6Ü!×-Ñ-¨a¸Ó@ˆØ"&Ò"2�•ˆØˆð 9?ˆØˆr   c                óº  € V P                   w  r#rE\        P                  ! VP                  ^ ,          4      P	                  VP
                  4      P	                  VP                  4      p\        P                  WcV4      pV P                  ^ ,          '       d@   VP                  ^ 4      P                  VP                  ^ ^4      4      P                  ^ 4      pXRRR3# )r    N)Úsaved_tensorsr   ÚeyeÚshaper+   r$   Údtyper(   r?   Úneeds_input_gradÚsqueezeÚmatmulÚ	transposeÚ	unsqueeze)r@   Úgrad_outputÚinputrB   r1   rC   ÚidentityÚ
grad_inputs   &&      r   ÚbackwardÚEetqLinearMMFunction.backward8   s®   € à&)×&7Ñ&7Ñ#ˆ�vÜ—9’9˜VŸ\™\¨!�_Ó-×0Ñ0°·±Ó?×BÑBÀ5Ç;Á;ÓOˆô "×-Ñ-¨hÀÓGˆà×Ñ ×"Ô"à$×,Ñ,¨QÓ/×6Ñ6°v×7GÑ7GÈÈ1Ó7MÓN×XÑXÐYZÓ[ˆJà˜4  tÐ+Ð+r   © r
   )	r4   r5   r6   r7   ÚstaticmethodrE   rU   r8   r9   r:   s   @r   r<   r<   /   s+   ø‡ € Øóó ðð ñ,ó ö,r   r<   c                   óT   a a€ ] tR t^Gt o]P
                  R3V 3R lltR tRtVt	V ;t
# )Ú
EetqLinearFc                óª  <€ \         SV `  4        \        P                  ! \        P
                  ! W3VR 7      RR7      V n        \        P                  ! \        P
                  ! V\        P                  R 7      4      V n        V'       dB   \        P                  ! \        P
                  ! V\        P                  R 7      4      V n	        R# RV n	        R# ))rK   F)Úrequires_gradN)
Úsuperr   ÚnnÚ	Parameterr   ÚemptyrB   Úfloat16Úweight_scalesrC   )r   Úin_featuresÚout_featuresrK   rC   Ú	__class__s   &&&&&€r   r   ÚEetqLinear.__init__H   sy   ø€ Ü‰ÑÔÜ—l’l¤5§;¢;°Ð/JÐRWÔ#XÐhmÔnˆŒÜŸ\š\¬%¯+ª+°|ÌEÏMÉMÔ*ZÓ[ˆÔßÜŸš¤U§[¢[°,ÄuÇ}Á}Ô%UÓVˆDŽIàˆDŽIr   c                óp   € \         P                  WP                  V P                  V P                  4      pV# r
   )r<   ÚapplyrB   rb   rC   )r   rR   rD   s   && r   rE   ÚEetqLinear.forwardQ   s,   € Ü%×+Ñ+¨E·;±;À×@RÑ@RÐTX×T]ÑT]Ó^ˆØˆr   )rC   rB   rb   )r4   r5   r6   r7   r   r*   r   rE   r8   r9   Ú__classcell__)re   r   s   @@r   rZ   rZ   G   s   ù‡ € Ø8=¿
¹
È÷ ÷ò r   rZ   c                óH   € V ^8„  d   QhR\         \        ,          R,          /# )r   Úmodules_to_not_convertN)r   r   )r   s   "r   r   r   V   s   € ÷ %ñ %¼DÄ½IÈÕ<Lñ %r   c           	     ó  € ^RI Hp V! R4      sRpV'       d   / MRR/pV P                  4        F¡  w  rg\	        Wa4      '       g   K  \
        P                  ! R4      ;_uu_ 4        \        V\        P                  4      '       dC   \        VP                  VP                  3RVP                  RJ/VB pV P                  Wh4       RpRRR4       K£  	  V'       g   \        P!                  R	4       V #   + '       g   i     KÕ  ; i)
a´  
A helper function to replace all `torch.nn.Linear` modules by `EetqLinear` modules.

Parameters:
    model (`torch.nn.Module`):
        Input model or `torch.nn.Module` as the function is run recursively.
    modules_to_not_convert (`list[`str`]`, *optional*, defaults to `None`):
        Names of the modules to not convert in `EetqLinear`. In practice we keep the `lm_head` in full precision
        for numerical stability reasons.
)Ú
get_kernelz#kernels-community/quantization-eetqFrK   NÚmetarC   Tz»You are loading your model using eetq 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.)Úhub_kernelsrn   r(   Únamed_modulesr   r   r$   Ú
isinstancer^   ÚLinearrZ   rc   rd   rC   Úset_submoduleÚloggerÚwarning)	Úmodelrl   Úpre_quantizedrn   Úhas_been_replacedÚmodule_kwargsÚmodule_nameÚmoduleÚ
new_modules	   &&&      r   Úreplace_with_eetq_linearr~   V   sè   € õ (ñ "Ð"GÓHÐàÐç'‘B¨g°t¨_€MØ$×2Ñ2Ö4ÑˆÜ$ [×IÒIÙÜ�\Š\˜&×!Õ!Ü˜&¤"§)¡)×,Ò,Ü'Ø×&Ñ&¨×(;Ñ(;ñØBHÇ+Á+ÐUYÐBYðØ]jñ�
ð ×#Ñ# KÔ<Ø$(Ð!÷ "Ñ!ñ  5÷ Ü�‰ðô	
ð €L÷ "×!Ð!ús   Á%A#C3Ã3D)NF)Úcore_model_loadingr   Úquantizers.quantizers_utilsr   Úutilsr   r   r   Útorch.nnr^   Ú
get_loggerr4   ru   r   ÚautogradÚFunctionr<   ÚModulerZ   r~   rW   r   r   Ú<module>r‡      sq   ðõ /Ý ?ß /ñ ×ÒÛÝð 
×	Ò	˜HÓ	%€ôS�=ô Sô(,˜5Ÿ>™>×2Ñ2ô ,ô0�—‘ô ÷%ñ %r   