Trade Compute for Memory With Activation Checkpointing in Transformer Training
Last updated: November 29, 2026
Quick Overview
A model does not fit in accelerator memory during training because of stored activations; explain activation (gradient) checkpointing, estimate its memory savings and compute overhead, and compare it with other memory-saving options.
0
0
0 solved
A model does not fit in accelerator memory during training because of stored activations; explain activation (gradient) checkpointing, estimate its memory savings and compute overhead, and compare it with other memory-saving options.
Google infrastructure and ML engineers working with JAX on TPUs routinely choose remat policies, so this question checks whether a candidate understands where training memory goes and how to buy it back. The interviewer wants quantitative reasoning about recomputation and a sensible comparison against sharding and smaller micro-batches.
What the Interviewer Expects
- Breaks training memory into weights, gradients, optimizer state, and activations
- Explains why activations scale with batch, sequence length, width, and depth
- Describes saving only block inputs and recomputing the rest in the backward pass
- Estimates about one extra forward pass, roughly 33% more compute for full recomputation
- Mentions selective checkpointing of cheap but memory-heavy ops such as attention scores
- Compares with sharding optimizer state, micro-batching, and offloading
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- What is the square-root checkpointing scheme and when is it optimal?
- Why is the attention score matrix a good candidate to recompute rather than store?
- How does checkpointing interact with pipeline parallelism?
- How would you choose a remat policy in JAX for a given model?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Setup: training a Transformer with layers, micro-batch , sequence , width . Weights, gradients, and Adam state are already sharded across devices; what overflows is activation memory save...
Approach
Backpropagation needs intermediate values from the forward pass. Without checkpointing, each layer stores many tensors (QKV projections, attention probabilities, MLP hidden states, normalization input...