Verba/Rapida

Esperimenti #175dk2

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

done

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

Cosa è stato provato

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

Modello e configurazione

the verify's

Guadagno atteso

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

Da dove viene l'idea

row 175dk

Esito

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)

Lezione

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.

Adottato

no (line not met)

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