o
    
۾i                     @   sR   d dl mZ d dlmZ d dlmZ d dlmZ e sJ dG dd deZ	dS )    )AnyN)CommBackend)has_flashinfer_all2allz+Flashinfer alltoallv module cannot be foundc                   @   st   e Zd Zdd ZdefddZdefddZdefd	d
ZdededefddZ	dddZ
dededd fddZdS )CustomCommunicatorc                 C   s
   || _ d S N)_group)selfgroup r
   f/home/ubuntu/.local/lib/python3.10/site-packages/vllm/distributed/device_communicators/mnnvl_compat.py__init__      
zCustomCommunicator.__init__returnc                 C   
   | j  S r   )r   rankr   r
   r
   r   Get_rank   r   zCustomCommunicator.Get_rankc                 C   r   r   )r   sizer   r
   r
   r   Get_size   r   zCustomCommunicator.Get_sizedatac                 C   s$   d g|    }tj||| jd |S )N)r	   )r   distall_gather_objectr   )r   r   gatheredr
   r
   r   	allgather   s   zCustomCommunicator.allgatherrootc                 C      t r   NotImplementedError)r   r   r   r
   r
   r   bcast      zCustomCommunicator.bcastNc                 C   r   r   r   r   r
   r
   r   barrier"   r   zCustomCommunicator.barriercolorkeyc                 C   s   | S r   r
   )r   r!   r"   r
   r
   r   Split%   r   zCustomCommunicator.Split)r   N)__name__
__module____qualname__r   intr   r   r   r   r   r    r#   r
   r
   r
   r   r      s    
r   )
typingr   torch.distributeddistributedr   flashinfer.comm.mnnvlr   vllm.utils.flashinferr   r   r
   r
   r
   r   <module>   s   