Verba/Rapida

Experiments #109

An M4 port of mlx-serve's M5-only MoE prefill design (`gather_qmm_nax.zig:498`, `:511`): no gathered copy...

stage

What was tested

An M4 port of mlx-serve's M5-only design (`gather_qmm_nax.zig:498`, `:511`): no gathered copy of rows, gate and up in one pass with the activation fused, 32 or 64-row tiles instead of MLX's 16 (`.cpp:1733-1735`); first a harness microbench of MLX's expert kernel at 32 and 64 rows

Model and setup

the best

Expected gain

at most -1.45 s per 8k first token (-14%; MoE at 4.8 against the dense MLP's 7.0 TFLOP/s, row 106), expected about -0.7 s

Where the idea came from

rows 106, 107

Outcome

stage 1 done 2026-10-31 (`2026-10-31-mac-engine-audit/README.md` § Microbench, row 109 stage 1, `kb109/`): fused gate+up+GeGLU through the row map at 32-row tiles plus MLX's kernel at bm 32 for down saves 2.8 to 3.4 ms per layer per chunk, bit-identical, about -0.34 to -0.41 s per 8k first token; 64-row tiles slower; stage 2 screen done 2026-10-31 (§ Screen, row 109, `apply109.py`, PATCHED): in the engine 40 of 40 identical and 8 of 8 in-engine bit checks, 8k first token -3.0% and -4.1% (unpaired; the 1k +7.6% is a drifting window, slid too); pair row 109a done 2026-10-31 (§ Result, row 109a, `mac/109a/1`): reply -0.6% [-0.8, -0.4] per turn, all of it on turn 1 ( first token -3.8%; later turns are prefix-cache warm, under the 32-row bar), decode level, under the 1.0% threshold, not adopted; kept as a lossless stack candidate with row 110

Lesson

the stage-1 port works in the engine unchanged: gate+up+GeGLU through the row map and down at 32-row tiles are bit-identical to MLX's 16-row path (8 of 8 in-engine checks, 40 of 40 replies) even though MLX's custom-kernel compiler builds them, and cut the 8k first token 3% to 4% as the microbench predicted. An unpaired screen cannot price a 3% prefill effect (one window drifted +12% on the 1k first token with decode sliding too), and greedy replies depend on which earlier request wrote the shared system 's cached KV, so reply identity is compared only between servers with the same request history.

Adopted

no (screen).

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