Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.When one desk isn’t big enough
If a single giant map doesn’t fit on any desk, you can cut it into strips and give each person one strip (they must talk at the edges), or arrange people in an assembly line where each does one stage of the work and passes it on. Huge neural networks are split the same ways: tensor parallelism cuts each layer’s big matrices into strips; pipeline parallelism gives different layers to different GPUs and streams small batches through them like an assembly line.
Foundation models for Earth observation, weather and language have tens to hundreds of billions of parameters: they don’t fit in one GPU’s memory. Even moderately large scientific models (3D vision transformers, long-context sequence models for telemetry) need model parallelism once activations or parameters outgrow a single device.
- 1. Model parallelism is needed when…
- 2. Pipeline parallelism gives each GPU…
- 3. In the demo, what shrinks the idle bubble?
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The four ways to split
| Strategy | What is split | Communication | Typical placement |
|---|---|---|---|
| tensor (TP) | weight matrices of each layer | all-reduce per block (2 per layer forward) | within a node (NVLink) |
| pipeline (PP) | layers into stages | point-to-point activations between stages | across nodes |
| sequence / context (SP/CP) | activations along the sequence | all-gather / reduce-scatter, ring attention | with TP, long contexts |
| expert (EP) | experts of MoE layers | all-to-all token routing | across GPUs |
| data (DP) | the batch | gradient all-reduce | everywhere |
N GPUs are factored as TP × PP × DP (× EP, CP). Frameworks: Megatron-LM, DeepSpeed, PyTorch’s DTensor and pipelining APIs, JAX’s sharding (C3.4).
- 1. Which split communicates most often and so belongs within a node?
- 2. 64 GPUs as TP = 8, PP = 2: how many data-parallel replicas?
- 3. Expert parallelism routes tokens with…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Tensor parallelism (Megatron-LM)
Split the first MLP weight W₁ by columns: each GPU computes its slice of XW₁ with no communication, and GELU (element-wise) applies locally. Split W₂ by rows: each GPU multiplies its slice of the hidden activations by its rows of W₂, producing a partial sum of the output; one all-reduce combines them. Attention splits the same way by heads (Q, K, V columns per head, output projection by rows). Each transformer layer therefore needs two all-reduces in forward and two in backward, of size batch × sequence × hidden.
Pipeline parallelism
Stages of consecutive layers on different GPUs; a batch is cut into M micro-batches. With S stages, forward and backward times t_f and t_b, a step takes (M + S − 1)(t_f + t_b): the bubble fraction is (S − 1)/(M + S − 1). GPipe runs all forwards then all backwards, storing M micro-batches of activations; 1F1B interleaves them so stage 0 stores at most S. Interleaved 1F1B (several virtual stages per GPU) and zero-bubble schedules reduce the bubble further.
Mixture of experts
A router sends each token to its top-k experts; each expert accepts at most C = capacity factor × tokens/experts tokens, extra tokens are dropped (passed through the residual). Load-balancing losses keep experts evenly used.
- 1. Why split W₁ by columns and W₂ by rows?
- 2. Bubble for S = 4 stages and M = 8 micro-batches?
- 3. 1F1B's advantage over GPipe is…
Level 3: Advanced
★★★★☆ Advanced⏱ 35 minGraduate level, with full derivations and proofs.Choosing a layout
- Fit first: parameters, gradients and optimizer states (16 bytes per parameter in mixed-precision Adam, C5.5; sharded further by ZeRO, C6.3) plus activations must fit in GPU memory.
- Tensor parallelism inside a node: its all-reduces happen every layer; over NVLink (hundreds of GB/s) they are cheap, across nodes (tens of GB/s) they dominate.
- Pipeline across nodes: only activations at stage boundaries cross the network; keep M ≫ S to make the bubble small.
- Data parallelism for the rest: it scales throughput, its gradient all-reduce overlaps backward, and ZeRO removes its memory redundancy.
- Long sequences: sequence/context parallelism splits the attention activations that grow with sequence length.
Typical large-model recipes: TP = 8 within each node, PP over a few nodes, DP (with ZeRO/FSDP) over the rest.
- 1. Tensor parallelism of 16 on 8-GPU nodes forces…
- 2. A 70B model in mixed-precision Adam needs roughly how much memory for model states alone?
- 3. Pipelines want many micro-batches because…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Model parallelism, measured
Exercise 1. The tensor-parallel MLP and attention reproduce the unsplit layers exactly for 1, 2, 4 and 8 ranks, with one all-reduce each. For S = 4 stages and M = 8 micro-batches (forward 1, backward 2 time units), both schedules take 33 units (bubble 3/11 = 27%), confirmed by an event simulation; GPipe stores 8 micro-batches per stage, 1F1B 4; with M = 32 the bubble falls below 10%. Routing 1000 tokens to 8 experts (one expert favoured by the router) with capacity factor 1.25 (157 tokens per expert) drops 222 tokens; capacity factor 2.0 drops 129.
Exercise 2: searching 3D layouts. 64 A100s (8 per node, NVLink 300 GB/s inside a node, 25 GB/s per GPU between nodes), global batch 512 sequences of 2048 tokens, micro-batch 1, 1F1B, ZeRO-1, no compute/communication overlap, 50% kernel efficiency:
| Model | best (TP, PP, DP) | time per step | memory per GPU | MFU | notable alternatives |
|---|---|---|---|---|---|
| 1.3B | (2, 2, 16) | 0.89 s | 3.1 GB | 43% | pure DP: 0.95 s, fits easily |
| 13B | (2, 4, 8) | 8.81 s | 15.8 GB | 45% | pure DP: 9.91 s at 67 GB (gradient all-reduce of 26 GB) |
| 70B | (4, 4, 4) | 44.1 s | 40 GB | 46% | pure DP: needs 315 GB, impossible; TP = 16 across nodes: 144 s |
Many layouts land within 1% of the best, because with 32–128 micro-batches per pipeline the bubble is small and NVLink makes intra-node tensor parallelism cheap; the decisive mistakes are layouts that don’t fit and tensor parallelism across nodes, whose per-layer all-reduces take 2.5× longer than the computation itself. The model ignores overlap and communication-hiding tricks, so absolute times are pessimistic.
Model parallelism in AI, robotics and aerospace
- Foundation models for language, Earth observation (multi-spectral vision transformers) and weather (global forecasting transformers) trained with 3D parallelism.
- Long-context models for telemetry or genomics using sequence/context parallelism.
- Mixture-of-experts models that scale parameters without proportionally scaling compute.
- Inference: tensor parallelism across the GPUs of one server to serve a model too large for one GPU at low latency.
References
- M. Shoeybi et al. (2019). “Megatron-LM: training multi-billion parameter language models using model parallelism.” arXiv:1909.08053.
- Y. Huang et al. (2019). “GPipe: efficient training of giant neural networks using pipeline parallelism.” NeurIPS.
- D. Narayanan et al. (2021). “Efficient large-scale language model training on GPU clusters using Megatron-LM.” SC21 (1F1B, interleaving, 3D parallelism).
- W. Fedus, B. Zoph, N. Shazeer (2022). “Switch transformers: scaling to trillion parameter models with simple and efficient sparsity.” JMLR, 23.
- V. Korthikanti et al. (2023). “Reducing activation recomputation in large transformer models.” MLSys (sequence parallelism, activation memory).