+
    –°³jÕe  ã                   óÒ  € R t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
Ht ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^RIHt ^RIHtHtHt ]'       d   ^ RI H!t! ]PD                  ! ]#4      t$]R R l4       t%R R lt&R R lt']R R l4       t(]R R l4       t)]R R l4       t*]! RR7      R R l4       t+R R lt, ]R  R! l4       t-]P\                   ! R" R#]4      4       t/R$ R% lt0R& R' lt1RRR( R) llt2R* R+ lt3R, R- lt4RSR. R/ llt5]! R0]5R17       ]! ]0R2R37      t6]! R4]6R17       R5 R6 lt7]! R7]7R17       R8 R9 lt8]! R:]8R17       R; R< lt9]! R=]9R17       ]! ]R>7      t:]! R?]:R17        ! R@ RA];4      t< ! RB RC];4      t=]RD RE l4       t>]RF RG l4       t?]RH RI l4       t@]RJ RK l4       tA]P\                   ! RL RM4      4       tBRN RO ltC ! RP RQ4      tDR# )TaD  
This module provides debugging backends for TorchDynamo to help diagnose and troubleshoot
compilation and execution issues. It includes:

Key Debugging Backends:
- eager: Simple pass-through backend that runs models in eager mode
- eager_noexcept: Similar to eager but with additional exception handling
- eager_debug: Adds schema validation checks for custom operators
- aot_eager: Uses AOT Autograd with nop compiler for debugging
- aot_eager_decomp_partition: Uses TorchInductor decompositions for debugging
- torchscript: Compiles using TorchScript for debugging JIT-related issues

Testing and Development Tools:
- Backends for inducing specific errors (compile/runtime/accuracy)
- ExplainOutput class for detailed graph compilation analysis
- Utilities for cross-referencing and mode management
- Tools for graph detail inspection and break reason analysis

These backends are primarily used for:
1. Debugging graph breaks and compilation failures
2. Testing error handling and recovery mechanisms
3. Analyzing performance bottlenecks
4. Validating operator schemas and decompositions
N)ÚCallableÚIterable)Úimport_module)ÚAnyÚTYPE_CHECKING)Ú#min_cut_rematerialization_partition)Ú_guards)ÚGraphCompileReason)Úconfig)Ú
ts_compile)Ú
OutputCode)Úaot_autograd)Ú
CompiledFnÚ
CompilerFnÚregister_debug_backend)ÚTargetc          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# ©é   ÚgmÚfake_tensor_inputsÚkwargsÚreturn.©ÚtorchÚfxÚGraphModuleÚlistÚTensorr   r   )Úformats   "Úa/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_dynamo/backends/debugging.pyÚ__annotate__r!   5   sH   € ÷ 
ñ 
Ü�‰×Ñð
Ü26´u·|±|Õ2Dð
ÜPSð
äˆc”3ˆhÕñ
ó    c                 óÆ   € V'       d   \         P                  R V4       \        P                  P                  P
                  '       d   ^ RIHp V! V 4      # V P                  # )z&eager backend ignoring extra kwargs %s)ÚGraphModuleSerializableCallable)	ÚlogÚwarningr   Ú
_functorchr
   Úforce_autograd_cacheÚtorch._dynamo.aot_compile_typesr$   Úforward)r   r   r   r$   s   &&, r    Úeagerr+   4   sF   € ÷ Ü�‰Ð<¸fÔEä×Ñ×Ñ×3×3Ð3ÝSá.¨rÓ2Ð2Ø�:‰:Ðr"   c                ór   € V ^8„  d   QhR\         P                  P                  R\        R\        3,          /# )r   Úmoder   .)r   Ú	overridesÚTorchFunctionModer   r   )r   s   "r    r!   r!   B   s3   € ÷ @ñ @Ü
�/‰/×
+Ñ
+ð@äˆc”3ˆhÕñ@r"   c                 ó   € \        V .4      # ©N)Ú,make_eager_backend_with_torch_function_modes©r-   s   &r    Ú+make_eager_backend_with_torch_function_moder4   B   s   € ô 8¸¸Ó?Ð?r"   c                óˆ   € V ^8„  d   QhR\         \        P                  P                  ,          R\        R\
        3,          /# )r   Úmodesr   .)r   r   r.   r/   r   r   )r   s   "r    r!   r!   H   s4   € ÷ ñ Ü”E—O‘O×5Ñ5Õ6ðäˆc”3ˆhÕñr"   c                ó*   a a€ ^ RI Ho R VV 3R llpV# )zßUsed to trace HOPs (cond and while) for eager execution, the metadata
TF mode mutates vars outside of the scope of the HOP, and we can't have graph breaks
in the HOP, so we need to externally run this mode and not trace it.)Ú	ExitStackc          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   ÚBmake_eager_backend_with_torch_function_modes.<locals>.__annotate__P   sH   € ÷ 	ñ 	Ü�H‰H× Ñ ð	Ü6:¼5¿<¹<Õ6Hð	ÜTWð	ä	�#”s�(Õ	ñ	r"   c                 ó    <a € R  VV V3R llpV# )c                ó<   € V ^8„  d   QhR\         R\         R\         /# )r   Úargsr   r   ©r   )r   s   "r    r!   ÚNmake_eager_backend_with_torch_function_modes.<locals>.fn.<locals>.__annotate__S   s!   € ÷ 	3ñ 	3œ3ð 	3¬#ð 	3´#ñ 	3r"   c                  ó¸   <€ S! 4       ;_uu_ 4       pS F  pVP                  V4       K  	  SP                  ! V / VB uuR R R 4       #   + '       g   i     R # ; ir1   )Úenter_contextr*   )r=   r   Ústackr-   r8   r   r6   s   *,  €€€r    ÚwrapperÚImake_eager_backend_with_torch_function_modes.<locals>.fn.<locals>.wrapperS   sA   ø€ Ù—” Û!�DØ×'Ñ'¨Ö-ñ "à—z’z 4Ð2¨6Ñ2÷ ——“ús   ‘,AÁA	© )r   r   r   rC   r8   r6   s   f&, €€r    ÚfnÚ8make_eager_backend_with_torch_function_modes.<locals>.fnP   s   ù€ ÷	3ò 	3ð ˆr"   )Ú
contextlibr8   )r6   rF   r8   s   f @r    r2   r2   H   s   ù€ õ %÷	ñ 	ð €Ir"   c          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   r!   _   sH   € ÷ ñ Ü�‰×ÑðÜ26´u·|±|Õ2DðÜPSðäˆc”3ˆhÕñr"   c                 óV   a € V'       d   \         P                  R V4       R V 3R llpV# )z/eager_noexcept backend ignoring extra kwargs %sc                ó0   € V ^8„  d   QhR\         R\         /# ©r   r=   r   r>   )r   s   "r    r!   Ú$eager_noexcept.<locals>.__annotate__g   s   € ÷ ñ ”Sð œSñ r"   c                  óŒ   <€  S! V !  #   \          d0   p\        P                  P                  P	                  R 4      ThRp?ii ; i)z7Unexpected exception when running generated GraphModuleN)Ú	Exceptionr   Ú_dynamoÚexcÚTorchDynamoException)r=   Úer   s   * €r    ÚinnerÚeager_noexcept.<locals>.innerg   sE   ø€ ð	Ù�t‘9ÐøÜô 	Ü—-‘-×#Ñ#×8Ñ8ØIóàðûð	ús   ƒ	 ‰A”*>¾A)r%   r&   )r   r   r   rT   s   f&, r    Úeager_noexceptrV   ^   s(   ø€ ÷ Ü�‰ÐEÀvÔN÷ð ð €Lr"   c                óÂ   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\         P                  P                  /# )r   r   r   r   r   )r   r   r   r   r   r   )r   s   "r    r!   r!   s   sI   € ÷ ñ Ü�‰×ÑðÜ26´u·|±|Õ2DðÜPSðä
‡X�X×Ññr"   c                 óž   a € V'       d   \         P                  R V4       ^ RIHp R V 3R llpV! VRR7      ! V!  pVP	                  4        V# )z3pre_dispatch_eager backend ignoring extra kwargs %s)Úmake_fxc                ó0   € V ^8„  d   QhR\         R\         /# rL   r>   )r   s   "r    r!   Ú(pre_dispatch_eager.<locals>.__annotate__{   s   € ÷ 3ñ 3œ3ð 3¤3ñ 3r"   c                  ó^   <€ \         P                  P                  S4      P                  ! V !  # r1   ©r   r   ÚInterpreterÚrun)r=   r   s   *€r    Úrunnable_gmÚ'pre_dispatch_eager.<locals>.runnable_gm{   s#   ø€ Ü�x‰x×#Ñ# BÓ'×+Ò+¨TÑ2Ð2r"   T)Úpre_dispatch)r%   r&   Ú"torch.fx.experimental.proxy_tensorrY   Úprint_readable)r   r   r   rY   r`   Úpre_dispatch_gms   f&,   r    Úpre_dispatch_eagerrf   r   sJ   ø€ ÷ Ü�‰ÐIÈ6ÔRå:÷3ð 3ñ ˜k¸Õ=Ð?QÑR€OØ×"Ñ"Ô$àÐr"   c          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   r!   …   sH   € ÷ ñ Ü�‰×ÑðÜ26´u·|±|Õ2DðÜPSðäˆc”3ˆhÕñr"   c                 óf   a a€ V'       d   \         P                  R V4       ^ RIHo R VV 3R llpV# )z,eager_debug backend ignoring extra kwargs %s)ÚSchemaCheckModec                ó0   € V ^8„  d   QhR\         R\         /# rL   r>   )r   s   "r    r!   Ú!eager_debug.<locals>.__annotate__�   s   € ÷ 7ñ 7”Sð 7œSñ 7r"   c                  óº   <€ S! 4       ;_uu_ 4        \         P                  P                  S4      P                  ! V !  uuR R R 4       #   + '       g   i     R # ; ir1   r]   )r=   ri   r   s   *€€r    rT   Úeager_debug.<locals>.inner�   s8   ø€ Ù×ÕÜ—8‘8×'Ñ'¨Ó+×/Ò/°Ñ6÷ ××Óús   ‘-A	Á	A	)r%   r&   Ú#torch._subclasses.schema_check_moderi   )r   r   r   rT   ri   s   f&, @r    Úeager_debugro   „   s+   ù€ ÷ Ü�‰ÐBÀFÔKåC÷
7ñ 7ð €Lr"   Úts)Únamec                ó¶   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P
                  P                  /# )r   r   r   r   )r   r   r   r   r   ÚjitÚScriptModule)r   s   "r    r!   r!   ˜   sA   € ÷ ;ñ ;Ü�‰×Ñð;Ü26´u·|±|Õ2Dð;ä
‡Y�Y×Ññ;r"   c                 óX   € ^ RI Hp \        P                  P	                  V! V 4      4      # )é    )Ú_unwrap_lazy_graph_module)Útorch.fx._lazy_graph_modulerw   r   rs   Úscript)r   r   rw   s   && r    Útorchscriptrz   —   s#   € õ Fä�9‰9×ÑÑ5°bÓ9Ó:Ð:r"   c                ó¨   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        3,          /# )r   ÚsubgraphÚexample_inputsr   .©r   r   r   r   r   r   r   )r   s   "r    r!   r!       s@   € ÷ #ñ #Ü�h‰h×"Ñ"ð#Ü48¼¿¹Õ4Fð#äˆc”3ˆhÕñ#r"   c                óœ   a aa€ ^ RI Hp ^ RIHo \        P
                  P                  VR VV 3R ll4       4       oR V3R llpRVn        V# )zðInner compiler that wraps forward/backward graphs in invoke_subgraph HOP.

This is used as the fw_compiler/bw_compiler for aot_autograd. When the resulting
function is traced by make_fx, it emits an invoke_subgraph HOP instead of inlining.
)Údisable)Úinvoke_subgraph_inferc                ó0   € V ^8„  d   QhR\         R\         /# )r   Úoperandsr   r>   )r   s   "r    r!   Ú4invoke_subgraph_inner_compiler.<locals>.__annotate__®   s   € ÷ :ñ :´3ð :¼3ñ :r"   c                  ó   <€ S! S.V O5!  # r1   rE   )rƒ   r�   r|   s   *€€r    Úinvoke_subgraph_wrapper_unboxedÚGinvoke_subgraph_inner_compiler.<locals>.invoke_subgraph_wrapper_unboxed¬   s   ø€ ñ % XÐ9°Ó9Ð9r"   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# rL   )r   r   )r   s   "r    r!   r„   ³   s   € ÷ 6ñ 6¤d¬3¥ið 6´Cñ 6r"   c                 ó   <€ S! V !  # r1   rE   )r=   r†   s   &€r    Úinvoke_subgraph_wrapperÚ?invoke_subgraph_inner_compiler.<locals>.invoke_subgraph_wrapper³   s   ø€ ñ
 /°Ñ5Ð5r"   T)Útorch._dynamor€   Ú'torch._higher_order_ops.invoke_subgraphr�   r   rP   Úallow_in_graphÚ_boxed_call)r|   r}   r€   rŠ   r�   r†   s   f&  @@r    Úinvoke_subgraph_inner_compilerr�       sQ   ú€ õ &ÝMô ‡]�]×!Ñ!Ø÷:ð :ó ó "ð:÷
6ð 6ð +/ÐÔ'à"Ð"r"   c          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   r!   õ   sH   € ÷ ñ Ü�‰×ÑðÜ26´u·|±|Õ2DðÜPSðäˆc”3ˆhÕñr"   c                ó€   € V'       d   \         P                  RV4       \        \        \        \        RR7      ! W4      # )aø  Backend that wraps forward/backward graphs in invoke_subgraph HOP when traced by make_fx.

This backend uses AOTAutograd to partition into forward/backward graphs, then wraps
each in an invoke_subgraph HOP. This is useful for recursive Dynamo tracing scenarios
where you want the compiled subgraph to appear as invoke_subgraph HOPs in the outer
trace rather than being inlined.

Requires:
- torch._dynamo.config.force_compile_during_fx_trace = True
  (this implicitly overrides error_on_nested_fx_trace)
z0invoke_subgraph backend ignoring extra kwargs %sT©Úfw_compilerÚbw_compilerÚpartition_fnÚkeep_inference_input_mutations)r%   r&   r   r�   r   )r   r   r   s   &&,r    Úinvoke_subgraphr˜   ô   s;   € ÷ Ü�‰ÐFÈÔOô Ü2Ü2Ü8Ø'+õ	ð
 	óð r"   c                   ó¤   a € ] tR tRt o RtRt]P                  ! RRR7      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tRtV tR# )ÚAOTEagerOutputCodei  zÇ
An OutputCode that wraps a GraphModule for eager-mode execution.

This allows non-inductor backends (like aot_eager) to participate in
the bundled autograd cache and aot_compile serialization flow.
NF)ÚdefaultÚinitc                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r   Úinputsr   r>   )r   Ú__classdict__s   "€r    r!   ÚAOTEagerOutputCode.__annotate__  s   ø€ ÷ 'ñ '™sð '¡sñ 'r"   c                ój   € V P                   f   \        R4      hV P                   P                  V4      # )Núgm must not be None)r   ÚAssertionErrorr*   )Úselfrž   s   &&r    Ú__call__ÚAOTEagerOutputCode.__call__  s*   € Ø�7‰7Š?Ü Ð!6Ó7Ð7Ø�w‰w�‰˜vÓ&Ð&r"   c                ó   <€ V ^8„  d   QhRR/# )r   r   NrE   )r   rŸ   s   "€r    r!   r       s   ø€ ÷ ñ ¨4ñ r"   c                óœ  € ^ RI HpHp V P                  f   \	        R4      hV P                  P
                  P                   FW  pVP                  P                  RR4       VP                  P                  RR4       VP                  P                  RR4       KY  	  VP                  V P                  V! RR7      4      V n
        RV n        R# )rv   )ÚGraphPicklerÚOptionsNr¢   Únn_module_stackÚsource_fn_stackÚexample_value)Ú
ops_filter)Útorch.fx._graph_picklerr©   rª   r   r£   ÚgraphÚnodesÚmetaÚpopÚdumpsÚ_serialized_gm)r¤   r©   rª   Únodes   &   r    Úprepare_for_serializationÚ,AOTEagerOutputCode.prepare_for_serialization   s‘   € ßAà�7‰7Š?Ü Ð!6Ó7Ð7Ø—G‘G—M‘M×'Ô'ˆDØ�I‰I�M‰MÐ+¨TÔ2Ø�I‰I�M‰MÐ+¨TÔ2Ø�I‰I�M‰M˜/¨4Ö0ñ (ð
 +×0Ñ0°·±¹'ÈTÔ:RÓSˆÔØˆŽr"   c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   r=   r   r   Nr>   )r   rŸ   s   "€r    r!   r    -  s"   ø€ ÷ 'ñ '¡#ð '±ð '¸ñ 'r"   c                óî  € V P                   fç   V P                  e×   ^ RIHp ^ RIHp ^ RIHp ^ RIH	p V! V! 4       R7      pVP                  V P                  V4      p\        V\        P                  P                  4      '       g   \        R\!        V4       24      hW€n         V P                   P"                  P%                  V! 4       4       V P                   P'                  4        R V n        R # R # R # )N)ÚFakeTensorMode)r©   )ÚShapeEnv©Ú_BoxedCodeGen)Ú	shape_envz#Expected torch.fx.GraphModule, got )r   rµ   Útorch._subclassesr»   r¯   r©   Ú%torch.fx.experimental.symbolic_shapesr¼   Útorch.fx.graphr¾   ÚloadsÚ
isinstancer   r   r   r£   Útyper°   Úset_codegenÚ	recompile)	r¤   r=   r   r»   r©   r¼   r¾   Ú	fake_moder   s	   &*,      r    Úpost_compileÚAOTEagerOutputCode.post_compile-  s±   € Ø�7‰7Š?˜t×2Ñ2Ò>Ý8Ý<ÝFÝ4á&±³Ô<ˆIØ×#Ñ# D×$7Ñ$7¸ÓCˆBÜ˜b¤%§(¡(×"6Ñ"6×7Ò7Ü$Ð'JÌ4ÐPRË8È*Ð%UÓVÐVØŒGØ�G‰G�M‰M×%Ñ%¡m£oÔ6Ø�G‰G×ÑÔØ"&ˆDÖñ  ?‰?r"   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   Útriton_bundler   Nr>   )r   rŸ   s   "€r    r!   r    =  s   ø€ ÷ ñ ©sð °tñ r"   c                ó   € R # r1   rE   )r¤   rÌ   s   &&r    Úset_triton_bundleÚ$AOTEagerOutputCode.set_triton_bundle=  s   € Ùr"   c                óv   <€ V ^8„  d   Qh/ S[ P                  P                  R,          ;R&   S[R,          ;R&   # )r   Nr   rµ   )r   r   r   Úbytes)r   rŸ   s   "€r    r!   r      s2   ø‡ ‚ ñ 	�‰×Ñ˜tÕ#Ñ*ñ ñ ˜D•LÑNò r"   )rµ   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚdataclassesÚfieldrµ   r¥   r·   rÉ   rÎ   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©rŸ   s   @r    rš   rš     sS   ø‡ € ñð '+€BØ#.×#4Ò#4¸TÈÔ#N€N÷'ð '÷
ð ÷'ð '÷ ð ÷] ƒ r"   rš   c                ó¨   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        3,          /# )r   Úfx_gr}   r   .r~   )r   s   "r    r!   r!   B  s@   € ÷ ñ Ü
�(‰(×
Ñ
ðÜ04´U·\±\Õ0Bðäˆc”3ˆhÕñr"   c                 ó2  a a€ ^ RI Hp S P                  P                  V! 4       4       S P	                  4        \
        P                  '       g   \
        P                  '       d   \        S R7      pRVn	        V# S P                  oR VV 3R llpRVn	        V# )rv   r½   )r   Tc                ó0   € V ^8„  d   QhR\         R\         /# rL   r>   )r   s   "r    r!   Úboxed_nop.<locals>.__annotate__S  s   € ÷  ñ  ”#ð  œ#ñ  r"   c                 ó�   <€ ^ RI HpHp V! 4       ;p e+   VP                  '       d   V! SRR7      P                  ! V !  # S! V 4      # )rv   )ÚDebugInterpreterÚget_active_debug_modeÚ	aot_eager)Úbackend)Útorch.utils._debug_moderã   rä   Úrun_compile_with_interpreterr_   )r=   rã   rä   Ú
debug_modeÚ
forward_fnrÞ   s   &   €€r    r_   Úboxed_nop.<locals>.runS  sJ   ø€ ßSñ 0Ó1Ð1ˆJØòà$×A×AÐAÙ# D°+Ô>×BÒBÀDÑIÐIÙ˜$ÓÐr"   )rÂ   r¾   r°   rÆ   rÇ   Úfunctorch_configr(   Úbundled_autograd_cacherš   r�   r*   )rÞ   r}   r¾   Úresultr_   rê   s   f&   @r    Ú	boxed_noprï   B  sz   ù€ õ -ð 	‡J�J×Ñ™=›?Ô+Ø‡N�NÔä×,×,Ð,Ô0@×0W×0WÐ0WÜ# tÔ,ˆØ!ˆÔØˆð —‘€J÷ ñ  ð €C„OØ€Jr"   c          
      óÜ   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P
                  P                  R\        R\        3,          /# )r   rÞ   r}   r-   r   .)	r   r   r   r   r   r.   r/   r   r   )r   s   "r    r!   r!   `  sV   € ÷ ñ Ü
�(‰(×
Ñ
ðäœŸ™Õ&ðô �/‰/×
+Ñ
+ð	ô
 ˆc”3ˆhÕñr"   c                ó°   aa€ ^ RI Hp V P                  P                  V! 4       4       V P	                  4        V P
                  oR VV3R llpRVn        V# )rv   r½   c                ó0   € V ^8„  d   QhR\         R\         /# rL   r>   )r   s   "r    r!   Ú)boxed_nop_with_mode.<locals>.__annotate__o  ó   € ÷ $ñ $”#ð $œ#ñ $r"   c                 óf   <€ S;_uu_ 4        S! V 4      uuR R R 4       #   + '       g   i     R # ; ir1   rE   )r=   rê   r-   s   &€€r    r_   Ú boxed_nop_with_mode.<locals>.runo  s   ø€ ßŠTÙ˜dÓ#÷ �T�T‹Tús   ŒŸ0	T©rÂ   r¾   r°   rÆ   rÇ   r*   r�   )rÞ   r}   r-   r¾   r_   rê   s   &&d  @r    Úboxed_nop_with_moderø   `  sK   ù€ õ -ð 	‡J�J×Ñ™=›?Ô+Ø‡N�NÔð —‘€J÷$ñ $ð €C„OØ€Jr"   c          
      ó  € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        \         P                  P                  .\        3,          R,          R\
        R\        3,          /# )r   rÞ   r}   Úignore_op_fnNr   .)
r   r   r   r   r   r   Ú_opsÚ
OpOverloadÚboolr   )r   s   "r    r!   r!   w  sh   € ÷ ñ Ü
�(‰(×
Ñ
ðäœŸ™Õ&ðô œEŸJ™J×1Ñ1Ð2´DÐ8Õ9¸DÕ@ðô ˆc”3ˆhÕñ	r"   c                 ó°   aa€ ^ RI Hp V P                  P                  V! 4       4       V P	                  4        V P
                  oR VV3R llpRVn        V# )rv   r½   c                ó0   € V ^8„  d   QhR\         R\         /# rL   r>   )r   s   "r    r!   Ú-fake_crossref_boxed_nop.<locals>.__annotate__…  rô   r"   c                 ó    <€ \         P                  P                  S4      ;_uu_ 4        S! V 4      uuR R R 4       #   + '       g   i     R # ; ir1   )r   Ú_subclassesÚCrossRefFakeMode)r=   rê   rú   s   &€€r    r_   Ú$fake_crossref_boxed_nop.<locals>.run…  s1   ø€ Ü×Ñ×/Ñ/°×=Õ=Ù˜dÓ#÷ >×=×=Ó=ús	   ©<¼A	Tr÷   )rÞ   r}   rú   r¾   r_   rê   s   &&f  @r    Úfake_crossref_boxed_nopr  w  sK   ù€ õ
 -ð 	‡J�J×Ñ™=›?Ô+Ø‡N�NÔð —‘€J÷$ñ $ð €C„OØ€Jr"   c                óX   € V ^8„  d   QhR\         P                  P                  R\        /# )r   Úopr   )r   rû   rü   rý   )r   s   "r    r!   r!   �  s$   € ÷ 5ñ 5œŸ
™
×-Ñ-ð 5´$ñ 5r"   c                 ó    € V P                   R9   # )Úaten)r	  ÚprimsÚprim)Ú	namespace)r  s   &r    Úignore_builtinsr  �  s   € Ø�<‰<Ð4Ñ4Ð4r"   c                ó¾   € V ^8„  d   QhR\         \        P                  P                  \        \        P
                  ,          .\         R\        3,          3,          /# )r   r   .)r   r   r   r   r   r   r   )r   s   "r    r!   r!   ‘  sD   € ÷ Xñ X”hÜ
‡X�X×Ñœ4¤§¡Õ-Ð.´¸¼c¸Õ0BÐBõñ Xr"   c                  ó´  € \         P                  P                  P                  '       g   \        # \         P                  P                  P                  R 8X  d   \
        # \         P                  P                  P                  R8w  d2   \        R\         P                  P                  P                  : 24      h\        P                  ! \
        \        R7      # )ÚallÚ
custom_opsz6Expected fake_tensor_crossref to be 'custom_ops', got )rú   )
r   r'   r
   Úfake_tensor_crossrefrï   r  r£   Ú	functoolsÚpartialr  rE   r"   r    Úget_nop_funcr  ‘  s¢   € ô ×Ñ×"Ñ"×7×7Ð7ÜÐÜ	×	Ñ	×	 Ñ	 ×	5Ñ	5¸Ô	>Ü&Ð&ä×Ñ×"Ñ"×7Ñ7¸<ÔGÜ ðÜ×'Ñ'×.Ñ.×CÑCÑFðHóð ô × Ò Ô!8ÄÔWÐWr"   c                ó  € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        3,          R,          R\
        R\        3,          R,          R\        R\
        R\        3,          /# )	r   r   r   r”   .Nr•   r   r   r~   )r   s   "r    r!   r!   £  s|   € ÷ (ñ (Ü�‰×Ñð(äœUŸ\™\Õ*ð(ô ˜#œs˜(Õ# dÕ*ð(ô ˜#œs˜(Õ# dÕ*ð	(ô
 ð(ô ˆc”3ˆhÕñ(r"   c                 ón   € \        T;'       g    \        T;'       g    \        \        R R7      ! W3/ VB # )Tr“   )r   rï   r   )r   r   r”   r•   r   s   &&&&,r    rå   rå   £  sA   € ô Ø×,Ð,¤9Ø×,Ð,¤9Ü8Ø'+õ	ð
 	ñ(ð
 !'ñ(ð (r"   rå   )rq   Úcompiler_fnT)r”   r—   Úaot_eager_default_partitionerc          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   r!   À  sH   € ÷ "ñ "Ü�‰×Ñð"Ü26´u·|±|Õ2Dð"ÜPSð"äˆc”3ˆhÕñ"r"   c                 ó   € V'       d   \         P                  R V4       ^ RIHp RR/pVP	                  R4      ;p'       d   VP                  V4       \        P                  ! V4      ;_uu_ 4        \        \        4       \        4       R \        P                  ! \        RR7      R7      ! W4      uuR	R	R	4       #   + '       g   i     R	# ; i)
z;aot_eager_decomp_partition backend ignoring extra kwargs %s)ÚCompilerBisectorÚunlift_effect_tokensTÚaot_eager_decomp_partitionc                  ó4   € \        R 4      P                  4       # ©ztorch._inductor.compile_fx©r   Úselect_decomp_tablerE   r"   r    Ú<lambda>Ú,aot_eager_decomp_partition.<locals>.<lambda>Ö  s   € ¤=Ø,ó$ç!Ñ!Ó#ð$$r"   Úinductor©Úcompiler©r”   r•   Údecompositionsr–   N)r%   r&   Ú!torch._inductor.compiler_bisectorr  Úget_config_changeÚupdaterì   Úpatchr   r  r  r  r   )r   r   r   r  Úconfig_patchesÚbisect_changess   &&,   r    r  r  À  s«   € ÷ Ü�‰ØIÈ6ô	
õ Cà,¨dÐ3€NØ)×;Ñ;Ø$óð €~ö ð 	×Ñ˜nÔ-ä	×	Ò	 ×	/Õ	/Üä$›Ü$›ñ$ô #×*Ò*Ü3¸jôõ
ð ó"÷ 
0×	/×	/Ó	/ús   Á1A B<Â<C	r  c                óÀ   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\
        R\        R\
        3,          /# )r   r   r   r-   Úkwargr   .r   )r   s   "r    r!   r!   æ  sV   € ÷ ñ Ü�‰×ÑðäœUŸ\™\Õ*ðô ðô ð	ô
 ˆc”3ˆhÕñr"   c           
      óÊ   € \        \        P                  ! \        VR 7      \        P                  ! \        VR 7      R \        P                  ! \        RR7      R7      ! W4      # )r3   c                  ó4   € \        R 4      P                  4       # r   r!  rE   r"   r    r#  Ú6aot_eager_decomp_partition_with_mode.<locals>.<lambda>ñ  s   € œ}Ø(ó 
ç
Ñ
Ó
ð  r"   r%  r&  r(  )r   r  r  rø   r   )r   r   r-   r1  s   &&&,r    Ú$aot_eager_decomp_partition_with_moder5  æ  sW   € ô ä×%Ò%Ô&9ÀÔEÜ×%Ò%Ô&9ÀÔEñ ô ×&Ò&Ü/¸*ô
õð 	óð r"   r5  c          
      ó´   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\
        R\        R\
        3,          /# r   r   )r   s   "r    r!   r!      sN   € ÷ Lñ LÜ�‰×ÑðLÜ26´u·|±|Õ2DðLÜPSðLäˆc”3ˆhÕñLr"   c                 óæ   € \         P                  '       g   R M\         P                  p\         P                  ! VR7      ;_uu_ 4        \        W3/ VB uuRRR4       #   + '       g   i     R# ; i)r  )r  N)rì   r  r-  r  )r   r   r   Ú
config_vals   &&, r    Ú#aot_eager_decomp_partition_crossrefr9     sS   € ô  ×4×4Ð4ñ 	ä×2Ñ2ð ô
 
×	Ò	°Z×	@Ö	@Ü)¨"ÑKÀFÑK÷ 
A×	@×	@Ó	@ús   ÁAÁA0	r9  )r”   Úaot_tsc                   ó   € ] tR tRtRtR# )ÚReluCompileErrori  rE   N©rÒ   rÓ   rÔ   rÕ   rÚ   rE   r"   r    r<  r<    ó   † Ûr"   r<  c                   ó   € ] tR tRtRtR# )ÚTestingOnlyCompileErrori#  rE   Nr=  rE   r"   r    r@  r@  #  r>  r"   r@  c                ó¶   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P                  P                  /# ©r   r   r}   r   ©r   r   r   r   r   )r   s   "r    r!   r!   (  sA   € ÷ ñ Ü�‰×ÑðÜ.2´5·<±<Õ.@ðä
‡X�X×Ññr"   c                 óˆ   € V P                   P                   F'  pVP                  \        P                  J g   K#  \
        h	  V # r1   )r°   r±   Útargetr   Úrelur<  ©r   r}   r¶   s   && r    Úrelu_compile_error_TESTING_ONLYrH  '  s3   € ð —‘—”ˆØ�;‰;œ%Ÿ*™*Õ$Ü"Ð"ñ ð €Ir"   c                ó¶   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P                  P                  /# rB  rC  )r   s   "r    r!   r!   2  sA   € ÷ ñ Ü�‰×ÑðÜ.2´5·<±<Õ.@ðä
‡X�X×Ññr"   c                 óØ   € V P                   P                   F?  pVP                  \        P                  J g   K#  \        P
                  Vn        RVn        KA  	  V P                  4        V # )F)FÚReluRuntimeError)r°   r±   rE  r   rF  Ú_assertr=   rÇ   rG  s   && r    Úrelu_runtime_error_TESTING_ONLYrM  1  sH   € ð —‘—”ˆØ�;‰;œ%Ÿ*™*Õ$ÜŸ-™-ˆDŒKØ3ˆDŽIñ ð ‡L�L„NØ€Ir"   c                ó¶   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P                  P                  /# rB  rC  )r   s   "r    r!   r!   >  sA   € ÷ 	ñ 	Ü�‰×Ñð	Ü.2´5·<±<Õ.@ð	ä
‡X�X×Ññ	r"   c                 óþ   € V P                   P                   FR  pVP                  \        P                  J g   K#  \        P
                  Vn        VP                  ^ ,          ^3Vn        KT  	  V P                  4        V # )rv   )r°   r±   rE  r   rF  Úaddr=   rÇ   rG  s   && r    Ú relu_accuracy_error_TESTING_ONLYrQ  =  sU   € ð —‘—”ˆØ�;‰;œ%Ÿ*™*Õ$ÜŸ)™)ˆDŒKØŸ™ 1� qÐ)ˆDŽIñ ð ‡L�L„Nà€Ir"   c                ó¶   € V ^8„  d   QhR\         P                  P                  R\        \         P                  ,          R\         P                  P                  /# rB  rC  )r   s   "r    r!   r!   K  sA   € ÷ ñ Ü�‰×ÑðÜ.2´5·<±<Õ.@ðä
‡X�X×Ññr"   c                 ó¬   € V P                   P                   F  pVP                  R 8X  g   K   M	  V # V F  pVP                  '       d   K  \        h	  V # )Úcall_function)r°   r±   r  Úis_leafr@  )r   r}   r¶   Úts   &&  r    Ú#non_leaf_compile_error_TESTING_ONLYrW  J  sL   € ð —‘—”ˆØ�7‰7�oÖ%Ùñ ð ˆ	ÛˆØ�y�yŠyÜ)Ð)ñ ð €Ir"   c                   óN   a € ] tR tRt o RtRtRtRtV 3R lR ltV 3R lt	Rt
V tR# )ÚExplainOutputi[  zi
This is the output of :func:`torch._dynamo.explain()`
There is no reason to create this class directly.
Nc                ó    <€ V ^8„  d   QhRS[ /# ©r   r   )Ústr)r   rŸ   s   "€r    r!   ÚExplainOutput.__annotate__k  s   ø€ ÷ ñ ™ñ r"   c                ó<  € R V P                    R2pVRV P                   R2,          pVRV P                   R2,          pVR,          p\        V P                  4       FY  w  r#VRV^,            R2,          pVRVP
                   R2,          pVR,          pVP                   F  pVR	V R2,          pK  	  K[  	  V P                  eR   VR
,          p\        V P                  4       F/  w  r%VRV^,            R2,          pV F  pVRV R2,          pK  	  K1  	  V P                  eQ   VR,          p\        V P                  4       F.  w  rxVRV^,            R2,          pVR\        V4       2,          pK0  	  V P                  e   VRV P                   R2,          pV# )zGraph Count: Ú
zGraph Break Count: z
Op Count: zBreak Reasons:
z  Break Reason z:
z    Reason: z    User Stack:
z      zOps per Graph:
z  Ops z    zOut Guards:
z  Guard zCompile Times: )Úgraph_countÚgraph_break_countÚop_countÚ	enumerateÚbreak_reasonsÚreasonÚ
user_stackÚops_per_graphÚ
out_guardsr\  Úcompile_times)	r¤   ÚoutputÚidxÚbreak_reasonÚframe_summaryÚopsr  ÚiÚguards	   &        r    Ú__str__ÚExplainOutput.__str__k  s²  € Ø  ×!1Ñ!1Ð 2°"Ð5ˆØÐ'¨×(>Ñ(>Ð'?¸rÐBÕBˆØ�J˜tŸ}™}˜o¨RÐ0Õ0ˆàÐ$Õ$ˆÜ!*¨4×+=Ñ+=Ö!>ÑˆCØ˜¨¨a­ y°Ð4Õ4ˆFØ˜ \×%8Ñ%8Ð$9¸Ð<Õ<ˆFØÐ)Õ)ˆFØ!-×!8Ô!8�Ø˜F = /°Ð4Õ4’ó "9ñ	 "?ð ×ÑÒ)ØÐ(Õ(ˆFÜ% d×&8Ñ&8Ö9‘�Ø˜F 3¨¥7 )¨3Ð/Õ/�Û�BØ  R D¨˜mÕ+’Fó ñ :ð
 �?‰?Ò&Ø�oÕ%ˆFÜ% d§o¡oÖ6‘�Ø˜H Q¨¥U G¨3Ð/Õ/�Ø˜D¤ U£ Ð-Õ-’ñ 7ð ×ÑÒ)Ø˜¨×(:Ñ(:Ð';¸2Ð>Õ>ˆFØˆr"   c                ó.  <€ V ^8„  d   Qh/ S[ S[P                  P                  ,          ;R&   S[;R&   S[;R&   S[ S[,          ;R&   S[;R&   S[ S[ R,          ,          R,          ;R&   S[ S[P                  ,          R,          ;R	&   S[R,          ;R
&   # )r   Úgraphsr`  ra  rd  rb  r   Nrg  rh  ri  )	r   r   r   r   Úintr	   r   ÚGuardr\  )r   rŸ   s   "€r    r!   r]  [  s¡   ø‡ ‚ ñ ‘—‘×%Ñ%Õ&Ñ&ñ ñ Ññ ñ Ññ ñ Ñ*Õ+Ñ+ñ ñ �Mñ ñ ™˜X�Õ'¨$Õ.Ñ5ñ ñ ‘W—]‘]Õ# dÕ*Ñ1ñ ñ ˜•:Ñ$ò r"   rE   )rÒ   rÓ   rÔ   rÕ   rÖ   rg  rh  ri  rq  rÙ   rÚ   rÛ   rÜ   s   @r    rY  rY  [  s,   ø‡ € ñð 26€MØ-1€JØ $€M÷ð ÷! ƒ r"   rY  c                óà  € V ^8„  d   QhR\         P                  P                  R\        \         P                  P                  ,          R\        R\        \        R,          ,          R\        \
        ,          R\        \         P                  P                  \        \         P                  P                  ,          \        \        \        R,          ,          \        \
        ,          3,          /# )r   r   rt  rb  rg  r   rd  r   )r   r   r   r   ru  r	   Útuple)r   s   "r    r!   r!   Š  s­   € ÷ %>ñ %>Ü�‰×Ñð%>ä”—‘×%Ñ%Õ&ð%>ô ð%>ô œ˜X�Õ'ð	%>ô
 Ô*Õ+ð%>ô Ü	‡H�H×ÑÜŒ�‰×	Ñ	ÕÜÜŒˆh�ÕÜÔ	Õð	õñ%>r"   c                ón  € VP                  V 4       V P                  P                   Uu. uF!  qUP                  R8X  g   K  VP                  NK#  	  ppV\        V4      ,          pVP                  V4       V P                  P                  '       d   VP                  V P                  4       WW#V3# u upi )ap  
This function is a utility which processes a torch.fx.GraphModule and
accumulates information about its ops, graph breaks, and other details. It
is intended to be used by the ExplainWithBackend class and
`torch._dynamo.explain()` to provide details from Dynamo's graph capture.

Parameters:
    gm (torch.fx.GraphModule): The GraphModule to be processed.
    graphs (list): A list that accumulates all the GraphModules processed.
    op_count (int): The total count of operations in all GraphModules processed so far.
    ops_per_graph (list): A list that accumulates the operations of each GraphModule.
    break_reasons (list): A list that accumulates the reasons for breaks in each GraphModule.

Returns:
    tuple: A tuple containing the processed GraphModule, the updated lists of graphs,
           operations per graph, and break reasons, and the updated operation count.
rT  )Úappendr°   r±   r  rE  ÚlenÚcompile_subgraph_reasonÚgraph_break)r   rt  rb  rg  rd  r¶   rn  s   &&&&&  r    Ú_explain_graph_detailr~  Š  s�   € ð< ‡M�M�"ÔØ#%§8¡8§>¢>Ó
P¡>˜4·W±WÀÑ5OŒ;ˆ4�;Œ;¡>€CÐ
PØ”�C“Õ€HØ×Ñ˜ÔØ	×!Ñ!×-×-Ð-Ø×Ñ˜R×7Ñ7Ô8à�x°Ð=Ð=ùò Qs   ªB2ÁB2c                   óZ   a € ] tR tRt o R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	R
# )ÚExplainWithBackendi²  a3  
This class is intended to be used as a backend for `torch.compile`. It is
composable with other backends. When used in this way, it accumulates
information about graph breaks, ops, and other info and provides a string
representation summarizing this information.

Attributes:
    backend (str): The name of the backend to use for optimization.
    graphs (list): A list of the graphs captured by TorchDynamo.
    op_count (int): The total number of operations in all optimized graphs.
    break_reasons (list): A list of graph break reasons with stack traces.

Example Usage:
    def fn(x):
        x = torch.sigmoid(x)
        return x

    torch._dynamo.reset()
    eb = ExplainWithBackend("inductor")
    optimized_fn = torch.compile(fn, backend=eb)
    result = optimized_fn(torch.randn(5))
    print(eb.output())
c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   ræ   r   N)r   r\  )r   rŸ   s   "€r    r!   ÚExplainWithBackend.__annotate__Ë  s    ø€ ÷ :ñ :¡
©SÕ 0ð :°Tñ :r"   c                óV   € ^RI Hp V! V4      V n        . V n        ^ V n        . V n        R# )é   )Úlookup_backendN)Úregistryr…  ræ   rt  rb  rd  )r¤   ræ   r…  s   && r    Ú__init__ÚExplainWithBackend.__init__Ë  s'   € Ý,á% gÓ.ˆŒØ24ˆŒØˆŒØ79ˆÖr"   c                óx   <€ V ^8„  d   QhRS[ P                  P                  RS[S[ P                  ,          RS[/# rB  )r   r   r   r   r   r   )r   rŸ   s   "€r    r!   r‚  Ó  s8   ø€ ÷ 0ñ 0Ù—(‘(×&Ñ&ð0Ù8<¹U¿\¹\Õ8Jð0á	ñ0r"   c                ó¤   € . p\        WP                  V P                  W0P                  4      w  qn        V n        q@n        V P	                  W4      # r1   )r~  rt  rb  rd  ræ   )r¤   r   r}   rg  Ú_s   &&&  r    r¥   ÚExplainWithBackend.__call__Ó  sH   € ð -/ˆÜ@UØ—‘˜TŸ]™]¨M×;MÑ;MóA
Ñ=ˆŒK˜œ¨Ô+=ð �|‰|˜BÓ/Ð/r"   c                ó    <€ V ^8„  d   QhRS[ /# r[  )rY  )r   rŸ   s   "€r    r!   r‚  Ü  s   ø€ ÷ 
ñ 
™ñ 
r"   c                ó˜   € \        V P                  4      p\        V P                  VV^,
          V P                  V P                  4      pV# )r„  )r{  rt  rY  rd  rb  )r¤   r`  rj  s   &  r    rj  ÚExplainWithBackend.outputÜ  sB   € Ü˜$Ÿ+™+Ó&ˆÜØ�K‰KØØ˜!�OØ×ÑØ�M‰Mó
ˆð ˆr"   )ræ   rd  rt  rb  N)
rÒ   rÓ   rÔ   rÕ   rÖ   r‡  r¥   rj  rÚ   rÛ   rÜ   s   @r    r€  r€  ²  s(   ø‡ € ñ÷0:ð :÷0ð 0÷
ö 
r"   r€  r1   )NN)ErÖ   r×   r  ÚloggingÚcollections.abcr   r   Ú	importlibr   Útypingr   r   r   Úfunctorch.compiler   r   Útorch._dynamo.output_graphr	   Útorch._functorchr
   rì   Útorch._functorch.compilersr   Útorch._inductor.output_coder   Úcommonr   r†  r   r   r   Úregister_backendÚtorch.fx.noder   Ú	getLoggerrÒ   r%   r+   r4   r2   rV   rf   ro   rz   r�   r˜   Ú	dataclassrš   rï   rø   r  r  r  rå   r  r  r5  r9  r:  rO   r<  r@  rH  rM  rQ  rW  rY  r~  r€  rE   r"   r    Ú<module>rž     sE  ðñó2 Û Û ß .Ý #ß %ã Ý AÝ Ý 9Ý 7Ý 1Ý 2å  ß XÑ X÷ Ý$ð ×Ò˜Ó!€ð ô
ó ð
õ@õð, ôó ðð& ôó ðð" ôó ðñ$ �tÔô;ó ð;õ#ðD/ðd ôó ðð4 ×Ñô.˜ó .ó ð.õdõ<÷.õ,5õX÷$(ñ �k¨yÕ 9á ,Ø¸$ô!Ð ñ Ø	(Ð6Sõõ"ñ> Ø	%Ð3Mõõñ( Ø	/Ø4õõLñ Ø	.Ø3õñ 
 *Ô	-€Ù �h¨FÕ 3ô	�yô 	ô	˜iô 	ð ôó ðð ôó ðð ô	ó ð	ð ôó ðð  ×Ñ÷+ð +ó ð+õ\%>÷P4ó 4r"   