Experiments #90f
8-bit KV read packed in SDPA's single pass: an `sdpa_vector_2pass` decode variant that takes K and V as...
done
What was tested
8-bit KV read packed in SDPA's single pass: an `sdpa_vector_2pass` The writing phase: the model produces the reply one token at a time. Read more variant that takes K and V as affine 8-bit triples and dequantizes in registers, wired into `gemma4MoeAttnWith` for head dims 256 and 512 with the dense view removed (row 90e: the view is 2.2 to 3.4 ms a step); row 90b's two-`quantized_matmul` read recovered nothing, so the single pass is the point; first step a unit test against the dense view's output on the M4, then the step profile; lossy (row 90c's read of the 8-bit cache passed)
Model and setup
the best
Expected gain
the view's 2.2 to 3.4 ms back, plus half the KV bytes in The step where each token looks back at the earlier tokens to decide what matters. Read more: about 0.4 to 0.8 ms a step under the dense best at 8k (row 149v sizing), and 2.5 GB less peak memory
Where the idea came from
row 90e
Outcome
done 2026-11-13: loss, the in-register 8-bit kernel is bit-identical to the dense 8-bit view in rounded mode and 18% under A 16-bit number format for model weights; the full-quality baseline here. on the sliding layers (folded), but 46% over bf16 on the head-dim-512 global layers at 8k, so with the 0.6 ms write the 8-bit cache stays 0.4 to 0.9 ms a step slower; no pair (`2026-11-07-mac-reopened-rows/README.md`)
Lesson
an 8-bit KV kernel that dequantizes in registers beats bf16 only where the head dimension is small (256: -18%); at head dim 512 its per-element dequantization makes it 46% slower than bf16 for half the bytes, and the 8-bit write's 0.6 ms then sinks the cache, so the global layers' kernel decides whether an 8-bit cache can pay on Gemma 4.
Adopted
no (the 8-bit cache stays slower than the bf16 best; no pair, no read)