Verba/Rapida

Experiments #89

A faster single-token SDPA for Gemma 4's head dims 256 and 512 on the best: probe 88p measured SDPA alone...

screen

What was tested

A faster single-token SDPA for Gemma 4's head dims 256 and 512 on the best: 88p measured SDPA alone at 1.79 ms per step at 1k (about 60 us per layer, nearly fixed: 2.05 ms at 8k) while its KV bytes are a small share; read MLX's SDPA kernel (`sdpa_vector` and its 2-pass variant, the D=512 path) for the fixed cost, then a lossless or rounding-checked kernel (one dispatch for all heads, split-K tuned to small contexts)

Model and setup

the best

Expected gain

+8 to +15% decode (inferred: most of 1.8 ms)

Where the idea came from

row 88

Outcome

screen done 2026-10-31 (89s): the one-dispatch GQA kernel loses to MLX's 2-pass above 1,024 keys and changes 10 of 20 1k replies below; -0.8% at 1k; not adopted; leads rows 91 and 92

Want to see what these experiments produced? Lesto, the Gemma 4 inference engine for Apple silicon Macs, is on lestoengine.com

Made by Federico Andrioli, @fedeandri on X A research lab's own measurements, generated from its files. Data built