Repository navigation
[CPU] Fix accumulation precision in fp quantized matmul - #4879
Merged
zcbenz merged 1 commit intoNov 22, 2026
Merged
Conversation
zcbenz
marked this pull request as ready for review
November 22, 2026 03:46
…r affine; add test
zcbenz
force-pushed
the
fix-cpu-fp-qmm-accum
branch
from
November 22, 2026 03:55
16733d5 to
33b0930
Compare
zcbenz
approved these changes
Nov 22, 2026
1 task
rcfa
pushed a commit
to cubiculum-ai/mlx
that referenced
this pull request
Nov 26, 2026
) Ported onto the fork's nvfp4 global scales (osaurus-ai/mlx PR 31): scale_dec stays the last argument and acc follows transposed_w. The row accumulator acc is used for GatherQMM and QQMatmul too. Of the test changes, only test_fp_qmm_accumulation_precision is taken; its context, test_qmv_affine_bias_sum_precision, is not in the fork. The fork's Highway backend (quantized_highway_backend.cpp, used when MLX_USE_HIGHWAY_KERNELS is set) has its own non-transposed fp_qmm. It now also accumulates each row in float32, in a local buffer, as its affine _qmm does since ml-explore#4803. Before, the Linux build failed test_fp_qmm_accumulation_precision with transpose=False. (cherry picked from commit 07fff01)
inureyes
added a commit
to lablup/mlxcel
that referenced
this pull request
Nov 29, 2026
Advance the reproducible MLX pin from fc344c98 to 5a48f9cc, the head of upstream main on 2026-11-28 (87 commits, past v0.32.5). Review record: docs/mlxcelverse/mlx-pin-2026-11-28.md. - The CPU quantized-matmul overlay (#2248) is retired: upstream now accumulates the fp qmm loops in float (ml-explore/mlx#4879), and cpu_qmm_accum_tests guard the upstream loops. - 24 Metal and CUDA overlays are rebased onto the pin. SDPA threads upstream's window_size through the deterministic and bucketed plan paths. The CUDA grouped_gemm.h overlay includes <cstdint>, and device/unary_ops.cuh (added on main by #3540 at the old pin) carries upstream's new SignBit functor. - The #637 sm_120/121 qmm tile cap is dropped for upstream's #4851 rule (large_tiles ? 128 : 64). A GB10 A/B on llama-3.1-8b-4bit and qwen2.5-7b-4bit showed no prefill gain from the cap at 2048 or 8192 tokens and byte-identical greedy output; the 512-token qwen gain (about 10%) is recorded in the pin doc. TILE_M_CAP_BLACKWELL is 64. - ROCm overlay retargeted: the fork's fusion limits move to mlx/compile/fuse.cpp, the new allocator hooks are inert, GroupedMM and SignBit get NO_GPU stubs, and HIP sources compile as C++20 because the pin's scheduler.h uses std::atomic::notify_all (LOCAL_FIXES 77 to 80, after main's 76). - The MiniCPM5 and Qwen3 DSpark exactness gates require MLXCEL_SDPA_DETERMINISTIC=1 on CUDA, where decode attention otherwise takes cuDNN stream-K and its engine choice depends on what ran earlier in the process. - A clippy needless_range_loop in the router WebUI harness test from #3552 is fixed; main's clippy job had not run on that change. Validation: on M3 Ultra, make verify-test (17374 passed). On GB10 (spark-102), make verify-test-cuda-qmm-determinism (5 passed) and make verify-test-cuda (17741 passed, 3 failed, none from this change: a DeepSeek-OCR CLIP parity failure identical on main, and two port or timing flakes that pass alone), check_nvrtc_headers.py with NVRTC against the new-pin build tree, make verify-rocm-overlay, and both real-checkpoint DSpark gates. CI passes except binary assets, which fails on main for the undeclared tests/fixtures/audio/speech.flac from #3533. No ROCm host was available: the HIP C++20 change is covered by the Windows compile-only job only.
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.
CPU FP kernels (mxfp4, nvfp4, mxfp8) in
quantized_matmulandgather_qmmpreviously performed accumulation in bf16/fp16;
this fix switches to float32 accumulators, consistent with the approach used for
affinein [CPU] Fix accumulation precision in affine quantized matmul #4803;result: bf16, K=4096, mxfp4: CPU 2.6e-2 → 3.0e-3 (GPU 3.1e-3);
added a new test:
test_fp_qmm_accumulation_precision;tests passed on the CPU build; I didn't create a Metal build.
☑️ I understand it is strictly prohibited to use AI to write PR description
AI usage disclosure: AI helped find the error