ML Performance Mental-Math Drills
ML Performance Mental-Math Drills
Section titled “ML Performance Mental-Math Drills”Interviewers for ML performance roles use fumbled arithmetic as a shallowness signal. These drills build the reflexes: each answer in under two minutes, reasoning spoken aloud, no calculator.
▶ Open the interactive drill trainer — randomized problems across all four categories, a 2:00 countdown, and step-by-step reveal.
Specs to memorize (dense BF16, no sparsity)
Section titled “Specs to memorize (dense BF16, no sparsity)”| Chip | TFLOP/s (BF16) | HBM BW (TB/s) | Ridge (FLOP/B) | HBM (GB) |
|---|---|---|---|---|
| NVIDIA H100 SXM | 989 | 3.35 | ~295 | 80 |
| NVIDIA B200 | 2,250 | 7.7 | ~292 | 180 |
| AMD MI300X | 1,307 | 5.3 | ~247 | 192 |
| TPU v5p | 459 | 2.76 | ~166 | 95 |
| TPU v6e (Trillium) | 918 | 1.64 | ~560 | 32 |
| NVIDIA A100 (anchor) | 312 | 2.0 | ~156 | 80 |
Native low-precision by generation: v5e/v5p/Trillium → int8 (AQT/QAT path, fp8 emulated); Ironwood → first native fp8 (4,614 TF) and spec-sheet twin of B200; B200 adds fp4 (NVFP4). Full generation-vs-NVIDIA map: dtype table.
Ridge point = peak FLOP/s ÷ bytes/s. Arithmetic intensity above the ridge → compute-bound; below → memory-bound. FP8 doubles the FLOP number, so the FP8 ridge is ~2×. Quote dense (non-sparsity) numbers — marketing figures are often 2× with sparsity.
The four identities
Section titled “The four identities”GEMM arithmetic intensity. For in bf16:
Square : . Shortcut: AI is bounded by the smallest of — a skinny GEMM (small batch) is memory-bound no matter how big the other dims are.
Decode bytes/token (batch 1).
Batch-1 decode has AI ≈ 1–2 FLOP/byte — hopelessly memory-bound; batching raises effective AI roughly by the batch size. Prefill attention’s AI grows with sequence length → compute-bound.
Roofline attainable throughput.
Tile / SRAM budget (H100: 228 KB smem/SM, 255 regs/thread, 64K regs/SM).
Four more identities (distributed & capacity rounds)
Section titled “Four more identities (distributed & capacity rounds)”Ring all-reduce. Bandwidth-optimal time for chips: for large — the -dependence nearly cancels. Compare against backprop time to see whether comms hide behind compute.
Training FLOPs and MFU. (forward 2, backward 4). MFU = achieved ÷ peak; step time . Run it backwards to get MFU from measured tokens/s.
KV-cache capacity. Concurrent sequences ≈ (HBM − weights) ÷ KV-per-sequence. This bounds batch size, which bounds decode arithmetic intensity, which bounds throughput — the whole serving-economics chain in one division.
Training memory. Adam mixed precision ≈ 16 bytes/param of model state (2 bf16 weight + 2 grad + 12 fp32 optimizer/master), sharded by ZeRO-3/FSDP degree, plus activations (shrinkable via checkpointing — see Activation Checkpointing).
Drill protocol
Section titled “Drill protocol”- 15 minutes daily, cold, on paper. Rotate through the four categories.
- Speak the reasoning aloud exactly as you would in the interview — the units narration (“989 teraflops over 3.35 terabytes per second is about 295 flops per byte”) is part of what’s being scored.
- Under 2:00 per problem or it counts as a miss. The interactive trainer enforces the clock and shows the worked steps.
Useful talking point that falls out of the table: Trillium’s ridge (~560 FLOP/B) is roughly double NVIDIA’s (~280–300), which is why TPU inference leans harder on batching and on keeping working sets in its large on-chip memory.