Start studying
Module 16 · Advanced AI Module contents
Module 16  ·  Card 18 / 23advanced

Distributed Training

Distributed training spreads one training run across many GPUs.

Data parallelism copies the model and splits the batch.

Tensor parallelism splits individual layers across devices.

Pipeline parallelism assigns different layers to different devices.

Frontier models combine all three, and communication becomes the bottleneck.

Learn in depth ↓
Module 16 · Advanced AI · 23 concepts
In depth  /  15 lines

Distributed Training, in more detail

Distributed training spreads one training run across many GPUs.

It becomes necessary when a model or its batch will not fit on one device.

Data parallelism is the simplest form and the most common.

Every GPU holds a full copy of the model and processes a different slice of the batch.

Gradients are averaged across devices after each step so the copies stay in step.

That works until the model itself no longer fits on one GPU.

Tensor parallelism splits individual layers across devices.

A matrix multiplication is divided, with each device computing part of the result.

It needs fast interconnects, since devices exchange data within every layer.

Pipeline parallelism assigns different layers to different devices.

The batch is split into micro-batches so devices are not idle waiting for each other.

Frontier training combines all three, which is where the complexity lives.

Communication becomes the bottleneck rather than arithmetic.

ZeRO and FSDP shard optimizer state and gradients to cut memory further.

Failures are routine at this scale, so checkpointing is not optional.

Want the full technical article? Wikipedia ↗
Deep dive

What is underneath Distributed Training

Three things can be split, and they split differently

Data parallelism runs the same model on different batches.

Tensor parallelism splits one matrix multiply across devices.

Pipeline parallelism puts different layers on different devices.

Which one to use is decided by what does not fit: the batch, a single layer, or the whole model.

M≈16N bytes for trainingM \approx 16 N \text{ bytes for training}

A 70-billion-parameter model needs over a terabyte of optimiser state and gradients, so the question is never whether to distribute but how.

Data parallel, and its communication cost

g=1D∑d=1Dgd\mathbf{g} = \frac{1}{D} \sum_{d=1}^{D} \mathbf{g}_d

Every device holds a full copy, processes its own shard of the batch, and the gradients are averaged before the step.

all-reduce:2ND−1D bytes moved\text{all-reduce} : 2 N \frac{D-1}{D} \text{ bytes moved}

The averaging moves roughly twice the parameter count per step regardless of the number of devices, which is why it overlaps with the backward pass rather than waiting for it.

ZeRO shards the optimiser state first, then the gradients, then the parameters.

Fully sharded data parallel keeps the data-parallel structure and splits the memory, gathering each layer's parameters just before it is needed and releasing them after.

That converts a memory problem into a bandwidth problem, and it is the default for large model training today.

Tensor parallel

Y=XW=X[W1  W2]=[XW1  XW2]Y = XW = X[W_1 \; W_2] = [XW_1 \; XW_2]

A matrix multiply splits along the output dimension with no communication, and along the input dimension with a sum afterwards.

Attention splits naturally, one head per device.

Transformers split cleanly because heads are independent and the feed-forward block is two matrices in sequence.

That costs two all-reduces per layer.

The cost is communication inside every layer, which means tensor parallelism is used within a machine over fast interconnect and almost never across machines.

Pipeline parallel, and the bubble

bubble=P−1M+P−1\text{bubble} = \frac{P - 1}{M + P - 1}
  • PP: the number of pipeline stages.
  • MM: the number of micro-batches.

Splitting by layer means stage two waits for stage one on the first batch, and the idle time at the start and end is the bubble.

Many small micro-batches shrink it, and they also shrink the arithmetic efficiency of each one, which is the trade.

One large run, in order

  1. Tensor parallel inside a node, where the interconnect is fastest.
  2. Pipeline parallel across a small number of nodes, if a stage still does not fit.
  3. Data parallel across everything else, with sharded optimiser state.
  4. Gradient checkpointing to trade recomputation for activation memory.
  5. Overlap every collective with computation, or the network becomes the bottleneck.

Using all three at once is called 3D parallelism.

That combination is what every frontier training run uses, and the ratios between the three are tuned to the specific cluster rather than chosen from a rule.

efficiency=achieved FLOPspeak×devices\text{efficiency} = \frac{\text{achieved FLOPs}}{\text{peak} \times \text{devices}}

Model FLOPs utilisation is the number to watch. A well-tuned large run reaches 40 to 55 percent, and anything below 30 usually means communication is not overlapping.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What becomes the bottleneck when training is spread across very many GPUs?
Advanced AI

23 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close