Distributed Model Parallelism
Partition model state and computation across devices
Derive the state ownership, local tensor shapes, communication, memory, and scheduling effects of each parallel dimension before composing a physical rank mesh.
Suppose a transformer training process needs 96 GiB for model weights, gradients, and optimizer state, but one graphics processing unit (GPU) has only 80 GiB of high-bandwidth memory (HBM). Adding a second GPU does not make the model fit automatically. Software must decide which bytes each GPU stores, which matrix operations each GPU performs, and when the GPUs exchange partial results.
Distributed training frameworks normally run one central processing unit (CPU) process per GPU. The process receives an integer identifier called a rank. Rank 0 is a process identity, not a claim that its GPU is faster or physically central. A process group names the ranks that participate in a particular sequence of communication operations. PyTorch logs, profiler events, and NCCL messages use these rank and group identifiers to relate local activity to the complete job.
A memory report collected after model construction shows persistent allocations such as parameters and optimizer tensors. A profiler trace collected for one step shows temporary parameter gathers, gradient reductions, activation transfers, and idle intervals. Local tensor shapes printed at selected module boundaries show how each general matrix multiplication (GEMM) changed on every rank. GPU communication kernels can also occupy streaming multiprocessors (SMs) while model kernels wait. Together, the observations reveal whether a parallel method solved the original capacity problem and what new work the method introduced.
This chapter derives data, fully sharded, tensor, pipeline, expert, and combined parallelism from those concrete objects. Every section names the owner of each tensor, the exact local shape, the required communication, and the point in forward or backward execution where another rank's data becomes necessary.
Prerequisites
- Chapter 3 accounting for parameters, gradients, optimizer state, and activations
- Chapter 13 collective contracts and route model
- Ability to follow tensor dependencies through forward and backward computation
Learning objectives
- State tensor ownership and local shapes for every parallel axis
- Calculate persistent memory, peak transient memory, collective bytes, and readiness
- Map a multidimensional rank mesh to measured physical topology
Study this chapter
- 14.1Data parallelism and gradient synchronizationBegin lesson →
Derive the synchronized global-batch gradient and explain replicated memory, bucket readiness, and slowest-rank behavior in distributed data parallel training
- 14.2ZeRO and fully sharded data parallelismBegin lesson →
Draw one module's parameter and gradient lifetimes through fully sharded forward and backward execution and identify the measured memory peak
- 14.3Tensor and sequence parallelismBegin lesson →
Derive local forward and backward matrix shapes, ownership, and collectives for column- and row-parallel linear layers
- 14.4Pipeline and expert parallelismBegin lesson →
Read a pipeline-stage timeline and an expert token-count distribution to locate structural idle time, stage imbalance, and routing skew
- 14.5Parallel mesh designBegin lesson →
Construct rank coordinates, process groups, memory timelines, collective tables, and physical placement for one feasible combined mesh
Extended exercises
Complete these projects after the lesson-level practice tasks. Each project combines several mechanisms from the chapter.
Linear-layer sharding
For X[8,192, 4,096] and W[4,096, 16,384], derive four-rank column and row partitions through forward and backward computation.
Evidence: Global and local tensor shapes, ownership after each operation, and exact collective type and payload at every transition.
Training resource comparison
Compare data parallelism, full sharding, and tensor parallelism for the recurring 1-billion-parameter model on one eight-GPU server with declared sequence length, microbatch, precision, and links.
Evidence: Per-rank persistent and peak memory, local matrix shapes, communication bytes and readiness, plus one measured slice for the largest assumption.
Mesh proposal
Design a multidimensional rank mesh for a declared model that cannot fit on one server and compare it with one serious alternative.
Evidence: Rank coordinates, process-group lists, topology mapping, memory timeline, collective schedule, predicted step time, restore plan, and measured reason for rejecting the alternative.
Sources and further reading
The lesson explanations synthesize primary papers and official references. Follow the originals for proofs, exact APIs, architecture details, and version-sensitive behavior.