Skip to content

[ROCm][MiniMax-M3.1] Serve NVFP4 routed experts natively on gfx950 (AITER moe_nvfp4) + NIXL whole-row KV transfer for non-MLA BLHNC - #67793

Open
sshlyapn wants to merge 2 commits into
vllm-project:mainfrom
sshlyapn:sshliapn/features/vllm-main-nvfp4-moe
Open

sshlyapn wants to merge 2 commits into
vllm-project:mainfrom
sshlyapn:sshliapn/features/vllm-main-nvfp4-moe

Conversation

@sshlyapn

Copy link
Copy Markdown
Contributor

Purpose

Problem. MiniMax-M3.1 checkpoints (quant_method: mxfp8, moe_quant_algo: NVFP4, moe_quant_format: nvfp4-pack-quantized) ship the routed experts as NVFP4. vLLM main has no NVFP4 MoE backend on ROCm, so MiniMaxM3MoE raises NotImplementedError unless the user re-quantizes the experts online at load time:

  • --quantization-config.moe mxfp8: the accurate option, but it doubles the routed-expert weight bytes (8.25 vs 4.5 bits per weight [A]) and decode is weight-bandwidth bound, so it is the slowest.
  • --quantization-config.moe mxfp4: fast (4.25 bits per weight [A]), but it is a second, lossy quantization of weights that are already quantized (E8M0 block-32 scales replace the checkpoint FP8 block-16 scales plus global scale), and show accuracy 1.5-1.7 pp below MXFP8 on AIME26.

Change. On gfx950 with an AITER build that contains aiter.ops.moe_nvfp4 (ROCm/aiter#7606), the checkpoint NVFP4 weights go unchanged to the AITER HIP NVFP4 MoE kernels for every token count. No flag and no env var. --quantization-config.moe mxfp8|mxfp4 keeps the existing online re-quantization path unchanged. Without gfx950 or without aiter.ops.moe_nvfp4 (for example today's stock image with AITER v0.1.29) the behavior is the same as today.

Why: MXFP8 accuracy at MXFP4 speed. NVFP4 native serves the weights exactly as shipped, so it is a drop-in replacement for the MXFP8 re-quant option:

  • Accuracy equals MXFP8 within run-to-run noise on every AIME26 comparison we ran (2026-11-07: NVFP4 90.10 vs MXFP8 90.00, paired t p 0.89) [V].
  • Decode speed equals MXFP4: 1P1D PD median ITL speedup vs MXFP4 0.970x-1.062x over 15 cells (1.06x at C1, 0.97-0.98x at C32-C64) [V/A].
  • Decode is 1.07x-1.30x faster than MXFP8 (median ITL, every cell of the same grid), and output throughput is 1.07x-1.29x higher [V/A].
  • KV-cache capacity is the same as with the re-quant flag [V].

Second change: NIXL fix for P/D. Without it, P/D on vLLM main cannot serve M3.1 long contexts: NIXL moves the BLHNC KV cache in ~125 small pieces per block, and UCX runs out of resources at 8k C64 and 64k. The fix restores the whole-row transfer that the PR #63232 fork already had. Details in "PD fix: NIXL whole-row transfer".

Changes

2 commits, 4 files, +256 / -46 against dadf740.

  • f59beb9 [ROCm][MiniMax-M3] Serve NVFP4 routed experts on AITER moe_nvfp4: +190 / -37.
  • c5cf9c5 [KV Connector][NIXL] Transfer whole packed rows for non-MLA BLHNC: +66 / -9.

NVFP4 MoE (f59beb9).

  • vllm/models/minimax_m3/amd/model.py (+54 / -37): computes keep_nvfp4 (ModelOpt MXFP8 config with moe_quant_algo == "NVFP4", experts not excluded, no online MoE quantization config). Raises NotImplementedError only when keep_nvfp4 and not nvfp4_moe_supported(); the message says the model needs gfx950 and AITER moe_nvfp4, otherwise use --quantization-config.moe mxfp8 (or mxfp4). FusedMoEFactory(...) is built inside skip_checkpoint_backend_selection() when keep_nvfp4 (the compressed-tensors NVFP4 MoE method creates the checkpoint parameters but skips its backend selection, which has no ROCm NVFP4 backend), then keep_nvfp4_experts(self.experts) is called. The factory arguments are unchanged; most of the -37 lines are the re-indent under the with block.
  • vllm/models/minimax_m3/amd/nvfp4_experts.py (+136, new): nvfp4_moe_supported() = gfx950 and import aiter.ops.moe_nvfp4 succeeds. MiniMaxM3NvFp4HipMoEMethod(CompressedTensorsW4A4Nvfp4MoEMethod) builds aiter.ops.moe_nvfp4.NvFp4MoeWeights (shuffled copies) in process_weights_after_loading, deletes the 8 checkpoint parameters so the weights are not held twice, and calls moe_nvfp4(weights, x, topk_ids, topk_weights) in apply. Not monolithic, no modular kernel; the kernel takes bf16 activations and quantizes them internally. keep_nvfp4_experts checks the method is exactly CompressedTensorsW4A4Nvfp4MoEMethod, swaps its class before weight loading and logs once: "MiniMax-M3 NVFP4 routed experts: AITER moe_nvfp4 for every T. Prefill (large T) may be slower than with --quantization-config.moe mxfp4".

Rejected at load (NotImplementedError), limits of the AITER kernels: expert parallelism; fused shared experts (VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1, default 0); padded MoE sizes; any activation other than SwiGLU-OAI uninterleaved with alpha 1.702, beta 1.0, limit 7.0; apply_router_weight_on_input.

Behavior notes. The routed scaling factor is applied by the runner (RoutedScaleMode.OUTPUT, the existing non-FSE path). The shared expert is not overlapped through a modular kernel; the runner's shared-expert aux stream still applies. KV-cache capacity equals the re-quant flag (221.61 GiB at TP4) because the checkpoint parameters are freed.

NIXL fix (c5cf9c5).

  • vllm/distributed/kv_transfer/kv_connector/v1/nixl/base_worker.py (+21 / -3): a non-MLA model whose KV views share one block-major allocation (BLHNC) and has no SSM state now registers whole block rows as one NIXL region, the same path MLA models already use. A P/D TP-size mismatch on such rows is rejected at handshake with "Packed KV rows of a non-MLA model need the same TP on prefill and decode ... Use LBHNC for heterogeneous TP."
  • tests/v1/kv_connector/unit/test_nixl_desc_geometry.py (+45 / -6): 3 new tests (whole-row registration for pull and push workers at PP=1, TP-mismatch rejection).

Dependency: AITER ROCm/aiter#7606

  • [HIP] [JIT] [MoE] NVFP4 routed-expert MoE for gfx950 ROCm/aiter#7606 "NVFP4 MoE for CDNA4" adds aiter.ops.moe_nvfp4 (HIP kernels, ctypes entry, dispatch module, tuned CSV for M3.1 TP4 / TP8, op tests). It was still open on 2026-11-15.
  • In Aiter's NVFP4 MoE PR module_moe_nvfp4 is an experimental module, so the stock PREBUILD_KERNELS=1 wheel does not prebuild it and it JIT-compiles on first use (about 11 s) [V].
  • AITER main pins flydsl==0.5.0 (the v0.1.29 stack has 0.4.2). M3.1 gsm8k, AIME26 and perf ran on 0.5.0 without errors; other models that use vLLM FlyDSL kernels were not tested on 0.5.0.

Docker build (official recipe)

AITER is built in the stack (docker/Dockerfile.rocm_base, stage build_aiter), so the stack and runtime must be rebuilt in the same bake graph to get #7606 into vllm-openai:

# After #7606 merges: AITER_BRANCH=main (or the first release tag with #7606).
TAG=vllm-openai-rocm:m31-nvfp4-moe \
docker buildx bake -f docker/docker-bake-rocm.hcl vllm-openai \
    --set stack-rocm.args.AITER_REPO=https://github.com/sshlyapn/aiter.git \
    --set stack-rocm.args.AITER_BRANCH=sshliapn/features/cdna4_nvfp4_moe

Serving: P/D decode node (MI355X)

Setup. This is the decode command of the official vLLM MI355X MiniMax-M3.1 P/D recipe with the minimum changes for NVFP4 decode. The prefill node keeps MXFP8 re-quantized experts with VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1; every P/D result in this description used such a P (details below).

docker run --device=/dev/kfd --device=/dev/dri \
  --security-opt seccomp=unconfined --group-add video \
  --privileged --ipc=host -p 8002:8002 \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  -e VLLM_NIXL_SIDE_CHANNEL_PORT=5558 \
  -e VLLM_NIXL_SIDE_CHANNEL_HOST=$DECODE_NODE_1 \
  -e CUDA_VISIBLE_DEVICES=0,1,2,3 \
  -e VLLM_ROCM_USE_AITER=1 \
  -e VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0 \
  -e VLLM_KV_CACHE_LAYOUT=BLHNC \
  vllm-openai-rocm:m31-nvfp4-moe MiniMaxAI/MiniMax-M3.1-Flash \
  --block-size 128 \
  --disable-hybrid-kv-cache-manager \
  --port 8002 \
  --kv-cache-dtype nvfp4 \
  --attention-config '{"indexer_kv_dtype": "nvfp4", "indexer_decode_cp": true}' \
  --tensor-parallel-size 4 \
  --compilation-config '{"cudagraph_mode": "FULL_AND_PIECEWISE"}' \
  --kv-transfer-config '{"kv_connector":"NixlConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"num_threads":4}}' \
  --tool-call-parser minimax_m3 \
  --enable-auto-tool-choice \
  --reasoning-parser minimax_m3 \
  --speculative-config '{"method":"dspark","num_speculative_tokens":3,"attention_backend":"TRITON_ATTN","kv_cache_dtype":"fp8","draft_sample_method":"probabilistic"}'

Differences from the official decode command (3 lines).

-  -e VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1 \
+  -e VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0 \
-  vllm/vllm-openai-rocm:minimax-m31-flash MiniMaxAI/MiniMax-M3.1-Flash \
+  vllm-openai-rocm:m31-nvfp4-moe MiniMaxAI/MiniMax-M3.1-Flash \
-  --quantization-config.moe mxfp8 \
  • No --quantization-config.moe: the routed experts stay in the checkpoint NVFP4 format and run on AITER moe_nvfp4. Startup logs "MiniMax-M3 NVFP4 routed experts: AITER moe_nvfp4 for every T ...". Adding --quantization-config.moe mxfp8 (or mxfp4) back gives the unchanged re-quant path.
  • VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0: required; the NVFP4 path rejects fused shared experts at load ("fused shared experts are unsupported"). The shared expert runs as a separate module.
  • Image: any image with this PR and an AITER that contains aiter.ops.moe_nvfp4 ([HIP] [JIT] [MoE] NVFP4 routed-expert MoE for gfx950 ROCm/aiter#7606), for example the tag built in "Docker build". Our P and D both ran the same image with the NIXL commit of this PR; a P without the NIXL commit paired with a D with it was not tested.
  • Same TP on P and D: with VLLM_KV_CACHE_LAYOUT=BLHNC the NIXL fix requires equal P and D TP (TP4 / TP4 here); a mismatch fails at handshake. The fix does not change LBHNC.

Accuracy

All runs: MI355X (gfx950), TP4 per engine, MiniMax-M3.1-Flash. AIME26 = sgl-eval, 16 repeats per run, max_tokens 65536, temperature 1.0, top-p 0.95, thinking_mode enabled. 1P1D = P TP4 MXFP8 re-quant (+FSE), D TP4 = the arm. Error rate 0 in every run [V].

D arm r1 r2 r3 r4 mean +- std spec AL
MXFP8 re-quant 88.33 92.08 89.17 90.42 90.00 +- 1.63 2.601
MXFP4 re-quant 89.17 88.33 89.58 86.88 88.49 +- 1.20 2.510
NVFP4 native 91.04 90.62 89.17 89.58 90.10 +- 0.88 2.577

Paired per problem (30 problems x 64 repeats) [V]:

  • NVFP4 - MXFP8: +0.10 pp, paired t p 0.89, Wilcoxon p 0.92. No difference detected.
  • NVFP4 - MXFP4: +1.61 pp, sign p 0.052, Wilcoxon p 0.057, paired t p 0.13. Borderline.
  • MXFP4 - MXFP8: -1.51 pp, sign p 0.078, Wilcoxon p 0.070, paired t p 0.105. Borderline. With the 2026-11-04 runs added: -1.71 pp, sign p 0.023, Wilcoxon p 0.036, paired t p 0.051.
  • Spec acceptance length follows the same order: MXFP4 2.51 is 3.5% below MXFP8 2.60, NVFP4 2.58 is 0.9% below [V].

Performance

1P1D PD, full grid, NVFP4 vs MXFP4 vs MXFP8 (2026-11-15, this PR stack + NIXL fix)

Setup. P = MXFP8 re-quant + FSE=1 for every arm; D = NVFP4 native (FSE=0), MXFP4 re-quant (FSE=1) or MXFP8 re-quant (FSE=1), same image. DSpark MTP k=7 with synthetic acceptance [0.77, 0.55, 0.39, 0.27, 0.19, 0.14, 0.10]; random prefix ISL 1k / 8k / 64k, OSL 1024, C 1 / 8 / 16 / 32 / 64, warmup per C, 2 passes in palindrome order (MXFP8, MXFP4, NVFP4, NVFP4, MXFP4, MXFP8). 0 failed requests; pass-to-pass ITL 0.97-1.03. Values are means of 2 passes [V]; speedups [A].

cell NVFP4 ITL ms MXFP4 ITL ms MXFP8 ITL ms ITL speedup vs MXFP4 ITL speedup vs MXFP8 tok/s speedup vs MXFP4 tok/s speedup vs MXFP8 (ref) MXFP4 ITL speedup vs MXFP8
1k C1 7.90 8.39 9.16 1.062x 1.159x 1.060x 1.155x 1.092x
1k C8 13.94 14.30 18.06 1.026x 1.296x 1.030x 1.285x 1.263x
1k C16 18.29 18.27 23.27 0.999x 1.272x 1.000x 1.264x 1.274x
1k C32 25.40 24.63 31.09 0.970x 1.224x 0.982x 1.215x 1.262x
1k C64 39.03 38.66 45.74 0.991x 1.172x 0.993x 1.165x 1.183x
8k C1 8.06 8.51 8.59 1.056x 1.066x 1.057x 1.068x 1.009x
8k C8 14.89 15.12 18.94 1.015x 1.272x 1.016x 1.261x 1.253x
8k C16 16.17 16.50 18.61 1.020x 1.151x 1.019x 1.145x 1.128x
8k C32 25.86 25.12 31.37 0.971x 1.213x 0.973x 1.207x 1.249x
8k C64 40.09 39.63 46.64 0.989x 1.163x 0.996x 1.153x 1.177x
64k C1 8.48 8.99 9.62 1.060x 1.134x 1.063x 1.120x 1.070x
64k C8 14.45 14.87 17.27 1.029x 1.195x 1.038x 1.176x 1.161x
64k C16 19.37 19.41 24.23 1.002x 1.251x 1.007x 1.239x 1.248x
64k C32 26.87 26.23 32.33 0.976x 1.203x 1.002x 1.181x 1.233x
64k C64 41.05 40.20 47.45 0.979x 1.156x 1.028x 1.132x 1.180x
  • vs MXFP8: NVFP4 is faster in every cell: ITL 1.066x-1.296x, output throughput 1.068x-1.285x. Median TPOT follows ITL within 0.02 [V/A].
  • vs MXFP4: comparable. ITL 1.056x-1.062x at C1, 1.015x-1.029x at C8, 0.999x-1.020x at C16, 0.970x-0.991x at C32-C64 [A].
  • Why C32 / C64 lose to MXFP4: with k=7 the D MoE runs at T = 8 x C tokens per step, so C32 / C64 are T 256 / 512, where our MoE kernel benches show the NVFP4 kernels slightly behind the AITER MXFP4 kernels.
  • TTFT (median, NVFP4 / baseline): vs MXFP4 0.872-1.043, vs MXFP8 0.877-1.014 [V]. The 64k NVFP4 / MXFP4 TTFT of 0.87-0.92 was not investigated.

PD fix: NIXL whole-row transfer for non-MLA BLHNC

What it does. With a block-outermost KV layout (BLHNC), one block row holds this rank's page of every layer (for M3.1 TP4: 1,822,720 B per 128-token block [V, D log]). On vLLM main the NIXL connector registers such a row as one region only for MLA models. M3.1 is not MLA, so it registers one region per layer and KV kind; a block then moves as ~125 separate descriptors of a few KB to ~18 KB each (18,432 B for a main-attention page [V, unfixed D log]; ~14.6 KB on average [A]). With the fix a block moves as one 1.74 MiB descriptor. The bytes moved, the READ path, the block pairing and the completion notifications do not change; only the registration granularity and the descriptor count do.

Why it is needed.

  • Descriptors per request: ~1000 at 1k ISL and ~64000 at 64k without the fix; 4-8 at 1k, ~60 at 8k and 512 at 64k with it [V].
  • Without it, the current nightly UCX stack fails at long context: at 64k C64 UCX ran out of rendezvous fragments and the D engine died; with UCX_RMA_PPLN_ENABLE=y it then ran out of shared-memory segments (shmget ENOSPC, host kernel.shmmni 4096) from 8k C64 and at 64k C16, with ~42k transfer errors [V].
  • 64k KV transfer rate: 0.30-0.44 GB/s without the fix, ~22 GB/s with it [V].
  • With the fix, 0 failed requests and 0 UCX errors in all 7 PD runs (validation + 6 sweep runs x 15 cells) [V].

Origin: replicated from the PR #63232 fork. The PR #63232 branch (squashed commit 36ae880, 2026-10-23; head 8d0f05a) already allowed whole-row transfer for non-MLA models with the same TP-mismatch check. This commit restores it: the accepted cases are the same boolean condition as in the fork (written as a separate packed_head_sharded_storage flag next to main's replicated_shared_storage), and the handshake check is the fork's code verbatim. The 3 unit tests are new. Credit for the logic goes to the #63232 authors.

Limits.

  • Heterogeneous TP between P and D is rejected for non-MLA BLHNC rows (a whole row holds this rank's heads, so it cannot be re-sharded); use LBHNC for heterogeneous TP.
  • With several KV-cache groups (HMA on) a row is paired once per group; groups with disjoint block ids move each row once, which is what vLLM allocates. M3.1 serves with --disable-hybrid-kv-cache-manager (one group).

AIME26 test command

# AIME26 (sgl-eval 0.1.3) against the server or the vllm-router (PD)
sgl-eval run aime26 --model MiniMaxAI/MiniMax-M3.1-Flash --api-key EMPTY --base-url http://127.0.0.1:30000/v1 \
    --num-threads 128 --n-repeats 16 --max-tokens 65536 --temperature 1.0 --top-p 0.95 \
    --chat-template-kwarg thinking_mode=enabled --out-dir <run dir>/sgl_eval

No new vLLM unit test for the NVFP4 MoE path: it needs gfx950 and an AITER build with moe_nvfp4, which current vLLM CI images do not have. Without the op, nvfp4_moe_supported() is False and the same NotImplementedError path is kept by construction (not run as a separate test).

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added minimax rocm Related to AMD ROCm kv-connector labels Nov 15, 2026
@mergify mergify Bot added the nixl NIXL KV connector / multi-tiered KV offloading (KVCR) label Nov 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Nov 15, 2026
@sshlyapn
sshlyapn force-pushed the sshliapn/features/vllm-main-nvfp4-moe branch from c5cf9c5 to de55ccd Compare November 15, 2026 17:21
@mergify

mergify Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @sshlyapn.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks, Sergei! The NVFP4 path looks good to me. Could you rebase onto main and share the results of a MI355X PD smoke test using the final ROCm image?

On gfx950 with AITER moe_nvfp4 (ROCm/aiter#7606), the NVFP4 routed experts
of MiniMax-M3.1 checkpoints run on the AITER HIP kernels when no
--quantization-config.moe is given: the CompressedTensors NVFP4 MoE method
becomes MiniMaxM3NvFp4HipMoEMethod before weight loading (its backend
selection is skipped) and feeds the checkpoint weights to
aiter.ops.moe_nvfp4 for every T (no re-quantized copy, no modular kernel).
--quantization-config.moe mxfp4|mxfp8 keeps the online re-quantization;
other ROCm targets keep the error.

EP, fused shared experts, padded MoE sizes and other SwiGLU-OAI parameters
are rejected. The startup log notes that prefill (large T) may be slower
than with --quantization-config.moe mxfp4.

Signed-off-by: Sergei Shliapnikov <sergei.shliapnikov@amd.com>
With a block-outermost layout (BLHNC) one block row holds this rank's
page of every layer. Only MLA models registered the row as one region;
non-MLA models (e.g. MiniMax-M3.1) registered one region per layer, so a
transfer took one descriptor per layer and block (64000 per 64k-token
request instead of ~440), which exhausted UCX rendezvous fragments under
load.

A non-MLA row is head-sharded, so it can move whole only when P and D
shard the heads alike: allow it and reject a TP mismatch at handshake.

Signed-off-by: Sergei Shliapnikov <sergei.shliapnikov@amd.com>
@sshlyapn
sshlyapn force-pushed the sshliapn/features/vllm-main-nvfp4-moe branch from a5b47f5 to f3c942d Compare November 24, 2026 13:21
@mergify mergify Bot removed the needs-rebase label Nov 24, 2026
@sshlyapn

Copy link
Copy Markdown
Contributor Author

Thanks @zhou9402! Rebased onto main (99b0b0b) and re-tested.

Image. Built with the official docker/docker-bake-rocm.hcl recipe from this branch, using AITER_REPO=https://github.com/ROCm/aiter.git AITER_BRANCH=v0.1.30 (the release that includes ROCm/aiter#7606). No overlays or local patches.

MI355X PD smoke (1P1D, NIXL, vllm-router). Same setup as in the PR description: P is TP4 MXFP8 and D is TP4 with native NVFP4. Compared with the pre-rebase image, nothing changed significantly, and the numbers match the ones in the description.

  • AIME26 (2 runs x 16 repeats): matches PR description ranges (90.21 vs 90.10 description).
  • gsm8k 5-shot: 0.958.
  • 0 failed NIXL transfers, 0 failed requests, 0 preemptions.

PD perf vs the pre-rebase image (k=7, synthetic acceptance; the pre-rebase numbers are the NVFP4 column of the full grid in the description):

ISL conc ITL ms (new / pre-rebase) output tok/s (new / pre-rebase)
1k 1 7.90 / 7.90 409.4 / 412.4
1k 16 18.23 / 18.29 2806.7 / 2812.8
1k 64 38.66 / 39.03 5180.6 / 5281.9
8k 1 7.95 / 8.06 403.0 / 390.2
8k 16 16.17 / 16.17 3002.5 / 3084.2
64k 1 8.38 / 8.48 356.5 / 362.2
64k 16 19.34 / 19.37 2468.0 / 2523.6

ITL is equal or lower in every cell. Throughput differences are within 3%, inside the pass-to-pass spread of the pre-rebase runs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kv-connector minimax nixl NIXL KV connector / multi-tiered KV offloading (KVCR) rocm Related to AMD ROCm

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants