Repository navigation
Modernize post-training modelopt example scripts - #4807
Merged
kevalmorabia97 merged 13 commits intoMay 19, 2026
Merged
kevalmorabia97 merged 13 commits into
kevalmorabia97 merged 13 commits into
Conversation
|
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. |
kevalmorabia97
marked this pull request as ready for review
May 14, 2026 20:48
Contributor
Author
|
/ok to test 0f67913 |
kevalmorabia97
force-pushed
the
kmorabia/modelopt-examples-modernize
branch
from
May 15, 2026 13:55
f6e9eda to
e814b3c
Compare
kevalmorabia97
force-pushed
the
kmorabia/modelopt-examples-modernize
branch
from
May 15, 2026 14:44
e814b3c to
0edcc20
Compare
kevalmorabia97
requested review from
AAnoosheh,
jenchen13,
yeyu-nvidia and
yueshen2016
May 15, 2026 15:26
Contributor
Author
|
/ok to test 239971b |
kevalmorabia97
marked this pull request as draft
May 15, 2026 16:05
kevalmorabia97
force-pushed
the
kmorabia/modelopt-examples-modernize
branch
from
May 15, 2026 16:06
239971b to
5753fc1
Compare
Contributor
Author
|
/ok to test 5753fc1 |
janEbert
previously requested changes
May 19, 2026
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
kevalmorabia97
force-pushed
the
kmorabia/modelopt-examples-modernize
branch
from
May 19, 2026 17:09
6f9eecf to
83d287e
Compare
yaoyu-33
approved these changes
May 19, 2026
jaredcasper
reviewed
May 19, 2026
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Contributor
Author
|
/ok to test e60e95f |
jaredcasper
approved these changes
May 19, 2026
janEbert
approved these changes
May 19, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/26124136128 |
This branch was previously deployed
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.
What does this PR do?
Modernize
examples/post_training/modelopt/to use ModelOpt's plugin utilities, Adds a smallmegatron/core/refactor so pruning can use the default full Transformer Engine spec withoutmoe_grouped_gemm.Summary
Pruning (
prune.py,prune.sh,README.md)--prune-export-config '<json>'arg replaces the nine--target-*flags.--layers-to-dropremoved (usenum_layersin the export config).modelopt.torch.utils.plugins.megatron_prefill(..., skip_return_logits=True); prompt verification usesmegatron_generate.calib_max_sequence_lengthchunks instead of relying onget_dataset_dataloader's truncate-and-pad path (eliminates padding-token noise / discarded long-document context; +5.8 pts MMLU vs. unpacked on Qwen3-8B 30L/3584/11776). Revert once 0.45 ships with the upstream fix.layer_norm_weightfrom HF post-import for GPT-family models (_load_fused_norms_from_hf_war). Modelopt ≤ 0.44 only handles fused norms for Nemotron-H._gated_mlp_merging_war(modelopt ≤ 0.44 strict-load fix).nemotron-post-training-dataset-v2(gated; richer multi-domain signal than the previouscnn_dailymail).args.moe_grouped_gemm = False; default--prune-intermediate-ckptto<save>/modelopt_pruning_scores;prune.shswitches--export-te-mcore-model→--export-default-te-spec.MMLU evaluation (
mmlu.py)modelopt.torch.utils.plugins.megatron_mmlu(batched prefill + log-likelihood scoring; much faster than the previous diskcache + per-subject autoregressive loop).--few-shots,--mmlu-batch-size.--disable-tqdm/--mmlu-datasetkept as silent BW-compat no-ops.broadcast_from_last_pipeline_stagenon-contiguous assertion under SP + TP (fixed upstream in 0.45).Generation / Quantization (
generate.py,quantize.py,megatron/post_training/generate.py)simple_generate→megatron_generateon all text-gen paths; calibration usesmegatron_prefill(skip_return_logits=True).simple_speculative_generaterewired throughmegatron_generate(enable_kv_cache=False)— incidentally fixes a latentposition_idsbug (arange(shape[0])was using batch size).simple_generatedeleted —megatron_generate/megatron_prefillcover every prior call site. Module loses several transitive deps.nemotron-post-training-dataset-v2(matches prune.py).Core refactor (
megatron/core/,megatron/post_training/model_builder.py)get_hybrid_stack_spec(moe_grouped_gemm: bool = True)factory inhybrid_layer_specs.py; module-levelhybrid_stack_spec/mamba_stack_specpreserved.get_hybrid_stack_modelopt_specthreadsmoe_grouped_gemmto the factory whenuse_default_te_spec=True.modelopt_gpt_hybrid_builder's GPT branch honours--export-default-te-spec(was hybrid-only) and forwardsargs.moe_grouped_gemm.Upstream consumers
WARs above are temporary; the matching modelopt 0.45 fixes are in Model-Optimizer PR #1501. Once 0.45 ships and the modelopt pin is bumped, the prune.py / mmlu.py WARs can be removed.
Pre-checks
tools/autoformat.shrun (black + isort + ruff + pylint + mypy)cc @mcore-oncall