Pick a concrete input and say what the equation should give before you read the math.
Foundation reference
Activation Checkpointing & Memory Efficiency
Activation checkpointing stores selected intermediate activations and recomputes the others during backpropagation. Recomputing activations is a standard way to fit the training of large models into GPU memory (Korthikanti et al., 2023); PyTorch (torch.utils.checkpoint) and JAX (jax.checkpoint) both provide it.
Study guide
Where to start
Why does backpropagation need the forward-pass activations at all, and which parts of a transformer layer produce the largest activations?
How to study this pagePredict · Check · Generalize · Continue
Work through the math, then read the cited papers for the original argument.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Activation checkpointing stores selected intermediate activations and recomputes the others during backpropagation. Recomputing activations is a standard way to fit the training of large models into GPU memory (Korthikanti et al., 2023); PyTorch (torch.utils.checkpoint) and JAX (jax.checkpoint) both provide it.
- Chen et al. (2016) showed that an n-layer network can be trained with O(√n) activation memory for the cost of one extra forward pass per mini-batch.
- Recomputing everything is wasteful: Korthikanti et al. (2023) combined selective recomputation with sequence parallelism to cut activation memory by a factor of 5 while removing over 90% of the time overhead of full recomputation.
Questions to Think About
- Why do √L segments of √L layers minimize peak memory, and how does the best split change when layers have very different activation sizes?
- Why does recomputation cost about one extra forward pass, roughly a third more compute, rather than doubling the cost of training?
Core Math
Why activations take memory. Backpropagation needs the activations from the forward pass to compute gradients, so a standard implementation keeps the output of every layer until the backward pass reaches it. For layers this costs memory proportional to , and each layer's activations also grow with batch size and sequence length.
Checkpointing stores only some activations and recomputes the rest (Chen et al., 2016):
- Forward: split the layers into segments of layers and keep only the input of each segment.
- Backward: before back-propagating through a segment, rerun its forward pass from the stored input.
Counting in units of one layer's activations, peak memory is about stored segment inputs plus the activations of the segment being processed:
The price is one extra forward pass. A backward pass costs about twice a forward pass, so training compute rises from about three forward passes' worth to four, roughly a third more.
Applying the idea recursively reduces memory to at the cost of forward computation (Chen et al., 2016), and Griewank & Walther (2000) give schedules that are optimal for a given number of checkpoints.
Selective recomputation recomputes only the parts of a transformer layer that need much memory but little arithmetic, such as the attention softmax and its dropout, and stores the rest (Korthikanti et al., 2023).