Repository navigation
[ROCm][MiniMax-M3] Fuse qkv_proj's per-token FP8 input quant into the input RMSNorm - #65310
vorapolsiloai wants to merge 9 commits into
Conversation
e79f26f to
6e7eb27
Compare
|
Hey @vorapolsiloai, heads up on an ordering question. My PR #61119 adds fuse_input_allreduce to the AMD MiniMax-M3 model, which sits in the forward_input_norm branch before the fuse_input_norm_mxfp8 path. @frida-andersson flagged that your FP8 norm change here would need to handle the case where both fuse_input_allreduce and the per-token FP8 norm are active on the same layer. I would say maybe my PR #61119 might land first. Can you make sure your PR can handle the combined case on top of mine ? Happy to help if you'd like me to test the interaction once both are in. Let me know if you'd prefer a different approach! |
|
@akii96 yes lets do that I will rebase on top of your branch |
|
This pull request has merge conflicts that must be resolved before it can be |
…'s norm The NVIDIA MiniMax-M3 model leaves each FFN output un-reduced and lets the next layer's input_layernorm (or the final norm) complete that all-reduce through fused_allreduce_gemma_rms_norm. The AMD model only fused the attention-site all-reduce, so every layer paid a separate FFN all-reduce plus a norm. Port the wiring: MoE/MLP built with reduce_results=False, the chain set up in MiniMaxM3Model, and the final norm absorbing the last layer's reduce. EAGLE3 captures after a deferring layer reduce a copy so they never record a per-rank partial. Deferral is off under PP>1 (hidden states cross stages), with mono decode or specialized decode (their kernels expect reduced layer outputs), and for MTP (adds the residual directly). Layers whose input norm also quantizes to MXFP8 all-reduce first and keep that fusion. Co-authored-by: Claude (DSH agent) Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
- Split DecoderLayer.forward into forward_input_norm + forward_after_input_norm
so the model loop can capture residual for EAGLE3 after the norm completes the
deferred all-reduce. This eliminates the extra all-reduce per capture that the
previous _maybe_add_hidden_state override performed, matching the NVIDIA model.
- Remove _aux_needs_reduce and _maybe_add_hidden_state override; replace with
_maybe_capture_aux which clones residual after the norm.
- Capture residual.clone() at the final norm for end-layer EAGLE3 captures.
- Tighten the mono decode guard: only disable deferral when mono would actually
activate (MONO_ENABLE + TP4 + DP1 + no EP), not just when the env var is set.
- Drop two flag-only unit tests (TP2 test covers the actual behavior).
- Add pytest.importorskip('flydsl') to the TP2 test.
- Update test toggle: use PP>1 in config instead of MONO_ENABLE at TP2.
Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
vllm#61813 dropped vllm.transformers_utils.configs.minimax_m3.MiniMaxM3Config. Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
…XFP8 deferred norm - Capture each aux layer exactly once: drop the pre-loop layer-0 capture on the stock path, skip a later PP stage start_layer, send end_layer from non-last PP stages, and keep the final-norm capture off the specialized decode path. - Gate deferral on mono.dispatch.deployment_refusal, the config-only checks MonoDecode itself uses, instead of re-deriving TP4/DP1/no-EP. - Finish a deferred reduce before an MXFP8 input norm through allreduce_gemma_rms_norm_mxfp8 so the fused all-reduce + norm kernels apply. - Tests: MXFP8 input-norm variant at TP2, all aux layers incl. 0 and the final norm, the specialized decode loop, a PP2 boundary capture, and both sides of the mono gate. Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
… fused norm helper changes Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com> # Conflicts: # .buildkite/test-amd.yaml # .buildkite/test_areas/models_basic.yaml
…el, check the input norm outputs Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
… serving AITER's Gluon paged-attention decode is specialized on its context partition count (a constexpr, 8 down to ONE_SHOT as rows grow) and on the 16-byte alignment of the context-length pointer (a prefill's rows follow the decode rows in the indexer's table buffers). The startup forwards do not reach every variant, so serving compiled the rest inside user requests. Call the attend once per partition count and alignment on each layer's own cache and table buffers during kernel warmup. Split out of vllm-project#65310. Signed-off-by: Vorapol Assavasangthong <Vorapol.Assavasangthong@amd.com>
… input RMSNorm On FP8-attention checkpoints whose qkv_proj takes a per-token FP8 activation (kFp8DynamicTokenSym, e.g. AITER's preshuffled per-token FP8 GEMM), the input RMSNorm wrote BF16 and a separate kernel quantized it. Add a per-token FP8 epilogue to the existing fused add + Gemma RMSNorm Triton kernel (next to the MXFP8 one) and use it when VLLM_MINIMAX_M3_FUSE_NORM_FP8=1. Split out of vllm-project#65310. Signed-off-by: Vorapol Assavasangthong <Vorapol.Assavasangthong@amd.com>
c1233df to
c0eed47
Compare
… serving AITER's Gluon paged-attention decode is specialized on its context partition count (a constexpr, 8 down to ONE_SHOT as rows grow) and on the 16-byte alignment of the context-length pointer (a prefill's rows follow the decode rows in the indexer's table buffers). The startup forwards do not reach every variant, so serving compiled the rest inside user requests. Call the attend once per partition count and alignment on each layer's own cache and table buffers during kernel warmup. Split out of vllm-project#65310. Signed-off-by: Vorapol Assavasangthong <Vorapol.Assavasangthong@amd.com>
… input RMSNorm On FP8-attention checkpoints whose qkv_proj takes a per-token FP8 activation (kFp8DynamicTokenSym, e.g. AITER's preshuffled per-token FP8 GEMM), the input RMSNorm wrote BF16 and a separate kernel quantized it. Add a per-token FP8 epilogue to the existing fused add + Gemma RMSNorm Triton kernel (next to the MXFP8 one) and use it when VLLM_MINIMAX_M3_FUSE_NORM_FP8=1. Split out of vllm-project#65310. Signed-off-by: Vorapol Assavasangthong <Vorapol.Assavasangthong@amd.com>
c0eed47 to
0a4fdd7
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
Overview
In MiniMax-M3 decoder layers the input RMSNorm writes a BF16 row and a separate kernel reads it back to quantize it to per-token FP8 for
qkv_proj. This puts that quant into the fused norm kernel, opt-in (VLLM_MINIMAX_M3_FUSE_NORM_FP8=1); output matches the unfused path up to 1-ULP rounding.MI355X, MiniMax-M3 TP4: +1.1 to +2.2% output tok/s and -0.7 to -2.0% median TPOT in all 6 workloads (8k/1k and 1k/1k, c4/16/64); fused op 1.4-1.6x faster at M = 17424.
Claims
MiniMaxM3Sparse*checkpoints on ROCm with per-token dynamic FP8qkv_projinput; MXFP8-attention checkpoints are unaffected.Validation
Full description, commands, tables, provenance
Overview
In each MiniMax-M3 decoder layer the input RMSNorm (fused with the residual add) feeds
qkv_proj, which on FP8-attention checkpoints takes a per-token FP8 activation. Today the norm writes a BF16 row and a separate kernel reads it back to quantize it, while checkpoints with MXFP8 attention already quantize inside the fused norm kernel. This PR adds the per-token FP8 quant to that same fused kernel (opt-in,VLLM_MINIMAX_M3_FUSE_NORM_FP8=1), computing the scale as AITER's per-token quant does, so the output matches the unfused path up to 1-ULP rounding.Perf: +1.1 to +2.2% output tok/s and -0.7 to -2.0% median TPOT in all 6 workloads of the 8k/1k and 1k/1k sweep at c4/16/64 (MI355X, MiniMax-M3 TP4); GSM8K, GPQA diamond and NIAH 128k unchanged; the fused op is 1.4-1.6x faster at M = 17424.
Claims
MiniMaxM3Sparse*) on ROCm whoseqkv_projinput quant is per-token dynamic FP8 (FP8-attention checkpoints such asamd/MiniMax-M3-MXFP4-AttnFP8, the one measured). Checkpoints with MXFP8 attention linears already use the MXFP8 fusion and are unaffected (checked: MiniMax-M3.1-Flash MXFP4). Off under batch invariance; no other model is touched.Validation
pytest tests/kernels/test_minimax_m3_amd_ops.py # MI350X: 149 passed, 1 skipped (gfx942 only); new test: 16 casesNull range: the same delta over every 3-vs-3 split of the 6
mainruns; every PR run beat everymainrun on all three metrics.Standard sweep and accuracy, same server command (main: 4 runs, PR: 2 runs, interleaved, fresh servers; evals: 1 run per arm):
Null: the largest delta between the 4
mainruns split 2 vs 2. Both PR runs beat all 4mainruns on output tok/s and median TPOT in all 6 workloads.Sweep, all metrics; 128k row (MI355X; main 4 runs / PR 2 runs, means)
59 of 66 delta cells (11 metrics incl. total token and request throughput) are outside the null range, all better; a code-identical arm (2 vs 4 runs) lands outside in ~13 by chance. 128k/1k c4 on a fresh server (
--random-input-len 131072 --max-concurrency 4 --num-prompts 8 --num-warmups 0): median TPOT 9.75 -> 9.58 ms (-1.8%). GSM8K flexible-extract 0.8863 -> 0.8908 (p 0.69). About 15% of GSM8K answers also differ betweenmainand branches that do not touch the numerics (batch-order effects at temperature 0), so the paired test is the comparison, not the score difference.Details
Implementation, op microbenchmark, image rows, scope changes
QUANT_FP8_TOKENconstexpr branch next to the MXFP8 one in_gemma_fused_add_rmsnorm_kernel; it quantizes the input-dtype normed row the way AITER'sdynamic_per_token_scaled_quantdoes (scale = amax / FP8_MAX; a zero row gets scale 0) and handsqkv_projaQuantizedActivation. The server logsFusing input_layernorm with qkv_proj's per-token FP8 input quant(absent onmain). New test:test_gemma_fused_add_rmsnorm_fp8_token_matches_unfused(incl. outlier channels and an all-zero row).VLLM_MINIMAX_M3_FUSE_NORM_FP8=1to enable); with the flag off the code path is the old one.forward_input_norm): whichever lands second rebases; the FP8 branch takes the same plain all-reduce fallback as the MXFP8 one. Not measured on top of [ROCm][Perf][MiniMax-M3] Defer the FFN all-reduce into the next layer's norm #61119.Op level, MI350X, fused vs
gemma_fused_add_rmsnorm+ per-tokenscaled_fp8_quant, median time:No sign flips; the residual output is identical, and the mean error against an FP32 reference is equal for both paths.
Image rows, same runs (output tok/s; not claimed):
mainarms: -3.3 .. +5.1%)Details
Not claimed: numbers on top of #61119 (measured on main before the rebase). Depends on #61119.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (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)