The interview problem
A deep model runs out of accelerator memory even though its parameters fit. Explain activation checkpointing and estimate the memory/compute tradeoff for a simple chain.
Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.
1. Scope and assumptions
This is recomputing forward activations during backward, distinct from saving training checkpoints to durable storage or accumulating gradients across batches. Assume deterministic pure blocks for the initial calculation.
2. Worked approach
Partition the forward chain into segments and retain segment boundaries rather than all intermediate activations. During backward, recompute the needed segment from its retained input and then calculate gradients. Use the framework's supported mechanism and preserve random-state behavior when stochastic layers are involved.
Inventory parameters, optimizer state, activations and temporary workspaces separately. Checkpointing mainly targets saved activations; it does not automatically reduce optimizer memory. Validate gradients and stateful side effects because running a block twice must not silently update external counters or statistics twice.
3. Calculate the example
For 100 equal-sized layers each needing an illustrative 10 MB saved activation, retaining all layer activations costs about 1,000 MB. With ten-layer segments, a simplified peak of ten boundary activations plus ten recomputed internal activations is about 200 MB. Exact overlap, endpoints and framework workspaces change this estimate. If forward costs F and backward costs 2F, one extra full forward increases total compute from 3F to 4F, about 33.33%, under this simplified schedule.
4. Failure cases and trade-offs
Different dropout randomness during recomputation changes the function whose gradient is computed. Stateful normalization or side effects may run twice. A segmentation plan can move the peak into a large temporary attention workspace rather than reduce it enough.
Smaller segments retain more boundaries but reduce recomputation span. Larger segments save boundary memory at potentially higher temporary memory or work. Offloading activations trades device memory for transfer cost; lower batch size changes optimization and throughput differently.
5. Validate the result
Compare gradients and loss trajectories against a non-checkpointed small run with controlled randomness. Profile actual peak memory and wall time, not only the activation estimate. Test stateful layers and mixed precision explicitly.
6. Interview follow-ups and self-review
Why might the wall-time penalty differ from the FLOP ratio? What memory remains unchanged?
Reward clear checkpoint meaning, qualified memory arithmetic, state correctness and measured end-to-end tradeoffs.
Sources and related practice
Technical reference: docs.pytorch.org — Official activation-checkpointing behavior; simplified chain calculation is original.
Page created June 16, 2025; last updated July 27, 2026. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.
Continue with Compare large batches and gradient accumulation; Design distributed training checkpoint storage.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.