
    -`i+              
          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Z	 ddej        d	edej        fd
Z		 ddej        d	edej        fdZ
	 ddej        ded	edej        dz  fdZ	 ddeeej        ez  f         dz  defdZdS )    )AnyN   )get_tp_groupinput_returnc                 D    t                                          |           S )z8All-reduce the input tensor across model parallel group.)r   
all_reduce)r   s    u/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/distributed/communication_op.py tensor_model_parallel_all_reducer      s    >>$$V,,,    dimc                 F    t                                          | |          S )z8All-gather the input tensor across model parallel group.)r   
all_gatherr   r   s     r
    tensor_model_parallel_all_gatherr      s     >>$$VS111r   c                 F    t                                          | |          S )z<Reduce-Scatter the input tensor across model parallel group.)r   reduce_scatterr   s     r
   $tensor_model_parallel_reduce_scatterr      s     >>((555r   dstc                 H    t                                          | ||          S )z4Gather the input tensor across model parallel group.)r   gather)r   r   r   s      r
   tensor_model_parallel_gatherr      s      >>  c222r   tensor_dictsrcc                     t           j                                        s| S t                                          | |          S )N)torchdistributedis_initializedr   broadcast_tensor_dict)r   r   s     r
   r    r    &   s;     ++-- >>//SAAAr   )r   )r   r   )Nr   )typingr   r   torch.distributedparallel_stater   Tensorr   intr   r   r   dictr     r   r
   <module>r(      sz              ( ( ( ( ( (-U\ -el - - - - &(2 2L2"2
\2 2 2 2 &(6 6L6"6
\6 6 6 6 463 3L3"3-03
\D3 3 3 3 JKB Bc5<#--.5BCFB B B B B Br   