ó
    Eñi–p  ã                  ó¬  • % S SK Jr  S SKrS SKrS SKJr  S SKJrJrJrJ	r	  S SK
JrJrJr  S SKrS SKJr  \(       a  S SKJr  SS	KJr  / S
Qr\" S5      r\" S5      r\" \R0                  S5      (       d]  \" S5      \R0                  R2                  S'   \" S5      \R0                  R2                  S'   \" S5      \R0                  R2                  S'   S SKJrJrJr  SS jrS S jr " S S\5      r  " S S5      r!\	S\S\"4   4   r#S\$S'   \   S!           S"S jj5       r%\   S!           S#S jj5       r%   S!           S$S jjr%g)%é    )ÚannotationsN)ÚCallable)ÚoverloadÚTYPE_CHECKINGÚ	TypeAliasÚUnion)Ú	ParamSpecÚSelfÚTypeVar)ÚTensor)Ú_POOL_HANDLEé   )Ú_dummy_type)Úis_current_stream_capturingÚgraph_pool_handleÚ	CUDAGraphÚgraphÚmake_graphed_callablesÚ_RÚ_PÚ_CudaStreamBaseÚ
_CUDAGraphÚ_graph_pool_handleÚ_cuda_isCurrentStreamCapturing)r   r   r   c                 ó   • [        5       $ )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   © ó    ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/cuda/graphs.pyr   r   -   s   € ô
 *Ó+Ð+r   c                 óP   • [         R                  R                  [        5       5      $ )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.
)ÚtorchÚcudar   r   r   r   r   r   r   6   s   € ô �:‰:×"Ñ"Ô#5Ó#7Ó8Ð8r   c                  óä   ^ • \ rS rSrSrSSU 4S jjjr S     SU 4S jjjrSU 4S jjrSU 4S jjrSU 4S jjr	SU 4S jjr
SU 4S	 jjrSU 4S
 jjrSU 4S jjrSU 4S jjrSU 4S jjrSrU =r$ )r   éB   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 called
        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.

c                ó"   >• [         TU ]  X5      $ ©N)ÚsuperÚ__new__)ÚclsÚ
keep_graphÚ	__class__s     €r   r'   ÚCUDAGraph.__new__]   s   ø€ Ü‰w‰˜sÓ/Ð/r   c                ó    >• [         TU ]  XS9  g)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>`) 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>`_
)ÚpoolÚcapture_error_modeN)r&   Úcapture_begin)Úselfr-   r.   r*   s      €r   r/   ÚCUDAGraph.capture_begin`   s   ø€ ô& 	‰Ñ 4ÐÒOr   c                ó"   >• [         TU ]  5         g)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&   Úcapture_end©r0   r*   s    €r   r3   ÚCUDAGraph.capture_endu   s   ø€ ô 	‰ÑÕr   c                ó"   >• [         TU ]  5         g)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``.
N)r&   Úinstantiater4   s    €r   r7   ÚCUDAGraph.instantiate€   s   ø€ ô 	‰ÑÕr   c                ó"   >• [         TU ]  5         g)z,Replay the CUDA work captured by this graph.N)r&   Úreplayr4   s    €r   r:   ÚCUDAGraph.replay‰   s   ø€ ä‰‰Õr   c                ó"   >• [         TU ]  5         g)z1Delete the graph currently held by this instance.N)r&   Úresetr4   s    €r   r=   ÚCUDAGraph.reset�   s   ø€ ä‰‰�r   c                ó    >• [         TU ]  5       $ )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-   r4   s    €r   r-   ÚCUDAGraph.pool‘   s   ø€ ô ‰w‰|‹~Ðr   c                ó    >• [         TU ]  5       $ )z/Enable debugging mode for CUDAGraph.debug_dump.)r&   Úenable_debug_moder4   s    €r   rB   ÚCUDAGraph.enable_debug_mode™   s   ø€ ä‰wÑ(Ó*Ð*r   c                ó"   >• [         TU ]  U5      $ )z®
Arguments:
    debug_path (required): Path to dump the graph to.

Calls a debugging function to dump the graph if the debugging is
enabled via CUDAGraph.enable_debug_mode()
)r&   Ú
debug_dump)r0   Ú
debug_pathr*   s     €r   rE   ÚCUDAGraph.debug_dump�   s   ø€ ô ‰wÑ! *Ó-Ð-r   c                ó    >• [         TU ]  5       $ )am  Returns the underlying cudaGraph_t. ``keep_graph`` must be True.

See the following for APIs for how to manipulate this object: `Graph Managmement <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_graphr4   s    €r   rI   ÚCUDAGraph.raw_cuda_graph§   s   ø€ ô
 ‰wÑ%Ó'Ð'r   c                ó    >• [         TU ]  5       $ )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_execr4   s    €r   rL   ÚCUDAGraph.raw_cuda_graph_exec®   s   ø€ ô
 ‰wÑ*Ó,Ð,r   r   )F)r)   ÚboolÚreturnr
   )NÚglobal)r-   ú_POOL_HANDLE | Noner.   ÚstrrO   ÚNone©rO   rS   ©rO   r   )rF   rR   rO   rS   )rO   Úint)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r'   r/   r3   r7   r:   r=   r-   rB   rE   rI   rL   Ú__static_attributes__Ú__classcell__)r*   s   @r   r   r   B   sr   ø† ñ÷40ñ 0ð KSðPØ'ðPØDGðPà	÷Pð P÷*	÷÷÷÷÷+÷.÷(÷-õ -r   r   c                  ó^   • \ rS rSr% SrSrS\S'      S
       SS jjrSS jrSS jr	S	r
g)r   é¶   am  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>`) 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>`_

.. 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                ó�  • UcD  U R                   R                  c-  [        R                  R	                  5       U R                   l        Uc  SOU4U l        Ub  UOU R                   R                  U l        U R                  c  [        S5      e[        R                  R                  U R                  5      U l	        Xl
        X@l        g )Nr   zcapture_stream must not be None)r*   ra   r    r!   ÚStreamr-   Úcapture_streamÚAssertionErrorÚstreamÚ
stream_ctxÚ
cuda_graphr.   )r0   rh   r-   rf   r.   s        r   Ú__init__Úgraph.__init__Ö   s�   € ð ‰>˜dŸn™n×CÑCÑKÜ49·J±J×4EÑ4EÓ4GˆD�N‰NÔ1à;?¹<±RÈdÈWˆŒ	àÑ(‰F¨d¯n©n×.SÑ.Sð 	Ôð ×ÑÑ&Ü Ð!BÓCÐCÜŸ*™*×+Ñ+¨D×,?Ñ,?Ó@ˆŒØ$ŒØ"4Õr   c                óÈ  • [         R                  R                  5         [         R                  R                  R
                  (       a  [        R                  " 5         [         R                  R                  5         [         R                  R                  5         U R                  R                  5         U R                  R                  " U R                  SU R                   06  g )Nr.   )r    r!   ÚsynchronizeÚcompilerÚconfigÚforce_cudagraph_gcÚgcÚcollectÚempty_cacheÚ_CÚ_host_emptyCacherg   Ú	__enter__rh   r/   r-   r.   )r0   s    r   ru   Úgraph.__enter__í   s‹   € ä�
‰
×ÑÔ ä�>‰>× Ñ ×3×3ô �JŠJŒLä�
‰
×ÑÔ ä�‰×!Ñ!Ô#ð 	�‰×!Ñ!Ô#à�‰×%Ò%à�Y‰Yð	
ð  $×6Ñ6ó		
r   c                ój   • U R                   R                  5         U R                  R                  " U6   g r%   )rh   r3   rg   Ú__exit__)r0   Úargss     r   rx   Úgraph.__exit__  s$   € Ø�‰×#Ñ#Ô%Ø�‰× Ò  $Ò'r   )r.   rd   rh   r-   rg   )NNrP   )rh   r   r-   rQ   rf   r`   r.   rR   rT   )ry   ÚobjectrO   rS   )rW   rX   rY   rZ   r[   ra   Ú__annotations__ri   ru   rx   r\   r   r   r   r   r   ¶   sU   ‡ ñð: 8<ÐÐ4Ó;ð
 %)Ø+/Ø"*ð5àð5ð "ð5ð )ð	5ð
  õ5ô.
÷6(r   r   útorch.nn.Module.r   Ú_ModuleOrCallablec                ó   • g r%   r   ©Ú	callablesÚsample_argsÚnum_warmup_itersÚallow_unused_inputr-   s        r   r   r     s   € ð r   c                ó   • g r%   r   r€   s        r   r   r     s   € ð %(r   c                ó4  • [         R                  " 5       (       a%  [         R                  " 5       (       a  [        S5      eSn[	        U [
        5      (       d+  SnU 4n [        R                  " [
        [        S4   U5      4nO-[        R                  " [
        [
        [        S4   S4   U5      n/ n[        X5       GH  u  p‰[	        U[         R                  R                  5      (       a†  [        UR                  5      S:X  a2  [        UR                  5      S:X  a  [        UR                  5      S:X  d  [!        S5      e[#        S UR%                  5        5       5      (       d  [!        S5      e[         R&                  R(                  R*                  " U	6 n
UR-                  [        U
5      5        [#        S	 U
 5       5      (       a  GM  [!        S
5      e   U V	s/ s H  n	[        U	5      PM     nn	U  Vs/ s HG  n[	        U[         R                  R                  5      (       a  [        UR/                  5       5      OSPMI     nn[1        [        U 5      5       Vs/ s H  nX}   XÍ   -   PM     nn[1        [        U 5      5       Vs/ s H!  n[         R2                  R5                  5       PM#     nn[1        [        U 5      5       Vs/ s H!  n[         R2                  R5                  5       PM#     nnUc
  [7        5       OUn[         R2                  R9                  5         [         R2                  R;                  [         R2                  R=                  5       5         [        XU5       H¼  u  nn	nSu  nnn[1        U5       H“  n[         R&                  R(                  R?                  U" U	6 5      n[        S U 5       5      n[        U5      S:”  d  MR  [         R@                  RC                  U[        S U 5       5      [        S U 5       5      SUS9nM•     UUU4 H  nAM     M¾     SSS5        [         R2                  R9                  5         / n/ n[        XU5       HŠ  u  nn	n[         R2                  RE                  UUS9   U" U	6 nSSS5        [         R&                  R(                  RG                  W5      u  nnUR-                  [        U5      5        UR-                  U5        MŒ     / n/ n [        [I        U5      [I        U5      [I        U5      5       GH  u  nn!n"[        S U! 5       5      n#[        S U! 5       5      nSn[        U5      S:”  ah  [         R2                  RE                  U"US9   [         R@                  RC                  U[        S U 5       5      [        S U# 5       5      SUS9nSSS5        / n$Sn%U HC  n&U&RJ                  (       a  Ub  U$R-                  UU%   5        U%S-  n%M2  U$R-                  S5        ME     [        U$5      n$UR-                  U#5        U R-                  U$5        GM"     URM                  5         U RM                  5                             SS jn'/ n([O        U 5       H®  u  nnU'" UU   UU   XÍ   X½   UU   Xí   UU   UU   U U   5	      n)[	        U[         R                  R                  5      (       aF            SS jn*U*" UURP                  U)URR                  5      Ul)        U(R-                  U5        M�  U(R-                  U)5        M°     U(       a  U(S   $ [        U(5      $ s  sn	f s  snf s  snf s  snf s  snf ! , (       d  f       GNC= f! , (       d  f       GNô= f! , (       d  f       GNÚ= f)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>`) that hints this graph may share memory
        with the indicated pool.  See :ref:`Graph memory management<graph-memory-management>`.
.. 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.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.c              3  ó<   #   • U  H  oR                   S L v •  M     g7f)FN©Úrequires_grad©Ú.0Úbs     r   Ú	<genexpr>Ú)make_graphed_callables.<locals>.<genexpr>Š  s   é € ÐEº°A—‘¨%Õ/ºùs   ‚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``.c              3  óV   #   • U  H  n[        U[        R                  5      v •  M!     g 7fr%   )Ú
isinstancer    r   )r‹   Úargs     r   r�   rŽ   ’  s   é € ÐHºK°S”:˜c¤5§<¡<×0Ð0ºKùs   ‚')zfIn the beta API, sample_args for each callable must contain only Tensors. Other types are not allowed.r   N)NNNc              3  óJ   #   • U  H  oR                   (       d  M  Uv •  M     g 7fr%   rˆ   ©r‹   Úos     r   r�   rŽ   ´  s   é € Ð$K²¨1¿?½?§Q¡Q²ùó   ‚#š	#c              3  óJ   #   • U  H  oR                   (       d  M  Uv •  M     g 7fr%   rˆ   ©r‹   Úis     r   r�   rŽ   ¸  s   é € ð %Ú'; !¿½ŸA™AÒ';ùr•   c              3  ór   #   • U  H-  oR                   (       d  M  [        R                  " U5      v •  M/     g 7fr%   ©r‰   r    Ú
empty_liker“   s     r   r�   rŽ   »  s(   é € ð +Ú9@°AÇOÅOÓ/œE×,Ò,¨Q×/Ð/ºùs   ‚7š7)ÚoutputsÚinputsÚgrad_outputsÚonly_inputsÚallow_unused)r-   c              3  ór   #   • U  H-  oR                   (       a  [        R                  " U5      OS v •  M/     g 7fr%   rš   r“   s     r   r�   rŽ   ß  s'   é € ð $
ÚFTÀ§?§?ŒE×Ò˜QÔ¸Ô<Ânùs   ‚57c              3  óJ   #   • U  H  oR                   (       d  M  Uv •  M     g 7fr%   rˆ   r“   s     r   r�   rŽ   ã  s   é € ÐJª 1¿/½/ŸQ™Qªùr•   c              3  óJ   #   • U  H  oR                   (       d  M  Uv •  M     g 7fr%   rˆ   r—   s     r   r�   rŽ   é  s   é € Ð TÒ,@ qÇOÅO§¡Ò,@ùr•   c              3  ó.   #   • U  H  oc  M  Uv •  M     g 7fr%   r   r“   s     r   r�   rŽ   ê  s   é € Ð&WÒ2E¨Q§q¡qÒ2Eùs   ‚Œ	é   c	           	     ó†   ^ ^^^^^^^^^
•  " UU UUUUU4S jS[         R                  R                  5      m
SU
UU4S jjn	U	$ )Nc                  óš   >• \ rS rSr\SUUUU4S jj5       r\\R                  R                  R                  SU UU4S jj5       5       r
Srg)ÚOmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphedi  c                óB  >• [        T5       HB  nTU   R                  5       X   R                  5       :w  d  M,  TU   R                  X   5        MD     TR                  5         [	        T[
        5      (       d  [        S[        T5       35      e[        S T 5       5      $ )Nz"static_outputs must be tuple, got c              3  ó@   #   • U  H  oR                  5       v •  M     g 7fr%   ©Údetachr“   s     r   r�   Újmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward.<locals>.<genexpr>  s   é € Ð@²¨AŸX™XŸZ˜Z²ùs   ‚)ÚrangeÚdata_ptrÚcopy_r:   r�   Útuplere   Útype)Úctxr�   r˜   Ú	fwd_graphÚlen_user_argsÚstatic_input_surfaceÚstatic_outputss      €€€€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óð ô Ñ@±Ó@Ó@Ð@r   c                ó´  >• [        U5      [        T5      :w  a#  [        S[        U5       S[        T5       35      e[        TU5       H?  u  p#Uc  M
  UR                  5       UR                  5       :w  d  M.  UR	                  U5        MA     TR                  5         [        T[        5      (       d  [        S[        T5       35      e[        S T 5       5      $ )Nzlen(grads)=z != len(static_grad_outputs)=z&static_grad_inputs must be tuple, got c              3  óL   #   • U  H  nUb  UR                  5       OUv •  M     g 7fr%   r«   rŠ   s     r   r�   Úkmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward.<locals>.<genexpr>3  s(   é € ð ò 0˜ð #$¡-�A—H‘H”J°QÔ6Ú/ùs   ‚"$)	Úlenre   Úzipr¯   r°   r:   r�   r±   r²   )r³   ÚgradsÚgÚgradÚ	bwd_graphÚstatic_grad_inputsÚstatic_grad_outputss       €€€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óó ð r   r   N)r³   r{   r�   r   rO   útuple[Tensor, ...])r³   r{   r¿   r   rO   rÇ   )rW   rX   rY   rZ   Ústaticmethodr¸   r    ÚautogradÚfunctionÚonce_differentiablerÅ   r\   )rÂ   r´   rµ   rÃ   rÄ   r¶   r·   s   €€€€€€€r   ÚGraphedr¨     sN   ø† Ø÷
Añ 
Aó ð
Að Ø�^‰^×$Ñ$×8Ñ8÷ð ó 9ó ór   rÌ   c                 óÜ   >• [         R                  R                  R                  " U 6 nTR                  " [        U5      T-   6 n[         R                  R                  R                  UT5      $ r%   )r    ÚutilsÚ_pytreeÚarg_tree_leavesÚapplyr±   Útree_unflatten)Ú	user_argsÚflatten_user_argsÚoutrÌ   Úmodule_paramsÚoutput_unflatten_specs      €€€r   ÚfunctionalizedÚVmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.functionalized9  sW   ø€ ô !&§¡× 3Ñ 3× CÒ CÀYÐ OÐØ—-’-¤%Ð(9Ó":¸]Ñ"JÐLˆCÜ—;‘;×&Ñ&×5Ñ5°cÐ;PÓQÐQr   )rÓ   r{   rO   r{   )r    rÉ   ÚFunction)r´   rÂ   rÖ   rµ   r×   r¶   r·   rÄ   rÃ   rØ   rÌ   s   ````````` @r   Úmake_graphed_autograd_functionÚ>make_graphed_callables.<locals>.make_graphed_autograd_function  s4   ÿù€ ÷(	õ (	”e—n‘n×-Ñ-ô (	÷T	Rñ 	Rð Ðr   c                ó$   ^ ^^^• SU UUU4S jjnU$ )Nc                 óD   >• TR                   T:X  a  T" U 0 UD6$ T" U 0 UD6$ r%   )Útraining)rÓ   Úuser_kwargsÚfuncÚgraph_training_stateÚgraphedÚorig_fwds     €€€€r   Únew_fwdÚEmake_graphed_callables.<locals>.make_graphed_forward.<locals>.new_fwdZ  s2   ø€ ð —}‘}Ð(<Ó<Ù&¨	ÐA°[ÑAÐAá'¨ÐB°kÑBÐBr   )rÓ   z_P.argsrà   z	_P.kwargsrO   r   r   )rá   râ   rã   rä   rå   s   ```` r   Úmake_graphed_forwardÚ4make_graphed_callables.<locals>.make_graphed_forwardT  s   û€ ÷Cò Cð �r   )r´   r   rÂ   r   rÖ   ztuple[torch.nn.Parameter, ...]rµ   rV   r×   ztorch.utils._pytree.TreeSpecr¶   rÇ   r·   rÇ   rÄ   ztuple[Tensor | None, ...]rÃ   rÇ   rO   zCallable[..., object])
rá   r}   râ   rN   rã   úCallable[_P, _R]rä   ré   rO   ré   )*r    Úis_autocast_enabledÚis_autocast_cache_enabledÚRuntimeErrorr�   r±   ÚtypingÚcastr   r¾   ÚnnÚModuler½   Ú_backward_hooksÚ_forward_hooksÚ_forward_pre_hooksre   ÚallÚbuffersrÎ   rÏ   rÐ   ÚappendÚ
parametersr®   r!   r   r   rl   rf   rc   Útree_leavesrÉ   rÁ   r   Útree_flattenÚreversedr‰   ÚreverseÚ	enumeraterß   r¸   )+r�   r‚   rƒ   r„   r-   Újust_one_callableÚ_sample_argsÚflatten_sample_argsÚcry   Úflatten_argÚper_callable_len_user_argsÚper_callable_module_paramsr˜   Ú"per_callable_static_input_surfacesÚ_Ú
fwd_graphsÚ
bwd_graphsÚmempoolrá   r¶   Úgrad_inputsrœ   Úoutputs_gradÚvÚper_callable_static_outputsÚ"per_callable_output_unflatten_specr´   Úfunc_outputsÚflatten_outputsÚspecÚ per_callable_static_grad_outputsÚper_callable_static_grad_inputsr·   rÂ   rÄ   rÃ   Úgrad_idxr‘   rÛ   Úretrã   rç   s+                                              r   r   r   %  sO  € ôR × Ò ×"Ñ"¤u×'FÒ'F×'HÑ'HÜØmó
ð 	
ð Ðô �i¤×'Ñ'Ø ÐØ�Lˆ	ÜŸš¤E¬&°#¨+Ñ$6¸ÓDÐF‰ä—{’{¤5¬¬v°s¨{Ñ);¸SÐ)@Ñ#AÀ;ÓOˆàÐä�y×/‰ˆÜ�aœŸ™Ÿ™×)Ñ)ä�A×%Ñ%Ó&¨!Ó+Ü˜×(Ñ(Ó)¨QÓ.Ü˜×,Ñ,Ó-°Ó2ä$ðaóð ô ÑE¸¿¹¼ÓE×EÑEÜ$ð1óð ô
 —k‘k×)Ñ)×9Ò9¸4Ð@ˆØ×"Ñ"¤5¨Ó#5Ô6ÜÑ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à%)¡\ÔÔ!°t€Gô
 
‡J�J×ÑÔÜ	�‰×	Ñ	œ5Ÿ:™:×,Ñ,Ó.Õ	/Ü03ØÐ%Gö1
Ñ,ˆD�$Ð,ð 2BÑ.ˆK˜ ,ÜÐ+Ö,�ÜŸ+™+×-Ñ-×9Ñ9¹$À¸+ÓF�Ü$Ñ$K±Ó$KÓK�Ü�|Ó$ qÕ(Ü"'§.¡.×"5Ñ"5Ø ,Ü$ñ %Ù';ó%ó  ô &+ñ +Ù9@ó+ó &ð %)Ø%7ð #6ð 
#’Kñ	 -ð ˜|¨[Ó9�Úó :ñ'1
÷ 
0ô. 
‡J�J×ÑÔð #%ÐØ)+Ð&Ü!$ Y¸jÖ!IÑˆˆd�IÜ�Z‰Z×Ñ˜i¨gÐÒ6Ù ˜;ˆL÷ 7ô !&§¡× 3Ñ 3× @Ñ @ÀÓ NÑˆ˜Ø#×*Ñ*¬5°Ó+AÔBØ*×1Ñ1°$Ö7ñ "Jð (*Ð$Ø&(Ð#Ü;>ÜÐ3Ó4ÜÐ,Ó-Ü�Ó÷<Ñ7Ð˜n¨iô $ñ $
ÙFTó$
ó 
Ðô ÑJ©ÓJÓJˆØˆÜˆ|Ó˜qÓ Ü—‘×!Ñ! )°'Ð!Ò:Ü#Ÿn™n×1Ñ1Ø(Ü Ñ TÑ,@Ó TÓTÜ!&Ñ&WÑ2EÓ&WÓ!WØ $Ø!3ð 2ð �÷ ;ð  ÐØˆÛ'ˆCØ× ×  [Ñ%<Ø"×)Ñ)¨+°hÑ*?Ô@Ø˜A‘’à"×)Ñ)¨$Ö/ñ (ô #Ð#5Ó6Ðà(×/Ñ/Ð0CÔDØ'×.Ñ.Ð/A×BñK<ðP %×,Ñ,Ô.Ø#×+Ñ+Ô-ð=Øð=àð=ð 6ð=ð ð	=ð
  <ð=ð 1ð=ð +ð=ð 7ð=ð /ð=ð 
ô=ð@ $&€CÜ˜YÖ'‰ˆˆ4Ù0Ø�q‰MØ�q‰MØ&Ñ)Ø&Ñ)Ø.¨qÑ1Ø.Ñ1Ø'¨Ñ*Ø,¨QÑ/Ø+¨AÑ.ó

ˆô �dœEŸH™HŸO™O×,Ñ,ðØ%ðà&*ðð *ðð +ð	ð
 "ôñ  0Ø�d—m‘m W¨d¯l©lóˆDŒLð �J‰J�tÖà�J‰J�wÖñI (öL Ø�1‰vˆä�‹:Ðùòi "Mùò"ùò*ùò
 IùÚH÷ 
0Ö	/ú÷B 7Ö6ú÷0 ;Ö:úsL   Ç]Ç8A]É]Ê	(]Ë	(]ÍA3]$ÏA]$Ò]6Õ3A^Ý$
]3Ý6
^	Þ
^	)rO   rN   rU   )é   FN)r�   r~   r‚   rÇ   rƒ   rV   r„   rN   r-   rQ   rO   r~   )r�   útuple[_ModuleOrCallable, ...]r‚   ztuple[tuple[Tensor, ...], ...]rƒ   rV   r„   rN   r-   rQ   rO   r  )r�   ú1_ModuleOrCallable | tuple[_ModuleOrCallable, ...]r‚   z3tuple[Tensor, ...] | tuple[tuple[Tensor, ...], ...]rƒ   rV   r„   rN   r-   rQ   rO   r  )&Ú
__future__r   rp   rí   Úcollections.abcr   r   r   r   r   Útyping_extensionsr	   r
   r   r    r   Ú
torch.cudar   Ú_utilsr   Ú__all__r   r   Úhasattrrs   Ú__dict__Útorch._Cr   r   r   r   r   r   r   r{   r~   r|   r   r   r   r   Ú<module>r!     sû  ðæ "ã 	Û Ý $ß <Ó <ß 6Ñ 6ã Ý ö å'å  ò€ñ ˆTƒ]€Ùˆtƒ_€ñ ˆu�x‰xÐ*×+Ñ+á&1°,Ó&?€E‡H�H×Ñ�lÑ#Ù.9Ð:NÓ.O€E‡H�H×ÑÐ*Ñ+Ù:EØ(ó;€E‡H�H×ÑÐ6Ñ7÷ TÑ Sô,ô9ôq-�
ô q-÷hT(ñ T(ðp  %Ð%6¸ÀÀfÀÑ8MÐ%MÑNÐ �9Ó Nð 
ð Ø$Ø $ðØ ðà#ðð ðð ð	ð
 ðð ôó 
ðð 
ð Ø$Ø $ð(Ø,ð(à/ð(ð ð(ð ð	(ð
 ð(ð #ô(ó 
ð(ð Ø$Ø $ðIØ@ðIàDðIð ðIð ð	Ið
 ðIð 7öIr   