+
    –°³j.*  ã                   ó¶   € ^ RI t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	H
t
 ^ RIt^ RIHt ] ! R R4      4       t ! R R	]
4      t ! R
 R4      t ! R R4      tR# )é    N)ÚCallable)Úcontextmanager)Ú	dataclassÚfield)ÚAnyÚ
NamedTuplec                   ón   a € ] tR t^t o Rt]! ]P                  P                  R7      t	Rt
V 3R ltRtV tR# )ÚTracingConfigau  
This represents a symbolic tracing configuration.

Args:
    tracer (torch.fx.Tracer): An instance of :class:`torch.fx.Tracer` to
        use for symbolic tracing. The default value is the native
        :class:`torch.fx.Tracer` constructed with default arguments.
        However, the user may want to pass a different value such as the
        ``HFTracer`` for models in the HuggingFace Transformers_ library.
        .. _Transformers: https://huggingface.co/docs/transformers/index
    concrete_args (Optional[Dict[str, Any]]): Concrete arguments that
        should not be treated as ``torch.fx.Proxy`` when tracing the
        module ``forward()``. Passing ``concrete_args`` allows partially
        specializing the forward, e.g. to remove control flow or data
        structures. This ``concrete_args`` here is the same argument used
        in :meth:`~torch.fx.Tracer.trace`.
)Údefault_factoryNc                ó~   <€ V ^8„  d   Qh/ S[ P                  P                  ;R&   S[S[S[3,          R,          ;R&   # )é   ÚtracerNÚconcrete_args)ÚtorchÚfxÚTracerÚdictÚstrr   )ÚformatÚ__classdict__s   "€Úd/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/fsdp/_trace_utils.pyÚ__annotate__ÚTracingConfig.__annotate__   s4   ø‡ ‚ ñ( �H‰H�O‰OÑDñ) ñ* ™™S˜•> DÕ(Ñ/ò+ ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   r   r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r
   r
      s*   ø‡ € ññ$ $°E·H±H·O±OÔD€FØ+/€M÷+ ƒ r   r
   c                   ó0   a € ] tR t^$t o RtV 3R ltRtV tR# )Ú_ParamUsageInfoaþ  
This is used for ``_ExecutionInfo.module_to_param_usage_infos`` to record
execution information. The ``dict`` maps modules to a list of these
``_ParamUsageInfo`` instances, where each instance represents a group of
parameters used together.

Specifically, for each module key in the ``dict``, each instance of this
class represents either:
(1) the module and some sublist of its ``named_parameters()`` used
together in execution (see ``_patched_create_proxy()``), or
(2) a submodule and all of ``submodule.named_parameters()`` (see
``_patched_call_module()``).

Type (1) corresponds to directly using parameters in ops without calling
``forward()``, and type (2) corresponds to calling ``forward()``. The
mapped-to lists in the ``dict`` follow the execution order.
c                ó€   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[S[S[S[ P
                  3,          ,          ;R&   # )r   ÚmoduleÚnamed_params)ÚnnÚModuleÚlistÚtupler   Ú	Parameter)r   r   s   "€r   r   Ú_ParamUsageInfo.__annotate__$   s6   ø‡ ‚ ñ& �I‰IÑñ' ñ( ‘u™S¡"§,¡,Ð.Õ/Õ0Ñ0ò) r   r   N)r   r   r   r   r    r!   r"   r#   r$   s   @r   r&   r&   $   s   ø‡ € ñ÷ ƒ r   r&   c                   ó6   a € ] tR t^;t o RtV 3R lR ltRtV tR# )Ú_ExecutionInfoaé  
This represents the execution order information from the forward pass.

Attributes:
    curr_module (nn.Module): Current module being traced.
    module_forward_order (List[nn.Module]): The modules in (pre-)forward
        order, i.e. the order in which their ``forward()`` methods are
        called. Each call to a module's ``forward()`` corresponds to one
        element in the list.
    module_to_param_usage_infos (Dict[nn.Module, List[_ParamUsageInfo]]):
        Maps a module to a list of module execution infos. See
        :class:`_ParamUsageInfo` for details.
    param_forward_order (List[nn.Parameter]): The parameters in forward
        execution order, where only a parameter's first participation is
        included.
    visited_params (Set[nn.Parameter]): The parameters visited so far
        during the trace. This is only used during tracing for fast
        membership check. Invariant: The parameters in
        ``param_forward_order`` are exactly those in ``visited_params``.
c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )r   Úroot_moduleÚreturnN)r*   r+   )r   r   s   "€r   r   Ú_ExecutionInfo.__annotate__Q   s   ø€ ÷ 7ñ 7¡B§I¡Ið 7°$ñ 7r   c                ó`   € Wn         V.V n        V. /V n        . V n        \	        4       V n        R # ©N)Úcurr_moduleÚmodule_forward_orderÚmodule_to_param_usage_infosÚparam_forward_orderÚsetÚvisited_params)Úselfr3   s   &&r   Ú__init__Ú_ExecutionInfo.__init__Q   s6   € Ø&1ÔØ6A°]ˆÔ!à˜ðT
ˆÔ(ð 8:ˆÔ Ü14³ˆÖr   )r8   r9   r:   r;   r=   N)r   r   r   r   r    r?   r"   r#   r$   s   @r   r1   r1   ;   s   ø‡ € ñ÷*7ö 7r   r1   c                   óv   a € ] tR t^[t o V 3R lR lt]V 3R lR l4       tV 3R lR ltRV 3R lR	 lltR
t	V t
R# )Ú_ExecOrderTracerc                ó   <€ V ^8„  d   QhRR/# )r   r4   Nr   )r   r   s   "€r   r   Ú_ExecOrderTracer.__annotate__\   s   ø€ ÷ 5ñ 5˜$ñ 5r   c                ó   € R V n         R # r7   ©Ú	exec_info)r>   s   &r   r?   Ú_ExecOrderTracer.__init__\   s	   € Ø04ˆŽr   c                ób   <€ V ^8„  d   QhRS[ P                  P                  RS[P                  /# )r   r   r3   )r   r   r   r*   r+   )r   r   s   "€r   r   rD   `   s'   ø€ ÷ 4ñ 4¡5§8¡8§?¡?ð 4ÁÇÁñ 4r   c              #  ó˜  "  € \        V4      V n        VP                  pVP                  p\        P
                  ! V P                  W0P                  4      Vn        \        VP                  4       4      p\        P
                  ! V P                  VV P                  V4      Vn         R x € W1n        WAn        R #   Y1n        YAn        i ; i5ir7   )
r1   rG   Úcall_moduleÚcreate_proxyÚ	functoolsÚpartialÚ_patched_call_moduler   Únamed_parametersÚ_patched_create_proxy)r>   r   r3   Úorig_call_moduleÚorig_create_proxyÚfqn_to_params   &&&   r   Úpatch_tracerÚ_ExecOrderTracer.patch_tracer_   s­   é € ä'¨Ó4ˆŒØ!×-Ñ-ÐØ"×/Ñ/ÐÜ&×.Ò.Ø×%Ñ%Ð'7¿¹ó
ˆÔô ˜K×8Ñ8Ó:Ó;ˆÜ'×/Ò/Ø×&Ñ&ØØ�N‰NØó	
ˆÔð	4Ûà!1ÔØ"3Öøð "2ÔØ"3Õüs   ‚B$C
Â'B9 Â+C
Â9CÃC
c                ó‚   <€ V ^8„  d   QhRS[ RS[RS[P                  RS[ RS[S[R3,          RS[S[S[3,          RS[/# )	r   rK   rG   r(   ÚforwardÚargs.Úkwargsr4   )r   r1   r*   r+   r-   r   r   r   )r   r   s   "€r   r   rD   t   se   ø€ ÷ +ñ +áð+ñ "ð+ñ
 —	‘	ð+ñ ð+ñ ‘C˜�H�oð+ñ ‘S™#�X•ð+ñ 
ñ+r   c                ó‚  € VP                   P                  V4       \        VP                  4       4      pVP                  pV'       dQ   W‚P
                  9  d   \        R4      hVP
                  VP                  ,          P                  \        W74      4       Tp	W2n        . VP
                  V&   V! W4WV4      p
W’n        V
# )a–  
Overrides ``call_module`` to save execution information to
``exec_info``. Note that ``call_module`` is called during symbolic
tracing for each non-root module.

Args:
    call_module (Callable): Original ``call_module`` to override.
    exec_info (_ExecutionInfo): Used to record execution information.
    module (nn.Module): Module corresponding to this ``call_module``.
    forward (Callable): ``forward()`` method of ``module`` to be called
        for this ``call_module``.
    args (Tuple[Any, ...]): Positional arguments for ``forward``.
    kwargs (Dict[str, Any]): Keyword arguments for ``forward``.

Returns:
    Same return value as ``call_module``.
zPThe current module should have already been processed by a patched `call_module`)r9   Úappendr,   rP   r8   r:   ÚAssertionErrorr&   )r>   rK   rG   r(   rX   rY   rZ   r)   r8   Úprev_curr_moduleÚoutputs   &&&&&&&    r   rO   Ú%_ExecOrderTracer._patched_call_modulet   s³   € ð6 	×&Ñ&×-Ñ-¨fÔ5Ü˜F×3Ñ3Ó5Ó6ˆØ×+Ñ+ˆßØ×"GÑ"GÔGÜ$Øfóð ð ×1Ñ1°)×2GÑ2GÕH×OÑOÜ Ó5ôð 'ÐØ &ÔØ8:ˆ	×-Ñ-¨fÑ5Ù˜V¨dÓ;ˆØ 0ÔØˆr   Nc                ó¦  <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  3,          RS[RS[P                  P                  P                  RS[
S[R3,          RS[S[S[3,          R	S[R
,          RS[R
,          RS[ S[P                  P                  .S[P                  P                  3,          R
,          RS[P                  P                  /# )r   rL   rG   rT   ÚkindÚtargetrY   .rZ   ÚnameNÚ	type_exprÚproxy_factory_fnr4   )r   r1   r   r   r*   r.   r   r   ÚnodeÚTargetr-   r   ÚNodeÚProxy)r   r   s   "€r   r   rD   ¡   sã   ø€ ÷ Oñ OáðOñ "ðOñ ™3¡§¡Ð,Õ-ð	Oñ ðOñ —‘—‘×$Ñ$ðOñ ‘C˜�H�oðOñ ‘S™#�X•ðOñ �D�jðOñ ˜•:ðOñ #¡E§H¡H§M¡M ?±E·H±H·N±NÐ#BÕCÀdÕJðOñ 
�‰�‰ñOr   c           	     óÄ  € V! WEWgW‰V
4      pVP                   pVR9   Ed   VEe   . pV F×  p\        V\        P                  P                  4      '       g   K/  VP
                  P                  V9   g   KL  W>P
                  P                  ,          pVP                  VP
                  P                  V34       WòP                  9  g   K¡  VP                  P                  V4       VP                  P                  V4       KÙ  	  V'       d,   VP                  V,          P                  \        WÍ4      4       V# VR8X  d¡   \        VP                  4       4      pV'       d,   VP                  V,          P                  \        WÍ4      4       V FN  w  ppWòP                  9  g   K  VP                  P                  V4       VP                  P                  V4       KP  	  V# )a‰  
Overrides ``create_proxy`` to save execution information to
``exec_info``. Note that ``create_proxy`` is called during symbolic
tracing for each leaf function/method/module.

Args:
    create_proxy (Callable): Original ``create_proxy`` to override.
    exec_info (_ExecutionInfo): Used to record execution information.
    fqn_to_param (Dict[str, nn.Parameter]): ``dict`` version of the
        root module's ``named_parameters()`` with FQN as key and
        parameter as value.
    kind (str): Kind of the target method ('call_function',
        'call_method', 'get_attr', 'call_module', 'placeholder', or
        'output'). See :class:`torch.fx.Graph` for details. This is
        passed to ``create_proxy``.
    target (torch.fx.node.Target): Contains the string name of the
        function/method/module. This is passed to ``create_proxy``.
    args (Tuple[Any, ...]): Positional arguments for the function/
        method/module. This is passed to ``create_proxy``.
    kwargs (Dict[str, Any]): Keyword arguments for the function/method/
        module. This is passed to ``create_proxy``
    name (Optional[str]): An optional string name for the ``Node``
        created in ``create_proxy``. This is passed to
        ``create_proxy``.
    type_expr (Optional[Any]): An optional type annotation representing
        the Python type that the output of the node has. This is passed
        to ``create_proxy``.
    proxy_factory_fn (Callable[[torch.fx.Node], torch.fx.Proxy]):
        An alternative proxy constructor used in ``create_proxy``. This
        is passed to ``create_proxy``.

Returns:
    torch.fx.Proxy: Created ``Node`` wrapped in a ``Proxy`` object.
rK   )Úcall_functionÚcall_method)r8   Ú
isinstancer   r   rj   rg   rc   r\   r=   Úaddr;   r:   r&   r,   rP   )r>   rL   rG   rT   rb   rc   rY   rZ   rd   re   rf   Úproxyr8   r)   ÚargÚparamÚ_s   &&&&&&&&&&&      r   rQ   Ú&_ExecOrderTracer._patched_create_proxy¡   s�  € ñ` Ø˜$¨Ð9Ió
ˆð  ×+Ñ+ˆØÐ3Õ3ØÓØ?A�Û�Cä" 3¬¯©¯©×7Ô7ØŸH™HŸO™O¨|Ö;à ,¯X©X¯_©_Õ =˜Ø$×+Ñ+¨S¯X©X¯_©_¸eÐ,DÔEØ ×(@Ñ(@Ö@Ø%×4Ñ4×8Ñ8¸Ô?Ø%×9Ñ9×@Ñ@ÀÖGñ  ÷  Ø×9Ñ9¸+ÕF×MÑMÜ'¨ÓBôð ˆð �]Ô"Ü × <Ñ <Ó >Ó?ˆLßØ×5Ñ5°kÕB×IÑIÜ# KÓ>ôó )‘��5Ø× 8Ñ 8Ö8Ø×,Ñ,×0Ñ0°Ô7Ø×1Ñ1×8Ñ8¸Ö?ñ )ð ˆr   rF   )NNN)r   r   r   r   r?   r   rU   rO   rQ   r"   r#   r$   s   @r   rB   rB   [   s@   ø‡ € ÷5ð 5ð ÷4ó ð4÷(+ð +÷ZO÷ Oð Or   rB   )rM   Úcollections.abcr   Ú
contextlibr   Údataclassesr   r   Útypingr   r   r   Útorch.nnr*   r
   r&   r1   rB   r   r   r   Ú<module>rz      sV   ðã Ý $Ý %ß (ß "ã Ý ð ÷0ð 0ó ð0ô.1�jô 1÷.7ñ 7÷@Uó Ur   