Lesson deck
Model and kernel optimization flashcards
Reviewing needs JavaScript. You can read every card in the list below.
Loading your cards...
Back to the lesson13 cards in this deck
Read all 13 cards as a list
- Front
- What does FlashAttention change, and what stays the same?
- Back
- It tiles attention with an online softmax so the n × n score matrix never goes to HBM: fewer memory accesses. The result is exact attention.
- Front
- Why does FlashAttention help prefill more than decode?
- Back
- Prefill has an n × n score matrix per head; decode has one query row, so its traffic is dominated by reading weights and the KV-cache.
- Front
- What does quantization store?
- Back
- x ≈ scale × q, with the scale per tensor, channel or group. Group size 128 with a 16-bit scale averages 4.125 bits per 4-bit weight.
- Front
- Why do activation outliers hurt per-tensor 8-bit?
- Back
- The largest value sets the scale, so small values round to zero or lose precision. Weights are better behaved than activations.
- Front
- LLM.int8() in one line?
- Back
- W8A8 with outlier feature dimensions multiplied in 16-bit and the other 99.9 percent of values in 8-bit.
- Front
- GPTQ and AWQ in one line each?
- Back
- GPTQ: layer-wise weight-only quantization using approximate second-order information. AWQ: weight-only, protects about 1 percent salient channels chosen from activation statistics by scaling them.
- Front
- SmoothQuant and FP8 in one line each?
- Back
- SmoothQuant: moves quantization difficulty from activations to weights offline for W8A8. FP8: 8-bit floats (E4M3, E5M2) with wider range; needs supporting hardware.
- Front
- Which quantization for memory-bound decode?
- Back
- Weight-only low-bit (W4A16, W8A16, FP8 weights): fewer bytes per step, and idle arithmetic hides unpacking. A 4-bit step floor falls toward a quarter of BF16, less in practice.
- Front
- Which quantization for compute-bound work?
- Back
- W8A8 or FP8, because 8-bit matrix hardware runs faster. Weight-only gains little past the ridge and adds unpacking work.
- Front
- What is the hardware catch for FP8 W8A8?
- Back
- Support depends on the GPU generation. vLLM's table (2026-10-21) lists it for Ada and Hopper, not Ampere. Check the table for the version you run.
- Front
- How do you validate a quantized model?
- Back
- Perplexity first (coarse), then task evals against the 16-bit baseline with slices, production-like calibration data, a canary and a rollback. Perplexity alone misses task regressions.
- Front
- What do CUDA graphs and fusion remove?
- Back
- Graphs: per-kernel CPU launch overhead, by replaying a recorded sequence with one launch (padded to captured batch sizes). Fusion: round trips to memory between adjacent operations.
- Front
- Why can temperature 0 vary between runs?
- Back
- Floating-point addition is not associative and kernels change reduction order with batch size. Batch-invariant kernels fix it at a speed cost (one write-up: 26 s became 42 to 55 s).