
    ȅi[                        S r SSKrSSKJrJrJrJrJrJr  SSK	J
r
JrJr  SSKJrJrJr  SSKJr  SSKJr  SS	KJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  SS
KJ)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  SSK:J;r;J<r<J=r=J>r>J?r?J@r@  SSKAJBrC  / SQrD\R                  R                  \R                  R&                  R                  /5        \R                  \R                  R                  L aU  SSKKr\R                  " \R                  5      \lI        \R                  R                  R                  \R                  S5        SS jrPSS jrQS\R4S jrSS\RSS4S jrTg)a  
TorchDynamo is a Python-level JIT compiler designed to make unmodified PyTorch programs faster.
TorchDynamo hooks into the frame evaluation API in CPython (PEP 523) to dynamically modify Python
bytecode right before it is executed. It rewrites Python bytecode in order to extract sequences of
PyTorch operations into an FX Graph which is then just-in-time compiled with a customizable backend.
It creates this FX Graph through bytecode analysis and is designed to mix Python execution with
compiled backends to get the best of both worlds: usability and performance. This allows it to
seamlessly optimize PyTorch programs, including those using modern Python features.
    N   )aot_compileconfigconvert_frame
eval_framefunctional_exportresume_execution)list_backendslookup_backendregister_backend)callback_handleron_compile_endon_compile_start)code_context)replay)allow_in_graphassume_constant_resultdisabledisable_nested_graph_breaksdisallow_in_graphdont_skip_tracingerror_on_graph_breakforbid_in_graphgraph_breakis_dynamo_disable_recursivemark_dynamicmark_staticmark_static_addressmaybe_mark_dynamicnonstrict_tracepatch_dynamo_configrun
set_stance
skip_framestep_unsupportedsubstitute_in_graph)	_reset_guarded_backend_cacheexplainexportis_dynamo_supportedis_inductor_supportedoptimizeoptimize_assertOptimizedModule
reset_code)is_compiling)GenerationTracker)reset_code_state)TensorifyState)graph_break_reasonsguard_failuresorig_code_map(register_hook_for_recompile_user_contextreset_frame_countreset_recompile_user_contexts)loader)#r   r   r   r   r   r   r   r)   r(   r   r   r0   r   r
   r   r   r   r   r   r    r,   r-   r.   r!   r   r   resetr9   r"   r   set_recursion_limitr#   r$   r%   r&   zaten::manual_seedreturnc                  x   SSK n U R                  [        5      nUR                  S5        [        R
                     [        5         [        R                  R                  5         [        5         [        R                  R                  5         [        R                  " 5         [        R                  " 5         [        R                  " 5         [        R                  R                   R                  5         [#        5         [%        5         [&        R(                  R*                  R-                  5         S[        l        [        R0                  R                  5         [2        R                  " 5         [4        R                  " 5         [6        R                  " 5         [&        R(                  R8                  R:                  R                  5         [&        R<                  R>                  RA                  S5        [&        RB                  RE                  5       (       a  SSK#J$n  U" 5         SSS5        g! , (       d  f       g= f)a  
Clear all compile caches and restore initial state.  This function is intended
to reset Dynamo's state *as if* you had started a fresh process invocation, which
makes it good for testing scenarios where you want to behave as if you started
a new process.  It does NOT affect any file system caches.

NB: this does NOT reset logging state.  Don't use this to test logging
initialization/reinitialization.
r   Nztorch._dynamo.resetF)reset_cudagraph_trees)%logging	getLogger__name__infor   compile_lockreset_code_cachesinput_codesclearr2   output_codesr6   r5   r4   r	   ContinueExecutionCachecacher'   r8   torch_dynamocompiled_autogradr;   FRAME_COUNTERFRAME_COMPILE_COUNTERr   r1   r3   utilswarn_once_cache_C	_autograd _saved_tensors_hooks_set_tracingcudais_availabletorch._inductor.cudagraph_treesr?   )r@   logr?   s      P/home/james-whalen/.local/lib/python3.13/site-packages/torch/_dynamo/__init__.pyr;   r;      sW    


H
%CHH"#		#	#!!'')""((*!!#//55;;=$&''--/&'#++113 !++113;;EB ::""$$M!#3 
$	#	#s   G'H++
H9c                     SSK n U R                  [        5      nUR                  S5         [        R
                     [        5         [        R                  R                  [        R                  R                  -    H  nU" 5       nU(       d  M  [        U5        M      [        R                  " 5         SSS5        g! , (       d  f       g= f)z
Clears in-memory code cache, which is what stores compiled products.  This
resets less state than :func:`reset` and is mostly only used for testing
purposes.
r   Nztorch._dynamo.reset_code_caches)r@   rA   rB   rC   r   rD   r2   rF   seenrH   r/   r   rG   )r@   rX   	weak_codecodes       rY   rE   rE      s     


H
%CHH./=		#	#%%**]-G-G-L-LL  ;Dt4 	 M
 	 
$	#	#s   AB<$B<<
C
c                  f    [         R                  R                  R                  R	                  5       $ )z
Returns the internal dynamo recursion limit set by `torch._dynamo.set_recursion_limit`.

Returns -1 if no c recursion limit has been set.
)rK   rR   rL   r   get_c_recursion_limit     rY   get_recursion_limitrb      s#     88&&<<>>ra   limitc                 j    [         R                  R                  R                  R	                  U 5        g)ao  
Sets an internal dynamo recursion limit. The limit must be >= 1, or -1 to reset
to the default (unset) state.

This is possibly needed in Python 3.12-3.13 since there is a separate C recursion limit
that is not visible at the Python level. If you are getting RecursionErrors during
Dynamo compilation and `sys.setrecursionlimit()` doesn't help, this function may alleviate
the issue.

NOTE: this function does NOT call `sys.setrecursionlimit()` - the user is expected to manually
    call this if required. This is because the 2 recursion limits are not sync'd up - e.g. in
    Python 3.12, functions can be inline-evaluated, which apparently doesn't use up the C stack.

WARNING: increasing the recursion limit to an arbitrary large value may cause segfaults
    due to stack overflows! You can try also try to manually increase the stack size, e.g.
    with `$ ulimit -s ...`
N)rK   rR   rL   r   set_c_recursion_limit)rc   s    rY   r<   r<      s"    $ 
HH55e<ra   )r=   N)U__doc__rK    r   r   r   r   r   r	   backends.registryr
   r   r   callbackr   r   r   r   r   
decoratorsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   external_utilsr0   mutation_guardr1   pgor2   symbolic_convertr3   rP   r4   r5   r6   r7   r8   r9   	polyfillsr:   ___all__serializationadd_safe_globalsrL   	_DimRangemanual_seedrandomtorch.jit._builtins_disable_dynamojit	_builtins_register_builtinr;   rE   intrb   r<   r`   ra   rY   <module>r}      s*     O N H H & !     .
 
 
 ) - ! ,  #$N    $ $emm&>&>&H&H%I J000 --e.?.?@E	II))%*;*;=PQ($V.?S ?=s =t =ra   