o
    á)i  ã                
   @   sÜ   d dl mZmZ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ej fdd„Z		 ddeeeeejef f  de
fdd„ZdS )é    )ÚAnyÚOptionalÚUnionNé   )Úget_tp_groupÚinput_Úreturnc                 C   s   t ƒ  | ¡S )z8All-reduce the input tensor across model parallel group.)r   Z
all_reduce)r   © r	   úm/home/app/PaddleOCR-VL-test/.venv_paddleocr/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   Z
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   Z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ÚdistributedZis_initializedr   Úbroadcast_tensor_dict)r   r   r	   r	   r
   r   $   s   
r   )r   )r   r   )Nr   )Útypingr   r   r   r   Ztorch.distributedZparallel_stater   ZTensorr   Úintr   r   r   Údictr   r	   r	   r	   r
   Ú<module>   sB   
ÿÿ
ÿ
ÿÿ
ÿ
þÿþ
þþÿþ