Use shared ModelOpt calibration loop on 0.45+ with 0.44 fallback fix - #4881
Merged
kevalmorabia97 merged 6 commits intoMay 28, 2026
Merged
Conversation
svcnvidia-nemo-ci
marked this pull request as draft
May 19, 2026 23:14
Contributor
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
|
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. |
The new modelopt 0.45 shared util get_megatron_calibration_forward_loop unifies prune/quantize calibration with pack=True. Wrap both prune.py and quantize.py with try-import + _HAS_SHARED_CALIB so they continue to work on modelopt 0.44 (inline pack=True for prune, legacy local-JSONL / HF-dataset pad+truncate for quantize) and use the shared util on 0.45+. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
kevalmorabia97
force-pushed
the
kmorabia/modelopt-calib-loop-dual-compat
branch
from
May 20, 2026 16:24
676fa82 to
ab1d17c
Compare
kevalmorabia97
marked this pull request as ready for review
May 20, 2026 16:40
Contributor
Author
|
/ok to test ab1d17c |
kevalmorabia97
requested review from
AAnoosheh,
ChenhanYu and
jenchen13
and removed request for
jenchen13
May 20, 2026 16:40
kevalmorabia97
force-pushed
the
kmorabia/modelopt-calib-loop-dual-compat
branch
from
May 21, 2026 20:31
e5be771 to
3f92796
Compare
Contributor
Author
|
/ok to test 3f92796 |
…ib-loop-dual-compat
Contributor
Author
|
/ok to test 97ba449 |
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Contributor
Author
|
/ok to test bb9b6b5 |
ChenhanYu
approved these changes
May 28, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/26588711787 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: NVIDIA/Model-Optimizer#1501
Summary
prune.pyandquantize.pynow use ModelOpt 0.45's sharedget_megatron_calibration_forward_loop(one sample per row + per-row trim + EOS-at-row-end), guarded by atry-import so 0.44 falls back to the prior inline path.--calib-dataset nemotron-post-training-dataset-v2,--calib-size 1024,--calib-max-sequence-length 4096,--calib-batch-size 1. Conservative defaults sized for MoE robustness (top-K routing → fewer tokens per expert → more samples × longer seq needed for stable amax / scoring statistics).Results
Qwen3-8B (TP=1 PP=2 prune; TP=2 PP=1 quantize). "Original" = pre-PR inline per-example calibration; "Shared" = ModelOpt 0.45 shared loop.
MMLU noise floor (binomial 2σ at acc ≈ 0.70):
Minitron prune (Qwen3-8B → 30L/3584/11776 ≈ 6B params)
pack=TrueWAR)NVFP4 quantize (
NVFP4_DEFAULT_CFG)get_calib_dataloaderpad+truncate)For reference,
hf_ptq.py(ModelOpt's HF-side path) on the same nemotron-v2 / seq=4096 / calib=512 setup reaches 5% MMLU 0.707 / Full 0.712 at bs=1 (and 0.690 / 0.706 at bs=8), confirming the M-LM and HF calibration paths agree within MMLU noise for Qwen3-8B.Takeaway: shared loop is ≥ original on every workload tested at 5% MMLU; on full MMLU the quantize gain shrinks into the ±0.78 pt noise band. The real benefits are: (1) one shared calibration surface across M-LM + M-Bridge × prune + quantize, (2) trim+EOS matches
GPTSFTDataset(add_eos=True)semantics exactly, (3) sort-by-length enables true mbs > 1 batched-forward throughput, (4) MoE-friendly conservative defaults.🤖 Generated with Claude Code