Gradient checkpointing, what does it trade, and roughly by how much?
Gradient checkpointing trades extra compute for activation memory. Typical cost is roughly 30 percent more wall-clock per step in exchange for roughly 60 to 70 percent less activation memory.
Imagine taking a long road trip and writing down detailed notes about every turn so you can retrace your route home. Eventually your notebook fills up. Activation checkpointing is like deciding to write down only the major waypoints (every fifth turn) instead of every single turn. When you need to find your way back, you can drive the small loops between waypoints again to reconstruct the detailed turns you did not write down. You burn extra fuel doing the small re-drives, but your notebook stays small enough to carry. For long sequences during model training, the savings are dramatic: the difference between running out of GPU memory and finishing the job.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: explain the compute-memory tradeoff, walk through the recomputation mechanism, then cover the typical magnitudes and the interactions with FlashAttention and ZeRO-3.
Real products, models, and research that use this idea.
- Hugging Face Trainer exposes gradient_checkpointing=True as a single config flag that enables per-layer checkpointing on standard transformer architectures.
- Production Llama 4 Maverick fine-tunes at 8K context routinely enable checkpointing to fit activations alongside the 70B base on 4xH100.
- Axolotl and Unsloth both ship YAML configs with gradient_checkpointing on by default for any model above 7B.
- PyTorch FSDP uses torch.utils.checkpoint.checkpoint with use_reentrant=False under the hood for activation checkpointing in distributed training.
- Qwen 3.5 32B QLoRA recipes on consumer 24GB GPUs depend on gradient checkpointing to make the activation footprint fit alongside the 4-bit base and LoRA adapters.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is the compute cost of gradient checkpointing approximately 1.33x rather than 2x?
QHow does gradient checkpointing compose with FlashAttention, and why does the memory saving shrink?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing gradient checkpointing saves optimizer state or weight memory. It only reduces activation memory, the third memory term, by recomputing forward activations during backward.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.