+
    öäûj©  ã                   ó‚   a € R t	0 t R t^ RItR^ R^ R^R^R^R^/t] ^ k R R ltR	 R
 ltRR R lltR R ltR R ltR# )a5  Activations that a quantizer can absorb on the way in.

An MLP's ``linear(act(proj(x)))`` otherwise writes act's output to HBM and reads
it straight back to quantize it. Backends that can fold the activation into the
quantizer do so; the rest apply it here first and then quantize unchanged, so
every path produces the same result.

``swiglu`` is the gated pair variant: the input carries ``[gate | up]`` halves
on the last dim and the activation ``silu(gate) * up`` halves it, so the
quantized row is half as wide as the raw input row.

``situ`` is MOSS-Image's soft-capped gated pair on ``[hidden | gate]`` halves:
``4*tanh(gate/4)*sigmoid(gate) * 25*tanh(hidden/25)``, also halving the row.

``rms_norm`` is the row-wise ``x * rsqrt(mean(x^2) + eps) * w``; it carries a
K-element weight and an eps alongside the code.
NÚnoneÚ	gelu_tanhÚswigluÚrms_normÚsituc                ó>   € V ^8„  d   QhR\         R,          R\        /# ©é   Ú	input_actNÚreturn©ÚstrÚint)Úformats   "Ú_C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\comfy_kitchen\backends\_activations.pyÚ__annotate__r   #   s   € ÷ <ñ <œc D�jð <¬Sñ <ó    c                óf   €  \         V ,          #   \         d    \        \        T 4      4      Rhi ; i)z<Kernel code for `input_act`, rejecting anything unsupported.N)ÚINPUT_ACT_TO_CODEÚKeyErrorÚ
ValueErrorÚ_unsupported©r
   s   &r   Úinput_act_coder   #   s3   € ð<Ü  Õ+Ð+øÜô <Üœ iÓ0Ó1°tÐ;ð<ús   ‚ �!0c                ó>   € V ^8„  d   QhR\         R,          R\        /# r   r   )r   s   "r   r   r   +   s   € ÷ 7ñ 7œs T�zð 7¬cñ 7r   c                ó   € V R9   d   ^# ^# )zRHow many input columns produce one activated column (1, or 2 for the gated pairs).)r   r   © r   s   &r   Úinput_act_widthr   +   s   € àÐ/Ô/ˆ1Ð6°QÐ6r   c          
      ó¬   € V ^8„  d   QhR\         P                  R\        R,          R\         P                  R,          R\        R\         P                  /# )r	   Úxr
   NÚ
act_weightÚact_epsr   )ÚtorchÚTensorr   Úfloat)r   s   "r   r   r   0   sO   € ÷ .ñ .Ü‡|�|ð.ä�T�zð.ô —‘˜tÕ#ð.ô ð	.ô
 ‡\�\ñ.r   c                óv  € VR9   d   V # VR8X  d,   \         P                  P                  P                  V RR7      # VR8X  dN   V P	                  ^RR7      w  rE\         P                  P                  P                  V4      P                  V4      # VR8X  d¤   V P	                  ^RR7      w  rdVP                  R4      P                  4       P                  R4      P                  \         P                  ! V4      4      pVP                  R4      P                  4       P                  R4      P                  V4      # VR	8X  dg   Vf   \        R
4      h\         P                  P                  P                  W P                  R,          3VP                  V P                  4      VR7      # \        \        V4      4      h)zžApply the pre-quantization activation eagerly.

Used by backends and shapes the fused quantizer does not cover, so the
fallback result matches the fused one.
r   Útanh)Úapproximater   )Údimr   g      @g      9@r   z(input_act 'rms_norm' requires act_weight)ÚweightÚeps)Nr   éÿÿÿÿ)r"   ÚnnÚ
functionalÚgeluÚchunkÚsiluÚmul_ÚdivÚtanh_Úsigmoidr   r   ÚshapeÚtoÚdtyper   )r   r
   r    r!   ÚgateÚupÚhiddenÚgateds   &&&&    r   Úapply_input_actr<   0   sh  € ð �NÔ"ØˆØ�KÔÜ�x‰x×"Ñ"×'Ñ'¨°vÐ'Ó>Ð>Ø�HÔØ—7‘7˜1 "�7Ó%‰ˆÜ�x‰x×"Ñ"×'Ñ'¨Ó-×2Ñ2°2Ó6Ð6Ø�FÔð —w‘w˜q b�wÓ)‰ˆØ—‘˜“×#Ñ#Ó%×*Ñ*¨3Ó/×4Ñ4´U·]²]À4Ó5HÓIˆØ�z‰z˜$Ó×%Ñ%Ó'×,Ñ,¨TÓ2×7Ñ7¸Ó>Ð>Ø�JÔØÒÜÐGÓHÐHÜ�x‰x×"Ñ"×+Ñ+Ø—‘˜•ˆ~ j§m¡m°A·G±GÓ&<À'ð ,ó Kð 	Kä
”\ )Ó,Ó
-Ð-r   c                ó´   € V ^8„  d   QhR\         P                  R\         P                  R,          R\         P                  R,          R\         P                  /# )r	   ÚoutÚresidualNÚresidual_scaler   )r"   r#   )r   s   "r   r   r   Q   sP   € ÷ Tñ TÜ	�‰ðTä�l‰l˜TÕ!ðTô —L‘L 4Õ'ðTô ‡\�\ñ	Tr   c                ó¾   € Vf   V # Vf   \        R4      h\        P                  ! VP                  V P                  4      WP                  V P                  4      4      # )zg``residual + residual_scale * out`` in out's dtype (addcmul's type
promotion would otherwise widen it).z residual requires residual_scale)r   r"   Úaddcmulr6   r7   )r>   r?   r@   s   &&&r   Úapply_residualrC   Q   sN   € ð ÒØˆ
ØÒÜÐ;Ó<Ð<Ü�=Š=˜Ÿ™ S§Y¡YÓ/°×6GÑ6GÈÏ	É	Ó6RÓSÐSr   c                ó$   € V ^8„  d   QhR\         /# )r	   r   )r   )r   s   "r   r   r   _   s   € ÷ Mñ Mœsñ Mr   c                 óB   € \        R  \         4       4      pRV : RV R2# )c              3   ó0   "  € T F  qf   K  Vx € K  	  R # 5i)Nr   )Ú.0Úks   & r   Ú	<genexpr>Ú_unsupported.<locals>.<genexpr>`   s   é € ÐAÑ/˜—1’1Ó/ùs   ‚Œ
zunsupported input_act: z (expected one of Ú))Úsortedr   )r
   Úknowns   & r   r   r   _   s)   € ÜÑAÕ/ÓAÓA€EØ$ Y¡MÐ1CÀEÀ7È!ÐLÐLr   c                óp   € V ^8„  d   Qh/ ^ \         9   d"   \        \        R,          \        3,          ;R&   # )r	   Nr   )Ú__conditional_annotations__Údictr   r   )r   s   "r   r   r      s/   € ÷ ñ ÷,ò ”4œ˜d�
¤C˜Õ(ñ ò-r   )Ng        )
rO   Ú__doc__r"   r   r   r   r<   rC   r   r   )rO   s   @r   Ú<module>rR      sY   øðöó$ ð
 	ˆ!Ø
ˆAØ�ØˆaØ�Ø
ˆAð,Ð ó õ<õ7÷
.õBT÷Mr   