Skip to content

feat(modelopt): support real NVFP4 QAT rollout for MoE and Mamba - #2983

Merged
terrykong merged 9 commits into
NVIDIA-NeMo:mainfrom
HollowMan6:real_quant
Jul 20, 2026
Merged

feat(modelopt): support real NVFP4 QAT rollout for MoE and Mamba#2983
terrykong merged 9 commits into
NVIDIA-NeMo:mainfrom
HollowMan6:real_quant

Conversation

@HollowMan6

@HollowMan6 HollowMan6 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Add ModelOpt NVFP4 real-quant vLLM reload support for W4A16 fused-MoE & w4a4 rollout weights.

Issues

List issues that this PR closes (syntax):

Summary

  • Add Nano3-specific/Qwen3 real-quant ignore profile so Mamba, attention, gates/routers, shared experts, norms, and selected sensitive layers stay in BF16.
  • Wire Megatron real-quant refit through export_hf_weights_modelopt(..., quant_mode="w4a16_nvfp4").
  • Add Nano3/Qwen3 W4A16 & W4A4 real-quant recipe.

Usage

Run the Nano3 W4A16 real-quant rollout recipe directly:

uv run --no-sync examples/run_grpo.py \
  --config examples/configs/recipes/llm/grpo-nanov3-30ba3b-4n4g-megatron-qa-nvfp4-w4a16-real.yaml

Or enable real-quant rollout on an existing Megatron + vLLM recipe:

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

image image image image

@copy-pr-bot

copy-pr-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@HollowMan6
HollowMan6 requested a review from mxinO June 29, 2026 03:01
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Jun 29, 2026
@HollowMan6 HollowMan6 added CI:L1 Run doctests, unit tests, and functional tests Feature labels Jun 29, 2026
Comment thread nemo_rl/modelopt/models/policy/workers/megatron_quant_policy_worker.py Outdated
Comment thread nemo_rl/modelopt/models/policy/workers/megatron_quant_policy_worker.py Outdated
Comment thread nemo_rl/modelopt/models/policy/workers/megatron_quant_policy_worker.py Outdated
Comment thread nemo_rl/modelopt/models/policy/workers/utils.py Outdated
Comment thread nemo_rl/modelopt/utils.py Outdated
Comment thread nemo_rl/modelopt/models/generation/vllm_quant_patch.py Outdated
@HollowMan6
HollowMan6 requested a review from mxinO June 30, 2026 08:06
Comment thread nemo_rl/modelopt/models/generation/vllm_modelopt_patch.py Outdated
@HollowMan6
HollowMan6 force-pushed the real_quant branch 10 times, most recently from 93c66ac to be1d918 Compare July 7, 2026 21:51
@HollowMan6
HollowMan6 marked this pull request as ready for review July 11, 2026 08:46
@HollowMan6
HollowMan6 requested a review from a team as a code owner July 11, 2026 08:46
Copilot AI review requested due to automatic review settings July 11, 2026 08:46
@HollowMan6
HollowMan6 requested review from a team as code owners July 11, 2026 08:46

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@HollowMan6

Copy link
Copy Markdown
Contributor Author

/ok to test 6a982e5

@NVIDIA-NeMo NVIDIA-NeMo deleted a comment from cursor Bot Jul 17, 2026
@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 6a982e5 (PR #2983 from real_quant)

✅ Submodules that are properly updated:

Megatron-Bridge: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@NVIDIA-NeMo NVIDIA-NeMo deleted a comment from github-actions Bot Jul 17, 2026
@terrykong
terrykong requested a review from sharonyu-115 July 18, 2026 01:06

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sharonyu-115 to review

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 62c766b (PR #2983 from real_quant)

✅ Submodules that are properly updated:

Megatron-Bridge: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice feature — this closes out the real-quant rollout story from #1750, and the switch from the broad vLLM monkeypatch to registering ModelOpt NVFP4 through vLLM's public quantization registry (plus the new design doc) is a real improvement over the earlier revision.

This review was done by a multi-agent pass (6 agents) at head 62c766b. Summary of what was checked and found clean, plus a few informational notes:

  • Existing review threads: all 12 inline threads from @mxinO and @zhangyimi were verified as resolved at the current head (nano3 quant configs net-reverted, monkeypatch removed, backend selection moved into get_forward_loop_func(), rank-0 stale-cache warning added, etc.).
  • Verified clean: every vLLM 0.20.0 internal symbol used by vllm_modelopt.py/vllm_quant_backend.py was checked against the pinned wheel (incl. the retain-MoE-kernel-across-layerwise-reload design and the manual a1_gscale/a2_gscale copy-back — both correct); the Megatron-Bridge submodule bump (fast-forward, required for native w4a16_nvfp4 export) and modelopt 0.46.0.dev86 bump were verified required; 174 unit tests from the PR pass locally; pre-commit run --all-files passes at the PR head.
  • Super-120B recipes: the two 16-node real-quant recipes are registered as BF16/real-quant comparison smokes with no convergence claim — fine as-is; consider adding an evidence-table row in docs/guides/quantization-aware-rl.md once those runs complete.
  • Sibling PR heads-up: open PR #3012 (Simulated KV cache QARL) touches 6 of the same files, including vllm_quant_backend.py and megatron_quant_policy_worker.py — worth coordinating merge order to keep rebases cheap.

Inline comments: 5 for a dead-negative-assertion pattern in the new recipe scripts (with click-applyable fixes) and 2 for stale quant-config filenames in the guide.

Generated by Claude Code

Comment thread tests/test_suites/llm/grpo-nanov3-30ba3b-4n4g-megatron-qa-nvfp4-w4a16-real.sh Outdated
Comment thread tests/test_suites/llm/grpo-qwen3-30ba3b-4n4g-megatron-qa-nvfp4-w4a4-real.sh Outdated
Comment thread docs/guides/quantization-aware-rl.md Outdated
Comment thread nemo_rl/modelopt/models/generation/vllm_modelopt.py Outdated
Comment thread nemo_rl/modelopt/models/generation/vllm_modelopt.py
Comment thread nemo_rl/modelopt/models/generation/vllm_modelopt.py
Comment thread docs/design-docs/modelopt-real-quant-architecture.md Outdated
@HollowMan6

Copy link
Copy Markdown
Contributor Author

/ok to test 81c44aa

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 81c44aa (PR #2983 from real_quant)

✅ Submodules that are properly updated:

Megatron-Bridge: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

Comment thread nemo_rl/modelopt/models/generation/vllm_modelopt.py
@zhangyimi

Copy link
Copy Markdown

I reviewed the W4A4-related changes, and the implementation looks good to me. The training curves also look healthy. LGTM aside from the one remaining comment.

Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
Signed-off-by: Hollow Man <hollowman@opensuse.org>
@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 66c5545 (PR #2983 from real_quant)

✅ Submodules that are properly updated:

Megatron-Bridge: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@HollowMan6

Copy link
Copy Markdown
Contributor Author

/ok to test 66c5545

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

Labels

CI:L1 Run doctests, unit tests, and functional tests Documentation Improvements or additions to documentation Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support QAT for low precision RL

5 participants