分级通信原理
HCCL通常按Server内和Server间分为两级拓扑,分级执行集合通信,各集合通信算子的具体分级通信过程如下表所示:
集合通信算子  | 
阶段一  | 
阶段二  | 
阶段三  | 
|---|---|---|---|
ReduceScatter  | 
Server间ReduceScatter  | 
Server内ReduceScatter  | 
/  | 
AllGather  | 
Server内AllGather  | 
Server间AllGather  | 
/  | 
AllReduce  | 
Server内ReduceScatter  | 
Server间AllReduce  | 
Server内AllGather  | 
Scatter  | 
Server间Scatter  | 
Server内Scatter  | 
/  | 
Broadcast  | 
Server内Scatter  | 
Server间Broadcast  | 
Server内AllGather  | 
Reduce  | 
Server内ReduceScatter  | 
Server间Reduce  | 
Server内Gather  | 
AlltoAll  | 
Server内AlltoAll  | 
Server间AlltoAll  | 
/  | 
AlltoAllV  | 
Server内AlltoAllV  | 
Server间AlltoAllV  | 
/  | 
下面以典型的通信算子ReduceScatter、AllGather、AllReduce为例介绍分级通信的流程。
ReduceScatter
如图1所示,ReduceScatter算子要求第i个rank最终得到第i份规约结果,为了保证Server间通信数据块的连续性,首先在Server间执行ReduceScatter操作,再在Server内执行ReduceScatter操作。
AllGather
如图2所示,AllGather算子要求第i个rank的输入数据出现在结果的第i个位置上,为了保证Server间通信数据块的连续性,首先在Server内执行AllGather操作,再在Server间执行AllGather操作。
AllReduce
如图3所示,AllReduce算子的输出是完整的规约结果,因此虽然拆解为了ReduceScatter和AllGather两个阶段,但不需要严格遵循ReduceScatter和AllGather的语义,可以将较大数据量的通信过程放在带宽更高的Server内,即先在Server内执行ReduceScatter操作,然后在Server间执行AllReduce操作,最后在Server内执行AllGather操作。


