[论文解读] DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Models
DeepSpeed-Ulysses 引入了一种新颖的序列并行方法,通过将输入序列跨 GPU 分区,并利用高效的 all-to-all 通信,实现了 Transformer 模型在极端序列长度(高达 100 万 token)下的训练,相比先前系统实现 2.5 倍更快的训练速度和超过 10 倍的通信量减少,同时保持高吞吐量,并与 FlashAttention 和 ZeRO-3 兼容。
Computation in a typical Transformer-based large language model (LLM) can be characterized by batch size, hidden dimension, number of layers, and sequence length. Until now, system works for accelerating LLM training have focused on the first three dimensions: data parallelism for batch size, tensor parallelism for hidden size and pipeline parallelism for model depth or layers. These widely studied forms of parallelism are not targeted or optimized for long sequence Transformer models. Given practical application needs for long sequence LLM, renewed attentions are being drawn to sequence parallelism. However, existing works in sequence parallelism are constrained by memory-communication inefficiency, limiting their scalability to long sequence large models. In this work, we introduce DeepSpeed-Ulysses, a novel, portable and effective methodology for enabling highly efficient and scalable LLM training with extremely long sequence length. DeepSpeed-Ulysses at its core partitions input data along the sequence dimension and employs an efficient all-to-all collective communication for attention computation. Theoretical communication analysis shows that whereas other methods incur communication overhead as sequence length increases, DeepSpeed-Ulysses maintains constant communication volume when sequence length and compute devices are increased proportionally. Furthermore, experimental evaluations show that DeepSpeed-Ulysses trains 2.5x faster with 4x longer sequence length than the existing method SOTA baseline.
研究动机与目标
- 解决现有并行技术(数据并行、张量并行和流水线并行)在处理 Transformer 模型中极长序列长度时的可扩展性限制。
- 克服现有序列并行方法中存在的内存-通信低效问题,这些问题是长序列可扩展性的障碍。
- 设计一种通用、可移植且仅需极少代码修改的系统级优化,以实现跨不同硬件和注意力机制的长序列大模型高效可扩展训练。
- 实现高计算利用率(超过峰值的 54%),并支持密集注意力和稀疏注意力,性能下降最小。
提出的方法
- 沿序列维度将输入序列分区到多个 GPU 上,实现非重叠序列段的并行处理。
- 在注意力计算前后使用 all-to-all 通信原语,重新分配查询、键和值到不同注意力头,确保每个 GPU 仅为其分配的头子集进行计算。
- 采用两阶段 all-to-all 通信:第一阶段重新配置数据,使每个 GPU 收到其指定注意力头所需的完整序列;第二阶段在重新分区序列维度的同时聚合结果。
- 与 ZeRO-3 无缝集成,实现模型并行和内存优化,支持大模型尺寸和长序列长度的训练。
- 支持高效的注意力机制,包括 FlashAttention v2 和稀疏注意力(如分块稀疏),并保持低通信开销。
- 系统设计为实现无关性,仅需对现有训练框架进行极少代码修改。

实验结果
研究问题
- RQ1序列并行能否在大规模下实现通信高效,尤其是在序列长度增加时?
- RQ2如何利用 all-to-all 通信在序列长度和设备数量增加时保持通信量恒定?
- RQ3像 DeepSpeed-Ulysses 这样的系统级优化能否在无需侵入式代码重构的情况下实现长序列训练的高吞吐量和强可扩展性?
- RQ4与现有序列并行方法(如 Megatron-LM)相比,该方法在吞吐量、内存效率和可扩展性方面有多大的性能优势?
- RQ5DeepSpeed-Ulysses 与 ZeRO-3 和 FlashAttention 的集成如何影响训练效率和模型尺寸的可扩展性?
主要发现
- DeepSpeed-Ulysses 支持训练序列长度高达 100 万 token 的模型,是现有系统长度的 4 倍。
- 该方法在 7B 和 30B 参数模型的密集注意力设置下,相比 SOTA 基线(Megatron-LM)实现 2.5 倍更高的训练吞吐量。
- 随着序列长度和 GPU 数量成比例增加,通信量保持恒定,而其他方法则因通信开销增加而性能下降。
- 系统在实验中持续达到每 GPU 超过 175 TFlops,实现超过 54% 的硬件峰值性能。
- 通过与 ZeRO-3 集成带来的内存节省,即使在相同硬件条件下,也能实现比 Megatron-LM 长 4 倍的序列长度。
- 该方法表现出强弱可扩展性:当序列长度和 GPU 数量成比例增加时,吞吐量仍保持较高水平,仅因通信开销导致轻微性能下降。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。