What are data, tensor and pipeline parallelism in distributed training, and when should you use each?

ML system design, Distributed training
Level L3 Intermediate. Length Medium. Nature Th Theoretical.

What's being asked

Whether you understand the three main ways to distribute neural-network training across GPUs (graphics processing units): what each splits, what each communicates, and when to combine them.

Key idea

Data parallelism splits the training batch across GPUs while replicating the model; tensor parallelism splits individual weight matrices inside each layer; pipeline parallelism splits whole layers into sequential stages. You start with data parallelism when the model fits on one GPU, add tensor or pipeline parallelism when it does not, and combine all three (3D parallelism) on large clusters.

Steps

  1. Data parallelism (DP): split each mini-batch across N GPUs, with every GPU holding a full replica of the model weights and optimiser states. After each backward pass, GPUs synchronise their gradients with an all-reduce (a collective operation that sums gradients across GPUs and returns the result to all of them) so every copy stays identical; use DP first whenever the model fits in one GPU's memory.
  2. Tensor parallelism (TP): split individual layer weight matrices (such as attention projections and multilayer perceptron (MLP) linear layers) by rows or columns across GPUs so each GPU computes a slice of the matrix multiplication. Because every layer must synchronise activations via all-reduce or all-gather, TP needs high-bandwidth intra-node links (such as NVLink, a fast GPU-to-GPU interconnect) and is normally kept within one server.
  3. Pipeline parallelism (PP): partition the model's layers into p sequential stages on different GPUs, passing activations forward and gradients backward only at stage boundaries. Because communication occurs only between neighbouring stages, PP needs far less bandwidth than TP and scales across servers.
  4. The pipeline bubble: with one batch, only one stage computes at a time while p−1 stages sit idle. Splitting the batch into m micro-batches lets stages overlap execution, shrinking the idle bubble fraction to roughly p−1m+p−1 (for example, p=4 stages with m=16 micro-batches cuts idle time from 75% at m=1 down to 3/19≈15.8%).
  5. Combining all three (3D parallelism): use DP alone when the model fits on one GPU, add TP within a node when single layers or activations exceed one GPU's memory, add PP across nodes when the full depth still does not fit, and stack DP across model replicas to scale total batch throughput.

Common mistakes

How long your answer should be

2–3 minutes; cover what is split, what is communicated, the pipeline bubble formula, and how 3D parallelism combines them.

Read this

Previous in ML system design: How would you design a movie recommendation system for a small app with 10,000 users and 2,000 movies? Using a 3×3 rating table where Movie A has ratings (3,4,0), Movie B has (4,3,0) and Movie C has (0,3,4) from three users, what is the cosine similarity between Movie A and Movie B, and how much storage is needed to precompute 20 recommendations per user nightly?
Next in ML system design: You run data-parallel training on N=8 GPUs for a model with P=1 billion parameters and fp16 gradients (2 bytes each). Using ring all-reduce, how many bytes does each GPU send per step, and how long does communication take at 100 GB/s per link?