Ë
    ÄÓ^jÓÇ  ã                  ó   — U d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZ ddlZddlmZmZ ddlmZmZ ddlmZ dd	lmZmZmZmZmZmZmZmZ dd
l m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 er2ddl9m:Z: ddl;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZI  ej”                  eK«      ZLejš                   G d„ d«      «       ZNeOZPdeQd<   d3d„ZRd4d „ZSd5d!„ZT	 	 	 	 	 	 d6d#„ZU	 	 	 	 	 	 	 	 d7d$„ZV	 	 	 	 	 	 	 	 	 	 	 	 d8d%„ZW	 	 	 	 	 	 	 	 	 	 	 	 d8d&„ZX	 	 	 	 	 	 	 	 	 	 d9d'„ZY G d(„ d)«      ZZ G d*„ d+eZ«      Z[ejš                   G d,„ d"eN«      «       Z\ejš                   G d-„ d.eN«      «       Z]ejš                   G d/„ d0eN«      «       Z^ejš                   G d1„ d2eN«      «       Z_y):aÞ  
This provides an abstract class which parametrizes over an "output code" concept
for Inductor.  Intuitively, this represents the compiled callable which Inductor
produces which you can call to get optimized code.  However, this callable
has some other capabilities:

- It is serializable, so you can save/load this product from disk without
  having to do compilation again.

- (When using remote cache) it is addressable, so you can save just a key
  which you can use to load this product from remote cache later.

This class is abstract because we have several different implementations of
serialized format:

- Python wrapper (the default)

- AOTInductor (this produces ABI stable binaries which work across PyTorch
  versions)

é    )ÚannotationsN)Úpartial)ÚAnyÚcastÚTYPE_CHECKINGÚ	TypeAlias)ÚcountersÚget_runtime_metrics_context)Úcompile_contextÚCompileContext)Úinductor_compiled_code)ÚBoxedDeviceIndexÚCudagraphCachedInfoÚCudagraphMetadataÚget_input_storage_mutation_infoÚ!get_input_storage_mutation_reasonÚ get_partition_cudagraph_metadataÚget_placeholder_infoÚ#log_cudagraph_skip_and_bump_counter)Úhas_frozen_paramsÚis_frozen_param)Ú&_unstable_customized_partition_wrapperÚalign_inputs_from_check_idxsÚ	BoxedBoolÚCUDAGraphWrapperMetadataÚGraphPartitionMapÚ	InputTypeÚoutput_nodeÚ"set_tracing_context_output_strides)Ú
OpaqueBase)Ú_node_metadata_key_filter_safeÚ_ops_filter_safe)Ú
OrderedSet)Úis_in_torch_dispatch_modeé   )Úconfig)ÚAutotuneCacheBundler)ÚCounter)ÚCallableÚSequence)Úmetrics)ÚGraphLowering)ÚFakeScriptObject)ÚWeights)Ú_CompileFxKwargs)ÚTritonBundlec                  óÔ   — e Zd ZU  ej                  dd¬«      Zded<    ej                  dd¬«      Zded<    ej                  dd¬«      Zded	<   dd
„Z	dd„Z
	 	 	 	 	 	 	 	 dd„Zdd„Zy)Ú
OutputCodeNF)ÚdefaultÚinitú
str | NoneÚ_fx_graph_cache_keyzlist[str] | NoneÚ_fx_graph_cache_debug_linesz
int | NoneÚ_time_taken_nsc                ó*   — t        t        | «      «      ‚©N©ÚNotImplementedErrorÚtype©ÚselfÚinputss     úf/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/_inductor/output_code.pyÚ__call__zOutputCode.__call__^   ó   € Ü!¤$ t£*Ó-Ð-ó    c                ó*   — t        t        | «      «      ‚r:   r;   ©r?   s    rA   Úprepare_for_serializationz$OutputCode.prepare_for_serializationa   rC   rD   c                ó*   — t        t        | «      «      ‚r:   r;   ©r?   Úexample_inputsÚ	constantsÚgraph_kwargss       rA   Úpost_compilezOutputCode.post_compiled   s   € ô "¤$ t£*Ó-Ð-rD   c                ó*   — t        t        | «      «      ‚r:   r;   ©r?   Útriton_bundles     rA   Úset_triton_bundlezOutputCode.set_triton_bundlem   rC   rD   ©r@   zSequence[Any]Úreturnr   ©rS   ÚNone©rJ   úSequence[InputType]rK   ÚCompiledFxGraphConstantsrL   r/   rS   rU   ©rP   r   rS   rU   )Ú__name__Ú
__module__Ú__qualname__ÚdataclassesÚfieldr6   Ú__annotations__r7   r8   rB   rG   rM   rQ   © rD   rA   r2   r2   Q   s“   … ð
 '8 k×&7Ñ&7ÀÈ5Ô&QÐ˜ÓQØ4E°K×4EÑ4EØ˜5ô5ÐÐ!1ó ð
 "3 ×!2Ñ!2¸4ÀeÔ!L€N�JÓLó.ó.ð.à+ð.ð ,ð.ð 'ð	.ð
 
ó.ô.rD   r2   r   Ú_StrideExprStrc                óÜ   — t        | t        j                  «      sy t        | j                  «      D �cg c].  }| j                  |«      dk(  sŒ| j                  |«      dk7  sŒ-|‘Œ0 c}S c c}w ©Nr   r%   )Ú
isinstanceÚtorchÚTensorÚrangeÚndimÚstrideÚsize)ÚtÚis     rA   Úget_expanded_dimsrm   x   sL   € Ü�aœŸ™Ô&àÜ˜QŸV™V“}ÖL�!¨¯©°«°qÓ(8¸Q¿V¹VÀA»YÈ!»^ŠAÒLÐLùÒLs   ³A)ÁA)Á"A)c                ól   — |D ].  }t         j                  j                  j                  | |dd«      } Œ0 | S rc   )re   ÚopsÚatenÚslice)rk   Úexpanded_dimsÚexpanded_dims      rA   Úindex_expanded_dimsrt      s4   € Ø%ò 8ˆÜ�I‰I�N‰N× Ñ   L°!°QÓ7‰ð8à€HrD   c                óÞ  — | j                   |j                   k(  sJ ‚t        | j                  «       «      t        |j                  «       «      k(  sJ ‚t        | j                  «       «      t        |j                  «       «      k(  sJ ‚| j	                  «       dk(  ry t        d„ |j                  «       D «       «      sJ d«       ‚|j                  «       }t        d„ t        |j                  «       |j                  «       «      D «       «      dz   |z  }|j                  «       |z  }| j                  «       |z  }| j                  «       |||z    j                  |j                  «       |||z    «       y )Nr   c              3  ó&   K  — | ]	  }|d k\  –— Œ y­w)r   Nr`   )Ú.0Ústs     rA   ú	<genexpr>z(copy_strided_storage_.<locals>.<genexpr>�   s   è ø€ Ò.˜2ˆr�Q�wÑ.ùs   ‚z3copy_strided_storage_ requires non-negative stridesc              3  ó2   K  — | ]  \  }}|d z
  |z  –— Œ y­w)r%   Nr`   )rw   Úsrx   s      rA   ry   z(copy_strided_storage_.<locals>.<genexpr>“   s   è ø€ ÒJ¡5 1 b�1�q‘5˜B•,ÑJùs   ‚r%   )ÚdtypeÚtuplerj   ri   ÚnumelÚallÚelement_sizeÚsumÚzipÚstorage_offsetÚuntyped_storageÚcopy_)ÚdstÚsrcÚelemÚnbytesÚsrc_offÚdst_offs         rA   Úcopy_strided_storage_rŒ   ‰   s4  € Ø�9‰9˜Ÿ	™	Ò!Ð!Ð!Ü�—‘“Ó¤ c§h¡h£jÓ 1Ò1Ð1Ð1Ü�—‘“Ó¤%¨¯
©
«Ó"5Ò5Ð5Ð5Ø
‡y�yƒ{�aÒØÜÑ. §¡£Ô.Ô.ð Ø=óÐ.ð ×ÑÓ€DÜÑJ¬C°·±³
¸C¿J¹J»LÓ,IÔJÓJÈQÑNÐRVÑV€FØ× Ñ Ó" TÑ)€GØ× Ñ Ó" TÑ)€GØ×ÑÓ˜' G¨fÑ$4Ð5×;Ñ;Ø×ÑÓ˜g¨°&Ñ(8Ð9õrD   ÚCompiledFxGraphc                óH  ‡‡— | j                   €J ‚| j                  d   }|r�t        j                  j                  rf|€J ‚|j
                  €J ‚| j                   Št        j                  j                  j                  |j
                  d¬«      Š‰€J ‚dˆˆfd„}|| _         y y y )NÚis_backwardF)Úcreate_if_none_existsc                ó4   •— ‰j                  «         ‰| «      S r:   )Úset_to_running_backward)Ú
new_inputsÚcompiled_graph_callableÚmanagers    €€rA   Úcompiled_artifactz;maybe_handle_backward_generation.<locals>.compiled_artifact°   s   ø€ Ø×+Ñ+Ô-Ù*¨:Ó6Ð6rD   )r“   ú	list[Any]rS   zCallable[..., Any])	Úcurrent_callableÚ	fx_kwargsr&   ÚtritonÚcudagraph_treesÚvaluere   Ú	_inductorÚget_manager)Úcompiled_graphÚboxed_forward_device_indexr�   r–   r”   r•   s       @@rA   Ú maybe_handle_backward_generationr¡   ›   s°   ù€ ð ×*Ñ*Ð6Ð6Ð6Ø ×*Ñ*¨=Ñ9€Kñ
 ”v—}‘}×4Ò4Ø)Ð5Ð5Ð5Ø)×/Ñ/Ð;Ð;Ð;Ø"0×"AÑ"AÐä—/‘/×1Ñ1×=Ñ=Ø&×,Ñ,ÀEð >ó 
ˆð Ð"Ð"Ð"ö	7ð +<ˆÕ'ð 5€{rD   c                ó:  — t         j                  j                  s-|D ](  }t        |t        j
                  «      sŒt        |«       Œ* | j                  d   }| j                  d   }|�4|s1|s.|j                  t        t        | j                  «      «      «       y y y y )NÚis_inferencer�   )r&   rš   r›   rd   re   ÚSymIntÚintr™   ÚsetÚnextÚiterÚdevice_idxs)rŸ   rJ   r    rk   r£   r�   s         rA   Úprepare_cudagraph_post_compilerª   ·   s‹   € ô
 �=‰=×(Ò(àò 	ˆAÜ˜!œUŸ\™\Õ*Ü�A•ð	ð "×+Ñ+¨NÑ;€LØ ×*Ñ*¨=Ñ9€KØ!Ð-±lÉ;Ø"×&Ñ&¤t¬D°×1KÑ1KÓ,LÓ'MÕNð LW°lÐ-rD   c                ój  — ddl m} |j                  €J ‚|j                  €J ‚|j                  }|j                  }|j
                  d   }|j
                  d   }	|j                  dd«      r-t        j                  |«       t        ||«       t        d«       y|�s3|j
                  }
|
d	   }|j                  }|j                  }|€J d
«       ‚t        || |«       |j                  }|€J ‚|j                  «       D ��ci c]#  \  }}t        |t         j"                  «      sŒ!||“Œ% }}}t%        t'        |j(                  «      «      }t+        |||	|t-        |j/                  «       «      |t-        |j0                  «      ¬«      }t2        j4                  }|� |j6                  || |xs dfi |¤Ž|_        yddlm}  ||fd	|xs di|¤Ž|_        yt        j                  |«       t        ||«       d|j:                  v r1|j<                  rt        |j<                  «       yt        d|› �«       yyc c}}w )z¡
    Checks for any reasons not to run cudagraphs and then
    runs it on compiled_graph.
    Mutates the `compiled_graph.current_callable` and `cudagraphs`
    r   ©ÚCompilerBisectorNr£   r�   ÚinductorÚ
cudagraphsú#skipping cudagraphs due to bisectorÚstatic_input_idxsz9stack_traces should not be None in cudagraph_post_compile)Údevice_indexÚstack_tracesr�   r£   rK   ÚplaceholdersÚmutated_input_idxsr`   r%   ©ÚcudagraphifyÚcudaúskipping cudagraphs due to )Ú!torch._inductor.compiler_bisectorr­   r˜   Úcudagraph_infoÚcudagraph_fail_reasonsr™   Údisable_subsystemr   Údisabler¡   r   r´   r³   rª   Úitemsrd   re   rf   r§   r¨   r©   Údictr}   Úvaluesrµ   r&   Úcudagraph_policyr·   Ú
compile_fxÚdevice_typesÚdisabled_cudagraphs_reason)rJ   rŸ   r¯   rK   r    r­   Úcached_infor¼   r£   r�   r™   r±   r´   r³   r˜   ÚkÚvÚtensor_constantsr²   Úcudagraphify_kwargsÚpolicyr·   s                         rA   Úcudagraph_post_compilerÌ   È   sh  € õ Cà×*Ñ*Ð6Ð6Ð6Ø×(Ñ(Ð4Ð4Ð4Ø ×/Ñ/€KØ(×?Ñ?ÐØ!×+Ñ+¨NÑ;€LØ ×*Ñ*¨=Ñ9€Kð ×)Ñ)¨*°lÔCÜ×Ñ˜*Ô%Ü(¨Ð9SÔTÜ+Ð,QÔRØâ!Ø"×,Ñ,ˆ	Ø%Ð&9Ñ:Ðà"×/Ñ/ˆØ"×/Ñ/ˆØÐ'ð 	
ØGó	
Ð'ô 	'Ø˜NÐ,Fô	
ð *×:Ñ:ÐØÐ+Ð+Ð+ð 'Ÿ_™_Ó.÷
Ù�Q˜´*¸QÄÇÁÕ2MˆAˆq‰Dð
Ðñ 
ô œD ×!;Ñ!;Ó<Ó=ˆÜ"Ø%Ø%Ø#Ø%ÜÐ,×3Ñ3Ó5Ó6Ø%Ü$ ^×%FÑ%FÓGô
Ðô ×(Ñ(ˆØÐØ.A¨f×.AÑ.AØ ØØ!Ò' Rñ/ð &ñ	/ˆNÕ+õ 1á.:Ø ñ/à"3Ò"9°rð/ð &ñ/ˆNÕ+ô 	×Ñ˜*Ô%Ü(¨Ð9SÔTà�^×0Ñ0Ñ0ð ×8Ò8Ü3Ø"×=Ñ=õô 4Ø1Ð2HÐ1IÐJõð 1ùóI
s   Ã="H/Ä H/c                ó  — ddl m} |j                  dd«      r-t        j                  |«       t        ||«       t        d«       y|j                  €J ‚|j                  j                  }|s$|j                  �t        |j                  «      dk(  r"t        j                  |«       t        ||«       y|j                  €J ‚|j                  €J ‚|j                  d   }|j                  d   }t        |j                  d	   xs d
«      }	|j                  }
t!        t#        |j$                  «      «      }|j'                  «       D ��ci c]#  \  }}t)        |t*        j,                  «      sŒ!||“Œ% }}}|j                  j.                  €J d«       ‚t1        |j                  j2                  |	|
|j                  j.                  |«      }t5        || |«       ddlm} g }|j                  D ]Ž  }t;        ||«      }t=        |t?        |j@                  «      ||j.                  ||t?        |jB                  jE                  «       «      |j2                  t?        |j                  «      ¬«	      }|jG                  |«       Œ� |j                  |«       yc c}}w )aF  
    Cudagraphify each partition function, which first prepares the necessary
    metadata and then applies the cudagraphify function to each partition.

    Assuming all partition functions are cudagraphified and share the same order
    as `compiled_graph.partition_maps`. See [Note: Graph Partition Map for CUDAGraph].
    r   r¬   r®   r¯   r°   Nr£   r�   r±   r`   zCstack_traces should not be None in cudagraph_partition_post_compiler%   r¶   )r±   r²   r³   r�   r£   rK   r´   rµ   )$rº   r­   r½   r   r¾   r¡   r   r»   r¼   Úpartition_mapsÚlenr˜   Úrecursively_apply_fnsr™   r#   rµ   r§   r¨   r©   r¿   rd   re   rf   r³   r   r´   rª   rÃ   r·   r   r   r}   r±   rK   rÁ   Úappend)rJ   rŸ   r¯   rK   r    r­   r¼   r£   r�   r±   rµ   r²   rÇ   rÈ   rÉ   Úgraph_metadatar·   Úcudagraphify_fnsÚpartition_mapÚpartition_metadataÚcudagraphify_fns                        rA   Ú cudagraph_partition_post_compiler×   &  s�  € õ Cà×)Ñ)¨*°lÔCÜ×Ñ˜*Ô%Ü(¨Ð9SÔTÜ+Ð,QÔRØà×(Ñ(Ð4Ð4Ð4Ø+×:Ñ:×QÑQÐñ 	Ø×(Ñ(Ð0Üˆ~×,Ñ,Ó-°Ò2ô 	×Ñ˜*Ô%Ü(¨Ð9SÔTØà×*Ñ*Ð6Ð6Ð6Ø×/Ñ/Ð;Ð;Ð;Ø!×+Ñ+¨NÑ;€LØ ×*Ñ*¨=Ñ9€KÜ" >×#;Ñ#;Ð<OÑ#PÒ#VÐTVÓWÐØ'×:Ñ:ÐÜœ˜^×7Ñ7Ó8Ó9€Lð #Ÿ™Ó*÷Ù��A¬j¸¼E¿L¹LÕ.Iˆˆ1‰ðÐñ ð ×(Ñ(×5Ñ5ÐAð ØMóÐAô 'Ø×%Ñ%×2Ñ2ØØØ×%Ñ%×2Ñ2Øó€Nô #Ø˜Ð(Bôõ )ð
 ÐØ'×6Ñ6ò 1ˆÜ=ØØó
Ðô
 "ØÜ#Ð$6×$HÑ$HÓIØ%Ø+×8Ñ8Ø#Ø%ÜÐ.×8Ñ8×?Ñ?ÓAÓBØ+×8Ñ8Ü$Ð%7×%JÑ%JÓKô

ˆð 	×Ñ Õ0ð#1ð& ×(Ñ(Ð)9Õ:ùóYs   Å"JÅ(Jc                óÔ   — | sa|}|j                   r|D �cg c]	  }||v sŒ|‘Œ }}|r<|j                  €J ‚t        |j                  ||«      }||j                  ur||_        yyyyc c}w )aW  
    Realigns input strides from inputs_to_check if
    we didn't end up running cudagraphs. Mutates
    `compiled_graph.current_callable` if cudagraphs
    was run. Otherwise, does nothing.

    Non-mutated inputs are handled by deferred alignment copies
    in the generated code. Only mutated inputs need the wrapper
    for writeback.
    N)Ú_defers_input_alignmentr˜   r   )Úran_cudagraphsrŸ   Úinputs_to_checkÚmutated_inputs_idxsÚ
check_idxsrl   Únew_callables          rA   Úmaybe_realign_inputsrß   �  sŽ   € ñ  Ø$ˆ
Ø×1Ò1ð
 &5ÖQ ¸Ð=PÒ8Pš!ÐQˆJÐQÙØ!×2Ñ2Ð>Ð>Ð>Ü7Ø×/Ñ/ØØ#óˆLð
  >×#BÑ#BÑBØ2>�Õ/ð Cð ð ùò Rs
   •	A%ŸA%c                  ó   — e Zd ZdZdd„Zy)rX   a\  Wrapper class that unwraps constants from a compiled fx graph. This
    version of the class only supports directly grabbing the saved constants off of
    a CompiledFxGraph.

    With freezing, FxGraphCache doesn't store the constants of the input
    GraphModule it gets from AOTAutograd. Instead, it saves just the **names**
    of those constants, and grabs the constant values directly from the graph module
    passed in at runtime.

    Thing is, we don't always *have* the graph module available at runtime, hence
    the existence of this class and its CompiledFxGraphConstantsWithGm counterpart.

    To support freezing, FXGraphCache gets passed a CompiledFxGraphConstantsWithGm during
    post compile. Otherwise, CompiledFxGraphConstants supports the basic case of loading
    the value of constants directly off of the original saved object.
    c                óR   — |j                   €J ‚i |j                   ¥|j                  ¥S r:   )rK   Úopaque_value_type_classes)r?   Úgs     rA   ÚunwrapzCompiledFxGraphConstants.unwrap¶  s,   € Ø�{‰{Ð&Ð&Ð&Ø=�!—+‘+Ð= ×!<Ñ!<Ð=Ð=rD   N©rã   r�   rS   údict[str, torch.Tensor | type])rZ   r[   r\   Ú__doc__rä   r`   rD   rA   rX   rX   ¤  s   „ ñô">rD   rX   c                  ó    — e Zd ZdZdd„Zdd„Zy)ÚCompiledFxGraphConstantsWithGma/  
    This version of CompiledFxGraphConstants, instead of grabbing constants
    directly saved on CompiledFxGraphs, will just grab their names. Then, it takes
    a second GraphModule to grab the corresponding constant values out of.

    This is necessary for supporting freezing in FxGraphCache.
    c                ó   — || _         y r:   ©Úgm)r?   rì   s     rA   Ú__init__z'CompiledFxGraphConstantsWithGm.__init__Ä  s	   € Øˆ�rD   c           	     óÔ   — |j                   j                  «       D ��ci c]  \  }}|t        | j                  |«      “Œ }}}|j                  xs i }i |¥|¥|j
                  ¥S c c}}w r:   )Úfrozen_param_namesr¿   Úgetattrrì   rK   râ   )r?   rã   ÚnameÚ	orig_nameÚfrozen_paramsrK   s         rA   rä   z%CompiledFxGraphConstantsWithGm.unwrapÇ  st   € ð $%×#7Ñ#7×#=Ñ#=Ó#?÷
á��ið ”'˜$Ÿ'™' 9Ó-Ñ-ð
ˆñ 
ð —K‘KÒ% 2ˆ	ØL�)ÐL˜}ÐL°×0KÑ0KÐLÐLùó
s   ž!A$N)rì   útorch.fx.GraphModulerS   rU   rå   )rZ   r[   r\   rç   rí   rä   r`   rD   rA   ré   ré   »  s   „ ñóôMrD   ré   c                  óÚ  — e Zd ZU dZded<   ded<   ded<   ded<    ej                  d	¬
«      Zded<    ej                  d	¬
«      Zded<    ej                  d	¬
«      Z	ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   d ed!<   d"ed#<   d$ed%<   d ed&<   d ed'<   d ed(<   d ed)<   d*ed+<   d,ed-<   d ed.<   d/ed0<   d1ed2<   d3Z
d4ed5<   d3Zd6ed7<   d	Zd8ed9<   d	Zd8ed:<    ej                  d3d	d	d	¬;«      Zd<ed=<   d3Zd>ed?<   d3Zd@edA<   	 	 	 dK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dLdB„ZdMdC„ZdMdD„ZdNdE„Z	 	 	 	 	 	 	 	 dOdF„ZdPdG„ZdMdH„ZdQdI„ZdRdJ„Zy3)Sr�   zr
    Class holding a compiled FX graph. This is the object serialized on disk
    to support FxGraph caching.
    úCallable[..., Any] | Noner˜   rÐ   ú
Any | NoneÚcompiled_fn_runnerÚstrÚ	cache_keyF)ÚreprÚsource_codeÚrunnable_graph_strÚinductor_post_grad_graph_strzlist[tuple[int, str]] | NoneÚcache_linemapzOrderedSet[str]rÄ   úOrderedSet[int]r©   Úmutated_inputsrµ   zdict[str, torch.Tensor] | NonerK   zdict[str, str]rï   z3dict[str, torch._C.ScriptObject | FakeScriptObject]Útorchbind_constantszdict[str, type]râ   z.list[tuple[_StrideExprStr, ...] | None] | NoneÚoutput_stridesr5   rÅ   úmetrics.CachedMetricsDeltasÚmetrics_deltasúCounter[str]Úcounter_deltasÚguards_exprÚextern_libs_keyÚinductor_provenance_mapping_strÚ$inductor_provenance_stack_traces_strzCudagraphCachedInfo | Noner»   zlist[GraphPartitionMap] | NonerÎ   Úcompile_region_namer/   r™   úSequence[int]rÛ   Nzbool | NoneÚ_boxed_callzTritonBundle | NoneÚ_triton_bundleÚboolÚ_wrap_compiled_regionsrÙ   )r3   r4   rû   ÚcomparezCompileContext | NoneÚ_compile_contextztorch.fx.GraphModule | NoneÚ_original_gmúbytes | NoneÚ_serialized_original_gmc                óf	  — || _         || _        |�|j                  nd | _        |j                  | _        |j                  r3t        |j                  «      5 }|j                  «       | _        d d d «       || _        || _	        || _
        || _        |j                  | _        t        |j                  «      | _        t        |j                  «      | _        t        |j                   «      | _        t        |j"                  «      | _        t%        |«      s|j&                  | _        i | _        ngi | _        i | _        |j&                  j+                  «       D ]<  \  }}t-        |«      r|j.                  |   | j(                  |<   Œ.|| j&                  |<   Œ> |j0                  | _        |j2                  | _        || _        || _        || _        || _        d | _        d | _        d | _         |jB                  | _!        tE        |dd«      | _#        tI        |«      }i | _%        d| _&        d }|�rÌ| j6                  rRd| j                  v rtO        d| j6                  › �«       ntP        d   dxx   dz  cc<   tS        jT                  |«       �nntV        jX                  jZ                  s3d	d
l.m/}  ||| j                   | j"                  |
«      }|d u}|r
|| _        nd }ta        |«      }|�|| _        |d u df| dftV        jb                   dfte        d„ |	D «       «      dfg}tg        |«      }ti        |jj                  «      dk(  sJ ‚|jl                  jo                  d«      xsW |jj                  d	   D �cg c]>  }tq        |tr        jt                  jv                  jx                  «      r|jz                  nd ‘Œ@ c}}|D � �!cg c]
  \  } }!| rŒ	|!‘Œ }"} }!t}        t        |j€                  «      «      }#tƒ        |#||"«      }|| _         || _B        || _&        || _%        | j‡                  «        d| _D        tV        jŠ                  | _F        | jŒ                  rRd	d lG}$|$j‘                  |«      }%|%j€                  j’                  D ]  }&|&jl                  j•                  «        Œ |%| _K        y y # 1 sw Y   �Œ1xY wc c}w c c}!} w )NrÙ   Fr`   r¸   r¹   r®   Úcudagraph_skipsr%   r   )Ú3check_for_mutation_ignore_cuda_graph_managed_tensorzinput storage mutationzmutated inputsÚ$force_disable_cudagraph_TESTING_ONLYc              3  ó˜   K  — | ]B  }t        |t        j                  t        j                  t        j                  t
        f«      –— ŒD y ­wr:   )rd   re   rf   r¤   Ú	Generatorr    )rw   rk   s     rA   ry   z+CompiledFxGraph.__init__.<locals>.<genexpr>‡  s?   è ø€ ò ð !"ô 'Ø !ä$)§L¡LÜ$)§L¡LÜ$)§O¡OÜ$.ð	!"÷ñùs   ‚AA
znon-Tensor inputsÚoutput_stack_tracesT)Lr˜   rø   rÐ   rú   Ú
cache_pathÚopenÚreadrü   rý   rþ   r
  r  rÿ   r#   rÄ   r©   r  rµ   r   rK   rï   r¿   r   Úallocated_constant_namer  râ   r  rÅ   r  r  r  r	  r»   rÎ   rð   rÙ   r   r™   rÛ   r   r	   r   r¾   r&   rš   Ú cudagraph_support_input_mutationÚtorch._inductor.cudagraph_utilsr  r   r  r   r   rÏ   ÚargsÚmetaÚgetrd   re   ÚfxÚnodeÚNodeÚstack_tracer}   r   Úgraphr   r  Ú'_set_compile_context_for_autotune_cacher  Úwrap_inductor_compiled_regionsr  ÚcopyÚdeepcopyÚnodesÚclearr  )'r?   r˜   r+  rì   r  rÅ   r  r  r¯   rJ   r±   r  r™   rÛ   rý   rþ   rø   r
  r  ÚfrÇ   rÈ   Ústorage_mutation_infor»   r  Úhas_mutation_strÚhas_mutationÚstorage_mutation_reasonÚcudagraph_testsÚoutputÚargr³   Úbr{   r¼   r´   r.  Úgm_copyr(  s'                                          rA   rí   zCompiledFxGraph.__init__
  s•  € ð* !1ˆÔØ"4ˆÔð "Ð-ð ×4Ò4àð 	Ô"ð
 Ÿ™ˆŒØ×ÒÜ�e×&Ñ&Ó'ð ,¨1Ø#$§6¡6£8�Ô ÷,à"4ˆÔØ,HˆÔ)Ø/NˆÔ,Ø4XˆÔ1Ø"×0Ñ0ˆÔä& u×'9Ñ'9Ó:ˆÔÜ% e×&7Ñ&7Ó8ˆÔÜ(¨×)=Ñ)=Ó>ˆÔÜ",¨U×-EÑ-EÓ"FˆÔô ! Ô$Ø"Ÿ_™_ˆDŒNØ&(ˆDÕ#àˆDŒNØ&(ˆDÔ#ØŸ™×-Ñ-Ó/ò *‘��1Ü" 1Ô%Ø16×1NÑ1NÈqÑ1Q�D×+Ñ+¨AÒ.à()�D—N‘N 1Ò%ð	*ð $)×#<Ñ#<ˆÔ Ø).×)HÑ)HˆÔ&Ø,ˆÔØ*DˆÔ'Ø,ˆÔØ,ˆÔØˆÔØ#ˆÔØ"ˆÔØ#×2Ñ2ˆÔÜ'.¨uÐ6OÐQVÓ'WˆÔ$Ü ?ÀÓ CÐØˆŒØ!ˆÔàˆÚà×.Ò.Ø˜T×.Ñ.Ñ.Ü7Ø5°d×6UÑ6UÐ5VÐWõô ˜ZÑ(Ð):Ó;¸qÑ@Ó;Ü×!Ñ! *Ö-ä—}‘}×EÒEõñ
 LØØ ×/Ñ/Ø ×3Ñ3Ø-ó	ð %ð $4¸4Ð#?�Lá#Ø:J˜Õ7ð $(�Lä*KØ)ó+Ð'ð +Ð6Ø6M�DÔ3ð -°Ð4Ð6NÐOØ%Ð%Ð'7Ð8ä"×GÑGÐGØ>ðô
 ñ ð &4ôó ð ,ðð#�ô. % R›�ä˜6Ÿ;™;Ó'¨1Ò,Ð,Ð,ð  &Ÿ{™{Ÿ™Ð/DÓEò  à%Ÿ{™{¨1™~öJàô )3°3¼¿¹¿¹×8JÑ8JÔ(K�S—_’_ÐQUÑUòJ�ð 9H×)Q±°°1Êqª!Ð)QÐ&Ñ)QÜ$Ô%9¸"¿(¹(Ó%CÓD�Ü!4Ø  ,Ð0Fó"�ð -ˆÔØ#6ˆÔ Ø.ˆÔØ"ˆŒØ×4Ñ4Ô6ð  ˆÔô '-×&KÑ&KˆÔ#à×&Ò&ó à—m‘m BÓ'ˆGØŸ™×+Ñ+ò "�Ø—	‘	—‘Õ!ð"à 'ˆDÕð '÷W,ñ ,üòhJùó *Rs   ÁRÍ,AR(Î7
R-ÏR-ÒR%c                ó6   — | j                   �| j                   `y y r:   )rø   Ú
partitionsrF   s    rA   Ú__del__zCompiledFxGraph.__del__¾  s!   € Ø×"Ñ"Ð.ð ×'Ñ'Ñ2ð /rD   c                ót   — t        j                  «       }t        j                  |«      r|| _        y d | _        y r:   )r   Útry_getr'   Úhas_active_compiler  )r?   Ú"compile_context_for_autotune_caches     rA   r,  z7CompiledFxGraph._set_compile_context_for_autotune_cacheÇ  s>   € Ü-;×-CÑ-CÓ-EÐ*ô $×6Ñ6Ø2ôð /ð 	Õð
 ð 	ÕrD   c                óš  — | j                   €J ‚t        j                  j                  j                  rÏt        j                  j                  j
                  �«| j                  j                  d«      }|�Wt        j                  j                  j                  �3t        j                  j                  j                  j                  |«      nd }t        j                  j                  j
                  j                  d|i«       | j                  }t        j                  |«      }|rt        |«      nt        j                  «       }	 |5  	 t        j                   j"                  j$                  r­t        j&                  j(                  j+                  d| j,                  › d�ddi¬«      5  | j                  |«      cd d d «       t/        «       j1                  «        |rt        j2                  «        cd d d «       |rt        j                  |«      sd | _
        S S S | j                  |«      t/        «       j1                  «        |rt        j2                  «        cd d d «       |rt        j                  |«      sd | _
        S S S # 1 sw Y   nxY w	 t/        «       j1                  «        |rIt        j2                  «        n4# t/        «       j1                  «        |rt        j2                  «        w w xY wd d d «       n# 1 sw Y   nxY w|rt        j                  |«      sd | _
        y y y # |rt        j                  |«      sd | _
        w w w xY w)NÚgraph_idÚ
compile_idz## Call CompiledFxGraph z ##ÚscopeÚ
user_scope)Úkeyword_values)r˜   re   r�   ÚdebugÚRECORD_GRAPH_EXECUTIONÚGRAPH_EXECUTION_ORDERr™   r&  ÚGRAPH_COMPILE_IDSrÑ   r  r'   rA  r   Ú
contextlibÚnullcontextÚautogradÚprofilerÚ_is_profiler_enabledÚ_CÚ	_profilerÚ_RecordFunctionFastr6   r
   ÚfinishÚend_compile)r?   r@   rD  rE  rB  Ú!has_active_autotune_cache_bundlerÚautotune_cache_contexts          rA   rB   zCompiledFxGraph.__call__Ñ  sý  € Ø×$Ñ$Ð0Ð0Ð0ô �O‰O×!Ñ!×8Ò8Ü—‘×%Ñ%×;Ñ;ÐGà—~‘~×)Ñ)¨*Ó5ˆHð Ð'Ü—O‘O×)Ñ)×;Ñ;ÐGô —‘×%Ñ%×7Ñ7×;Ñ;¸HÔEð ð	 ô �O‰O×!Ñ!×7Ñ7×>Ñ>à  *ðôð
 .2×-BÑ-BÐ*Ü,@×,SÑ,SØ.ó-
Ð)ñ
 1ô Ð>Ô?ä×'Ñ'Ó)ð 	ð	-Ø'ñ ;ð;ä—~‘~×.Ñ.×CÒCÜ"ŸX™X×/Ñ/×CÑCØ6°t×7OÑ7OÐ6PÐPSÐTØ,3°\Ð+Bð Dó ñ Að $(×#8Ñ#8¸Ó#@÷	Að Aô 0Ó1×8Ñ8Ô:Ù8Ü,×8Ñ8Ô:÷;ð ;ñ" 2Ü,×?Ñ?Ø6ôð )-�Õ%ð	ð 2ð  $×4Ñ4°VÓ<ä/Ó1×8Ñ8Ô:Ù8Ü,×8Ñ8Ô:÷;ð ;ñ" 2Ü,×?Ñ?Ø6ôð )-�Õ%ð	ð 2÷Að Aúð Aô 0Ó1×8Ñ8Ô:Ù8Ü,×8Ñ8Õ:øô 0Ó1×8Ñ8Ô:Ù8Ü,×8Ñ8Õ:ð 9ú÷;÷ ;ñ ;úñ" 2Ü,×?Ñ?Ø6ôð )-�Õ%ð	ð 2øÑ1Ü,×?Ñ?Ø6ôð )-�Õ%ð	ð 2úss   ÅL( ÅK;Å	AJ>Æ(JÆ9	J>Ç.K;Ç0	L( ÈJ>È*.K;É	L( ÊJ	ÊJ>Ê/K;Ê>1K/Ë/K;Ë2	L( Ë;LÌ L( Ì("M
c                ó&  ‡ ‡‡‡— t         j                  r£t        j                  r“‰ j                  €J ‚‰ j
                  €J ‚t        ‰ j
                  j                  «      }t        |«      D �cg c]  }t        ||«      ‘Œ }}t        j                  Š|D �cg c]	  }|fˆfd„	‘Œ }}‰ j	                  |«       yt        |‰ «       |d   €J ‚|d   €J ‚|d   }	|d   }
t         j                  }|�:|j                  ‰ «      s)t        d   dxx   dz  cc<   t        j                  |
«       |
rÌ‰ j                   rQd‰ j"                  v rt%        d	‰ j                   › �«       nt        d   dxx   dz  cc<   t        j                  |
«       no|	rd
|v sJ ‚|d
   }n|j'                  d
d«      }t         j                  r!|€t)        |‰ |
|j+                  ‰ «      |«       nt-        |‰ |
|j+                  ‰ «      |«       ‰ j.                  }t1        |
‰ |‰ j2                  «       ‰ j4                  €‰‰ j6                  �}ddlm} ddlm} ddl m!}  |d |«       ¬«      }tE        tF        jH                  jJ                  |jM                  ‰ j6                  |«      «      }|jO                  «        |‰ _        d‰ _        ‰ jP                  rM‰ jR                  �@ddl*m+} ‰ jR                  Š |‰‰ j4                  ‰ jX                  ¬«      Šˆˆˆ fd„}|‰ _)        yyyc c}w c c}w )a—  
        Run a set of post processing steps after loading from the cache. These involve:
         - Setting the tracing context output strides
         - Running cudagraphs if enabled
         - Realigning inputs

        This runs whether or not we have a cache hit, and always runs directly after we get a CompiledFxGraph.
        The results of this function are *not* saved in the cache itself.
        Nc                ó   •—  ‰| |«      S r:   r`   )r2  ÚmÚcustomized_wrappers     €rA   ú<lambda>z.CompiledFxGraph.post_compile.<locals>.<lambda>#  s   ø€ Ñ&8¸¸AÓ&>€ rD   r¯   r�   r®   r  r%   r¸   r¹   r    r   )ÚFakeTensorMode©ÚGraphPickler)ÚShapeEnvT)Úallow_non_fake_inputsÚ	shape_env)ÚInductorCompiledCallable)r  c                óz   •— t        «       r)‰j                  �d‰j                  ini }t        ‰| fi |¤ŽS  ‰| «      S )Nrñ   )r$   r  r   )r@   ÚkwargsÚinductor_callableÚoriginal_callabler?   s     €€€rA   Úwrapped_callablez6CompiledFxGraph.post_compile.<locals>.wrapped_callable�  sO   ø€ Ü,Ô.ð  ×3Ñ3Ð?ð   ×!9Ñ!9Ñ:àð ô
 2Ð2CÀVÑVÈvÑVÐVá,¨VÓ4Ð4rD   )-r&   Úgraph_partitionr   ÚwrapperrÐ   rø   rÏ   r=  rg   r   r   rÂ   Úshould_wrapr	   r   r¾   rÅ   rÄ   r   r&  r×   rä   rÌ   rÛ   rß   rµ   r  r  Útorch._subclassesr^  Útorch.fx._graph_picklerr`  Ú%torch.fx.experimental.symbolic_shapesra  r   re   r'  ÚGraphModuleÚloadsÚ	recompiler  r˜   Útorch._higher_order_ops.wraprd  r  )r?   rJ   rK   rL   Únum_partitionsrl   Úwrapper_metadatasÚmetadataÚ!customized_wrappers_with_metadatar�   r¯   rË   r    rÛ   r^  r`  ra  Ú	fake_modeÚoriginal_gmrd  ri  r\  rg  rh  s   `                    @@@rA   rM   zCompiledFxGraph.post_compile	  sB  û€ ô ×!Ò!Ô&L×&TÒ&Tà×-Ñ-Ð9Ð9Ð9Ø×*Ñ*Ð6Ð6Ð6Ü  ×!8Ñ!8×!CÑ!CÓDˆNô ˜~Ó.ö!àô )¨¸Õ;ð!Ðð !ô "H×!OÑ!OÐð !2ö1àð %Ö>ð1Ð-ð 1ð ×&Ñ&Ð'HÔIØä*¨>¸4Ô@Ø˜LÑ)Ð5Ð5Ð5Ø˜MÑ*Ð6Ð6Ð6Ø" =Ñ1ˆØ ,¨\Ñ :ˆ
ô ×(Ñ(ˆØÐ f×&8Ñ&8¸Ô&>Ü�ZÑ Ð!2Ó3°qÑ8Ó3Ü×Ñ˜jÔ)áð ×.Ò.Ø˜T×.Ñ.Ñ.Ü7Ø5°d×6UÑ6UÐ5VÐWõô ˜ZÑ(Ð):Ó;¸qÑ@Ó;Ü×!Ñ! *Õ-áØ7¸<ÑGÐGÐGØ1=Ø4ñ2Ñ.ð 2>×1AÑ1AØ4°dó2Ð.ô ×)Ò)¨f¨nô 5Ø&ØØ"Ø!×(Ñ(¨Ó.Ø2õô +Ø&ØØ"Ø!×(Ñ(¨Ó.Ø2ôð ×.Ñ.ˆô 	ØØØØ×#Ñ#ô		
ð ×ÑÐ$¨×)EÑ)EÐ)QÝ8Ý<ÝFá&Ø&*Ù"›*ôˆIô Ü—‘×$Ñ$Ø×"Ñ" 4×#?Ñ#?ÀÓKóˆKð ×!Ñ!Ô#Ø +ˆDÔØ+/ˆDÔ(ð ×&Ò&¨4×+@Ñ+@Ð+LÝMà $× 5Ñ 5Ðá 8Ø!Ø×!Ñ!Ø$(×$<Ñ$<ô!Ðö	5ð %5ˆDÕ!ð- ,MÐ&ùòO!ùò
1s   Á-L	ÂLc                ó   — || _         y r:   )r  rO   s     rA   rQ   z!CompiledFxGraph.set_triton_bundleœ  s
   € Ø+ˆÕrD   c                óÄ   — d | _         d | _        d | _        d | _        | j                  �8ddlm}m} |j                  | j                   |d ¬«      «      | _	        d | _        y y )Nr   ©r`  ÚOptions)Ú
ops_filter)
r  r˜   rÐ   rø   r  rn  r`  r}  Údumpsr  )r?   r`  r}  s      rA   rG   z)CompiledFxGraph.prepare_for_serializationŸ  se   € ð
 !%ˆÔØ $ˆÔØ%)ˆÔ"Ø"&ˆÔØ×ÑÐ(ßEà+7×+=Ñ+=Ø×!Ñ!¡7°dÔ#;ó,ˆDÔ(ð !%ˆDÕð )rD   c                óÚ   — ddl m} ddlm}m}  || j
                  d«      d   }| j                  }t        j                  j                  |«      s|d   dxx   dz  cc<    |||d	¬
«       |S )Nr   )r	   )Úget_pathÚwrite_atomicÚpyé   r®   Úfxgraph_lookup_write_filer%   T)Ú	make_dirs)
Útorch._dynamo.utilsr	   Útorch._inductor.codecacher�  r‚  rú   rü   ÚosÚpathÚexists)r?   r	   r�  r‚  Úartifact_pathÚcodes         rA   Úwrite_to_diskzCompiledFxGraph.write_to_disk²  sb   € Ý0ßDñ ! §¡°Ó6°qÑ9ˆØ×ÑˆÜ�w‰w�~‰~˜mÔ,Ø�ZÑ Ð!<Ó=ÀÑBÓ=Ù˜¨¸Õ=ØÐrD   c           	     ó   — ddl m} ddlm} | j	                  «       }	  |dd¬«      5  |j                  | j                  || j                  |j                  | «      «      }|j                  | _
        t        |dd «      | _        t        |dd «      | _        d d d «       |S # 1 sw Y   |S xY w# t        $ r t        j!                  d	|«       ‚ w xY w)
Nr   )Údynamo_timed)ÚPyCodeCachezPyCodeCache.load_by_key_pathT)Úlog_pt2_compile_eventrÐ   ÚrunnerzFailed to load artifact: %s)r‡  r�  rˆ  r‘  rŽ  Úload_by_key_pathrú   rÿ   rä   Úcallr˜   rð   rÐ   rø   ÚOSErrorÚlogÚerror)r?   rK   r�  r‘  rŒ  Ú
code_caches         rA   Úafter_deserializationz%CompiledFxGraph.after_deserialization¿  s×   € Ý4Ý9à×*Ñ*Ó,ˆð	ÙØ.Ø&*ôñ Nð )×9Ñ9Ø—N‘NØ!Ø×&Ñ&Ø×$Ñ$ TÓ*ó	�
ð )3¯©�Ô%Ü-4ØÐ 7¸ó.�Ô*ô +2°*¸hÈÓ*M�Ô'÷Nð& Ð÷'Nð& Ðûô	 ò 	Ü�I‰IÐ3°]ÔCØð	ús)   ž
B, ¨A-BÂB, ÂB)Â$B, Â)B, Â,!C)NNN)&r˜   rö   r+  r,   rì   rô   r  z'list[tuple[_StrideExprStr, ...] | None]rÅ   r5   r  r  r  r  r¯   r   rJ   rW   r±   r  r  r5   r™   r/   rÛ   r  rý   rù   rþ   rù   rø   r÷   r
  r5   r  r5   rS   rU   rT   rR   rV   rY   )rS   rù   )rK   rX   rS   rù   )rZ   r[   r\   rç   r_   r]   r^   rü   rý   rþ   r  r  r  rÙ   r  r  r  rí   r>  r,  rB   rM   rQ   rG   rŽ  rš  r`   rD   rA   r�   r�   Ð  s’  … ñð
 0Ó/Ø4Ó4Ø"Ó"ØƒNØ(�{×(Ñ(¨eÔ4€K�Ó4Ø/˜k×/Ñ/°UÔ;Ð˜Ó;Ø(9¨×(9Ñ(9Øô)Ð  #ó ð 0Ó/Ø!Ó!Ø Ó Ø#Ó#Ø'Ó'Ø-Ó-Ø&Ó&ØLÓLØ.Ó.ØBÓBØ *Ó*Ø/Ó/Ø Ó ð ÓØÓØ%/Ó/Ø*4Ó4à.Ó.Ø2Ó2Ø#Ó#ØÓØ"Ó"à#€K�Ó#Ø*.€NÐ'Ó.Ø#(Ð˜DÓ(Ø$)Ð˜TÓ)Ø.?¨k×.?Ñ.?Ø˜5 u°eô/ÐÐ+ó ð 15€LÐ-Ó4Ø,0Ð˜\Ó0ð& *.Ø6:Ø;?ð'r(à3ðr(ð ðr(ð !ð	r(ð
 @ðr(ð %/ðr(ð 4ðr(ð %ðr(ð ðr(ð ,ðr(ð )ðr(ð (ðr(ð $ðr(ð 'ðr(ð  ðr(ð  '*ð!r(ð" 'ð#r(ð$ *4ð%r(ð& /9ð'r(ð( 
ó)r(óh3ó
ó6-ðpQ5à+ðQ5ð ,ðQ5ð 'ð	Q5ð
 
óQ5óf,ó%ó&ôrD   c                  ó    — e Zd ZU dZded<   ded<   dZded<    ej                  e¬	«      Z	d
ed<   d„ Z
dd„Zdd„Zd„ Z	 	 	 	 	 	 	 	 dd„Zdd„Zy)ÚCompiledAOTIz3
    Class holding an AOTInductor compiled so.
    z0str | list[str | Weights] | torch.fx.GraphModuleÚfilenamerù   Údevice_typeNrö   r˜   )Údefault_factoryzdict[str, bytes]Ú_cached_filesc                ód  — t         j                  j                  sy t        j                  j
                  j                  s$t        j                  j
                  j                  ry t         j                  j                  dk(  ry t         j                  j                  ry t         j                  sy t        | j                  t        «      rt        d„ | j                  D «       «      }n| j                  }t        |t        j                  j                   «      r|| _        y | j$                  j'                  d«      rBt        j(                  j*                  j-                  |d| j$                  dd«      j.                  }n¸| j$                  j'                  d«      rAt        j(                  j*                  j1                  |d| j$                  d«      j.                  }n\| j$                  dk(  r5t        j(                  j*                  j3                  |d«      j.                  }nt5        d	| j$                  › �«      ‚|| _        d| _        | j8                  D ]U  }t:        j<                  j?                  |«      rŒ#tA        |d
«      5 }|jC                  | j8                  |   «       d d d «       ŒW y # 1 sw Y   ŒbxY w)NÚwindowsc              3  óf   K  — | ])  }t        |t        «      sŒ|j                  d «      sŒ&|–— Œ+ y­w)z.soN)rd   rù   Úendswith)rw   Úfns     rA   ry   z-CompiledAOTI.__post_init__.<locals>.<genexpr>û  s*   è ø€ ò $Ø¬j¸¼SÕ.AÀbÇkÁkÐRWÕFX”ñ$ùs   ‚1˜1ª1r¸   r%   Ú TÚxpuÚcpuzunsupported device type Úwb)"r&   Úaot_inductorÚlink_libtorchre   r�   Úcpp_builderÚ	_IS_MACOSÚ_IS_WINDOWSÚcross_target_platformÚpackage_cpp_onlyÚenable_autograd_for_aotrd   r�  Úlistr§   r'  rp  r˜   rž  Ú
startswithrR  Ú_aotiÚAOTIModelContainerRunnerCudaÚrunÚAOTIModelContainerRunnerXpuÚAOTIModelContainerRunnerCpuÚRuntimeErrorr  r   r‰  rŠ  r‹  r  Úwrite)r?   r˜   Úfiler2  s       rA   Ú__post_init__zCompiledAOTI.__post_init__ç  s"  € Ü×"Ñ"×0Ò0Øô �O‰O×'Ñ'×1Ò1Ü�‰×*Ñ*×6Ò6àä×Ñ×4Ñ4¸	ÒAØä×Ñ×/Ò/Øä×-Ò-Øä�d—m‘m¤TÔ*Ü#ñ $Ø!Ÿ]™]ô$ó  Ñð  $Ÿ}™}ÐäÐ&¬¯©×(<Ñ(<Ô=à$4ˆDÔ!Øà×Ñ×&Ñ& vÔ.ä—‘—‘×;Ñ;Ø$ØØ×$Ñ$ØØó÷ ‘#ñ ð ×Ñ×(Ñ(¨Ô/ä—‘—‘×:Ñ:Ø$ØØ×$Ñ$Øó	÷
 ‘#ñ ð ×Ñ Ò&ä—‘—‘×:Ñ:Ø$ aóç‘#ñ ô Ð!9¸$×:JÑ:JÐ9KÐLÓMÐMØ 0ˆÔØˆÔØ×&Ñ&ò 	6ˆDÜ—7‘7—>‘> $Õ'Ü˜$ Ó%ð 6¨Ø—G‘G˜D×.Ñ.¨tÑ4Ô5÷6ð 6ñ	6÷6ð 6ús   É<J&Ê&J/	c                óR   — | j                   €t        d«      ‚| j                  |«      S )Nz%AOTInductor compiled so is not loaded)r˜   r¹  r>   s     rA   rB   zCompiledAOTI.__call__(  s+   € Ø× Ñ Ð(ÜÐFÓGÐGØ×$Ñ$ VÓ,Ð,rD   c                óJ  — d | _         i | _        g }t        | j                  t        «      r| j                  }n't        | j                  t
        «      r| j                  g}|D ]4  }t        |d«      5 }|j                  «       | j                  |<   d d d «       Œ6 y # 1 sw Y   ŒAxY w)NÚrb)r˜   r   rd   r�  r²  rù   r  r   )r?   Ú	filenamesrñ   r2  s       rA   rG   z&CompiledAOTI.prepare_for_serialization-  s’   € Ø $ˆÔØˆÔØ!ˆ	Ü�d—m‘m¤TÔ*ØŸ™‰IÜ˜Ÿ™¤sÔ+ØŸ™˜ˆIØò 	4ˆDÜ�d˜DÓ!ð 4 QØ+,¯6©6«8�×"Ñ" 4Ñ(÷4ð 4ñ	4÷4ð 4ús   Á0BÂB"	c                óD   — | j                   j                  «       }d |d<   |S )Nr˜   )Ú__dict__r.  )r?   Ústates     rA   Ú__getstate__zCompiledAOTI.__getstate__9  s$   € Ø—‘×"Ñ"Ó$ˆØ$(ˆÐ Ñ!ØˆrD   c                ó>   — | j                   €| j                  «        y y r:   )r˜   r¼  rI   s       rA   rM   zCompiledAOTI.post_compile>  s!   € ð × Ñ Ð(Ø×ÑÕ ð )rD   c                 ó   — y r:   r`   rO   s     rA   rQ   zCompiledAOTI.set_triton_bundleG  ó   € ØrD   rR   rT   rV   rY   )rZ   r[   r\   rç   r_   r˜   r]   r^   rÀ   r   r¼  rB   rG   rÄ  rM   rQ   r`   rD   rA   rœ  rœ  Ü  s~   … ñð ?Ó>ØÓØ26ÐÐ/Ó6Ø&7 k×&7Ñ&7ÈÔ&M€MÐ#ÓMò?6óB-ó

4òð
!à+ð!ð ,ð!ð 'ð	!ð
 
ó!ôrD   rœ  c                  óL   — e Zd ZU dZded<   dd„Z	 	 	 	 	 	 	 	 d	d„Zd
d„Zdd„Zy)ÚMockFXGraphCacheOutputNr   rì   c                ó   — d| _         y )NT)r  rF   s    rA   r¼  z$MockFXGraphCacheOutput.__post_init__O  s
   € ØˆÕrD   c                 ó   — y r:   r`   rI   s       rA   rM   z#MockFXGraphCacheOutput.post_compileR  s   € ð 	rD   c                ó$   — | j                  |«      S r:   rë   r>   s     rA   rB   zMockFXGraphCacheOutput.__call__Z  s   € Ø�w‰w�v‹ÐrD   c                 ó   — y r:   r`   rO   s     rA   rQ   z(MockFXGraphCacheOutput.set_triton_bundle]  rÇ  rD   rT   rV   rR   rY   )	rZ   r[   r\   rì   r_   r¼  rM   rB   rQ   r`   rD   rA   rÉ  rÉ  K  sE   … à€BˆƒNó ðà+ðð ,ðð 'ð	ð
 
óóôrD   rÉ  c                  ó¬   ‡ — e Zd ZU dZdZded<   dZded<   dZded<   ee	f	 	 	 	 	 dˆ fd	„Z
dd
„Zed„ «       Z	 	 dd„Z	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zˆ xZS )ÚRegionalOutputCodeað  
    OutputCode for regional inductor compilation results.

    Regional inductor returns a torch.fx.GraphModule that contains both
    compiled regions (via standalone_compile) and eager regions. This needs
    special serialization using GraphPickler instead of standard pickle.

    The serialization strategy stores the GraphModule as bytes using
    GraphPickler.dumps(), which handles FakeTensors, AOTCompiledArtifacts,
    and other special objects that standard pickle cannot handle.
    Nr  Ú_serialized_graph_moduleztorch.nn.Module | NoneÚ_graph_moduleúCallable[[str], bool] | NoneÚ_ops_filterc                ó*  •— t         ‰| �  «        || _        d| _        g | _        d| _        | j                  «       \  }}t        |j                  j                  t        j                  j                  j                  «      | _        || _        || _        y)a  
        Args:
            graph_module: The torch.fx.GraphModule returned by regional_inductor
            ops_filter: Optional filter function for op names during serialization.
                If provided, only ops whose name passes the filter will be serialized.
        NT)Úsuperrí   rÑ  rÐ  Ú_serialized_wrappersr  Ú_unwrap_graph_modulerd   r+  Ú_codegenre   r'  Ú_BoxedCodeGenÚ_inner_boxed_callrÓ  Ú_node_metadata_key_filter)r?   Úgraph_moduler~  Únode_metadata_key_filterÚ_ÚmoduleÚ	__class__s         €rA   rí   zRegionalOutputCode.__init__x  s~   ø€ ô 	‰ÑÔØ)ˆÔØ(,ˆÔ%Ø$&ˆÔ!ØˆÔØ×-Ñ-Ó/‰	ˆˆ6Ü!+Ø�L‰L×!Ñ!¤5§8¡8§>¡>×#?Ñ#?ó"
ˆÔð &ˆÔØ)AˆÕ&rD   c                óˆ   — | j                   €t        d«      ‚| j                  r| j                  |«      S  | j                   |Ž S )a\  
        Execute the regional compiled graph.

        Args:
            inputs: A mutable list of inputs. Must be a list (not an arbitrary
                Sequence) because the boxed calling convention allows the callee
                to mutably clear the list when inputs become dead, enabling early
                memory deallocation.
        zURegionalOutputCode has no graph module loaded. Did you forget to call post_compile()?)rÑ  r¹  rÚ  r>   s     rA   rB   zRegionalOutputCode.__call__’  sQ   € ð ×ÑÐ%Üð9óð ð
 ×!Ò!Ø×%Ñ% fÓ-Ð-Ø!ˆt×!Ñ! 6Ð*Ð*rD   c                ó@   — | j                  «       \  }}|j                  S r:   )r×  r+  )r?   rÞ  rß  s      rA   r+  zRegionalOutputCode.graph¦  s   € à×-Ñ-Ó/‰	ˆˆ6Ø�|‰|ÐrD   c                óÎ  — | j                   }g }t        |t        j                  j                  «      rŠ|j
                  }t        |t        j                  j                  j                  «      sJ ‚|j                  t        j                  j                  |j                  |j                  dœf«       |j                  }t        |t        j                  j                  «      sJ ‚||fS )N)ÚreasonÚwrapping)rÑ  rd   re   Ú_dynamoÚOptimizedModuleÚ
dynamo_ctxÚ
eval_frameÚDisableContextrÑ   r¾   Úmsgrå  Ú	_orig_modr'  rp  )r?   rß  Úserialized_wrappersrè  s       rA   r×  z'RegionalOutputCode._unwrap_graph_module«  s¸   € ð ×#Ñ#ˆØ ÐÜ�fœeŸm™m×;Ñ;Ô<Ø×*Ñ*ˆJÜ˜j¬%¯-©-×*BÑ*B×*QÑ*QÔRÐRÐRØ×&Ñ&ä—M‘M×)Ñ)Ø)Ÿ~™~¸:×;NÑ;NÑOðôð ×%Ñ%ˆFÜ˜&¤%§(¡(×"6Ñ"6Ô7Ð7Ð7Ø" FÐ*Ð*rD   c                óz  — | j                   �y| j                  €J ‚ddlm}  ||«      }|€t	        d«      ‚ddlm} |j                  | j                  |«      }t        |t        j                  j                  «      sJ ‚|j                  «        t        | j                  «      D ]  \  }}	 ||fi |	¤Ž}Œ || _         y)zÀ
        Post-compile processing for regional inductor.

        This deserializes the GraphModule from bytes using GraphPickler,
        extracting the fake_mode from example_inputs.
        Nr   )Údetect_fake_modeziCould not detect fake mode from example inputs. Regional inductor requires fake mode for deserialization.r_  )rÑ  rÐ  Útorch._guardsrï  r¹  rn  r`  rq  rd   re   r'  rp  rr  ÚreversedrÖ  )
r?   rJ   rK   rL   rï  rx  r`  rì   r¥  rf  s
             rA   rM   zRegionalOutputCode.post_compile½  sÀ   € ð ×ÑÐ)ØØ×,Ñ,Ð8Ð8Ð8å2á$ ^Ó4ˆ	ØÐÜðLóð õ 	9à×Ñ × =Ñ =¸yÓIˆÜ˜"œeŸh™h×2Ñ2Ô3Ð3Ð3Ø
�‰ŒÜ" 4×#<Ñ#<Ó=ò 	"‰JˆB�Ù�BÑ!˜&Ñ!‰Bð	"àˆÕrD   c                 ó   — y)z6Regional inductor doesn't use triton bundles directly.Nr`   rO   s     rA   rQ   z$RegionalOutputCode.set_triton_bundleà  s   � rD   c                óâ   — | j                   �cddlm}m} d| _        | j                  «       \  | _        }|j                  | || j                  | j                  ¬«      ¬«      | _        d| _         yy)a  
        Prepare for serialization by converting the GraphModule to bytes.

        This uses GraphPickler to serialize the graph module since it contains
        special objects like FakeTensors and AOTCompiledArtifacts that need
        custom pickling.
        Nr   r|  )r~  rÝ  )Úoptions)
rÑ  rn  r`  r}  rÐ  r×  rÖ  r  rÓ  rÛ  )r?   r`  r}  rÜ  s       rA   rG   z,RegionalOutputCode.prepare_for_serializationã  su   € ð ×ÑÐ)ßEà,0ˆDÔ)Ø6:×6OÑ6OÓ6QÑ3ˆDÔ% |à,8×,>Ñ,>ØÙØ#×/Ñ/Ø-1×-KÑ-Kôð -?ó -ˆDÔ)ð "&ˆDÕð *rD   )rÜ  rô   r~  zCallable[[str], bool]rÝ  rÒ  )r@   r—   rS   r   )rS   zBtuple[list[tuple[Callable, dict[str, Any]]], torch.fx.GraphModule]rV   rY   rT   )rZ   r[   r\   rç   rÐ  r_   rÑ  rÓ  r"   r!   rí   rB   Úpropertyr+  r×  rM   rQ   rG   Ú__classcell__)rà  s   @rA   rÏ  rÏ  a  s¹   ø… ñ
ð .2Ð˜lÓ1ð -1€MÐ)Ó0ð 15€KÐ-Ó4ð
 -=à*ðBà*ðBð *ðBð #?õ	Bó4+ð( ñó ðð+à	Kó+ð$! à+ð! ð ,ð! ð 'ð	! ð
 
ó! óFE÷&rD   rÏ  )rk   útorch.TensorrS   ú	list[int])rk   r÷  rr   rø  rS   r÷  )r†   r÷  r‡   r÷  rS   rU   )rŸ   r�   r    úBoxedDeviceIndex | NonerS   rU   )rŸ   r�   rJ   rW   r    rù  rS   rU   )rJ   rW   rŸ   r�   r¯   r   rK   ræ   r    rù  rS   rU   )
rÚ   r   rŸ   r�   rÛ   r  rÜ   r   rS   rU   )`rç   Ú
__future__r   rM  r]   Úloggingr‰  Ú	functoolsr   Útypingr   r   r   r   re   r‡  r	   r
   rð  r   r   rs  r   r#  r   r   r   r   r   r   r   r   Útorch._inductor.freezing_utilsr   r   Útorch._inductor.utilsr   r   r   r   r   r   r   r   Útorch._opaque_baser    rn  r!   r"   Útorch.utils._ordered_setr#   Útorch.utils._python_dispatchr$   r¦  r&   Úruntime.autotune_cacher'   Úcollectionsr(   Úcollections.abcr)   r*   Útorch._inductorr+   Útorch._inductor.graphr,   Ú"torch._library.fake_class_registryr-   Ú)torch.export.pt2_archive._package_weightsr.   rÃ   r/   Útriton_bundlerr0   Ú	getLoggerrZ   r—  Ú	dataclassr2   rù   ra   r_   rm   rt   rŒ   r¡   rª   rÌ   r×   rß   rX   ré   r�   rœ  rÉ  rÏ  r`   rD   rA   ú<module>r     s…  ðòõ, #ã Û Û Û 	Ý ß 6Ó 6ã ß Eß 9Ý ?÷	÷ 	ó 	÷ N÷	÷ 	ó 	õ *ß TÝ /Ý Bå Ý 8ñ Ý#ß2å'Ý3ÝCÝAå,Ý,à€g×Ñ˜Ó!€ð ×Ñ÷.ð .ó ð.ð>  €�	Ó óMóóð$<Ø#ð<à 7ð<ð 
ó<ð8OØ#ðOà'ðOð !8ðOð 
ó	Oð"[Ø'ð[à#ð[ð ð[ð .ð	[ð
 !8ð[ð 
ó[ð|X;Ø'ðX;à#ðX;ð ðX;ð .ð	X;ð
 !8ðX;ð 
óX;ðv ?Øð ?à#ð ?ð #ð ?ð )ð	 ?ð
 
ó ?÷F>ñ >ô.MÐ%=ô Mð* ×ÑôH�jó Hó ðHðV ×Ñôk�:ó kó ðkð\ ×Ñô˜Zó ó ðð* ×ÑôW&˜ó W&ó ñW&rD   