因此对应于分层架构,主要是分层次的通信速度/带宽,需要采用分层的并行策略。最常见的就是机器内采用tensor 并行,机器外采用其他并行方案。
总结分为几方面
零冗余优化器 (Zero Redundancy Optimizer,ZeRO) - 也执行与 TP 相类似的张量分片,但整个张量会及时重建以进行前向或反向计算,因此不需要修改模型。它还支持各种卸载技术以补偿有限的 GPU 内存。
ZeRO是什么为什么它与Megratron不同?
ZeRO 数据并行
看上去比较高大上,可能让你很难专心去理解,但实际上,这个概念非常简单。这只是通常的 DDP,只是没有每个 GPU 都复制完整的模型参数、梯度和优化器状态,而是每个 GPU 只存储其中的一部分。在随后的运行过程中,当需要给定层的完整层参数时,所有 GPU 同步以相互提供它们缺失的部分 —— 仅此而已。
We call this ZeRO-powered data parallelism, which allows per-device memory usage to scale linearly with the degree of data parallelism and incurs similar communication volume as data parallelism. ZeRO-powered data parallelism can fit models of arbitrary size—as long as the aggregated device memory is large enough to share the model states.
Megatron PP+TP
v1: Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism
v2: Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM
v3: Reducing Activation Recomputation in Large Transformer Models
v1解决的主要问题,是降低显存;v2解决的主要问题是3D并行如何组合;v3解决的问题是降低activation
interleaving pipeline并行优化:interleaved 1F1B pipeline
combination of same tensor and optimized pipeline model parallelism (MP)
v3 activation优化:序列并行sequence parallel、selective activation recomputation
解决的问题是tensor并行对于activation切分不彻底,既然没法在隐向量维度切分,这里改成了从序列维度来切分。
ZeRO
v1: ZeRO: Memory Optimizations Toward Training Trillion Parameter Models
v2: ZeRO-Offload: Democratizing Billion-Scale Model Training
v3: ZeRO-Infinity: Breaking the GPU Memory Wall for Extreme Scale Deep Learning
v1DP+PP
v2
v3