Verba/Rapida

Experiments #175dk2

Row 175dk's kernel body rewritten along its measured mechanism: each lane holds D/32 contiguous elements...

done

What was tested

Row 175dk's kernel body rewritten along its measured mechanism: each lane holds D/32 contiguous elements loaded as vectors (the host declines unaligned rows), a block's keys split across the threadgroup's simdgroups (SGK) with the pairs' online-softmax state combined in threadgroup memory as MLX's `_gqa_` 2-pass kernel does, no staging; masks, decline rules, switch and pass 2 kept. Step 1: the same microbench, checks and 95 us a round line as row 175dk; step 2 as row 175dk's

Model and setup

the verify's

Expected gain

up to about +9% at k = 3 (the same 2.2 ms ceiling)

Where the idea came from

row 175dk

Outcome

done 2026-11-21 (engine-rows): line not met (0 us a round against 95); the contiguous layout fixed the control (sg24p1 604 us against row 175dk's 3,206, 1.21 times MLX's 497), but every multi-pair configuration is slower and the time grows with the pairs a simdgroup handles (3.3 times at 3 pairs); MLX's 3-row call is 2.46 times one row, so the excess is per-query work, not repeated K/V reads (`2026-11-20-mac-r175dk2-mq-attention-v2/README.md` ยง Result, row 175dk2 step 1)

Lesson

once the per-lane load layout matched MLX's (control 3,206 to 604 us), a shared-K/V multi-query kernel was still slower, and its time grew with the pairs each simdgroup handles (3.3 times at 3 pairs). MLX's own 3-row call is near-linear in queries (2.46 times one row). The verify's attention excess is per-query work, not repeated K/V reads, so a kernel that only shares reads cannot recover it. Test which resource a kernel is bound by (vary its work per simdgroup at a fixed read) before designing one to save the other.

Adopted

no (line not met)

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