基础知识
分布式通信原语
- Broadcast: 将一张XPU卡数据复制同步到其它所有XPU卡上
- Scatter: 将一张XPU卡数据切片分发到其它所有XPU卡上
- Reduce:接收其它所有XPU卡上数据,通过某种操作(Sum/Mean/Max)之后,最终放到某个XPU卡上
- Gather: 接受其它所有XPU卡上数据,Concat之后放到某个XPU卡上
- All Reduce:所有的XPU节点上都应用同样的Reduce操作。常用的比较负载均衡的是Ring AllReduce,由Reduce Scatter + All gather组合实现。
- All Gather:所有的XPU节点上都应用同样的Gather操作。可通过 单点Gather + Broadcast 来实现。
- Reduce Scatter: 结果上看,每张XPU卡上仅持有Reduce后的部分切片。
Ring AllReduce
为什么说AllReduce由Reduce Scatter + All gather组合实现?
暴力方法一:所有GPU Reduce实现。
暴力方法二:单点Reduce + Broadcast。
缺点:总通信量大,负载不均衡。
| 方法 | 通信量 |
|---|---|
| 暴力方法一 | \((N - 1)^2\) * $ \Phi $ |
| 暴力方法二 | 2 * (N - 1) * $ \Phi $,但通信负载不均衡 |
| Ring All Reduce | 2 * (N - 1) * $ \Phi $ |
Ring All Reduce实现

本文来自博客园,作者:fariver,转载请注明原文链接:https://www.cnblogs.com/fariver/p/18901297

浙公网安备 33010602011771号