Attention Kernels practice test
Online softmax and its proof, FlashAttention 1 to 3 and what each generation changed, split-KV decoding, paged attention kernels, MLA absorption, sliding windows, and why IO, not FLOPs, is the cost model. The pool for this topic holds 10 easy, 12 medium and 8 hard items. Each answer comes with its reasoning and a link to the question or concept page it was drawn from.
Sample items with answers
FP32 tops out near 3.4e38, which is e^88.7, so exp(100) is infinity and the row becomes NaN after division. Softmax is invariant to subtracting any constant from every logit, because the factor e^-c cancels between numerator and denominator. Subtracting the max puts every exponent at or below 0, so terms land in (0, 1]. The normalizing division is still needed, and the result is exact with or without the shift when no overflow happens. FP16 is worse: it overflows past e^11.1.
Standard attention writes S = QK^T to HBM, reads it back for softmax, writes P, and reads P again for PV, so HBM traffic grows with T x S. FlashAttention tiles Q, K and V into shared memory and uses the online softmax recurrence so the score tiles never leave the SM. FLOPs are the same (slightly more, from rescaling) and the output is exact up to floating-point order. Low-rank and windowed schemes change the math; FlashAttention changes only where intermediate values live.
After the test
Picking an option is easier than deriving the answer at a whiteboard. These pages make you derive it: