Verba/Rapida

Experiments #150

The fused router on many threadgroups: `mlxserve_router_qmv8_softmax` (8-bit matvec 128 x 2816, top-k...

done

What was tested

The fused router on many threadgroups: `mlxserve_router_qmv8_softmax` (8-bit matvec 128 x 2816, top-k, softmax, renormalisation) runs as one threadgroup of 1,024 threads (`src/transformer.zig:13137`, grid equal to the threadgroup), so each layer's 389 KB streams through one core at 18 GB/s, 644 us a step in split mode (row 149v); split the 128 rows over several threadgroups with each simdgroup keeping its 4 rows and sum order, the top-k in a last threadgroup or a second small dispatch; lossless, proven by identical replies and `MLX_SERVE_ROUTER_KERNEL_CHECK`

Model and setup

the best

Expected gain

about 0.4 to 0.5 ms a step, +4% to +5% at 1k and 8k (`2026-11-12-mac-decode-profile-r147/README.md` ยง Sizing)

Where the idea came from

none

Outcome

done 2026-11-12: exact (150 of 150, 24,000 checked calls) and -1.51% [-1.65, -1.44] decode (`mac/150/1`, loss): on MLX's concurrent encoder the fused router already ran beside the independent dense-MLP matvec; the split's dependent top-k put a barrier between them (`2026-11-12-mac-router-split`)

Lesson

spreading the fused router over 16 threadgroups is exact but 1.5% slower: on MLX's concurrent encoder the one-threadgroup router already ran beside the independent dense-MLP matvec, and the split's extra dependent kernel put a barrier between them. A split-mode kernel time overstates any kernel that overlaps an independent neighbour in normal mode.

Adopted

no (a loss; `row/150` is not )

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