Verba/Rapida

Esperimenti #170

The global layers' K=V cache stored once (big bet; decode attention sweep 2026-11-19, ranked 1 by both web...

done

Il testo degli esperimenti resta in inglese, come l'ha scritto il laboratorio.

Cosa è stato provato

The global layers' K=V cache stored once (big bet; 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 (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

Modello e configurazione

the best

Guadagno atteso

about +2% to +3.7% decode (up to 0.38 ms of the 1.01 ms global time at 8k; **estimate** from bytes)

Da dove viene l'idea

rows 149m, 156g, 165

Esito

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 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)

Vuoi vedere cosa hanno prodotto questi esperimenti? Lesto, il motore di inferenza per Gemma 4 sui Mac con Apple silicon, è su lestoengine.com

Creato da Federico Andrioli, @fedeandri su X Le misure di un laboratorio di ricerca, ricavate direttamente dai suoi file. Dati aggiornati al