+
    –°³jK  ã                   óh   € ^ RI t ^ RIHt ^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 R.t
R	R^ /R R llltR# )
é    N©Úfnmatch)Ú_mesh_resourcesÚ
DeviceMesh)ÚParallelStyleÚparallelize_moduleÚsrc_data_rankc          
      óÞ   € V ^8„  d   QhR\         P                  R\        R,          R\        \        \
        \        3,          ,          R,          R\        R,          R\         P                  /# )é   ÚmoduleÚdevice_meshNÚparallelize_planr	   Úreturn)ÚnnÚModuler   r   ÚdictÚstrÚint)Úformats   "Úf/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/tensor/parallel/api.pyÚ__annotate__r      sf   € ÷ @
ñ @
Ü�I‰Ið@
ä˜dÕ"ð@
ô $¤d¬3´Ð+=Õ&>Õ>ÀÕEð@
ô
 ˜•:ð@
ô ‡Y�Yñ@
ó    c          
     óX  a€ \         P                  P                  R4       T;'       g    \        P                  ! 4       pVf   \
        P                  ! R^R7       V # \        V\        4      '       d   W2n	        VP                  W4      # \        V\        4      '       dô   VP                  4        FÝ  w  rEVR8X  d   \        WV4       K  VP                  R4      pV^ ,          o\        \!        V3R lV P#                  4       4      4      pV'       g%   \
        P                  ! RV RS R	V  R
2^R7       K‡  VP%                  ^ 4       V F?  w  r‰V'       d$   RP'                  V4      p
\        V	VW¥/VR7       K0  \        V	VVVR7       KA  	  Kß  	  V # \)        R\+        V4       R24      h)a+
  
Apply Tensor Parallelism in PyTorch by parallelizing modules or sub-modules based on a user-specified plan.

We parallelize module or sub_modules based on a parallelize_plan. The parallelize_plan contains
:class:`ParallelStyle`, which indicates how user wants the module or sub_module
to be parallelized.

User can also specify different parallel style per module fully qualified name (FQN).

Note that ``parallelize_module`` only accepts a 1-D :class:`DeviceMesh`, if you have a 2-D or N-D :class:`DeviceMesh`,
slice the DeviceMesh to a 1-D sub DeviceMesh first then pass to this API(i.e. ``device_mesh["tp"]``)

Args:
    module (:class:`nn.Module`):
        Module to be parallelized.
    device_mesh (:class:`DeviceMesh`, optional):
        Object which describes the mesh topology of devices for the DTensor.
        If not specified, the call must be under a DeviceMesh context.
    parallelize_plan (Union[:class:`ParallelStyle`, Dict[str, :class:`ParallelStyle`]], optional):
        The plan used to parallelize the module. It can be either a
        :class:`ParallelStyle` object which contains how we prepare
        input/output for Tensor Parallelism or it can be a dict of module
        FQN and its corresponding :class:`ParallelStyle` object. If not
        specified, the call will do nothing at the moment.
Keyword args:
    src_data_rank (int, optional): the rank of the source data for the logical/global tensor, it is used by
        :meth:`distribute_tensor` to scatter/broadcast the shards/replicas to other ranks. By default,
        we use ``group_rank=0`` on each DeviceMesh dimension as the source data to preserve the single-device
        semantic. If passing ``None`` explicitly, :meth:`parallelize_module` simply uses its local data instead
        of trying to preserve the single-device semantic via scatter/broadcast. Default: 0
Return:
    A :class:`nn.Module` object parallelized.

Example::
    >>> # xdoctest: +SKIP("distributed")
    >>> from torch.distributed.tensor.parallel import parallelize_module, ColwiseParallel
    >>> from torch.distributed.device_mesh import init_device_mesh
    >>>
    >>> # Define the module.
    >>> m = Model(...)
    >>> tp_mesh = init_device_mesh("cuda", (8,))
    >>> m = parallelize_module(m, tp_mesh, {"w1": ColwiseParallel(), "w2": RowwiseParallel()})
    >>>

.. note:: For complex module architecture like Attention, MLP layers, we recommend composing
    different ParallelStyles together (i.e. ``ColwiseParallel`` and ``RowwiseParallel``) and pass
    as a parallelize_plan, to achieve the desired sharding computation.
z4torch.distributed.tensor.parallel.parallelize_modulez‚No parallelize_plan is provided and auto-parallel is not supported at the moment, so this parallelize_module call will do nothing.)Ú
stacklevelÚ Ú.c                 ó*   <€ \        V ^ ,          S4      # )r   r   )ÚtÚtokens   &€r   Ú<lambda>Ú$parallelize_module.<locals>.<lambda>f   s   ø€ œg a¨¥d¨EÔ2r   zParallelize plan key 'z6' could not be resolved: no submodule matching token 'z' in module z, skipping this plan entry.)r	   zLExpect Union[ParallelStyle, Dict[str, ParallelStyle]] for parallelize_plan, z found!)ÚtorchÚ_CÚ_log_api_usage_oncer   Úget_current_meshÚwarningsÚwarnÚ
isinstancer   r	   Ú_applyr   Úitemsr   ÚsplitÚlistÚfilterÚnamed_childrenÚpopÚjoinÚ	TypeErrorÚtype)r   r   r   r	   Úmodule_pathÚparallelize_styleÚpath_splitsÚmatched_childrenÚ_Ú	submoduleÚ	leaf_pathr   s   &&&$       @r   r   r      s³  ø€ ôn 
‡H�H× Ñ Ð!WÔXà×CÐC¤×!AÒ!AÓ!C€KàÒÜ�ŠðNàõ	
ð
 ˆô
 Ð"¤M×2Ò2Ø)6Ô&Ø×&Ñ& vÓ;Ð;Ü	Ð$¤d×	+Ò	+Ø.>×.DÑ.DÖ.FÑ*ˆKØ˜bÔ ä" 6Ð8IÔJÙà%×+Ñ+¨CÓ0ˆKð   •NˆEä#Üä2Ø×)Ñ)Ó+óó Ð÷ $ä—’Ø,¨[¨Mð :4Ø49°7¸,ÀvÀhð O0ð1ð  !õ	ñ ð �O‰O˜AÔã 0‘�ßà #§¡¨Ó 5�IÜ&Ø!Ø#Ø"Ð6Ø&3÷	ô 'Ø!Ø#Ø)Ø&3÷	ó !1ñ? /Gðb ˆäð"Ü"&Ð'7Ó"8Ð!9¸ðBó
ð 	
r   )NN)r&   r   r"   Útorch.nnr   Útorch.distributed.device_meshr   r   Ú'torch.distributed.tensor.parallel.styler   Ú__all__r   © r   r   Ú<module>r?      s8   ðã Ý ã Ý ß EÝ Að  Ð
 €ñ@
ð
 !"÷@
ò @
r   