Advanced
Tensor, pipeline & sequence parallelism
Model parallel methods split matrix dimensions, layer depth, or sequence positions when data sharding alone cannot fit or efficiently compute the model.
Updated
1
Concept
Fully sharded data parallelism distributes model state but still asks each rank to perform a module’s complete matrix operations after gathering parameters. Very large layers, deep stacks, or extreme sequence lengths may need the computation itself partitioned. Model parallelism is a family of layouts that split different axes.
Tensor parallelism divides a large operation across feature dimensions. For a linear layer , ranks can own columns of and produce different output slices, or own rows and sum partial results. Transformer projections are arranged in complementary column- and row-parallel forms to avoid unnecessary gathers between adjacent operations. Collectives such as all-reduce, all-gather, or reduce-scatter restore the information needed by the next step.
Tensor parallelism reduces per-rank parameter and compute load for a layer, but communication occurs frequently inside every block. It performs best over high-bandwidth, low-latency links, often within one server. Poor placement across a slow network can spend more time combining partial matrices than multiplying them. Head counts, hidden widths, and vocabulary partitions must be divisible or padded according to the chosen layout.
Pipeline parallelism assigns consecutive groups of layers to stages. A microbatch flows through stage 0, then stage 1, and so on. To keep stages busy, the global batch is divided into several microbatches whose forward and backward passes are interleaved. Activations cross stage boundaries, while parameters remain owned by their stages.
The pipeline has bubbles: idle periods during fill, drain, or dependency waits. More microbatches can improve utilization but increase scheduling and activation-state complexity. Uneven layer cost creates imbalance, so partitioning by layer count alone may be poor. Activation checkpointing and interleaved schedules trade memory, recomputation, and bubble size.
Sequence parallelism partitions the token dimension. Some operations, such as normalization and position-wise FFNs, can process local sequence slices. Attention needs interaction across positions, so the system must exchange the right query, key, value, or head partitions. DeepSpeed-Ulysses uses all-to-all communication to transpose between sequence and head partitions, enabling each rank to compute complete attention for a subset of heads before transposing back.
These axes compose into 3D or higher-dimensional parallelism. One deployment may use data-parallel groups across replicas, pipeline stages across layer ranges, tensor-parallel ranks within each stage, and sequence sharding for long contexts. The product of group sizes must match the world size, and each rank needs deterministic coordinates in this grid.
Composition makes batch arithmetic and checkpointing harder. Data-parallel ranks average gradients; tensor ranks jointly own one layer; pipeline ranks own different layers. A checkpoint manifest must know which axis partitioned each tensor. Changing topology at resume requires resharding rather than naïvely assigning rank files.
Measure model FLOPs utilization, but also inspect collective time, exposed communication, stage idle time, memory peaks, and stragglers. A high theoretical FLOP count with long bubbles is not efficient. Profiling should reflect the real sequence and microbatch lengths, since a layout optimized for one workload can fail on another.
The durable map is by axis: data parallelism splits examples; tensor parallelism splits feature computation; pipeline parallelism splits depth; sequence parallelism splits positions. Each makes a larger problem fit by creating coordination. The best topology aligns the heaviest communication with the fastest links and keeps every stage doing useful work.
2
Explain it like I am five
A theatre can divide one production three ways. Tensor parallelism gives sections of the orchestra different notes from the same chord, then combines their sound. Pipeline parallelism assigns acts to different stages and moves several casts through like an assembly line. Sequence parallelism gives each editor a different stretch of the same long script, then exchanges information when a scene needs the whole context.
3
Teach it back
Distinguish what dimension tensor, pipeline, and sequence parallelism partition and state one communication or scheduling cost of each.
Minimum: 80 characters and 15 words. Your text stays only in this browser.
Saved only on this device.
Show a model answer
Tensor parallelism partitions large matrix operations across feature dimensions and uses collectives to combine partial results. Pipeline parallelism assigns consecutive layers to stages and schedules microbatches, introducing activation transfers and pipeline bubbles. Sequence parallelism partitions token positions, reducing per-rank activation or attention memory but requiring exchanges such as all-to-all when attention heads need information across sequence shards.
4
Check your understanding
Complete the teach-back and answer the quiz correctly to finish this lesson.
Sources
- Mohammad Shoeybi et al. (2019). Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism.
- Yanping Huang et al. (2019). GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism.
- Sam Ade Jacobs et al. (2023). DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Models.