Splitting examples or splitting a calculation #

Suppose a training step involves 1,024 examples. With eight data-parallel workers, each can process 128 examples using a copy of the same weights. For equal-sized groups, an average of their average gradients gives the gradient for the full batch, apart from numerical rounding and any operations that depend on how examples are grouped. The workers then apply a coordinated update. Each needs enough memory to carry its part of the model and its training state.

Tensor parallelism instead splits one operation. For example, two devices can calculate different groups of output columns in a matrix multiplication. The next operation determines whether each device can continue locally or must receive some of its partner’s results. A fast arithmetic unit can spend a substantial fraction of a step waiting for these transfers. The Megatron-LM study evaluated combinations of tensor, pipeline and data parallelism within a single training system.

Section sources [1]

Keeping a pipeline occupied #

Pipeline parallelism assigns successive groups of layers to different devices. GPipe divides a batch into smaller pieces called microbatches. While the second device processes the first microbatch, the first device can start on the second. Gradient accumulation allows one update after the full batch has passed through the schedule.

Consider four equally fast stages and four microbatches in a forward pass. Filling and draining the pipeline takes seven stage intervals. The processors perform sixteen useful stage intervals out of twenty-eight available. With sixteen microbatches the same forward pipeline uses sixty-four out of seventy-six. These are illustrations with zero communication overhead. Backward passes, uneven layer costs and activation memory change the utilization of a training run.

Section sources [1] [2]

Where the memory goes #

Weights are only part of the memory bill. Gradients and optimizer variables can each occupy substantial space, and intermediate activations must be retained or recomputed. ZeRO partitions training state that ordinary data-parallel workers would duplicate. Its stages successively distribute optimizer state, gradients and parameters. A worker can obtain a parameter when its computation needs it. This trades memory replication for more carefully scheduled communication.

Section sources [3]

Reading a speedup claim #

Compare time to a specified validation result alongside examples or tokens per second. Doubling throughput by doubling the global batch can change how many optimizer updates occur over the same training data. A larger model that fits for the first time answers a different question again. Report the batch, hardware, numerical precision, model size and stopping condition. These details distinguish improved utilization from changes in the learning problem itself. Peak arithmetic throughput alone cannot tell a reader how long a distributed experiment took. Amdahl’s law gives a ceiling for the speedup of a fixed job when some work stays sequential. A team using more processors to train a larger model is answering a different question.

Section sources [1] [2] [3] [4]

From one iteration to weeks of useful work #

Narayanan and colleagues ran iterations of a trillion-parameter model on 3,072 A100 GPUs and measured 502 quadrillion floating-point operations per second across the cluster, approximately 52 percent of the devices’ theoretical peak. The measurement included communication and optimization during the iteration. Extrapolating it to a full training schedule requires a second measurement of how much wall-clock time the job spends making progress.

The Llama 3 team recorded 466 interruptions during a 54-day pretraining window. It classified 47 as planned and 419 as unexpected, yet reported that more than 90 percent of elapsed time went to useful training. A synchronous job can stall when one worker fails. Saving state often reduces the amount of training that has to be repeated after a restart, but writing and loading that state consumes time. Counts of failed jobs, throughput within a healthy step and useful training time capture different parts of the same run.

Section sources [1] [5]

Reconstructing a layer’s inputs #

Reversible computing also inspired a way to save activation memory on conventional hardware. In a reversible residual network, successive blocks let the backward pass reconstruct their inputs. Gomez and colleagues tested the design on image classification. Storing fewer activations frees space that might otherwise limit batch size on a worker, while reconstruction adds arithmetic. Ordinary layers between reversible blocks can still require stored inputs. This strategy tackles a different memory cost from distributing a model’s optimizer state.

Section sources [3] [6]

Sources

  1. Deepak Narayanan and colleagues · Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM (2021) arxiv.org
  2. Yanping Huang and colleagues · GPipe (2018 preprint) arxiv.org
  3. Samyam Rajbhandari and colleagues · ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (2019 preprint) arxiv.org
  4. John L. Gustafson · Reevaluating Amdahl’s Law (1988) users.cs.utah.edu
  5. Aaron Grattafiori and colleagues · The Llama 3 Herd of Models (2024) arxiv.org
  6. Aidan N. Gomez and colleagues · The Reversible Residual Network: Backpropagation Without Storing Activations (2017) papers.neurips.cc