Do the GPU memory math: why can't you full-fine-tune a 7B model on a single 24 GB GPU with Adam?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Count the bytes per parameter for standard mixed-precision training with Adam:
| Component | Precision | Bytes/param |
|---|---|---|
| Model weights | bf16 | 2 |
| Gradients | bf16 | 2 |
| Master weights (optimizer copy) | fp32 | 4 |
| Adam first moment (m) | fp32 | 4 |
| Adam second moment (v) | fp32 | 4 |
| Total (static) | 16 |
Full worked answer with diagram
Count the bytes per parameter for standard mixed-precision training with Adam:
| Component | Precision | Bytes/param |
|---|---|---|
| Model weights | bf16 | 2 |
| Gradients | bf16 | 2 |
| Master weights (optimizer copy) | fp32 | 4 |
| Adam first moment (m) | fp32 | 4 |
| Adam second moment (v) | fp32 | 4 |
| Total (static) | 16 |
Adam is the culprit: it keeps three fp32 tensors per parameter (master weights + two moment estimates) = 12 bytes/param - 6× the size of the bf16 model itself. For 7B params: 7e9 × 16 B ≈ 112 GB of static state - nearly 5× a 24 GB card before you've processed a single token.
On top of that come activations, which scale with batch_size × sequence_length × hidden_dim × layers - easily tens of GB at length 4096 without mitigation - plus CUDA context and fragmentation overhead.
The levers, mapped to which term they attack:
- Gradient checkpointing → activations: store only layer-boundary activations, recompute the rest in backward; ~30% compute overhead for a several-fold activation reduction.
- Gradient accumulation → activations: reach an effective batch of 64 with micro-batches of 1-4.
- 8-bit optimizers (e.g. bitsandbytes) → optimizer states: quantize m/v, cutting 8 bytes/param to ~2.
- ZeRO/FSDP → all static state: shard optimizer states, gradients, and parameters across GPUs; per-GPU static cost divides by world size.
- LoRA/QLoRA → grads + optimizer states: only ~0.1-1% of params are trainable, so optimizer state collapses to ~nothing; QLoRA additionally shrinks weights to ~0.5 bytes/param (NF4). That's how 7B training fits in <16 GB.
This accounting question is a favourite because it instantly reveals whether a candidate has actually planned a training run or only read about them.
Worth sketching. stacking the bytes shows the optimizer, not the model, is what will not fit.
flowchart LR
A["One parameter,<br/>7B of them"] --> B["bf16 weights: 2 B"]
A --> C["bf16 grads: 2 B"]
A --> D["fp32 master copy: 4 B"]
A --> E["Adam m: 4 B"]
A --> F["Adam v: 4 B"]
B --> G["16 bytes/param<br/>= ~112 GB static"]
C --> G
D --> G
E --> G
F --> G
G --> H["Activations on top,<br/>before a single token moves"]
What a good answer covers
- Adam is the culprit: it keeps three fp32 tensors per parameter (master weights + two moment estimates) =…
- For 7B params: 7e9 × 16 B ≈ 112 GB of static state - nearly 5× a 24 GB card before you've processed a…
- On top of that come activations, which scale with batch_size × sequence_length × hidden_dim × layers -…
- Gradient checkpointing → activations
- Gradient accumulation → activations: reach an effective batch of 64 with micro-batches of 1-4
Key terms: Total (static) · 16 · 112 GB · activations · Gradient checkpointing · Gradient accumulation · 8-bit optimizers · ZeRO/FSDP · LoRA/QLoRA
In the glossary: Adam · Gradient checkpointing · FSDP / ZeRO · LoRA · QLoRA · NF4
Interviewer follow-ups to expect
Where does 8-bit Adam save memory and what's the risk?
Redo the math for LoRA at r=16 - what's now the dominant memory term?
Why keep fp32 master weights at all in bf16 training?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep