分级通信原理
HCCL通常按节点内/节点间分为两级拓扑、或按节点内/节点间/超节点间分为三级拓扑,分级执行集合通信,不同的层级间链路带宽不同。分级通信可以使通信任务编排与网络拓扑亲和,从而最大化利用链路能力。
以
集合通信算子 |
阶段一 |
阶段二 |
阶段三 |
---|---|---|---|
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 |
/ |
AlltoAllVC |
Server内AlltoAllVC |
Server间AlltoAllVC |
/ |
下面以通信算子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操作。