o
    `Û·ik  ã                   @   sP   d dl mZ d dlmZ d dlZd dlmZ eG dd„ dƒƒZG dd„ dƒZdS )	é    )Ú	dataclass)ÚListN)ÚBackendc                   @   s*   e Zd ZU dZeed< eed< eed< dS )ÚCommunicatorz=
    A handle to a communicator that we are a member of.
    ÚnameÚrankÚbackendN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__Úint© r   r   ú^/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/experimental/collective/communicator.pyr      s
   
 r   c                   @   s~   e Zd ZdZdeejj dedefdd„Z	dejjfdd	„Z
ed
eejj fdd„ƒZed
efdd„ƒZed
efdd„ƒZdS )ÚCommunicatorHandlezj
    A communicator handle used by the driver to store handles to the
    actors in the communicator.
    Úactorsr   r   c                 C   s   || _ || _t|ƒ| _dS )a„  
        Initializes the CommunicatorHandle with the given actor handles.
        Assumes that the communicator has already been initialized on all actors.

        Args:
            actors: A list of actor handles to be stored.
            name: Name of the communicator.
            backend: Communicator backend. See
                ray.util.collective.types for valid values.
        N)Ú_actorsÚ_namer   Ú_backend)Úselfr   r   r   r   r   r   Ú__init__   s   zCommunicatorHandle.__init__Úactorc                 C   s(   t | jƒD ]\}}||kr|  S qdS )Néÿÿÿÿ)Ú	enumerater   )r   r   ÚiÚar   r   r   Úget_rank,   s
   ÿzCommunicatorHandle.get_rankÚreturnc                 C   s   | j dd… S )z@
        Return all actor handles in this communicator.
        N)r   ©r   r   r   r   r   2   s   zCommunicatorHandle.actorsc                 C   ó   | j S ©N)r   r    r   r   r   r   9   ó   zCommunicatorHandle.namec                 C   r!   r"   )r   r    r   r   r   r   =   r#   zCommunicatorHandle.backendN)r	   r
   r   r   r   Úrayr   ÚActorHandler   r   r   Úpropertyr   r   r   r   r   r   r   r      s    r   )	Údataclassesr   Útypingr   r$   Úray.util.collective.typesr   r   r   r   r   r   r   Ú<module>   s    