Repository navigation
fix(rocm/quant): commit mxfp4 regression tests and log the native route - #2057
Merged
Merged
Conversation
An audit on gfx1151 at dfc5986 found none of #1808's failures left: mxfp4 quantized_matmul at 256x512 with M = 1 finishes and matches a dequantized f32 reference, and GPU quantize at 4096x4096 launches and matches the CPU quantizer. The overlay fixes from #1818 (LOCAL_FIXES items 8, 10, 11) hold, but nothing committed checked them, and a ROCm load of an mxfp4 checkpoint did not say whether it ran natively or was converted. tests/rocm_mxfp4_quant.rs checks GPU quantize (bitwise against the CPU), quantized_matmul (f32, f16, bf16; M = 1, 8, 64; up to gpt-oss's 2880x2880) and gather_qmm (sorted and unsorted, top 4 at K = 2880) against CPU references, and pins the capability table's mxfp4 entry to Native. Each numeric test fails with its overlay fix reverted. Quantized layer loaders now call validate_quantization_mode_for_running_backend, which prints one line per block-float mode per process when the mode runs natively on a backend that also converts or refuses modes (ROCm). Metal, CUDA and CPU print nothing new. Refs #1808
This was referenced Sep 30, 2026
Closed
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.
Closes #1808
Audit result
The issue's title is stale: nothing it describes still fails on current main (dfc5986). Reproduced on gfx1151 under
timeout:quantized_matmulat 256x512, M = 1: no hang. It finishes and matchesx @ dequantize(w).Tin f32 on the CPU (relative error 1.8e-7 for f32, 2.8e-3 for bf16).quantizeat 4096x4096: no "invalid configuration argument". It launches in about 80 ms and matches the CPU quantizer bit for bit.gather_qmm: matches a per-expert dequantized reference, sorted and unsorted (1.6e-6 f32, 2.6e-3 bf16).The fixes are PR #1818's overlay items 8, 10 and 11 in
patches-rocm/LOCAL_FIXES.md. Native mxfp4 is correct, so the capability table'sNativeentry for ROCm stays and the affine 4-bit fallback (plan step 4) is not needed. No overlay change here.Changes
tests/rocm_mxfp4_quant.rs: the committed version of those checks. It also pins the table entry. Each numeric test fails with its fix reverted: item 8 gives NaN, item 10 a GPU memory fault (reported as an error since fix(rocm): surface ROCm GPU failures through Event::error instead of NaN or hangs #1804), item 11 the original launch error.validate_quantization_mode_for_running_backend. On a backend that also converts or refuses modes (ROCm), the first layer of each natively run block-float mode printsQuantization mode mxfp4: running on native ROCm kernels, no load-time conversion .... This is the native counterpart of the NVFP4 repack line. On Metal, CUDA and CPU every mode is native, so no line prints and their output does not change.docs/installation.md: states the log line and the test. The stale 3.6 tok/s gpt-oss figure now reads 8.07 tok/s, as measured in the perf(bench): ROCm support in the benchmark harness and a gfx1151 baseline #2056 baseline.The four mxfp4
ffi_tests::compiled_qgelu_mlp_global_scale_*cases, two of which the old NVFP4 abort hid, all pass on ROCm now.Verification (gfx1151)
cargo test --profile test-fast --features rocm --test rocm_mxfp4_quant -- --test-threads=1: 4 passed, 26 s.mlxcel generate -m models/mlx/gpt-oss-20b-MXFP4-Q4 --temp 0: coherent answer ("The capital of France is Paris.") and the native-route line appears once. Qwen3-0.6B-4bit (affine) prints no line.ffi_tests::compiled_qgelu_mlp_global_scale(5 passed).layers::tests: the new test passes, and the only failure is the known bf16prefill_dense_gemm_matches_qmm_bytes_where_eligiblebaseline. Root libmodels::{switch_layers,gpt_oss,kimi_linear}: 40 passed.dead_doc_pointerspassed.-D warningson mlxcel-core (lib, tests) and mlxcel (lib, new test), plusmake verify-versions verify-kernel-dtype-keys verify-kernel-port-dispatch verify-llama-compat verify-fmt: all clean.Not verified: Metal and CUDA (not available on this host). The loader call sites this touches are shared with them, but there
native_quantization_route_linereturnsNone(covered by a unit test for every backend), so their behavior is unchanged by construction.