o
    $iF                     @   sR   d Z ddlZddlZddlZeeZejG dd dZejG dd dZ	dS )z#Some utility class for Collectives.    Nc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )NCCLUniqueIDStorezNCCLUniqueID Store as a named actor class.

    Args:
        name: the unique name for this named actor.

    Attributes:
        name: the unique name for this named actor.
        nccl_id: the NCCLUniqueID held in this store.
    c                 C   s   || _ d | _t | _d S )N)namenccl_idasyncioEventevent)selfr    r	   U/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/util/collective/util.py__init__   s   zNCCLUniqueIDStore.__init__c                    s   || _ | j  |S )z
        Initialize the NCCL unique ID for this store.

        Args:
            uid: the unique ID generated via the NCCL generate_communicator_id API.

        Returns:
            The NCCL unique ID set.
        )r   r   set)r   uidr	   r	   r
   set_id   s   

zNCCLUniqueIDStore.set_idc                    s   | j  I dH  | jS )z4Wait for the NCCL unique ID to be set and return it.N)r   waitr   r   r	   r	   r
   wait_and_get_id)   s   z!NCCLUniqueIDStore.wait_and_get_idc                 C   s   | j std| j | j S )z*Get the NCCL unique ID held in this store.z.The NCCL ID has not been set yet for store {}.)r   loggerwarningformatr   r   r	   r	   r
   get_id.   s
   
zNCCLUniqueIDStore.get_idN)__name__
__module____qualname____doc__r   r   r   r   r	   r	   r	   r
   r   
   s    
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	InfozrStore the group information created via `create_collective_group`.

    Note: Should be used as a NamedActor.
    c                 C   s"   d | _ d| _d| _d | _d| _d S )Ni0u  ids
world_sizerankbackendgloo_timeoutr   r	   r	   r
   r   >   s
   
zInfo.__init__c                 C   s"   || _ || _|| _|| _|| _dS )zStore collective information.Nr   )r   r   r   r   r    r!   r	   r	   r
   set_infoE   s
   
zInfo.set_infoc                 C   s   | j | j| j| j| jfS )z-Get previously stored collective information.r   r   r	   r	   r
   get_infoM   s   zInfo.get_infoN)r   r   r   r   r   r"   r#   r	   r	   r	   r
   r   7   s
    r   )
r   r   loggingray	getLoggerr   r   remoter   r   r	   r	   r	   r
   <module>   s    
,