+
    QV-j�j  ã                  ó¼  € ^ RI Ht ^ RIHt ^ RIHt ^RIHt ^RIH	t	 ^RI
HtHtHtHt ^RIHt ^RIHt ]! 4       '       d;   ^ R	It]P(                  P+                  ]4      t]P(                  P+                  ]4      t]P,                  ! ]4      tR-R R lltR R ltR R ltR R ltR tR t]! 4       '       dZ   ]P>                  PA                  R]R.RR7       ]P>                  PC                  R]4       ]P>                  PE                  R]]R7       R R lt#R R lt$R-R R llt%R R  lt& ! R! R"]	4      t']'! 4       t(R# R$ lt)R/R%](R&R'R(R
R)R
R*R'/R+ R, lllt*R	# )0é    )Úannotations)ÚCallable)Úwraps)Úlogging)ÚGeneralInterface)Úis_torch_availableÚis_torch_greater_or_equalÚis_torch_less_or_equalÚis_torchdynamo_compiling)Údeepgemm_bf16_experts_forward)Úsonicmoe_experts_forwardNFc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	é   Úinputútorch.TensorÚweightÚbiasútorch.Tensor | NoneÚis_transposedÚboolÚreturn© )Úformats   "Ún/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/integrations/moe.pyÚ__annotate__r   T   s:   € ÷ ñ Øðàðð ðð ð	ð
 ñó    c                ó  € V'       d7   \         P                  ! V P                  ^4      V4      P                  ^4      pM4\         P                  ! WP                  R4      4      P                  R4      pVe   VP	                  V4       V# )a‚  Batched linear layer supporting optional bias and transposed weights.

Args:
    input (`torch.Tensor`):
        Input tensor of shape (batch_size, input_dim).
    weight (`torch.Tensor`):
        Weight tensor of shape (batch_size, output_dim, input_dim) if transposed is `False`,
        else of shape (batch_size, input_dim, output_dim).
    bias (`torch.Tensor`, *optional*):
        Bias tensor of shape (batch_size, output_dim). Default is `None`.
    is_transposed (`bool`, *optional*, defaults to `False`):
        Whether the weight tensor is transposed.
Returns:
    `torch.Tensor`: Output tensor of shape (batch_size, output_dim).
éÿÿÿÿ)ÚtorchÚbmmÚ	unsqueezeÚsqueezeÚadd_)r   r   r   r   Úouts   &&&& r   Ú_batched_linearr%   T   se   € ÷* ä�iŠi˜Ÿ™¨Ó*¨FÓ3×;Ñ;¸AÓ>‰ô �iŠi˜§¡°Ó 3Ó4×<Ñ<¸RÓ@ˆàÒØ�‰�Œà€Jr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# ©r   Úselfztorch.nn.ModuleÚhidden_statesr   Útop_k_indexÚtop_k_weightsr   r   )r   s   "r   r   r   v   s:   € ÷ =7ñ =7Ø
ð=7àð=7ð ð=7ð  ð	=7ð
 ñ=7r   c                ó  € VP                  R4      pVP                  ^ 4      pVP                  R4      pVP                  V^ R7      pVP                  R4      pVP                  R4      p	V	P                  ^ V P                  ^,
          4      p	V P
                  '       d<   V P                  V	,          p
V P                  '       d   V P                  V	,          MRpM:V P                  V	,          p
V P                  '       d   V P                  V	,          MRp\        WzW°P                  R7      pV P
                  '       d   V P                  V4      pMV P                  V4      pV P                  V	,          p
V P                  '       d   V P                   V	,          MRp\        WÊW°P                  R7      pWÈP#                  R4      ,          pVP%                  WTV4      P'                  ^R7      pVP)                  VP*                  4      # )é   ©ÚdimN©r   r   r   )ÚsizeÚrepeat_interleaveÚreshapeÚclampÚnum_expertsÚhas_gateÚgate_up_projÚhas_biasÚgate_up_proj_biasÚup_projÚup_proj_biasr%   r   Ú_apply_gateÚact_fnÚ	down_projÚdown_proj_biasr!   ÚviewÚsumÚtoÚdtype)r(   r)   r*   r+   Ú	num_top_kÚ
num_tokensÚ
hidden_dimÚselected_hidden_statesÚsample_weightsÚ
expert_idsÚselected_weightsÚselected_biasesÚproj_outÚweighted_outÚfinal_hidden_statess   &&&&           r   Úbatched_mm_experts_forwardrO   v   s¿  € ð × Ñ  Ó$€IØ×#Ñ# AÓ&€JØ×#Ñ# BÓ'€Jð +×<Ñ<¸YÈAÐ<ÓNÐØ"×*Ñ*¨2Ó.€NØ×$Ñ$ RÓ(€Jð ×!Ñ! ! T×%5Ñ%5¸Õ%9Ó:€Jð ‡}‡}€}Ø×,Ñ,¨ZÕ8ÐØ@DÇÇÀ˜$×0Ñ0°Ö<ÐSW‰àŸ<™<¨
Õ3ÐØ;?¿=¿=¸=˜$×+Ñ+¨JÖ7Èdˆô Ø°×VhÑVhô€Hð
 ‡}‡}€}à×#Ñ# HÓ-‰ð —;‘;˜xÓ(ˆð —~‘~ jÕ1ÐØ9=¿¿¸�d×)Ñ)¨*Ö5ÈD€Oô Ø¨×HZÑHZô€Hð
 ×6Ñ6°rÓ:Õ:€Lð '×+Ñ+¨JÀ:ÓN×RÑRÐWXÐRÓYÐà×!Ñ! -×"5Ñ"5Ó6Ð6r   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   r   r   r   Úoffsr   r   )r   s   "r   r   r   ¹   s)   € ÷ ñ  ð °lð È,ð Ð[gñ r   c                ó@  € \         P                  ! V P                  ^ 4      VP                  ^4      V P                  V P                  R7      p^ p\        VP                  4       4       F2  w  rVWF8X  d   K  \         P                  ! WV W,          W4V R7       TpK4  	  V# )a  
Fallback grouped matrix multiplication used when `torch.nn.functional.grouped_mm` and `torch._grouped_mm`
are unavailable or incompatible with `torch.compile` (e.g. non-bfloat16 weights).

Args:
    input (`torch.Tensor`): Input of shape (S, input_dim), sorted by expert id.
    weight (`torch.Tensor`): Expert weights of shape (num_experts, input_dim, output_dim).
    offs (`torch.Tensor`): Cumulative token counts per expert of shape (num_experts,).
Returns:
    `torch.Tensor`: Output of shape (S, output_dim).
©ÚdevicerC   ©r$   )r   Úzerosr1   rU   rC   Ú	enumerateÚtolistÚmm)r   r   rR   ÚoutputÚstartÚiÚends   &&&    r   Ú_grouped_mm_fallbackr_   ¹   s�   € ô �[Š[˜Ÿ™ A›¨¯©°A«¸u¿|¹|ÐSX×S^ÑS^Ô_€Fà€Eô ˜DŸK™K›MÖ*‰ˆØŒ<ÙÜ�Š�˜SÐ! 6¥9°&¸sÐ2CÕDØŠñ	 +ð €Mr   c               ó(   € V ^8„  d   QhRRRRRRRR/# rQ   r   )r   s   "r   r   r   Ó   s/   € ÷ ^ñ ^ \ð ^¸<ð ^È|ð ^Ð`lñ ^r   c                óŒ  € V P                  4       ^8X  g   Q R\        V P                  4       24       hVP                  4       ^8X  g   Q R\        VP                  4       24       hVP                  4       ^8X  g   Q R\        VP                  4       24       hVP                  ^ 4      VP                  ^ 4      8X  g,   Q RVP                  ^ 4       RVP                  ^ 4       24       hV P                  ^4      VP                  ^4      8X  g,   Q RV P                  ^4       RVP                  ^4       24       hVP                  \
        P                  \
        P                  39   g   Q RVP                   24       h\
        P                  ! V P                  ^ 4      VP                  ^4      V P                  V P                  R	7      # )
zRShape/dtype inference stub for `_grouped_mm_fallback` required by `torch.compile`.z+input must be 2D (S, input_dim), got shape zBweight must be 3D (num_experts, input_dim, output_dim), got shape z*offs must be 1D (num_experts,), got shape zoffs length z must match number of experts zinput_dim mismatch: input has z, weight has z$offs must be an integer tensor, got rT   )
r/   ÚtupleÚshaper1   rC   r   Úint32Úint64ÚemptyrU   ©r   r   rR   s   &&&r   Ú_grouped_mm_fallback_fakerh   Ó   s�  € à�9‰9‹;˜!ÔÐ_ÐJÌ5ÐQV×Q\ÑQ\ÓK]ÐJ^Ð_Ó_ÐØ�:‰:‹<˜1Ôð Ø
LÌUÐSY×S_ÑS_ÓM`ÐLaÐbóÐð �8‰8‹:˜Œ?Ð\ÐHÌÈtÏzÉzÓIZÐH[Ð\Ó\ˆ?Ø�9‰9�Q‹<˜6Ÿ;™; q›>Ô)Ðv¨\¸$¿)¹)ÀA»,¸ÐGeÐfl×fqÑfqÐrsÓftÐeuÐ+vÓvÐ)Ø�:‰:�a‹=˜FŸK™K¨›NÔ*ð Ø
(¨¯©°A«¨°}ÀVÇ[Á[ÐQRÃ^ÐDTÐUóÐ*ð �:‰:œ%Ÿ+™+¤u§{¡{Ð3Ô3ÐhÐ7[Ð\`×\fÑ\fÐ[gÐ5hÓhÐ3Ü�;Š;�u—z‘z !“} f§k¡k°!£n¸U¿\¹\ÐQV×Q\ÑQ\Ô]Ð]r   c                ób   € V P                  V^ ,          V^,          4       V^,          V n        R# )zjSaves input and weight for backward; offs is stored directly as it is a non-differentiable integer tensor.N)Úsave_for_backwardrR   )ÚctxÚinputsr[   s   &&&r   Ú"_grouped_mm_fallback_setup_contextrm   â   s%   € à×Ñ˜& �) V¨A¥YÔ/Ø�a�y€C†Hr   c                ó¢  € V P                   w  r#\        P                  ! V4      p\        P                  ! V4      p^ p\        V P                  P                  4       4       Fi  w  rxWh8X  d   K  \        P                  ! WV W7,          P                  WFV R7       \        P                  ! W&V P                  WV WW,          R7       TpKk  	  WER3# )zuBackward pass for `_grouped_mm_fallback`. Computes grad_input and grad_weight per expert group; offs has no gradient.rV   N)Úsaved_tensorsr   Ú
zeros_likerX   rR   rY   rZ   ÚT)	rk   Úgrad_outputr   r   Ú
grad_inputÚgrad_weightr\   r]   r^   s	   &&       r   Ú_grouped_mm_fallback_backwardru   è   s®   € à×%Ñ%�M€EÜ×!Ò! %Ó(€JÜ×"Ò" 6Ó*€Kà€Eô ˜CŸH™HŸO™OÓ-Ö.‰ˆØŒ<ÙÜ�Š� 3Ð'¨­¯©¸*È3Ð:OÕPÜ�Š�˜SÐ!×#Ñ# [°sÐ%;ÀÅÕPØŠñ /ð  DÐ(Ð(r   z!transformers::grouped_mm_fallbackz4(Tensor input, Tensor weight, Tensor offs) -> Tensor)Úmutates_argsÚschema)Úsetup_contextc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   r   rR   r   r   r   )r   s   "r   r   r   
  s/   € ÷ *Wñ *W˜|ð *W°\ð *WÈð *WÐZ^ñ *Wr   c                ó�  € \        4       '       d    VP                  \        P                  8w  gg   VP                  P
                  R8X  dN   \        RRR7      '       d;   VP                  4       ^,          ^ 8w  g   V P                  4       ^,          ^ 8w  d   R# VP                  P
                  R8X  dÚ   \        \        P                  P                  R4      '       d-   \        P                  P                  VP                  4      R
8¬  # \        \        R4      '       dl   \        R	RR7      '       d-   \        P                  P                  VP                  4      R
8¬  # \        P                  P                  VP                  4      R8¬  # R# \        \        P                  P                  R4      ;'       g    \        \        R4      # )aî  
Check if torch.nn.functional.grouped_mm or torch._grouped_mm can be used based on availability and compatibility with torch.compile.

Args:
    input (`torch.Tensor`):
        Input tensor of shape (S, input_dim).
    weight (`torch.Tensor`):
        Weight tensor of shape (num_experts, input_dim, output_dim).
    offs (`torch.Tensor`):
        Offsets tensor indicating the boundaries of each group in the input tensor.
Returns:
    `bool`: True if grouped_mm can be used, False otherwise.
Úcpuz2.10.0T)Ú
accept_devFÚcudaÚ
grouped_mmÚ_grouped_mmz2.9)é   r   )é	   r   )r   rC   r   Úbfloat16rU   Útyper
   Údata_ptrÚhasattrÚnnÚ
functionalr}   Úget_device_capabilityr	   rg   s   &&&r   Ú_can_use_grouped_mmr‰   
  s/  € ô 	!×"Ò" v§|¡|´u·~±~Ô'EØ�‰×Ñ˜eÔ#ä" 8¸×=Ó=Ø�_‰_Ó Õ# qÔ(¨E¯N©NÓ,<¸rÕ,AÀQÔ,Fñ ð
 ‡}�}×Ñ˜VÔ#Ü”5—8‘8×&Ñ&¨×5Ò5Ü—:‘:×3Ñ3°F·M±MÓBÀfÑLÐLÜ”5˜-×(Ò(Ü(¨¸4×@Ó@Ü—z‘z×7Ñ7¸¿¹ÓFÈ&ÑPÐPä—z‘z×7Ñ7¸¿¹ÓFÈ&ÑPÐPáä”5—8‘8×&Ñ&¨Ó5×VÐV¼ÄÈÓ9VÐVr   c               ó(   € V ^8„  d   QhRRRRRRRR/# rQ   r   )r   s   "r   r   r   7  s6   € ÷ Pñ PØðPàðPð ðPð ñ	Pr   c                óæ  € \        WV4      '       d¶   \        \        P                  P                  R4      '       dE   \        P                  P                  P                  V P                  VP                  4      WR7      # \        \        R4      '       d2   \        P                  ! V P                  VP                  4      WR7      # \        P                  P                  P                  WVR7      # )aí  Grouped matrix multiplication dispatcher that uses torch.nn.functional.grouped_mm if available, else falls back to torch._grouped_mm.

Args:
    input (`torch.Tensor`):
        Input tensor of shape (S, input_dim).
    weight (`torch.Tensor`):
        Weight tensor of shape (num_experts, input_dim, output_dim).
    offs (`torch.Tensor`):
        Offsets tensor indicating the boundaries of each group in the input tensor.
Returns:
    `torch.Tensor`: Output tensor of shape (S, output_dim).
r~   ©rR   r   )r‰   r…   r   r†   r‡   r~   rB   rC   r   ÚopsÚtransformersÚgrouped_mm_fallbackrg   s   &&&r   r   r   7  s¤   € ô$ ˜5¨$×/Ò/ô
 ”5—8‘8×&Ñ&¨×5Ò5Ü—8‘8×&Ñ&×1Ñ1°%·(±(¸6¿<¹<Ó2HÈ&Ð1Ó\Ð\Ü”U˜M×*Ò*Ü×$Ò$ U§X¡X¨f¯l©lÓ%;¸VÔOÐOä�9‰9×!Ñ!×5Ñ5°eÈ$Ð5ÓOÐOr   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R/# )
r   r   r   r   rR   r   r   r   r   r   r   )r   s   "r   r   r   V  sD   € ÷ #ñ #Øð#àð#ð ð#ð ð	#ð
 ð#ð ñ#r   c                ó–   € V'       d   \        WVR7      pM\        WP                  RR4      VR7      pVe   VP                  V4       V# )aÜ  Grouped linear layer supporting optional bias and transposed weights.

Args:
    input (`torch.Tensor`):
        Input tensor of shape (S, input_dim).
    weight (`torch.Tensor`):
        Weight tensor of shape (num_experts, input_dim, output_dim) if `is_transposed`,
        else of shape (num_experts, output_dim, input_dim).
    offs (`torch.Tensor`):
        Offsets tensor indicating the boundaries of each group in the input tensor.
    bias (`torch.Tensor`, *optional*):
        Bias tensor of shape (num_experts, output_dim). Default is `None`.
    is_transposed (`bool`, *optional*, defaults to `False`):
        Whether the weight tensor is transposed.
Returns:
    `torch.Tensor`: Output tensor of shape (S, output_dim).
rŒ   éþÿÿÿr   )r   Ú	transposer#   )r   r   rR   r   r   r$   s   &&&&& r   Ú_grouped_linearr”   V  sD   € ÷0 ä˜%¨dÔ3‰ô ˜%×!1Ñ!1°"°bÓ!9ÀÔEˆàÒà�‰�Œà€Jr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# r'   r   )r   s   "r   r   r   |  sA   € ÷ e7ñ e7Ø
ðe7àðe7ð ðe7ð  ð	e7ð
 ñe7r   c                óh  € VP                   pVP                  R	4      pVP                  ^ 4      pVP                  R	4      pVP                  R	4      pVP                  R	4      p	\        P                  ! V	4      w  r«WV,          ,          pW‹,          pVP
                  R
9   d   V
P                  4       MV
P                  4       p\        P                  ! WàP                  ^ V P                  ^,
          R7      p\        P                  ! V^ \        P                  R7      pW P                  8¬  P                  R	4      pV
P                  V P                  ^,
          R7       V P                  '       d5   V P                  pV P                   '       d   V P"                  V
,          MRpM3V P$                  pV P                   '       d   V P&                  V
,          MRpVP)                  VR4       \+        VVVVV P,                  R7      pV P                  '       d   V P/                  V4      pMV P1                  V4      pV P2                  pV P                   '       d   V P4                  V
,          MRp\+        VVVVV P,                  R7      pVVP                  R	4      ,          pVP)                  VR4       \        P6                  ! V4      p\        P8                  ! VP                  ^ 4      VR7      VV&   VV,          pVP;                  WeV4      P=                  ^R7      pVP?                  VP@                  4      # )r-   )ÚbinsÚminÚmax)r/   rC   )r™   Ng        r0   )rU   r.   r   )r{   Úmps)!rU   r1   r3   r   Úsortrƒ   ÚfloatÚintÚhistcr5   Úcumsumrd   r!   Úclamp_r6   r7   r8   r9   r:   r;   Úmasked_fill_r”   r   r<   r=   r>   r?   Ú
empty_likeÚaranger@   rA   rB   rC   )r(   r)   r*   r+   rU   rD   rE   rF   rH   rI   Úexpert_ids_gÚpermÚselected_hidden_states_gÚsample_weights_gÚhistc_inputÚtokens_per_expertÚoffsetsÚsentinel_maskrJ   rK   rL   rM   Úinv_permrN   s   &&&&                    r   Úgrouped_mm_experts_forwardr­   |  sº  € ð ×!Ñ!€FØ× Ñ  Ó$€IØ×#Ñ# AÓ&€JØ×#Ñ# BÓ'€Jð #×*Ñ*¨2Ó.€NØ×$Ñ$ RÓ(€Jô Ÿš JÓ/Ñ€LØ,°YÕ->Õ?ÐØ%Õ+Ðð +1¯+©+¸Ô*G�,×$Ñ$Ô&È\×M]ÑM]ÓM_€KÜŸš K×6FÑ6FÈAÐSW×ScÑScÐfgÕSgÔhÐÜ�lŠlÐ,°!¼5¿;¹;ÔG€Gð" "×%5Ñ%5Ñ5×@Ñ@ÀÓD€MØ×Ñ˜D×,Ñ,¨qÕ0ÐÔ1ð ‡}‡}€}Ø×,Ñ,ÐØBFÇ-Ç-À-˜$×0Ñ0°Ö>ÐUY‰àŸ<™<ÐØ=A¿]¿]¸]˜$×+Ñ+¨LÖ9ÐPTˆð ×)Ñ)¨-¸Ô=ô Ø Ð"2°GÀ/Ðae×asÑasô€Hð
 ‡}‡}€}à×#Ñ# HÓ-‰ð —;‘;˜xÓ(ˆð —~‘~ÐØ;?¿=¿=¸=�d×)Ñ)¨,Ö7Èd€Oô ØÐ" G°/ÐQU×QcÑQcô€Hð
 Ð.×8Ñ8¸Ó<Õ<€Lð ×Ñ˜m¨SÔ1ô ×Ò Ó%€HÜ—\’\ $§)¡)¨A£,°vÔ>€HˆT�NØ Õ)€Lð '×+Ñ+¨JÀ:ÓN×RÑRÐWXÐRÓYÐà×!Ñ! -×"5Ñ"5Ó6Ð6r   c                  óF   a € ] tR tRtRtR]R]R]R]/t	R V 3R llt
R	tV ;t# )
ÚExpertsInterfaceiä  z;Interface for registering custom experts forward functions.ÚdeepgemmÚ
batched_mmr~   Úsonicmoec               ó$   € V ^8„  d   QhRRRRRR/# )r   Úexperts_implementationÚstrÚdefaultr   r   r   )r   s   "r   r   ÚExpertsInterface.__annotate__î  s!   € ÷ <ñ <°Cð <À(ð <Èxñ <r   c                óŽ   <€ Vf   \         P                  R4       MVR8w  d   W9  d   \        RV R24      h\        SV `  W4      # )zfReturn the requested `experts_implementation`. Also strictly check its validity, and raise if invalid.a
  You tried to access the `ExpertsInterface` with a `config._experts_implementation` set to `None`. This is expected if you use an Expert Module as a standalone Module. If this is not the case, something went wrong with the dispatch of `config._experts_implementation`ÚeagerÚ`zL` is not a valid experts implementation registered in the `ExpertsInterface`)ÚloggerÚwarning_onceÚKeyErrorÚsuperÚget)r(   r´   r¶   Ú	__class__s   &&&€r   Úget_interfaceÚExpertsInterface.get_interfaceî  s[   ø€ à!Ò)Ü×ÑðNõð
 $ wÔ.Ð3IÔ3UÜØÐ*Ð+Ð+wÐxóð ô ‰w‰{Ð1Ó;Ð;r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   rO   r­   r   Ú_global_mappingrÁ   Ú__static_attributes__Ú__classcell__)rÀ   s   @r   r¯   r¯   ä  s1   ø† ÙEð 	Ð1ØÐ0ØÐ0ØÐ,ð	€O÷<ö <r   r¯   c               ó    € V ^8„  d   QhRRRR/# )r   Úgate_up_outr   r   r   )r   s   "r   r   r      s   € ÷ "ñ "¨<ð "¸Lñ "r   c                ó\   € VP                  ^RR7      w  r#V P                  V4      V,          # )a{  
Default gating mechanism: splits the gate_up_out into gate and up parts,
applies the activation function to the gate part, and multiplies it with the up part.
Args:
    gate_up_out (`torch.Tensor`):
        The output tensor from the gate and up projection of shape (S, 2 * intermediate_dim).
Returns:
    `torch.Tensor`: The gated output tensor of shape (S, intermediate_dim).
r.   r   )Úchunkr=   )r(   rÌ   ÚgateÚups   &&  r   Ú_default_apply_gaterÑ      s/   € ð × Ñ  ¨Ð Ó+�H€DØ�;‰;�tÓ˜rÕ!Ð!r   Úexperts_interfaceÚis_concatenatedTr   r8   r6   c               ó4   € V ^8„  d   QhRRRRRRRRRRR	RR
R/# )r   Úexperts_classztype[torch.nn.Module] | NonerÒ   r¯   rÓ   r   r   r8   r6   r   útype[torch.nn.Module]r   )r   s   "r   r   r     sP   € ÷ ;ñ ;Ø/ð;ð (ð;ð ð	;ð
 ð;ð ð;ð ð;ð ñ;r   c               óB   aaaaa€ R VVVVV3R llpV e	   V! V 4      # V# )a\  Decorator to modify experts class to support different experts implementations.

Args:
    experts_class (`type[torch.nn.Module]`, *optional*):
        The experts class to modify. If not provided, returns a decorator that can be applied to the class.
    experts_interface (`ExpertsInterface`, *optional*, defaults to `ALL_EXPERTS_FUNCTIONS`):
        The experts interface to use for dispatching the forward method.
    is_concatenated (`bool`, *optional*, defaults to `True`):
        Whether the expert weights are stored in concatenated layout [gate;up]
        or interleaved layout [gate0, up0, gate1, up1, ...].
    is_transposed (`bool`, *optional*, defaults to `False`):
        Whether the expert weights are stored in transposed format.
    has_bias (`bool`, *optional*, defaults to `False`):
        Whether the expert layers include bias terms or not.
    has_gate (`bool`, *optional*, defaults to `True`):
        Whether the experts use a gating mechanism or not.
        Whether it has gate_up_proj weights or just up_proj weights.

Returns:
    `type[torch.nn.Module]`: The modified experts class.
c               ó    € V ^8„  d   QhRRRR/# )r   rÕ   rÖ   r   r   )r   s   "r   r   Ú0use_experts_implementation.<locals>.__annotate__-  s   € ÷ ñ Ð4ð Ð9Nñ r   c                óè   <aa€ V P                   oV P                  o\        S4      VVVV	V3R  l4       p\        S4      VV3R l4       p\        V R4      '       g   \        V n        Wn         W n        V # )c                ód   <€ S! W.VO5/ VB  Wn         SV n        SV n        SV n        SV n        R # ©N)Úconfigr6   r8   r   rÓ   )	r(   rÝ   ÚargsÚkwargsr8   r6   rÓ   r   Úoriginal_inits	   &&*,€€€€€r   Ú__init__Ú=use_experts_implementation.<locals>.wrapper.<locals>.__init__1  s8   ø€ á˜$Ð8¨Ò8°Ò8Ø ŒKØ$ˆDŒMØ$ˆDŒMØ!.ˆDÔØ#2ˆDÖ r   c                óh   <€ SP                  V P                  P                  S4      pV! V .VO5/ VB # rÜ   )rÁ   rÝ   Ú_experts_implementation)r(   rÞ   rß   Úexperts_forwardrÒ   Úoriginal_forwards   &*, €€r   ÚforwardÚ<use_experts_implementation.<locals>.wrapper.<locals>.forward:  s5   ø€ à/×=Ñ=¸d¿k¹k×>aÑ>aÐcsÓtˆOÙ" 4Ð9¨$Ò9°&Ñ9Ð9r   r<   )rá   rç   r   r…   rÑ   r<   )
rÕ   rá   rç   ræ   rà   rÒ   r8   r6   rÓ   r   s
   &  @@€€€€€r   ÚwrapperÚ+use_experts_implementation.<locals>.wrapper-  sy   ú€ Ø%×.Ñ.ˆØ(×0Ñ0Ðä	ˆ}Ó	÷	3ð 	3ó 
ð	3ô 
ÐÓ	 õ	:ó 
!ð	:ô �} m×4Ò4Ü(;ˆMÔ%à!)ÔØ 'ÔØÐr   r   )rÕ   rÒ   rÓ   r   r8   r6   ré   s   &ddddd r   Úuse_experts_implementationrë     s%   ü€ ÷>ô ð2 Ò Ù�}Ó%Ð%à€Nr   )NFr   rÜ   )+Ú
__future__r   Úcollections.abcr   Ú	functoolsr   Úutilsr   Úutils.genericr   Úutils.import_utilsr   r	   r
   r   r°   r   r²   r   r   Ú_dynamoÚassume_constant_resultÚ
get_loggerrÃ   r»   r%   rO   r_   rh   rm   ru   ÚlibraryÚ	custom_opÚregister_fakeÚregister_autogradr‰   r   r”   r­   r¯   ÚALL_EXPERTS_FUNCTIONSrÑ   rë   r   r   r   Ú<module>rú      sr  ðõ #å $Ý å Ý ,÷ó õ 4Ý .ñ ×ÒÛð
 !&§¡× DÑ DÐE^Ó _ÐØ"Ÿ]™]×AÑAÐBXÓYÐð 
×	Ò	˜HÓ	%€÷VõD=7õFõ4^òò)ñ& ×ÒØ	‡M�M×ÑØ+ØØØEð	 ô ð 
‡M�M×ÑÐ CÐE^Ô_Ø	‡M�M×#Ñ#Ø+Ø%Ø8ð $ô õ*WõZP÷>#õLe7ôP<Ð'ô <ñ2 )Ó*Ð õ"ñ;ð +@ð;ð !ð	;ð
  ð;ð ð;ð ÷;ò ;r   