Handbooks  /  Distributed Training
AI Engineering~13 min readAdvanced
Deep Dive

Distributed training: when the model doesn't fit, split it four ways.

A frontier model's weights, gradients and optimizer state can demand terabytes of memory — dozens of times what the biggest GPU holds. Training it means orchestrating thousands of GPUs to act as one, and there are exactly four ways to cut the problem up. Understand each cut, and what it costs in communication, and the whole intimidating world of ZeRO, FSDP and 3D parallelism becomes a small menu of trade-offs.

01

What actually eats the memory

Before splitting anything, know what you're splitting. Training an N-parameter model with Adam in mixed precision holds, per parameter: FP16 weights (2 bytes), FP16 gradients (2), and the optimizer's FP32 master weights + two moments (12) — roughly 16-20 bytes per parameter, before a single activation. A 70B model is ~1.2 TB of state; the biggest GPU holds 80-140 GB. Plus activations — the forward-pass values stashed for the backward — which scale with batch size and sequence length and often rival the weights.

→ The two problems, kept separate

Distributed training solves two distinct things people conflate: "train faster" (throughput — spread the batch) and "it doesn't fit" (memory — spread the model/state). Different strategies target different problems; naming which one you have is the first move.

02

Data parallelism: copy the model, split the batch

The workhorse. Every GPU holds a full model copy and processes a different batch slice; after each backward pass, an all-reduce averages gradients across all GPUs so the copies stay identical. Simple, scales throughput near-linearly (until all-reduce saturates the network), and it's the default in every framework.

Its one fatal assumption: the whole model fits on one GPU. The moment it doesn't, pure data parallelism is dead — and every strategy below exists to lift that ceiling. The all-reduce also becomes the scaling wall at large GPU counts, which is why the communication-overlap tricks in section 06 matter.

03

ZeRO / FSDP: stop storing everything N times

Data parallelism is wildly redundant: every GPU stores the same optimizer states, gradients and weights. ZeRO (DeepSpeed) and FSDP (PyTorch) ask the obvious question — why? — and shard that state across GPUs, gathering each layer's parameters just-in-time for its forward/backward, then releasing them.

The sharding stages — more sharded, more memory saved, more communication
Stage 1shard optimizer states (the 12-byte chunk) — biggest saving per unit pain.
Stage 2also shard gradients.
Stage 3 / FSDPalso shard parameters themselves — gather per layer, use, discard. Trains models far past one GPU's memory.

The beauty: it stays logically data parallel — nearly the same training code, dramatically higher memory ceiling, at the cost of extra all-gather traffic. For most teams training big-but-not-frontier models, FSDP/ZeRO-3 is the answer, full stop; the exotic strategies below are for when even this isn't enough.

04

Tensor parallelism: split the layer itself

When a single layer's matrices are too big, split within the operation: a matrix multiply is divided column- or row-wise across GPUs, each computes its shard, and they combine results with an all-reduce. This happens inside every layer, on every forward and backward — so tensor parallelism is communication-hungry and lives on NVLink, staying inside a single node (typically 8 GPUs). Cross-node tensor parallelism drowns in interconnect latency. It's the tool for making an individual layer fit, not for scaling out broadly.

05

Pipeline parallelism: split the model into stages

Cut the model by layers: GPU 0 runs layers 1-10, GPU 1 runs 11-20, and so on, passing activations down the line like a factory. It moves only activations at stage boundaries — bandwidth-light enough to cross nodes. The catch is the pipeline bubble: while stage 1 works on the first micro-batch, stages 2-4 sit idle waiting for it. The fix is micro-batching — split the batch into many small pieces so all stages stay busy processing different micro-batches at once, shrinking the idle bubble toward zero. Pipeline parallelism is how you scale across the datacenter where tensor parallelism can't reach.

06

3D parallelism and the overlap that decides everything

No single axis scales far enough, so frontier training composes all three: tensor parallelism inside a node (hungry, needs NVLink), pipeline parallelism across a handful of nodes (layer stages), data parallelism across the resulting groups (replicas on different data). Each covers another's weakness, mapped deliberately onto the NVLink-fast / InfiniBand-slow topology.

→ The metric that rules the cluster

Efficiency lives or dies on overlapping communication with computation: all-reduce gradients for layer N while computing layer N-1, prefetch the next shard while using the current one. A job that stalls on communication can burn half its GPU-hours doing nothing — which is why real MFU of 35-50% is a triumph, not a disappointment.

07

The memory tricks you'll reach for first

TechniqueWhat it buys
Mixed precision (BF16/FP8)half+ the memory and ~2× compute on tensor cores — the free lunch, on by default
Gradient accumulationsimulate a huge batch on small memory — accumulate over K micro-steps, then update
Activation checkpointingstore fewer activations, recompute them in backward — trade compute for memory
CPU/NVMe offloadpark cold optimizer state off-GPU (ZeRO-Infinity) — slow but makes the impossible fit
Gradient clippingnot memory, but the stability seatbelt that keeps big runs from spiking

The honest order of operations: reach for mixed precision + FSDP + activation checkpointing first — that combination trains most large models teams actually build. Tensor and pipeline parallelism are the frontier-scale tools you add only when sharding alone runs out of room.

Frequently asked

Quick answers

What is data parallelism?

Every GPU holds the full model, processes a different batch slice, and all-reduces gradients to stay in sync. Simple and fast — but the model must fit on one GPU.

What do ZeRO / FSDP do?

Shard optimizer state, gradients and (stage 3) parameters across GPUs, gathering per layer on demand — near-data-parallel code, far higher memory ceiling.

Tensor vs pipeline parallelism?

Tensor splits inside a layer (bandwidth-hungry, one node, NVLink); pipeline splits by layers into stages (bandwidth-light, crosses nodes, has a bubble micro-batching hides).

What is 3D parallelism?

All three composed: tensor inside a node, pipeline across nodes, data across the groups — mapped onto the NVLink/InfiniBand topology.

Distributed Training · AI Engineering · Vibe Engines · 2026
Finished this one? 0 / 49 Handbooks done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.