mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-22 09:59:38 +00:00
[doc] update sp doc (#6055)
* update sp doc * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * fix * fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,25 @@
|
||||
- [Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism](https://arxiv.org/abs/1909.08053)
|
||||
- [Chimera: Efficiently Training Large-Scale Neural Networks with Bidirectional Pipelines](https://arxiv.org/abs/2107.06925)
|
||||
|
||||
### 序列并行
|
||||
序列并行是一种对于序列维度进行切分的并行策略,它是训练长文本序列的有效方法。现成熟的序列并行方法包括megatron提出的序列并行,DeepSpeed-Ulysses序列并行和ring-attention序列并行等。
|
||||
#### megatron sp:
|
||||
|
||||
该序列并行方法是在张量并行的基础上实现的序列并行,模型并行的每个gpu上,样本独立且重复的,对于非线性运算的部分如layernorm等无法使用张量并行的模块,可以在序列维度将样本数据切分为多个部分,每个gpu计算部分数据,然后在计算attention及mlp等线性部分使用张量并行策略,需要将activation汇总,这样可以在模型进行切分的情况下进一步减少activation的内存占用,需要注意的是该序列并行方法只能与张量并行一起使用。
|
||||
|
||||
#### DeepSpeed-Ulysses:
|
||||
|
||||
序列并行通过在序列维度上分割样本并利用all-to-all通信操作,使每个GPU接收完整序列但仅计算注意力头的非重叠子集,从而实现序列并行。该并行方法具有完全通用的attention,可支持密集和稀疏的注意力。
|
||||
alltoall是一个全交换操作,相当于分布式转置的操作,在attention计算之前,将样本沿序列维度进行切分,每个设备只有N/P的序列长度,然而使用alltoall后,qkv的子部分shape变为[N, d/p],在计算attention时仍考虑了整体的序列。
|
||||
#### ring attention:
|
||||
|
||||
ring attention思路类似于flash attention,每个GPU只计算一个局部的attention,最后将所有的attention块结果进行归约计算出总的attention。在Ring Attention中,输入序列被沿着序列维度切分为多个块,每个块由不同的GPU或处理器负责处理,Ring Attention采用了一种称为“环形通信”的策略,通过跨卡的p2p通信相互传递kv子块来实现迭代计算,可以实现多卡的超长文本。在这种策略下,每个处理器只与它的前一个和后一个处理器交换信息,形成一个环形网络。通过这种方式,中间结果可以在处理器之间高效传递,而无需全局同步,减少了通信开销。
|
||||
|
||||
相关论文:
|
||||
[Reducing Activation Recomputation in Large Transformer Models](https://arxiv.org/pdf/2205.05198)
|
||||
[DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Models](https://arxiv.org/abs/2309.14509)
|
||||
[Ring Attention with Blockwise Transformers for Near-Infinite Context](https://arxiv.org/pdf/2310.01889)
|
||||
|
||||
|
||||
## 优化器相关的并行
|
||||
|
||||
@@ -90,3 +109,4 @@
|
||||
- [ZeRO-Offload: Democratizing Billion-Scale Model Training](https://arxiv.org/abs/2101.06840)
|
||||
- [ZeRO-Infinity: Breaking the GPU Memory Wall for Extreme Scale Deep Learning](https://arxiv.org/abs/2104.07857)
|
||||
- [PatrickStar: Parallel Training of Pre-trained Models via Chunk-based Memory Management](https://arxiv.org/abs/2108.05818)
|
||||
<!-- doc-test-command: echo -->
|
||||
|
Reference in New Issue
Block a user