Experiments #27
Engine code audit of decode attention on mlx-vlm 0.7.10 / MLX 0.32.4 (row 13c: attention about 131 GB/s...
obsolete
What was tested
Engine code audit of The writing phase: the model produces the reply one token at a time. Read more The step where each token looks back at the earlier tokens to decide what matters. Read more on mlx-vlm 0.7.10 / MLX 0.32.4 (row 13c: attention about 131 GB/s, the least efficient part; `docs/experiments/2026-10-28-mac-decode-profile/README.md` § Code audit): timing-free first, settle the two suspects on the rented Mac: (a) a full The memory where the model keeps what it has already read, so it does not recompute it for every new token. Read more copy per layer per step under pipelined decode (count allocations or time a step with `async_eval` against synchronous eval in the profiler), (b) the head_dim 512 path (time one full-attention layer's SDPA at 512, 1,024 and 8k keys); then patch the confirmed one as an overlay (in-place KV write, or a one-read GQA path for D = 512) and pair it against unpatched mlx-vlm
Model and setup
gemma-4-26b-a4b OptiQ-4bit
Expected gain
2 to 4 ms per step if suspect (a) is real (**guess**), toward 100 How many tokens the model writes each second once it has started.
Where the idea came from
row 13c
Outcome
obsolete 2026-11-02: an mlx-vlm attention audit, covered by rows 28, 89s, 92, 96 and 83