
    ^jD                        U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z	d dlZd dlZd dlZd dlZd dlZd dlmZmZmZ d dlmZmZ d dlmZ d dlZd dlmZmZmZ d dlmZ d dlm Z  d dl!m"Z" d d	l#m$Z% d d
l&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: ddl;m$Z$m<Z< ddl<m=Z= ddl>m?Z?m@Z@mAZAmBZBmCZC ddlDmEZE  ej                  eG      ZHdaIeJeKeLeMf      dz  eNd<   daOePeNd<   daQeKeReLdz  f   dz  eNd<    e)eGd      ZS e)eGd      ZTeJe   ZU e j                  dd d!g      ZWg d"ZX e8d#d$g      ZYej                  d%ePfd&       Z[d'eLdz  d%eLfd(Z\	 	 dfd)eJe?   d*ePd'eLdz  d%dfd+Z]d,eJe?   d%ej                  fd-Z_	 	 dgd)eUdz  d.eKeLeLf   d/eLdz  d0eRd%df
d1Z`d.eKeLeLf   d%eKeLeWf   fd2Zad3ej<                  j^                  d,eUd%dfd4Zbej                  d%ed   fd5       Zdi aeeKeLeKeLeJeL   f   f   eNd6<   i afeKeLeJeL   f   eNd7<   dageRdz  eNd8<   i aheKeLeLf   eNd9<   i aieKeLeJeL   f   eNd:<   d ajeReNd;<   dhd<Zkej                  d%ed   fd=       Zl G d> d?      Zm G d@ dA      Znd)eUd%dfdBZod)eUd%dfdCZpdDeJeLdz     d%dfdEZqd)ee?   d%dfdFZrdGeeseetf      d%dfdHZudhdIZvej                  d%ed   fdJ       Zwej                   G dK dL             Zyej                   G dM dN             Zz ej                         Z|dOeRdz  dPeKeLef   d%eKeLeKeLeJeL   f   f   fdQZ}dReKeLef   d%eKeLeKeLef   f   fdSZ~d%eKeLef   fdTZd%eKeLeKeLeJeL   f   f   fdUZ	 didVee?   e=z  dWeLdXePd%eRdz  fdYZdZed[ed%dfd\Zd]eLd%efd^Zdd_d`edaeLf   dbej                  j
                  dceKeLef   dde6dz  d%eLf
deZy)j    N)CallableIteratorSequence)AnyIO)patch)
draw_graphget_aot_graph_nameget_graph_being_compiled)fx)save_graph_repro)get_debug_dirconfig)utils)getArtifactLogger)trace_structured)signpost_event)GraphModule)_extract_tensor_metadataTensorMetadata)legalize_graph)FileLike)
OrderedSet)tree_map   )r   ir)ExternKernel)BaseSchedulerNodeFusedSchedulerNodeNopKernelSchedulerNode
OutputNodeSchedulerNode)VGRAPH_EXECUTION_ORDERFRECORD_GRAPH_EXECUTIONGRAPH_COMPILE_IDSir_pre_fusionir_post_fusionBufMetanamen_origin)dotz-Gnslimit=2z-Gnslimit1=2z-Gmaxiter=5000r-   rawreturnc                  0    t        j                  d      d uS )Nr-   )shutilwhich     `/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/_inductor/debug.pyhas_dotr6   A   s    <<d**r4   fnamec                     | 5t         j                  j                  |       \  }}|r|j                  d      S t        j
                  S )N.)ospathsplitextlstripfunctorch_configtorch_compile_graph_format)r7   _exts      r5   _get_graph_output_formatrB   F   s=    !!%(3::c?"666r4   nodesprint_graphc           
         t        |      }|t        vr t               st        j	                  d       y|
t               }t        |       }|j                  D ]  }d|j                  vr|j                  d   j                  }t        |t              r t        |d   t              r|d   f}nj|d   }ndt        |t              rT	 |j                  d   j                  }|j                         d   j                   j#                         }|rt        |      nd}d}	t        |t&        j(                        r|j*                  j,                  }	t/        ||	ddddd      }
|
|j                  d<    |rt1        |       t3        i |      }t5        |       |j6                  j9                          t;        ||dt<        j>                  j@                  	       y# t$        $ r d}Y w xY w)
z 
    Draw a graph in fname.
    z*draw_buffers() requires `graphviz` packageNfusion_metar   r   r3   tensor_metaF)
clear_metadot_graph_shape)!rB   _RAW_DOT_GRAPH_FORMATSr6   logwarningr   create_fx_from_snodesrC   metagroup
isinstancetupleintstrsnodeget_outputsnodemaybe_get_size	Exceptionr   ComputedBufferdatadtyper   printr   r   graphlintr	   r   tracerI   )rC   rD   r7   graph_formatr]   rV   rO   rT   sizer[   metadatagms               r5   draw_buffersrd   N   s    ,E2L11')@A}(*!%(E ,		)		-(..eU#%(C(qas#		-066((*1-22AAC'+d
 dB--.IIOOE!%dD$M#+		- 7,: e	R	B2HHMMO
EeV\\5Q5Q%  s   AGG G snodesc                    dt         dt        dt        f   fd}t        j                  dg d      }i }i }t
        j                  j                         }d}g }d}| D ]  }	|	j                         rd}
|
}ns|	j                         rd	}
|
}n^t        |	t              rd
}
|
}nIt        |	t              rd}
|	j                  }n*t        |	t              rd}
|	j                  }nt        d      t
        j                   j"                  j%                  |	j'                         d      }|
 d| } ||      }i }t)        |	d      rd|	j+                         i}|j-                  |d|      }dt.        t        z  dt0        ffd |	      r|j3                  |       |	j5                         }||_         |||	|
      |j8                  d<   |||<   |	j;                         D ]  }|||j5                         <    ||} | D ]  }	|	j5                         }|	j<                  j>                  }||   }g }|D ]{  }|j6                  |v r||j6                     }nD|jA                  |      5  |jC                  |j6                        }|||j6                  <   ddd       |k(  rk|j3                  |       } tE        |      |_#         |jI                  tK        |      dk(  r|d          |S tE        |             |S # 1 sw Y   ixY w)B
    Creates a FX Graph from a list of SchedulerNode objects.
    r+   r/   .c                 4    dt         dt        fd}| |_        |S )Nargsr/   c                       yNr   r3   )ri   s    r5   func1z;create_fx_from_snodes.<locals>.get_fake_func.<locals>.func1   s    r4   )r   rR   __name__)r+   rl   s     r5   get_fake_funcz,create_fx_from_snodes.<locals>.get_fake_func   s#    	 	 	 r4   
FusionMeta)rO   rT   typeNexterntemplatenopcomputefusedzUnknown node typeoriginal_atenz: 
get_devicedevicer3   ri   kwargsrT   c                     t        | t              rt        fd| j                  D              S t        d | j	                         D              S )Nc              3   .   K   | ]  } |        y wNr3   ).0x	in_outputs     r5   	<genexpr>z;create_fx_from_snodes.<locals>.in_output.<locals>.<genexpr>   s     >A9Q<>s   c              3   r   K   | ]/  }|j                   D ]  }t        |j                  t                 1 y wr}   )usersrP   rV   r"   )r~   bufusers      r5   r   z;create_fx_from_snodes.<locals>.in_output.<locals>.<genexpr>   s<      II  499j11s   57)rP   r    anyre   rU   )rT   r   s    r5   r   z(create_fx_from_snodes.<locals>.in_output   sF    %!34>>>>  ,,.  r4   rF   r   r   )&rS   r   rR   collections
namedtupletorchr   Graph	is_externis_templaterP   r!   r#   rO   r    RuntimeError	_inductorr   get_fused_kernel_name	get_nodeshasattrrw   call_functionr   boolappendget_namer+   rN   rU   read_writesreadsinserting_beforeplaceholderrQ   ri   outputlen)re   rn   ro   buf_to_fx_nodenode_to_fx_noder]   
first_nodeoutputsrO   rT   	node_type
fused_name	func_name	node_funcrz   fx_noder+   r   depsnew_argsdepdep_noder   s                         @r5   rM   rM      s   
C HS#X$6  ''6PQJNOHHNNEJGE  2!?? IE "IE56IE}-!IKKE12IKKE233__**@@OO

 !kJ<0	!),	5,' 0 0 23F%%ib%H	.1CC 	 	 UNN7#~~&0y&I]# '$$& 	5C-4N3<<>*	5  Je2!j  '~~  &&!$' 		&Cxx>))#((3++J7 8$00:H/7N388,8 7"OOH%		& X#'& 
LLs7|q0EL 7<GnEL8 8s    +K33K<node_name_to_buf_nameparent_buf_name	n_originsc                 X   | y | D ]  }|j                         }|j                         }| t        |      dkD  rt        ||||n|       Et        |      dk(  r|d   |k(  sJ |j                  }||j
                  x|j
                  D ]  }|j                  }	|	|vs||n|||	<     y )Nr   r   )r   r   r   $update_orig_fx_node_name_to_buf_namerV   originsr+   )
rC   r   r   r   rV   buf_namechildren_nodesir_nodeorigin	node_names
             r5   r   r      s     } ==?)%#n*=*A0%+3
  ~&!+q0AT0III))?goo5oo 	FI  55 / 7H_ &i0	%r4   c                     i }| j                         D ]-  \  }}||vrt        |g      ||<   ||   j                  |       / i }| j                         D ]"  \  }}t        ||         }t	        ||      ||<   $ |S r}   )itemsr   addr   r*   )r   buf_name_to_n_noder   r   node_name_to_buf_metan_nodes         r5   get_node_name_to_buf_metar     s     4::< 8	8--+5yk+Bx( x(,,Y78 4::< E	8'12+28V+Di(E ! r4   rc   c                     i }t        ||       |yt        |      }| j                  j                  D ]9  }|j                  |v s|j                  |j                        |j                  d<   ; y)rg   Nbuf_meta)r   r   r]   rC   r+   getrN   )rc   re   r   r   rV   s        r5   annotate_orig_fx_with_snodesr   !  sm     -/(1FG$56KL I99--$9$=$=dii$HDIIj!Ir4   c               #     K   t         j                  j                  dd      dk(  } dd l}t	        j
                  |j                  j                  j                        }t        j                         }| s	 d  |j                          y |j                  t        dd             t         j                  j                  t!               d      }t        j"                  |d       t	        j$                  t         j                  j                  |d	t'                d
            }|j)                  t        j*                         |j-                  t	        j.                  d             |j1                  |       	 d  |j3                  |       |j                          y # |j                          w xY w# |j3                  |       |j                          w xY ww)NTORCH_COMPILE_DEBUG01r   z*functorch.compile.config.debug_partitionerTtorchinductorexist_okaot_z
_debug.log3[%(filename)s:%(lineno)d %(levelname)s] %(message)s)r:   environr   torch._functorch.aot_autogradlogging	getLogger
_functorchaot_autogradrm   
contextlib	ExitStackcloseenter_contextr   r;   joinr   makedirsFileHandlerr
   setLevelDEBUGsetFormatter	Formatter
addHandlerremoveHandler)compile_debugr   rK   stackr;   fhs         r5   enable_aot_loggingr   2  sZ    JJNN#8#>#EM(


E,,99BB
CC  "E	KKM 
JDQR77<<9DKKt$			
%'(
3	

B KKOOOP NN2"3 KKM0 	"s7   A1G4F 8C>G7F2 ;"GF//G2#GG _inductor_post_to_pre_grad_nodes._inductor_triton_kernel_to_post_grad_node_info_pre_grad_graph_id#_inductor_pre_grad_node_stack_trace_inductor_kernel_stack_trace(_inductor_kernel_provenance_debug_handlec                      da y rk   )r   r3   r4   r5   -reset_inductor_kernel_provenance_debug_handler   f  s    /0,r4   c               #      K   t         } t        j                         }t        j                         }t        j                         }t
        j                         }t        }da i ai ai ai ada	 d | a |a|a|a|a|ay# | a |a|a|a|a|aw xY ww)zzContext manager that resets provenance tracking globals upon entering
    and restores their original values when exiting.r   N)r   r   copyr   r   r   r   )original_pre_grad_graph_idoriginal_post_to_pre_grad_nodes-original_triton_kernel_to_post_grad_node_info+original_inductor_pre_grad_node_stack_trace$original_inductor_kernel_stack_trace0original_inductor_kernel_provenance_debug_handles         r5   reset_provenance_globalsr   k  s      "4&F&K&K&M#6;;= 2 	,002 0 ,H+L+L+N(0 5
 ')$572*,'#% /0,
 8+J(9 	7 (L$7 	, = 	1 8+J(9 	7 (L$7 	, = 	1s   A)B,A= 0B=BBc                   ^   e Zd Z ej                         Zedededz  fd       ZddZ	deddfdZ
	 dded	ed
ededee   f
dZej                  	 dded	ed
ededeee      f
d       ZdedefdZddZddZdededdfdZdee   dz  dedz  dedz  ddfdZddZdeded   dz  fdZy)DebugContextfolder_namer/   Nc                    t         j                  j                  xs
 t               }t        j
                  D ]C  }t        j                  j                  |d|  d|       }	 t        j                  |d       |c S  y # t        $ r Y Rw xY w)Nr   r9   Fr   )r   r_   	debug_dirr   r   _counterr:   r;   r   r   FileExistsError)r   r   ndirnames       r5   create_debug_dirzDebugContext.create_debug_dir  s    LL**=mo	&& 	Aggll-q$G
Ge4	 	 #  s   !A>>	B
	B
c                 R    d | _         d | _        t        j                         | _        y r}   )_prof_pathr   r   _stack)selfs    r5   __init__zDebugContext.__init__  s     

 **,r4   new_pathc                    | j                   sy |j                  d      sJ |       ddlm} 	  || d      5  t        j
                  j                  |      rt        j                  |       t        j                  | j                   |       d d d        y # 1 sw Y   y xY w# t        $ r$ t        j                  d| j                   |       Y y w xY w)Nz.debugr   )FileLockz.lockz(Failed to copy debug files from %s to %s)r   endswithfilelockr  r:   r;   existsr1   rmtreecopytreeOSErrorrK   rL   )r   r  r  s      r5   r   zDebugContext.copy  s    zz  *4H4*%	XJe,- 677>>(+MM(+

H56 6 6  	KK:DJJ	s/   B" ABB" BB" B" "*CCfilename
write_moderi   rz   c                     | j                   sJ t        t        j                  j	                  | j                   |      |g|i |S r}   r   openr:   r;   r   )r   r
  r  ri   rz   s        r5   fopenzDebugContext.fopen  s:     zzzBGGLLX6
TTTVTTr4   c              /      K   | j                   sJ t        t        j                  j	                  | j                   |      |g|i |5 }| d d d        y # 1 sw Y   y xY wwr}   r  )r   r
  r  ri   rz   fs         r5   fopen_contextzDebugContext.fopen_context  sW      zzz"'',,tzz84jR4R6R 	VWG	 	 	s   AA#	A	A#A A#suffixc                 r    | j                   sJ t        j                  j                  | j                   |      S r}   )r   r:   r;   r   )r   r  s     r5   r
  zDebugContext.filename  s'    zzzww||DJJ//r4   c                    t         j                  j                  dd l}| j                  sJ t
        j                  j                  | j                  t
        j                  j                  | j                         d      }|j                  |d      5 }|j                  | j                  t
        j                  j                  | j                               d d d        t         j                  j                  |       y y # 1 sw Y   *xY w)Nr   z.tar.gzzw:gz)arcname)r   r_   
upload_tartarfiler   r:   r;   r   basenamer  r   )r   r  tar_filetars       r5   r  zDebugContext.upload_tar  s    <<"".:::ww||

rww//

;<GDH h/ J3

BGG,<,<TZZ,HIJLL##H- /J Js   ADD
c                    t         j                  rjt        j                  d      j                  }j                  t        j                         dt        dd ffd}| j                  j                  ||       | j                  j                  t        j                  |              t         j                  j                  sy | j                  t!                     | _        t         j                  j$                  r | j'                  dt        j                         t         j                  j(                  r!| j'                  dt        j*                         y y )Nztorch._dynamolevelr/   c                 (    j                  |        y r}   )r   )r  rK   s    r5   reset_log_levelz/DebugContext.__enter__.<locals>.reset_log_level  s    U#r4   z	debug.logzinfo.log)r   debugr   r   r  r   r   r   r   callbackr   r$   set_debug_handlerr_   enabledr   r
   r   	debug_log_setup_log_captureinfo_logINFO)r   
prev_levelr  rK   s      @r5   	__enter__zDebugContext.__enter__  s    <<##O4CJLL'$s $t $ KK  *=!!!"5"5d";<||##**+=+?@
<<!!##K?<<  ##J= !r4   r  c                    t        j                  d      }| j                  j                  | j	                  |            }t        j
                  |      }|j                  |       |j                  t        j                  d             |j                  |       |j                  t        |j                  |             | j                  j                  |j                  |       y )Nztorch._inductorr   )r   r   r   r   r  StreamHandlerr   r   r   r   minr  r!  r   )r   r
  r  rK   fdchs         r5   r%  zDebugContext._setup_log_capture  s    
  12[[&&tzz(';<""2&
E
ST	
 	rSE*+S..3r4   exc_typeexc_valexc_tbc                 .   | j                   r*| j                   j                          | j                          | j                  r9| j	                          t
        j                  dt               | j                         | j                  j                          y )Nz%s debug trace: %s)
r   disable_save_profile_datar   r  rK   rL   r   r   r   )r   r/  r0  r1  s       r5   __exit__zDebugContext.__exit__  sa     ::JJ ##%::OOKK,.F.H$**Ur4   c                    | j                   sJ | j                   j                  | j                  d             | j                  d      5 }t	        j
                  | j                   |      }|j                          |j                  d       |j                  d       |j                  d       |j                  d       d d d        y # 1 sw Y   y xY w)Nzcompile.profzcompile.stats)streamcumtimed   tottime)	r   
dump_statsr
  r  pstatsStats
strip_dirs
sort_statsprint_stats)r   r-  statss      r5   r4  zDebugContext._save_profile_data$  s    zzz

dmmN;<ZZ( 	#BLLB7EY'c"Y'c"	# 	# 	#s   
A6C		Cr+   ).Nc                 
   t         j                  j                  r0t        t         j                  |      r	 t        t	        |       |      S dt        dt        dd fd}|S # t
        $ r t        j                  dd       Y y w xY w)Nz Ignoring exception in debug codeTexc_infori   rz   r/   c                       y r}   r3   ry   s     r5   ignoredz)DebugContext.__getattr__.<locals>.ignored8  s    r4   )	r   r_   r#  getattrDebugFormatterrX   rK   rL   r   )r   r+   rF  s      r5   __getattr__zDebugContext.__getattr__/  sy    <<GFLL$$?~d3T::s c d  N  >Ns   A  BBr/   N)w)rm   
__module____qualname__	itertoolscountr   staticmethodrS   r   r   r   r   r   r  r   contextmanagerr   r  r
  r  r)  rR   r%  rp   BaseExceptionr5  r4  r   rI  r3   r4   r5   r   r     s   y Hc cDj  "-
S T & UU U 	U
 U 
CU  		 	 		
 	 
"S'		 	0s 0s 0
.>.44 4 
	4 }%, % d
	
 
	# (;d(B r4   r   c                      e Zd ZdeddfdZdej                  j                  deej                     ddfdZ
dej                  j                  deej                     ddfdZd	eddfd
Zd	eddfdZed	edefd       Zd	eddfdZdej                  j                  d	eddfdZddededdfdZdedeej,                     dedef   dedededz  ddfdZy)rH  handlerr/   Nc                 x    |j                   | _         |j                  | _        |j                  | _        || _        y r}   )r  r  r
  rT  )r   rT  s     r5   r   zDebugFormatter.__init__?  s/    ]]
$22((r4   rc   inputsc           
         | j                  d      5 }d }t        j                  j                  j                  j
                  rRt        j                  j                  j                  |      }t        j                  j                  |j                        }t        j                  j                  j                  j
                  }t        j                  j                  j                  ddd      5  t        |||d||       d d d        d d d        | j                  d      5 }|j                  |j!                  d             d d d        y # 1 sw Y   MxY w# 1 sw Y   QxY w# 1 sw Y   y xY w)Nzfx_graph_runnable.pyF)ztrace.enabledztrace.save_real_tensorsinductor)save_dirstable_hashzfx_graph_readable.pyprint_output)r  r   r   r   r_   save_real_tensors_subclasses
fake_utilstry_convert_fake_to_realr:   r;   r   r+   r   r   writeprint_readable)r   rc   rV  r-  rY  rZ  s         r5   fx_graphzDebugFormatter.fx_graphE  s+   
 ZZ./ 	2H%%++==**55NNvV77??2773
  //0066HHK''--"'EJ 
 !% +
	, ZZ./ 	<2HHR&&E&:;	< 	<
 
	 	,	< 	<s0   CE/EE""E%E	EE"%E.c                     | j                  d      5 }|j                  |j                  d             d d d        y # 1 sw Y   y xY w)Nzfx_graph_transformed.pyFr[  )r  ra  rb  )r   rc   rV  r-  s       r5   fx_graph_transformedz#DebugFormatter.fx_graph_transformedc  sB    
 ZZ12 	<bHHR&&E&:;	< 	< 	<s	   "=ArC   c                     | j                  d      5 }|j                  | j                  |             d d d        y # 1 sw Y   y xY w)Nzir_pre_fusion.txtr  ra  	_write_irr   rC   r-  s      r5   r(   zDebugFormatter.ir_pre_fusionk  s;    ZZ+, 	,HHT^^E*+	, 	, 	,	   !<Ac                     | j                  d      5 }|j                  | j                  |             d d d        y # 1 sw Y   y xY w)Nzir_post_fusion.txtrg  ri  s      r5   r)   zDebugFormatter.ir_post_fusiono  s;    ZZ,- 	,HHT^^E*+	, 	, 	,rj  c                     t        j                         }| D ]2  }|j                  |j                                |j                  d       4 |j	                         S )Nz


)ioStringIOra  	debug_strgetvalue)rC   r   rV   s      r5   rh  zDebugFormatter._write_irs  sI    kkm 	 DIIdnn&'IIh	  ||~r4   c                 r    t        || j                  dt        j                  j                                y )Nzgraph_diagram.)r7   )rd   r
  r   r_   graph_diagram_format)r   rC   s     r5   graph_diagramzDebugFormatter.graph_diagram{  s+    --.1R1R0S TU	
r4   c                     t        ||       t        || j                  dt        j                  j
                         dt        dt        j                  j                         y )Nzorig_fx_graph_diagram.FT)r7   rH   progparse_stack_tracerI   )r   r	   r
  r   r_   orig_fx_graph_diagram_formatGRAPHVIZ_COMMAND_SCALABLErI   )r   rc   rC   s      r5   draw_orig_fx_graphz!DebugFormatter.draw_orig_fx_graph  sR    
 	%R/--()R)R(ST *""LL88		
r4   r
  	extensionc                 T    t        j                  || j                  d|              y )Nzoutput_code.)r1   r   r
  )r   r
  rz  s      r5   output_codezDebugFormatter.output_code  s     Hdmml9+,FGHr4   r+   input_nodestimingsChoiceCallerelapseprecompile_elapseprescreening_elapsec           	      N   ddl m dt         j                  dt        t        t        f   ffd|t
        j                  j                         t
        j                  j                         |D cg c]
  } |       c}|||d}| j                  ddd	
      5 }	|j                         D ][  \  }
}t        |
j                               }|j                  |       ||d<   t        j                  ||	       |	j                  d       ] 	 d d d        y c c}w # 1 sw Y   y xY w)Nr   )FixedLayoutrV   r/   c           
         t        | d      r| j                  }nd}|t        |       j                  d}	 | j	                         }t        |      r |j                  |j                  t        j                  j                  j                  |j                        t        j                  j                  j                  |j                        t        j                  j                  j                  |j                  d            }t!        |      |d<   nt!        |      |d<   	 t!        | j%                               |d<   	 t!        | j'                               |d	<   	 t!        t        j                  j                  j                  | j)                                     |d
<   	 t!        t        j                  j                  j                  | j+                                     |d<   	 t!        t        j                  j                  j                  | j-                                     |d<   t        | d      r9t        | j.                  t0        j2                        r | j.                        |d<   |S # t"        $ r Y Yw xY w# t"        $ r Y Lw xY w# t"        $ r Y ?w xY w# t"        $ r Y w xY w# t"        $ r Y w xY w# t"        $ r Y w xY w)Nr+    )r+   rp   r   )fallback)r[   ra   strideoffsetlayoutr[   rx   r  ra   numelrZ   )r   r+   rp   rm   get_output_specrP   rx   r[   r$   r]   sizevarsoptimization_hintsra   r  optimization_hintr  rS   rX   	get_dtyperw   
get_strideget_size	get_numelrZ   r   IRNode)rV   r   	node_infor  static_layoutr  build_node_infos        r5   r  z>DebugFormatter.log_autotuning_results.<locals>.build_node_info  s\   tV$ II		!T
++I--/fk2$/$llWW--@@M ww//BB6==Q ww//AA"MMA  B  %M +.m*<Ih'*-f+Ih'%()9%:	'"&)$//*;&<	(#&)GG$$778IJ'	(#
$'GG$$77H%	&!
%(GG$$66t~~7GH&	'"
 tV$DIIryy)I$3DII$>	&!=            so   C/I2 &J J  AJ" $AJ2 (AK 2	I?>I?	JJ	JJ"	J/.J/2	J>=J>	KK)op_namecuda_device_namecuda_device_countr}  autotuning_timeprecompile_timeprescreening_timezautotuning_result_json_list.txtatzutf-8)encodingbenchmark_result
)r   r  r  dictrS   r   cudaget_device_namedevice_countr  r   	info_dictupdatejsondumpra  )r   r+   r}  r~  r  r  r  rV   general_propertiesr-  callertimer  r  r  s                @@r5   log_autotuning_resultsz%DebugFormatter.log_autotuning_results  s    	$6	")) 6	S#X 6	r  %

 : : <!&!8!8!:>IJdOD1J%0!4
 -tg   
 	 '  !1!1!34	  !3404	,-		)R(	 	 K
	 	s   2D
A/DD$)py)rm   rL  rM  r   r   r   r   r   listTensorrc  re  SchedulerNodeListr(   r)   rP  rS   rh  rs  ry  r|  r   r  r  floatr  r3   r4   r5   rH  rH  >  s     <HH  < U\\"< 
	<<<HH  < U\\"< 
	<,#4 , ,,$5 ,$ , * s  
#4 
 

HH  
 !
 
	
"IC IC I4 ITT "))_T ne+,	T
 T !T #T\T 
Tr4   rH  c                     t         j                  t        j                        r)t         j	                  dt
        j                  |              t        j                  j                  |        y )NzBEFORE FUSION
%s)
ir_pre_fusion_logisEnabledForr   r'  inforH  rh  r$   r   r(   rC   s    r5   log_ir_pre_fusionr    sB    %%gll32N4L4LU4STGG% r4   c                     t         j                  t        j                        r)t         j	                  dt
        j                  |              t        j                  j                  |        y )NzAFTER FUSION
%s)
ir_post_fusion_logr  r   r'  r  rH  rh  r$   r   r)   r  s    r5   log_ir_post_fusionr    sB    &&w||4 2N4L4LU4STGG5!r4   schedulec                 x     	 t        dd  fd       y # t        $ r t        j                  dd       Y y w xY w)Nartifactc                      dddS )Ninductor_collective_scheduler  r+   r  r3   r3   r4   r5   <lambda>z+_dump_collective_schedule.<locals>.<lambda>  s    6"! r4   c                       S r}   r3   r  s   r5   r  z+_dump_collective_schedule.<locals>.<lambda>  s    x r4   metadata_fn
payload_fnzAFailed to log inductor_collective_schedule via structured loggingTrC  )r   rX   rK   r   r  s   `r5   _dump_collective_scheduler    sE    
 (	
  
		O 	 	

s     99c           
          | D cg c]6  }t        t        |dd       x}t        j                        rt        |dd       8 }}|rt	        |       y y c c}w )NrV   python_kernel_name)rP   rG  r   _CollectiveKernelr  )rC   rV   opr  s       r5   log_collective_scheduler    s`     GD&$77b9M9MN 	($/H  !(+ s   ;Anode_runtimesc           	      h   	 t         j                  j                  j                  dt        t
           dz  dt        t
           ffd}dt
        dt        dz  fd}g | D ]  \  }}t        |j                  d|j                               }t        j                  |j                        rdnd	}g }	 |j                         D ]  }|j                  }	|	j                         }
t        |	j                   t"        j$                        r|	j'                         nd}|	j)                         }|j+                   ||
       ||       ||      d
        	 j+                  ||||d       	 t/        dd fd       y# t,        $ r Y 7w xY w# t,        $ r t0        j3                  dd       Y yw xY w)zDLog per-op runtime estimates and output tensor metadata for TLParse.r   Nr/   c                 .    | t         |             S g S r}   )r  )r   to_optimization_hintss    r5   to_listz,log_runtime_and_tensor_meta.<locals>.to_list  s    56]4-a01JJr4   r[   c                 D    | y t        |       }|j                  d      }|S )Nztorch.)rS   removeprefix)r[   ss     r5   dtype_to_strz1log_runtime_and_tensor_meta.<locals>.dtype_to_str   s&    }E
Ax(AHr4   r  
collectivert   )shaper  r[   )r+   rp   estimated_runtime_nsr   r  c                      dddS )N inductor_runtime_and_tensor_metar  r  r3   r3   r4   r5   r  z-log_runtime_and_tensor_meta.<locals>.<lambda>M  s    :"! r4   c                      d iS )Nopsr3   )r  s   r5   r  z-log_runtime_and_tensor_meta.<locals>.<lambda>Q  s    s| r4   r  z.Failed to log inductor_runtime_and_tensor_metaTrC  )r$   r]   r  r  r   r   r  rS   rG  rV   r   r   is_collectiverU   rW   rP   r  r   Layoutr  maybe_get_dtyper   rX   r   rK   r   )r  r  r  r  
runtime_nsr+   op_typer   r   irnoder  r  r[   r  r  s                @@r5   log_runtime_and_tensor_metar    s   :S ! 0 0 C C	Kx}t+ 	KS	 	K	 	d
 	 %'* !	MAz166#7FD&+&9&9!&&&AlyG -/G==? C XXF"113E &fmmRYY? ))+! 
 #224ENN%,U^&-fo%1%%8& JJ #,6&	5!	F 	 ,	
  (  S		BT	RSs7   B/F 4BE?,F ?	FF 
FF  F10F1c                      t         sy	 t        dd d        y# t        $ r t        j	                  dd       Y yw xY w)	z:Emit a structured artifact with the graph execution order.Nr  c                      dddS )Ngraph_executionr  r  r3   r3   r4   r5   r  z%log_graph_execution.<locals>.<lambda>^  s    )"! r4   c                      dt         iS )Ngraph_execution_order)r%   r3   r4   r5   r  z%log_graph_execution.<locals>.<lambda>b  s     79NO r4   r  zFailed to log graph_executionTrC  )r%   r   rX   rK   r   r3   r4   r5   log_graph_executionr  W  sH     
B P	
  B		1D	ABs     ==c               #   l   K   g a i ada	 d t                dada day# t                dada daw xY ww)z5Record graph execution order and log it once on exit.TNF)r%   r'   r&   r  r3   r4   r5   $record_and_log_graph_execution_orderr  h  sU      !!!& $  	!& $ s   4 414c                   6    e Zd ZU eed<   ej                  ed<   y)TensorMetadataHoldertensor_metadatarx   N)rm   rL  rM  r   __annotations__r   rx   r3   r4   r5   r  r  x  s    ##LLr4   r  c                   ^    e Zd ZU eed<   eed<   eez  ez  dz  ed<   e	eeez  ez  f   ed<   y)SymExprMetadataHolderpytypeexprNhintsymbol_hints)
rm   rL  rM  rS   r  r   rR   r  r   r  r3   r4   r5   r  r  ~  s9    K
I
+
t
##sC%K$..//r4   r  pre_grad_graph_idpost_to_pre_grad_nodes_jsonc           	         i i d}t        |t              st        j                  d       |S t        | t              s|S t        j                  t              }t        j                  t              }	 dt        t        t        f   dt        fd}|j                         D ]<  \  }}t        |t              st        j                  d       |c S |D ]  } ||      s|c c S |j                  d      | k(  r.||d      j                  |       ||   j                  |d          |j                  d	g       D 	cg c]  }	|	|f }
}	|
sx|
j                         \  } ||      s|c c S |j                  d      | k(  r.||d      j                         |   j                  |d          |
j!                  fd
|j                  d	g       D               |
r
 ? dt        t        t        f   ddfd} ||        ||       ||dS c c}	w # t"        $ rd}t%        dddt        |      t'        j(                         d       t        j                  d|       t        j                  d|        |cY d}~S d}~ww xY w)zx
    Create bidirectional mappings between pre_grad graph nodes
    and post_grad graph code nodes, and vice versa.
    )	preToPost	postToPrezCProvenance tacking error: post_to_pre_grad_nodes_json is not a dictrV   r/   c                     t        | t              st        j                  d       yd| vsd| vsd| vrt        j                  d       yy)NzVProvenance tacking error: node provenance in post_to_pre_grad_nodes_json is not a dictFgraph_idr+   	from_nodezYProvenance tacking error: node provenance in post_to_pre_grad_nodes_json has wrong formatT)rP   r  rK   error)rV   s    r5   check_formatz8create_mapping_pre_post_grad_nodes.<locals>.check_format  sN    dD)		l %t);{RV?V		o r4   zIProvenance tacking error: post_to_pre_grad_nodes_json value is not a listr  r+   r  c              3   &   K   | ]  }|f 
 y wr}   r3   )r~   r   
parent_keys     r5   r   z5create_mapping_pre_post_grad_nodes.<locals>.<genexpr>  s      !,-J!s   dNc                 J    | D ]  }t        | |         | |<    t        |       } y r}   r  r  r  keys     r5   convert_sets_to_listszAcreate_mapping_pre_post_grad_nodes.<locals>.convert_sets_to_lists  +     &af#&QAr4   rX  provenance_tracking_error"create_mapping_pre_post_grad_nodesfunction	error_msgstack_tracez post_to_pre_grad_nodes_json:  %szpre_grad_graph_id:  %s)rP   r  rK   r  rR   r   defaultdictr   rS   r   r   r   r  r   r   popextendrX   r   	traceback
format_exc)r  r  empty_returnpre_to_postpost_to_prer   	outer_key
node_arrayrV   r   r   current_noder  er  s                 @r5   r  r    s    5L
 148		WX'- "-"9"9*"EK"-"9"9*"EKD	tCH~ 	$ 	 &A%F%F%H 	!Izj$/		_ $#" #D)''88J'+<<V-11)<	*..tF|< 26+r1JKA!YKK/4yy{,L*'5++#''
37HH#L$89==jI#J/33L4HILL !1=1A1A+r1R!  	6	T#s(^ 	 	 	k*k*$$
 	
) L0   	'@ V(335	
 			46QR		*,=>sR   3AH H $AH :HH 
 H +A.H 3H H 	J AI;5J ;J triton_kernel_to_post_grad_jsonc           	      F   i i d}t        | t              st        j                  d       |S t	        j
                  t              }	 | j                         D ]I  \  }}t        |t              st        j                  d       |c S |D ]  }||   j                  |        K dt        t        t        f   ddfd} ||       | |dS # t        $ rN}t        dd	d
t        |      t        j                         d       t        j                  d|        |cY d}~S d}~ww xY w)zqCreate bidirectional mappings between triton kernel name and post_grad
    graph code nodes, and vice versa.
    )cppCodeToPostpostToCppCodezGProvenance tacking error: triton_kernel_to_post_grad_json is not a dictzMProvenance tacking error: triton_kernel_to_post_grad_json value is not a listr  r/   Nc                 J    | D ]  }t        | |         | |<    t        |       } y r}   r  r  s     r5   r  zFcreate_node_mapping_kernel_to_post_grad.<locals>.convert_sets_to_lists	  r	  r4   rX  r
  "create_mapping_kernel_to_post_gradr  z$triton_kernel_to_post_grad_json:  %s)rP   r  rK   r  r   r  r   r   r  r   rS   r   rX   r   r  r  )r  r  post_to_cpp_coder  r  	curr_noder  r  s           r5   'create_node_mapping_kernel_to_post_gradr$    s:    /L
 5t<		U	
 '2'>'>z'J$%D%J%J%L 	;!Izj$/		c $#' ;	 +//	:;	;	T#s(^ 	 	 	./<-
 	
   	'@ V(335	
 			24S	
 s&   >C	 AC	 		D ADD D c            	         	 i } t         rrt        t              }i t        |} t        j
                  j                  r?t        j                  j                  dd      5 }t        j                  | |       d d d        d| d<   | S # 1 sw Y   xY w# t        $ r8}t        dddt        |      t        j                          d       i cY d }~S d }~ww xY w)	Nz/inductor_provenance_tracking_node_mappings.jsonrK  g       @versionrX  r
  dump_inductor_provenance_infor  )r   r$  r   r   r   r_   r#  r$   r   r  r  r  rX   r   rS   r  r  )node_mappingnode_mapping_kernelr-  r  s       r5   r'  r'  &  s    " (*"I>#2%L ||##WW]]Es 0IIlB/0 #&Y0 0   	'; V(335	
 	s6   AB B4B BB 	C-CCCc            	          	 t         j                  di       } t        t        j	                               t        t
        j	                               z  }i }|D ]p  }t
        j                  |g       }t               }|D ]#  }|j                  | j                  |g              % t        j                  |g       |t        |      d||<   r |S # t        $ r8}t        dddt        |      t        j                         d       i cY d}~S d}~ww xY w)zCreate kernel information JSONr  )stack_tracespost_grad_nodespre_grad_nodesrX  r
  create_kernel_information_jsonr  N)r   r   r   r   keysr   r  r  rX   r   rS   r  r  )r  all_kernelsresultkernel_namer,  r-  	post_noder  s           r5   r.  r.  L  s   %
 7::;K !=!B!B!DE
:??AI
 
 & 	KLPPRO /9lN, F	%%kooi&DEF != @ @b Q#2"&~"6#F;	  
'< V(335	
 	
s   C	C 	D-DDDnode_scheduler2  r   c           	        
 t         j                  j                  dk(  ry	 ddlm}m} t        dz  ag }| dt         }|rt        | t              sJ t        j                  |g       
| j                  r,| j                  j                  }|
vr6
j                  |       n$
j                  
fd| j                  D               t!        | j#                               }nt        | t               sJ t%               }| D ]  }|||fvs
|j&                  t        j                  |g       
|j)                  |j&                  j#                                
j                  
fd|j&                  j                  D                t!        |      }t*        j                  |g       j                  |       t        S # t,        $ r6}	t/        dd	d
t1        |	      t3        j4                         d       Y d}	~	yd}	~	ww xY w)z
    Set the mapping between `kernel_name` and the post_grad nodes in `node_schedule`.

    Returns a unique int debug handler for each call to this function.
    r   Nr   )DisableReductionEnableReduction:c              3   R   K   | ]  }|j                   vr|j                      y wr}   r+   r~   r   curr_node_infos     r5   r   z:set_kernel_post_grad_provenance_tracing.<locals>.<genexpr>  s)      &{{.8 KK&   $'c              3   R   K   | ]  }|j                   vr|j                      y wr}   r:  r;  s     r5   r   z:set_kernel_post_grad_provenance_tracing.<locals>.<genexpr>  s+      . !'%{{.@ #KK.r=  rX  r
  'set_kernel_post_grad_provenance_tracingr  )r   r_   provenance_tracking_levelcodegen.simd_kernel_featuresr6  r7  r   rP   r   r   
setdefaultorigin_noder+   r   r  r   r  get_stack_tracesr   rV   r  r   rX   r   rS   r  r  )r4  r2  r   r6  r7  r+  origin_node_namestack_traces_setrT   r  r<  s             @r5   r?  r?  v  s    ||--2?S 	1A50"$$Q'O&PQm\:::KVVRN ((#0#<#<#A#A #>9"))*:;%% &"/"7"7& 
   > > @ALmT2220:& 2B CCzz-JUU +R ' )//

0K0K0MN&-- . +0***<*<.     01L$//R@GGU77  	'E V(335	
 s%   C%F9 F9 B$F9 9	G8,G33G8ri   rz   c                    	
 t         j                  j                  t        j                         d      }t         j                  j                  |      st        j                  |       dt        dt        t        z  t        z  dz  fddt        dt        dt        ffd	dt        dt        f	
fd	
t        
| |f      \  }}d
}| d| dt        t               d}t!        |d      5 }t#        j$                  ||f|       ddd       t&        j)                  t*        j,                        rd| d|d}t/        |       yy# 1 sw Y   BxY w)z
    This function is used to save arguments for a compile_fx_inner function call
    to the file system.  Later on one can replay the compile_fx_inner call
    with the saved arguments using load_args_and_run_compile_fx_inner.
    inductor_saved_argsvaluer/   Nc                     | y t        | t              r| S t        | t        t        f      r| S t	        | dd       du rt        |       S 	 t        |       S # t
        t        f$ r t        |       cY S w xY w)N
is_integerF)rP   r   rR   r  rG  	TypeError
ValueError)rI  s    r5   python_valuez4save_args_for_compile_fx_inner.<locals>.python_value  st    =eT"Lec5\*L5,-6<	 u::& 	 <	 s   	
A A10A1r   r  c                 0   | j                   }|j                  }i }|R|j                  j                  D ]9  }|j                  j                  |      }|! |      }|,||t        |      <   ; t        ||j                   |j                        |      S r}   )	rV   	shape_envr  free_symbolsbacked_var_to_valr   rS   r  r  )	r   r  rV   rP  r  symbolr  python_hintrN  s	           r5   handle_sym_exprz7save_args_for_compile_fx_inner.<locals>.handle_sym_expr  s    vvNN	68 ))00 @ 2266v>#".t"4K".4?S[1@ %II#	
 	
r4   c                    t        | t              rMt        j                  |       }|j                  j
                  D ]  }t        |j                        |_         |S t        | t        j                        r)t        t        t        |             | j                        S t        | t        j                        r	 | d      S t        | t        j                        r	 | d      S t        | t        j                        r	 | d      S | S )a  
        Pickle FakeTensor/SymInt will result in errors like:
        AttributeError: Can't pickle local object 'WeakValueDictionary.__init__.<locals>.remove'

        Convert tensors and symbolic values to metadata. This may also make
        pickle faster.
        rR   r  r   )rP   r   r   deepcopyr]   rC   r   rN   r   r  r  r   rx   SymIntSymFloatSymBool)r   rc   rV   rU  handle_tensors      r5   r[  z5save_args_for_compile_fx_inner.<locals>.handle_tensor  s     a%q!B ?$]DII>	?Ia&'(@(CDahh  5<<("1e,,5>>*"1g..5==)"1f--Hr4   compile_fx_inner/r@   z.pklwbz3
Arguments for a compile_fx_inner call is saved to z. To replay the call,
run the following:

from torch._inductor.debug import load_args_and_run_compile_fx_inner
load_args_and_run_compile_fx_inner(z
)
        )r:   r;   r   tempfile
gettempdirr  mkdirr   rR   r  r   rS   r  r   nextsave_args_cntr  pickler  rK   r  r   r   r\   )ri   rz   folderargs_to_savekwargs_to_savefn_namer;   r  messagerU  r[  rN  s            @@@r5   save_args_for_compile_fx_innerrj    s@    WW\\(--/1FGF77>>&!
 C  C%K$$6$=  
3 
 
0E 
$  4 $,MD&>#J L. GXQwiqm!4 5T:D	dD	 7Q\>2A67 &337& 9$ %)8 ,	 	g '7 7s   -EEr;   c                   	
 ddl m ddlm} ddlmm} t        | d      5 }t        j                  |      \  }}d d d         |       i dt        dt        ffd
dt        dt        f	
fd		t        j                  j                  d
      }|5  t        j                   dd      5  t#        	f      \  }} ||i |cd d d        cd d d        S # 1 sw Y   xY w# 1 sw Y   nxY wd d d        y # 1 sw Y   y xY w)Nr   )ConstantSource)r\  )
DimDynamicShapeEnvrbr   r/   c                 `   | j                   }t        |t              r-dd l}dd lmc mc m} |j                  ||j                        }i }|j                  D ]  }t        |      }|vr| j                  j                  |      }|U| j                  ||k(  r| j                  }n7
j                   |            j                  j                   |<   |   ||<   
j!                  | |      	j"                  d      |<   |   ||<    |j%                  |      }| j&                  dk(  r
j)                  || j                        S | j&                  dk(  r
j+                  || j                        S | j&                  dk(  r
j-                  |      S t/        d	| j&                         )
Nr   )localsT)dynamic_dimdo_not_specialize_zero_onerR   )r  r  r   z%Unexpected symbolic expression type: )r  rP   rS   sympytorch.utils._sympy.functionsr   _sympy	functionssympify__dict__rQ  r  r   r  create_unbacked_symintrV   create_symbolDYNAMICxreplacer  create_symintnodecreate_symfloatnodecreate_symboolnodeAssertionError)r   r  rt  sympy_functionsreplacementsrS  symbol_namer  rl  rm  rP  symbol_caches           r5   restore_sym_exprz<load_args_and_run_compile_fx_inner.<locals>.restore_sym_expr.  s   vvdC BB==o.F.F=GD'' 	=Ff+K,.~~))+6<vv)dfn vv4=4T4T*;75$tt %[1 0<K/HV, ,5,C,C";/ * 2 2/3	 -D -[) $0#<L '	=( }}\*88u..t!&&.AAXX 00AFF0CCXX//55 #H
!STTr4   c                    t        | t              r8| j                  j                  D ]  }t	        |j
                        |_         | S t        | t              rjt	        | j                        }t        j                  j                  j                  |j                  |j                  |j                  | j                        S t        | t               r |       S | S r}   )rP   r   r]   rC   r   rN   r  r  r   _dynamotestingrand_stridedr  r  r[   rx   r  )r   rV   r  r[  r  s      r5   r[  z9load_args_and_run_compile_fx_inner.<locals>.handle_tensorU  s    a% ?$]DII>	?H/0&}a6G6GHO==((55%%&&%%	  01#A&&Hr4   T)allow_non_fake_inputsrP  	save_argsF)torch._dynamo.sourcerl  torch._inductor.compile_fxr\  %torch.fx.experimental.symbolic_shapesrm  rn  r  rd  loadr  r   r   r^  FakeTensorModer   r   r   )r;   r\  rn  r  ri   rz   	fake_moderl  rm  r[  r  rP  r  s          @@@@@@r5   "load_args_and_run_compile_fx_innerr  #  s   3;J	dD	 &Q{{1~f& 
I#%L%U1 %Uc %U %UN  $ !!00"i 1 I 
 1FLLe4 1f~>f001 1 1E& &D1 1 1 1 1s/   CD 3C+	D C(+C4	0D  D	)package_pathfunc.exported_programinductor_configsr  c                   ddl m} ddlm} ddlm} ddlm} |j                  j                  }|j                  d      }	t        |	t        j                  j                        sJ |j                  \  }
}	 |r$|j                  j                   dk(  r ||d	|
       |r|j                  j                   dk(  rt#        j$                  |	      }t#        j$                  |j                        }t#        j$                  |      } |||d   |d   |
      \  }}t'        |      }t        j(                  j)                  ||d      } | |j                  d      |||dd        | |	|
||||      S # |$ r(} ||dd|       t*        j-                  d       |d }~wt.        $ r2}|r)d}|j                  j                   dk(  rd} ||d	||       |d }~ww xY w)Nr   )AccuracyError)dump_to_minifyr   )_aoti_flatten_inputsF)check_guards   aot_inductor)options   r   )strictTaccuracy)r  r  load_and_runcheck_accuracy)r  r  r  aot_inductor_accuracyminify)commandr  zAccuracy failedrun)torch._dynamo.debug_utilsr  torch._dynamo.repro.aotir  torch._inductorr   r  r  r  dump_aoti_minifiermodulerP   r   r   r   example_inputsrepro_levelr   rW  rQ   exportrK   rL   rX   )r  r  r  r  r  r  r   r  use_minifierrc   ri   rz   gm_copyexample_inputs_copyconfig_copyflat_example_inputstuple_inputsflattened_epr  r  s                       r5   aot_inductor_minifier_wrapperr  o  s    87&?&&99L		 	 e	 	4Bb%((..///#22LD&>F//;;q@ (
 F//;;q@ mmB'G"&--0@0O0O"P--(89K/C#A&#A&#	0, !!45L <<..wU.SL###7!,)!) -%%
 	
  #$		
 	%& G""..!3 (	 s%   7C7E/ /G4#FG#-GG)FNrk   rJ  )F)r   r   r   dataclasses	functoolsrm  rN  r  r   r:   os.pathrd  r<  r1   r_  r  collections.abcr   r   r   typingr   r   unittest.mockr   r   functorch.compiler	   r
   r   r   torch._dynamo.repro.after_aotr   torch._dynamo.utilsr   torch._functorchr   r>   r  r   torch._loggingr   torch._logging._internalr   torch._utils_internalr   torch.fx.graph_moduler   torch.fx.passes.shape_propr   r   torch.fx.passes.tools_commonr   torch.typesr   torch.utils._ordered_setr   torch.utils._pytreer   r  r   r   	schedulerr   r    r!   r"   r#   virtualizedr$   r   rm   rK   r%   r  r  rS   objectr  r&   r   r'   rR   r  r  r  r   r*   rx  rJ   cacher6   rB   rd   r   rM   r   r   r   rQ  r   r   r   r   r   r   r   r   r   r   rH  r  r  r  r  rQ   r  r  r  r  	dataclassr  r  rO  rc  r  r$  r'  r.  r?  rj  r  r  ExportedProgramr  r3   r4   r5   <module>r     s        	    	       8 8    V V  : - 7 ! , 5 0 - O 7   / (     g! 9= tDf-.5 <$  $26 4S4Z(4/ 6%h@ &x1AB I 
 +
 
 VZ,@
AT #UEN3  + + +7C$J 73 7 7!"77 :7 
	7t`$'8"9 `bhh `L #'	!t#!S>! 4Z! 	!
 
!H!S>!	#w,!$III 
I" %HTN % %V EG  $sDd3i,@'@"A FGI .S$s)^0D I!% C$J %68 #T#s(^ 857 d3S	>2 701 (# 11
 /
(4. /
 /
d] ]@k k\!. !4 !"/ "D "
S4Z(8 
T 
"	,8,=#> 	,4 	,=Sxc5j8I/J =St =S@B" !htn ! !   
 0 0 0  	!^Tz^!%c3h^ 
#tCcN#
#$^B9%)#s(^9	#tCH~
9x#tCH~ #L'S$sDI~2F-F(G 'Z M-.=MM M 	4Z	M`Z# Z Z ZzI1S I1S I1b %)Q
38
Qll22Q 38n	Q
 T/Q 	Qr4   