Ë
    *êñiã  ã                   óª  — U d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	Z	ddl
mZmZmZmZmZ ddlmZ i Zeed	f   ed
<   g d¢Z G d„ d	e«      Zdededdfd„Zdedededede	j4                  dedefd„Zdedededede	j4                  dedefd„Z ede«        ede«       dededee	j4                  z  dedef
d„Zdefd„Zededed   fd „«       Z y)!zä
This is an experimental new API for PyTorch Distributed. This is actively in development and subject to change or deletion entirely.

This is intended as a proving ground for more flexible and object oriented distributed APIs.
é    )Ú	Generator)Úcontextmanager)Ú	timedelta)ÚProtocolN)Ú_current_process_groupÚ_set_process_groupÚProcessGroupÚReduceOpÚStore)Ú
rendezvousÚProcessGroupFactoryÚ	_BACKENDS)r	   r
   r   Úregister_backendÚ	new_groupÚcurrent_process_groupÚprocess_groupc                   óH   — e Zd ZdZdededededej                  de	de
fd	„Zy
)r   z%Protocol for process group factories.ÚstoreÚrankÚ
world_sizeÚtimeoutÚdeviceÚkwargsÚreturnc                  ó   — y )N© )Úselfr   r   r   r   r   r   s          úZ/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torch/distributed/_dist2.pyÚ__call__zProcessGroupFactory.__call__'   s   € ð ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úintr   Útorchr   Úobjectr	   r   r   r    r   r   r   $   sR   „ Ù/ðàðð ðð ð	ð
 ðð —‘ðð ðð 
ôr    ÚnameÚfuncr   c                 óD   — | t         v rt        d| › d�«      ‚|t         | <   y)z™
    Register a new process group backend.

    Args:
        name: The name of the backend.
        func: The function to create the process group.
    úBackend z already registeredN)r   Ú
ValueError)r(   r)   s     r   r   r   2   s*   € ð ŒyÑÜ˜8 D 6Ð)<Ð=Ó>Ð>à„Iˆd‚Or    r   r   r   r   r   r   c                 óp  — ddl m} t        |«      dk7  rt        d«      ‚ || |||«      }|j	                  «        t        | ||«      }|j                  t
        j                  j                  «       |j                  |t
        j                  j                  |«       |j                  t        j                  d«      t
        j                  j                  |«       t        j                  j                  «       r>|j                  t        j                  d«      t
        j                  j                  |«       |S )Nr   )ÚProcessGroupGlooz'Gloo backend received unexpected kwargsÚcpuÚcuda)Útorch.distributedr.   ÚlenÚAssertionErrorÚ_set_sequence_number_for_groupr	   Ú_set_default_backendÚBackendTypeÚGLOOÚ_register_backendr&   r   r0   Úis_available)	r   r   r   r   r   r   r.   Úbackend_classÚpgs	            r   Ú_gloo_factoryr<   @   sð   € õ 3ä
ˆ6ƒ{�aÒÜÐFÓGÐGá$ U¨D°*¸gÓF€MØ×0Ñ0Ô2ä	�e˜T :Ó	.€BØ×ÑœL×4Ñ4×9Ñ9Ô:ð ×Ñ˜¤×!9Ñ!9×!>Ñ!>ÀÔNØ×ÑÜ�‰�UÓœ\×5Ñ5×:Ñ:¸Môô ‡z�z×ÑÔ Ø
×ÑÜ�L‰L˜Ó ¤,×":Ñ":×"?Ñ"?Àô	
ð €Ir    c                 óØ  — ddl m} |j                  «       }||_        |j	                  «       D ],  \  }}	t        ||«      st        d|› �«      ‚t        |||	«       Œ.  || |||«      }
|
j                  «        |
j                  |«       t        | ||«      }|j                  t        j                  j                  «       |j                  |t        j                  j                  |
«       |S )Nr   )ÚProcessGroupNCCLzUnknown option )r1   r>   ÚOptionsÚ_timeoutÚitemsÚhasattrÚKeyErrorÚsetattrr4   Úeager_connect_single_devicer	   r5   r6   ÚNCCLr8   )r   r   r   r   r   r   r>   ÚoptsÚkÚvr:   r;   s               r   Ú_nccl_factoryrJ   _   sÔ   € õ 3à×#Ñ#Ó%€DØ€D„MØ—‘“ò ‰ˆˆ1Ü�t˜QÔÜ˜_¨Q¨CÐ0Ó1Ð1Ü��a˜Õðñ
 % U¨D°*¸dÓC€MØ×0Ñ0Ô2Ø×-Ñ-¨fÔ5ä	�e˜T :Ó	.€BØ×ÑœL×4Ñ4×9Ñ9Ô:Ø×Ñ˜¤×!9Ñ!9×!>Ñ!>ÀÔNà€Ir    ÚglooÚncclÚbackendc                 óä   — | t         vrt        d| › d�«      ‚t        j                  |«      }t	        t        t        d«      «      «      \  }}}|j                  |«       t        |    |||||fi |¤ŽS )aF  
    Create a new process group with the given backend and options. This group is
    independent and will not be globally registered and thus not usable via the
    standard torch.distributed.* APIs.

    Args:
        backend: The backend to use for the process group.
        timeout: The timeout for collective operations.
        device: The device to use for the process group.
        **kwargs: All remaining arguments are passed to the backend constructor.
                  See the backend specific documentation for details.

    Returns:
        A new process group.
    r+   z not registeredzenv://)r   r,   r&   r   ÚnextÚiterr   Úset_timeout)rM   r   r   r   r   r   r   s          r   r   r      st   € ð* ”iÑÜ˜8 G 9¨OÐ<Ó=Ð=ä�\‰\˜&Ó!€Fä"¤4¬
°8Ó(<Ó#=Ó>Ñ€Eˆ4�Ø	×Ñ�gÔä�WÑ˜e T¨:°wÀÑQÈ&ÑQÐQr    c                  ó   — t        «       S )zn
    Get the current process group. Thread local method.

    Returns:
        The current process group.
    )r   r   r    r   r   r   Ÿ   s   € ô "Ó#Ð#r    r;   )NNNc              #   óv   K  — t        «       }t        | «       	 d–— t        |«       y# t        |«       w xY w­w)zs
    Context manager for process groups. Thread local method.

    Args:
        pg: The process group to use.
    N)r   r   )r;   Úprev_pgs     r   r   r   ©   s1   è ø€ ô $Ó%€Gä�rÔð$Ûä˜7Õ#øÔ˜7Õ#üs   ‚9™) �9©6¶9)!r$   Úcollections.abcr   Ú
contextlibr   Údatetimer   Útypingr   r&   Útorch._C._distributed_c10dr   r   r	   r
   r   Útorch.distributed.rendezvousr   r   ÚdictÚstrÚ__annotations__Ú__all__r   r   r%   r   r'   r<   rJ   r   r   r   r   r    r   ú<module>r_      s’  ðòõ &Ý %Ý Ý ã ÷õ õ 4ð /1€	ˆ4�Ð*Ð*Ñ+Ó 0ò€ô˜(ô ð˜3ð Ð&9ð ¸dó ðØðà
ðð ðð ð	ð
 �L‰Lðð ðð óð>Øðà
ðð ðð ð	ð
 �L‰Lðð ðð óñ8 �˜Ô 'Ù �˜Ô 'ðRØðRàðRð �%—,‘,ÑðRð ð	Rð
 óRð@$˜|ó $ð ð$�lð $ yÐ1AÑ'Bò $ó ñ$r    