ParallelismOptimization track

Activation checkpointing

Read it in Chapter 4 · checkpoint +50 XP →

Throw away activations during forward and recompute them in backward: trade ~33% more compute for far less memory.

Backpropagation needs the activations from the forward pass. For a transformer layer with FlashAttention that's roughly 34 · s · b · h bytes (sequence × micro-batch × hidden), and it adds up fast. A 7B model at micro-batch 4 needs over 70 GB of activations.

Checkpointing (also called recomputation) keeps only each layer's input, then re-runs the layer's forward during backward. Cost: an extra forward pass, ~33% more compute (8N instead of 6N FLOPs per token). Benefit: activation memory drops to about 2 · s · b · h bytes per layer.

Use it when activations are what's stopping you from fitting the model or a larger micro-batch. Turn it off when memory is fine. It's pure overhead then. Selective checkpointing (only the attention internals) gets most of the savings for a fraction of the cost.

Note that MFU deliberately doesn't count recomputed FLOPs, so checkpointing lowers MFU even though the GPU is just as busy.

LIVE Training memory calculator
weights 13.4 GBgradients 13.4 GBoptimizer 5.0 GBactivations 36.5 GBframework 3.0 GB
80 GB HBM
Per GPU
71.3 GB
Verdict
fits
Data parallel
dp = 16
Params / GPU
6.70 B

Per-GPU memory for mixed-precision Adam, sequence length 4096, flash attention. Activations use the Korthikanti et al. estimate.

Use it in a mission

Related

Sources & further reading

Written for LazyLab in our own words; sources are cited for depth and verification.