Verba/Rapida

Esperimenti #149g

The global layers' attention at long context: `sdpa_vector_2pass` at head dim 512, 2 KV heads, no mask, 5...

done

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

Cosa è stato provato

The global layers' at long context: `sdpa_vector_2pass` at head dim 512, 2 KV heads, no mask, 5 layers, takes 1,018 us a step at 8k (235 at 1k), reading 32 MB a layer at about 157 GB/s (row 149v); read MLX's 2-pass kernel (blocks per pass, reduction) at its `file:line`, then a lossless change (more blocks for few KV heads, or a fused single pass at head dim 512) proven by identical replies

Modello e configurazione

the best

Guadagno atteso

0.35 to 0.43 ms a step at 8k by the bandwidth arithmetic, about +3.5% at the sessions' lengths

Da dove viene l'idea

row 149v

Esito

done 2026-11-12 (stage 1): no `MLX_SDPA_BLOCKS` arm beats the default at 8k (32: +0.88% at 1k, -1.91% at 8k; 128 and 256 slower at both); the global layers are not short of blocks; rows 149h (length-dependent count) and 149k (the kernel read) (`2026-11-12-mac-decode-profile-r147`)

Lezione

MLX's default block count for the global layers' 2-pass attention (64 on the M4 Pro) is already the best at 8k (32 loses 1.9%, 128 loses 1%), and only short contexts gain from fewer blocks (+0.9% at 1k), so the global layers' shortfall at long context is not parallelism.

Adottato

no (a screen; no arm beats the default at the sessions' lengths)

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