Repository navigation
Conversation
ahuzmeza
marked this pull request as ready for review
October 29, 2026 00:09
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Affine quantized_matmul at 3–16 rows on GPUs without NAX.
On main use_qmv_mma returns false for affine (quantized.cpp L645-647), and #4781 opens it only behind is_nax_available(), so those chips stay on qmv / qmv_wide / qmm. This is the non-NAX side of the picture.
Port of #4712's fp_qmv_mma to affine. Differences:
N·K >= 2^21 (fp: 2^22). Not on Ultra or NAX
4 and 8 bits at group sizes 32, 64 and 128.
Measured on the M2 Pro (gen 14) and the M4 (gen 16),
Unmeasured: M1 (gen 13), M3 (gen 15) and A-series phones, enabled by generation.
Non-affine and NAX dispatches are unchanged.
Overlaps #4781 (@XXXXRT666, the NAX side) in a few lines of quantized.cpp. Decided to bring them here to not chain PRs.
M2 Pro (16-core), main VS. this branch, speedup [95% interval]
[1.14, 1.15]
[1.43, 1.46]
[1.74, 1.79]
[2.88, 3.00]
[3.05, 3.09]
[3.14, 3.15]
[1.96, 1.97]
[1.91, 1.96]
[1.88, 1.95]
[1.15, 1.18]
[1.50, 1.51]
[1.84, 1.86]
[3.27, 3.28]
[3.34, 3.34]
[3.41, 3.43]
[2.07, 2.08]
[2.05, 2.06]
[2.02, 2.02]
At 6–8 rows main (gen 13/14) moves the MLP projections to qmm_splitk; against main with that limit raised the gain is 2.09–2.84×.
M4 (10-core), same
[1.02, 1.03]
[1.03, 1.03]
[1.07, 1.11]
[1.23, 1.27]
[1.42, 1.47]
[1.56, 1.60]
[1.87, 1.89]
[1.82, 1.83]
[1.10, 1.13]
[1.33, 1.36]
[1.55, 1.60]
[1.81, 1.86]
[2.16, 2.22]
[1.52, 1.55]
[1.82, 1.85]
[1.92, 1.93]
End to end on the M2 Pro, mlx-community/gemma-4-e4b-it-4bit with
mlx_lm.benchmark -p 512 -g 128 -b 8 -n 2=> batch 8 decode goes from 70.0 to 202.1 tok/s (2.89×), batch 1 remains unchanged (1.00×)Method
Chained decoder forward pass on Qwen3-4B shapes, bf16, group size 64. 10 rounds per build in separate processes, alternating. (ratio of medians with a 95% bootstrap interval). mxfp8 is the control. Details are in the script below.
Benchmark script (to reproduce)
Install main and this branch in two venvs, then: