What is sequence parallelism?
Sequence parallelism is a method splitting the input sequence of transformer models across GPUs along the token dimension, sharing activation memory between devices; the term has two senses: splitting along the sequence the layers tensor parallelism leaves whole, or distributing the whole sequence.
It complements tensor parallelism, which splits large matrix multiplications but repeats activations of layers such as normalisation on every device; narrow sequence parallelism splits these along the sequence. The broad sense splitting everything including attention is often called context parallelism.
- Topic
- Infrastructure and runtime
- Also known as
- SP
- Origin
- Li et al., 2021; Korthikanti et al., 2022
How sequence parallelism works
- In the tensor parallel region, matrix operations are split along the hidden dimension.
- In regions such as normalisation and dropout, activations are shared across devices along the sequence.
- Transitions between regions use cross-device all-gather and reduce-scatter operations.
- With fewer activations to store, costly recomputation is needed less.
In more detail
Equal communication volume and the memory reduction ratio
Narrow sequence parallelism adds zero extra communication compared with standard tensor parallelism because an All-Reduce equals a Reduce-Scatter followed by an All-Gather. Instead of executing one monolithic All-Reduce, Megatron-SP places All-Gather before the tensor-parallel block and Reduce-Scatter after it, keeping communication byte volume unchanged while dividing intermediate activation memory by the tensor-parallel degree N.
Context parallelism methods: ring attention and DeepSpeed-Ulysses
In broad sequence parallelism (context parallelism), approaches such as Ring Attention pass key-value blocks around a ring of GPUs while overlapping communication with FlashAttention computation, whereas DeepSpeed-Ulysses uses All-to-All communication to switch from sequence partitioning to attention-head partitioning. Hybrid designs (such as Unified Sequence Parallelism) combine both to scale beyond attention-head count limits on 128K to multi-million token contexts.
The multi-dimensional parallelism stack and use in prefill
Sequence parallelism integrates directly into 3D/4D parallelism stacks alongside data parallelism (FSDP/ZeRO), tensor parallelism and pipeline parallelism. During inference, context/sequence parallelism is also applied to the prefill stage of very long prompts to cut time-to-first-token (TTFT) across multiple GPUs.
Commonly confused terms
| Term | How it differs |
|---|---|
| Pipeline parallelism | Pipeline parallelism assigns consecutive transformer layers (stages) to different devices, whereas sequence parallelism keeps layers on the same TP group while partitioning activation tensors along the sequence length. |
Why sequence parallelism matters for on-premises AI
Activations are often the memory bottleneck in training large models; they are either stored or recomputed in the backward pass at extra cost. A study combining sequence parallelism with selective recomputation cut activation memory fivefold and recomputation time overhead by over 90%, reaching 54.2% model FLOPS utilisation training a 530 billion parameter model on 2240 GPUs. The broad sense enables training on sequences too long for one device.
Training a mid-sized language model on its own data, a telecom operator's research team adds sequence parallelism to tensor parallelism; lower activation memory lets it switch off most recomputation and train faster on the same GPUs.
Common questions
What does sequence parallelism do?
It splits activations along the sequence across devices to cut memory use, allowing larger models or longer sequences.
How does sequence parallelism differ from context parallelism?
Narrowly, sequence parallelism splits only layers tensor parallelism leaves whole. Context parallelism splits the sequence in all layers including attention.
Related terms
- Context parallelism
- Tensor parallelism
- Model parallelism
- Distributed training
- GPU memory
- Long-context model
Sources
- Korthikanti et al., Reducing Activation Recomputation in Large Transformer Models, 2022
- Li et al., Sequence Parallelism: Long Sequence Training from System Perspective, 2021
In the glossary: Glossary, R to Z