Skip to content

[ROCm] Support MiniMax-M3 NVFP4 SwiGLU-OAI - #48939

Closed
wangjiaxin99 wants to merge 5 commits into
vllm-project:mainfrom
wangjiaxin99:jiaxwang/minimax-m3-nvfp4-rocm-swiglu-oai
Closed

wangjiaxin99 wants to merge 5 commits into
vllm-project:mainfrom
wangjiaxin99:jiaxwang/minimax-m3-nvfp4-rocm-swiglu-oai

Conversation

@wangjiaxin99

@wangjiaxin99 wangjiaxin99 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

MiniMax-M3 NVFP4 ROCm SwiGLU-OAI Support

Summary

  • Allow the NVFP4 MoE emulation backend to be selected for models that set swiglu_limit.
  • Thread MiniMax-M3 swiglu_alpha and swiglu_beta metadata from Quark MoE layers into FusedMoEQuantConfig as gemm1_alpha and gemm1_beta.
  • Preserve existing behavior for backends and models that do not provide SwiGLU-OAI activation parameters.

Motivation

MiniMax-M3 uses a clamped SwiGLU-OAI activation in its MoE experts. On ROCm, Quark NVFP4 checkpoints rely on the NVFP4 emulation backend rather than native NVIDIA FP4 kernels. Before this change, models with swiglu_limit filtered the emulation backend out of the candidate backend list before support probing, so ROCm could not fall back to the path that can apply the activation parameters.

The Quark NVFP4 path also did not pass swiglu_limit, swiglu_alpha, or swiglu_beta from the layer into the shared NVFP4 MoE quant config helper. As a result, the execution backend could not receive the activation metadata needed to reproduce MiniMax-M3's MoE formula.

Implementation

The change updates the NVFP4 MoE backend oracle to treat NvFp4MoeBackend.EMULATION as clamp-capable. This lets ROCm deployments with swiglu_limit reach the emulation backend during normal backend selection.

The shared nvfp4_moe_quant_config helper now accepts optional gemm1_alpha and gemm1_beta scalar parameters and stores them in FusedMoEQuantConfig. The EMULATION branch of make_nvfp4_moe_quant_config maps layer-level swiglu_alpha and swiglu_beta to these gemm1_* fields, matching where the activation is applied: after the first MoE GEMM and before the down projection.

The Quark NVFP4 MoE method now reads swiglu_limit, swiglu_alpha, and swiglu_beta from the layer with getattr(..., None) and forwards them into the shared helper. Models without those attributes continue to use the existing None defaults.

Support Model and Accuracy

https://huggingface.co/amd/MiniMax-M3-NVFP4

Note

This is scoped to NVFP4 MoE quant config construction and Quark's NVFP4 MoE method. Existing models that do not define SwiGLU-OAI attributes continue passing None, preserving prior behavior. The main behavioral change is that EMULATION can now be selected for clamped SwiGLU NVFP4 MoE models.

@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 the rocm Related to AMD ROCm label Jul 17, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Jul 17, 2026
@tjtanaa

tjtanaa commented Jul 21, 2026

Copy link
Copy Markdown
Member

@wangjiaxin99 please provide the vllm serve command and gsm8k numshot 20 score. numshot 20 and high concurrency is to ensure that the sparse indexer logic is correct.

#!/bin/bash

MODEL=<MODEL>
NUM_FEWSHOT=${NUM_FEWSHOT:-20}
RESULT_TAG=${RESULT_TAG:-minimaxm3_numshot${NUM_FEWSHOT}_cc256}
lm_eval --model local-completions --model_args model=$MODEL,base_url=http://0.0.0.0:8001/v1/completions,num_concurrent=256,max_retries=10,max_gen_toks=2048,max_length=1048576,timeout=60000,trust_remote_code=True,temperature=0 --batch_size auto --tasks gsm8k --num_fewshot "${NUM_FEWSHOT}" \
  --output_path "./results_${RESULT_TAG}" \
  --log_samples \
| tee "lmeval_${RESULT_TAG}.log"

@tjtanaa tjtanaa self-assigned this Jul 21, 2026
@wangjiaxin99
wangjiaxin99 force-pushed the jiaxwang/minimax-m3-nvfp4-rocm-swiglu-oai branch from c5050d8 to 2bf1329 Compare July 21, 2026 06:34
Signed-off-by: jiaxwang <jiaxwang@amd.com>
@wangjiaxin99
wangjiaxin99 force-pushed the jiaxwang/minimax-m3-nvfp4-rocm-swiglu-oai branch from 2bf1329 to e15dff8 Compare July 21, 2026 06:37
@wangjiaxin99

wangjiaxin99 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@wangjiaxin99 please provide the vllm serve command and gsm8k numshot 20 score. numshot 20 and high concurrency is to ensure that the sparse indexer logic is correct.

#!/bin/bash

MODEL=<MODEL>
NUM_FEWSHOT=${NUM_FEWSHOT:-20}
RESULT_TAG=${RESULT_TAG:-minimaxm3_numshot${NUM_FEWSHOT}_cc256}
lm_eval --model local-completions --model_args model=$MODEL,base_url=http://0.0.0.0:8001/v1/completions,num_concurrent=256,max_retries=10,max_gen_toks=2048,max_length=1048576,timeout=60000,trust_remote_code=True,temperature=0 --batch_size auto --tasks gsm8k --num_fewshot "${NUM_FEWSHOT}" \
  --output_path "./results_${RESULT_TAG}" \
  --log_samples \
| tee "lmeval_${RESULT_TAG}.log"

Sure, here is the command I used. @tjtanaa

The vllm serve command matches the one documented in the model card:

vllm serve /mnt/amd/MiniMax-M3-NVFP4 \
  --trust-remote-code \
  --block-size 128 \
  --tensor-parallel-size 4 \
  --attention-backend TRITON_ATTN \
  --mm-encoder-tp-mode data \
  --mm-encoder-attn-backend ROCM_AITER_FA \
  --tool-call-parser minimax_m3 \
  --enable-auto-tool-choice \
  --reasoning-parser minimax_m3

The GSM8K accuracy for the regular evaluation is already reported in the model card:
https://huggingface.co/amd/MiniMax-M3-NVFP4#accuracy

I also ran the requested GSM8K 20-shot evaluation with high concurrency:

#!/bin/bash

MODEL=/mnt/amd/MiniMax-M3-NVFP4
NUM_FEWSHOT=${NUM_FEWSHOT:-20}
RESULT_TAG=${RESULT_TAG:-minimaxm3_numshot${NUM_FEWSHOT}_cc256}

lm_eval --model local-completions \
  --model_args model=$MODEL,base_url=http://0.0.0.0:8000/v1/completions,num_concurrent=256,max_retries=10,max_gen_toks=2048,max_length=1048576,timeout=60000,trust_remote_code=True,temperature=0 \
  --batch_size auto \
  --tasks gsm8k \
  --num_fewshot "${NUM_FEWSHOT}" \
  --output_path "./results_${RESULT_TAG}" \
  --log_samples \
  | tee "lmeval_${RESULT_TAG}.log"

Result:

Requesting API: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [04:35<00:00,  4.79it/s]
fatal: not a git repository (or any of the parent directories): .git
2026-07-21:07:26:36 INFO     [loggers.evaluation_tracker:247] Saving results aggregated
2026-07-21:07:26:36 INFO     [loggers.evaluation_tracker:119] Saving per-task samples to results_minimaxm3_numshot20_cc256/__mnt__amd__MiniMax-M3-NVFP4/*.jsonl
local-completions ({'model': '/mnt/amd/MiniMax-M3-NVFP4', 'base_url': 'http://0.0.0.0:8000/v1/completions', 'num_concurrent': 256, 'max_retries': 10, 'max_gen_toks': 2048, 'max_length': 1048576, 'timeout': 60000, 'temperature': 0}), gen_kwargs: ({}), limit: None, num_fewshot: 20, batch_size: auto
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|    20|exact_match|↑  |0.9280|±  |0.0071|
|     |       |strict-match    |    20|exact_match|↑  |0.9287|±  |0.0071|

Please let me know if you would like me to run any additional settings.

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

LGTM

@mergify mergify Bot added the quantization label Jul 23, 2026
@wangjiaxin99

Copy link
Copy Markdown
Contributor Author

Hi @tjtanaa , thanks again for the guidance.

I’ve added the requested vllm serve command and GSM8K 20-shot high-concurrency result in the earlier comment. When you get a chance, could you please let me know if there is anything else needed from my side for the review?

Thanks!

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

LGTM thanks, @tjtanaa ptal

@mergify

mergify Bot commented Aug 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, @wangjiaxin99.

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 Aug 6, 2026
Signed-off-by: wangjiaxin99 <jiaxwang@amd.com>

@tjtanaa tjtanaa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for pinging @wangjiaxin99 . LGTM.

@tjtanaa tjtanaa added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 19, 2026
@github-actions

Copy link
Copy Markdown

@wangjiaxin99, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@tjtanaa

tjtanaa commented Aug 19, 2026

Copy link
Copy Markdown
Member

/ci run

@tjtanaa
tjtanaa enabled auto-merge (squash) August 19, 2026 10:19
@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #84581 for commit 617dec5a1190.

@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Hi @wangjiaxin99, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@tjtanaa

tjtanaa commented Aug 19, 2026

Copy link
Copy Markdown
Member

@wangjiaxin99 can you fix the pre-commit

gemm1_alpha=swiglu_alpha,
gemm1_beta=swiglu_beta,
gemm1_clamp_limit=swiglu_limit,
gemm1_alpha=swiglu_alpha,

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.

duplicated from L503 above

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

maybe it's fixed in another PR? now the only thing new is unittest, the rest seems duplicated after solving merge conflict.

@mergify mergify Bot added the minimax label Aug 19, 2026
@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Hi @wangjiaxin99, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@tjtanaa
tjtanaa disabled auto-merge August 20, 2026 08:57
@mergify

mergify Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Hi @wangjiaxin99, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@wangjiaxin99

Copy link
Copy Markdown
Contributor Author

I will close this PR since this issue has been fixed in #47106

@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Aug 25, 2026
@wangjiaxin99
wangjiaxin99 deleted the jiaxwang/minimax-m3-nvfp4-rocm-swiglu-oai branch August 25, 2026 09:55
@wangjiaxin99

Copy link
Copy Markdown
Contributor Author

maybe it's fixed in another PR? now the only thing new is unittest, the rest seems duplicated after solving merge conflict.

You're right, this PR ended up duplicating changes that had already been merged. I verified that there wasn't any additional functional change beyond what's already in the codebase, so I've closed the PR. Thanks for pointing it out.

@wangjiaxin99

Copy link
Copy Markdown
Contributor Author

@wangjiaxin99 can you fix the pre-commit

Thanks for the heads-up. I checked and found that this PR was duplicating changes that had already been merged, so I've closed it. Appreciate you taking a look!

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

Labels

frontend minimax quantization ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm rust

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants