
    IЦi                     (   S SK r S SKrS SKrS SKrS SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJr  S SKJr  S SKrSSKJrJr  SSKJrJr  SSKJrJr  SSKJrJr  SS	KJrJ r J!r!J"r"  SS
K#J$r$J%r%J&r&J'r'J(r(J)r)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0   S SK1J2r2  \(       a  S SK4J5r5  S SK6J7r7J8r8  \" S\S9r9S:S;S jjr:S;S jr;S\	\<\.4   4S jr=S r> " S S\.5      r? " S S\?5      r@ " S S\@5      rA " S S\A5      rB " S  S!\@5      rCS;S" jrD " S# S$\?5      rE " S% S&\.5      rF " S' S(\.5      rGS) rHS;S* jrI " S+ S,\@5      rJ " S- S.\.5      rK " S/ S0\.5      rLS S1K6JMrMJNrN   " S2 S3\N5      rO\O" 5       rP " S4 S5\.5      rQ " S6 S7\.5      rR " S8 S9\.5      rSg! \3 a    Sr2 GNf = f)<    N)AnyCallableDictListOptionalTupleTYPE_CHECKINGTypeVar)Never   )	polyfills	variables)create_call_functioncreate_rot_n)unimplementedUnsupported)GuardBuilderinstall_guard)
AttrSourceConstantSourceDefaultsSourceGetItemSource)check_constant_argscheck_unspec_or_constant_argsidentityis_functionis_wrapper_or_member_descriptoristype	make_cell   )typestrValueMutationNewVariableTrackerConstantVariable)_fsdp_param_group)InstructionTranslator)TritonGridTypeTritonKernelType_F)boundc                     [        U[        5      (       a  U$ U(       d  [        R                  " X5      $ [        R                  R                  X5      $ N)
isinstancer#   buildr   LazyVariableTrackercreate)txvalsources      `/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/_dynamo/variables/functions.pywrap_bound_argr6   1   sA    #''
$$R-- ,,33C@@    c                     [        UR                  5       5       H/  u  p#[        U[        [        45      (       d  M"  [        X5      X'   M1     g r-   )listitemsr.   tupledictr6   )r2   resultkvs       r5   wrap_args_kwargsr@   =   s6    V\\^$a%''&r-FI %r7   r=   c                     U R                   R                  nUR                   H<  nUR                  5       nXA;   a   UR	                  XQR                  U5      5        XQU'   M>     g)z
Update `result` to add mapping from local name to new cells created
directly by `code`, or update SideEffects in `parent` if the a local cell is
already in `result` (cell argument).
N)outputside_effectsco_cellvarstrack_cell_new
store_cellpop)parentr=   coderC   namenew_cells         r5   init_cellvarsrL   D   sV     ==--L  ..0> ##Hjj.>?t !r7   c                     SSK Jn  U" XX#U5      nXXl        [        U[        5      (       a  SSKJn	  [        U	" U5      5      nUb  [        U[        5      (       d   eXhl        U$ )Nr   )FunctionTypepairwise)	typesrN   __kwdefaults__r.   r;   	itertoolsrP   r<   __annotations__)
rI   	f_globalsrJ   defaultsclosure
kwdefaultsannotationsrN   funcrP   s
             r5   _create_nested_fnr[   U   s_     #AD$+u%%&8K01 *[$"?"???&Kr7   c                   \    \ rS rSrS rS r        SS jrSSS\S\4S	 jr	S
 r
S rSrg)BaseUserFunctionVariablei   c                 6    U R                  5       R                  $ r-   )get_codeco_filenameselfs    r5   get_filename%BaseUserFunctionVariable.get_filenamej   s    }}***r7   c                 6    U R                  5       R                  $ r-   )r`   co_namerb   s    r5   get_name!BaseUserFunctionVariable.get_namem   s    }}&&&r7   r2   r'   returnc                 L    UR                  U / U R                  5       QUQU5      $ r-   )inline_user_function_return	self_argsrc   r2   argskwargss       r5   call_function&BaseUserFunctionVariable.call_functionp   s,     --d4Ndnn6F4N4NPVWWr7   rJ   c                     Sn [        U R                  5       U5      n[
        R                  R                  U5      $ ! [         a     US:X  a  [        U [        5      (       a  Sn NHf = f)NF__name__T)hasattrget_functionNotImplementedErrorr.   NestedUserFunctionVariabler   r%   r1   rc   r2   rJ   r=   s       r5   call_hasattr%BaseUserFunctionVariable.call_hasattrx   sf    	T..0$7F ))0088 # 	z!j7Q&R&R	s   = 'A'&A'c                 p    [        [        R                  " U R                  5       5      R                  5      $ r-   )r9   inspect	signaturerv   
parametersrb   s    r5   inspect_parameter_names0BaseUserFunctionVariable.inspect_parameter_names   s'    G%%d&7&7&9:EEFFr7   c                     0 $ r-    )rc   r2   s     r5   closure_vars%BaseUserFunctionVariable.closure_vars       	r7   r   Nr2   r'   ro   List[VariableTracker]rp   Dict[str, VariableTracker]rj   r#   )rt   
__module____qualname____firstlineno__rd   rh   rq   strr#   rz   r   r   __static_attributes__r   r7   r5   r]   r]   i   sb    +'X#X &X -	X
 
X96 9c 9o 9Gr7   r]   c                      ^  \ rS rSrSrSS1\R                  kr\S 5       rSSU 4S jjjr	U 4S jr
S	 rS
 rS rS rS rS rS\\\4   4S jrSSS\4S jrSSS\S\4S jr        SU 4S jjrSrU =r$ )UserFunctionVariable   z-Some unsupported user-defined global functionfnis_constantc                 ^    [        UR                  [        R                  5      5        U " XS9$ Nr4   )r   
make_guardr   CLOSURE_MATCHclsvaluer4   s      r5   create_with_source'UserFunctionVariable.create_with_source   s&    f''(B(BCD5((r7   rj   c                 B  > [         TU ]  " S0 UD6  [        USS5      (       a  SU l        OSU l        [	        U[
        R                  [        R                  R                  45      (       d   S[        U5       SU 35       e[        R                  " USU5      nXl        g )N_dynamo_marked_constantFTzexpected FunctionType found  _torchdynamo_inliner   )super__init__getattrr   r.   rQ   rN   torchjitScriptFunctionr!   r}   getattr_staticr   )rc   r   r   rp   	__class__s       r5   r   UserFunctionVariable.__init__   s    "6"20%88#D$D##UYY%=%=>
 
 	=)'"+at<	= 
 ##B(=rB&(r7   c                 b   > [        U [        5      (       a  U R                  $ [        TU ]  5       $ r-   )r   r   r   r   as_python_constantrc   r   s    r5   r   'UserFunctionVariable.as_python_constant   s(    $,--77Nw)++r7   c                     / $ r-   r   rb   s    r5   rm   UserFunctionVariable.self_args   r   r7   c                     U R                   $ r-   r   rb   s    r5   rv   !UserFunctionVariable.get_function       wwr7   c                 .    U R                   R                  $ r-   )r   __code__rb   s    r5   r`   UserFunctionVariable.get_code   s    wwr7   c                 "    [         R                  $ r-   )rQ   rN   rb   s    r5   python_type UserFunctionVariable.python_type   s    !!!r7   c                 4    [        U R                  SS 5      S L$ )N__self__)r   r   rb   s    r5   has_selfUserFunctionVariable.has_self   s    tww
D1==r7   c                 .    U R                   R                  $ r-   )r   __globals__rb   s    r5   get_globals UserFunctionVariable.get_globals   s    ww"""r7   c                    U R                   (       a   eUR                  R                  n[        R                  " [
        US9nU R                  nUR                  =(       d    / n[        U5       VV	s/ s H*  u  pU R                  c  SO[        U R                  U5      PM,     n
nn	[        R                  " UR                  UR                  UR                  [!        [#        Xz5       VVs/ s H  u  pU" XS9PM     snn5      UR$                  5      nUR&                  (       a{  UR&                   Vs0 s H(  nUU R                  c  SO[        U R                  USS9_M*     nnUR&                  R)                  5        VVs0 s H  u  nnX" UX   S9_M     snnUl        [*        R,                  " U5      R.                  " U0 UD6nUR1                  5         [3        UR4                  R)                  5       5      n[7        UU5        [9        UUUR                  5        U R                  R$                  =(       d    Sn[;        U5      [;        U R                  R                  R<                  5      :X  d   e[#        [>        R@                  " 5       U R                  R                  R<                  U5       H  u  nnnUR                  RB                  nUU;   a  UU   nOU R                  (       ac  [E        [G        U R                  S5      U5      n[G        US5      n [H        RJ                  " UURL                  U5      nURU                  UUU5      nO5 [H        RJ                  " UURL                  5      nURU                  SUU5      nUUU'   M     U$ s  sn	nf s  snnf s  snf s  snnf ! [N         a    [P        RR                  " 5       n Nf = f! [N         a    [P        RR                  " 5       n N{f = f)	z
Assume `args` and `kwargs` are VariableTracker arguments for a call to
this function, create new bindings for initial locals.
)r2   N)r3   r4   T)is_kwr   __closure__cell_contents)+r   rB   root_tx	functoolspartialr6   r   __defaults__	enumerater4   r   rQ   rN   r   r   rt   r;   zipr   rR   r:   r}   r~   bindapply_defaultsr<   	argumentsr@   rL   lenco_freevarsrS   countrC   r   r   r#   r/   r   
ValueErrorr   DeletedVariabletrack_cell_existing)rc   rH   ro   rp   r   wrapr   rV   idx_defaults_sourcesargr4   	fake_funcr>   kwdefaults_sourcesr?   r+   r=   rW   rJ   cellrC   cell_varclosure_cellclosure_cell_contentscontents_vars                              r5   	bind_argsUserFunctionVariable.bind_args   s   
 ####--''  G<!%??(b $H-
- KK'D^DKK-MM- 	 
 &&KKNNKK (+8'F'F S0'F NN
	  **" +A {{* 'QdCD
 +  " --335(5DAq 4A&8&;<<5(I$
 !!),114B6Beoo++-.&)ffbkk2''%%+7|s477#3#3#?#?@@@@"OOtww//;;W 
OCt "==55L|#'-,t{{M:C  )3<(Q%?#2#8#8 2 24I$L (;; $?#2#8#8ASAS#TL (;;D$U#F4LE 
H U
"(< " ?#,#<#<#>L? " ?#,#<#<#>L?s<   21N*N2/N N"N$!O	$OO	O+*O+r2   r'   rJ   c                 Z   U R                   =(       a    [        U R                   U5      n [        R                  " U R                  U5      nU(       a  [        R                  R                  XC5      $ [        R                  " X5      $ ! [
         a    [        R                  " XUS9s $ f = fr   )r4   r   r}   r   r   AttributeErrorr   GetAttrVariabler0   r1   r#   r/   )rc   r2   rJ   r4   subobjs        r5   var_getattr UserFunctionVariable.var_getattr  s    >DKK!>	H++DGGT:F 0077GG$$R00	  	H,,TGG	Hs   !B B*)B*c                 l    [        U R                  U5      n[        R                  R	                  U5      $ r-   )ru   r   r   r%   r1   ry   s       r5   rz   !UserFunctionVariable.call_hasattr!  s)    $'))0088r7   c                 P  > U R                   (       a%  [        XR                  U R                  5       X#5      $ UR                  R
                  R                  (       a  UR                  R
                  R                  (       ds   SSKJ	n  Ubi  U R                  UR                  UR                  4;   aC  [        R                  R                  R                  U5         [         TU ]E  XU5      sS S S 5        $ [         TU ]E  XU5      $ ! [         a    S n Nf = f! , (       d  f       N0= f)Nr   )	FSDPState)r   invoke_and_store_as_constantr   rh   rB   current_tracerunder_activation_checkpoint#allow_side_effects_under_checkpoint/torch.distributed.fsdp._fully_shard._fsdp_stater   	Exception_pre_forward_post_forwardr   _dynamorC   r   rq   )rc   r2   ro   rp   r   r   s        r5   rq   "UserFunctionVariable.call_function%  s     /GGT]]_d  II$$@@II,,PP!U $&&''5 * ]]//SSTVW 706B XWw$Rv66  ! 	! XWs   D DDD
D%)r   r   )Frj   Nr   )rt   r   r   r   __doc__r]   _nonvar_fieldsclassmethodr   r   r   rm   rv   r`   r   r   r   r   r   r#   r   r   rz   rq   r   __classcell__r   s   @r5   r   r      s    7 	 
"	0	0N ) )) )", ">#Uc?6J1K Un15 1S 196 9c 9o 97#7 &7 -	7
 
7 7r7   r   c                   v   ^  \ rS rSrSrSU 4S jjrS\4S jrS rS r	        SU 4S jjr
U 4S	 jrS
rU =r$ )UserMethodVariablei@  z$Some unsupported user-defined methodrj   c                 6   > [         TU ]  " SSU0UD6  X l        g )Nr   r   )r   r   obj)rc   r   r  rp   r   s       r5   r   UserMethodVariable.__init__C  s    )B)&)r7   c                 h    U R                   R                   SU R                   SU R                   S3$ )N(z, ))r   rt   r   r  rb   s    r5   __repr__UserMethodVariable.__repr__G  s.    ..))*!DGG9BtxxjBBr7   c                     U R                   /$ r-   r  rb   s    r5   rm   UserMethodVariable.self_argsJ  s    zr7   c                 "    [         R                  $ r-   )rQ   
MethodTyperb   s    r5   r   UserMethodVariable.python_typeM  s    r7   c                 N  > UR                   R                  5       (       a  [        U R                  [        R
                  5      (       a  [        U R                  SS5      nUb  UR                  S5      (       a  US:w  d  U R                  (       a9  U R                  R                  XR                  R                  X#U R                  S9$ Ol[        be  U R                  [        R                  R                  L a>  [        R                  " U R                  5      R!                  XR                  /UQ7U5      $ U R                  (       aO  [        U R                  R"                  U R                  R                  5      n[%        XU R'                  5       X#5      $ [(        TU ]A  XU5      $ )Nr    z	torch.nn.ztorch.nn.utils.parametrize)constant)rB   is_root_tracerr.   r  r   NNModuleVariabler   r   
startswithr   call_methodrt   r&   FSDPParamGroupuse_training_stateTorchCtxManagerClassVariablerq   r   r   rh   r   )rc   r2   ro   rp   module_attrr   r   s         r5   rq    UserMethodVariable.call_functionP  sN   $ 99##%%*HHi00+
 +
 "$''<<K '**;77#??##xx++(($AQAQ ,   $ ),;;NNN99$''BPPXX%%v  )9)9:B/VVw$Rv66r7   c                 &   > [         TU ]  5       SS  $ )Nr    )r   r   r   s    r5   r   *UserMethodVariable.inspect_parameter_names|  s    w.044r7   r	  r   r   )rt   r   r   r   r   r   r   r  rm   r   rq   r   r   r   r   s   @r5   r   r   @  sY    .C# C *7#*7 &*7 -	*7
 
*7X5 5r7   r   c                   L   ^  \ rS rSrSU 4S jjr        SU 4S jjrSrU =r$ )WrappedUserMethodVariablei  c                    > UR                  SS 5        UR                  SS 5        [        TU ]  " UR                  UR                  40 UD6  Xl        X l        g Nr   r  )rG   r   r   r   r  wrappedcontextrc   r   r!  rp   r   s       r5   r   "WrappedUserMethodVariable.__init__  sE    

4

5$W[[;F;r7   c                    > U R                   R                  U5        [        TU ]  XU5      nU R                   R	                  U5        U$ r-   r!  enterr   rq   exitrc   r2   ro   rp   r=   r   s        r5   rq   'WrappedUserMethodVariable.call_function  ?     	2&r8"r7   r!  r   r   r   rt   r   r   r   r   rq   r   r   r   s   @r5   r  r    8    	#	 &	 -		
 
	 	r7   r  c                   L   ^  \ rS rSrSU 4S jjr        SU 4S jjrSrU =r$ )WrappedUserFunctionVariablei  c                    > UR                  SS 5        UR                  SS 5        [        TU ]  " UR                  40 UD6  Xl        X l        g r  )rG   r   r   r   r   r!  r"  s       r5   r   $WrappedUserFunctionVariable.__init__  s?    

4

5$.v.r7   c                    > U R                   R                  U5        [        TU ]  XU5      nU R                   R	                  U5        U$ r-   r%  r(  s        r5   rq   )WrappedUserFunctionVariable.call_function  r*  r7   r+  r   r   r,  r   s   @r5   r/  r/    r-  r7   r/  c                     S nU Vs/ s H
  oe" U5      PM     nnUR                  5        VVs0 s H  u  pxXu" U5      _M     nnnU" U0 UD6n	U R                  R                  U	U[        U5      S9$ s  snf s  snnf )Nc                     [        U [        R                  5      (       a  U R                  5       $ U R	                  5       $ r-   )r.   r   TensorVariableget_real_valuer   )xs    r5   convert-invoke_and_store_as_constant.<locals>.convert  s3    a1122##%%##%%r7   r   )r:   rB   register_attr_or_moduler   )
r2   r   rJ   ro   rp   r9  r8  r>   r?   ress
             r5   r   r     s    &
 !%%1GAJD%(.7amF7
d
f
C99,,d# -   &7s
   A1A6c                      ^  \ rS rSrS1\R
                  kr S SU 4S jjjrS rS rS r	S r
S rS	 rS
 rS rSrU =r$ )rx   i  rU   c	                 \  > [         T
U ]  " S0 U	D6  [        UR                  5       [        5      (       d   e[        UR                  5       [
        R                  5      (       d   e[        U[        5      (       d   eXl        X l	        X0l
        X@l        XPl        X`l        Xpl        Xl        g Nr   )r   r   r.   r   r   rQ   CodeTyper<   fn_namerI   rU   rV   rX   rY   rW   
wrapped_fn)rc   rA  rI   rU   rV   rX   rY   rW   rB  rp   r   s             r5   r   #NestedUserFunctionVariable.__init__  s     	"6"'446<<<<$113U^^DDDD)T****	" $&5?r7   c                     / $ r-   r   rb   s    r5   rm   $NestedUserFunctionVariable.self_args  r   r7   c                 6    U R                   R                  5       $ r-   )rI   r   rb   s    r5   r`   #NestedUserFunctionVariable.get_code  s    yy++--r7   c                    U R                   (       a  [        e[        R                  " U R                  R                  5       U R                  U R                  R                  5       5      nU R                  (       a  U R                  R                  5       Ul	        U R                  (       a  U R                  R                  5       Ul        U R                  (       ac  U R                  R                  5       n[        U[        5      (       a  SSKJn  [#        U" U5      5      n[        U["        5      (       d   eX!l        U$ )Nr   rO   )rW   rw   rQ   rN   rI   r   rU   rA  rV   r   rX   rR   rY   r.   r;   rS   rP   r<   rT   )rc   rZ   rY   rP   s       r5   rv   'NestedUserFunctionVariable.get_function  s    <<%%!!II((*NNLL++-

 == $ @ @ BD??"&//"D"D"FD**==?K+u--."8K#89 k40000#. r7   c                     U R                   S L$ r-   )rW   rb   s    r5   has_closure&NestedUserFunctionVariable.has_closure  s    ||4''r7   c                     g)NFr   rb   s    r5   r   #NestedUserFunctionVariable.has_self  s    r7   c                     U R                   $ r-   )rU   rb   s    r5   r   &NestedUserFunctionVariable.get_globals  s    ~~r7   c                 `   U R                  5       n[        R                  " UU R                  U R                  R                  5       U R                  (       a  [        U R                  R                  5      OS [        S [        [        U R                  5       R                  5      5       5       5      5      nU R                  (       a  U R                  R                  5       Ul        [        R                   " U5      R"                  " U0 UD6nUR%                  5         ['        UR(                  R                  5       5      n[+        UR,                  R.                  U5        [1        XU5        [3        UR                  5       H)  u  pX;  d   eU R4                  R                  U   n
XU	'   M+     U$ )Nc              3   8   #    U  H  n[        S 5      v   M     g 7fr-   )r   ).0r   s     r5   	<genexpr>7NestedUserFunctionVariable.bind_args.<locals>.<genexpr>  s     S+Ra)D//+Rs   )r`   rQ   rN   rU   rA  r   rV   r;   r:   ranger   r   rX   keys_as_python_constantrR   r}   r~   r   r   r<   r   r@   rB   r   rL   r   rW   )rc   rH   ro   rp   rI   rZ   r+   r=   r   rJ   r   s              r5   r   $NestedUserFunctionVariable.bind_args   s9   }}!!NNLL++-*.--E$--%%&TS5T]]_5P5P1Q+RSS
 ??"&//"I"I"KD!!$',,d=f=eoo++-...7fd+"4#3#34IC%%%<<%%c*D4L 5
 r7   c                 &  ^ TR                  U4S j5        T" U R                  5        TR                  TR                  U R                  5      /5        T" [
        R                  " U R                  R                  R                  5      5        U R                  (       a  T" U R                  5        O!TR                  TR                  S 5      /5        U R                  (       a  T" U R                  5        O!TR                  TR                  S 5      /5        U R                  (       a  T" U R                  5        O!TR                  TR                  S 5      /5        U R                  (       a=   U R                  R                  5       nTR                  TR                  U5      /5        O!TR                  TR                  S 5      /5        TR                  [!        SS5      5        U R"                  (       ax  TR                  U4S j5        T" U R"                  5        TR                  [!        SS5      5        TR                  [%        S5      5        TR                  [!        SS5      5        g g ! [         a    T" U R                  5         Nf = f)Nc                  0   > T R                  [        S5      $ )Nr[   )load_import_fromrt   codegens   r5   <lambda>8NestedUserFunctionVariable.reconstruct.<locals>.<lambda>  s    G,,X7JKr7      Fc                  (   > T R                  SS5      $ )Nr   wrapsr[  r\  s   r5   r^  r_  >  s    00gFr7   r    r   T)add_push_nullrI   extend_outputcreate_load_const_uncheckedrU   r%   r1   r   rg   rV   create_load_constrW   rX   rY   r   rw   r   rB  r   )rc   r]  rY   s    ` r5   reconstruct&NestedUserFunctionVariable.reconstruct  s   K	
 			wBB4>>RST ''		(?(?@A==DMM"!!7#<#<T#B"CD<<DLL!!!7#<#<T#B"CD??DOO$!!7#<#<T#B"CD*"..AAC%%88EF !!7#<#<T#B"CD21e<=??!!F DOO$!!"6q%"@A!!,q/2!!"6q$"?@  ' *(()*s   /;I1 1JJ)rY   rW   rI   rV   rU   rA  rX   rB  r-   r   )rt   r   r   r   r]   r   r   rm   r`   rv   rK  r   r   r   rh  r   r   r   s   @r5   rx   rx     sf    	!	0	0N  @ 
@ @6.0(0+A +Ar7   rx   c                      ^  \ rS rSrSS1\R
                  krSSU 4S jjjrS r\S 5       r	\
\R                  " S5      S 5       5       r        SS	 jrS
rU =r$ )SkipFunctionVariableiF  r   reasonNc                 >   > [         TU ]  " S0 UD6  Xl        X l        g r?  )r   r   r   rl  )rc   r   rl  rp   r   s       r5   r   SkipFunctionVariable.__init__M  s    "6"
r7   c                     U R                   $ r-   r   rb   s    r5   r   'SkipFunctionVariable.as_python_constantR  s    zzr7   c                 ~    [        U5      (       d(  [        UR                  [        R                  5      5        U " XS9$ r   )r   r   r   r   FUNCTION_MATCHr   s      r5   r   'SkipFunctionVariable.create_with_sourceU  s3    .u55 &++L,G,GHI5((r7   c                  B    [         R                  [        R                  0$ r-   )collections
namedtupler   UserDefinedClassVariabler   r7   r5    fold_through_function_to_wrapper5SkipFunctionVariable.fold_through_function_to_wrapper^  s     ""I$F$F
 	
r7   c                   ^ [         R                  " U R                  SS5      (       a  [        SU R                   35        g U R                  U R	                  5       R                  5       ;   a  [        TU5      (       a  U R                  " T Vs/ s H  oDR                  5       PM     sn0 UR                  5        VVs0 s H  u  pVXVR                  5       _M     snnD6nU R	                  5       R                  U R                  5      " U[        5       S9$ U R                  [        R                  L a2  U(       d+  [        T5      S:X  a  U4S jn[        R                  " U5      $  [         R                   " U R                  5      n	SU R                  R"                   SU	 S	3n
U R                  R"                  S:X  a  Sn
XR2                  (       a  SU R2                   S	3OS-  n
[        U
5        g s  snf s  snnf ! [$         GaM    S
S1nU R                  R&                  U;   a3  SU R                  R&                   SU R                  R"                   S3n
 NU R                  R&                  b  U R                  R&                  R)                  S5      (       a]  SU R                  R&                   SU R                  R"                   S3n
[*        R,                  R.                  R1                  U
5         GNRSU R                  R&                   SU R                  R"                   S3n
[*        R,                  R.                  R1                  U
5         GNf = f)N_torchdynamo_disableFz.call torch._dynamo.disable() wrapped function )mutation_typer    c                    > [        U [        R                  5      (       a  U R                  TS   S9$ [	        SU  S35        g )Nr   )rB  zfunctools.wraps(r  )r.   r   rx   cloner   )r   ro   s    r5   rb  1SkipFunctionVariable.call_function.<locals>.wraps|  s=    b)"F"FGG88tAw877 0A67r7   z'skip function z	 in file '_abc	_warningsz.Graph break due to unsupported Python builtin .zM. Please file an issue on GitHub so the PyTorch team can add support for it. optreez)Graph break for an optree C/C++ function zj. Consider using torch.utils._pytree - https://github.com/pytorch/pytorch/blob/main/torch/utils/_pytree.pyz'Graph break due to unsupported builtin a  . This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind). If it is a Python builtin, please file an issue on GitHub so the PyTorch team can add support for it and see the next case for a workaround. If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use torch.compiler.allow_in_graph.allow_in_graphzFound an allow_in_graph decorator to a function which is created inside the parent function that is getting compiled. This is not supported for now.z', r  )r}   r   r   r   ry  keysr   r   r:   getr"   r   rb  r   r   LambdaVariablegetfiler   	TypeErrorr   r  r   r   utils	warn_oncerl  )rc   r2   ro   rp   r8  r>   r?   r   rb  pathmsgknown_python_builtin_moduless     `         r5   rq   "SkipFunctionVariable.call_functione  s    !!$**.DeLLJ4::,WX JJ$??AFFHH#D&11JJ267$Q&&($79?H1**,,HE 88:>>tzzJ%5%7  ZZ9??*6c$i1n8
 ++E22$7tzz2'

(?(?'@	$qQF zz&&*::? 
 ;;SQ'B>C#w 8H"  !706/D,::((,HHHI^I^H__`aeakakaxax`y zG H  JJ))5

--88BB DDJJDYDYCZZ[\`\f\f\s\s[t u^ _  MM''11#6 B$**BWBWAXXYZ^ZdZdZqZqYr 	s9 	:  MM''11#6C!7s-   G0>G5&=G; ;AMBM5AMM)rl  r   r-   r   r   )rt   r   r   r   r#   r   r   r   r   r   staticmethodr   	lru_cachery  rq   r   r   r   s   @r5   rk  rk  F  s     
	'	'N 
 ) ) 
  

J#J &J -	J
 
J Jr7   rk  c                   Z   ^  \ rS rSrSrSU 4S jjrSU 4S jjr        S	S jrSrU =r	$ )
WrapperUserFunctionVariablei  a  
Used to represent a wrapper object that contains the actual callable as an
attribute. For example, torch.jit.script/trace have the original function at
their _torchdynamo_inline attribute. Similarly, functions with
__script_if_tracing_wrapper have the original attr at "__original_fn".
c                 >   > [         TU ]  " S0 UD6  Xl        X l        g r?  )r   r   wrapper_objattr_to_trace)rc   r  r  rp   r   s       r5   r   $WrapperUserFunctionVariable.__init__  s    "6"&*r7   c                    > X R                   :X  a`  [        U R                  U R                   5      nU R                  =(       a    [	        U R                  U5      n[
        R                  " XU5      $ [        TU ]!  X5      $ r-   )	r  r   r  r4   r   r#   r/   r   r   )rc   r2   rJ   r3   r4   r   s        r5   r   'WrapperUserFunctionVariable.var_getattr  sc    %%%$**D,>,>?C[[BZT%BF"((&99w"2,,r7   c                     [         R                  " [        R                  5      R	                  X[         R
                  " U R                  5      /UQU5      $ r-   )r   r   r   getattr_and_tracerq   r%   r  rn   s       r5   rq   )WrapperUserFunctionVariable.call_function  sJ     --''

-y11$2D2DEMMv
	
r7   )r  r  r   r2   r'   r   )
rt   r   r   r   r   r   r   rq   r   r   r   s   @r5   r  r    sB    +
-

#

 &

 -	


 


 

r7   r  c                  \    [         R                  R                  5       (       a  SSKJn   U $ 0 $ )Nr   traceable_collective_remaps)r   distributedis_available)torch.distributed._functional_collectivesr  r  s    r5   _traceable_collective_remapsr    s)    %%''	
 +*Ir7   c                     [         R                  R                  5       (       d   S5       eU[        5       R	                  5       ;   d   eUR
                  nU R                  S5      n[        X25      $ )NzIllegal invocation.z)torch.distributed._functional_collectives)r   r  r  r  valuesrt   import_sourcer   )r2   r   
inner_namepath_sources       r5   _traceable_collectives_sourcer    sc    ))++B-BB+-/668888J""#NOKk..r7   c                      ^  \ rS rSrSrS	U 4S jjr\S
S j5       r\S 5       r\S
S j5       r	        SS jr
SrU =r$ )!CollectiveFunctionRewriteVariablei  a  
Some of the torch.distributed.* collective APIs are possible to rewrite to 'traceable' collectives.

This class provides both a way to check if a function is remappable, and perform the remapping.

In the case that a function is 'remappable' but only for some combinations of call-time arguments,
we check the args at `call_function` time and fall back to graph-breaking if needed.  This is no worse
than status-quo as we currently graph-break on all distributed.* collectives.
c                b   > [         TU ]  " U40 UD6  [        U[        5      (       d   eX l        g r-   )r   r   r.   r   replacement_var)rc   r   r  rp   r   s       r5   r   *CollectiveFunctionRewriteVariable.__init__  s/    &v&/+?@@@@.r7   c                 f    [         R                  X5      u  pE[        U4[        U4SU0UD6US.UD6$ )Nr4   )r  r4   )r  rewriter   )r2   old_fnr4   optionsnew_fn
new_sources         r5   r1   (CollectiveFunctionRewriteVariable.create  sI    >FFrR0
0V
VgV
 	
 	
r7   c                 V    [         R                  " U 5      =(       a    U [        5       ;   $ r-   )r}   
isfunctionr  )variables    r5   can_rewrite-CollectiveFunctionRewriteVariable.can_rewrite  s%     x(WX9U9W-W	
r7   c                 6    [        5       U   nU[        X5      4$ r-   )r  r  )r2   r   r  s      r5   r  )CollectiveFunctionRewriteVariable.rewrite  s     -/34R@@@r7   c                    SS K Jn  SSKJn  [        R
                  " U R                  5      n[        UR                  " U0 UD6R                  5      nSnSU;   a0  US   R                  5       (       a  [        SU R                   35        U R                  UR                  UR                  UR                  4;   ap  UR                  S5      nUb  UR                   OUR"                  S   R$                  nX;  a  ['        SU 35      e[(        R*                  R-                  XX   5      US'   U R.                  R1                  XU5      $ )Nr   )REDUCE_OP_TO_STRr   async_opzBCollectiveFunctionRewriteVariable can't support async_op=True for opzUnsupported all_reduce op: )torch.distributedr  r  r  r}   r~   r   r<   r   r   r   r   
all_reducereduce_scatter_tensor_reduce_scatter_baser  r   r   defaultr   r   r%   r1   r  rq   )	rc   r2   ro   rp   distr  r~   reduce_op_var	reduce_ops	            r5   rq   /CollectiveFunctionRewriteVariable.call_function  s6    	)N %%dgg.	innd5f5??@F:$6$I$I$K$KTUYU\U\T]^ 77OO&&%%
 

 #JJt,M !, ##))$/77 
 0 #>yk!JKK$55<< +F4L ##11"FCCr7   )r  r   r  r   )rt   r   r   r   r   r   r  r1   r  r  rq   r   r   r   s   @r5   r  r    s    /
 
 
 
 

 A A'D#'D &'D -	'D
 
'D 'Dr7   r  c                   |   ^  \ rS rSrS\SS4U 4S jjrS rS r        SS
 jrSS	S\	S\4S jr
S rS rSrU =r$ )FunctoolsPartialVariablei7  rZ   rj   Nc                    > [         TU ]  " S0 UD6  Xl        [        U[        5      (       d   eX l        [        U[        5      (       d   eX0l        g r?  )r   r   rZ   r.   r9   ro   r<   keywords)rc   rZ   ro   r  rp   r   s        r5   r   !FunctoolsPartialVariable.__init__8  sH    "6"	$%%%%	(D)))) r7   c                 R  ^ TR                  U4S j5        T" U R                  5        U R                  (       a  TR                  U R                  5        U R                  (       d2  TR                  [        [        U R                  5      S-   S5      5        g TR                  U R                  R                  5       5        [        U R                  R                  5       5      nTR                  TR                  [        U5      [        U R                  5      -   S-   US5      5        g )Nc                  (   > T R                  SS5      $ )Nr   r   rc  r\  s   r5   r^  6FunctoolsPartialVariable.reconstruct.<locals>.<lambda>A  s    g&>&>{I&Vr7   r    F)rd  rZ   ro   foreachr  re  r   r   r  r;   r  create_call_function_kw)rc   r]  r  s    ` r5   rh  $FunctoolsPartialVariable.reconstruct@  s    VW		99OODII&}}!!"6s499~7I5"QR,,./T]]'')*++CIDII,F,JDRWX	
r7   c                 "    U R                  5       $ r-   r   rb   s    r5   rv   %FunctoolsPartialVariable.get_functionO      &&((r7   r2   r'   c                 x    U R                   U-   n0 U R                  EUEnU R                  R                  XU5      $ r-   )ro   r  rZ   rq   )rc   r2   ro   rp   merged_argsmerged_kwargss         r5   rq   &FunctoolsPartialVariable.call_functionR  s<     ii$&34==3F3yy&&rFFr7   rJ   c                     [         R                  R                  [        [        R
                  " [        5      U5      5      $ r-   )r   r%   r1   ru   r   r   r   )rc   r2   rJ   s      r5   rz   %FunctoolsPartialVariable.call_hasattr\  s0    ))00I%%h/6
 	
r7   c                 B   [         R                  " U R                  R                  5       /U R                   Vs/ s H  oR                  5       PM     snQ70 U R
                  R                  5        VVs0 s H  u  p#X#R                  5       _M     snnD6$ s  snf s  snnf r-   )r   r   rZ   r   ro   r  r:   )rc   r   r>   r?   s       r5   r   +FunctoolsPartialVariable.as_python_constantb  s      II((*
26))<)3$$&)<
 6:]]5H5H5JK5JTQq&&((5JK
 	
<K   B
4Bc                 B   [         R                  " U R                  R                  5       /U R                   Vs/ s H  oR                  5       PM     snQ70 U R
                  R                  5        VVs0 s H  u  p!X!R                  5       _M     snnD6$ s  snf s  snnf )zcSimilar to as_python_constant(), but add ID_MATCH guards to try to force things to become constants)r   r   rZ   guard_as_python_constantro   r  r:   )rc   r?   r>   s      r5   r  1FunctoolsPartialVariable.guard_as_python_constanti  s      II..0
48II>Iq((*I>
 <@==;N;N;PQ;P41q,,..;PQ
 	
>Qr  )ro   rZ   r  r   )rt   r   r   r   r#   r   rh  rv   rq   r   rz   r   r  r   r   r   s   @r5   r  r  7  sz    !_ !4 !
)G#G &G -	G
 
G
6 
c 
o 


 
r7   r  c                   *  ^  \ rS rSrSSS1\R
                  kr\\R                  " S5      S\	\
S\4   \R                  4   4S j5       5       r\S	 5       rS\SS4U 4S
 jjr\S\4S j5       rS rS r        SS jr      SS jrS rSrU =r$ )PolyfilledFunctionVariableir  r   rB  traceable_fnNrj   .c                     0 $ r-   r   )r   s    r5   _get_polyfill_handlers1PolyfilledFunctionVariable._get_polyfill_handlersz  s	     	r7   c                 ^    [        UR                  [        R                  5      5        U " XS9$ r   )r   r   r   rs  r   s      r5   r   -PolyfilledFunctionVariable.create_with_source  s&    f''(C(CDE5((r7   c                 D  > [         TU ]  " S0 UD6  Xl        U R                  5       R	                  X5      n[        U5      (       d   SU SU 35       eS H,  n[        X4S 5      nU(       d  M  [        U5      (       d   eUn  O   [        SU S35      eX0l        X`l	        g )NzPolyfill handler z is not callable for )__torch_dynamo_polyfill____python_implementation__z# does not have a traceable functionr   )
r   r   r   r  r  callabler   RuntimeErrorrB  r  )rc   r   rp   handlercandidate_attr	candidater  r   s          r5   r   #PolyfilledFunctionVariable.__init__  s    "6"--/33B;  X$5gY>STVSW"XX 
N  >Iy	****(
 #G9,OP  & ,r7   c                     U R                   $ r-   )r  rb   s    r5   polyfill_fn&PolyfilledFunctionVariable.polyfill_fn  s       r7   c                 0    [        U R                  SS5      $ )N*__torch_dynamo_can_constant_fold_through__F)r   rB  rb   s    r5   can_constant_fold_through4PolyfilledFunctionVariable.can_constant_fold_through  s    OOI5
 	
r7   c                 "    U R                  5       $ r-   r  rb   s    r5   rv   'PolyfilledFunctionVariable.get_function  r  r7   c                 r   U R                  5       (       a  [        X#5      (       aw  U R                  " U Vs/ s H  oDR                  5       PM     sn0 UR	                  5        VVs0 s H  u  pVXVR                  5       _M     snnD6n[
        R                  " X5      $ U R                  [        R                  L Ga<  [        U5      S:X  Ga,  U(       Gd$  [        US   [        R                  [        R                  45      (       a  [        S US   R                   5       5      (       a  [        R                  R!                  UUR"                  R%                  S[&        R(                  [+        S US   R                   5       5      40 5      [&        R(                  " US   R                   Vs/ s H:  n[        U[        R,                  5      (       a  UR.                  OUR0                  PM<     sn5      S9$ [
        R                  " XR2                  5      nUR5                  XU5      $ s  snf s  snnf s  snf )Nr    r   c              3     #    U  H~  n[        U[        R                  5      =(       a    [        UR                  [        5      =(       d7    [        U[        R
                  5      =(       a    UR                  5       [        L v   M     g 7fr-   )r.   r   r%   r   intSymNodeVariabler   )rS  r8  s     r5   rT  ;PolyfilledFunctionVariable.call_function.<locals>.<genexpr>  sd       'A Ay99:Wz!''SV?W Yq)";";<WTWAWY&s   BBrq   c              3   @   #    U  H  oR                  5       v   M     g 7fr-   )as_proxy)rS  as     r5   rT  r    s     ?A::<<s   )sym_num)r  r   r   r   r:   r#   r/   builtinssumr   r.   r   ListVariableTupleVariableallr  r1   rB   create_proxyr   sym_sumr;   r%   r   r
  r  rq   )	rc   r2   ro   rp   r8  r>   r?   r=   traceable_function_variables	            r5   rq   (PolyfilledFunctionVariable.call_function  s    ))++0M1
 1
 6:;d**,d;=C\\^L^TQq..00^L  #((44 GGx||#D	Q47Y%;%;Y=T=T$UVV  a   ,,33		&&#MM?a??A	  "&a "/A  *!Y-G-GHH GG!"+ "/	 4  ( '6&;&;B@Q@Q&R#*886JJO <L4s   H)%H.-AH4c                 v   US:X  a  U R                  XU5      $ [        U R                  US 5      nUc   SU SU R                   35       e[        U5      (       d   SU SU R                   35       e0 nU R                  (       a  [        U R                  U5      US'   [        U40 UD6nUR                  XU5      $ )N__call__zMember z not found in z is not callable in r4   )rq   r   r   r   r4   r   r  )rc   r2   rJ   ro   rp   methodr  polyfilled_method_variables           r5   r  &PolyfilledFunctionVariable.call_method  s     :%%b77$-!JWTF.	#JJ!6""QgdV3Gy$QQ";; *4;; =GH%?%R'%R")77&IIr7   c                     U R                   $ r-   r   rb   s    r5   r   -PolyfilledFunctionVariable.as_python_constant  r   r7   )r   r  rB  r   ro   r   rp   r   rj   r#   )rt   r   r   r   r#   r   r   r   r  r   r   r   rQ   rN   r  r   r*   r   propertyr  r  rv   rq   r  r   r   r   r   s   @r5   r  r  r  s    
	'	'	N tHS#X,>@R@R,R'S    ) )
-2 -D -. !R ! !

)2K#2K &2K -	2K
 
2KhJ &	J
 -J 
J& r7   r  )TMADescriptorMetadataTritonHOPifierc                       \ rS rSrS\S\4S jrS\S\4S jr	S\S\4S jr
S\\R                  R                  R                  S	4   4S
 jrS rS\4S jrSrg)DynamoTritonHOPifieri  r  rj   c                     [        U5      er-   )r   )rc   r  s     r5   raise_unsupported&DynamoTritonHOPifier.raise_unsupported  s    #r7   maybe_callablec                 .    [        U[        [        45      $ r-   )r.   rx   r   )rc   r$  s     r5   is_callable DynamoTritonHOPifier.is_callable  s    79MN
 	
r7   r3   c                     UR                   $ r-   rp  )rc   r3   s     r5   	get_valueDynamoTritonHOPifier.get_value  s    yyr7   .c                 ~    SSK Jn  [        X5      (       a  UR                  5       $ [	        S[        U5       35        g )Nr    )BaseListVariablezgrid for the triton kernel is )listsr,  r.   r  r   type)rc   gridr,  s      r5   
check_gridDynamoTritonHOPifier.check_grid  s0    +d--==?":4:,GHr7   c                     UR                  5        VVs0 s H%  u  pE[        R                  R                  U5      U_M'     nnnUR	                  X2/0 5      nU$ s  snnf r-   )r:   r   r%   r1   rq   )rc   r/  metar2   r>   r?   s         r5   	call_gridDynamoTritonHOPifier.call_grid  sS    DHJJLQLDA	**11!4a7LQ!!"fb1 Rs   ,Ac                 `   SSK Jn  SSKJn  0 n[	        UR                  5       5       HH  nX8   n	[        U	[        5      (       d  M  U	R                  5       Xx'   U	R                  R                  X8'   MJ     UR                  5        VV	s0 s H%  u  p[        R                  R                  U5      U	_M'     n
nn	SSKJnJn  UR                  5        VV	s0 s H'  u  p[        X5      (       d  M  XR#                  5       _M)     nnn	U
R                  5        VV	s0 s H  u  p[        X5      (       a  M  X_M     nnn	UR%                  5        Hb  n	U	R'                  5       n	[        U	[        R(                  [        R*                  45      (       a  MD  U R-                  S[/        U	5       S35        Md     UR1                  U5      nU" U[2        5      nUR4                  R7                  SUS	UR8                  UUUUR;                  5       S
.5        [        R                  " S 5      $ s  sn	nf s  sn	nf s  sn	nf )Nr    r$   )ConstDictVariabler   )kernel_side_tabletriton_kernel_wrapper_mutationz.Unexpected argument type for a Triton kernel: r  rq   r   )
kernel_idxconstant_args_idxr/  tma_descriptor_metadatarp   )r  r%   dictsr7  r9   r  r.   TMADescriptorVariableto_metadatadata_ptrfrom_tensorr:   r   r1   *torch._higher_order_ops.triton_kernel_wrapr8  r9  r   r  realizer6  r  r"  repradd_constant_argsr<   rB   r  r:  r  )rc   r  gridscombined_args_rawr2   r%   r7  r<  r>   r?   combined_argsr8  r9  constant_argsnon_constant_argsr;  r3  s                    r5   call_HOPDynamoTritonHOPifier.call_HOP  s   ., :<',,./A!$A!233-.]]_'*'(zz'='=!$	 0 *//1
1 &&--a0!31 	 

	
 *//1
1!. &A##%%1 	 
 &++-
-a2 AD- 	 
 #))+A		Aa)":":I<U<U!VWW&&DT!WIQO , .??N !2D9
		*&11%6+B--/		
 ))
 	
]



s   ,HH$+H$H*/H*r   N)rt   r   r   r   r   r   r"  r   boolr&  r)  r   r   fxproxyProxyr0  r4  r%   rK  r   r   r7   r5   r   r     su    S U 
# 
$ 

S S I%(<(<c(A"B I
@
BR @
r7   r   c                      ^  \ rS rSr% S\S'   S\S'   \\   \S'   SU 4S jjr        SS	 jr      SU 4S
 jjr	S\
S\
4S jrSrU =r$ )TritonKernelVariableiX  r(   r/  r)   kernelr:  rj   c                 R   > [         TU ]  " S0 UD6  [        R                  XX#5        g r?  )r   r    dynamo_triton_hopifier_singletoninit_variable)rc   rS  r:  r/  rp   r   s        r5   r   TritonKernelVariable.__init__]  s#    "6"(66tZVr7   c                 .    [         R                  XX15      $ r-   )rU  call_triton_kernelrn   s       r5   rq   "TritonKernelVariable.call_functiona  s     0BB
 	
r7   c                    > US:X  a  [         R                  X5      $ US:X  a  [         R                  XXA5      $ [        TU ]  XX45      $ )N__getitem__run)rU  call_getitemcall_runr   r  )rc   r2   rJ   ro   rp   r   s        r5   r   TritonKernelVariable.call_methodk  sL     = 3@@LLU]3<<TTT w"2T::r7   r   c                 ~    SSK Jn  SSKJn  [	        X5      (       a   UR
                  " UR                  5       5      $ U$ )Nr    r$   )r  )r  r%   tensorr  r.   r1   evaluate_expr)rc   r   r%   r  s       r5   specialize_symbolic(TritonKernelVariable.specialize_symbolicz  s4    .+ c++#**3+<+<+>??
r7   r   r   r   r  )rt   r   r   r   rT   r   r  r   rq   r  r   rd  r   r   r   s   @r5   rR  rR  X  s    
W
#
 &
 -	

 

; &	;
 -; 
;s s  r7   rR  c                   H   ^  \ rS rSr        SU 4S jjrS rS rSrU =r$ )r>  i  c                    > [        U[        R                  5      (       d   e[        TU ]  " S0 UD6  Xl        X l        X0l        X@l        g r?  )	r.   r   DataPtrVariabler   r   r@  dims
block_dimselement_size)rc   r@  ri  rj  rk  rp   r   s         r5   r   TMADescriptorVariable.__init__  sC     (I$=$=>>>>"6" 	$(r7   c                     U R                    Vs/ s H  oR                  5       PM     snU R                   Vs/ s H  oR                  5       PM     snU R                  R                  5       4$ s  snf s  snf r-   )ri  r  rj  rk  )rc   dims     r5   r?  !TMADescriptorVariable.to_metadata  sX    '+yy1y\\^y1'+7\\^7&&(
 	
17s
   A.A3c                   ^ ^ TR                  UU 4S j5        T R                  R                  T5        / T R                  QT R                  QT R
                  PnTR                  U5        TR                  [        U5      S-   S5        g )Nc                  V   > T R                  SS[        TR                  5       S35      $ )Nz$triton.tools.experimental_descriptorcreate_d_tma_descriptor)r[  r   ri  )r]  rc   s   r5   r^  3TMADescriptorVariable.reconstruct.<locals>.<lambda>  s)    G,,6#dii.))9:r7   r    F)	rd  r@  rh  ri  rj  rk  r  rq   r   )rc   r]  ro   s   `` r5   rh  !TMADescriptorVariable.reconstruct  sp    	
 	!!'*@@T__@d.?.?@c$i!mU3r7   )rj  r@  ri  rk  )r@  zvariables.DataPtrVariableri  List[ConstantVariable]rj  rv  rk  r%   )	rt   r   r   r   r   r?  rh  r   r   r   s   @r5   r>  r>    s=    )-) ') -	)
 ))

4 
4r7   r>  c                   N   ^  \ rS rSrS\SS4U 4S jjr        SS jrSrU =r$ )	CreateTMADescriptorVariablei  rankrj   Nc                 B   > US;   d   e[         TU ]  " S0 UD6  Xl        g )N)r    r   r   )r   r   ry  )rc   ry  rp   r   s      r5   r   $CreateTMADescriptorVariable.__init__  s&    
 v~~"6"	r7   c                 $   SU;   a  US   OUS   n[        U[        R                  5      (       d  [        SU R                   S35      eU R                  S:X  a@  [        U5      [        U5      -   S:X  d   eSU;   a  US   OUS   /nSU;   a  US   OUS	   /nO][        U5      [        U5      -   S
:X  d   eSU;   a  US   OUS   SU;   a  US   OUS	   /nSU;   a  US   OUS   SU;   a  US   OUS   /nSU;   a  US   OUS   n[        UUUUS9$ )Nptrr   z8Please ensure there were no graph breaks between create_z3d_tma_descriptor and the upstream .data_ptr() call.r       rn  	block_dimr      dim1dim0
block_dim1   
block_dim0rk  )r@  ri  rj  rk  )r.   r   rh  r   ry  r   r>  )rc   r2   ro   rp   r}  ri  rj  rk  s           r5   rq   )CreateTMADescriptorVariable.call_function  sd     %fUmDG#y8899)) %$$  99>t9s6{*a///!&&ud1gD (3f'<{#$q'J t9s6{*a///"(F"2vQ"(F"2vQD
 )5(>|$DG(4(>|$DGJ 2@61Ivn-tTVx$!%	
 	
r7   )ry  r   )	rt   r   r   r   r  r   rq   r   r   r   s   @r5   rx  rx    sJ     
	(
#(
 &(
 -	(

 
(
 (
r7   rx  r-   r  )Tr  rv  r   r}   rS   rQ   typingr   r   r   r   r   r   r	   r
   typing_extensionsr   r   r  r   r   bytecode_transformationr   r   excr   r   guardsr   r   r4   r   r   r   r   r  r   r   r   r   r   r   r   baser!   r"   r#   r  r%   #torch.distributed.fsdp._fully_shardr&   ModuleNotFoundErrortorch._dynamo.symbolic_convertr'   rB  r(   r)   r*   r6   r@   r   rL   r[   r]   r   r   r  r/  r   rx   rk  r  r  r  r  r  r  r  r  r   rU  rR  r>  rx  r   r7   r5   <module>r     s         U U U #  # H , 0 N N   = < &E
 D T"	A. $sO';"<  "( @t73 t7n=5- =5@ 2 ("6 ( KA!9 KA\i? iX
/ 
D/LD(< LD^8
 8
v~ ~BY
> Y
x $8#9  )? )X!4O !4H2
/ 2
M$  s   F FF