Skip to content

[ROCm][Perf][MiniMax-M3] Defer the FFN all-reduce into the next layer's norm - #61119

Open
akii96 wants to merge 7 commits into
vllm-project:mainfrom
akii96:m3-amd-xlayer-ffn-allreduce-fusion
Open

akii96 wants to merge 7 commits into
vllm-project:mainfrom
akii96:m3-amd-xlayer-ffn-allreduce-fusion

Conversation

@akii96

@akii96 akii96 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Make the AMD MiniMax-M3 model defer each layer's FFN all-reduce into the next layer's norm, the same way the NVIDIA model already does. On its own this does not change performance. It is the groundwork for wiring MiniMax-M3 into the fused AITER all-reduce + norm kernels that have already landed (ROCm/aiter#6404). See Details.

Claims

Validation

Serve command used for MI355X runs:

export HIP_VISIBLE_DEVICES=0,1,2,3
export VLLM_ROCM_USE_AITER=1
export VLLM_ROCM_USE_AITER_MOE=1
export VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION=1
export VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1
export VLLM_ROCM_SHUFFLE_KV_CACHE_LAYOUT=1
export VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4
export VLLM_ROCM_USE_AITER_FLYDSL_QR_INT4=1
export VLLM_ROCM_QUICK_REDUCE_USE_FLYDSL=0  # workaround for #59478 until ROCm/aiter#7258 is pinned
export VLLM_USE_BREAKABLE_CUDAGRAPH=1
export VLLM_WORKER_MULTIPROC_METHOD=spawn
export SAFETENSORS_FAST_GPU=1

vllm serve amd/MiniMax-M3-MXFP4 \
  --served-model-name amd/MiniMax-M3-MXFP4-AttnFP8 \
  --host 0.0.0.0 --port 8000 \
  --tensor-parallel-size 4 \
  --distributed-executor-backend mp \
  --trust-remote-code \
  --kv-cache-dtype fp8 \
  --block-size 128 \
  --no-enable-prefix-caching \
  --language-model-only \
  --max-model-len 133120 \
  --gpu-memory-utilization 0.92 \
  --max-num-batched-tokens 32768 \
  --max-num-seqs 128 \
  --enable-chunked-prefill \
  --async-scheduling \
  --attention-config '{"backend":"ROCM_AITER_UNIFIED_ATTN","indexer_kv_dtype":"fp8"}' \
  --moe-backend aiter \
  --quantization-config '{"targets": {"re:^language_model\\.model\\.layers\\.\\d+\\.self_attn\\.(qkv_proj|o_proj)$": "fp8_per_channel"}}' \
  --no-enable-log-requests

The ablation runs on nightly cf5cea2da used the same command without VLLM_ROCM_USE_AITER_FLYDSL_QR_INT4 and VLLM_ROCM_QUICK_REDUCE_USE_FLYDSL, which no longer exist on main. That nightly ships AITER 0.1.28.post1, which includes the ROCm/aiter#7258 fix.

Bench command:

vllm bench serve --model amd/MiniMax-M3-MXFP4-AttnFP8 --base-url http://localhost:8000 \
  --dataset-name random --random-input-len <ISL> --random-output-len <OSL> \
  --num-prompts <N> --request-rate inf

Unit test. pytest tests/models/minimax_m3/test_xlayer_allreduce_fusion.py gives 9 passed on MI355X. At TP2 the deferred model's final hidden states, every EAGLE3 capture (layer 0 through the final norm) and every layer's input norm output (bf16, or MXFP8 for qkv_proj) match the non-deferred model, exactly without AITER, on both the stock and the specialized decode layer loop. The input norm outputs are compared directly because attention runs without metadata here, so nothing else that is compared depends on them. Giving the deferred MXFP8 norm the wrong weight fails the test. A PP2 run checks that a stage boundary is captured once. The mono tests check that deferral is off exactly when mono decode can run (TP4), stays on at TP2 and under EP, and is off whenever --monokernel is set. pytest tests/models/minimax_m3/amd_specialized_decode/test_model.py gives 5 passed on this head, and the other pinned MiniMax-M3 monokernel steps give 119 passed, 1 skipped.

Performance A/B on MI355X. TP4, nightly dd4e4014. A is this PR, B is baseline. 0 failed requests.

ISL OSL conc A out tok/s B out tok/s A/B A TPOT (ms) B TPOT (ms)
8192 1024 1 95.70 95.70 100.0% 5.34 5.35
8192 1024 32 3803.64 3774.30 100.8% -- --
60000 600 64 612.65 612.17 100.1% -- --

Performance A/B on MI350X. TP4, nightly 2b009fc6d. A is this PR, B is baseline. 0 failed requests.

ISL OSL conc A out tok/s B out tok/s A/B A TPOT (ms) B TPOT (ms)
8192 1024 8 937.82 924.85 101.4% 8.18 8.29
8192 1024 32 2133.54 2134.05 100.0% 14.04 13.99
8192 1024 64 2914.04 2912.97 100.0% 20.71 20.73
8192 1024 128 3898.18 3893.81 100.1% 30.19 30.26
60000 600 16 492.74 491.66 100.2% 29.15 29.68
60000 600 64 586.88 585.87 100.2% 99.44 99.62
128000 1024 16 385.98 385.13 100.2% 37.41 37.74

Rerun of this head on MI350X. TP4, nightly f5d93296, this PR (GPUs 0-3) and the nightly (GPUs 4-7) side by side, three rounds of the two long-context points on one server each. 0 failed requests.

ISL OSL conc A out tok/s B out tok/s A/B
32768 1024 32 1150.3 1154.9 99.6%
131072 1024 8 299.1 301.7 99.1%

Ablation with the follow-up #65858 on MI355X. TP4, nightly cf5cea2da (AITER 0.1.28.post1). Same image for every column, only the changed Python files swapped. Output tok/s, 4 warmups, 3x concurrency prompts, 0 failed requests. All columns include #65995, which a server with INT4 QuickReduce needs to start on AITER 0.1.28.

ISL/OSL conc Nightly + this PR + #65858 only + this PR + #65858 #65858 gain without / with this PR
8k/1k 16 1540.7 1563.2 1566.8 1569.3 +1.7% / +1.9%
8k/1k 64 2939.1 2949.1 2988.7 3032.9 +1.7% / +3.2%
32k/1k 32 1237.9 1242.2 1263.9 1289.9 +2.1% / +4.2%
128k/1k 8 320.6 322.0 327.7 336.6 +2.2% / +5.0%

Gains are relative to the nightly. This PR alone is flat. Each point is a single run, so treat differences below about 1% as noise.

EAGLE3 spec decode. Verified on MI350X (TP4, nightly 40941f2c4) with --speculative-config '{"method": "eagle3", "model": "amd/MiniMax-M3-EAGLE3.1", "num_speculative_tokens": 3, "attention_backend": "TRITON_ATTN"}'. Server loaded, served single and concurrent requests with coherent output, no errors.

Quality. GSM8K 5-shot (full, 1319 samples) via lm-eval 0.4.13 (local-chat-completions, --apply_chat_template --fewshot_as_multiturn, seed 1234, 32 concurrent). The run used VLLM_ROCM_QUICK_REDUCE_USE_FLYDSL=0 to work around a known upstream AITER scale-clipping bug (#59478, fix in ROCm/aiter#7258).

Check This PR Baseline
GSM8K 5-shot (flexible-extract) 0.9272 0.9272
GSM8K 5-shot (strict-match) 0.9257 0.9272

On MI355X nightly cf5cea2da, which has the AITER fix and so no workaround, the same GSM8K setup gives 0.9234 with this PR and 0.9196 on the nightly (flexible-extract, standard error about 0.007).

The runs above use fp8_per_channel attention, so they never reach the MXFP8 input norm. MiniMax-M3.1 does: MiniMaxAI/MiniMax-M3.1-Flash at TP4 on MI355X, nightly be47189f3, recipe flags plus --reasoning-parser minimax_m3, logs deferring 60/60 FFN all-reduces into the next norm (59 before an MXFP8 input norm). GSM8K 5-shot via tests/evals/gsm8k/gsm8k_eval.py (chat completions, all 1319 questions, 4096 max tokens):

Run This PR Baseline
1 0.955 0.963
2 0.964 0.959

Details

What changes. The NVIDIA model (vllm/models/minimax_m3/nvidia/model.py) leaves each layer's FFN output un-reduced. The next layer's input_layernorm, or the final norm, then finishes the all-reduce through fused_allreduce_gemma_rms_norm. The AMD model never got this wiring. At TP > 1, every AMD layer pays for a separate full-size all-reduce and a separate norm on its FFN output. This PR ports the NVIDIA wiring:

  • MiniMaxM3MoE and MiniMaxM3MLP are built with reduce_results=False. MiniMaxM3DecoderLayer.ffn_all_reduce_deferred reports whether a layer left its FFN output un-reduced.
  • MiniMaxM3Model._configure_allreduce_fusion sets fuse_input_allreduce on each layer that follows a deferring layer. The final norm picks up the last layer's reduce.
  • MTP blocks (is_mtp_block=True) and PP > 1 keep reducing as before. MTP adds the residual directly, and PP sends hidden states across stages.
  • DecoderLayer.forward is split into forward_input_norm and forward_after_input_norm, matching the NVIDIA model. Between the two it captures residual.clone() for EAGLE3, after the norm has already completed the deferred all-reduce. The model loop still calls each layer as a module, so forward hooks on it keep firing. No extra all-reduce per capture. Each layer is captured once: a later PP stage skips its start_layer, which the stage before sends.
  • A deferred reduce before an MXFP8 input norm goes through allreduce_gemma_rms_norm_mxfp8, so the fused all-reduce + norm kernels apply there too.
  • Deferral is off under --monokernel and when mono decode can run, decided by deployment_refusal in mono/dispatch.py, the same config checks MonoDecode makes. Both read reduced layer outputs but pick their kernels only after the layers exist, so the gate keys on the flags, and setting up either one raises if a layer still defers.

Why land this before it shows a speedup. The fused AITER all-reduce + norm kernels for MiniMax-M3 have already landed (ROCm/aiter#6404) and ship in AITER 0.1.28. The follow-up #65858 wires MiniMax-M3 to use them at prefill sizes. Those kernels can only reach the FFN all-reduce if the model defers it into the next norm, which is what this PR does. The ablation table shows the effect: #65858 alone gives about +2%, and with this PR underneath it gives up to +5%. NVIDIA already does this, so it also brings the two models in line.

Landing order. This PR does not depend on any other open PR and can land first. To reproduce the ablation on a current nightly, #65995 is needed: since AITER 0.1.28 renamed QuickAllReduceInt4.compile(), a server with INT4 QuickReduce fails at startup without it. The follow-ups land after this PR: #57547 (FlyDSL fused all-reduce + RMSNorm in QuickAllReduce), then #65858. Two open PRs touch the same code: #66184 removes mono/envs.py, so its MONO_ENABLE term in the gate goes away on rebase, and #67072's decode glue all-reduces the MoE output, so it needs to honour ffn_all_reduce_deferred. Whichever lands second takes the small change.

Not a duplicate. Two earlier PRs tried the same deferral. #47270 was closed by its author after a flat A/B; this PR is flat on its own too, and the ablation above shows what it unlocks with #65858. #52680 is an idle draft with no description or results that also adds the AR + GemmaNorm fusion itself.


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.

@mergify mergify Bot added minimax rocm Related to AMD ROCm labels Oct 11, 2026
@akii96 akii96 changed the title [ROCm][Perf][MiniMax-M3] Defer the FFN all-reduce into the next layer… [ROCm][Perf][MiniMax-M3] Defer the FFN all-reduce into the next layer's norm Oct 11, 2026
@mergify

mergify Bot commented Oct 24, 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, @akii96.

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 Oct 24, 2026
@akii96
akii96 force-pushed the m3-amd-xlayer-ffn-allreduce-fusion branch from 6548416 to 76f9a69 Compare October 31, 2026 06:15
@mergify mergify Bot added ci/build and removed needs-rebase labels Oct 31, 2026
@akii96
akii96 force-pushed the m3-amd-xlayer-ffn-allreduce-fusion branch 2 times, most recently from 4892a23 to cd7b5c0 Compare October 31, 2026 07:54
@akii96
akii96 marked this pull request as ready for review November 3, 2026 10:14
@akii96
akii96 requested a review from a team November 3, 2026 10:14

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

@frida-andersson frida-andersson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Can you add the serve and bench commands to the description? A concurrency 1 point would also help, since that's where a per-layer all-reduce change shows most. And the Validation section still describes the CPU-only test with stand-in layers. Can you post the run of the current test file on this head?

Comment thread vllm/models/minimax_m3/amd/model.py Outdated
if layer_idx in self.aux_hidden_state_layers and self._aux_needs_reduce(
layer_idx
):
hidden_states = tensor_model_parallel_all_reduce(hidden_states)

@frida-andersson frida-andersson Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This adds an extra all-reduce for every EAGLE3 capture after a deferring layer: the capture reduces a copy, and the next layer's input norm then reduces the same tensor again. The NVIDIA model splits the layer into forward_input_norm and forward_after_input_norm and clones residual after the norm instead. Can you do the same here? Then _aux_needs_reduce isn't needed either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks! Split forward into forward_input_norm + forward_after_input_norm to match the NVIDIA model. The loop now captures residual.clone() after the norm has already completed the deferred all-reduce, so there's no extra all-reduce per capture. Removed _aux_needs_reduce and the _maybe_add_hidden_state override entirely.

Comment thread vllm/models/minimax_m3/amd/model.py Outdated
if residual is None:
residual = hidden_states
attn_input = self.input_layernorm(hidden_states)
elif self.fuse_input_allreduce and not self.fuse_input_norm_mxfp8:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once #65310 lands, its per-token FP8 norm (VLLM_MINIMAX_M3_FUSE_NORM_FP8=1) comes after this branch, so it would never run behind a deferring layer. Can you sync with @vorapolsiloai on the order?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped a comment on #65310 with a suggestion on ordering. I think this might land before that one so I proposed they handle the combined case on top of mine. Offered to help test the interaction, and if anything breaks I can pick it up in my follow-up perf PR that builds on this work!

Comment thread vllm/models/minimax_m3/amd/model.py Outdated
# specialized decode kernels expect reduced layer outputs.
defer_ffn_all_reduce = (
vllm_config.parallel_config.pipeline_parallel_size == 1
and not mono_envs.MONO_ENABLE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: Mono decode only turns on at TP4 without DP, PP or EP (_config_refusal), but this turns deferral off whenever the env var is set. Can the config-only checks in _config_refusal be reused here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, fixed. Now checks whether mono would actually activate (MONO_ENABLE + TP4 + DP1 + no EP) instead of just the env var.

return MiniMaxM3Model(vllm_config=vllm_config, prefix="model")


def test_each_deferred_all_reduce_completes_once(dist_init, checkpoint):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: This test and the next one only check the flags and a private helper, and the TP2 test already covers the outputs and the captures. Can we drop them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, dropped both. The TP2 test covers the real behavior



@pytest.mark.parametrize("use_aiter", [False, True])
def test_deferred_matches_reduced_at_tp2(checkpoint, monkeypatch, use_aiter):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: The reference model sets MONO_ENABLE, which imports flydsl through MonoDecode. Can you add pytest.importorskip("flydsl") like the mono test does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, thanks.

@akii96

akii96 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @frida-andersson ! Updated the PR body with the serve and bench commands, added a c1/remeasured data point on MI355X (TPOT 5.34ms vs 5.35ms, identical) since that was the node available on hand. and EAGLE3 spec decode verification. Test count is 4 after dropping the two flag-only tests per your suggestion.

@akii96
akii96 force-pushed the m3-amd-xlayer-ffn-allreduce-fusion branch from 5137667 to ae18b29 Compare November 5, 2026 10:25

@frida-andersson frida-andersson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @akii96 for the updates! I added two new comments. Also, the description says the test file gives 4 passed on CPU only, but it has three test cases now and they need ROCm GPUs. Can you post the output from this head?

Comment thread vllm/models/minimax_m3/amd/model.py Outdated
hidden_states, residual = layer.forward_input_norm(
hidden_states, residual
)
self._maybe_capture_aux(aux_hidden_states, idx, residual)

@frida-andersson frida-andersson Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like a PP stage no longer captures its end_layer, so a capture layer at a stage boundary is lost. E.g. with PP2 the second stage starts at layer 30, which is a default EAGLE3 layer, and the first step then fails with a KeyError on aux_hidden_states_1. Does it make sense to do what e.g. the NVIDIA model does here: skip idx == self.start_layer on later stages and capture self.end_layer before returning IntermediateTensors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch! Fixed it the same way the NVIDIA model does. A PP stage that is not the last one now captures end_layer before it returns, and the next stage skips its own start_layer, so each boundary layer is captured exactly once. I also added a real PP2 test that checks the first stage sends the right aux slots and the last stage only returns its own.

Comment thread vllm/models/minimax_m3/amd/model.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: It looks like the loop below now captures idx == 0 as well, so layer 0 would be captured twice if it's in the aux layers. Can we move this into the specialized decode branch, since that's the only path still using idx + 1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, done. The pre-loop capture now only runs on the specialized decode path, since that is the only one still using idx + 1. The final norm capture had the same problem in reverse on that path, so it now only runs on the normal loop. The TP2 test now captures every layer from 0 to the final norm and also runs the specialized decode loop, so a double capture at either end would fail it.

@mergify

mergify Bot commented Nov 6, 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, @akii96.

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 6, 2026
@akii96
akii96 force-pushed the m3-amd-xlayer-ffn-allreduce-fusion branch from ae18b29 to 79bd0f7 Compare November 6, 2026 11:36
@mergify mergify Bot removed the needs-rebase label Nov 6, 2026
@mergify

mergify Bot commented Nov 9, 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, @akii96.

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

…'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>
@akii96
akii96 force-pushed the m3-amd-xlayer-ffn-allreduce-fusion branch from d724a69 to ba4ee03 Compare November 11, 2026 14:58
@mergify mergify Bot removed the needs-rebase label Nov 11, 2026
@akii96

akii96 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @frida-andersson! Rebased onto main and addressed both comments. A few other fixes along the way:

  • The mono guard now reuses deployment_refusal, the same check MonoDecode runs, so they can't drift apart.
  • The MXFP8 input norm path now gets the fused all-reduce + norm kernels too, and the test covers it.
  • Without AITER the TP2 test now expects an exact match.

test_xlayer_allreduce_fusion.py gives 8 passed on this head. A serving rerun on today's nightly is within 1% of baseline with no failed requests. Description is updated.

@mergify

mergify Bot commented Nov 11, 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, @akii96.

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 11, 2026
Comment thread vllm/models/minimax_m3/amd/model.py Outdated
hidden_states, residual = layer(positions, hidden_states, residual)
self._maybe_add_hidden_state(
aux_hidden_states, idx + 1, hidden_states, residual
hidden_states, residual = layer.forward_input_norm(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The stock loop now calls forward_input_norm and forward_after_input_norm directly instead of layer(...), so forward pre-hooks on MiniMaxM3DecoderLayer no longer fire. Could you update _install/_replay, take #67038's pinned test list on rebase, and run pytest models/minimax_m3/amd_specialized_decode on this head?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, you were right: the hooks weren't firing and three tests in that file broke. Fixed in e2dfc2e. The loop calls layer(...) again, so hooks work. I also took the pinned test list from #67038. The specialized decode tests now pass (5/5).

# norm. PP ships hidden states across stages, and the mono and
# specialized decode kernels expect reduced layer outputs.
mono_decode = False
if mono_envs.MONO_ENABLE:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two paths bypass forward_input_norm and assume reduced layer outputs: the --monokernel FFN kernels (specialized_decode/runtime/executor.py:111) and mono's dense prefix (mono/runner.py:197). This gate only stays in sync with them by predicting their init-time decisions. #66184 (cc @micah-wil) deletes mono/envs.py, so this line becomes a NameError. It also sets specialized_decode_config only after make_layers, so on the obvious rebase that term is always None. With --monokernel at TP4 under the default FULL_AND_PIECEWISE, deployment_refusal refuses on piecewise but specialized decode is still built. Every layer then defers, and the kernel layers norm un-reduced partials, so decode output is silently wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, the old check was guessing too early. Fixed in e2dfc2e: with --monokernel on, deferral is now always off. If a layer ever still defers when those kernels start, the server fails at startup instead of giving wrong output. Added a test that mimics the #66184 ordering. I'll handle the envs.py removal on whichever of the two PRs lands second (cc @micah-wil).

), residual
return self.input_layernorm(hidden_states, residual)

def forward_after_input_norm(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#67072 (cc @vgokhale) adds a decode-only glue that all-reduces the MoE output inside the producer (glue/decode.py: tensor_model_parallel_all_reduce(moe_out), or an Mxfp8Carry), and its moe_half call merges cleanly into this method. Whichever lands second needs the glue to honour ffn_all_reduce_deferred, and forward_input_norm needs to handle the carry ahead of its deferred-reduce branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, if both land as-is that MoE output would be reduced twice. Whichever PR lands second should make the glue skip its all-reduce when the layer defers. Happy to do it on my side if this one lands second (cc @vgokhale).

positions = torch.arange(37, device=device)

def run(model, vllm_config):
with torch.inference_mode(), set_forward_context(None, vllm_config):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here attention runs with no metadata and returns zeros (rocm_aiter_unified_attn.py:273, triton_attn.py:629). So the input-norm output, bf16 or the new MXFP8 x_q/x_scale (model.py:1727-1738), reaches nothing that is compared; only the residual stream and the final norm are. Dropping the MXFP8 sub-branch, or passing it the wrong norm weight, still passes at rtol=0, so "bitwise ... with MXFP8 attention" in the description overstates the check. The GSM8K/NIAH runs used fp8_per_channel attention and don't reach this branch either. Yet it is M3.1's prefill path, above the one-stage fused all-reduce + norm size. Could you compare the forward_input_norm outputs of both models directly, and add one M3.1 TP4 GSM8K run?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. The test didn't actually check the input norm, and the description said more than it proved. Fixed in e2dfc2e: the test now compares each layer's input norm output directly. To make sure it catches real bugs, I broke that code path on purpose. The old test still passed, the new one fails.

M3.1 TP4 GSM8K on MI355X, which does use that path:

this PR main
run 1 0.955 0.963
run 2 0.964 0.959

Same within noise. Description updated.

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>
@mergify mergify Bot removed the needs-rebase label Nov 12, 2026
@mergify

mergify Bot commented Nov 17, 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, @akii96.

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

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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants