What this method splits, and what it must communicate
The two questions, at the top of the page as always.
What SP splits: the sequence length. SP, or Sequence Parallelism, splits neither the batch, nor the weights, nor the layers. It cuts the text: device 0 handles tokens 0 to 511, device 1 tokens 512 to 1023, and so on. It is the fourth possible axis, and the only one that attacks the fourth memory item of training, the activations.
What it must communicate: it depends on the operation, and that is the whole subject. Some operations in a transformer treat each token independently of the others: layer normalization, dropout, residual addition, and the matrix products themselves. For those, splitting the sequence costs nothing: each device does its share without asking for anything. But attention is precisely the operation where every token must see every other one. If the sequence is split, something has to travel.
Hence two distinct techniques, constantly confused because their names look alike.
| Technique | What it splits along the sequence | What it communicates |
|---|---|---|
| SP, sequence parallelism | only the operations tensor parallelism does not split: normalization, dropout, residual | an all-gather and a reduce-scatter at the boundaries between the two modes, volume unchanged |
| CP, Context Parallelism | everything, attention included | the keys and values of each slice, which must travel to every device |
In the literature, "sequence parallelism" sometimes means the first row of the table (the Megatron-LM optimization, coupled to tensor parallelism, that leaves attention alone) and sometimes the second, that is, splitting the sequence including for attention. An earlier 2021 paper already used the term in that second sense.
This page reserves "SP" for the first sense and "CP" for the second, as NVIDIA's documentation does. When you read a paper, check which one it means: the question to ask is always "is attention being split, yes or no?".
Sequence Parallelism: Long Sequence Training from System Perspective (Li et al., 2021)Why the sequence is the right axis for activations
The accounting of the four memory items is established in ZeRO: weights, gradients and optimizer states are counted per parameter, 12 bytes, i.e. 84 GB for a 7-billion model, whereas activations are counted per position in the text.
That difference in counter governs everything. ZeRO and FSDP split the first three items and do not touch the fourth. Tensor parallelism splits some activations, those of the large matrix products, but leaves the rest replicated. Yet at very long context it is the fourth item that explodes, and it only explodes in one direction: length.
The number, derived
Take a hidden dimension , a batch of 1 sequence, and BF16 at 2 bytes per value. One activation tensor of the shape "one value per token per hidden dimension" weighs:
where is the sequence length in tokens and the hidden dimension.
| Context length | One single tensor |
|---|---|
| 8,192 tokens | MB |
| 131,072 tokens (128K) | GB |
A transformer layer produces several tensors of that shape, at minimum the three of , , plus the attention output. At 128K tokens that is already GB for a single layer. Across 80 layers: roughly 690 GB, when a datacenter card tops out at 80 GB.
That is the calculation that makes splitting the sequence mandatory. No other axis answers it: the batch is already at 1, and the weights are not the problem.
An attentive reader will object that the attention score matrix is of size per head, at 128K tokens, over 17 billion entries per head. True, and that is why it is never built: Flash Attention computes attention block by block without ever materializing that matrix, which brings this item from quadratic down to linear in .
In other words, Flash Attention is the prerequisite, and it is not sufficient: once the quadratic matrix is avoided, the tensors that are linear in in the table above remain, and those are what splitting the sequence attacks.
SP: removing a redundancy without paying network
The problem SP solves
You already use tensor parallelism to split the large matrix products. But it does not touch the lightweight operations: layer normalization, dropout, residual addition. Those are executed identically on all 8 devices of the group.
Two wastes. Compute first: eight devices redo the same normalization, like eight accountants recomputing the same invoice. But above all memory: each device stores its own full copy of those activations. At a tensor-parallel degree of 8, the same information takes up eight times its room.
The fix, and its zero cost
SP splits those operations along the sequence. The tensor goes from shape to on each device, where is the degree of the group. Each does one eighth of the work, once.
At the boundaries between the two splitting modes, a conversion is needed:
- from sequence mode to tensor mode: an all-gather, which glues the sequence slices back together into the complete input the matrix product needs;
- from tensor mode to sequence mode: a reduce-scatter, which sums the partial contributions of the matrix product and returns to each device only its slice of the sequence.

Here is the remarkable point, and it rests on an exact identity: an all-reduce is precisely a reduce-scatter followed by an all-gather. That identity is demonstrated in FSDP.
Now, without SP, tensor parallelism was already doing an all-reduce at each boundary. With SP, that all-reduce is replaced by the reduce-scatter and all-gather pair. Those are the two halves of the same operation: exactly the same volume crosses the network. You remove a memory redundancy without paying a single extra byte. That is rare, and it is why SP is switched on by default as soon as tensor parallelism is in use.
What it buys
Take the 134-megabyte tensor computed above, for a context of 8,192 tokens. A layer keeps a handful of tensors of that shape for the operations tensor parallelism does not split. Across several dozen layers you reach a few tens of gigabytes per device, replicated identically on all eight devices of the group. SP divides that item by 8. Not spectacular next to 80 GB of total memory, but it is precisely the headroom that lets you raise batch size or sequence length.
The authors combine sequence parallelism with selective activation recomputation, recomputing only what costs the most memory per unit of compute saved, rather than everything. They report activation memory reduced 5x and the time overhead of recomputation cut by more than 90% relative to full recomputation.
On a 530-billion-parameter model trained on 2,240 A100 cards they measure an MFU (Model FLOPs Utilization, the fraction of the floating-point operations available on the card that actually goes into the model) of 54.2%, against 42.1% with full recomputation, i.e. 29% faster training. Careful: that figure is measured on A100 hardware and does not transfer to another generation, since the denominator of MFU is the card's theoretical peak.
Reducing Activation Recomputation in Large Transformer Models (Korthikanti et al., 2022)The recomputation mechanism is explained in Activation recomputation.
CP: splitting attention itself
SP does not touch attention. Yet once the context reaches 128K tokens and beyond, it is the attention tensors (the , , and output from the table derived above) that dominate. So attention has to be split too.
CP, or Context Parallelism, gives each device a slice of the sequence: for instance 32K tokens on each of 4 devices for a 128K context. Each device keeps its own queries () and computes attention for its own tokens, but since those tokens must see the whole sequence, it needs the keys and values ( and ) of every other slice.
The solution is to pass them around a ring: each device sends its key-value block to one neighbour and receives the other neighbour's, while computing. After one full lap, every device has seen the whole sequence without ever having stored it whole.

That ring algorithm is exactly the one behind Ring Attention, covered in detail in Ring Attention: the overlap between sending the next block and computing the current one, the combination with Flash Attention, the load imbalance causal masking creates and how it is fixed. None of that is repeated here.
CP is the same idea, integrated into training frameworks alongside the other three parallelisms, with two practical additions: support for causal masking, and composition with the tensor-, pipeline- and data-parallel degrees.
Ring Attention with Blockwise Transformers for Near-Infinite Context (Liu et al., 2023)Unlike SP, CP adds communication: the keys and values of each slice must go around the ring, at every layer. On short sequences that traffic can cost more than the memory it saves: there is little compute per token to stack on top of the exchange, hence little material to hide it under. CP earns its place when the sequence is long enough for the attention computation to dwarf the transport of keys and values.
Ulysses: the same end by a different means
An alternative strategy, proposed by Microsoft in DeepSpeed, avoids the ring. Rather than circulating keys and values, it changes the split for the duration of attention:
- Initially , and are split along the sequence: each device holds tokens, but all the attention heads.
- An all-to-all (the collective operation where each device sends a different piece to every other device and receives one from each) redistributes the data: each device now holds the whole sequence, but only some of the heads.
- Each device computes attention for its heads, on its own, with no exchange at all: it has everything it needs.
- A second all-to-all restores the sequence-wise split for the rest of the layer.
The trick rests on the independence of attention heads: since a head needs nothing from the others, the work can be redistributed by head instead of by slice of text.

The authors establish that Ulysses's communication volume stays constant as sequence length and device count are increased in the same proportion, that is the paper's central theoretical argument, other methods seeing their traffic grow with length. On the measurement side, they report training 2.5x faster on sequences 4x longer than the prior method taken as the reference baseline.
DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Models (Jacobs et al., 2023)How to choose? The difference is about network topology. Ulysses concentrates all its traffic into two massive exchanges in which everyone talks to everyone: it therefore needs a network where that pattern is fast and uniform. Ring-based CP only exchanges between neighbours, which tolerates a hierarchy of unequal links, fast inside a machine, slower between machines. In practice, prefer Ulysses on a well-meshed single machine and CP as soon as you have to cross the machine boundary.
Stacking the four axes
SP and CP do not replace the other splits, they add to them. Here is an illustrative configuration for a model trained on 128K tokens with 64 devices:
| Split | Degree | Scope |
|---|---|---|
| TP, tensor parallelism | 8 | inside one machine, over the NVLink |
| SP, sequence parallelism | 8 | coupled to TP: same devices, same degree |
| CP, context parallelism | 4 | attention spread over 4 groups |
| DP, data parallelism | 2 | 2 replicas of the whole thing |
| Total |
Why does SP not appear in the product? Because it is not an independent dimension: it reuses exactly the devices of the tensor-parallel group and only makes sense alongside it, since it operates at the boundaries between the two modes. CP, on the other hand, is a genuine separate dimension that multiplies the device count.
The ranking follows that of the links, as in Megatron-LM. Tensor parallelism, whose exchange cannot be hidden, gets the fastest link. CP exchanges a lot but can overlap its transfers with computation, which makes it more tolerant. Pipeline parallelism, which only sends one boundary activation point-to-point, and data parallelism, which exchanges once per step, take what is left.
When this becomes necessary
SP should be switched on as a matter of course whenever tensor parallelism is in use: it costs nothing on the network and removes a pure redundancy. There is no trade-off to weigh.
CP is a genuine choice, and it arises when two conditions hold: the context is long enough that attention activations no longer fit on one device, and the attention computation is heavy enough for the transport of keys and values to hide underneath it. At short context it costs more than it returns.
These techniques are what makes training on contexts of several hundred thousand tokens practical; the means used by closed models are not public, but context parallelism is available in the open training frameworks, and the context-extension methods build on it.
Summary
Sequence parallelism splits the length of the text, and it is the only axis that attacks activation memory, the one ZeRO and FSDP leave untouched. The calculation that forces it is simple: at 128K tokens and a hidden dimension of 8,192, one single activation tensor weighs 2.1 GB, and there are several per layer across dozens of layers.
Two distinct techniques carry neighbouring names. SP splits only the operations tensor parallelism leaves replicated; it replaces an all-reduce by the reduce-scatter and all-gather pair, which carries exactly the same volume, so it is free and always worth taking. CP splits attention itself and circulates keys and values from slice to slice (the Ring Attention algorithm) which adds real traffic and only earns its place at very long context.
1. The term sequence parallelism refers to two different techniques depending on the paper. What question should you ask to know which one is meant?
2. Why is SP free in communication, to the point of being switched on as a matter of course whenever tensor parallelism is in use?
3. CP, on the other hand, is not free. When does it earn its place?
4. Why is splitting the sequence the only axis that attacks activation memory at very long context?
5. At very long context, is Flash Attention enough to solve the memory problem?