+
    –°³j¡`  ã                   ó\  € ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RI	t	^ RI
Hu Ht ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHtHtHt ^ R	IH t  ^ R
I!H"t" ^ RI#H$t$ ^ RI%H&t& ]PN                  ! ](4      t)R R lt* ! R R]PV                  4      t, ! R R]4      t-R# )é    N)ÚCallable©ÚAny)Úcounters)Úir)ÚSubgraphCPUBenchmarkRequestÚSubgraphGPUBenchmarkRequestÚ
TensorMeta)ÚKernelTemplate)ÚBufferÚFixedLayoutÚget_free_symbolsÚget_symbolic_inputsÚgm_original_output_stridesÚir_node_to_tensorÚLayout)Úbenchmarker)Údo_bench_using_profiling©ÚV)Ú
OrderedSetc                ó†   € V ^8„  d   QhR\         P                  P                  R\        \        ,          R\
        R\        /# )é   ÚgmÚinputsÚnameÚreturn)ÚtorchÚfxÚGraphModuleÚlistr   Ústr)Úformats   "Úa/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_inductor/codegen/subgraph.pyÚ__annotate__r%   &   s:   € ÷ )ñ )Ü�‰×Ñð)Ü&*¬3¥ið)Ü7:ð)äñ)ó    c                óÜ   € ^ RI Hp \        P                  P                  p V \        P                  n        V! W4      V\        P                  n        #   T\        P                  n        i ; i)a  Inline a subgraph by converting its FX operations to individual IR nodes.

This converts a subgraph to multiple ComputedBuffer nodes (fusable),
enabling epilogue fusion with subsequent operations.

Returns:
    TensorBox containing the final operation result as individual IR nodes
)Úprocess_subgraph_nodes)Útorch._inductor.loweringr(   r   ÚgraphÚmodule)r   r   r   r(   Úoriginal_modules   &&&  r$   Úinline_subgraph_to_ir_nodesr-   &   sF   € õ @ô —g‘g—n‘n€Oð)ØŒ�‰ŒÙ% bÓ1à(Œ�‰�ø˜Œ�‰�ús   ¢A ÁA+c                   ó:  a a€ ] tR t^<t oRtRV3R lV 3R llltV3R lR ltV3R lR ltV3R lR	 ltV3R
 lR lt	V3R lR lt
]V3R lR l4       tV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltRtVtV ;t# ) ÚSubgraphChoiceCallerz–
Represents a Subgraph Autotuning choice, and the subgraph can be any arbitrary
GraphModule. Compiles the Subgraph down to a module for benchmarking.
c                ó¶   <€ V ^8„  d   QhRS[ RS[S[,          RS[RS[ RS[RS[3,          RS[S[S[S[.S[P                  3,          3,          R,          R	R/# )
r   r   Úinput_nodesÚlayoutÚdescriptionÚmake_fx_graph.Úinput_gen_fnsNr   )
r"   r!   r   r   r   r   ÚdictÚintr   ÚTensor)r#   Ú__classdict__s   "€r$   r%   Ú!SubgraphChoiceCaller.__annotate__B   s†   ø€ ÷ B?ñ B?áðB?ñ ™&•\ðB?ñ ð	B?ñ
 ðB?ñ   ¡S Õ)ðB?ñ ™C¡©3¨%±·±Ð*=Õ!>Ð>Õ?À$ÕFðB?ð 
ñB?r&   c           
     ó¦  <€ \         S
V `  WW44       . p. V n        \        P                  ;_uu_ 4        \        V P                  4       Fú  w  r‰\        \        V	P                  4       R R7      4      ^ 8w  d   \        R4      h\        \        V	P                  4       R R7      4      ^ 8w  d   \        R4      hV	P                  P                  4        VP                  \        V	4      4       Ve0   W†9   d*   V P                  P                  Wh,          ! V	4      4       KÔ  V P                  P                  \        V	R R7      4       Kü  	  RRR4       V! V!  V n        \#        V P                   4       Wpn        \'        V P                  4      V n        V P+                  4       V n        RV n        / V n        / V n        RV n        RV n        \8        P:                  '       dN   \        P                  ;_uu_ 4        V P=                  4       V n        V P?                  4       V n        RRR4       R# R#   + '       g   i     Lí; i  + '       g   i     R# ; i)T)Úunbacked_onlyz*expected no unbacked symbols in input sizez,expected no unbacked symbols in input strideN)Úreplace_symbols_with_hints) ÚsuperÚ__init__Úbenchmark_inputsr   Ú	fake_modeÚ	enumerater1   Úlenr   Úget_sizeÚAssertionErrorÚ
get_strideÚdataÚfreeze_layoutÚappendr   r   r   Úexample_inputsr   Ú
sym_inputsÚ_compute_sym_input_valuesÚsym_input_valuesÚdecompositionÚdecomposition_kwargsÚconfig_patchesÚ_compiled_moduleÚ_bmreqÚconfigÚpipeline_max_autotune_gemmÚ_compile_for_benchmarkingÚ_create_benchmark_request)Úselfr   r1   r2   r3   r4   r5   Útrace_inputsÚiÚinpÚ	__class__s   &&&&&&&   €r$   r?   ÚSubgraphChoiceCaller.__init__B   sÏ  ø€ ô 	‰Ñ˜¨FÔ@ð ˆØ "ˆÔÜ�[�[‹[Ü# D×$4Ñ$4Ö5‘�äÔ'¨¯©«ÀdÔKÓLÐPQÔQÜ(Ð)UÓVÐVÜÔ'¨¯©Ó(8ÈÔMÓNÐRSÔSÜ(Ð)WÓXÐXà—‘×&Ñ&Ô(ð ×#Ñ#Ô$5°cÓ$:Ô;ð !Ò,°Ô1CØ×)Ñ)×0Ñ0°Ö1AÀ#Ó1FÖGà×)Ñ)×0Ñ0Ü)¨#È$ÔOöñ! 6÷ ñ,   Ñ.ˆŒÜ" 4§7¡7Ô+à*Ôä-¨d×.>Ñ.>Ó?ˆŒØ $× >Ñ >Ó @ˆÔð 9=ˆÔØ46ˆÔ!à.0ˆÔà%)ˆÔð ð 	Œô ×,×,Ð,Ü——“Ø(,×(FÑ(FÓ(H�Ô%Ø"×<Ñ<Ó>�”÷ ‘ñ -÷Y �[ú÷Z —�ús   ³DH,Ç5+H?È,H<	È?I	c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r   r   )r!   r7   )r#   r9   s   "€r$   r%   r:   †   s   ø€ ÷ ñ ©4±­9ñ r&   c           	     ó¾  € \        V P                   Uu. uF#  p\        VR4      '       g   K  VP                  NK%  	  up4      p/ p\	        V P
                  V P                  4       F¶  w  rE\        V\        P                  4      '       g   K'  \	        VP                  4       VP                  4       Fg  w  rg\        V\        P                  4      '       d   \        V4      W6P                  &   K>  \        V4      V9   g   KP  \        V4      V\        V4      &   Ki  	  K¸  	  . pV P                   F¦  p	\        V	\        P                  4      '       d5   V	P                  V9   d$   VP!                  W9P                  ,          4       KW  \"        P$                  P&                  P(                  P+                  V	^R7      p
VP!                  \        V
4      4       K¨  	  V# u upi )a	  Extract concrete dimension values for sym_inputs from benchmark_inputs.

The compiled module expects symbolic dimension values as runtime arguments.
This maps each symbolic variable to its concrete value from the benchmark tensors.
Used for range based autotuning.
r   )Úfallback)r   rK   Úhasattrr   Úzipr1   r@   Ú
isinstancer   r8   rD   ÚshapeÚsympyÚSymbolr7   r"   rI   r   r*   ÚsizevarsÚ	shape_envÚoptimization_hint)rW   ÚsÚsym_input_namesÚsym_name_to_valueÚinp_nodeÚbenchmark_inpÚsym_dimÚ
actual_dimÚresultÚsym_varÚhints   &          r$   rL   Ú.SubgraphChoiceCaller._compute_sym_input_values†   s_  € ô %Ø!Ÿ_š_ÓC™_˜´¸¸6×0BŒVˆQ�VŒV™_ÑCó
ˆð
 -/ÐÜ'*¨4×+;Ñ+;¸T×=RÑ=RÖ'SÑ#ˆHÜ˜-¬¯©×6Ô6Ü+.Ø×%Ñ%Ó'¨×)<Ñ)<ö,Ñ'�Gô " '¬5¯<©<×8Ò8Ü:=¸j»/Ð)¯,©,Ó7Ü˜W›¨Ö8Ü:=¸j»/Ð)¬#¨g«,Ó7ó,ñ (Tð ˆØ—”ˆGÜ˜'¤5§<¡<×0Ò0°W·\±\ÐEVÔ5VØ—‘Ð/·±Õ=Ö>ä—w‘w×'Ñ'×1Ñ1×CÑCÀGÐVWÐCÓX�Ø—‘œc $›iÖ(ñ 'ð ˆùò- Ds
   ”G­Gc                óT   <€ V ^8„  d   QhRS[ RS[3,          RS[S[S[3,          RR/# )r   rN   .Úkwargsr   N©r   r   r6   r"   )r#   r9   s   "€r$   r%   r:   ¦   s6   ø€ ÷ +ñ +Ù% c©3 hÕ/ð+Ù9=¹cÁ3¸h½ð+à	ñ+r&   c                ó   € Wn         W n        R# )zHCache decomposition function and kwargs for range-based dispatch lookup.N)rN   rO   )rW   rN   rv   s   &&&r$   Úcache_decompositionÚ(SubgraphChoiceCaller.cache_decomposition¦   s   € ð +ÔØ$*Ö!r&   c                ó    <€ V ^8„  d   QhRS[ /# r^   ©r"   )r#   r9   s   "€r$   r%   r:   ­   s   ø€ ÷ .ñ .™ñ .r&   c                ó"   € R V P                    R2# )zSubgraphCaller(Ú)©r   ©rW   s   &r$   Ú__str__ÚSubgraphChoiceCaller.__str__­   s   € Ø  §¡ ¨1Ð-Ð-r&   c                ó    <€ V ^8„  d   QhRS[ /# r^   r   )r#   r9   s   "€r$   r%   r:   °   s   ø€ ÷ -=ñ -=©3ñ -=r&   c                ó¶  € ^ RI Hp V P                  P                  RR4      P                  RR4      pV P                  '       d   V P
                  MV P                  p\        P                  RV P                  V P                  4       V P                  f   \        R4      hV! V P                  V\        P                  P                  \        P                  P                  \        P                  P                  \        P                  P                   \        P                  P"                  \        P                  P$                  RV 2R	7	      pV P                   F@  pWTP&                  VP                  &   VP(                  P+                  VP                  4       KB  	  \        P,                  ! V4      ;_uu_ 4        R
RRRRRRRRR/V P.                  Cp\0        P2                  ! V4      ;_uu_ 4        VP4                  ! V!   VP7                  4       uuRRR4       uuRRR4       #   + '       g   i     M; i RRR4       R#   + '       g   i     R# ; i)zCCompile the subgraph for benchmarking, returns the compiled module.)ÚGraphLoweringz::Ú_Ú.z#Benchmark compile %s: sym_inputs=%sNúexpected self.gm to be setÚ
benchmark_)	r   rJ   rh   Úcpp_wrapperÚaot_modeÚextern_node_serializerÚis_inferenceÚis_backwardr   Úmax_autotuneFÚmax_autotune_gemmÚmax_autotune_gemm_backendsÚATENÚbenchmark_fusionrT   )Útorch._inductor.graphr…   r   ÚreplacerK   rJ   r@   ÚlogÚdebugr   rE   r   r*   Ú
_shape_envrŠ   r‹   rŒ   r�   rŽ   Úgraph_inputsÚgraph_input_namesrI   Úset_graph_handlerrP   rS   ÚpatchÚrunÚcompile_to_module)rW   r…   Ú	safe_nameÚcompile_inputsÚbm_graph_loweringÚsym_inpÚbenchmark_configs   &      r$   rU   Ú.SubgraphChoiceCaller._compile_for_benchmarking°   s½  € å7à—I‘I×%Ñ% d¨CÓ0×8Ñ8¸¸cÓBˆ	ð $(§?§? ?ˆD×Ò¸×8MÑ8Mð 	ô 	�	‰	Ð7¸¿¹ÀDÇOÁOÔTà�7‰7Š?Ü Ð!=Ó>Ð>Ù)Ø�w‰wØ)Ü—g‘g×(Ñ(ÜŸ™×+Ñ+Ü—W‘W×%Ñ%Ü#$§7¡7×#AÑ#AÜŸ™×-Ñ-ÜŸ™×+Ñ+Ø˜i˜[Ð)ô

Ðð —”ˆGØ;B×*Ñ*¨7¯<©<Ñ8Ø×/Ñ/×6Ñ6°w·|±|ÖDñ 'ô × Ò Ð!2×3Õ3ð  Ø# UØ,¨fØ" EØ,¨eð0ð ×%Ñ%ð0Ðô —’Ð.×/Õ/Ø!×%Ò% ~Ò6Ø(×:Ñ:Ó<÷ 0Ñ/÷ 4Ò3÷ 0×/úÐ/÷ 4×3×3Ò3ús$   Æ=7IÇ4 H)	È
IÈ)H9È4IÉI	c                ó0   <€ V ^8„  d   QhRS[ S[,          /# r^   ©r	   r   )r#   r9   s   "€r$   r%   r:   ß   s   ø€ ÷ 
ñ 
á	$Ñ'BÕ	Bñ
r&   c           
     ó¾  € V P                   f   \        R4      h\        P                  ! V P                  4      p\        P                  ! V P
                  4      pV P
                  P                  P                  R8X  d   \        pM\        pV! V P                  VV\        4       V P                   P                  V P                   P                  V P                  R7      # )z0Create a benchmark request for async autotuning.z9Module must be compiled before creating benchmark requestÚcpu)Úkernel_nameÚinput_tensor_metaÚoutput_tensor_metaÚ
extra_argsÚmodule_pathÚmodule_cache_keyrM   )rQ   rE   r
   Úfrom_irnodesr1   r2   ÚdeviceÚtyper   r	   r   ÚtupleÚ__file__ÚkeyrM   )rW   rª   r«   Ú	bmreq_clss   &   r$   rV   Ú.SubgraphChoiceCaller._create_benchmark_requestß   s¶   € ð × Ñ Ò(Ü ØKóð ô '×3Ò3°D×4DÑ4DÓEÐÜ'×4Ò4°T·[±[ÓAÐà�;‰;×Ñ×"Ñ" eÔ+Ü3‰Iä3ˆIáØŸ	™	Ø/Ø1Ü“wØ×-Ñ-×6Ñ6Ø!×2Ñ2×6Ñ6Ø!×2Ñ2ô
ð 	
r&   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# r^   r¦   )r#   r9   s   "€r$   r%   r:   ú   s   ø€ ÷ ñ á	$Ñ'BÕ	Bñr&   c                óL   € V P                   f   \        R4      hV P                   # )z`Benchmark request for async autotuning. Pre-compiled when pipeline_max_autotune_gemm is enabled.zMbmreq accessed but pipeline_max_autotune_gemm was not enabled during __init__)rR   rE   r€   s   &r$   ÚbmreqÚSubgraphChoiceCaller.bmreqù   s*   € ð
 �;‰;ÒÜ Ø_óð ð �{‰{Ðr&   c                ó   <€ V ^8„  d   QhRR/# )r   r   N© )r#   r9   s   "€r$   r%   r:     s   ø€ ÷ Eñ E $ñ Er&   c                óP   € V P                   f   V P                  4       V n         R# R# )zKEnsure the module is compiled. Used for lazy compilation in non-async path.N)rQ   rU   r€   s   &r$   Ú_ensure_compiledÚ%SubgraphChoiceCaller._ensure_compiled  s$   € à× Ñ Ò(Ø$(×$BÑ$BÓ$DˆDÖ!ñ )r&   c                óP   <€ V ^8„  d   QhRS[ S[,          RS[P                  RS[/# )r   ÚargsÚoutr   )r!   r   r   r8   Úfloat)r#   r9   s   "€r$   r%   r:   	  s*   ø€ ÷ 
ñ 
™t¡C�yð 
©u¯|©|ð 
Áñ 
r&   c               ór  aaa€ V P                  4        V P                  P                  oV P                  oR VVV3R llpV P                  '       d   \
        P                  ! V4      # \        P                  '       d   \        V4      # \
        P                  ! V\
        P                  ! . SOSO5!  R7      # )z>Regular benchmarking: compile if needed, then use benchmarker.c                ó$   € V ^8„  d   QhR\         /# r^   r   )r#   s   "r$   r%   Ú4SubgraphChoiceCaller.benchmark.<locals>.__annotate__  s   € ÷ 	1ñ 	1”Cñ 	1r&   c                  ó   <€ S! . SOS O4      # ©Nr¼   )rÁ   Úbm_funcrK   s   €€€r$   ÚfnÚ*SubgraphChoiceCaller.benchmark.<locals>.fn  s   ø€ ÙÐ/˜ZÐ/¨$Ð/Ó0Ð0r&   )r°   )r¾   rQ   ÚcallrM   Ú_benchmark_with_cudagraphsr   Úbenchmark_gpu_with_cuda_graphrS   Ú/profile_bandwidth_with_do_bench_using_profilingr   Ú	benchmarkÚinfer_device)rW   rÂ   rÁ   rÊ   rÉ   rK   s   &$j @@r$   rÐ   ÚSubgraphChoiceCaller.benchmark	  s—   ú€ à×ÑÔØ×'Ñ'×,Ñ,ˆØ×*Ñ*ˆ
÷	1ò 	1ð ×*×*Ð*Ü×<Ò<¸RÓ@Ð@ä×A×AÐAÜ+¨BÓ/Ð/Ü×$Ò$ØÜ×+Ò+Ð?¨ZÐ?¸$Ó?ô
ð 	
r&   c                óN   <€ V ^8„  d   QhRS[ S[,          RS[P                  RR/# )r   rÁ   rÂ   r   N)r!   r   r   r8   )r#   r9   s   "€r$   r%   r:     s/   ø€ ÷ Dñ D©$©s­)ð D¹%¿,¹,ð DÈ4ñ Dr&   c               óx   € V P                  4        V P                  P                  . V P                  OVO4       R# )zFRun once for collective benchmarking (barrier sync handled by caller).N)r¾   rQ   rÌ   rM   )rW   rÂ   rÁ   s   &$*r$   Úbenchmark_collectiveÚ)SubgraphChoiceCaller.benchmark_collective  s3   € à×ÑÔØ×Ñ×"Ñ"Ð#B T×%:Ñ%:Ð#B¸TÐ#BÖCr&   c                ó    <€ V ^8„  d   QhRS[ /# r^   r|   )r#   r9   s   "€r$   r%   r:   !  s   ø€ ÷ 

ñ 

™#ñ 

r&   c           
     ó¸  € V P                   f   \        R4      hRP                  V P                  P	                  R^4      ^ ,          .V P
                   Uu. uF  p\        VP                  4       4      NK  	  upOV P
                   Uu. uF  p\        VP                  4       4      NK  	  upO\        V P                   P                  4      N4      # u upi u upi )Nrˆ   Ú-r†   )
r   rE   Újoinr   Úrsplitr1   r"   rD   rF   r*   )rW   rZ   s   & r$   Úhash_keyÚSubgraphChoiceCaller.hash_key!  s½   € Ø�7‰7Š?Ü Ð!=Ó>Ð>Ø�x‰xà—	‘	× Ñ   aÓ(¨Õ+ðà15×1AÒ1AÓBÑ1A¨#”#�c—l‘l“nÖ%Ñ1AÑBðð 48×3CÒ3CÓDÑ3C¨C”#�c—n‘nÓ&Ö'Ñ3CÑDðô �D—G‘G—M‘MÓ"ð	ó
ð 	
ùò CùÚDs   Á"C
Â	"C
c                ó4   <€ V ^8„  d   QhRS[ P                  /# r^   )r   Ú	TensorBox)r#   r9   s   "€r$   r%   r:   -  s   ø€ ÷ 
ñ 
™RŸ\™\ñ 
r&   c                óX  € V P                   f   \        R4      h\        P                  P	                  \        P
                  ! V P                  V P                  V P                   V P                  V P                  V P                  '       d   V P                  R7      4      # R R7      4      # )Nrˆ   )r2   r1   r   rJ   Úsubgraph_namerP   )r   rE   r   rß   ÚcreateÚSubgraphBufferr2   r1   rJ   r   rP   r€   s   &r$   Úoutput_nodeÚ SubgraphChoiceCaller.output_node-  s�   € Ø�7‰7Š?Ü Ð!=Ó>Ð>Ü�|‰|×"Ñ"Ü×ÒØ—{‘{Ø ×,Ñ,Ø—7‘7Ø#×2Ñ2Ø"Ÿi™iØ6:×6I×6IÐ6I˜t×2Ñ2ôó	
ð 		
ð PTôó	
ð 		
r&   c                ó6   <€ V ^8„  d   QhRS[ S[S[3,          /# r^   ©r6   r"   r   )r#   r9   s   "€r$   r%   r:   ;  s   ø€ ÷ 
ñ 
™4¡¡S �>ñ 
r&   c                ó"   € RRRV P                   /# )zRInformation returned here is logged to the autotune log file when that is enabled.ÚbackendÚsubgraphr©   r   r€   s   &r$   Ú	info_dictÚSubgraphChoiceCaller.info_dict;  s   € ð �zØ˜4Ÿ9™9ð
ð 	
r&   c                ó    <€ V ^8„  d   QhRS[ /# r^   r|   )r#   r9   s   "€r$   r%   r:   B  s   ø€ ÷ 'ñ '¡#ñ 'r&   c                ó    € R V P                    2# )Ú	subgraph_r   r€   s   &r$   Úautoheuristic_idÚ%SubgraphChoiceCaller.autoheuristic_idB  s   € Ø˜4Ÿ9™9˜+Ð&Ð&r&   )
rR   rQ   r@   rP   rN   rO   rJ   r   rM   rK   rÈ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r?   rL   ry   r�   rU   rV   Úpropertyr¹   r¾   rÐ   rÕ   rÜ   rä   rë   rð   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r[   r9   s   @@r$   r/   r/   <   s®   ù‡ € ñ÷
B?õ B?÷Hð ÷@+ð +÷.ð .÷-=ð -=÷^
ð 
ð4 ÷ó ð÷Eð E÷

ð 
÷&Dð D÷


ð 

÷
ð 
÷
ð 
÷'÷ 'ð 'r&   r/   c                   óÜ   a a€ ] tR tRt oRt]P                  ! 4       tV3R lV 3R lltRV3R lR llt	RV3R lR llt
V3R	 lR
 ltV3R lR ltV3R lR ltRV3R lR lltRtVtV ;t# )ÚSubgraphTemplateiF  zø
A template for subgraph evaluation to be used in autotuning.

This class allows creating customized subgraphs that can be appended
as choices during the autotuning process, enabling the selection of
optimal implementations for complex operations.
c                ó    <€ V ^8„  d   QhRS[ /# )r   r   r|   )r#   r9   s   "€r$   r%   ÚSubgraphTemplate.__annotate__Q  s   ø€ ÷ $ñ $áñ$r&   c                ó(   <€ \         SV `  VR7       R# )zd
Initialize a subgraph template.

Args:
    name: The name of this template
    graph: The FX graph
r   N)r>   r?   )rW   r   r[   s   &&€r$   r?   ÚSubgraphTemplate.__init__Q  s   ø€ ô 	‰Ñ˜dÐÖ#r&   c                ó¾   <€ V ^8„  d   QhRS[ RS[S[,          RS[RS[RS[3,          RS[ RS[S[S[S[.S[P                  3,          3,          R,          R	S[R
S[
/# )r   r   r1   r2   r4   .r3   r5   Nrv   r   )r"   r!   r   r   r   r   r6   r7   r   r8   r/   )r#   r9   s   "€r$   r%   rÿ   ^  s‡   ø€ ÷ !
ñ !
áð!
ñ ™&•\ð!
ñ ð	!
ñ
   ¡S Õ)ð!
ñ ð!
ñ ™C¡©3¨%±·±Ð*=Õ!>Ð>Õ?À$ÕFð!
ñ ð!
ñ 
ñ!
r&   c           	     ó\   € \        V R\        \        P                  4       2VVVVVR7      # )a!  
Generate a SubgraphChoiceCaller instance for autotuning.

Args:
    name: The name for this subgraph choice
    input_nodes: List of input nodes to the subgraph
    layout: Memory layout information for the output
    make_fx_graph: Callable that creates the FX graph for this subgraph
    description: Optional description of this choice
    input_gen_fns: Optional dict mapping input indices to tensor generators
    **kwargs: Additional keyword arguments

Returns:
    SubgraphChoiceCaller: A callable object that can be used for autotuning
r†   )r   r1   r2   r3   r4   r5   )r/   Únextrý   Úindex_counter)rW   r   r1   r2   r4   r3   r5   rv   s   &&&&&&&,r$   ÚgenerateÚSubgraphTemplate.generate^  s;   € ô4 $Ø�6˜œ4Ô 0× >Ñ >Ó?Ð@ÐAØ#ØØ#Ø'Ø'ô
ð 	
r&   c                óZ  <€ V ^8„  d   QhRS[ RS[S[RS[3,          ,          RS[S[,          RS[S[S[ S[3,          ,          RS[RS[3,          R,          RS[S[S[S[.S[P                  3,          3,          R,          R	S[S[S[ S[3,          ,          R,          R
S[S[	,          /# )r   r   Údecompositions.r1   Únon_tensor_argsÚdefault_implNr5   Úconfig_patches_listr   )
r"   r!   r   r   r   r6   r7   r   r8   r/   )r#   r9   s   "€r$   r%   rÿ   �  sÉ   ø€ ÷ sñ sáðsñ ™X c©3 hÕ/Õ0ðsñ ™&•\ð	sñ
 ™d¡3© 8�nÕ-ðsñ ˜s¡C˜xÕ(¨4Õ/ðsñ ™C¡©3¨%±·±Ð*=Õ!>Ð>Õ?À$ÕFðsñ "¡$¡s©C x¥.Õ1°DÕ8ðsñ 
Ñ"Õ	#ñsr&   c                ó   € V'       g   . # \        V4      \        V4      8w  d%   \        R\        V4       R\        V4       R24      hVf   V Uu. uF  p/ NK  	  pp\        W$4       U	U
u. uF  w  ršV P                  W9W¥V4      NK  	  pp	p
V P	                  WV4       V^ ,          p. p\        W$V4       F|  w  ržp^ RIHp RV	RV/R R llpV P                  Wž4      p V P                  V R	V 2VVVR
V	P                   2VR7      pTP                  Yž4       TTn        TP                  T4       K~  	  V# u upi u up
p	i   T dE    \        P                  RT	P                  4       \        R,          R;;,          ^,          uu&    K×  i ; i)a  
Generate multiple SubgraphChoiceCaller instances for custom op autotuning.

This method extends SubgraphTemplate to support custom op decompositions,
allowing multiple implementations to compete in autotuning.

Args:
    name: Base name for the choices
    decompositions: List of decomposition functions to compete in autotuning
    input_nodes: List of tensor inputs. All tensor arguments must be passed here.
    non_tensor_args: List of non-tensor kwargs only, one dict per corresponding decomposition.
    default_impl: Default implementation for layout inference
    input_gen_fns: Optional dict mapping input indices to tensor generators
    config_patches_list: Optional list of config patches per decomposition

Returns:
    List of SubgraphChoiceCaller instances for autotuning
z>decompositions and non_tensor_args must have same length, got z decompositions and z kwargs)Ú_ShapeEnvGuardErrorÚdecompÚdecomp_kwargsc                ó„   € V ^8„  d   QhR\         R\        R\         3,          R\        \        \         3,          R\         /# )r   rÁ   r  .r  r   )r   r   r6   r"   )r#   s   "r$   r%   ÚASubgraphTemplate.generate_custom_op_choices.<locals>.__annotate__¾  sA   € ÷ ñ Üðä  ¤c Õ*ðô  $¤C¬ H�~ðô ñ	r&   c           	      óH  € ^ RI Hp ^RIHp V! 4       p\        P
                  P                  pVe   VP                  4       M\        P                  ! 4       pV;_uu_ 4        V! \        P                  ! V 3/ VB VRR7      ! V!  uuRRR4       #   + '       g   i     R# ; i)r   )Úmake_fx)Úselect_decomp_tableNÚsymbolic)Údecomposition_tableÚtracing_mode)Ú"torch.fx.experimental.proxy_tensorr  rN   r  r   rA   rh   Úerror_on_new_guardsÚ
contextlibÚnullcontextÚ	functoolsÚpartial)r  r  rÁ   r  r  r  rh   Ú	guard_ctxs   $$*     r$   r4   ÚBSubgraphTemplate.generate_custom_op_choices.<locals>.make_fx_graph¾  sˆ   € õ Gå?á&9Ó&;Ð#ÜŸK™K×1Ñ1�	ð
 !Ò,ð ×1Ñ1Ô3ä#×/Ò/Ó1ð ÷
 ’YÙ"Ü!×)Ò)¨&ÑB°MÑBØ,?Ø%/õð ñ	÷ —Y—Y“Yús   Á!$BÂB!	r†   z	CustomOp )r   r1   r2   r4   r3   r5   z5Skipping decomposition %s: adds guards during tracingÚinductorÚcustom_op_decomp_guard_skips)rC   rE   rb   Ú_infer_custom_op_layoutÚ_validate_layout_equivalenceÚ%torch.fx.experimental.symbolic_shapesr  Ú_generate_variant_namer  rò   r–   Úinfor   ry   rP   rI   )rW   r   r	  r1   r
  r  r5   r  r†   r  rv   Úlayoutsr2   Úchoicesr  rP   r  r4   Úvariant_nameÚchoices   &&&&&&&&            r$   Úgenerate_custom_op_choicesÚ+SubgraphTemplate.generate_custom_op_choices�  sÔ  € ÷8 ØˆIäˆ~Ó¤# oÓ"6Ô6Ü ðÜ˜>Ó*Ð+Ð+?ÄÀOÓ@TÐ?UÐU\ð^óð ð Ò&Ù/=Ó">©~¨!£2©~ÐÐ">ô #& nÔ"Fô	
ñ #G‘�ð ×(Ñ(Ø V¸=öñ #Gð	 	ñ 
ð 	×)Ñ)¨$ÀÔHØ˜•ˆà.0ˆÜ58ØÐ-@ö6
Ñ1ˆF >õ
 Rðà-3ðð 1>÷ð8  ×6Ñ6°vÓMˆLðØŸ™Ø ˜6  < .Ð1Ø +Ø!Ø"/Ø"+¨F¯O©OÐ+<Ð =Ø"/ð 'ó �ð" ×&Ñ& vÔ=à$2ˆFÔ!Ø�N‰N˜6Ö"ñw6
ðz ˆùòY #?ùó
øðv 'ô Ü—‘ØKØ—O‘Oôô ˜Õ$Ð%C×DÈÕIÓDÚðús   ÁD7Á+D<Ã)EÅAFÆFc                óV   <€ V ^8„  d   QhRS[ RS[3,          RS[S[S[3,          RS[/# )r   r  .rv   r   rw   )r#   r9   s   "€r$   r%   rÿ   ö  s6   ø€ ÷ -ñ -Ù˜s¡C˜xÕ(ð-Ù26±s¹C°xµ.ð-á	ñ-r&   c                ó¾   aa€ ^ RI oVP                  pV'       g   V# R V3R lloRP                  V3R l\        VP	                  4       4       4       4      pV RV 2# )zLGenerate a descriptive name for a decomposition variant with its parameters.Nc                ó0   € V ^8„  d   QhR\         R\        /# )r   Úvr   )r   r"   )r#   s   "r$   r%   Ú=SubgraphTemplate._generate_variant_name.<locals>.__annotate__   s   € ÷ 	ñ 	œcð 	¤cñ 	r&   c                ó    <€ \        V 4      pSP                  RRV4      pV'       d'   V^ ,          P                  4       '       d
   RV,           pV# )z7Convert a value to a valid Python identifier component.z[^a-zA-Z0-9_]r†   )r"   ÚsubÚisdigit)r1  rj   Úres   & €r$   Úsanitize_valueÚ?SubgraphTemplate._generate_variant_name.<locals>.sanitize_value   s>   ø€ ä�A“ˆAà—‘Ð'¨¨aÓ0ˆAç�Q�q•T—\‘\—^’^Ø˜!•G�ØˆHr&   r†   c              3   óB   <"  € T F  w  rV R S! V4       2x € K  	  R# 5i)r†   Nr¼   )Ú.0Úkr1  r7  s   &  €r$   Ú	<genexpr>Ú:SubgraphTemplate._generate_variant_name.<locals>.<genexpr>
  s(   øé € ð  
Ù3I©4¨1ˆqˆc�‘> !Ó$Ð%Õ&Ó3Iùs   ƒ)r6  rò   rÚ   ÚsortedÚitems)rW   r  rv   Ú	base_nameÚparam_suffixr6  r7  s   &&&  @@r$   r&  Ú'SubgraphTemplate._generate_variant_nameö  s_   ù€ ó 	à—O‘Oˆ	ßØÐ÷	ð 	ð —x‘xô  
Ü39¸&¿,¹,».Ô3Ió 
ó 
ˆð �˜A˜l˜^Ð,Ð,r&   c                ó:   <€ V ^8„  d   QhRS[ S[S[3,          RR/# )r   rv   r   Nrç   )r#   r9   s   "€r$   r%   rÿ     s#   ø€ ÷ ñ ±$±s¹C°xµ.ð ÀTñ r&   c           	     óº   € VP                  4        FF  w  r#\        V\        P                  \        34      '       g   K-  \        RV R\        V4       R24      h	  R# )z8Validate that kwargs contains only non-tensor arguments.zkwargs['z'] contains tensor zo. Tensor arguments should be in input_nodes, not kwargs. Only scalar/non-tensor parameters should be in kwargs.N)r?  rc   r   r8   r   rE   r±   )rW   rv   r´   Úvalues   &&  r$   Ú_validate_non_tensor_kwargsÚ,SubgraphTemplate._validate_non_tensor_kwargs  sV   € à Ÿ,™,ž.‰JˆCÜ˜%¤%§,¡,´Ð!7×8Ô8Ü$Ø˜s˜eÐ#6´t¸E³{°mð DMð Nóð ó )r&   c                ód   <€ V ^8„  d   QhRS[ RS[S[RS[3,          ,          RS[S[,          RR/# )r   Úop_namer	  .r(  r   N)r"   r!   r   r   r   )r#   r9   s   "€r$   r%   rÿ     sE   ø€ ÷ ñ áðñ ™X c©3 hÕ/Õ0ðñ ‘f•ð	ð
 
ñr&   c                ób  € V'       g   R# V^ ,          p\        VR,          ^R7       EF  w  rVVP                  VP                  VP                  VP                  3VP                  VP                  VP                  VP                  38w  g   Kg  \        RV RW%,          P                   RVP                   RVP                   RVP                   RVP                   RV^ ,          P                   RVP                   RVP                   RVP                   RVP                   R	24      h	  R# )
zXEnsure all layouts have consistent stride, device, dtype, and sizes for fair autotuning.N:é   NN)ÚstartzLayout mismatch in custom op 'z': decomposition 'z' produces (z, z) but 'r~   )rB   r°   ÚdtypeÚsizeÚstriderE   rò   )rW   rI  r	  r(  Ú	referencerY   r2   s   &&&&   r$   r$  Ú-SubgraphTemplate._validate_layout_equivalence  s   € ÷ Ùà˜A•Jˆ	Ü" 7¨2¥;°a×8Ð8‰IˆAØ—‘˜vŸ|™|¨V¯[©[¸&¿-¹-ÐHØ× Ñ Ø—‘Ø—‘Ø× Ñ ð	Mö ô %Ø4°W°Ið >&Ø&4Õ&7×&@Ñ&@Ð%Að BØŸ™� b¨¯©¨°b¸¿¹¸ÀRÈÏÉÀð WØ*¨1Õ-×6Ñ6Ð7ð 8Ø!×(Ñ(Ð)¨¨I¯O©OÐ+<¸B¸y¿~¹~Ð>NÈbÐQZ×QaÑQaÐPbÐbcð	eóð ó 9r&   c                óê   <€ V ^8„  d   QhRS[ S[,          RS[RS[3,          RS[S[S[3,          RS[RS[3,          R,          RS[S[S[S[.S[P                  3,          3,          R,          RS[	/# )	r   r1   Úfunction_decomposition.rv   r  Nr5   r   )
r!   r   r   r   r6   r"   r7   r   r8   r   )r#   r9   s   "€r$   r%   rÿ   3  s‰   ø€ ÷ 4ñ 4á™&•\ð4ñ !)¨©c¨Õ 2ð4ñ ‘S™#�X•ð	4ñ
 ˜s¡C˜xÕ(¨4Õ/ð4ñ ™C¡©3¨%±·±Ð*=Õ!>Ð>Õ?À$ÕFð4ñ 
ñ4r&   c           
     ó~  € ^ RI p^ RIHp V P                  V4       VP                  ;_uu_ 4        . p\        V4       FÓ  w  ršV'       d   W•9   d   WY,          ! V
4      pM V
P                  4       pVP                  P                  P                  V4      pV
P                  4       pVP                  P                  P                  V4      p\        P                  ! VVV
P                  4       V
P                  4       R7      pVP                  V4       KÕ  	  VP                   ! V3/ VB pV! V!  p\#        V\        P$                  4      '       g   \'        R\)        V4       R24      h\+        VP,                  VP.                  VP0                  VP3                  4       R7      uuRRR4       #   + '       g   i     R# ; i)zÒInfer output layout for custom ops using the default implementation when available.
Note that the Subgraph assumes custom ops return exactly one tensor output.
TODO: Add support for multiple output custom ops.
Nr   )rM  r°   z#Expected single tensor output, got z:. Multi-output custom ops not yet supported in autotuning.)r°   rM  rN  rO  )r  Útorch._inductor.virtualizedr   rF  rA   rB   rD   r*   rg   Úoptimization_hintsrF   r   Úempty_stridedÚ	get_dtypeÚ
get_devicerI   r  rc   r8   rE   r±   r   r°   rM  rd   rO  )rW   r1   rS  rv   r  r5   r  r   rJ   rY   rZ   Úfake_tensorÚ	raw_shapeÚconcrete_shapeÚ
raw_strideÚconcrete_striderÊ   Úoutputs   &&&&&&            r$   r#  Ú(SubgraphTemplate._infer_custom_op_layout3  s`  € ó 	å1ð 	×(Ñ(¨Ô0à�[�[‹[ØˆNÜ# KÖ0‘�ß  QÔ%7Ø"/Ö"2°3Ó"7‘Kà #§¡£�IØ%&§W¡W×%5Ñ%5×%HÑ%HÈÓ%S�NØ!$§¡Ó!1�JØ&'§g¡g×&6Ñ&6×&IÑ&IÈ*Ó&U�OÜ"'×"5Ò"5Ø&Ø'Ø!Ÿm™m›oØ"Ÿ~™~Ó/ô	#�Kð ×%Ñ% kÖ2ñ 1ð  ×"Ò"Ð#9ÑD¸VÑDˆBÙ˜Ñ(ˆFô ˜f¤e§l¡l×3Ò3Ü$Ø9¼$¸v»,¸ð HOð Póð ô
 Ø—}‘}Ø—l‘lØ—\‘\Ø—}‘}“ô	÷9 �[�[‹[ús   °E0F+Æ+F<	r¼   )Ú N)NNN)NN)rò   ró   rô   rõ   rö   Ú	itertoolsÚcountr  r?   r  r,  r&  rF  r$  r#  rø   rù   rú   rû   s   @@r$   rý   rý   F  sg   ù‡ € ñð —O’OÓ%€M÷$ó $÷!
ò !
÷Fsò s÷j-ð -÷2ð ÷ð ÷44÷ 4ò 4r&   rý   ).r  r  rb  ÚloggingÚcollections.abcr   Útypingr   re   r   Útorch._inductor.configÚ	_inductorrS   Útorch._dynamo.utilsr   Útorch._inductorr   Ú torch._inductor.autotune_processr   r	   r
   Útorch._inductor.codegen.commonr   Útorch._inductor.irr   r   r   r   r   r   r   Ú$torch._inductor.runtime.benchmarkingr   Útorch._inductor.utilsr   rU  r   Útorch.utils._ordered_setr   Ú	getLoggerrò   r–   r-   ÚChoiceCallerr/   rý   r¼   r&   r$   Ú<module>rs     s�   ðÛ Û Û Û Ý $Ý ã ã ß 'Ð 'Ý (Ý ÷ñ õ
 :÷÷ ñ õ =Ý :Ý )Ý /ð ×Ò˜Ó!€õ)ô,G'˜2Ÿ?™?ô G'ôTa�~ö ar&   