Repository navigation
Conversation
Member
Contributor
Author
Almost, I think it's better to be implemented in qqmm 4722 converts the affine weights to symmetric int8 with one scale per row, so they are rounded a second time. Here the MMA uses the original codes, and the per-group scales and biases are applied in the kernel. |
XXXXRT666
force-pushed
the
metal-nax-affine-int-mma
branch
from
November 3, 2026 00:54
239bfa7 to
21f5e03
Compare
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.
Based on #4796 for benchmarking
mx.qqmmnow supportsmode="affine", with a newbiasesargument for quantized affine weights.xis quantized to int8 to use NAX.On chips with NAX, a new kernel runs int8 x int8 MMAs. It is used for 4, 6 and 8 bits weights when M >= 32, the group size is 64 or more, and there are at least 1.5 output tiles per GPU core. Otherwise
qqmmdequantizes the 8-bitxand runs thequantized_matmul. CPU and CUDA raise an error foraffine.Accuracy
M = 1024, K = N = 4096,
xandwfrom normal distribution, bf16. RMS error relative to the RMS ofx @ win float32:Performance
Measured on M5 Pro (16 cores), M5 Max (40 cores) and M6 (12 cores), bf16, group size 64.
Shapes (K x N): 4096x4096, 4096x14336, 14336x4096, 8192x2048.
Speedup of
qqmmoverquantized_matmul, geomean over the 4 shapes (>1 is faster):M5 Pro
M5 Max
M6
At M = 16
qqmmuses thequantized_matmulkernels.Per shape at M = 1024, microseconds (quantized_matmul / qqmm affine / qqmm nvfp4 or mxfp8):
4-bit, with qqmm nvfp4:
8-bit, with qqmm mxfp8: