Verba/Rapida

Experiments #30

Plain matmul-softmax-matmul for Gemma 4's head-dim-512 attention (overlay...

done

What was tested

Plain matmul-softmax-matmul for Gemma 4's head-dim-512 (overlay `docs/experiments/2026-10-29-mac-d512-attention/overlay/sitecustomize.py`, PATCHED mlx-vlm 0.7.10): MLX's fused kernel takes 1.78 ms for MTP's 7-token verify over 8k keys, the plain ops 0.44 ms (max abs difference 0.00098); paired against `vlm_optiq_mtp` on the 50 sessions

Model and setup

gemma-4-26b-a4b OptiQ-4bit + MTP assistant

Expected gain

+8 to +15% decode (**guess**: 5 layers x 1.34 ms per verify step)

Where the idea came from

rows 27, 28

Outcome

done 2026-10-29: , +4.2% decode (interval +2.3 to +5.0, threshold 5%); SUSPICIOUS: reply +0.5% because the overlay also took chunks; row 30b limits it to queries of 16 or fewer: +5.8% (interval +4.9 to +6.5), replicated +5.7%, reply -1.0 to -1.5%; meaning read owed; row 31 tries the variable on the 1-user mlx-serve, running since 15:35 (`docs/experiments/2026-10-29-mac-d512-attention/`)

Lesson

route a kernel swap only to the query lengths it was measured on: the plain path helped decode queries but slowed prefill chunks.

Adopted

no (no gain)

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