NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sequence Parallelism: Long Sequence Training from System Perspective

Shenggui Li, Fuzhao Xue, Chaitanya Baranwal, Yongbin Li, Yang You

Introduction

Transformers have revolutionized deep learning, but their quadratic memory complexity $O(L^2)$ creates a significant "memory wall" for long sequences. While many researchers attempt to solve this algorithmically through sparse or linear attention, these methods often alter model behavior. This paper introduces Sequence Parallelism (SP), a system-level optimization that enables training on sequences up to 27x longer than previous methods by distributing the sequence itself across multiple GPUs.

Overcoming the Memory Wall

Existing distributed training strategies like Tensor Parallelism (TP) and Pipeline Parallelism (PP) focus on splitting model weights or layers. However, they typically require the entire input sequence to reside on a single device at some point, limiting the maximum sequence length to the VRAM capacity of a single GPU.

Comparison of Pipeline, Tensor, and Sequence Parallelism strategies.

Sequence Parallelism addresses this by partitioning the input sequence along the length dimension. This allows for "4D Parallelism"—the simultaneous combination of Data, Pipeline, Tensor, and Sequence parallelism—to scale models across all dimensions of the training workload.

Methods: Ring Self-Attention (RSA)

The core challenge of sequence splitting is the global nature of self-attention: every token must attend to every other token in the sequence. To solve this without aggregating the full sequence on one device, the authors propose Ring Self-Attention (RSA).

In RSA, each GPU holds a local chunk of the sequence's Queries ($Q$), Keys ($K$), and Values ($V$). The $K$ and $V$ tensors are circulated between GPUs in a ring-style communication pattern. As these tensors pass through each device, the GPU computes partial attention scores and updates its local output.

The Ring Self-Attention mechanism circulating key and value embeddings.

This mechanism ensures that the mathematical output remains identical to vanilla attention while keeping the memory footprint per device low. When paired with linear attention algorithms, memory usage becomes independent of the total sequence length, theoretically allowing for "infinite" scaling limited only by the cluster size.

Key Results and Scaling

The researchers evaluated SP using BERT models and synthetic long sequences. Key findings include:

  • Massive Scaling: On 64 NVIDIA P100 GPUs, SP achieved a 3.0× longer maximum sequence length compared to Megatron-LM's Tensor Parallelism.
  • Extreme Lengths: By integrating efficient linear attention, the system successfully trained on sequences exceeding 114,000 tokens—a 27× improvement over single-device implementations.
  • Efficiency: SP proves more memory-efficient than TP in MLP blocks when the product of batch size and sequence length is large relative to the hidden dimension.
  • Convergence: Tests on the Wikipedia dataset confirmed that SP converges to the same accuracy as standard training, proving it is a lossless system optimization.

Conclusion

Sequence Parallelism shifts the focus of long-sequence training from algorithmic approximations to system-level distribution. By breaking the single-device memory limit, it paves the way for training on massive contexts like entire books or high-resolution imagery without sacrificing model quality.

Summary updated

BibTeX
@inproceedings{li2023sequence,
  author = {Shenggui Li and Fuzhao Xue and Chaitanya Baranwal and Yongbin Li and Yang You},
  title = {{Sequence Parallelism: Long Sequence Training from System Perspective}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.134},
}
Figure