o
    -i+                  
   @   s   d dl mZ d dlZd dlZddlmZ dejdejfddZ		ddejd
edejfddZ			ddejd
edejfddZ
		ddejded
edejdB fddZ	 ddeeejeB f dB defddZdS )    )AnyN   )get_tp_groupinput_returnc                 C   s   t  | S )z8All-reduce the input tensor across model parallel group.)r   
all_reduce)r    r   ^/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/distributed/communication_op.py tensor_model_parallel_all_reduce   s   r
   dimc                 C      t  | |S )z8All-gather the input tensor across model parallel group.)r   
all_gatherr   r   r   r   r	    tensor_model_parallel_all_gather      r   c                 C   r   )z<Reduce-Scatter the input tensor across model parallel group.)r   reduce_scatterr   r   r   r	   $tensor_model_parallel_reduce_scatter   r   r   dstc                 C   s   t  | ||S )z4Gather the input tensor across model parallel group.)r   gather)r   r   r   r   r   r	   tensor_model_parallel_gather   s   r   tensor_dictsrcc                 C   s   t j s| S t | |S )N)torchdistributedis_initializedr   broadcast_tensor_dict)r   r   r   r   r	   r   &   s   
r   )r   )r   r   )Nr   )typingr   r   torch.distributedparallel_stater   Tensorr
   intr   r   r   dictr   r   r   r   r	   <module>   sJ   


