+
    Nåûjøq ã                  ó  a € 0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHtHtHtHtHt ^ RIHtHtHt ^ RIt^ RIHt ^ RIHt  ^ R	IHtHt ]'       d$   ^ R
I H!t!H"t" ^ RI#H$t$ ^ RI%H&t& ]!]",          t'R](R&   M]P                  t'R](R&   ^RI)H*t* . R^Ot+]! R4      t,]! R4      t-R R lt.R R lt/]0! ]Pb                  R4      '       g^   ]*! R4      ]Pb                  Pd                  R&   ]*! R4      ]Pb                  Pd                  R&   ]*! R4      ]Pb                  Pd                  R&   ^ RI3H4t4H5t5H6t6 R R lt7R R  lt8R! R" lt9 ! R# R$4      t:]	! 4       t;R%](R&&   ]	! 4       t<R%](R'&   ]	! 4       t=R%](R(&   ]	! 4       t>R%](R)&   ]	! 4       t?R%](R*&   R+ R, lt@R- R. ltAR/ R0 ltBR1 R2 ltCR3 R4 ltDR5 R6 ltER7 R8 ltF]	! 4       tGR9](R:&   R; R< ltHR= R> ltI ! R? R]54      tJ ! R@ RA]P–                  4      tLRB RC ltMRDRE/RF RG lltNRDRE/RH RI lltORJ RK ltPRLR_RMR`RNRaRORb/tQRP](RQ&   RR RS ltR ! RT R4      tS]RU]RV]T3,          3,          tUR](RW&   ]RcRX RY ll4       tV]RcRZ R[ ll4       tVRcR\ R] lltVR#   ] d	    RtRt EL&i ; i)dé    )ÚannotationsN)ÚOrderedDict)ÚCallable)ÚAnyÚoverloadÚTYPE_CHECKINGÚ	TypeAliasÚ	TypeGuardÚUnion)Ú	ParamSpecÚSelfÚTypeVar)ÚTensor)Ú_check_cuda_bindings)ÚdriverÚruntime)Ú_POOL_HANDLEÚMemPool©Ú_CUDAGraphInputLivenessTracker©ÚRemovableHandler	   Ú
_GraphPool)Ú_dummy_typeÚ	CUDAGraphÚgraphÚ_RÚ_Pc               ó    € V ^8„  d   QhRRRR/# )é   ÚpoolÚobjectÚreturnzTypeGuard[MemPool]© )Úformats   "ÚMC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\cuda\graphs.pyÚ__annotate__r'   ?   s   € ÷ Eñ E�vð EÐ"4ñ Eó    c                óf   € \        \        P                  R R4      pVRJ;'       d    \        W4      # )r   N)ÚgetattrÚtorchÚcudaÚ
isinstance)r!   Úmempool_clss   & r&   Ú_is_mem_poolr/   ?   s,   € Üœ%Ÿ*™* i°Ó6€KØ˜dÐ"×DÐD¤z°$Ó'DÐDr(   c               ó    € V ^8„  d   QhRRRR/# )r    r!   ú_GraphPool | Noner#   z_POOL_HANDLE | Noner$   )r%   s   "r&   r'   r'   D   s   € ÷ -ñ -Ð(ð -Ð-@ñ -r(   c                ó    € V f   R # \        V 4      '       d"   \        P                  ! RV P                  4      # \        P                  ! RV 4      # )Nr   )r/   ÚtypingÚcastÚid)r!   s   &r&   Ú_get_pool_idr6   D   s;   € Ø‚|ÙÜ�D×ÒÜ�{Š{˜>¨4¯7©7Ó3Ð3Ü�;Š;�~ tÓ,Ð,r(   Ú_CudaStreamBaseÚ
_CUDAGraphÚ_graph_pool_handleÚ_cuda_isCurrentStreamCapturing)r:   r8   r9   c               ó   € V ^8„  d   QhRR/# )r    r#   Úboolr$   )r%   s   "r&   r'   r'   W   s   € ÷ ,ñ , Tñ ,r(   c                 ó   € \        4       # )zÄReturn True if CUDA graph capture is underway on the current CUDA stream, False otherwise.

If a CUDA context does not exist on the current device, returns False without initializing the context.
)r:   r$   r(   r&   Úis_current_stream_capturingr>   W   s   € ô
 *Ó+Ð+r(   c               ó   € V ^8„  d   QhRR/# ©r    r#   r   r$   )r%   s   "r&   r'   r'   `   s   € ÷ 9ñ 9˜<ñ 9r(   c                 óP   € \         P                  P                  \        4       4      # )zÊReturn an opaque token representing the id of a graph memory pool.

See :ref:`Graph memory management<graph-memory-management>`.

.. warning::
    This API is in beta and may change in future releases.
)r+   r,   r   r9   r$   r(   r&   Úgraph_pool_handlerB   `   s   € ô �:‰:×"Ñ"Ô#5Ó#7Ó8Ð8r(   c               ó   € V ^8„  d   QhRR/# ©r    r#   ÚNoner$   )r%   s   "r&   r'   r'   k   s   € ÷ 

ñ 

 ñ 

r(   c                 ó,   € \         f   \        R4      hR# )zœRaise a uniform error if the cuda-bindings package is unavailable.

``_cuda_runtime`` and ``_cuda_driver`` are imported together, so checking one
suffices.
NzcThis CUDAGraph API requires the cuda-bindings package; install it with `pip install cuda-bindings`.)Ú_cuda_runtimeÚRuntimeErrorr$   r(   r&   Ú_require_cuda_bindingsrI   k   s!   € ô ÒÜð;ó
ð 	
ñ r(   c                  ó2   € ] tR t^xtRtR R ltR R ltRtR# )Ú_RetainedCallbacksa  Holds destroy callbacks and retained objects for a single capture cycle
of a :class:`CUDAGraph`.

A :class:`CUDAGraph` owns one of these and arms a :func:`weakref.finalize`
bound to :meth:`fire`. The holder deliberately does NOT reference the graph,
so the finalizer cannot keep the graph alive; :meth:`fire` can still sync the
replay streams because they are mirrored onto the holder, not read off the
graph. Callbacks and objects live in ``OrderedDict``s keyed by
``RemovableHandle`` id so registrations can be individually removed.
c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   Ú_RetainedCallbacks.__annotate__„   s   € ÷ 
"ñ 
"˜$ñ 
"r(   c                	ó|   € \        4       V n        \        4       V n        \        4       V n        R V n        R V n        R# ©FN)r   Ú	callbacksÚobjectsÚsetÚreplay_streamsÚsync_before_fireÚ_fired©Úselfs   &r&   Ú__init__Ú_RetainedCallbacks.__init__„   s/   € Ü?J»}ˆŒÜ1<³ˆŒô 7:³eˆÔØ&+ˆÔØ!ˆŽr(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   rM   �   s   € ÷ ñ �dñ r(   c                	ó¼  € V P                   '       d   R # RV n         V P                  '       d%   V P                   F  p VP                  4        K  	  \        V P                  P                  4       4       F  p V! 4        K  	  V P                  P                  4        V P                  P                  4        R #   \         d     KŽ  i ; i  \         d     Ke  i ; i)NT)
rU   rT   rS   ÚsynchronizeÚ	ExceptionÚlistrP   ÚvaluesÚclearrQ   )rW   ÚstreamÚcbs   &  r&   ÚfireÚ_RetainedCallbacks.fire�   sµ   € à�;�;ˆ;ÙØˆŒØ× × Ð ð ×-Ô-�ðØ×&Ñ&Ö(ñ .ô
 �t—~‘~×,Ñ,Ó.Ö/ˆBðÙ–ñ 0ð
 	�‰×ÑÔØ�‰×ÑÖøô !ô Úðûô
 ô Úðús#   ¾B:Á9CÂ:C	ÃC	ÃCÃC)rU   rP   rQ   rS   rT   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rX   rc   Ú__static_attributes__r$   r(   r&   rK   rK   x   s   † ñ	õ
"÷ñ r(   rK   ú-OrderedDict[int, Callable[[CUDAGraph], None]]Ú_global_capture_start_hooksÚ_global_capture_end_hooksÚ_global_instantiate_hooksÚ_global_replay_start_hooksÚ_global_replay_end_hooksc               ó$   € V ^8„  d   QhRRRRRR/# )r    Úregistryrk   ÚfnúCallable[[CUDAGraph], None]r#   r   r$   )r%   s   "r&   r'   r'   ¸   s&   € ÷ ñ Ø;ðà#ðð ñr(   c                ó>   € ^ RI Hp V! V 4      pWVP                  &   V# )r   r   )Útorch.utils.hooksr   r5   )rr   rs   r   Úhandles   &&  r&   Ú_register_global_hookrx   ¸   s"   € õ 2á˜XÓ&€FØˆV�Y‰YÑØ€Mr(   c               ó$   € V ^8„  d   QhRRRRRR/# )r    rr   rk   Útorch_cuda_graphr   r#   rE   r$   )r%   s   "r&   r'   r'   Ã   s&   € ÷ ñ Ø;ðàðð 
ñr(   c                ó|   € \        V P                  4       4       F  p V! V4       K  	  R #   \         d     K   i ; i©N)r^   r_   r]   )rr   rz   rs   s   && r&   Ú_run_global_hooksr}   Ã   s<   € ô �8—?‘?Ó$Ö%ˆð	ÙÐÖ ó &øô ô 	Úð	ús   ž,¬;º;c               ó    € V ^8„  d   QhRRRR/# ©r    rs   rt   r#   r   r$   )r%   s   "r&   r'   r'   Î   s    € ÷ Bñ BØ#ðBàñBr(   c                ó"   € \        \        V 4      # )aè  Register a hook run with each CUDA graph as its capture begins. Returns a
RemovableHandle; call ``.remove()`` to unregister.

.. warning::
    The hook runs with capture already live on the current stream, so it must not issue
    CUDA work: anything it launches is captured into the graph, and under the default
    ``"global"`` capture error mode an unsafe call (e.g. an allocation) raises. Querying
    capture state is fine. Do preparation that needs CUDA before the capture instead.
)rx   rl   ©rs   s   &r&   Ú!register_graph_capture_start_hookr‚   Î   s   € ô !Ô!<¸bÓAÐAr(   c               ó    € V ^8„  d   QhRRRR/# r   r$   )r%   s   "r&   r'   r'   Ý   s    € ÷ @ñ @Ø#ð@àñ@r(   c                ó"   € \        \        V 4      # )zàRegister a hook run with each CUDA graph when its capture ends, while the captured
``cudaGraph_t`` is still live (see :meth:`CUDAGraph.register_capture_end_hook`). Returns a
RemovableHandle; call ``.remove()`` to unregister.)rx   rm   r�   s   &r&   Úregister_graph_capture_end_hookr…   Ý   s   € ô !Ô!:¸BÓ?Ð?r(   c               ó    € V ^8„  d   QhRRRR/# r   r$   )r%   s   "r&   r'   r'   æ   s    € ÷ @ñ @Ø#ð@àñ@r(   c                ó"   € \        \        V 4      # )z…Register a hook run with each CUDA graph right after it is instantiated. Returns a
RemovableHandle; call ``.remove()`` to unregister.)rx   rn   r�   s   &r&   Úregister_graph_instantiate_hookrˆ   æ   s   € ô
 !Ô!:¸BÓ?Ð?r(   c               ó    € V ^8„  d   QhRRRR/# r   r$   )r%   s   "r&   r'   r'   î   s    € ÷ 
Añ 
AØ#ð
Aàñ
Ar(   c                ó"   € \        \        V 4      # )aN  Register a hook run with each CUDA graph at the start of every replay, just before it
is launched. Returns a RemovableHandle; call ``.remove()`` to unregister.

.. note::
    Replay is the hot path and this fires for EVERY graph on EVERY replay -- keep it
    cheap. With nothing registered the cost is a single dict emptiness check.
)rx   ro   r�   s   &r&   Ú register_graph_replay_start_hookr‹   î   s   € ô !Ô!;¸RÓ@Ð@r(   c               ó    € V ^8„  d   QhRRRR/# r   r$   )r%   s   "r&   r'   r'   û   s   € ÷ ?ñ ?Ø#ð?àñ?r(   c                ó"   € \        \        V 4      # )ar  Register a hook run with each CUDA graph at the end of every replay, once the replay is
*enqueued* (the launch is asynchronous, so the GPU work has not completed). Fires even if
the launch raised, so a start hook is always balanced by an end. Returns a RemovableHandle;
call ``.remove()`` to unregister. See the hot-path note on
:func:`register_graph_replay_start_hook`.)rx   rp   r�   s   &r&   Úregister_graph_replay_end_hookrŽ   û   s   € ô !Ô!9¸2Ó>Ð>r(   z,OrderedDict[int, Callable[[set[int]], None]]Ú_global_destroy_hooksc               ó    € V ^8„  d   QhRRRR/# )r    rs   zCallable[[set[int]], None]r#   r   r$   )r%   s   "r&   r'   r'     s   € ÷ ñ Ð$>ð À?ñ r(   c                óP   € ^ RI Hp V! \        4      pV \        VP                  &   V# )zuRegister ``fn(graph_ids)`` to run when a CUDA graph is destroyed. Returns a handle whose
``remove()`` unregisters it.r   )rv   r   r�   r5   )rs   r   rw   s   &  r&   Úregister_graph_destroy_hookr’     s&   € õ 2áÔ2Ó3€FØ')Ô˜&Ÿ)™)Ñ$Ø€Mr(   c               ó    € V ^8„  d   QhRRRR/# )r    Ú	graph_idsúset[int]r#   rE   r$   )r%   s   "r&   r'   r'     s   € ÷ ñ ¨ð °Tñ r(   c                ó„   € \        \        P                  4       4       F  p V! V 4       K  	  R#   \         d     K   i ; i)zåInvoke every registered hook with the destroyed graph ids, swallowing per-hook
errors so one failure does not abort the rest (matching the destroy-callback fire
semantics). The single entry point a graph's destroy callback calls.N)r^   r�   r_   r]   )r”   rs   s   & r&   Ú_run_graph_destroy_hooksr—     s=   € ô Ô(×/Ñ/Ó1Ö2ˆð	ÙˆyŽMó 3øô ô 	Úð	ús   ¢0°?¾?c                  ót  a € ] tR tRt$ Rt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]R&   R]R&   RWR V 3R llltR R  ltR! R" ltR# R$ lt	R% R& lt
R' R( ltR) R* ltR+R/R, R- lltR+R/R. R/ lltR0 R1 ltR2 R3 ltR4 R5 ltRXR6 V 3R7 llltR8 V 3R9 lltR: V 3R; lltR< R= ltR> V 3R? lltR@ V 3RA lltRB V 3RC lltRD V 3RE lltRF V 3RG lltRH V 3RI lltRJ V 3RK lltRLRM/RN RO lltRP V 3RQ lltRR V 3RS lltRT RU lt RVt!V ;t"# )Yr   i!  a×  Wrapper around a CUDA graph.

Arguments:
    keep_graph (bool, optional): If ``keep_graph=False``, the
        cudaGraphExec_t will be instantiated on GPU at the end of
        ``capture_end`` and the underlying cudaGraph_t will be
        destroyed. Users who want to query or otherwise modify the
        underlying cudaGraph_t before instantiation can set
        ``keep_graph=True`` and access it via ``raw_cuda_graph`` after
        ``capture_end``. Note that the cudaGraphExec_t will not be
        instantiated at the end of ``capture_end`` in this
        case. Instead, it will be instantiated via an explicit call
        to ``instantiate`` or automatically on the first call to
        ``replay`` if ``instantiate`` was not already called. Calling
        ``instantiate`` manually before ``replay`` is recommended to
        prevent increased latency on the first call to ``replay``. It
        is allowed to modify the raw cudaGraph_t after first calling
        ``instantiate``, but the user must call ``instantiate`` again
        manually to make sure the instantiated graph has these
        changes. Pytorch has no means of tracking these changes.

.. warning::
    This API is in beta and may change in future releases.

z%_CUDAGraphInputLivenessTracker | NoneÚ_trackerr<   Ú_has_graph_execz
int | NoneÚ_capture_graph_idÚ_remapped_exec_idÚstrÚ_annotation_key_byr•   Ú_recorded_exec_idsÚ_keep_graphz&dict[int, Callable[[CUDAGraph], None]]Ú_capture_start_hooksÚ_capture_end_hooksÚ_post_instantiate_hooksÚ_caching_graph_datazdict | NoneÚ_instantiate_graph_dataÚ_replay_start_hooksÚ_replay_end_hooksrK   Ú	_retainedzweakref.finalize | NoneÚ_retained_finalizerFc               ó    € V ^8„  d   QhRRRR/# )r    Ú
keep_graphr<   r#   r   r$   )r%   s   "r&   r'   ÚCUDAGraph.__annotate__d  s   € ÷ ñ  ð °$ñ r(   c                	óh  <€ \         SV `  W4      pR Vn        R Vn        R Vn        RVn        \        4       Vn        Wn        \        4       Vn
        \        4       Vn        \        4       Vn        RVn        R Vn        \        4       Vn        \        4       Vn        R Vn        VP%                  4        V# )NÚexecF)ÚsuperÚ__new__r™   r›   rœ   rž   rR   rŸ   r    r   r¡   r¢   r£   r¤   r¥   r¦   r§   r©   Ú_arm_retained)Úclsr«   ÚinstanceÚ	__class__s   && €r&   r°   ÚCUDAGraph.__new__d  sœ   ø€ Ü‘7‘? 3Ó3ˆØ ˆÔØ%)ˆÔ"Ø%)ˆÔ"Ø&,ˆÔ#Ü&)£eˆÔ#Ø)Ôä(3«ˆÔ%Ü&1£mˆÔ#Ü+6«=ˆÔ(Ø',ˆÔ$Ø+/ˆÔ(Ü'2£}ˆÔ$Ü%0£]ˆÔ"Ø'+ˆÔ$Ø×ÑÔ Øˆr(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   x  s   € ÷ 0ñ 0˜tñ 0r(   c                	óÐ   a€ \        4       V n        \        P                  ! W P                  P                  4      V n        V P                  oR  V3R llpV P                  V4       R# )c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   Ú-CUDAGraph._arm_retained.<locals>.__annotate__„  s   € ÷ 	0ñ 	0˜ñ 	0r(   c                 óJ   <€ S'       d   ^ RI Hp  V ! S4       \        S4       R# )r   )Úremove_kernel_annotationsN)Útorch.cuda._graph_annotationsr»   r—   )r»   r”   s    €r&   ÚcleanupÚ(CUDAGraph._arm_retained.<locals>.cleanup„  s   ø€ ßÝSá)¨)Ô4Ü$ YÖ/r(   N)rK   r¨   ÚweakrefÚfinalizerc   r©   rŸ   Úregister_destroy_callback)rW   r½   r”   s   & @r&   r±   ÚCUDAGraph._arm_retainedx  sS   ø€ ô ,Ó-ˆŒÜ#*×#3Ò#3°D¿.¹.×:MÑ:MÓ#NˆÔ ð ×+Ñ+ˆ	÷	0ð 	0ð 	×&Ñ& wÖ/r(   c               ó    € V ^8„  d   QhRRRR/# ©r    Úhookrt   r#   r   r$   )r%   s   "r&   r'   r¬   �  s   € ÷ ñ Ø/ðà	ñr(   c                óf   € ^ RI Hp V! V P                  4      pWP                  VP                  &   V# )aÕ  Register ``hook(graph)`` to run when capture begins on this graph, right
after capture is under way on the current stream. Hooks fire in registration
order. Returns a handle whose ``remove()`` deregisters the hook.

.. warning::
    The hook runs inside the capture: any CUDA work it issues is captured into
    the graph, and under the default ``"global"`` capture error mode an unsafe
    call raises. See :func:`torch.cuda.graphs.register_graph_capture_start_hook`.
r   )rv   r   r¡   r5   ©rW   rÅ   r   rw   s   &&  r&   Úregister_capture_start_hookÚ%CUDAGraph.register_capture_start_hook�  s.   € õ 	6á  ×!:Ñ!:Ó;ˆØ/3×!Ñ! &§)¡)Ñ,Øˆr(   c               ó    € V ^8„  d   QhRRRR/# rÄ   r$   )r%   s   "r&   r'   r¬   Ÿ  s   € ÷ ñ Ø/ðà	ñr(   c                óf   € ^ RI Hp V! V P                  4      pWP                  VP                  &   V# )aè  Register ``hook(graph)`` to run when capture ends, after capture
completes but before the graph is finalized. The captured ``cudaGraph_t``
is live (via :meth:`raw_cuda_graph`) for both ``keep_graph`` modes. Hooks
fire in registration order. Returns a handle whose ``remove()``
deregisters the hook.

These hooks are best-effort: they do not run if ending the capture itself
fails (a mid-capture error typically leaves a forked stream unjoined, so
``cudaStreamEndCapture`` raises), and a hook that raises prevents the ones
registered after it from running. Anything that must happen exactly once
per capture -- disarming a callback, releasing a subscription -- needs its
own cleanup on the capture's error path rather than relying on this hook.
r   )rv   r   r¢   r5   rÇ   s   &&  r&   Úregister_capture_end_hookÚ#CUDAGraph.register_capture_end_hookŸ  s.   € õ  	6á  ×!8Ñ!8Ó9ˆØ-1×Ñ §	¡	Ñ*Øˆr(   c               ó    € V ^8„  d   QhRRRR/# rÄ   r$   )r%   s   "r&   r'   r¬   µ  s   € ÷ ñ Ø/ðà	ñr(   c                óf   € ^ RI Hp V! V P                  4      pWP                  VP                  &   V# )a  Register ``hook(graph)`` to run after each instantiation (including
re-instantiation, which produces a fresh exec graph). The instantiated
graph is available via :meth:`raw_cuda_graph_exec`. Hooks fire in
registration order. Returns a handle whose ``remove()`` deregisters the
hook.
r   )rv   r   r£   r5   rÇ   s   &&  r&   Úregister_post_instantiate_hookÚ(CUDAGraph.register_post_instantiate_hookµ  s.   € õ 	6á  ×!=Ñ!=Ó>ˆØ26×$Ñ$ V§Y¡YÑ/Øˆr(   c               ó    € V ^8„  d   QhRRRR/# rÄ   r$   )r%   s   "r&   r'   r¬   Ä  s   € ÷ ñ Ø/ðà	ñr(   c                óf   € ^ RI Hp V! V P                  4      pWP                  VP                  &   V# )aÀ  Register ``hook(graph)`` to run at the start of every :meth:`replay`,
just before the graph is launched (after any on-demand instantiation, so
:meth:`raw_cuda_graph_exec` is valid). Hooks fire in registration order.
Returns a handle whose ``remove()`` deregisters the hook.

.. note::
    Replay is the hot path and a registered hook runs on every replay --
    keep it cheap. With no hook registered the cost is a single dict
    emptiness check.
r   )rv   r   r¦   r5   rÇ   s   &&  r&   Úregister_replay_start_hookÚ$CUDAGraph.register_replay_start_hookÄ  s.   € õ 	6á  ×!9Ñ!9Ó:ˆØ.2× Ñ  §¡Ñ+Øˆr(   c               ó    € V ^8„  d   QhRRRR/# rÄ   r$   )r%   s   "r&   r'   r¬   ×  s   € ÷ ñ Ø/ðà	ñr(   c                óf   € ^ RI Hp V! V P                  4      pWP                  VP                  &   V# )a?  Register ``hook(graph)`` to run at the end of every :meth:`replay`,
just after the graph is launched. The launch is asynchronous, so the hook
runs once the replay is *enqueued*, not once the GPU work completes. Hooks
fire in registration order. Returns a handle whose ``remove()``
deregisters the hook. See the hot-path note on
:meth:`register_replay_start_hook`.

End hooks fire even if the launch raises -- so a start hook is always
balanced by an end -- and the launch error then propagates. (Start hooks
that raise abort the replay before launch, and no end hook fires.)
r   )rv   r   r§   r5   rÇ   s   &&  r&   Úregister_replay_end_hookÚ"CUDAGraph.register_replay_end_hook×  s.   € õ 	6á  ×!7Ñ!7Ó8ˆØ,0×Ñ˜vŸy™yÑ)Øˆr(   Úsynchronize_before_releasec               ó$   € V ^8„  d   QhRRRRRR/# )r    rb   zCallable[[], None]rÚ   r<   r#   r   r$   )r%   s   "r&   r'   r¬   ë  s(   € ÷ ñ àðð %)ð	ð
 
ñr(   c               óÀ   € ^ RI Hp V'       d   RV P                  n        V! V P                  P                  4      pWP                  P                  VP
                  &   V# )a¶  Register ``cb()`` to run when this graph is destroyed (finalized) or
explicitly :meth:`reset`, just before its CUDA resources are freed.
Callbacks fire once per capture cycle, in registration order; exceptions
are swallowed so one failure does not abort the rest. ``cb`` must NOT
reference this graph: the finalizer that fires it is held by a global
registry, so a callback reachable to the graph keeps the graph alive
until interpreter exit (it is never collected, hence never fired).
Returns a handle whose ``remove()`` deregisters the callback.

Teardown does not synchronize CUDA, and ``cudaGraphExecDestroy`` frees an
in-flight graph only asynchronously, so a callback that frees device
memory the graph reads/writes is a use-after-free if a replay is still
in flight. Pass ``synchronize_before_release=True`` to synchronize every
stream this graph was replayed on before firing. Otherwise callbacks
must not free anything the graph references.
r   T)rv   r   r¨   rT   rP   r5   )rW   rb   rÚ   r   rw   s   &&$  r&   rÁ   Ú#CUDAGraph.register_destroy_callbackë  sE   € õ, 	6ç%Ø.2ˆD�N‰NÔ+Ù  §¡×!9Ñ!9Ó:ˆØ.0�‰× Ñ  §¡Ñ+Øˆr(   c               ó$   € V ^8„  d   QhRRRRRR/# )r    Úobjr"   rÚ   r<   r#   r   r$   )r%   s   "r&   r'   r¬   	  s(   € ÷ ñ àðð %)ð	ð
 
ñr(   c               óÀ   € ^ RI Hp V'       d   RV P                  n        V! V P                  P                  4      pWP                  P                  VP
                  &   V# )aê  Keep ``obj`` alive for this graph's current capture cycle and release
it when the graph is destroyed (finalized) or explicitly :meth:`reset`.
No callback runs; normal refcounting drops ``obj`` when the retained
reference is released. Returns a handle whose ``remove()`` drops the
retained reference early. As with :meth:`register_destroy_callback`,
``obj`` must NOT reference this graph, or the graph is kept alive until
interpreter exit and ``obj`` is never released.

``synchronize_before_release`` has the same meaning and caveats as in
:meth:`register_destroy_callback`: set it if releasing ``obj`` frees device
memory the graph reads/writes (e.g. ``obj`` is the last reference to a
tensor the graph uses) and replays may still be in flight.
r   T)rv   r   r¨   rT   rQ   r5   )rW   rß   rÚ   r   rw   s   &&$  r&   Úretain_objectÚCUDAGraph.retain_object	  sE   € õ& 	6ç%Ø.2ˆD�N‰NÔ+Ù  §¡×!7Ñ!7Ó8ˆØ,/�‰×Ñ˜vŸy™yÑ)Øˆr(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   $  s   € ÷ @ñ @¨$ñ @r(   c                	ó,  € V P                   f   R # V P                  R8X  d0   ^ RIHp V! V 4      pVe   V P                  P                  V4       R # ^ RIHp V! V 4       V P                  e(   V P                  P                  V P                  4       R # R # )NÚsource)Úalias_sourceless_to_exec_graph)Úremap_to_exec_graph)r›   rž   r¼   ræ   rŸ   Úaddrç   rœ   )rW   ræ   Úaliased_exec_idrç   s   &   r&   Ú_maybe_remap_annotationsÚ"CUDAGraph._maybe_remap_annotations$  s„   € ð ×!Ñ!Ò)ÙØ×"Ñ" hÔ.õ Uá<¸TÓBˆOØÒ*Ø×'Ñ'×+Ñ+¨OÔ<ÙÝEá˜DÔ!à×!Ñ!Ò-Ø×#Ñ#×'Ñ'¨×(>Ñ(>Ö?ñ .r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   A  s   € ÷ ñ ¨4ñ r(   c                	óX   € V P                   R uqn         Ve   VP                  4        R # R # r|   )r™   Ústop)rW   Útrackers   & r&   Ú_release_python_resourcesÚ#CUDAGraph._release_python_resourcesA  s(   € ð "&§¡°Ðˆ”ØÒØ�L‰LŽNñ r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   K  s   € ÷ ñ ˜ñ r(   c                	óL   €  V P                  4        R #   \         d     R # i ; ir|   )rð   r]   rV   s   &r&   Ú__del__ÚCUDAGraph.__del__K  s%   € ð	Ø×*Ñ*Ö,øÜô 	Úð	ús   ‚ ”#¢#c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r    r!   r1   Úcapture_error_moder�   Úcheck_input_livenessr<   r#   rE   r$   )r%   s   "r&   r'   r¬   Q  s2   € ÷ 0ñ 0àð0ð  ð0ð #ð	0ð
 
ñ0r(   c                óž  <€ V P                   e"   V P                   P                  4        RV n         \        SV `  \	        V4      VR7       V'       d-   ^ RIHp V! 4       V n         V P                   P                  4        \        '       d   \        \        V 4       \        V P                  P                  4       4       F  pV! V 4       K  	  R# )a�  Begin capturing CUDA work on the current stream.

Typically, you shouldn't call ``capture_begin`` yourself.
Use :class:`~torch.cuda.graph` or :func:`~torch.cuda.make_graphed_callables`,
which call ``capture_begin`` internally.

Arguments:
    pool (optional): Token (returned by :func:`~torch.cuda.graph_pool_handle` or
        :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) or
        :class:`~torch.cuda.MemPool` that hints this graph may share memory
        with the indicated pool.  See :ref:`Graph memory management<graph-memory-management>`.
    capture_error_mode (str, optional): specifies the cudaStreamCaptureMode for the graph capture stream.
        Can be "global", "thread_local" or "relaxed". During cuda graph capture, some actions, such as cudaMalloc,
        may be unsafe. "global" will error on actions in other threads, "thread_local" will only error for
        actions in the current thread, and "relaxed" will not error on these actions. Do NOT change this setting
        unless you're familiar with `cudaStreamCaptureMode <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85>`_
    check_input_liveness (bool, optional):
        If ``True``, tracks external tensor inputs during graph capture and
        raises an error if any are deallocated before replay. This helps debug "use after free" errors
        where input tensors are garbage collected between capture and replay. Default: ``False``.

        .. note::
            Custom CUDA kernels added outside PyTorch (e.g., via cuLaunchKernel or DLPack) are not
            tracked by this mechanism.
N)r!   r÷   r   )r™   rî   r¯   Úcapture_beginr6   Útorch.utils._cuda_debugr   Ústartrl   r}   r^   r¡   r_   )rW   r!   r÷   rø   r   rÅ   r´   s   &&&&  €r&   rú   ÚCUDAGraph.capture_beginQ  s�   ø€ ð> �=‰=Ò$Ø�M‰M×ÑÔ Ø ˆDŒMÜ‰ÑÜ˜dÓ#Ð8Jð 	ô 	
÷  ÝNá:Ó<ˆDŒMØ�M‰M×ÑÔ!÷ 'Ó&ÜÔ9¸4Ô@Ü˜×2Ñ2×9Ñ9Ó;Ö<ˆDÙ�ŽJó =r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   ƒ  s   € ÷ "ñ " ñ "r(   c                ó$   <€ \         SV `  4        R# )zÁEnd capture but do not finalize: leaves the captured ``cudaGraph_t``
live (for both ``keep_graph`` modes) so it can be inspected before
:meth:`capture_end_post` instantiates and/or destroys it.N)r¯   Úcapture_end_pre©rW   r´   s   &€r&   r   ÚCUDAGraph.capture_end_preƒ  s   ø€ ô 	‰ÑÖ!r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   ‰  s   € ÷ !ñ ! $ñ !r(   c                óx   <€ \         SV `  4        V P                  e   V P                  P                  4        R# R# )zÂFinalize a capture started by :meth:`capture_end_pre`: destroy the
template when ``keep_graph=False`` (the graph must already be
instantiated; :meth:`capture_end` and the context manager do so).N)r¯   Úcapture_end_postr™   rî   r  s   &€r&   r  ÚCUDAGraph.capture_end_post‰  s/   ø€ ô 	‰Ñ Ô"Ø�=‰=Ò$Ø�M‰M×ÑÖ ñ %r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   ‘  s   € ÷  ñ  ˜Tñ  r(   c                ó&  € V P                  4        \        '       d   \        \        V 4       \        V P                  P                  4       4       F  pV! V 4       K  	  V P                  '       g   V P                  4        V P                  4        R# )a  End CUDA graph capture on the current stream.

After ``capture_end``, ``replay`` may be called on this instance.

Typically, you shouldn't call ``capture_end`` yourself.
Use :class:`~torch.cuda.graph` or :func:`~torch.cuda.make_graphed_callables`,
which call ``capture_end`` internally.
N)	r   rm   r}   r^   r¢   r_   r    Úinstantiater  )rW   rÅ   s   & r&   Úcapture_endÚCUDAGraph.capture_end‘  sn   € ð 	×ÑÔ÷ %Ó$ÜÔ7¸Ô>Ü˜×0Ñ0×7Ñ7Ó9Ö:ˆDÙ�ŽJñ ;à××Ðð ×ÑÔØ×ÑÖr(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   ª  s   € ÷ 0ñ 0˜Tñ 0r(   c                ó2  <€ \         SV `  4        V P                  4        RV n         \        '       d   \        \        V 4       \        V P                  P                  4       4       F  pV! V 4       K  	  RV n        RV n	        R#   RT n        RT n	        i ; i)züInstantiate the CUDA graph. Will be called by
``capture_end`` if ``keep_graph=False``, or by ``replay`` if
``keep_graph=True`` and ``instantiate`` has not already been
explicitly called. Does not destroy the cudaGraph_t returned
by ``raw_cuda_graph``.
TFN)
r¯   r	  rê   r¤   rn   r}   r^   r£   r_   r¥   ©rW   rÅ   r´   s   & €r&   r	  ÚCUDAGraph.instantiateª  sˆ   ø€ ô 	‰ÑÔØ×%Ñ%Ô'ð
 $(ˆÔ ð	0ß(Ó(Ü!Ô";¸TÔBÜ˜T×9Ñ9×@Ñ@ÓBÖC�Ù�T–
ñ Dð (-ˆDÔ$Ø+/ˆDÖ(øð (-ˆDÔ$Ø+/ˆDÕ(ús   ¨B ´AB ÂBc               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   Á  s   € ÷ ñ ˜ñ r(   c                óâ  <€ V P                   e*   V P                   P                  V P                  4       4       V P                  P                  '       dB   V P                  P
                  P                  \        P                  P                  4       4       V P                  '       g   V P                  4        \        '       d   \        \        V 4       V P                  '       d3   \        V P                  P!                  4       4       F  pV! V 4       K  	   \"        SV `I  4        \&        '       d   \        \&        V 4       V P(                  '       d5   \        V P(                  P!                  4       4       F  pV! V 4       K  	  R# R#   \&        '       d   \        \&        T 4       T P(                  '       d4   \        T P(                  P!                  4       4       F  pT! T 4       K  	  i i ; i)z,Replay the CUDA work captured by this graph.N)r™   Úcheck_aliveÚpoolsr¨   rT   rS   rè   r+   r,   Úcurrent_streamrš   r	  ro   r}   r¦   r^   r_   r¯   Úreplayrp   r§   r  s   & €r&   r  ÚCUDAGraph.replayÁ  s\  ø€ à�=‰=Ò$Ø�M‰M×%Ñ% d§j¡j£lÔ3Ø�>‰>×*×*Ð*ð �N‰N×)Ñ)×-Ñ-¬e¯j©j×.GÑ.GÓ.IÔJð ×#×#Ð#Ø×ÑÔß%Ó%ÜÔ8¸$Ô?Ø×#×#Ð#Ü˜T×5Ñ5×<Ñ<Ó>Ö?�Ù�T–
ñ @ð	Ü‰G‰NÔç'Ó'Ü!Ô":¸DÔAØ×%×%Ð%Ü  ×!7Ñ!7×!>Ñ!>Ó!@ÖA�DÙ˜–Jó Bñ &ø÷ (Ó'Ü!Ô":¸DÔAØ×%×%Ð%Ü  ×!7Ñ!7×!>Ñ!>Ó!@ÖA�DÙ˜–Jò Bð &ús   ÄF Æ.G.Æ:4G.c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬   Ý  s   € ÷ ñ �tñ r(   c                ó"  <€ V P                  4        V P                  P                  4        V P                  e   V P                  P	                  4        \        4       V n        V P                  4        RV n        RV n	        \        SV `-  4        R# )z1Delete the graph currently held by this instance.N)rð   r¨   rc   r©   ÚdetachrR   rŸ   r±   r›   rœ   r¯   Úresetr  s   &€r&   r  ÚCUDAGraph.resetÝ  sr   ø€ à×&Ñ&Ô(ð 	�‰×ÑÔØ×#Ñ#Ò/Ø×$Ñ$×+Ñ+Ô-ô #&£%ˆÔØ×ÑÔð "&ˆÔØ!%ˆÔÜ‰‰Žr(   c               ó   € V ^8„  d   QhRR/# r@   r$   )r%   s   "r&   r'   r¬   ò  s   € ÷ 7ñ 7�lñ 7r(   c                óZ   <€ \         P                  P                  \        SV `  4       4      # )zÌReturn an opaque token representing the id of this graph's memory pool.

This id can optionally be passed to another graph's ``capture_begin``,
which hints the other graph may share the same memory pool.
)r+   r,   r   r¯   r!   r  s   &€r&   r!   ÚCUDAGraph.poolò  s    ø€ ô �z‰z×&Ñ&¤u¡w¡|£~Ó6Ð6r(   c               ó   € V ^8„  d   QhRR/# )r    r#   zlist[_POOL_HANDLE]r$   )r%   s   "r&   r'   r¬   ú  s   € ÷ Kñ KÐ)ñ Kr(   c                ó„   <€ \         SV `  4        Uu. uF"  p\        P                  P	                  V4      NK$  	  up# u upi )zAReturn opaque tokens for all memory pools retained by this graph.)r¯   r  r+   r,   r   )rW   r!   r´   s   & €r&   r  ÚCUDAGraph.poolsú  s0   ø€ ä:?¹'¹-¼/ÓJ¹/°$”—
‘
×'Ñ'¨Ö-¹/ÑJÐJùÒJs   ’(=c               ó    € V ^8„  d   QhRRRR/# )r    r!   r   r#   rE   r$   )r%   s   "r&   r'   r¬   þ  s   € ÷ -ñ - ð -°ñ -r(   c                	óV   <€ \        V4      pVf   \        R4      h\        SV `  V4      # )Nz-CUDAGraph._retain_pool expected a memory pool)r6   rH   r¯   Ú_retain_pool)rW   r!   Úpool_idr´   s   && €r&   r$  ÚCUDAGraph._retain_poolþ  s.   ø€ Ü˜tÓ$ˆØŠ?ÜÐNÓOÐOÜ‰wÑ# GÓ,Ð,r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r¬     s   € ÷  ñ   4ñ  r(   c                ó2   <€ \         SV `  4        RV n        R# )z“Retain the captured graph (equivalent to ``keep_graph=True``) so it
can be inspected, e.g. via :meth:`debug_dump`. Kept for backward
compatibility.TN)r¯   Úenable_debug_moder    r  s   &€r&   r)  ÚCUDAGraph.enable_debug_mode  s   ø€ ô 	‰Ñ!Ô#àˆÖr(   ÚverboseTc               ó$   € V ^8„  d   QhRRRRRR/# )r    Ú
debug_pathr�   r+  r<   r#   rE   r$   )r%   s   "r&   r'   r¬     s!   € ÷ ;ñ ; Sð ;°dð ;Àdñ ;r(   c               ó    € \        WVR7       R# )al  Dump the captured graph to ``debug_path`` in Graphviz DOT format.

The graph's template must be live: ``keep_graph=True`` (or
:meth:`enable_debug_mode`), or called from a capture-end hook. Requires
the ``cuda.bindings`` package.

Arguments:
    debug_path (required): Path to dump the graph to.
    verbose: If ``True`` (default), use the most verbose DOT output.
©r+  N©Ú_dump_graph_dot)rW   r-  r+  s   &&$r&   Ú
debug_dumpÚCUDAGraph.debug_dump  s   € ô 	˜°'×:r(   c               ó   € V ^8„  d   QhRR/# ©r    r#   Úintr$   )r%   s   "r&   r'   r¬     s   € ÷ (ñ ( ñ (r(   c                ó    <€ \         SV `  4       # )a  Returns the underlying cudaGraph_t. The template must be live: this
requires ``keep_graph=True`` (it persists after ``capture_end``), or
access from within a capture-end hook (before the template is destroyed
for ``keep_graph=False``).

See the following for APIs for how to manipulate this object: `Graph Management <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__GRAPH.html>`_ and `cuda-python Graph Management bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest/module/runtime.html#graph-management>`_
)r¯   Úraw_cuda_graphr  s   &€r&   r8  ÚCUDAGraph.raw_cuda_graph  s   ø€ ô ‰wÑ%Ó'Ð'r(   c               ó   € V ^8„  d   QhRR/# r5  r$   )r%   s   "r&   r'   r¬   #  s   € ÷ -ñ - Sñ -r(   c                ó    <€ \         SV `  4       # )aš  Returns the underlying cudaGraphExec_t. ``instantiate`` must have been called if ``keep_graph`` is True, or ``capture_end`` must have been called if ``keep_graph`` is False. If you call ``instantiate()`` after ``raw_cuda_graph_exec()``, the previously returned cudaGraphExec_t will be destroyed. It is your responsibility not to use this object after destruction.

See the following for APIs for how to manipulate this object: `Graph Execution <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__GRAPH__EXEC.html>`_ and `cuda-python Graph Execution bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest/module/runtime.html#graph-execution>`_
)r¯   Úraw_cuda_graph_execr  s   &€r&   r<  ÚCUDAGraph.raw_cuda_graph_exec#  s   ø€ ô
 ‰wÑ*Ó,Ð,r(   c               ó   € V ^8„  d   QhRR/# )r    r#   Údictr$   )r%   s   "r&   r'   r¬   *  s   € ÷ Tñ T ñ Tr(   c                óþ  € V P                   e   V P                   # ^ RIHpHp \	        4        \
        e	   \        f   \        R4      hV! 4       '       d   \        R4      h\        P                  pVP                  RVP                  RVP                  RVP                  RVP                  R	VP                  R
VP                   RVP"                  RVP$                  RVP&                  RVP(                  RVP*                  R/pVP                  VP*                  0p\-        4       pV P/                  4       p\1        \
        P2                  ! V^ R7      4      w  r‰\1        \
        P2                  ! WyR7      4      w  r©/ p. p\5        V	4       EFü  pW­,          pWÛ\7        V4      &   V! V4      pWõ9   d!   VP9                  VP;                  Wÿ4      4       \1        \
        P<                  ! V4      4      pV^ ,	          pVR,          pRpRpRpRpWóP                  8X  EdG   \        P>                  ! V4      w  ppV\        P@                  PB                  8X  Ed   \7        VPD                  4      \7        VPF                  4      \7        VPH                  4      3p\7        VPJ                  4      \7        VPL                  4      \7        VPN                  4      3p\7        VPP                  4      pVPR                  '       dk   \        PT                  ! VPR                  4      w  ppV\        P@                  PB                  8X  d)   \W        V\X        4      '       d   VP[                  4       MTp^ pWóP"                  8X  d*   \7        \1        \
        P\                  ! V4      4      4      pM8WóP                   8X  d)   \7        \1        \
        P^                  ! V4      4      4      p^ pRpWóP                  8X  dY   \
        P`                  ! V4      w  ppV\
        Pb                  Pd                  8X  d!   \7        VPf                  4      p\i        V4      pVPk                  RVRVP;                  V\m        V4      4      RVRVRVRVRVRVRVRVRVRVR. R . /4       EKÿ  	  \1        \
        Pn                  ! V^ R!7      4      w    pp. pV^ 8”  Ed"   \1        \
        Pn                  ! VVR!7      4      w  pp p!p\5        V4       Fì  pVP;                  \7        VV,          4      4      p"VP;                  \7        V V,          4      4      p#V"f   KK  V#f   KQ  VV",          R ,          Pk                  V#4       VV#,          R,          Pk                  V"4       V!V,          p$VPk                  R"V"R#V#R$\7        V$Pp                  4      R%\7        V$Pr                  4      R&\7        V$Pt                  4      /4       Kî  	  \1        \
        Pv                  ! V Py                  4       4      4      p%V F"  p&V%^ ,          V&R,          ,          V&R&   V%V&R&   K$  	  V'       d&   \z        P|                  ! R'\        V4       R(2^R)7       R*V%R+VR,V/p'V P€                  '       d   V'V n         V'# )-ar  Return a dictionary describing the graph's topology and node metadata.

``keep_graph`` must be True.  The graph must have been instantiated
(via :meth:`instantiate`) before calling this method.
Requires the ``cuda.bindings`` package.

Returns a dictionary with structure::

    {
        "exec_graph_id": int,
        "nodes": [
            {
                "index": int,
                "node_type": str,
                "tools_id": int,
                "graph_id": int,
                "node_id": int,
                "kernel_name": str or None,
                "grid_dim": tuple(int, int, int) or None,
                "block_dim": tuple(int, int, int) or None,
                "shared_mem_bytes": int or None,
                "event_ptr": int,
                "host_fn_addr": int,
                "host_fn_name": str or None,
                "dependencies": [int, ...],
                "dependents": [int, ...],
            },
            ...,
        ],
        "edges": [
            {
                "from": int,
                "to": int,
                "from_port": int,
                "to_port": int,
                "type": int,
            },
            ...,
        ],
    }

``event_ptr`` is the ``cudaEvent_t`` handle (as an int) an event-record
or event-wait node records / waits on -- these nodes produce no timed
CUPTI record, so matching a wait to the record that signals it is the
only way to reason about the cross-stream sync it encodes. It is ``0``
for other node types.

``host_fn_addr`` / ``host_fn_name`` are populated for host nodes (a CPU
callback run as a graph node): the callback address and a best-effort
demangled symbol name for it (``None`` when it resolves to no exported
symbol). They are ``0`` / ``None`` for other node types.

``grid_dim`` / ``block_dim`` are the kernel launch dimensions
``(x, y, z)`` read from the kernel node's params, populated for kernel
nodes (``None`` when the params query fails). ``shared_mem_bytes`` is
that launch's *dynamic* shared memory, read from the same params. All
three are ``None`` for other node types.

Each node's ``graph_id`` is remapped to the exec graph id so that
``tools_id`` values match those reported by CUPTI-based profilers.
``dependencies`` and ``dependents`` are lists of node indices within
the ``nodes`` list.

``edges`` lists every dependency once, with ``from`` / ``to`` naming
node indices into ``nodes`` (the same relation ``dependencies`` /
``dependents`` encode per node) plus the raw ``cudaGraphEdgeData``
annotation: ``from_port`` / ``to_port`` / ``type`` as ints. All zero
is an ordinary full-serialization edge. A nonzero ``from_port`` or a
``type`` of 1 (``cudaGraphDependencyTypeProgrammatic``) marks a
programmatic edge whose semantics reachability alone cannot express,
so passes that rewrite the graph must leave such edges alone.

This structure is useful for inspecting a profiler trace and
establishing whether a particular dependency observed in the profile
is a true dependency (encoded in the graph) or a fake dependency
caused by mapping of independent streams to the same hardware
channel.

Child-graph and conditional nodes are reported as nodes in their own
right, but this walk does not descend into their bodies (those are
separate ``cudaGraph_t`` objects), so the work inside them is absent
from ``nodes`` and a warning is issued. The ids that *are* reported
stay valid: the exec graph preserves top-level node ids.
N)Ú_get_node_typeÚ_is_tools_id_unavailablez6expected _cuda_runtime and _cuda_driver to be not Nonez•get_graph_data requires cudaGraphNodeGetToolsId which needs cuda.bindings >= 13.1 and CUDA driver >= 13.1 (or cuda-compat >= 13.1 in LD_LIBRARY_PATH)ÚkernelÚmemcpyÚmemsetÚhostÚchild_graphÚemptyÚ
wait_eventÚevent_recordÚ	mem_allocÚmem_freeÚbatch_mem_opÚconditional)ÚnumNodesl   ÿÿ ÚindexÚ	node_typeÚtools_idÚgraph_idÚnode_idÚkernel_nameÚgrid_dimÚ	block_dimÚshared_mem_bytesÚ	event_ptrÚhost_fn_addrÚhost_fn_nameÚdependenciesÚ
dependents)ÚnumEdgesÚfromÚtoÚ	from_portÚto_portÚtypez$get_graph_data: this graph contains z‡ nodes; the work inside them is in a separate cudaGraph_t that this walk does not descend into, so it is absent from the returned nodes)Ú
stacklevelÚexec_graph_idÚnodesÚedges)Ar¥   r¼   rA  rB  rI   rG   Ú_cuda_driverÚAssertionErrorrH   ÚCUgraphNodeTypeÚCU_GRAPH_NODE_TYPE_KERNELÚCU_GRAPH_NODE_TYPE_MEMCPYÚCU_GRAPH_NODE_TYPE_MEMSETÚCU_GRAPH_NODE_TYPE_HOSTÚCU_GRAPH_NODE_TYPE_GRAPHÚCU_GRAPH_NODE_TYPE_EMPTYÚCU_GRAPH_NODE_TYPE_WAIT_EVENTÚCU_GRAPH_NODE_TYPE_EVENT_RECORDÚCU_GRAPH_NODE_TYPE_MEM_ALLOCÚCU_GRAPH_NODE_TYPE_MEM_FREEÚCU_GRAPH_NODE_TYPE_BATCH_MEM_OPÚCU_GRAPH_NODE_TYPE_CONDITIONALrR   r8  r   ÚcudaGraphGetNodesÚranger6  rè   ÚgetÚcudaGraphNodeGetToolsIdÚcuGraphKernelNodeGetParamsÚCUresultÚCUDA_SUCCESSÚgridDimXÚgridDimYÚgridDimZÚ	blockDimXÚ	blockDimYÚ	blockDimZÚsharedMemBytesÚfuncÚcuFuncGetNamer-   ÚbytesÚdecodeÚ cudaGraphEventRecordNodeGetEventÚcudaGraphEventWaitNodeGetEventÚcudaGraphHostNodeGetParamsÚcudaError_tÚcudaSuccessrs   Ú_resolve_host_fn_nameÚappendr�   ÚcudaGraphGetEdgesra  rb  rc  ÚcudaGraphExecGetIdr<  ÚwarningsÚwarnÚsortedr¤   )(rW   rA  rB  Ú
node_typesÚnode_type_namesÚnested_graph_typesÚnested_node_typesÚrawÚ_Únumrf  Úhandle_to_idxÚ
node_infosÚiÚnodeÚntyperR  rS  rT  rU  rV  rW  rX  ÚerrÚparamsÚnamerY  rZ  r[  Ú	num_edgesÚ
edge_infosÚ
from_nodesÚto_nodesÚ	edge_dataÚsrcÚdstÚ
annotationre  ÚinfoÚdatas(   &                                       r&   Úget_graph_dataÚCUDAGraph.get_graph_data*  sì  € ðl ×'Ñ'Ò3Ø×/Ñ/Ð/÷	
ô
 	Ô äÒ ¤LÒ$8Ü ØHóð ñ $×%Ò%Üð>óð ô "×1Ñ1ˆ
à×0Ñ0°(Ø×0Ñ0°(Ø×0Ñ0°(Ø×.Ñ.°Ø×/Ñ/°Ø×/Ñ/°Ø×4Ñ4°lØ×6Ñ6¸Ø×3Ñ3°[Ø×2Ñ2°JØ×6Ñ6¸Ø×5Ñ5°}ð
ˆð  ×/Ñ/Ø×5Ñ5ð
Ðô '*£eÐà×!Ñ!Ó#ˆä%¤m×&EÒ&EÀcÐTUÔ&VÓW‰ˆÜ)Ü×+Ò+¨CÔ>ó
‰
ˆð )+ˆØ!#ˆ
ä�s—ˆAØ•8ˆDØ'(œ#˜d›)Ñ$á" 4Ó(ˆEØÔ*Ø!×%Ñ% o×&9Ñ&9¸%Ó&GÔHÜ+¬M×,QÒ,QÐRVÓ,WÓXˆHØ 2•~ˆHØ Õ+ˆGàˆKØˆHØˆIØ#ÐØ×<Ñ<Õ<Ü*×EÒEÀdÓK‘��VØœ,×/Ñ/×<Ñ<Õ<ä˜FŸO™OÓ,Ü˜FŸO™OÓ,Ü˜FŸO™OÓ,ð �Hô ˜F×,Ñ,Ó-Ü˜F×,Ñ,Ó-Ü˜F×,Ñ,Ó-ð!�Iô
 (+¨6×+@Ñ+@Ó'AÐ$Ø—{—{�{Ü$0×$>Ò$>¸v¿{¹{Ó$K™	˜˜TØ¤,×"7Ñ"7×"DÑ"DÔDä1;¸DÄ%×1HÒ1H §¡¤Èdð (ð ˆIØ×BÑBÔBÜÜ(Ü%×FÒFÀtÓLóó‘	ð
 ×BÑBÔBÜÜ(Ü%×DÒDÀTÓJóó�	ð ˆLØˆLØ×:Ñ:Ô:Ü+×FÒFÀtÓL‘��VØœ-×3Ñ3×?Ñ?Ô?Ü#& v§y¡y£>�LÜ#8¸Ó#F�Là×Ñà˜QØ ×!4Ñ!4°U¼CÀ»JÓ!GØ Ø Ø˜wØ! ;Ø Ø Ø&Ð(8Ø Ø" LØ" LØ" BØ  "ð÷ñG ôl 2Ü×+Ò+¨C¸!Ô<ó
Ñˆˆ1ˆa�ð "$ˆ
Ø�q�=Ü9MÜ×/Ò/°¸iÔHó:Ñ6ˆJ˜ )¨Yô ˜9Ö%�Ø#×'Ñ'¬¨J°q­MÓ(:Ó;�Ø#×'Ñ'¬¨H°Q­KÓ(8Ó9�Ø”? s¤Ø˜s•O LÕ1×8Ñ8¸Ô=Ø˜s•O NÕ3×:Ñ:¸3Ô?Ø!*¨1¥�JØ×%Ñ%à" CØ  #Ø'¬¨Z×-AÑ-AÓ)BØ%¤s¨:×+=Ñ+=Ó'>Ø"¤C¨
¯©Ó$8ðöñ &ô" -Ü×,Ò,¨T×-EÑ-EÓ-GÓHó
ˆó ˆDØ -°Õ 3°t¸IµÕFˆD�ÑØ,ˆD�Óñ ÷ ô
 �MŠMØ6´vÐ>OÓ7PÐ6Qð RVð Vð õ	ð ˜]Ø�ZØ�Zð
ˆð
 ×#×#Ð#Ø+/ˆDÔ(Øˆr(   )	r¤   r›   r¥   r    rŸ   rœ   r¨   r©   r™   )F)NÚglobalF)#re   rf   rg   rh   ri   Ú__annotations__r°   r±   rÈ   rÌ   rÐ   rÔ   rØ   rÁ   rá   rê   rð   rô   rú   r   r  r
  r	  r  r  r!   r  r$  r)  r2  r8  r<  r®  rj   Ú__classcell__)r´   s   @r&   r   r   !  si  ø‡ ñð4 4Ó3ð Óð "Ó!ð "Ó!ð Óð !Ó ØÓà@Ó@Ø>Ó>ØCÓCð ÓØ(Ó(ð @Ó?Ø=Ó=ð "Ó!Ø0Ó0÷ò õ(0õ*õ$õ,õõ&ð(ð ,1÷	ð<ð ,1÷	õ6@õ:õ÷0ò 0÷d"ð "÷!ð !õ ÷20ð 0÷.ð ÷8ð ÷*7ð 7÷Kð K÷-ð -÷ ð  ð;¸T÷ ;÷(ð (÷-ð -÷Tó Tr(   c                  ó‚   € ] tR tRtR]P
                  3R]P                  3R]P
                  3R]P                  3.tRtR# )Ú_DlInfoiA  Ú	dli_fnameÚ	dli_fbaseÚ	dli_snameÚ	dli_saddrr$   N)	re   rf   rg   rh   ÚctypesÚc_char_pÚc_void_pÚ_fields_rj   r$   r(   r&   r´  r´  A  s9   † à	�f—o‘oÐ&Ø	�f—o‘oÐ&Ø	�f—o‘oÐ&Ø	�f—o‘oÐ&ð	„Hr(   r´  c               ó    € V ^8„  d   QhRRRR/# )r    Úaddrr6  r#   z
str | Noner$   )r%   s   "r&   r'   r'   J  s   € ÷ 7ñ 7 ð 7¨
ñ 7r(   c                ól  € V '       g   R# \        4       p\        P                  ! R4      P                  \        P                  ! V 4      \        P
                  ! V4      4      '       g   R# VP                  '       g   R# \        P                  P                  VP                  P                  4       4      # )zöBest-effort symbol name for a host-node callback address via dladdr + demangle.
Returns None when the address resolves to no exported symbol (e.g. an anonymous
trampoline). Host nodes carry no name in the CUPTI record, so this is the only source.N)r´  r¹  ÚCDLLÚdladdrr»  Úbyrefr·  r+   Ú_CÚ	_demanglerˆ  )r¾  r¬  s   & r&   rŽ  rŽ  J  sp   € ÷ ÙÜ‹9€DÜ�;Š;�tÓ×#Ñ#¤F§O¢O°DÓ$9¼6¿<º<ÈÓ;M×NÒNÙØ�>�>ˆ>ÙÜ�8‰8×Ñ˜dŸn™n×3Ñ3Ó5Ó6Ð6r(   r+  Tc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r    Ú
cuda_graphr   Úpathr�   r+  r<   r#   rE   r$   )r%   s   "r&   r'   r'   X  s)   € ÷ ñ  	ð °ð À$ð ÐRVñ r(   c               óÜ   € \        4        V'       d   \        P                  P                  M^ p\	        \        P
                  ! V P                  4       VP                  4       V4      4       R# )zCWrite ``cuda_graph``'s template to ``path`` in Graphviz DOT format.N)rI   rG   ÚcudaGraphDebugDotFlagsÚcudaGraphDebugDotFlagsVerboser   ÚcudaGraphDebugDotPrintr8  Úencode)rÆ  rÇ  r+  Úflagss   &&$ r&   r1  r1  X  sT   € äÔ÷ ô 	×,Ñ,×JÒJàð 
ô
 Ü×,Ò,Ø×%Ñ%Ó'¨¯©«¸ó	
ör(   c               ó$   € V ^8„  d   QhRRRRRR/# )r    rÇ  r�   r+  r<   r#   rt   r$   )r%   s   "r&   r'   r'   g  s"   € ÷ 	ñ 	�Sð 	 dð 	Ð6Qñ 	r(   c               ó   a a€ R V V3R llpV# )zíReturn a capture-end hook that dumps the captured graph to ``path`` in
Graphviz DOT format. Register it with
:meth:`CUDAGraph.register_capture_end_hook`; works for both ``keep_graph``
modes since it runs while the template is still live.c               ó    € V ^8„  d   QhRRRR/# ©r    rÆ  r   r#   rE   r$   )r%   s   "r&   r'   Ú export_dot.<locals>.__annotate__m  s   € ÷ ;ñ ;˜)ð ;¨ñ ;r(   c                ó$   <€ \        V SSR 7       R# )r/  Nr0  )rÆ  rÇ  r+  s   &€€r&   Ú_hookÚexport_dot.<locals>._hookm  s   ø€ Ü˜
 D°'×:r(   r$   )rÇ  r+  rÔ  s   fd r&   Ú
export_dotrÖ  g  s   ù€ ÷;ñ ;ð €Lr(   c               ó    € V ^8„  d   QhRRRR/# )r    rÇ  r�   r#   rt   r$   )r%   s   "r&   r'   r'   s  s   € ÷ ñ ˜Cð Ð$?ñ r(   c                ó   a € R V 3R llpV# )a]  Return a post-instantiate hook that pickles :meth:`CUDAGraph.get_graph_data`
to ``path``. Register it with :meth:`CUDAGraph.register_post_instantiate_hook`:
``get_graph_data`` needs the graph instantiated (it remaps node ids to the
exec graph id), and at post-instantiate time the template is still live, so
this works for both ``keep_graph`` modes.c               ó    € V ^8„  d   QhRRRR/# rÑ  r$   )r%   s   "r&   r'   Ú'export_graph_data.<locals>.__annotate__z  s   € ÷ 8ñ 8˜)ð 8¨ñ 8r(   c                ó²   <€ ^ RI p\        SR4      ;_uu_ 4       pVP                  V P                  4       V4       RRR4       R#   + '       g   i     R# ; i)r   NÚwb)ÚpickleÚopenÚdumpr®  )rÆ  rÝ  ÚfrÇ  s   &  €r&   rÔ  Ú export_graph_data.<locals>._hookz  s;   ø€ Ûä�$˜×Ô Ø�K‰K˜
×1Ñ1Ó3°QÔ7÷ ××Òús   š!AÁA	r$   )rÇ  rÔ  s   f r&   Úexport_graph_datarâ  s  s   ø€ ÷8ð 8ð €Lr(   ÚbackendÚkey_byÚrecord_py_stacksÚpy_stack_filter_pathsz;dict[str, tuple[typing.Any, tuple[typing.Any, ...] | None]]Ú_ANNOTATION_CONFIG_KEYSc               ó    € V ^8„  d   QhRRRR/# )r    Úconfigúdict[str, typing.Any] | Noner#   zdict[str, typing.Any]r$   )r%   s   "r&   r'   r'   Œ  s   € ÷  ñ  Ø(ð àñ r(   c           	     ó  € \         P                  4        UUUu/ uF
  w  pw  r#WbK  	  ppppV f   V# \        V 4      \        \         4      ,
          pV'       d(   \        R\	        V4       R\	        \         4       24      hV P                  4        F¼  w  r\         V,          ^,          pVfw   Ver   \        V\        \        34      '       d;   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   \        RV: R24      h\        V4      pM%Wg9  d    \        RV: R\        V4       R	V: 24      hWdV&   K¾  	  VR
,          '       d   VR,          R8X  d   \        R4      hV# u upppi )z˜Validate ``graph(annotation_config=...)`` and resolve it against the defaults, so an
unrecognized key or value raises instead of silently doing nothing.z&unrecognized annotation_config key(s) z; supported: c              3  óV   "  € T F  p\        V\        4      ;'       d    Tx € K!  	  R # 5ir|   )r-   r�   )Ú.0rÇ  s   & r&   Ú	<genexpr>Ú+_parse_annotation_config.<locals>.<genexpr>ž  s&   é € ð CÙ?D°t”J˜t¤SÓ)×2Ð2¨dÔ2»uùs   ‚)ž)FTzannotation_config[z7] must be None or a list/tuple of nonempty path stringsz] must be one of z, got rå  rã  Ú	edge_walkz;record_py_stacks=True requires the CUPTI annotation backend)	rç  ÚitemsrR   Ú
ValueErrorr”  r-   r^   ÚtupleÚall)ré  ÚkeyÚdefaultrš  ÚresolvedÚunknownÚvalueÚalloweds   &       r&   Ú_parse_annotation_configrû  Œ  sƒ  € ô
 7N×6SÑ6SÔ6UÕVÑ6UÑ!2 ¡l w�’Ñ6U€HÒVØ‚~ØˆÜ�&‹kœCÔ 7Ó8Õ8€GßÜØ4´V¸G³_Ð4Eð FÜ Ô!8Ó9Ð:ð<ó
ð 	
ð —l‘l–n‰
ˆÜ)¨#Õ.¨qÕ1ˆØŠ?ØÒ Ü! %¬$´¨×7Ò7¿s»sñ CÙ?DóC¿s¿sºsñ CÙ?DóC÷ @ò @ô %Ø,¨S©GÐ3jÐkóð ô ˜e›�øØÔ!ÜØ$ S¡GÐ+<¼TÀ'»]¸OÈ6ÐRWÑQZÐ[óð ð �‹ñ %ð  Ð"×#Ô#¨°Õ(;¸{Ô(JÜÐVÓWÐWØ€Oùô7 Ws   ™E;c                  óR   € ] tR tRt$ RtRtR]R&   RR R lltR R	 ltR
 R lt	Rt
R# )r   i¯  a  Context-manager that captures CUDA work into a :class:`torch.cuda.CUDAGraph` object for later replay.

See :ref:`CUDA Graphs <cuda-graph-semantics>` for a general introduction,
detailed use, and constraints.

Arguments:
    cuda_graph (torch.cuda.CUDAGraph): Graph object used for capture.
    pool (optional): Opaque token (returned by a call to :func:`~torch.cuda.graph_pool_handle()` or
        :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) or
        :class:`~torch.cuda.MemPool` hinting this graph's capture may share memory
        from the specified pool. See :ref:`Graph memory management<graph-memory-management>`.
    stream (torch.cuda.Stream, optional): If supplied, will be set as the current stream in the context.
        If not supplied, ``graph`` sets its own internal side stream as the current stream in the context.
    capture_error_mode (str, optional): specifies the cudaStreamCaptureMode for the graph capture stream.
        Can be "global", "thread_local" or "relaxed". During cuda graph capture, some actions, such as cudaMalloc,
        may be unsafe. "global" will error on actions in other threads, "thread_local" will only error for
        actions in the current thread, and "relaxed" will not error on actions. Do NOT change this setting
        unless you're familiar with `cudaStreamCaptureMode <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85>`_
    enable_annotations (bool, optional): If ``True``, enables kernel annotation
        recording on entry and automatically calls
        :func:`~torch.cuda._graph_annotations.resolve_pending_annotations` before
        the capture ends.  Annotations are **not** cleared on exit so that multiple
        graphs in the same workload can accumulate annotations.
        Requires ``cuda.bindings`` package and cuda-compat >= 13.1 or CUDA driver >= 13.1.
        Requires single-threaded autograd; wrap the capture in
        ``torch.autograd.grad_mode.set_multithreading_enabled(False)``.
    annotation_config (dict, optional): Options for annotation recording, used when
        ``enable_annotations=True``. An unrecognized key or value raises. Currently
        supports ``"backend"``, which selects how ``mark_kernels`` scopes discover their
        nodes: ``"auto"`` (default) uses CUPTI node-creation callbacks when Cuspy
        already holds a subscription and otherwise walks the capture graph's
        dependent edges; ``"cupti"`` requires the CUPTI path, bringing Cuspy up if
        needed -- which prevents kineto from initializing, so a later
        :class:`torch.profiler.profile` records no GPU activity; ``"edge_walk"`` forces
        the walk, which cannot see nodes created while the current stream was not yet
        capturing.
        Also supports ``"key_by"``, which selects the graph the annotations stay keyed
        to: ``"exec"`` (default) rekeys them to the executable graph at each
        ``instantiate()``, matching the graph node id CUPTI reports for replayed work;
        ``"source"`` leaves them on the capture graph, for a consumer that reads CUPTI's
        ``sourceGraphNodeId`` instead (needs CUPTI >= 13.4 and a CUDA driver >= 13.4,
        else the capture raises); ``"auto"`` is ``"source"`` where the stack supports it
        and ``"exec"`` where it does not, so it never raises. ``"exec"`` remains the
        default because kineto reports only the exec node id, so a trace exported
        through it cannot resolve capture-keyed annotations.
        ``"record_py_stacks"`` (bool, default ``False``) records user Python launch
        frames for kernel, memcpy, memset, batch-memory, event, and host nodes.
        It requires CUPTI and single-threaded autograd: ``backend="auto"``
        acquires a CUPTI subscription as with ``"cupti"``, and ``"edge_walk"`` is
        rejected. By default, framework and generated Inductor frames are omitted. Conditional
        and child-graph bodies require ``key_by="source"``. Use ``"exec"`` keys for
        exported traces or ``"source"`` keys for CUPTI's ``sourceGraphNodeId``. Save stacks
        separately with :func:`~torch.cuda.graph_annotations.dump_kernel_py_stacks`
        or read them with :func:`~torch.cuda.graph_annotations.get_kernel_py_stacks`.
        ``"py_stack_filter_paths"`` (list or tuple of str, default ``None``) replaces
        the default stack filters with directories whose frames should be omitted.
        Paths are matched on directory boundaries; relative paths are resolved when
        capture begins. ``None`` uses the defaults; an empty list disables filtering.
        Used only with ``record_py_stacks=True``.
    check_input_liveness (bool, optional): If ``True``, tracks external tensor inputs during graph capture and
        raises an error if any are deallocated before replay. This helps debug "use after free" errors
        where input tensors are garbage collected between capture and replay. Default: ``False``.

        .. note::
            Custom CUDA kernels added outside PyTorch (e.g., via cuLaunchKernel or DLPack) are not
            tracked by this mechanism.

.. note::
    For effective memory sharing, if you pass a ``pool`` used by a previous capture and the previous capture
    used an explicit ``stream`` argument, you should pass the same ``stream`` argument to this capture.

.. warning::
    This API is in beta and may change in future releases.

.. _cudaStreamCaptureMode:
    https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85
Nútorch.cuda.Stream | NoneÚdefault_capture_streamc               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR
/# )r    rÆ  r   r!   r1   ra   rý  r÷   r�   Úenable_annotationsr<   Úannotation_configrê  rø   r$   )r%   s   "r&   r'   Úgraph.__annotate__   sP   € ÷ 9ñ 9àð9ð  ð9ð )ð	9ð
  ð9ð !ð9ð 8ð9ð #ñ9r(   c                	óê  € \        V4      V n        VfF   V P                  P                  f.   \        P
                  P                  4       V P                  n        \        V4      pVf   RMV3V n        Ve   TMV P                  P                  V n	        V P                  f   \        R4      h\        P
                  P                  V P                  4      V n        Wn        W@n        WPn        Wpn        R # )Nzcapture_stream must not be Noner$   )rû  Ú_annotation_configr´   rþ  r+   r,   ÚStreamr6   r!   Úcapture_streamri  ra   Ú
stream_ctxrÆ  r÷   Ú_enable_annotationsrø   )	rW   rÆ  r!   ra   r÷   r   r  rø   r%  s	   &&&&&&&& r&   rX   Úgraph.__init__   sÈ   € ô #;Ð;LÓ"MˆÔð Š>˜dŸn™n×CÑCÒKÜ49·J±J×4EÑ4EÓ4GˆD�N‰NÔ1ä˜tÓ$ˆà’/‰B¨ zð 	Œ	ð Ò(‰F¨d¯n©n×.SÑ.Sð 	Ôð ×ÑÒ&Ü Ð!BÓCÐCÜŸ*™*×+Ñ+¨D×,?Ñ,?Ó@ˆŒØ$ŒØ"4ÔØ#5Ô Ø$8Ö!r(   c               ó   € V ^8„  d   QhRR/# rD   r$   )r%   s   "r&   r'   r     s   € ÷ Pñ P˜4ñ Pr(   c                	óÎ  € \         P                  P                  4        \         P                  P                  P
                  '       d   \        P                  ! 4        \         P                  P                  4        \         P                  P                  4        ^ RIHp ^ RIHpHpHpHp V P$                  R,          pV P&                  '       d<   VR9   d5   ^ RIHp V! 4       pVR8X  d   V'       d   RMRpMV'       g   \+        R4      hVR8X  d   RMTpW`P,                  n        V! V4       R	p	V P$                  R
,          p
V P&                  ;'       d    V P$                  R,          pV P&                  '       d²   V
R	8w  d«   V
R8H  ;'       g    Tp\         P                  P1                  4       '       d   V'       d   \+        R4      hMcVP3                  VVV P$                  R,          R7      '       d   Rp	M5V'       d.   V'       d   RMRpV'       d   RMRp\+        V R2V,           4      hV! V P&                  4       V P4                  P7                  4        V P,                  P8                  ! V P:                  RV P<                  RV P>                  /   V! V P,                  4       V	R8X  d<   VPA                  4       '       g&   VPC                  4        V'       d   \+        R4      hR	p	V! V	4       R#   \D         de    TPC                  4        T! R4        T P,                  PG                  4        M  \H         d     Mi ; iT P4                  PK                  RRR4       h i ; i)r   ©Ú_graph_node_callbacks)Ú_set_annotation_backendÚ_set_annotation_key_byÚ_set_annotations_enabledÚmaybe_stamp_capture_rooträ  rå   Úauto)Úsource_node_ids_availabler®   a  annotation_config={'key_by': 'source'} keeps annotations keyed to the capture graph, which needs a consumer reading CUPTI's sourceGraphNodeId (CUPTI >= 13.4) and a CUDA driver >= 13.4 or an equivalent cuda-compat. Use 'auto' to fall back to the exec graph instead.rð  rã  rå  Úcuptiz÷The CUPTI annotation backend requires single-threaded autograd, so that graph nodes are created on the capturing thread and attributed to the right mark_kernels scope. Wrap the capture in torch.autograd.grad_mode.set_multithreading_enabled(False).ræ  )Úforcerå  ræ  zrecord_py_stacks=Truezbackend='cupti'zJDisable record_py_stacks and use backend='auto' to capture without stacks.z;Use backend='auto' to fall back to the dependent-edge walk.z½ could not register CUPTI node-creation callbacks. This requires cupti-python, CUPTI >= 13.3, and a CUPTI subscription not already held by another profiler (e.g. Kineto or Nsight Systems). r÷   rø   zArecord_py_stacks=True could not arm CUPTI node-creation callbacksFN)rå   r  )&r+   r,   r\   Úcompilerré  Úforce_cudagraph_gcÚgcÚcollectÚempty_cacherÃ  Ú_host_emptyCacheÚ
torch.cudar  r¼   r  r  r  r  r  r  r  rH   rÆ  rž   Ú_is_multithreading_enabledÚregisterr  Ú	__enter__rú   r!   r÷   rø   ÚarmÚdisarmÚBaseExceptionr   r]   Ú__exit__)rW   r  r  r  r  r  rä  r  Ú	supportedrã  Ú	requestedrå  r  ÚreasonÚfallbacks   &              r&   r  Úgraph.__enter__   s  € ä�
‰
×ÑÔ ä�>‰>× Ñ ×3×3Ð3ô �JŠJŒLä�
‰
×ÑÔ ä�‰×!Ñ!Ô#õ 	5÷	
ó 	
ð ×(Ñ(¨Õ2ˆØ×#×#Ð#¨Ð2DÔ(DÝOá1Ó3ˆIà˜Ôß%.™°F‘ßÜ"ðIóð ð " VÔ+‘°ˆØ-3�‰Ô*Ù˜vÔ&àˆØ×+Ñ+¨IÕ6ˆ	à×$Ñ$×TÐT¨×)@Ñ)@ÐASÕ)Tð 	ð ×#×#Ð#¨	°[Ô(@Ø Ñ(×<Ð<Ð,<ˆEô �x‰x×2Ñ2×4Ò4ßÜ&ðVóð ð ð '×/Ñ/ØØ!1Ø&*×&=Ñ&=Ð>UÕ&Vð 0÷ ò ð
 "‘ßç/?Ñ+ÐEVð ÷
 (ñ aàVð ô
 #Ø�hð ]ð ]ð õóð ñ 	! ×!9Ñ!9Ô:ð 	�‰×!Ñ!Ô#à�‰×%Ò%à�Y‰Yð	
ð  $×6Ñ6ð		
ð "&×!:Ñ!:ò	
ð"	Ù$ T§_¡_Ô5ð
 ˜'Ô!Ð*?×*CÑ*C×*EÒ*EØ%×,Ñ,Ô.ß#Ü&Ø[óð ð &�Ù# GÖ,øÜô 		Ø!×(Ñ(Ô*Ù$ UÔ+ðØ—‘×/Ñ/Õ1øÜô áðúð �O‰O×$Ñ$ T¨4°Ô6Øð		ús<   Ê.K5 ËK5 ËK5 Ë5#M$ÌL4Ì3M$Ì4MÌ?M$ÍMÍ"M$c               ó    € V ^8„  d   QhRRRR/# )r    Úargsr"   r#   rE   r$   )r%   s   "r&   r'   r  ²  s   € ÷ &,ñ &,˜fð &,¨ñ &,r(   c                	ó@  € ^ RI Hp ^ RIHpHpHpHp  VP                  4        V P                  '       d0   V! 4        V P                  ;P                  V! 4       ,          un
         V P                  P                  4         T P                  P                  ! T!   TP                  4        T! R4       R#   \         d'    T P                  '       d   T! T P                  4       h i ; i  T P                  P                  ! T!   TP                  4        T! R4       i ; i)r   r  )r  Údiscard_capture_annotationsÚresolve_pending_annotationsÚtake_body_graph_idsFN)r  r  r¼   r  r,  r-  r.  r!  r  rÆ  rŸ   r
  r"  r  r#  )rW   r*  r  r  r,  r-  r.  s   &*     r&   r#  Úgraph.__exit__²  sã   € Ý4÷	
ó 	
ð	,ð "×(Ñ(Ô*Ø×'×'Ð'Ù+Ô-Ø—‘×2Ò2Ñ6IÓ6KÕKÕ2ð
Ø—‘×+Ñ+Õ-ð �O‰O×$Ò$ dÒ+ð "×(Ñ(Ô*Ù$ UÖ+øô !ô à×+×+Ð+Ù/°·±Ô@Øð	ûð �O‰O×$Ò$ dÒ+ð "×(Ñ(Ô*Ù$ UÕ+ús(   ”!C) ¶/C) Á&B5 Â5C&ÃC&Ã&C) Ã)4D)r  r  r÷   r  rø   rÆ  r!   r  )NNr°  FNF)re   rf   rg   rh   ri   rþ  r±  rX   r  r#  rj   r$   r(   r&   r   r   ¯  s.   ‡ ñLð\ 8<ÐÐ4Ó;÷9õ@P÷d&,ñ &,r(   útorch.nn.Module.Ú_ModuleOrCallablec               ó8   € V ^8„  d   QhRRRRRRRRR	R
RRRRRR/# )r    Ú	callablesr1  Úsample_argsútuple[Tensor, ...]Únum_warmup_itersr6  Úallow_unused_inputr<   r!   r1   r÷   r�   r   r#   r$   )r%   s   "r&   r'   r'   à  sX   € ÷ ñ Ø ðà#ðð ðð ð	ð
 ðð ðð ðð ñr(   c                ó   € R # r|   r$   ©r3  r4  r6  r7  r!   r÷   r   s   &&&&&&&r&   Úmake_graphed_callablesr:  ß  s   € ñ r(   c               ó8   € V ^8„  d   QhRRRRRRRRR	R
RRRRRR/# )r    r3  ztuple[_ModuleOrCallable, ...]r4  ztuple[tuple[Tensor, ...], ...]r6  r6  r7  r<   r!   r1   r÷   r�   r   r#   r$   )r%   s   "r&   r'   r'   ì  sX   € ÷ (ñ (Ø,ð(à/ð(ð ð(ð ð	(ð
 ð(ð ð(ð ð(ð #ñ(r(   c                ó   € R # r|   r$   r9  s   &&&&&&&r&   r:  r:  ë  s   € ñ %(r(   c               ó8   € V ^8„  d   QhRRRRRRRRR	R
RRRRRR/# )r    r3  z1_ModuleOrCallable | tuple[_ModuleOrCallable, ...]r4  z3tuple[Tensor, ...] | tuple[tuple[Tensor, ...], ...]r6  r6  r7  r<   r!   r1   r÷   r�   r   r#   r$   )r%   s   "r&   r'   r'   ÷  sb   € ÷ Kñ KØ@ðKàDðKð ðKð ð	Kð
 ðKð ðKð ðKð 7ñKr(   c                ó6  € \         P                  ! 4       '       d'   \         P                  ! 4       '       d   \        R4      hRp\	        V \
        4      '       g0   RpV 3p \        P                  ! \
        \        R3,          V4      3pM5\        P                  ! \
        \
        \        R3,          R3,          V4      p. p	\        W4       EFq  w  r«\	        V
\         P                  P                  4      '       d»   \        V
P                  4      ^ 8X  d5   \        V
P                  4      ^ 8X  d   \        V
P                  4      ^ 8X  g   \!        R4      h\"        ;QJ d*    R V
P%                  4        4       F  '       d   K   RM	  RM! R V
P%                  4        4       4      '       g   \!        R4      h\         P&                  P(                  P*                  ! V!  pV	P-                  \        V4      4       \"        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   EKi  \!        R4      h	  V	 Uu. uF  p\        V4      NK  	  ppV  U
u. uFH  p
\	        V
\         P                  P                  4      '       d   \        V
P/                  4       4      MRNKJ  	  pp
\1        \        V 4      4       Uu. uF  pWŸ,          Wï,          ,           NK  	  pp\1        \        V 4      4       Uu. uF!  p\         P2                  P5                  4       NK#  	  pp\1        \        V 4      4       Uu. uF!  p\         P2                  P5                  4       NK#  	  ppVf   \7        4       M
\9        V4      p\         P2                  P;                  4        \         P2                  P=                  4       p\         P2                  P?                  V4      ;_uu_ 4        \        WV4       EF  w  pppRRRppp\1        V4       Fæ  p\         P&                  P(                  PA                  V! V!  4      p\
        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        V4      ^ 8”  g   Kn  \         PB                  PE                  T\
        ;QJ d    . R	 V 4       F  NK  	  5M! R	 V 4       4      \
        ;QJ d    . R
 V 4       F  NK  	  5M! R
 V 4       4      RVR7      pKè  	  VVV3 F  p?K  	  EK  	  RRR4       \         P2                  P;                  4        . p. p\        WV4       F™  w  ppp\         P2                  PG                  VVVVVR7      ;_uu_ 4        V! V!  pRRR4       \         P&                  P(                  PI                  X4      w  p p!VP-                  \        V 4      4       VP-                  V!4       K›  	  . p". p#\        \K        V4      \K        V4      \K        V4      4       EF£  w  pp$p%\
        ;QJ d    . R V$ 4       F  NK  	  5M! R V$ 4       4      p&\
        ;QJ d    . R V$ 4       F  NK  	  5M! R V$ 4       4      pRp\        V4      ^ 8”  d®   \         P2                  PG                  V%VVVVR7      ;_uu_ 4        \         PB                  PE                  T\
        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      \
        ;QJ d    . R V& 4       F  NK  	  5M! R V& 4       4      RVR7      pRRR4       . p'^ p(V FM  p)V)PL                  '       d(   Ve$   V'P-                  VV(,          4       V(^,          p(K<  V'P-                  R4       KO  	  \        V'4      p'V"P-                  V&4       V#P-                  V'4       EK¦  	  V"PO                  4        V#PO                  4        R R lp*. p+\Q        V 4       FË  w  ppV*! VV,          VV,          Wï,          Wß,          VV,          VV,          VV,          V"V,          V#V,          4	      p,\	        V\         P                  P                  4      '       d>   R R lp-V-! VVPR                  V,VPT                  4      Vn*        V+P-                  V4       Kº  V+P-                  V,4       KÍ  	  V'       d
   V+^ ,          # \        V+4      # u upi u up
i u upi u upi u upi   + '       g   i     ELç; i  + '       g   i     EL‹; i  + '       g   i     ELù; i)aš  Accept callables (functions or :class:`nn.Module<torch.nn.Module>`\ s) and returns graphed versions.

Each graphed callable's forward pass runs its source callable's
forward CUDA work as a CUDA graph inside a single autograd node.

The graphed callable's forward pass also appends
a backward node to the autograd graph. During backward, this node runs the
callable's backward work as a CUDA graph.

Therefore, each graphed callable should be a drop-in replacement for its source callable
in an autograd-enabled training loop.

See :ref:`Partial-network capture<partial-network-capture>` for detailed use and constraints.

If you pass a tuple of several callables, their captures will use the same memory pool.
See :ref:`Graph memory management<graph-memory-management>` for when this is appropriate.

Arguments:
    callables (torch.nn.Module or Python function, or tuple of these): Callable or callables to graph.
        See :ref:`Graph memory management<graph-memory-management>` for when passing a tuple of callables
        is appropriate.  If you pass a tuple of callables, their order in the tuple must be the same order
        they'll run in the live workload.
    sample_args (tuple of Tensors, or tuple of tuples of Tensors): Samples args for each callable.
        If a single callable was passed, ``sample_args`` must be a single tuple of argument Tensors.
        If a tuple of callables was passed, ``sample_args`` must be tuple of tuples of argument Tensors.
    num_warmup_iters (int): The number of warmup iterations. Currently, ``DataDistributedParallel`` needs
        11 iterations for warm up. Default: ``3``.
    allow_unused_input (bool): If False, specifying inputs that were not used when computing outputs
        (and therefore their grad is always zero) is an error. Defaults to False.
    pool (optional): Token (returned by :func:`~torch.cuda.graph_pool_handle` or
        :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) or
        :class:`~torch.cuda.MemPool` that hints this graph may share memory
        with the indicated pool.  See :ref:`Graph memory management<graph-memory-management>`.
    enable_annotations (bool, optional): If ``True``, the forward and backward
        captures record kernel annotations from
        :func:`torch.cuda.graph_annotations.mark_kernels` scopes inside the
        callables (backward kernels are tagged via the scopes' autograd node
        hooks). See :mod:`torch.cuda.graph_annotations`. Default: ``False``.

.. note::
    The ``requires_grad`` state of each Tensor in ``sample_args`` must match the state
    that's expected for the corresponding real input in the training loop.

.. warning::
    This API is in beta and may change in future releases.

.. warning::
    ``sample_args`` for each callable must contain only Tensors. Other types are not allowed.

.. warning::
    Returned callables do not support higher order differentiation (e.g., double backward).

.. warning::
    In any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters
    may be trainable. Buffers must have ``requires_grad=False``.

.. warning::
    After you pass a :class:`torch.nn.Module` through :func:`~make_graphed_callables`,
    you may not add or remove any of that Module's parameters or buffers.

.. warning::
    :class:`torch.nn.Module`\s passed to :func:`~torch.cuda.make_graphed_callables` must not have module hooks
    registered on them at the time they are passed. However, registering hooks on modules *after* passing them
    through :func:`~torch.cuda.make_graphed_callables` is allowed.

.. warning::
    When running a graphed callable, you must pass its arguments in the same order and format
    they appeared in that callable's ``sample_args``.

.. warning::
    The automatic mixed precision is supported in :func:`~torch.cuda.make_graphed_callables` only with disabled
    caching. The context manager `torch.cuda.amp.autocast()` must have `cache_enabled=False`.
z_make_graphed_callables does not support the autocast caching. Please set `cache_enabled=False`.FT.c              3  ó<   "  € T F  qP                   R J x € K  	  R# 5irO   ©Úrequires_grad©rí  Úbs   & r&   rî  Ú)make_graphed_callables.<locals>.<genexpr>e  s   é € ÐE¹°A—‘¨%Õ/»ùs   ‚c              3  óV   "  € T F  p\        V\        P                  4      x € K!  	  R # 5ir|   )r-   r+   r   )rí  Úargs   & r&   rî  rD  m  s   é € ÐH¹K°S”:˜c¤5§<¡<×0Ð0»Kùs   ‚')Nc              3  óL   "  € T F  qP                   '       g   K  Vx € K  	  R # 5ir|   r@  ©rí  Úos   & r&   rî  rD  ’  s   é € Ð$K±¨1¿?½?§Q¢Q³ùó   ‚$š
$c              3  óL   "  € T F  qP                   '       g   K  Vx € K  	  R # 5ir|   r@  ©rí  rž  s   & r&   rî  rD  –  s   é € ð %Ù'; !¿½ŸAšAÓ';ùrJ  c              3  ót   "  € T F.  qP                   '       g   K  \        P                  ! V4      x € K0  	  R # 5ir|   ©rA  r+   Ú
empty_likerH  s   & r&   rî  rD  ™  s(   é € ð +Ù9@°AÇOÅOÔ/œE×,Ò,¨Q×/Ð/»ùs   ‚8š8)ÚoutputsÚinputsÚgrad_outputsÚonly_inputsÚallow_unused)ra   r!   r÷   r   c              3  ót   "  € T F.  qP                   '       d   \        P                  ! V4      MR x € K0  	  R # 5ir|   rN  rH  s   & r&   rî  rD  Ã  s)   é € ð $
ÙFTÀ§?§? ?ŒE×Ò˜QÔ¸Ô<Ãnùs   ‚68c              3  óL   "  € T F  qP                   '       g   K  Vx € K  	  R # 5ir|   r@  rH  s   & r&   rî  rD  Ç  s   é € ÐJ© 1¿/½/ŸQšQ«ùrJ  c              3  óL   "  € T F  qP                   '       g   K  Vx € K  	  R # 5ir|   r@  rL  s   & r&   rî  rD  Ó  s   é € Ð TÑ,@ qÇOÅO§¢Ó,@ùrJ  c              3  ó0   "  € T F  qf   K  Vx € K  	  R # 5ir|   r$   rH  s   & r&   rî  rD  Ô  s   é € Ð&WÑ2E¨Q§q¢qÓ2Eùs   ‚Œ
c               ó@   € V ^8„  d   QhRRRRRRRRRR	R
RRRRRRRRR/
# )r    Ú	fwd_graphr   Ú	bwd_graphÚmodule_paramsztuple[torch.nn.Parameter, ...]Úlen_user_argsr6  Úoutput_unflatten_specztorch.utils._pytree.TreeSpecÚstatic_input_surfacer5  Ústatic_outputsÚstatic_grad_outputsútuple[Tensor | None, ...]Ústatic_grad_inputsr#   zCallable[..., object]r$   )r%   s   "r&   r'   Ú,make_graphed_callables.<locals>.__annotate__î  sx   € ÷ Kñ KØðKàðKð 6ðKð ð	Kð
  <ðKð 1ðKð +ðKð 7ðKð /ðKð 
ñKr(   c	                óŠ   aaaaaaaa
a€ W3o ! VVVVV3R  lR\         P                  P                  4      o
R V
VVV3R llp	V	# )c                  óœ   <€ ] tR tRt]R V VV3R ll4       t]]P                  P                  P                  R VV3R ll4       4       t
RtR# )ÚOmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphedi  c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r    Úctxr   Úgraphsztuple[CUDAGraph, CUDAGraph]rQ  r   r#   r5  r$   )r%   s   "r&   r'   Ú\make_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.__annotate__  s2   € ÷ Añ AØðAØ"=ðAØHNðAà#ñAr(   c                	ó®  <€ Vw  r4W@n         \        S4       FS  pSV,          P                  4       W%,          P                  4       8w  g   K5  SV,          P                  W%,          4       KU  	  VP	                  4        \        S\        4      '       g   \        R \        S4       24      h\        ;QJ d    . R S 4       F  NK  	  5# ! R S 4       4      # )z"static_outputs must be tuple, got c              3  ó@   "  € T F  qP                  4       x € K  	  R # 5ir|   ©r  rH  s   & r&   rî  Újmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward.<locals>.<genexpr>  s   é € Ð@±¨AŸX™XŸZ˜Z³ùs   ‚)	r[  rx  Údata_ptrÚcopy_r  r-   ró  ri  rc  )	ri  rj  rQ  rZ  r[  rž  r]  r_  r`  s	   &&*   €€€r&   ÚforwardÚWmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward  s³   ø€ ð
 (.Ñ$�	Ø )”ä˜}Ö-�AØ+¨AÕ.×7Ñ7Ó9¸V½Y×=OÑ=OÓ=QÖQØ,¨QÕ/×5Ñ5°fµiÖ@ñ .ð × Ñ Ô"Ü! .´%×8Ò8Ü(Ø<¼TÀ.Ó=QÐ<RÐSóð ÷ ”uÑ@±Ó@—uÐ@�uÑ@±Ó@Ó@Ð@r(   c               ó$   € V ^8„  d   QhRRRRRR/# )r    ri  r   Úgradsr   r#   rb  r$   )r%   s   "r&   r'   rk    s"   € ÷ ñ ˜cð ¨6ð Ð6Oñ r(   c                	ó  <€ \        V4      \        S4      8w  d$   \        R \        V4       R\        S4       24      h\        SV4       FA  w  r#Vf   K  VP                  4       VP                  4       8w  g   K0  VP	                  V4       KC  	  V P
                  P                  4        \        S\        4      '       g   \        R\        S4       24      hR\        ;QJ d    . R S 4       F  NK  	  5,           # ! R S 4       4      ,           # )zlen(grads)=z != len(static_grad_outputs)=z&static_grad_inputs must be tuple, got c              3  óN   "  € T F  pVe   VP                  4       MTx € K  	  R # 5ir|   rn  rB  s   & r&   rî  Úkmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward.<locals>.<genexpr>+  s(   é € ð 'ñ 0˜ð #$¢-�A—H‘H”J°QÔ6Û/ùs   ‚#%r|   )
Úlenri  Úziprp  rq  r[  r  r-   ró  rc  )ri  ru  ÚgÚgradrc  ra  s   &*  €€r&   ÚbackwardÚXmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward  s   ø€ ô �u“:¤Ð%8Ó!9Ô9Ü(Ø%¤c¨%£j \Ð1NÌsÐSfÓOgÐNhÐióð ô  #Ð#6¸Ö>‘G�AØ”}ð Ÿ:™:›<¨4¯=©=«?Ö:ØŸG™G DžMñ  ?ð —‘×$Ñ$Ô&ô "Ð"4´e×<Ò<Ü(Ø@ÄÐFXÓAYÐ@ZÐ[óð ð §¤ñ 'ñ 0ó'§õ ð  ñ 'ñ 0ó'ó "õ ð r(   r$   N)re   rf   rg   rh   Ústaticmethodrr  r+   ÚautogradÚfunctionÚonce_differentiabler}  rj   )r]  rc  ra  r_  r`  s   €€€€€r&   ÚGraphedrg    sN   ø† Ø÷Añ Aó ðAð  Ø�^‰^×$Ñ$×8Ñ8÷ð ó 9ó ôr(   rƒ  c               ó    € V ^8„  d   QhRRRR/# )r    Ú	user_argsr"   r#   r$   )r%   s   "r&   r'   ÚTmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.__annotate__1  s   € ÷ 	Rñ 	R vð 	R°&ñ 	Rr(   c                 óð   <€ \         P                  P                  P                  ! V !  pSP                  ! S.\        V4      S,           O5!  p\         P                  P                  P                  VS4      # r|   )r+   ÚutilsÚ_pytreeÚarg_tree_leavesÚapplyró  Útree_unflatten)r…  Úflatten_user_argsÚoutrƒ  rj  r\  r^  s   *  €€€€r&   ÚfunctionalizedÚVmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.functionalized1  s\   ø€ ô !&§¡× 3Ñ 3× CÒ CÀYÑ OÐØ—-’- ÐT¬%Ð0AÓ*BÀ]Õ*RÓTˆCÜ—;‘;×&Ñ&×5Ñ5°cÐ;PÓQÐQr(   )r+   r€  ÚFunction)rZ  r[  r\  r]  r^  r_  r`  ra  rc  r�  rƒ  rj  s   &&fffffff @@r&   Úmake_graphed_autograd_functionÚ>make_graphed_callables.<locals>.make_graphed_autograd_functionî  s>   ÿø€ ð$ Ð'ˆ÷-	ó -	”e—n‘n×-Ñ-ô -	÷^	Ró 	Rð Ðr(   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r    r…  r0  Úgraph_training_stater<   ÚgraphedzCallable[_P, _R]Úorig_fwdr#   r$   )r%   s   "r&   r'   rd  L  s:   € ÷ *ñ *Ø%ð*à&*ð*ð *ð*ð +ð	*ð
 "ñ*r(   c                ó    aaaaa€ \         P                  ! V 4      o\        VR R4      V J oS'       d   VP                  MToR VVVVV3R llpV# )Ú__self__Nc               ó$   € V ^8„  d   QhRRRRRR/# )r    r…  z_P.argsÚuser_kwargsz	_P.kwargsr#   r   r$   )r%   s   "r&   r'   ÚJmake_graphed_callables.<locals>.make_graphed_forward.<locals>.__annotate__f  s&   € ÷ Dñ D¨ð DÀ	ð DÈbñ Dr(   c                 óš   <€ S! 4       pVf   \        R4      hVP                  S8X  d	   S! V / VB # S'       d   S! V.V O5/ VB # S! V / VB # )NzJthe graphed module has been freed; its forward cannot be called on its own)rH   Útraining)r…  r›  ÚmoduleÚfunc_refr•  r–  Úorig_bound_to_funcÚ	orig_calls   *, €€€€€r&   Únew_fwdÚEmake_graphed_callables.<locals>.make_graphed_forward.<locals>.new_fwdf  sh   ø€ Ù%›Z�FØ’~Ü*ð0óð ð —‘Ð*>Ô>Ù&¨	ÐA°[ÑAÐAß+Ù(¨ÐK°)ÒK¸{ÑKÐKá(¨)ÐC°{ÑCÐCr(   )r¿   Úrefr*   Ú__func__)r…  r•  r–  r—  r£  r   r¡  r¢  s   &ff& @@@r&   Úmake_graphed_forwardÚ4make_graphed_callables.<locals>.make_graphed_forwardL  sT   ü€ ô #Ÿ;š; tÓ,�ô &-¨X°zÀ4Ó%HÈDÐ%PÐ"÷ *ð ×%Ò%à!ð ÷Dô Dð  �r(   z§Modules must not have hooks registered at the time they are passed. However, registering hooks on modules after passing them through make_graphed_callables is allowed.zœIn any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have ``requires_grad=False``.zfIn the beta API, sample_args for each callable must contain only Tensors. Other types are not allowed.r$   )+r+   Úis_autocast_enabledÚis_autocast_cache_enabledrH   r-   ró  r3   r4   r   rz  ÚnnÚModulery  Ú_backward_hooksÚ_forward_hooksÚ_forward_pre_hooksri  rô  Úbuffersrˆ  r‰  rŠ  r�  Ú
parametersrx  r,   r   rB   r6   r\   r  ra   Útree_leavesr€  r|  r   Útree_flattenÚreversedrA  ÚreverseÚ	enumeraterž  rr  ).r3  r4  r6  r7  r!   r÷   r   Újust_one_callableÚ_sample_argsÚflatten_sample_argsÚcr*  Úflatten_argÚper_callable_len_user_argsÚper_callable_module_paramsrž  Ú"per_callable_static_input_surfacesrš  Ú
fwd_graphsÚ
bwd_graphsÚmempoolra   r…  r_  Úgrad_inputsrP  Úoutputs_gradÚvÚper_callable_static_outputsÚ"per_callable_output_unflatten_specrZ  Úfunc_outputsÚflatten_outputsÚspecÚ per_callable_static_grad_outputsÚper_callable_static_grad_inputsr`  r[  ra  rc  Úgrad_idxrF  r’  Úretr–  r§  s.   &&&&&&&                                       r&   r:  r:  ÷  s°  € ôd × Ò ×"Ò"¤u×'FÒ'F×'HÒ'HÜØmó
ð 	
ð Ðô �i¤×'Ò'Ø ÐØ�Lˆ	ÜŸš¤E¬&°#¨+Õ$6¸ÓDÐF‰ä—{’{¤5¬¬v°s¨{Õ);¸SÐ)@Õ#AÀ;ÓOˆàÐä�y×/‰ˆÜ�aœŸ™Ÿ™×)Ò)ä�A×%Ñ%Ó&¨!Ô+Ü˜×(Ñ(Ó)¨QÔ.Ü˜×,Ñ,Ó-°Ô2ä$ðaóð ÷ “3ÑE¸¿¹¼ÓE—3—3’3ÑE¸¿¹¼ÓE×EÒEÜ$ð1óð ô
 —k‘k×)Ñ)×9Ò9¸4Ñ@ˆØ×"Ñ"¤5¨Ó#5Ô6ß‹sÑH¹KÓH�s�sŠsÑH¹KÓH×HÕHÜ ð^óð ñ) 0ñ6 9LÓ!LÑ8K°¤# d¦)Ñ8KÐÐ!Lñ ó"áˆAô ",¨A¬u¯x©x¯©×!?Ò!?Œˆa�l‰l‹nÔÀRÒGÙð ð "ô ”s˜9“~Ô&ó*á&ˆAð 	ÕÐ!;Õ!>×>Ð>Ù&ð 'ð *ô
 38¼¸I»Ô2GÓHÑ2G¨Q”%—*‘*×&Ñ&Ö(Ñ2G€JÐHÜ27¼¸I»Ô2GÓHÑ2G¨Q”%—*‘*×&Ñ&Ö(Ñ2G€JÐHà%)¢\ÔÔ!´|ÀDÓ7I€Gô
 
‡J�J×ÑÔô �Z‰Z×ÑÓ €FÜ	�‰×	Ñ	˜6×	"Õ	"Ü03ØÐ%G÷1
Ñ,ˆD�$Ð,ð 26°t¸T ,˜ˆKÜÐ+Ö,�ÜŸ+™+×-Ñ-×9Ñ9¹$À¹+ÓF�ß$œuÑ$K±Ó$KŸu™uÑ$K±Ó$KÓK�Ü�|Ó$ qÖ(Ü"'§.¡.×"5Ñ"5Ø ,ß$œuñ %Ù';ó%Ÿu™uñ %Ù';ó%ó  ÷ &+¤Uñ +Ù9@ó+§U¡Uñ +Ù9@ó+ó &ð %)Ø%7ð #6ó 
#’Kñ	 -ð ˜|¨[Ó9�Úô :ñ'1
÷ 
#ô. 
‡J�J×ÑÔð #%ÐØ)+Ð&Ü!$ Y¸jÖ!IÑˆˆd�IÜ�Z‰Z×ÑØØØØ1Ø1ð ÷ 
õ 
ñ   ™;ˆL÷
ô !&§¡× 3Ñ 3× @Ñ @ÀÓ NÑˆ˜Ø#×*Ñ*¬5°Ó+AÔBØ*×1Ñ1°$Ö7ñ "Jð (*Ð$Ø&(Ð#Ü;>ÜÐ3Ó4ÜÐ,Ó-Ü�Ó÷<Ñ7Ð˜n¨i÷ $œeñ $
ÙFTó$
Ÿe™eñ $
ÙFTó$
ó 
Ð÷ ”uÑJ©ÓJ—u‘uÑJ©ÓJÓJˆØˆÜˆ|Ó˜qÔ Ü—‘×!Ñ!ØØØØ#5Ø#5ð "÷ õ ô $Ÿn™n×1Ñ1Ø(ß œ5Ñ TÑ,@Ó TŸ5™5Ñ TÑ,@Ó TÓTß!&¤Ñ&WÑ2EÓ&W§¡Ñ&WÑ2EÓ&WÓ!WØ $Ø!3ð 2ó �÷ð$  ÐØˆÛ'ˆCØ× × Ð  [Ò%<Ø"×)Ñ)¨+°hÕ*?Ô@Ø˜A•’à"×)Ñ)¨$Ö/ñ (ô #Ð#5Ó6Ðà(×/Ñ/Ð0CÔDØ'×.Ñ.Ð/A×BñW<ð\ %×,Ñ,Ô.Ø#×+Ñ+Ô-õKð\ $&€CÜ˜YÖ'‰ˆˆ4Ù0Ø�q�MØ�q�MØ&Õ)Ø&Õ)Ø.¨qÕ1Ø.¨qÕ1Ø'¨Õ*Ø,¨QÕ/Ø+¨AÕ.ó

ˆô �dœEŸH™HŸO™O×,Ò,õ*ñX 0Ø�d—m‘m W¨d¯l©lóˆDŒLð �J‰J�tÖà�J‰J�wÖñA (÷D Ø�1�vˆä�‹:Ðùò[ "Mùò"ùò*ùò
 IùÚH÷ 
#×	"Ð	"ú÷B
÷ 
ð 
ú÷<÷ ð ús]   ÉcÉAcËcË;'cÌ:'cÏBcÑ3$cÒ*cÓ>cÕ*c3ÚAdÛ/(dãc0	ã3däd)r>   rB   r   r   r:  rÖ  râ  r‚   r…   rˆ   r‹   rŽ   r’   )r  )r  r  rð  )r®   )r®   rå   r  )F)FT)NN)é   FNr°  F)WÚ__conditional_annotations__Ú
__future__r   r¹  r  r3   r’  r¿   Úcollectionsr   Úcollections.abcr   r   r   r   r	   r
   r   Útyping_extensionsr   r   r   r+   r   Útorch.cuda._utilsr   Úcuda.bindingsr   rh  r   rG   ÚImportErrorr  r   r   rû   r   rv   r   r   r±  Ú_utilsr   Ú__all__r   r   r/   r6   ÚhasattrrÃ  Ú__dict__Útorch._Cr:   r8   r9   r>   rB   rI   rK   rl   rm   rn   ro   rp   rx   r}   r‚   r…   rˆ   r‹   rŽ   r�   r’   r—   r   Ú	Structurer´  rŽ  r1  rÖ  râ  rç  rû  r   r"   r1  r:  )rÏ  s   @r&   Ú<module>rÝ     s¨  øðç "Ð "ã Û 	Û Û Û Ý #Ý $ß L× Lß 6Ñ 6ã Ý Ý 2ð÷÷ ç0ÝFÝ1à(¨7Õ2€J�	Ô2à"ŸJ™J€J�	Ó&å  ò€ñ" ˆTƒ]€Ùˆtƒ_€õEõ
-ñ ˆu�x‰xÐ*×+Ò+á&1°,Ó&?€E‡H�H×Ñ�lÑ#Ù.9Ð:NÓ.O€E‡H�H×ÑÐ*Ñ+Ù:EØ(ó;€E‡H�H×ÑÐ6Ñ7÷ TÑ Sõ,õ9õ

÷+ñ +ñl ƒMð ÐJó ñ LWË=Ð ÐHÓ XÙKVË=Ð ÐHÓ XáƒMð ÐIó ñ KVË-Ð ÐGÓ WõõõBõ@õ@õ
Aõ?ñ GRÃmÐ ÐCÓ Sõõô]�
ô ]ô@ˆf×Ñô õ7ðÈ÷ ð	¨T÷ 	õð$ Ð7ØÐ2ØÐ.Ø˜\ð	XÐ ÐTó õ ÷Fi,ñ i,ðZ	  %Ð%6¸ÀÀfÀÕ8MÐ%MÕNÐ �9Ó Nð 
öó 
ðð 
ö(ó 
ð(÷Kñ Køð. ô Ø€LØƒMðús   ÁI6 É6JÊJ