Verba/Rapida

Experiments #175dk

A multi-query vector attention kernel for the drafter's verify (row 175da: at 8k MLX's 2-pass vector kernel...

done

What was tested

A multi-query vector kernel for the 's verify (row 175da: at 8k MLX's 2-pass vector kernel costs 490 us a global layer at 3 queries against 202 at one, 72 against 40 a sliding layer, because each simdgroup walks the K/V itself for its own query and head, `kernels/sdpa_vector.h:234-237`, `:263`): a Lesto Metal kernel that reads each K/V block once a threadgroup and applies it to all 2 to 8 queries and every head of a KV group (MLX's `_gqa_` variant's structure, `sdpa_vector.h:326`, extended to several queries, head dims 256 and 512, the causal test and the band mask). Step 1: the kernel and a microbench against row 175da's 3-row call on the same shapes, outputs within of MLX's; then behind a switch, an identity count against the best (other summation order, so rounding class) and a pair

Model and setup

the drafter verify's attention

Expected gain

up to about +9% at k = 3 (a ceiling: 2.2 ms of a 23.8 ms round, the gap to one row's time)

Where the idea came from

row 175da

Outcome

done 2026-11-20 20:14 (engine-rows): correct (12 checks, one bf16 step) but slower than MLX's 3-row call in every configuration, global 8k 1,054 to 3,206 us against 497, sliding 87 to 365 against 73; confirmations -551 [-558, -536] and -13.6 [-13.8, -12.5] us, line not met; cause from the code: scalar `lane + 32 i` loads (16 a K row at hd 512) against MLX's contiguous per-lane chunks, a third of MLX's simdgroups, staging barriers; row 175dk2 rewrites the body (`2026-11-20-mac-r175dk-mq-attention/README.md` ยง Result)

Lesson

a shared-K/V attention kernel that reads each K/V row once can still be 2 to 6 times slower than MLX's per-pair walk, because the cost on the M4 tracked load instructions per row (scalar `lane + 32 i` loads against MLX's contiguous per-lane chunks) and simdgroups in flight, not bytes read. Match MLX's per-lane layout and key split first, then share.

Adopted

no (below the step 1 line; no served step).

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