Experiments #117
A head-dim-512 flash prefill kernel for Gemma 4's 5 full-attention layers on chips without NAX (Lesto today...
queued
What was tested
A head-dim-512 flash Prefill: the model reading the whole prompt before it can write the first token. Read more kernel for Gemma 4's 5 full-attention layers on chips without NAX (Lesto today runs MLX's composed fallback there, materialising the qL x kL scores: `src/transformer.zig:2935`, `:2033`; row 111 found no upstream kernel); first, timing-free, size those layers' The step where each token looks back at the earlier tokens to decide what matters. Read more share of an 8k first The unit of text a model reads and writes: roughly a short word or a piece of a longer one. from a trace, then a kernel modelled on `msv_attn_p256` only if the share is worth it
Model and setup
the best
Expected gain
first token: unknown until sized (guess -2 to -5% of an 8k first token)
Where the idea came from
row 111
Outcome
queued 2026-11-02; closed 2026-11-04 before any work: the sizing was already done by row 106 (`2026-10-31-mac-engine-audit/README.md` ยง The numbered revision of the quality-check procedure; results are only comparable within one version., row 106): the full hd-512 SDPA is 1.11 s of a 10.35 s 8k first token and already runs at about 6.1 TFLOP/s against the 7.0 of the dense matmuls, so a flash kernel can remove only the masked half of each diagonal block, about 0.22 s (2.1% of the first token, about -1.5% of a first-turn reply) and nothing on The writing phase: the model produces the reply one token at a time. Read more; at 8 h, rounding risk and a decode-only Mac adoption rule it cannot become the best