Skip to content

[Perf][MiniMax-M3] (NVIDIA-only) Fused norm+quant MXFP8 - #64852

Merged
zyongye merged 2 commits into
vllm-project:mainfrom
gau-nernst:m3-norm-mxfp8
Nov 2, 2026
Merged

zyongye merged 2 commits into
vllm-project:mainfrom
gau-nernst:m3-norm-mxfp8

Conversation

@gau-nernst

@gau-nernst gau-nernst commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Add a new Triton kernel for fused norm+quant MXFP8. To simplify integration, this kernel also covers additional no-quantize callsites:

  • norm+quant before QKV proj
  • No quantize: Input norm, final norm, MTP enorm/hnorm

dspark drafter's per-head norms remain on FlashInfer kernels.

Claims

  • MXFP8 norm + quantization: 1.39–1.60× faster than the norm → quantize chain across M=1–16K tokens (launch-bound at small M); 6.46 TB/s at M=16K tokens (~96% of the 6.76 TB/s streaming ceiling).
  • BF16 norm: faster than FlashInfer at all but one measured M (plain M=1024 tokens: 0.99×, noise level).
  • Bitwise residuals/UE8M0 scales; E4M3 code distance ≤1; BF16-out within 1 BF16 ulp.
  • GSM8K accuracy: 0.9360 vs 0.9380 base (1-question delta, within noise). E2E prefill TTFT p50 is 0.4–0.9% lower at c=1/16 and neutral at c=4; decode TPOT p50 is neutral at c=32 and 5.4–9.6% lower at c=128/512 (2 rounds per arm).

Validation

  • .venv/bin/python -m pytest tests/models/minimax_m3/test_norm_mxfp8.py -v → 13 passed on GB300.
  • pre-commit: all hooks passed.

Microbenchmark

  • CUPTI cold-L2 CUDA-graph medians, 3 rotated rounds, GB300 SM103, H=6144 BF16 elements. BW counts 7.03 bytes/element: BF16 x in, residual in + out, FP8 out, UE8M0 scales; measured streaming ceiling: 6.76 TB/s.

Fused MXFP8 norm vs FlashInfer norm + separate MXFP8 quantize chain

Tokens (M) Norm → quantize Fused Speedup Fused BW
1 4.64 µs 3.33 µs 1.39× 13.0 GB/s
4 5.15 µs 3.26 µs 1.58× 53.0 GB/s
16 5.28 µs 3.30 µs 1.60× 209 GB/s
64 5.41 µs 3.68 µs 1.47× 751 GB/s
256 7.55 µs 5.25 µs 1.44× 2.11 TB/s
1024 16.10 µs 11.39 µs 1.41× 3.88 TB/s
4096 46.27 µs 31.78 µs 1.46× 5.57 TB/s
16384 169.26 µs 109.54 µs 1.55× 6.46 TB/s

BF16-out norm parity vs FlashInfer norm

  • This PR also backs the plain BF16 norm paths. Speedup = FlashInfer ÷ Triton latency, range across 2 bench runs; latencies are from the latest run.
Form Tokens (M) FlashInfer Triton Speedup
Fused-add 1 2.91 µs 2.72 µs 1.058–1.071×
Fused-add 4 3.33 µs 2.75 µs 1.209×
Fused-add 16 3.46 µs 2.82 µs 1.228–1.253×
Fused-add 64 3.68 µs 3.01 µs 1.223×
Fused-add 256 4.80 µs 4.42 µs 1.087×
Fused-add 1024 11.04 µs 10.40 µs 1.062×
Fused-add 4096 32.38 µs 31.87 µs 1.014–1.016×
Fused-add 16384 116.80 µs 116.16 µs 1.006×
Plain 1 2.91 µs 2.59 µs 1.123–1.136×
Plain 4 3.46 µs 2.59 µs 1.317–1.333×
Plain 16 3.39 µs 2.59 µs 1.309×
Plain 64 3.49 µs 2.59 µs 1.346×
Plain 256 4.06 µs 3.39 µs 1.198×
Plain 1024 7.42 µs 7.52 µs 0.987–0.991×
Plain 4096 20.22 µs 18.62 µs 1.086×
Plain 16384 61.95 µs 61.66 µs 1.005×

Faster everywhere except plain M=1024 tokens (0.99×, noise level; a standalone re-measure had the ordering flipped). In the MXFP8 checkpoint, the BF16 path serves the post-attention norm (TP1 branch of the fused all-reduce helper), the final norm, and the MTP norms.

E2E serving

  • vllm bench serve; MiniMax-M3.1-Flash on GB300; base = upstream/main, PR = this branch.
  • 2 full runs per arm; ranges shown.
  • Decode used the mega MoE backend (--moe-backend deep_gemm_mega_moe); both configs use dspark speculative decoding.

Prefill: PP2 TP1, 100k-token random prefix + 8k-token input, 1 output token.

Concurrency Base TTFT p50 PR TTFT p50 Speedup
1 288.0 ms 286.5–286.9 ms 0.4–0.5%
4 638.2–642.4 ms 638.2–640.7 ms -0.4–+0.7%
16 1835.9–1836.0 ms 1820.4–1820.6 ms 0.8–0.9%

Decode: DEP4, 60k-token cached prefix, 1024 output tokens.

Concurrency Base TPOT p50 PR TPOT p50 Speedup
32 7.18–7.61 ms 7.61–7.70 ms -7.2–0.0%
128 11.75–12.03 ms 10.72–10.88 ms 8.8–9.6%
512 22.06–22.95 ms 20.87–21.23 ms 5.4–7.5%
1024 34.82–35.54 ms 33.68–34.71 ms 0.3–5.2%

Speedup is per-round paired (base vs PR within the same run), range across 2 rounds; decode is neutral at c=32 and faster at c≥128, so the fusion does not regress decode.

GSM8K

MiniMax-M3.1-Flash, PP2 TP1 on 2× GB300; first 500 examples, 5-shot, temperature 0, max_tokens=8192:

Config Accuracy
upstream/main 0.9380
This PR 0.9360

0.002 delta = 1 question, within run-to-run noise; the BF16 norm path differs from FlashInfer by at most 1 ulp, MXFP8 path is bitwise-identical.

Details

  • MiniMAXGemmaRMSNorm.forward calls the Triton kernel (ops/norm_mxfp8.py) via gemma_rmsnorm_mxfp8(x, weight, eps, residual=None, mxfp8=True).
  • Non-2-D inputs (the dspark drafter per-head norms, e.g. (16384, 4, 128)) keep the FlashInfer kernels.
  • forward_input_norm passes mxfp8=True when get_input_quant_key(qkv_proj) == kMxfp8Dynamic with a supported FlashInfer MXFP8 linear kernel.
  • TP>1 keeps the fused all-reduce + norm path; that helper's TP1 branch calls the norm module, so it uses Triton too.
  • Kernel: hidden size is tl.constexpr; token count is do_not_specialize (2 compiled variants total: MXFP8 on/off). Specializes on None residual/sf pointers instead of constexpr flags; asserts 2-D row-contiguous inputs, with arbitrary row stride supported.
  • PDL: every CTA calls gdc_wait before any global access, then gdc_launch_dependents.
  • Model-local to MiniMax-M3 NVIDIA; no new flags or dependencies.

Duplicate-work check (2026-10-31): no open NVIDIA MiniMax-M3 TP1 norm+MXFP8 PR found.

Related PR Why this is distinct
#62509 ROCm M3.1; this targets NVIDIA
#61073 General QuantizedActivation fusion contract, still iterating; this PR uses model-local dispatch and can migrate later
#64723 TP>1 Qwen3.5 fusion; complementary scope
#61783 Compile-pass NVFP4 fusion; different format/mechanism

AI assistance: Kimi Code assisted with the implementation; Codex wrote this PR description.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).
  • AI assistance was used during the creation of this PR.
  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing (anything written below this line will be removed by GitHub Actions)

@gau-nernst
gau-nernst force-pushed the m3-norm-mxfp8 branch 4 times, most recently from cc44c4b to 157e4dc Compare October 31, 2026 06:31
@gau-nernst gau-nernst changed the title [Perf][MiniMax-M3] (NVIDIA-only) TP1 input norm writes qkv_proj's MXFP8 input [Perf][MiniMax-M3] (NVIDIA-only) Fused norm+quant MXFP8 Oct 31, 2026
@mergify mergify Bot added the quantization label Oct 31, 2026
@gau-nernst
gau-nernst force-pushed the m3-norm-mxfp8 branch 6 times, most recently from 9ad5687 to 6f2996c Compare October 31, 2026 10:11
…P8 input

All MiniMax-M3 NVIDIA Gemma RMSNorm call sites run as one Triton kernel
(ops/norm_mxfp8.py): the input norm (fused add and layer 0's plain norm),
the final norm, the MTP embed/hidden norms, and the dspark drafter's
per-head context norms (leading dims flattened; the kernel normalizes the
last dim). When qkv_proj consumes MXFP8 the input norm additionally writes
its input directly (E4M3 data, UE8M0 scales in the 128x4 swizzled layout),
deleting the separate quantize kernel, which re-reads the full normed
activation. The output format is chosen per call from
get_input_quant_key(qkv_proj) == kMxfp8Dynamic with a FlashInfer MXFP8
linear kernel, following the Qwen3.5 fused norm+quant dispatch. TP>1 input
norms keep the fused all-reduce + norm.

The token count is marked do_not_specialize (varies per call; one compiled
variant per output format); the hidden size stays constexpr.

Accuracy bar: residual and scales bitwise, quantized codes within one E4M3
step. BF16-out norm matches FlashInfer's norm within 1 BF16 ulp and is
1.006-1.35x faster at every M measured except a noise-level 0.99x cell
(plain norm, M=1024), GB300, H=6144.

Kernel (CUPTI, cold L2, H=6144, GB300, fused vs norm->quantize chain): 1.39x
at M=1, 1.60x at 16, 1.41x at 1K, 1.46x at 4K, 1.55x at 16K; 6.46 TB/s at
16K, ~96% of the measured streaming ceiling.

Co-Authored-By: Kimi Code <noreply@moonshot.cn>
Signed-off-by: Thien Tran <gau.nernst@yahoo.com.sg>
@gau-nernst
gau-nernst marked this pull request as ready for review October 31, 2026 10:19

@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.

@gau-nernst

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #98929 for commit bd3e6bff7352.

ℹ️ This PR is 23 commits behind upstream main. Merged upstream main into this branch as bd3e6bff7352 before starting CI. Pull the branch before pushing more changes.

@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Nov 2, 2026
@zyongye
zyongye merged commit 318c4db into vllm-project:main Nov 2, 2026
93 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Nov 2, 2026
@gau-nernst
gau-nernst deleted the m3-norm-mxfp8 branch November 2, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants