
    [Th"                    <   S r 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  SSK	J
r
JrJrJrJr  SSK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Jr  SS
KJrJrJrJrJ r J!r!J"r"J#r#J$r$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/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8  SSK9J:r:J;r;J<r<  SSK=J>r>   SSK?J@r@  \(       a  SSKBJCrC  SSKDJErEJFrF  \" S\S9rGSQSRS jjrHSRS jrIS\J\K\<4   4S jrLS rM1 SkrNS rO " S S\<5      rP " S S \P5      rQ " S! S"\P5      rR " S# S$\<5      rS " S% S&\S5      rT " S' S(\P5      rU " S) S*\U5      rV " S+ S,\Q5      rW " S- S.\W5      rX " S/ S0\Q5      rYSRS1 jrZ " S2 S3\P5      r[ " S4 S5\<5      r\ " S6 S7\<5      r]S8 r^SRS9 jr_ " S: S;\Q5      r` " S< S=\Q5      ra " S> S?\Q5      rb " S@ SA\<5      rc " SB SC\<5      rd " SD SE\<5      re " SF SG\<5      rfSSHKDJgrgJhrh   " SI SJ\h5      ri\i" 5       rj " SK SL\<5      rk " SM SN\<5      rl " SO SP\<5      rmg! \A a    Sr@ GNnf = f)Sa  
Function-related variable tracking classes for Dynamo's symbolic execution.

This module contains classes that track different types of functions during graph
compilation, including:
- User-defined functions and methods
- Built-in functions and methods
- Wrapped functions (e.g. from decorators)
- Special function types (e.g. functools.partial)
- Triton kernels and related function types

These classes are responsible for:
- Tracking function calls and their arguments
- Managing function closures and cell variables
- Handling function attributes and special methods
- Maintaining guards for function identity and closure contents
- Supporting function inlining and specialization
- Enabling proper symbolic execution of different function types

The variable trackers here work together with the rest of Dynamo to enable
accurate graph capture while handling Python's various function-related behaviors.
    N)Sequence)AnyCallableOptionalTYPE_CHECKINGTypeVar)Never)patch   )	polyfills	variables)create_call_functioncreate_rot_nis_generator)get_dynamo_observed_exceptionhandle_observed_exceptionInfiniteGeneratorErrorObservedExceptionObservedGeneratorExitObservedUserStopIterationraise_observed_exception	SkipFrameunimplementedunimplemented_v2Unsupported)GuardBuilderinstall_guard)
AttrSourceConstantSourceDefaultsSourceGetItemSource)	check_constant_argscheck_unspec_or_constant_argscmp_name_to_op_mappingcounters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      Y/var/www/auris/envauris/lib/python3.13/site-packages/torch/_dynamo/variables/functions.pywrap_bound_argrA   X   sA    #''
$$R-- ,,33C@@    c                     [        UR                  5       5       H/  u  p#[        U[        [        45      (       d  M"  [        X5      X'   M1     g r8   )listitemsr9   tupledictrA   )r=   resultkvs       r@   wrap_args_kwargsrK   d   s6    V\\^$a%''&r-FI %rB   rH   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)parentrH   coderN   namenew_cells         r@   init_cellvarsrW   k   sV     ==--L  ..0> ##Hjj.>?t !rB   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)	typesrY   __kwdefaults__r9   rF   	itertoolsr[   rG   __annotations__)
rT   	f_globalsrU   defaultsclosure
kwdefaultsannotationsrY   funcr[   s
             r@   _create_nested_fnrf   |   s_     #AD$+u%%&8K01 *[$"?"???&KrB   >   __doc____code____closure____globals____defaults__r]   r_   c                 >   U=(       a    [        X#5      n [        R                  " X5      nU[
        ;   a  [        X5      nU(       a   [        R                  R                  WU5      $ [        R                  " U W5      $ ! [         a    [	        [        U 5         Nof = fr8   )r   inspectgetattr_staticAttributeErrorr   fn_known_dunder_attrsgetattrr   r;   r<   r.   r:   )r=   fnr?   rU   subobjs        r@   fn_var_getattrrt      s    0
60F5''1 $$",,33FFCC  V,,  5 	!45s   A? ?BB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)BaseUserFunctionVariable   c                 6    U R                  5       R                  $ r8   get_codeco_filenameselfs    r@   get_filename%BaseUserFunctionVariable.get_filename       }}***rB   c                 6    U R                  5       R                  $ r8   rz   co_namer|   s    r@   get_name!BaseUserFunctionVariable.get_name       }}&&&rB   r=   r2   returnc                 L    UR                  U / U R                  5       QUQU5      $ r8   )inline_user_function_return	self_argsr}   r=   argskwargss       r@   call_function&BaseUserFunctionVariable.call_function   s,     --d4Ndnn6F4N4NPVWWrB   rU   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NotImplementedErrorr9   NestedUserFunctionVariabler   r0   r<   r}   r=   rU   rH   s       r@   call_obj_hasattr)BaseUserFunctionVariable.call_obj_hasattr   sh     	T..0$7F ))0088 # 	z!j7Q&R&R	s   = 'A'&A'c                 p    [        [        R                  " U R                  5       5      R                  5      $ r8   )rD   rm   	signaturer   
parametersr|   s    r@   inspect_parameter_names0BaseUserFunctionVariable.inspect_parameter_names   s'    G%%d&7&7&9:EEFFrB   c                     0 $ r8    r}   r=   s     r@   closure_vars%BaseUserFunctionVariable.closure_vars       	rB   r   Nr=   r2   r   list[VariableTracker]r   dict[str, VariableTracker]r   r.   )r   
__module____qualname____firstlineno__r~   r   r   strr.   r   r   r   __static_attributes__r   rB   r@   rv   rv      sd    +'X#X &X -	X
 
X
9)
914
9	
9GrB   rv   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 functionrr   is_constantc                 ^    [        UR                  [        R                  5      5        U " XS9$ Nr?   )r   
make_guardr   CLOSURE_MATCHclsvaluer?   s      r@   create_with_source'UserFunctionVariable.create_with_source   s&    f''(B(BCD5((rB   r   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__rq   r   r9   r\   rY   torchjitScriptFunctionr,   rm   rn   rr   r}   rr   r   r   	__class__s       r@   r   UserFunctionVariable.__init__   s    "6"20%88#D$D"u115993K3KLMM 	
*72;-q=	
M ##B(=rB&(rB   c                 b   > [        U [        5      (       a  U R                  $ [        TU ]  5       $ r8   )r)   r   rr   r   as_python_constantr}   r   s    r@   r   'UserFunctionVariable.as_python_constant   s(    $,--77Nw)++rB   c                     / $ r8   r   r|   s    r@   r   UserFunctionVariable.self_args   r   rB   c                     U R                   $ r8   rr   r|   s    r@   r   !UserFunctionVariable.get_function       wwrB   c                 .    U R                   R                  $ r8   )rr   rh   r|   s    r@   rz   UserFunctionVariable.get_code   s    wwrB   c                 "    [         R                  $ r8   r\   rY   r|   s    r@   python_type UserFunctionVariable.python_type       !!!rB   c                 4    [        U R                  SS 5      S L$ N__self__)rq   rr   r|   s    r@   has_selfUserFunctionVariable.has_self   s    tww
D1==rB   c                 .    U R                   R                  $ r8   )rr   rj   r|   s    r@   get_globals UserFunctionVariable.get_globals  s    ww"""rB   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.
)r=   N)r>   r?   T)is_kwr   ri   cell_contents)+r   rM   root_tx	functoolspartialrA   rr   rk   	enumerater?   r    r\   rY   rh   rj   r   rF   zipri   r]   rE   rm   r   bindapply_defaultsrG   	argumentsrK   rW   lenco_freevarsr^   countrN   r!   r   r.   r:   r   
ValueErrorr   DeletedVariabletrack_cell_existing)r}   rS   r   r   r   wraprr   ra   idx_defaults_sourcesargr?   	fake_funcrI   kwdefaults_sourcesrJ   r6   rH   rb   rU   cellrN   cell_varclosure_cellclosure_cell_contentscontents_vars                              r@   	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+r=   r2   rU   c                     U[         ;   a  [        R                  " X5      $ [        XR                  U R
                  U5      $ r8   )r$   r   GetAttrVariablert   rr   r?   r}   r=   rU   s      r@   var_getattr UserFunctionVariable.var_getattr\  s3    )),,T88b''4;;==rB   c                 l    [        U R                  U5      n[        R                  R	                  U5      $ r8   )r   rr   r   r0   r<   r   s       r@   r   %UserFunctionVariable.call_obj_hasattra  s+     $'))0088rB   c                 B  > U R                   [        R                  R                  L a  [        R
                  " U R                   5      R                  " U0 UD6nUR                  S   n[        U[        5      (       d)  UR                  5       n[        SUR                   S35        [        U[        5      (       d  UR                  5       n[        SU S35        UR                   n[        R                   " USS9$ 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	R4                  U	R6                  4;   aC  [        R                  R8                  R-                  U5         [:        T
U ]y  XU5      sS S S 5        $ [:        T
U ]y  XU5      $ ! [2         a    S n	 Nf = f! , (       d  f       N0= f)	Nr   z=`nonstrict_trace` expects a callable, but got value of type <>z)
Applying `nonstrict_trace` to function <zl>; however, `nonstrict_trace` currently requires the function to be defined outside `torch.compile` region.
Tnonstrict_traceable)	FSDPState)rr   r   _dynamononstrict_tracerm   r   r   r   r9   rv   r   r   r   r   r   r   TorchInGraphFunctionVariabler   invoke_and_store_as_constantrM   current_tracerunder_activation_checkpoint#allow_side_effects_under_checkpoint/torch.distributed.fsdp._fully_shard._fsdp_stater	  	Exception_pre_forward_post_forwardrN   r   r   )r}   r=   r   r   r6   fn_vartypfn_namerr   r	  r   s             r@   r   "UserFunctionVariable.call_functiong  s    77emm333%%dgg.33TDVDEZZ]Ff&>??((*STWT`T`Saabc f&:;; //+))0	 2 B99"RVWW/GGT]]_d  II$$@@II,,PP!U $&&''5 * ]]//SSTVW 706B XWw$Rv66  ! 	! XWs   <G> H>HH
H)rr   r   Fr   Nr   )r   r   r   r   rg   rv   _nonvar_fieldsclassmethodr   r   r   r   r   rz   r   r   r   rG   r   r.   r   r  r   r   r   __classcell__r   s   @r@   r   r      s    7 	 
"	0	0N ) )) )", ">#Uc?6J1K Un>5 >S >
9)9149	9-7#-7 &-7 -	-7
 
-7 -7rB   r   c                   Z   ^  \ rS rSrSSU 4S jjjr\S 5       r        SS jrSrU =r	$ )	BuiltinMethodVariablei  c                 t   > [         TU ]  " S0 UD6  [        U[        R                  5      (       d   eXl        g Nr   )r   r   r9   r\   BuiltinMethodTyperr   r   s       r@   r   BuiltinMethodVariable.__init__  s1    "6""e556666rB   c                     U R                   nU R                  nU[        L =(       a    US:H  =(       d    [        U5      [        L =(       a    US:H  $ )N__new____contains__)r   r   rF   type	frozenset)objmethod_selfmethod_names      r@   is_supported_builtin_method1BuiltinMethodVariable.is_supported_builtin_method  sI    llll u$A	)A 
*L{n/L	
rB   c                     U R                   R                  nU R                   R                  nU R                  =(       a    [	        U R                  S5      n[
        R                  " XU5      nUR                  XX#5      $ r   )rr   r   r   r?   r   r.   r:   call_method)r}   r=   r   r   r+  rU   
obj_sourceobj_vts           r@   r   #BuiltinMethodVariable.call_function  s`     gg&&ww[[HZZ%H
 &&r
C!!"D99rB   r   r  r  r   )
r   r   r   r   r   staticmethodr-  r   r   r  r  s   @r@   r   r     sQ     
 
 

:#
: &
: -	
:
 

: 
:rB   r   c            
         ^  \ rS rSrS\R
                  S\S   4U 4S jjrS rS r	S r
S	 rS
 rS r S r\rS rS rS rS rS rS rS rS\R.                  4S jrS\\   4S jrS rS rS rSSS\SSSSSS 4
U 4S! jjr S"r!U =r"$ )#LocalGeneratorObjectVariablei  rT   inline_tracerr2   c                 J   > [         TU ]  " S0 UD6  Xl        X l        X0l        g r"  )r   r   rT   r`   r7  )r}   rT   r`   r7  r   r   s        r@   r   %LocalGeneratorObjectVariable.__init__  s%     	"6"	"*rB   c                     U R                   $ r8   )rT   r|   s    r@   rz   %LocalGeneratorObjectVariable.get_code  s    yyrB   c                 6    U R                  5       R                  $ r8   ry   r|   s    r@   r~   )LocalGeneratorObjectVariable.get_filename  r   rB   c                 6    U R                  5       R                  $ r8   r   r|   s    r@   r   %LocalGeneratorObjectVariable.get_name  r   rB   c                     [         er8   )r   r|   s    r@   r   )LocalGeneratorObjectVariable.get_function  s    !!rB   c                     gNFr   r|   s    r@   r   %LocalGeneratorObjectVariable.has_self      rB   c                 "    U R                  5       $ r8   )r   r|   s    r@   r   %LocalGeneratorObjectVariable.__name__  s    }}rB   c                 V    U R                   R                   SU R                  5        S3$ )N())r   r   r   r|   s    r@   __str__$LocalGeneratorObjectVariable.__str__  s'    ..))*!DMMO+<A>>rB   c                    SSK Jn  SSKJnJnJn  UR                  " 5       nU" U5      nU" U5      nU" U5      n	U   U   U	   U R                  U5      n
U
R                  (       d  U R                  U5      U l
        [        R                  " U R                  5      R                  U5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)Nr   )"disallow_side_effects_in_generator)r2    save_and_restart_speculation_log(temporarely_allow_writes_to_output_graph)torch._dynamo.side_effectsrN  torch._dynamo.symbolic_convertr2   rO  rP  
current_tx_get_inline_tracergenerator_exhaustedforce_unpack_var_sequenceremaining_itemsr   ListIteratorVariablereconstruct)r}   codegenrN  r2   rO  rP  r=   savedisallowtemptracers              r@   rY  (LocalGeneratorObjectVariable.reconstruct  s    Q	
 	
 #--//35b97;8T,,R0F--'+'E'Eb'I$**4+?+?@LLWU	 "8TTTT88TTs;   C%CA(C*C2C%
CC
C"	C%%
C3c                 :    U R                   R                  XU5      $ r8   )rr   r   r   s       r@   r   &LocalGeneratorObjectVariable.bind_args  s    ww  622rB   c                     U R                   $ r8   r`   r|   s    r@   r   (LocalGeneratorObjectVariable.get_globals      ~~rB   c                 "    [         R                  $ r8   )r\   GeneratorTyper|   s    r@   r   (LocalGeneratorObjectVariable.python_type  s    """rB   c                 p    SSK Jn  U R                  c  UR                  X/ 0 5      U l        U R                  $ Nr   )InliningInstructionTranslator)rR  rk  r7  build_inline_tracer)r}   r=   rk  s      r@   rT  /LocalGeneratorObjectVariable._get_inline_tracer  s9    P%!>!R!R"b"D !!!rB   c                 ~   U R                  U5      nU R                  5       (       a  [        [        U5         [        R
                  " [        S[        S   05         UR                  5       sS S S 5        [        S==   [        S   -  ss'   $ ! , (       d  f       Ol= f! [         a  nUeS nAf[         a    e [         aC  n[        R                  R                  R                  U R                  5       5        [         UeS nAff = f [        S==   [        S   -  ss'   g ! [        S==   [        S   -  ss'   f = f)Nr   inline_call)rT  _is_generator_exhaustedr   StopIterationr
   rG   r%   inline_call_r   r   r   r   r
  
eval_frame	skip_coderz   r   )r}   r=   r^  es       r@   next_variable*LocalGeneratorObjectVariable.next_variable  s   ((,''))$]B7	A H8O&PQ**, RQ _%-)@@% RQ  	G% 	 	#MM$$..t}}?"	# R _%-)@@%H_%-)@@%sS   $B B,	B 
BB D" B 
D)B++D>D  DD" "D<c                     grC  r   r   s     r@   has_unpack_var_sequence4LocalGeneratorObjectVariable.has_unpack_var_sequence  rE  rB   r   c                     gNTr   r   s     r@   has_force_unpack_var_sequence:LocalGeneratorObjectVariable.has_force_unpack_var_sequence  s    rB   c                     / n  UR                  U R                  U5      5        M#  ! [         a    [        U5         U$ f = fr8   )appendrv  r   r   )r}   r=   rH   s      r@   rV  6LocalGeneratorObjectVariable.force_unpack_var_sequence  sL    d0045  - )"-s    ' A A c                     U R                  U5      n UR                  U5        g ! [         a  nUR                  U5         S nAg S nAff = fr8   )rT  _raise_exception_variabler   exception_handler)r}   r=   excr^  ru  s        r@   _setup_exception-LocalGeneratorObjectVariable._setup_exception%  sH    ((,	(,,S1  	( $$Q''	(s   % 
A
AA
c                 ^    U R                   S L =(       d    U R                   R                  S:H  $ )Nr   )r7  instruction_pointerr|   s    r@   _is_generator_just_started7LocalGeneratorObjectVariable._is_generator_just_started.  s*    !!T)XT-?-?-S-SWX-XXrB   c                 0    [        U R                  SS5      $ )NrU  F)rq   r7  r|   s    r@   rp  4LocalGeneratorObjectVariable._is_generator_exhausted1  s    t))+@%HHrB   r=   rU   r   r   r   r   r.   c                   > US:X  a  U R                  U5      $ US:X  a  U $ US:X  a  U R                  5       (       a7  [        U5      (       a'  [        S U 5       5      (       d  [	        [
        U5        U R                  U5      nUR                  U5        U R                  U5      $ US:X  a  U R                  U5      nU R                  5       (       d  U R                  5       (       a  SUl	        [        R                  " S 5      $  U R                  U[        R                  " [        S5      5        [        R                   S:  a7  UR"                  R$                  S	:X  a  SUl	        [        R                  " S 5      $  U R                  U5      (       a  [	        [(        U5        OUS
:X  a  U R                  U5      n U R                  U[        U5      S:X  a  US   OUS   5        U R                  U5      n[1        S[2        40 5      n U R                  U[        R                  " US5      5        U R                  U5        [	        [(        U5        U$ [6        TU ]q  XX45        g ! [&         a     SUl	        [        R                  " S 5      s $ f = f! [&         a     SUl	        [        R                  " S 5      s $ [*         a    UR,                  c   eUR,                  s $ f = f! [.         a    e f = f! [5        U5       a     U$ f = f)N__next____iter__sendc              3   l   #    U  H*  n[        U[        5      =(       a    UR                  S L v   M,     g 7fr8   )r9   r0   r   ).0r   s     r@   	<genexpr>;LocalGeneratorObjectVariable.call_method.<locals>.<genexpr>G  s0      # s$45K#))t:KK#s   24closeTr   )      CALL_INTRINSIC_1throwr  r+   r   __InternalThrowException)rv  r  r   allr   	TypeErrorrT  	push_manyrp  rU  r   r0   r  ExceptionVariableGeneratorExitsysversion_infonext_instructionopnamer   RuntimeErrorr   symbolic_resultr   r(  r  r   r   r0  )	r}   r=   rU   r   r   r^  retvalexc_typer   s	           r@   r0  (LocalGeneratorObjectVariable.call_method4  s    :%%b))ZKV^ ..00SYY  #   -Y;,,R0FT"%%b))W_ ,,R0F..00D4P4P4R4R-1* 11$778%%	33M2F( $$///66:LL15F.$55d;;.%%b)),\2> W_ ,,R0F
 %%bSY!^$q'aQ
 ''+F| 6bIH?%%b)*E*EhPR*ST""2&
 )v>MBd3a ) 8-1* 11$778 ) 8-1* 11$77, .
 --999---., % N 1:  MsI   A5I# <&J ;)K# 8K2 #'JJ'K 9$K K #K/2LL)rT   r`   r7  rW  )#r   r   r   r   r\   CodeTyper   r   rz   r~   r   r   r   rK  __repr__rY  r   r   r   rT  rv  ry  builtinsboolr}  rD   r.   rV  r  r  rp  r   r0  r   r  r  s   @r@   r6  r6    s    
+nn
+   78	
++'"? HV&3#"A.8== tO/D (YIz4#z4 z4 &	z4
 -z4 
z4 z4rB   r6  c                       \ rS rSrSrSrg)4ContextlibContextManagerLocalGeneratorObjectVariablei  z
.. note::

    This is only used when the function is annotated with @contextlib.contextmanager

    It is a special case of a generator function as we do not allow return a context manager
    from a torch.compile function.
r   N)r   r   r   r   rg   r   r   rB   r@   r  r    s    rB   r  c                   b   ^  \ rS rSrSr\S.S\4U 4S jjjrS rS r	        S
S jr
S	rU =r$ )LocalGeneratorFunctionVariablei  zlfunctions that behaves like iterators

.. note::

    This is a wrapper around (Nested)UserFunctionVariable
)generator_clsvtc                >   > [         TU ]  " S0 UD6  Xl        X l        g r"  )r   r   r  r  )r}   r  r  r   r   s       r@   r   'LocalGeneratorFunctionVariable.__init__  s      	"6"*rB   c                     XR                   R                  R                  5       ;   a  [        X5      $ [        U R                  U5      $ r8   )r   __dict__keysrq   r  )r}   rU   s     r@   __getattr__*LocalGeneratorFunctionVariable.__getattr__  s7    >>**//114&&tww%%rB   c                 6    SSK Jn  UR                  UU UU5      $ rj  )rR  rk  rl  )r}   r=   r   r   rk  s        r@   _build_inline_tracer3LocalGeneratorFunctionVariable._build_inline_tracer  s$    P,@@	
 	
rB   c                    [        U R                  R                  5       5      (       d   eU R                  XU5      nU R                  R                  5       nU R                  R	                  5       nU R                  UUUU R                  S9$ r   )r   r  rz   r  r   r  r?   )r}   r=   r   r   r7  rT   r`   s          r@   r   ,LocalGeneratorFunctionVariable.call_function   s     DGG,,.////11"FCww!GG'')	 !!;;	 " 
 	
rB   )r  r  r   )r   r   r   r   rg   r6  r.   r   r  r  r   r   r  r  s   @r@   r  r    sY     3		+	+ 	+&


#
 &
 -	

 

 
rB   r  c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )3FunctionDecoratedByContextlibContextManagerVariablei5  za
.. note::

    This is only used when the function is annotated with @contextlib.contextmanager
c                 4   > [         TU ]  " U4S[        0UD6  g )Nr  )r   r   r  )r}   r  r   r   s      r@   r   <FunctionDecoratedByContextlibContextManagerVariable.__init__>  s%    	
N	
 	
rB   c                    > [         TU ]  XU5      n[        U[        R                  R
                  R                  5      (       d   eSUl        U$ r|  )r   r  r9   r   r
  symbolic_convert&InliningGeneratorInstructionTranslatoris_generator_from_ctx_manager)r}   r=   r   r   r^  r   s        r@   r  HFunctionDecoratedByContextlibContextManagerVariable._build_inline_tracerE  sR    
 -b?MM**QQ
 
 	
 
 04,rB   r   )	r   r   r   r   rg   r   r  r   r  r  s   @r@   r  r  5  s    
 rB   r  c                      ^  \ 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S	S\4U 4S jjrSrU =r$ )UserMethodVariableiS  z$Some unsupported user-defined methodr   c                 6   > [         TU ]  " SSU0UD6  X l        g )Nrr   r   )r   r   r*  )r}   rr   r*  r   r   s       r@   r   UserMethodVariable.__init__V  s    )B)&)rB   c                 h    U R                   R                   SU R                   SU R                   S3$ )NrI  z, rJ  )r   r   rr   r*  r|   s    r@   r  UserMethodVariable.__repr__Z  s.    ..))*!DGG9BtxxjBBrB   c                     U R                   /$ r8   r*  r|   s    r@   r   UserMethodVariable.self_args]  s    zrB   c                 "    [         R                  $ r8   )r\   
MethodTyper|   s    r@   r   UserMethodVariable.python_type`  s    rB   r=   r2   c                   > SSK Jn  U" U R                  5      (       aE  / U R                  5       QUQn[        R
                  " U R                  SS9nUR                  XU5      $ 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      $ [0        T	U ]  XU5      $ )
Nr   )is_nonstrict_trace_callableTr  r    z	torch.nn.ztorch.nn.utils.parametrize)constant)trace_rulesr  rr   r   r   r  r   rM   is_root_tracerr9   r*  NNModuleVariablerq   
startswithr   r0  r   r1   FSDPParamGroupuse_training_stateTorchCtxManagerClassVariabler   r  r   r   )
r}   r=   r   r   r  	call_argsvarmodule_attrrr   r   s
            r@   r    UserMethodVariable.call_functionc  s    	>&tww//2$..*2T2I88TC $$RF;; 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6rB   c                 &   > [         TU ]  5       SS  $ Nr+   )r   r   r   s    r@   r   *UserMethodVariable.inspect_parameter_names  s    w.044rB   rU   c                    > U R                   =(       a    [        U R                   U5      nUS:X  a  U R                  $ US:X  a!  [        R                  " XR
                  U5      $ [        TU ]  X5      $ )Nr   __func__)r?   r   r*  r.   r:   rr   r   r  )r}   r=   rU   r?   r   s       r@   r  UserMethodVariable.var_getattr  s\    >DKK!>:88O:"((WWf==w"2,,rB   r  r  r   )r   r   r   r   rg   r   r   r  r   r   r   r   r  r   r  r  s   @r@   r  r  S  sm    .C# C ;7#;7 &;7 -	;7
 
;7z5-5 -S - -rB   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 Nrr   r*  )rR   r   r   rr   r*  wrappedcontextr}   r  r  r   r   s       r@   r   "WrappedUserMethodVariable.__init__  sE    

4

5$W[[;F;rB   c                    > U R                   R                  U5        [        TU ]  XU5      nU R                   R	                  U5        U$ r8   r  enterr   r   exitr}   r=   r   r   rH   r   s        r@   r   'WrappedUserMethodVariable.call_function  ?     	2&r8"rB   r  r  r  r   r   r   r   r   r   r   r   r  r  s   @r@   r  r    8    	#	 &	 -		
 
	 	rB   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  )rR   r   r   rr   r  r  r  s       r@   r   $WrappedUserFunctionVariable.__init__  s?    

4

5$.v.rB   c                    > U R                   R                  U5        [        TU ]  XU5      nU R                   R	                  U5        U$ r8   r  r  s        r@   r   )WrappedUserFunctionVariable.call_function  r  rB   r  r  r   r  r  s   @r@   r  r    r  rB   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       $ r8   )r9   r   TensorVariableget_real_valuer   )xs    r@   convert-invoke_and_store_as_constant.<locals>.convert  s3    a1122##%%##%%rB   r   )rE   rM   register_attr_or_moduler   )
r=   rr   rU   r   r   r  r  rI   rJ   ress
             r@   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SrU =r$ )r   i  r`   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 r"  )r   r   r9   r   r   r\   r  rG   r  rT   r`   ra   rc   rd   rb   
wrapped_fn)r}   r  rT   r`   ra   rc   rd   rb   r  r   r   s             r@   r   #NestedUserFunctionVariable.__init__  s     	"6"'446<<<<$113U^^DDDD)T****	" $&5?rB   c                     / $ r8   r   r|   s    r@   r   $NestedUserFunctionVariable.self_args  r   rB   c                 6    U R                   R                  5       $ r8   )rT   r   r|   s    r@   rz   #NestedUserFunctionVariable.get_code  s    yy++--rB   c                 "    [         R                  $ r8   r   r|   s    r@   r   &NestedUserFunctionVariable.python_type  r   rB   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   rZ   )rb   r   r\   rY   rT   r   r`   r  ra   rk   rc   r]   rd   r9   rF   r^   r[   rG   r_   )r}   re   rd   r[   s       r@   r   'NestedUserFunctionVariable.get_function  s    <<%%!!II((*NNLL++-

 == $ @ @ BD??"&//"D"D"FD**==?K+u--."8K#89 k40000#. rB   c                     U R                   S L$ r8   )rb   r|   s    r@   has_closure&NestedUserFunctionVariable.has_closure&  s    ||4''rB   c                     grC  r   r|   s    r@   r   #NestedUserFunctionVariable.has_self)  rE  rB   c                     U R                   $ r8   rc  r|   s    r@   r   &NestedUserFunctionVariable.get_globals,  re  rB   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r8   )r*   )r  r   s     r@   r  7NestedUserFunctionVariable.bind_args.<locals>.<genexpr>6  s     S+Ra)D//+Rs   )rz   r\   rY   r`   r  r   ra   rF   rE   ranger   r   rc   keys_as_python_constantr]   rm   r   r   r   rG   r   rK   rM   r   rW   r   rb   )r}   rS   r   r   rT   re   r6   rH   r   rU   r   s              r@   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
 rB   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      $ )Nrf   )load_import_fromr   rZ  s   r@   <lambda>8NestedUserFunctionVariable.reconstruct.<locals>.<lambda>I  s    G,,X7JKrB      Fc                  (   > T R                  SS5      $ )Nr   wrapsr&  r'  s   r@   r(  r)  m  s    00gFrB   r+   r   T)add_push_nullrT   extend_outputcreate_load_const_uncheckedr`   r0   r<   r   r   ra   create_load_constrb   rc   rd   r   r   r   r  r   )r}   rZ  rd   s    ` r@   rY  &NestedUserFunctionVariable.reconstructG  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)rd   rb   rT   ra   r`   r  rc   r  r8   r  )r   r   r   r   rv   r  r   r   rz   r   r   r  r   r   r   rY  r   r  r  s   @r@   r   r     sk    	!	0	0N  @ 
@ @6."0(0+A +ArB   r   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	        SS	 jr
SS
 jrSSS\4S jrSrU =r$ )SkipFunctionVariableiu  r   reasonc                 >   > [         TU ]  " S0 UD6  Xl        X l        g r"  )r   r   r   r5  )r}   r   r5  r   r   s       r@   r   SkipFunctionVariable.__init__|  s    "6"
rB   c                     U R                   $ r8   r   r|   s    r@   r   'SkipFunctionVariable.as_python_constant  s    zzrB   c                 ~    [        U5      (       d(  [        UR                  [        R                  5      5        U " XS9$ r   )r(   r   r   r   FUNCTION_MATCHr   s      r@   r   'SkipFunctionVariable.create_with_source  s3    .u55 &++L,G,GHI5((rB   r=   r2   c           	      `   [         R                  " U R                  SS5      (       a/  [        S[	        U R                  5      SU R                   S3S/S9  g U R                  [
        R                  R                  L aA  UR                  SS 5      nU(       a  UR                  5       n[        S	S
U SU S3SU 3S/S9  g [        U R                  [        R                  5      (       aE  SU R                   S3n[
        R                  R                  R                  U5        [        U5        g [!        U R                  SS5      n [         R"                  " U R                  5      nSU SU S3nSU S3/n	SU;  a  U	SU SU S3S/-  n	US+:X  a  S,n/ n	U R,                  (       a  U R,                  OS-n[        S.S/U R                  R&                   S0U S1U 3UU	S9  g ! [$         GaF    SS1n
U R                  R&                  U
;   a#  SU R                  R&                   S U S3nS!S"/n	 NU R                  R&                  b  U R                  R&                  R)                  S#5      (       aa  S$U R                  R&                   S U S 3nS%/n	[
        R                  R                  R                  US&-   S&R+                  U	5      -   5         GNAS'U R                  R&                   S U S(3nS)S*/n	[
        R                  R                  R                  US&-   S&R+                  U	5      -   5         GNf = f)2N_torchdynamo_disableFz1Skip calling `torch.compiler.disable()`d functionzSkip calling function `z4` since it was wrapped with `torch.compiler.disable`z(Remove the `torch.compiler.disable` call)gb_typer  explanationhintsmsgz%Call to `torch._dynamo.graph_break()`z0Called `torch._dynamo.graph_break()` with args `z`, kwargs ``z$User-inserted graph break. Message: z.Remove the `torch._dynamo.graph_break()` call.z2Graph break due to unsupported wrapper descriptor zM. Please file an issue on GitHub so the PyTorch team can add support for it. r   z<unknown qualname>z?Dynamo developers have intentionally marked that the function `z` in file `z` should not be traced.zAvoid calling the function `z`.r
  zRemove the function `z` or the file `zv` from torch/_dynamo/trace_rules.py. More graph breaks may occur as a result of attempting to trace into the function.z Please file an issue to PyTorch._abc	_warningsz6Dynamo does not know how to trace the Python builtin `.zIf you are attempting to call a logging function (e.g. `_warnings.warn`), you can try adding it to `torch._dynamo.config.reorderable_logging_functions`.zKPlease file an issue on GitHub so the PyTorch team can add support for it. optreez*Dynamo cannot trace optree C/C++ function zi Consider using torch.utils._pytree - https://github.com/pytorch/pytorch/blob/main/torch/utils/_pytree.py
z/Dynamo does not know how to trace the builtin `z.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).zIf 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.a  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<missing reason>z,Attempted to call function marked as skippedzmodule: z, qualname: z, skip reason: )rm   rn   r   r   r   r   r
  graph_breakgetr   r9   r\   WrapperDescriptorTypeutils	warn_oncer   rq   getfiler  r   r  joinr5  )r}   r=   r   r   graph_break_msgrC  qualnamepathrA  rB  known_python_builtin_modulesr5  s               r@   r   "SkipFunctionVariable.call_function  sv    !!$**.DeLLKDJJ5djj\Auv>	 ZZ5==444$jj5O"1"D"D"F?J4&P[\b[ccdeB?BSTD	 

E$?$?@@DTZZL Q? @ 
 MM))#.#tzz>;OPH<Ytzz2UV^U_ `  $v%<> 
 38*B? D(/z OA A ;	 E` ++? 
 $(KKT[[5GFF"4::#8#8"9hZ_e^fg'	c  (Y06/D,::((,HH JJ112!H:RA  
iGE JJ))5

--88BB$NtzzOdOdNeefgofppq"rK^E
 MM''11+2DtyyQVGW2WX J$**J_J_I``abjak la b  m;E MM''11+2DtyyQVGW2WXQ(Ys"   AG A
L-(BL-
AL-,L-c                 h    [         R                  R                  [        U R                  U5      5      $ r8   )r   r0   r<   r   r   r   s      r@   r   %SkipFunctionVariable.call_obj_hasattr  s$    ))00T1JKKrB   rU   c                     U[         ;   a  [        R                  " X5      $ [        XR                  U R
                  U5      $ r8   )r$   r   r   rt   r   r?   r   s      r@   r   SkipFunctionVariable.var_getattr  s3    )),,T88b**dkk4@@rB   )r5  r   r8   r  r   r=   r2   )r   r   r   r   r.   r  r   r   r  r   r   r   r   r  r   r  r  s   @r@   r4  r4  u  s     
	'	'N 
 ) )o#o &o -	o
 
obLA5 AS A ArB   r4  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)r}   r_  r`  r   r   s       r@   r   $WrapperUserFunctionVariable.__init__  s    "6"&*rB   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      $ r8   )	r`  rq   r_  r?   r   r.   r:   r   r  )r}   r=   rU   r>   r?   r   s        r@   r  'WrapperUserFunctionVariable.var_getattr  sc    %%%$**D,>,>?C[[BZT%BF"((&99w"2,,rB   c                     [         R                  " [        R                  5      R	                  X[         R
                  " U R                  5      /UQU5      $ r8   )r   r   r   getattr_and_tracer   r0   r`  r   s       r@   r   )WrapperUserFunctionVariable.call_function  sJ     --''

-y11$2D2DEMMv
	
rB   )r`  r_  r  r[  r   )
r   r   r   r   rg   r   r  r   r   r  r  s   @r@   r]  r]    sB    +
-

#

 &

 -	


 


 

rB   r]  c                  \    [         R                  R                  5       (       a  SSKJn   U $ 0 $ )Nr   traceable_collective_remaps)r   distributedis_available)torch.distributed._functional_collectivesri  rh  s    r@   _traceable_collective_remapsrm  *  s)    %%''	
 +*IrB   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   rj  rk  rm  valuesr   import_sourcer   )r=   rr   
inner_namepath_sources       r@   _traceable_collectives_sourcers  5  sc    ))++B-BB+-/668888J""#NOKk..rB   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 r8   )r   r   r9   r   replacement_var)r}   rr   rw  r   r   s       r@   r   *CollectiveFunctionRewriteVariable.__init__I  s/    &v&/+?@@@@.rB   c                 f    [         R                  X5      u  pE[        U4[        U4SU0UD6US.UD6$ )Nr?   )rw  r?   )ru  rewriter   )r=   old_fnr?   optionsnew_fn
new_sources         r@   r<   (CollectiveFunctionRewriteVariable.createN  sI    >FFrR0
0V
VgV
 	
 	
rB   c                 V    [         R                  " U 5      =(       a    U [        5       ;   $ r8   )rm   
isfunctionrm  )variables    r@   can_rewrite-CollectiveFunctionRewriteVariable.can_rewriteX  s%     x(WX9U9W-W	
rB   c                 6    [        5       U   nU[        X5      4$ r8   )rm  rs  )r=   rr   r}  s      r@   rz  )CollectiveFunctionRewriteVariable.rewrite^  s     -/34R@@@rB   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.distributedrj  rl  r  rm   r   rr   rG   r   r   r   r   
all_reducereduce_scatter_tensor_reduce_scatter_baserL  r   r   defaultr   r   r0   r<   rw  r   )	r}   r=   r   r   distr  r   reduce_op_var	reduce_ops	            r@   r   /CollectiveFunctionRewriteVariable.call_functionc  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CrB   )rw  r  r[  r   )r   r   r   r   rg   r   r4  r<   r  rz  r   r   r  r  s   @r@   ru  ru  >  s    /
 
 
 
 

 A A'D#'D &'D -	'D
 
'D 'DrB   ru  c                   <   ^  \ rS rSr        SU 4S jjrSrU =r$ )FunctoolsWrapsVariablei  c                    >^ U(       d+  [        T5      S:X  a  U4S jn[        R                  " U5      $ [        TU ]  UTU5      $ )Nr+   c                    > [        U [        R                  5      (       a  U R                  TS   S9$ [	        SU  S35        g )Nr   )r  zfunctools.wraps(rJ  )r9   r   r   cloner   )rr   r   s    r@   r,  3FunctoolsWrapsVariable.call_function.<locals>.wraps  s=    b)"F"FGG88tAw877 0A67rB   )r   r   LambdaVariabler   r   )r}   r=   r   r   r,  r   s     `  r@   r   $FunctoolsWrapsVariable.call_function  s>     #d)q.8
 ++E22w$Rv66rB   r   r   )r   r   r   r   r   r   r  r  s   @r@   r  r    s3    7#7 &7 -	7
 
7 7rB   r  c                   4    \ rS rSrS r        SS jrSrg)CollectionsNamedTupleFunctioni  c                     U R                   $ r8   r   r|   s    r@   r   0CollectionsNamedTupleFunction.as_python_constant  r   rB   c                 P   [        X#5      nU(       a~  U R                  " U Vs/ s H  oUR                  5       PM     sn0 UR                  5        VVs0 s H  u  pgXgR                  5       _M     snnD6n[        R
                  " U[        5       S9$ [        S5        g s  snf s  snnf )N)mutation_typez!namedtuple with non constant args)r"   rr   r   rE   r   UserDefinedClassVariabler-   r   )	r}   r=   r   r   constant_argsr  rI   rJ   r   s	            r@   r   +CollectionsNamedTupleFunction.call_function  s     ,D9GG267$Q&&($79?H1**,,HE 55%5%7  	9: 8Hs   BB"r   Nr   )r   r   r   r   r   r   r   r   rB   r@   r  r    s2    ;#; &; -	;
 
;rB   r  c                      ^  \ rS rSrS\SS4U 4S jjrS rS rS r        SS jr	S	S
S\
S\4S jrS	S
S\
4S jrS rS rSrU =r$ )FunctoolsPartialVariablei  re   r   Nc                    > [         TU ]  " S0 UD6  Xl        [        U[        5      (       d   eX l        [        U[        5      (       d   eX0l        [        R                  " [        5      U l        g r"  )r   r   re   r9   rD   r   rG   keywordsr   r   r&   
fake_value)r}   re   r   r  r   r   s        r@   r   !FunctoolsPartialVariable.__init__  s\    "6"	$%%%%	(D))))  $++H5rB   c                 "    [         R                  $ r8   )r   r   r|   s    r@   r   $FunctoolsPartialVariable.python_type  s       rB   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   r-  r'  s   r@   r(  6FunctoolsPartialVariable.reconstruct.<locals>.<lambda>  s    g&>&>{I&VrB   r+   F)r.  re   r   foreachr  r/  r   r   ro  rF   r  create_call_function_kw)r}   rZ  r  s    ` r@   rY  $FunctoolsPartialVariable.reconstruct  s    VW		99OODII&}}!!"6s499~7I5"QR,,./T]]'')*++CIDII,F,JDRWX	
rB   c                 "    U R                  5       $ r8   r   r|   s    r@   r   %FunctoolsPartialVariable.get_function      &&((rB   r=   r2   c                 x    U R                   U-   n0 U R                  EUEnU R                  R                  XU5      $ r8   )r   r  re   r   )r}   r=   r   r   merged_argsmerged_kwargss         r@   r   &FunctoolsPartialVariable.call_function  s<     ii$&34==3F3yy&&rFFrB   rU   c                     [         R                  R                  [        [        R
                  " [        5      U5      5      $ r8   )r   r0   r<   r   r   r   r&   r   s      r@   r   )FunctoolsPartialVariable.call_obj_hasattr  s2     ))00I%%h/6
 	
rB   c                    U R                   =(       a    [        U R                   U5      nUS:X  a  U R                  $ US:X  a  [        R                  " U R
                  US9$ US:X  aW  U R                  R                  5        VVs0 s H  u  pE[        R                  " U5      U_M     nnn[        R                  " XcS9$ [        [        U5        g s  snnf )Nre   r   r   r  )r?   r   re   r   ListVariabler   r  rE   r0   r<   ConstDictVariabler   ro   )r}   r=   rU   r?   rI   rJ   rE   s          r@   r  $FunctoolsPartialVariable.var_getattr  s    >DKK!>6>996>))$))FCC:?C}}?R?R?TU?Ttq%,,Q/2?TEU..uDD 4 Vs   #C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 r8   )r   r   re   r   r   r  rE   )r}   r   rI   rJ   s       r@   r   +FunctoolsPartialVariable.as_python_constant  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   re   guard_as_python_constantr   r  rE   )r}   rJ   rI   s      r@   r  1FunctoolsPartialVariable.guard_as_python_constant  s      II..0
48II>Iq((*I>
 <@==;N;N;PQ;P41q,,..;PQ
 	
>Qr  )r   r  re   r  r   )r   r   r   r   r.   r   r   rY  r   r   r   r   r  r   r  r   r  r  s   @r@   r  r    s    	6_ 	64 	6!
)G#G &G -	G
 
G
)
14
	

55 
5S 
5

 
rB   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$ )PolyfilledFunctionVariablei  rr   r  traceable_fnNr   .c                     0 $ r8   r   )r   s    r@   _get_polyfill_handlers1PolyfilledFunctionVariable._get_polyfill_handlers  s	     	rB   c                 ^    [        UR                  [        R                  5      5        U " XS9$ r   )r   r   r   r<  r   s      r@   r   -PolyfilledFunctionVariable.create_with_source  s&    f''(C(CDE5((rB   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   rr   r  rL  callablerq   r  r  r  )r}   rr   r   handlercandidate_attr	candidater  r   s          r@   r   #PolyfilledFunctionVariable.__init__  s    "6"--/33B;  X$5gY>STVSW"XX 
N  >Iy	****(
 #G9,OP  & ,rB   c                     U R                   $ r8   )r  r|   s    r@   polyfill_fn&PolyfilledFunctionVariable.polyfill_fn/  s       rB   c                 0    [        U R                  SS5      $ )N*__torch_dynamo_can_constant_fold_through__F)rq   r  r|   s    r@   can_constant_fold_through4PolyfilledFunctionVariable.can_constant_fold_through3  s    OOI5
 	
rB   c                 "    U R                  5       $ r8   r  r|   s    r@   r   'PolyfilledFunctionVariable.get_function8  r  rB   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r8   )r9   r   r0   r   intSymNodeVariabler   )r  r  s     r@   r  ;PolyfilledFunctionVariable.call_function.<locals>.<genexpr>R  sd       'A Ay99:Wz!''SV?W Yq)";";<WTWAWY&s   BBr   c              3   @   #    U  H  oR                  5       v   M     g 7fr8   )as_proxy)r  as     r@   r  r  ]  s     ?A::<<s   )sym_num)r  r#   rr   r   rE   r.   r:   r  sumr   r9   r   r  TupleVariabler  r  r<   rM   create_proxyr   sym_sumrF   r0   r   r  r  r   )	r}   r=   r   r   r  rI   rJ   rH   traceable_function_variables	            r@   r   (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 r?   )r   rq   rr   r'   r?   r   r  )r}   r=   rU   r   r   methodr|  polyfilled_method_variables           r@   r0  &PolyfilledFunctionVariable.call_methodo  s     :%%b77$-!JWTF.	#JJ!6""QgdV3Gy$QQ";; *4;; =GH%?%R'%R")77&IIrB   c                     U R                   $ r8   r   r|   s    r@   r   -PolyfilledFunctionVariable.as_python_constant  r   rB   )rr   r  r  r   r   r   r   r   r   r.   )r   r   r   r   r.   r  r  r   	lru_cacherG   r   r   r\   rY   r  r   r5   r   propertyr  r  r   r   r0  r   r   r  r  s   @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& rB   r  c                       \ rS rSrS rSrg)TracebackVariablei  c                     g r8   r   r   s       r@   r   TracebackVariable.call_function  s    srB   r   N)r   r   r   r   r   r   r   rB   r@   r  r    s    2rB   r  c                   :   ^  \ rS rSrU 4S jrS rS rS rSrU =r	$ )SysFunctionVariablei  c                 2   > [         TU ]  " S0 UD6  Xl        g r"  )r   r   r   )r}   r   r   r   s      r@   r   SysFunctionVariable.__init__  s    "6"
rB   c                 z   [        UR                  5      (       aK  UR                  S   nUR                  nS n[        R                  " X5      U[        R                  " X5      /nOA[
        R                  " S 5      [
        R                  " S 5      [
        R                  " S 5      /n[
        R                  " U5      $ )N)r   exn_vt_stackr  r.   r:   r   r0   r  )r}   r=   exnr  tbrE   s         r@   exc_infoSysFunctionVariable.exc_info  s    r//"%C,,CB%%b.%%b-E **40**40**40E
 &&u--rB   c                 >    U R                  U5      R                  S   $ r  )r  rE   r   s     r@   	exceptionSysFunctionVariable.exception  s    }}R &&q))rB   c                     U R                   [        R                  L a  U R                  U5      $ U R                   [        R                  L a  U R                  U5      $ [	        SU R                   R
                   35        g )Nzsys.)r   r  r  r	  r   r   r   s       r@   r   !SysFunctionVariable.call_function  sZ    ::%==$$ZZ3==(>>"%%D!4!4 567rB   r9  )
r   r   r   r   r   r  r	  r   r   r  r  s   @r@   r  r    s    .$*8 8rB   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 rS rS rS\S\4S jrSSS\\   SS4S jrS\4S jrSrg)DynamoTritonHOPifieri  rC  r   c                     [        U5      er8   )r   )r}   rC  s     r@   raise_unsupported&DynamoTritonHOPifier.raise_unsupported  s    #rB   maybe_callablec                 .    [        U[        [        45      $ r8   )r9   r   r   )r}   r  s     r@   is_callable DynamoTritonHOPifier.is_callable  s    79MN
 	
rB   r>   c                     UR                   $ r8   r9  )r}   r>   s     r@   	get_valueDynamoTritonHOPifier.get_value  s    yyrB   .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  r9   r  r   r(  )r}   gridr  s      r@   
check_gridDynamoTritonHOPifier.check_grid  s0    +d--==?":4:,GHrB   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 r8   )rE   r   r0   r<   r   )r}   r  metar=   rI   rJ   s         r@   	call_gridDynamoTritonHOPifier.call_grid  sS    DHJJLQLDA	**11!4a7LQ!!"fb1 Rs   ,Ac                 X    SSK Jn  UR                  XA5      nUR                  XBU5      nU$ )Nr+   )SourcelessBuilder)builderr&  r<   r   )	r}   user_fnr   r   r=   r  r&  wrapped_user_functionrH   s	            r@   call_user_defined_fn)DynamoTritonHOPifier.call_user_defined_fn  s-    . 1 8 8 E&44RvFrB   c                 l    SSK Jn  U" U[        UR                  U 5      5      R	                  U5      nU$ )Nr+   )VariableBuilder)r'  r-  r   kernel_source_wrap)r}   user_objr=   r  rU   r-  wrapped_user_objs          r@   wrap_user_defined_obj*DynamoTritonHOPifier.wrap_user_defined_obj  s7    ,*
811dV=

%/ 	  rB   c                 p    UR                  U5      nU Vs/ s H  o3R                  5       PM     nnU$ s  snf r8   )unpack_var_sequencer  )r}   configsr=   configs       r@   maybe_unpack_configs)DynamoTritonHOPifier.maybe_unpack_configs  s<    --b1 DKK72247K Ls   3rH   c                 n    UR                  5       (       d  U R                  S5        UR                  5       $ )Nz`@triton.heuristics must return constant values because configs can only contain constant values.)is_python_constantr  r  )r}   rH   s     r@   maybe_unpack_heuristic_result2DynamoTritonHOPifier.maybe_unpack_heuristic_result  s3    ((**""r ..00rB   r  TritonKernelVariabler   c                     UR                   c  [        U5      S:w  a  U R                  S5        [        U5      " UR                  UR
                  US   UR                  S9$ )Nr+   z7Triton kernels should be called with only a single gridr   )kernel
kernel_idxr  r.  )r  r   r  r(  r@  rA  r?   )r}   r  r   s      r@   call_getitem!DynamoTritonHOPifier.call_getitem  sZ     ==$D	Q""I H~??**a"//	
 	
rB   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/   )r  r   )kernel_side_tabletriton_kernel_wrapper_mutationz.Unexpected argument type for a Triton kernel: rG  r   r   )rA  constant_args_idxr  tma_descriptor_metadatar   )r  r0   dictsr  rD   r  r9   TMADescriptorVariableto_metadatadata_ptrfrom_tensorrE   r   r<   *torch._higher_order_ops.triton_kernel_wraprE  rF  r   ro  realizer  r  r  repradd_constant_argsrG   rM   r  rA  r  )r}   r  gridscombined_args_rawr=   r0   r  rH  rI   rJ   combined_argsrE  rF  r  non_constant_argsrG  r"  s                    r@   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)r   r   r   r   r   r	   r  r   r  r  r  rF   r   fxproxyProxyr  r#  r*  r2  r8  r<  r   rB  r0   rV  r   r   rB   r@   r  r    s    S U 
# 
$ 

S S I%(<(<c(A"B I 1C 1C 1
(
 sm
 
 	
$@
BR @
rB   r  c                      ^  \ rS rSr% S\S'   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$ )r>  iH  r3   r  r4   r@  rA  r   r.  r   c                    > UR                  SS 5      U l        [        TU ]  " S0 UD6  [        R                  XX#5        g )Nr.  r   )rR   r.  r   r    dynamo_triton_hopifier_singletoninit_variable)r}   r@  rA  r  r   r   s        r@   r   TritonKernelVariable.__init__N  s6    #ZZ>"6"(66tZVrB   c                 .    [         R                  XX15      $ r8   )r]  call_triton_kernelr   s       r@   r   "TritonKernelVariable.call_functionS  s     0BB
 	
rB   c                    > US:X  a  [         R                  X5      $ US:X  a  [         R                  XXA5      $ [        TU ]  XX45      $ )N__getitem__run)r]  rB  call_runr   r0  )r}   r=   rU   r   r   r   s        r@   r0   TritonKernelVariable.call_method]  sL     = 3@@LLU]3<<TTT w"2T::rB   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  r0   tensorr  r9   r<   evaluate_expr)r}   r   r0   r  s       r@   specialize_symbolic(TritonKernelVariable.specialize_symbolicl  s4    .+ c++#**3+<+<+>??
rB   )r.  r  r   r  )r   r   r   r   r_   r   r  r   r   r0  r   rk  r   r  r  s   @r@   r>  r>  H  s    
W

#
 &
 -	

 

; &	;
 -; 
;s s  rB   r>  c                   H   ^  \ rS rSr        SU 4S jjrS rS rSrU =r$ )rJ  iv  c                    > [        U[        R                  5      (       d   e[        TU ]  " S0 UD6  Xl        X l        X0l        X@l        g r"  )	r9   r   DataPtrVariabler   r   rL  dims
block_dimselement_size)r}   rL  rp  rq  rr  r   r   s         r@   r   TMADescriptorVariable.__init__w  sC     (I$=$=>>>>"6" 	$(rB   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 r8   )rp  r  rq  rr  )r}   dims     r@   rK  !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   rp  )rZ  r}   s   r@   r(  3TMADescriptorVariable.reconstruct.<locals>.<lambda>  s)    G,,6#dii.))9:rB   r+   F)	r.  rL  rY  rp  rq  rr  r  r   r   )r}   rZ  r   s   `` r@   rY  !TMADescriptorVariable.reconstruct  sp    	
 	!!'*@@T__@d.?.?@c$i!mU3rB   )rq  rL  rp  rr  )rL  zvariables.DataPtrVariablerp  list[ConstantVariable]rq  r}  rr  r0   )	r   r   r   r   r   rK  rY  r   r  r  s   @r@   rJ  rJ  v  s=    )-) ') -	)
 ))

4 
4rB   rJ  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  rankr   Nc                 B   > US;   d   e[         TU ]  " S0 UD6  Xl        g )N)r+   r   r   )r   r   r  )r}   r  r   r   s      r@   r   $CreateTMADescriptorVariable.__init__  s&    
 v~~"6"	rB   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+      ru  	block_dimr      dim1dim0
block_dim1r  
block_dim0rr  r  )rL  rp  rq  rr  )r9   r   ro  r   r  r   rJ  )r}   r=   r   r   r  rp  rq  rr  s           r@   r   )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$!%	
 	
rB   )r  r   )	r   r   r   r   r  r   r   r   r  r  s   @r@   r  r    sJ     
	(
#(
 &(
 -	(

 
(
 (
rB   r  r8   r[  )nrg   r  r   rm   r^   r  r\   collections.abcr   typingr   r   r   r   r   typing_extensionsr	   unittest.mockr
   r   r  r   r   bytecode_transformationr   r   r   r  r   r   r   r   r   r   r   r   r   r   r   guardsr   r   r?   r   r   r    r!   rN  r"   r#   r$   r%   r&   r'   r(   r)   r*   baser,   r-   r.   r  r0   #torch.distributed.fsdp._fully_shardr1   ModuleNotFoundErrorrR  r2   rN  r3   r4   r5   rA   rK   rG   r   rW   rf   rp   rt   rv   r   r   r6  r  r  r  r  r  r  r  r   r4  r]  rm  rs  ru  r  r  r  r  r  r  r  r  r  r]  r>  rJ  r  r   rB   r@   <module>r     sR  .     
  $ B B #   # V V    1 N N
 
 
 = < &E
 D T"	A. $sO';"<  "( -" DF73 F7R:4 :<y4? y4x	
 
4
%= 4
n"<V-- V-r 2 ("6 ( NA!9 NAbPA? PAf
/ 
D/LD(< LD^71 7&;$8 ;,L
 L
^~ ~B3 3
 8/  8FN
> N
b $8#9  +? +\!4O !4H2
/ 2
c:  s   &H HH