Experiments #49
Achieved bandwidth of each matmul kernel of a Gemma 4 decode step at one token (row 48: the step is...
done
What was tested
Achieved bandwidth of each matmul kernel of a Gemma 4 The writing phase: the model produces the reply one token at a time. Read more step at one The unit of text a model reads and writes: roughly a short word or a piece of a longer one. (row 48: the step is GPU-bound): `gather_qmm` for the experts (128 x 704 x 2816, top 8) and `quantized_matmul` for the dense MLP, The step where each token looks back at the earlier tokens to decide what matters. Read more projections and LM head, 4- and 8-bit affine, over 30 layers' distinct weights in MLX 0.32.4 (`kernel_bw49.py`), against a plain 2 GiB read; the kernels far below 259 GB/s name the patch target
Model and setup
gemma-4-26b-a4b shapes
Expected gain
names the kernel to patch (**measured**, diagnostic)
Where the idea came from
row 48
Outcome
done 2026-10-30: 2k-row 4-bit matmuls reach 62 to 66% of read bandwidth, fused shapes 90 to 95%; mlx-serve already joins q/k/v and dense gate/up at load (49 groups in the best's log); only the experts' gate/up join is left (about 1%)
Lesson
on the M4 Pro a 4-bit matmul of about 2k x 2.8k reaches only 62% to 66% of read bandwidth at one token, a fused 8k-row one 95%; mlx-serve already joins Gemma 4's q/k/v and dense gate/up at load (49 groups), so the remaining gap is the 4-bit single-row kernels themselves and the small ops, not missing fusions.
Adopted
no (a diagnostic)