Explain bf16's advantage over fp16 and what gradient checkpointing trades
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain (a) why bf16 is preferred over fp16 for LLM fine-tuning, and (b) what gradient checkpointing trades: when it makes sense and when it doesn't.
bf16 keeps fp32's 8-bit exponent, so gradients never overflow and loss scaling disappears. Gradient checkpointing trades about 30% compute for about 70% activation memory.
Imagine a ruler with a fixed number of marks. You can either cover a huge span of sizes with marks far apart, or a tiny span with marks close together. One kind of number tries to measure finely, so it cannot reach the very smallest sizes, and those just round down to nothing. The other kind spreads its marks wide, so it reaches everything and nothing gets lost. Saving memory is a separate trick. Picture doing a long calculation on scratch paper. Instead of keeping every line you ever wrote, you keep only a few checkpoints and rework the missing lines when you need them. That clears your desk a lot, but you do some sums twice, so it takes a little longer.
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: bit allocation of fp16 vs bf16 + why range removes loss scaling + the mantissa cost + gradient checkpointing recompute mechanism + the memory and compute trade + memory-bound vs compute-bound decision.
| Property | fp16 | bf16 |
|---|---|---|
| Exponent / mantissa bits | 5 / 10 | 8 / 7 |
| Dynamic range | Narrow (~10^-5 to 10^4) | fp32-equivalent (~10^-38 to 10^38) |
| Precision | Higher (10 mantissa bits) | Lower (7 mantissa bits) |
| Loss scaling | Required (dynamic) | Not needed |
| Training stability on LLMs | NaN-prone without care | Stable by default |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying bf16 is just more accurate than fp16. It is actually less precise (7 mantissa bits) but has far wider range, and that range is what removes loss scaling.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.