
    ɯwg                     J   d dl mZmZ d dlZd dlmc mZ 	 d Zd Z	d Z
d Zd Zdej                  d	ed
edee   def
dZdeej                     d	ed
edee   def
dZdej                  deee      deee      d
edee   defdZdej                  dej                  fdZy)    )ListOptionalNc                     t        j                  ||      }t        j                  j                  j                  | ||      S N)c10d$_resolve_group_name_by_ranks_and_tagtorchops_c10d_functional	broadcast)inputsrctagranks
group_size
group_names         s/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/torch/distributed/_functional_collectives_impl.py
_broadcastr      s:    ::5#FJ99%%//     c                     t        j                  ||      }t        j                  j                  j                  | ||      S r   )r   r   r	   r
   r   
all_reducer   	reduce_opr   r   r   r   s         r   _all_reducer      s:    ::5#FJ99%%00 r   c                     t        j                  ||      }t        j                  j                  j                  | ||      S r   )r   r   r	   r
   r   all_reduce_coalescedinputsr   r   r   r   r   s         r   _all_reduce_coalescedr       s:    ::5#FJ99%%:: r   c                     t        j                  ||      }t        j                  j                  j                  | ||      S r   )r   r   r	   r
   r   all_gather_into_tensorr   r   r   r   r   s        r   _all_gather_into_tensorr#   )   s:    ::5#FJ99%%<< r   c                     t        j                  ||      }t        j                  j                  j                  | ||      S r   )r   r   r	   r
   r    all_gather_into_tensor_coalescedr"   s        r   !_all_gather_into_tensor_coalescedr&   2   s:    ::5#FJ99%%FF r   r   r   r   r   r   c                     t        j                  ||      }t        j                  j                  j                  | |||      S r   )r   r   r	   r
   r   reduce_scatter_tensorr   s         r   _reduce_scatter_tensorr)   ;   s?     ::5#FJ99%%;;	 r   r   c                     t        j                  ||      }t        j                  j                  j                  | |||      S r   )r   r   r	   r
   r   reduce_scatter_tensor_coalescedr   s         r    _reduce_scatter_tensor_coalescedr,   K   s?     ::5#FJ99%%EE	 r   output_split_sizesinput_split_sizesc                     ||#||J d       | j                   d   |z  g|z  }|}t        j                  ||      }t        j                  j
                  j                  | |||      S )Nz^output_split_sizes and input_split_sizes must either be specified together or both set to Noner   )shaper   r   r	   r
   r   all_to_all_single)r   r-   r.   r   r   r   r   s          r   _all_to_all_singler2   [   s     !%6%>!).?.G 	
5	
G $kk!n
:;jH.::5#FJ99%%77	 r   tensorreturnc                 T    t         j                  j                  j                  |       S r   )r	   r
   r   wait_tensor)r3   s    r   _wait_tensorr7   t   s    99%%11&99r   )typingr   r   r	   "torch.distributed.distributed_c10ddistributeddistributed_c10dr   r   r   r   r#   r&   Tensorstrintr)   r,   r2   r7    r   r   <module>r@      s   !  1 1<< 
 9	
   
 9	
  << c+  S	* 
	
 9 2: :%,, :r   