Experiments #170
The global layers' K=V cache stored once (big bet; decode attention sweep 2026-11-19, ranked 1 by both web...
done
What was tested
The global layers' K=V cache stored once (big bet; The writing phase: the model produces the reply one token at a time. Read more The step where each token looks back at the earlier tokens to decide what matters. Read more sweep 2026-11-19, ranked 1 by both web tracks; arXiv 2611.23035): Gemma 4's 5 global layers are K=V (`attention_k_eq_v`, Lesto `own_v = own_k`, `src/transformer.zig:9263`) with partial rotary 0.25, so a cached row can be V (512) plus K's 128 rotated dims, the k norm weight folded into q for the other 384: 640 values a row instead of 1,024, 21 instead of 33.5 MB a layer at 8k. Rounding class (the stock K is A 16-bit number format for model weights; the full-quality baseline here.(n x w)). Step 1 kill test: MLX's own two-pass SDPA kernels ported through `mx.fast.metal_kernel` (MLX instantiates no qk 640 / v 512 pair), timed at the variant's real shape (K the 640-column row, V its 512-column subview) against the same port at the stock shape at 8,192 keys, with a correctness check of the variant's output and a fidelity guard against MLX's own call (does the call follow its bytes, row 149m's open question), plus the rounding count in mlx-lm; step 2 a Lesto kernel, its identity count and the anchored read before any race
Model and setup
the best
Expected gain
about +2% to +3.7% decode (up to 0.38 ms of the 1.01 ms global time at 8k; **estimate** from bytes)
Where the idea came from
rows 149m, 156g, 165
Outcome
done 2026-11-19: UNDECIDED (row 170b's fidelity guard: the wheel's stock call at 512 is the slow arm, 25 GB/s, while the port matches Lesto's Keeping a model loaded on a machine so it can answer requests over the network. kernel); the line once / port 1.116 at 8k, 1.062 at 16k, against a kill above 0.85: MLX's kernel reads the two overlapping views separately, 1,152 values a key against 1,024; the byte cut needs a one-read kernel (`2026-11-19-mac-r170-global-kv-once/README.md` ยง Result, row 170b)