Skip to content

Leave MTP layers unquantized at any depth in the default PTQ exclusions - #2911

Merged
kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/disable-megatron-vlm-mtp-quant
Oct 21, 2026
Merged

kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/disable-megatron-vlm-mtp-quant

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Bug fix

The default PTQ exclusions (configs/ptq/units/default_disabled_quantizers, imported by the general/ptq/* recipes and mtq.*_CFG presets) disable multi-token-prediction layers with mtp.*, which only matches an MTP block at the model root (HF checkpoints, Megatron LLMs). Megatron vision-language models nest it under the language model (language_model.mtp.layers.0...), so their MTP layers were quantized. For Qwen3.5/3.6 VLMs quantized with examples/megatron_bridge/quantize.py and a general recipe, export_quantized_megatron_to_hf.py --vllm_fakequant_export then refuses the checkpoint ("MTP quantization is not supported by vLLM fakequant export/reload"). The pattern is now *mtp.*, matching the model-specific recipes that already use *mtp*.

Models whose MTP block was nested and previously quantized by a general recipe now keep it in BF16, which is what the exclusion intends. Recipes that quantize MTP on purpose (e.g. the Nemotron 3.5 Super ones) do not import this unit after their MTP entries, so they are unaffected.

Usage

No API change.

Testing

  • New tests/unit/recipe/test_presets.py::test_default_exclusions_disable_mtp_at_any_depth: with general/ptq/fp8_default-kv_fp8, MTP quantizers at the root and under language_model. are disabled and decoder quantizers stay enabled; fails without the change.
  • tests/unit/recipe: 492 passed.
  • Found while validating vLLM fake-quant export of Qwen3.6-35B-A3B ([2/2] Export vLLM fake-quant checkpoints through Megatron-Bridge #2889): the default nvfp4_default-kv_fp8 checkpoint was refused on language_model.mtp.layers.0.eh_proj.input_quantizer.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅ (nested MTP layers that a general recipe used to quantize now stay in BF16, as the exclusion intends)
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: ✅
  • Did you update Changelog?: ✅
  • Did you get Claude approval on this PR?: ❌

Additional Information

Related to #2889 (vLLM fake-quant export through Megatron-Bridge).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Corrected default post-training quantization recipes for Megatron vision-language models so MTP layers remain unquantized consistently, including nested language-model layers.
    • Preserved quantization behavior for unrelated decoder projection layers.
    • Added regression coverage to verify both root-level and nested MTP exclusions in the default FP8 recipe.
  • Documentation

    • Added a changelog entry for the 0.49.0 bug fix.

The default exclusions matched only a root-level mtp.* block, so Megatron vision-language models
(language_model.mtp.*) had their MTP layers quantized by the general recipes, and the vLLM
fake-quant export then refused the checkpoint. Match *mtp.* instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97
kevalmorabia97 requested review from a team as code owners October 21, 2026 09:00
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 8aa3faf1-effe-4ca2-90c6-bfeef3ebf92b
📥 Commits

Reviewing files that changed from the base of the PR and between 11c2a85 and 6373a69.

📒 Files selected for processing: 3
  • CHANGELOG.rst
  • modelopt_recipes/configs/ptq/units/default_disabled_quantizers.yaml
  • tests/unit/recipe/test_presets.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📝 Walkthrough

The default PTQ recipe now disables quantizers for MTP modules at the root level and under language_model. A regression test verifies that a nested decoder quantizer remains enabled.

Changes: Default MTP quantizer exclusions

Layer / File(s) Summary
Broaden and validate the MTP exclusion
modelopt_recipes/configs/ptq/units/default_disabled_quantizers.yaml, tests/unit/recipe/test_presets.py, CHANGELOG.rst
The disabled quantizer pattern now matches names with prefixes before mtp. The regression test checks root-level and nested MTP exclusions and confirms that a nested decoder quantizer remains enabled. The changelog records the change.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 6373a

The change correctly preserves quantization for decoder modules while excluding root-level and nested MTP modules.

Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: excluding MTP layers from default PTQ quantization at any nesting depth.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns Passed PASS. The pull request changes only CHANGELOG.rst, one YAML recipe, and a unit test. It adds no Python changes under modelopt or examples and no dependency-manifest changes. The added test contains no…
Full details: Security Anti-Patterns

Explanation

PASS. The pull request changes only CHANGELOG.rst, one YAML recipe, and a unit test. It adds no Python changes under modelopt or examples and no dependency-manifest changes. The added test contains no torch.load, numpy.load(..., allow_pickle=True), trust_remote_code=True, external-input eval/exec, or # nosec pattern. SECURITY.md also excludes tests from these contributor rules.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.82%. Comparing base (576c66f) to head (6373a69).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2911      +/-   ##
==========================================
+ Coverage   70.08%   78.82%   +8.74%     
==========================================
  Files         659      659              
  Lines       74081    74081              
==========================================
+ Hits        51917    58392    +6475     
+ Misses      22164    15689    -6475     
Flag Coverage Δ
examples-diffusers 20.04% <ø> (-0.01%) ⬇️
examples-gpt-oss 13.51% <ø> (-0.01%) ⬇️
examples-hf_ptq 23.19% <ø> (-0.04%) ⬇️
examples-llm_distill 13.59% <ø> (-0.01%) ⬇️
examples-llm_eval 17.24% <ø> (+<0.01%) ⬆️
examples-llm_qat 17.48% <ø> (-0.01%) ⬇️
examples-llm_sparsity 15.76% <ø> (-0.01%) ⬇️
examples-megatron_bridge 26.43% <ø> (-0.13%) ⬇️
examples-specdec_bench 13.29% <ø> (-0.01%) ⬇️
examples-speculative_decoding 17.47% <ø> (-0.01%) ⬇️
examples-torch_onnx 21.39% <ø> (-0.01%) ⬇️
examples-torch_trt 15.24% <ø> (-0.01%) ⬇️
examples-vllm_serve 15.08% <ø> (-0.01%) ⬇️
gpu 59.23% <ø> (+37.10%) ⬆️
unit 60.59% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Bot review (gpt-6.1-sol) — DM the bot to share feedback.

Approve: the shared exclusion now matches root and nested MTP layers, and the regression test verifies decoder quantization remains enabled.

No action needed.

@kevalmorabia97
kevalmorabia97 enabled auto-merge (squash) October 21, 2026 09:12
@kevalmorabia97
kevalmorabia97 merged commit af6d7d9 into main Oct 21, 2026
74 of 76 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/disable-megatron-vlm-mtp-quant branch October 21, 2026 10:00
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-21 10:00 UTC

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants