Skip to content

fix(rocm/quant): commit mxfp4 regression tests and log the native route - #2057

Merged
inureyes merged 3 commits into
mainfrom
fix/issue-1808-rocm-mxfp4
Sep 29, 2026
Merged

inureyes merged 3 commits into
mainfrom
fix/issue-1808-rocm-mxfp4

Conversation

@inureyes

Copy link
Copy Markdown
Member

Closes #1808

Audit result

The issue's title is stale: nothing it describes still fails on current main (dfc5986). Reproduced on gfx1151 under timeout:

  • mxfp4 quantized_matmul at 256x512, M = 1: no hang. It finishes and matches x @ dequantize(w).T in f32 on the CPU (relative error 1.8e-7 for f32, 2.8e-3 for bf16).
  • GPU mxfp4 quantize at 4096x4096: no "invalid configuration argument". It launches in about 80 ms and matches the CPU quantizer bit for bit.
  • mxfp4 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's Native entry 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.
  • Load log: quantized layer loaders now go through 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 prints Quantization 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.
  • mlxcel-core ffi_tests::compiled_qgelu_mlp_global_scale (5 passed). layers::tests: the new test passes, and the only failure is the known bf16 prefill_dense_gemm_matches_qmm_bytes_where_eligible baseline. Root lib models::{switch_layers,gpt_oss,kimi_linear}: 40 passed. dead_doc_pointers passed.
  • clippy -D warnings on mlxcel-core (lib, tests) and mlxcel (lib, new test), plus make 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_line returns None (covered by a unit test for every backend), so their behavior is unchanged by construction.

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
@inureyes inureyes added type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata arch:moe Sparse mixture-of-experts decoder platform:linux Linux (CUDA / packaging) specific status:review Under review labels Sep 29, 2026
Review follow-up for #2057: the once-per-mode slot lookup no longer uses expect in library code, and the capability-table comment says the revert checks were run while #1808 was worked rather than implying the repo reproduces them.

Refs #1808
@inureyes inureyes added status:done Completed and removed status:review Under review labels Sep 29, 2026
Bilingual report for the mxfp4 audit in #1808: the issue's failures no longer reproduce on main because PR #1818's overlay items 8, 10 and 11 fixed them, and the new tests each fail with one of those fixes reverted.
@inureyes
inureyes merged commit 4595b06 into main Sep 29, 2026
21 of 24 checks passed
@inureyes
inureyes deleted the fix/issue-1808-rocm-mxfp4 branch September 29, 2026 22:44
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:moe Sparse mixture-of-experts decoder area:models Model architectures, weights, loading, metadata platform:linux Linux (CUDA / packaging) specific priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(rocm/quant): mxfp4 qmm hang and GPU quantize launch failure, with an affine 4-bit fallback

1 participant