Various ModelOpt fixes: QAD test for CICD, use model builder config instead of model provider, allow loading teacher ckpt independently of student - #4520
Merged
Conversation
AAnoosheh
force-pushed
the
aanoosheh/qad-cicd-test
branch
from
May 11, 2026 13:04
cb52062 to
d06c767
Compare
|
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
approved these changes
Jun 22, 2026
AAnoosheh
force-pushed
the
aanoosheh/qad-cicd-test
branch
from
June 23, 2026 18:57
b856371 to
9c75554
Compare
jenchen13
approved these changes
Jun 24, 2026
chtruong814
approved these changes
Jul 1, 2026
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Contributor
Author
|
/ok to test 99f386d |
yaoyu-33
approved these changes
Jul 6, 2026
jaredcasper
reviewed
Jul 7, 2026
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Contributor
Author
|
/ok to test 5d57b6c |
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
….py/pretrain_hybrid.py Per Jared/Maanu feedback in review: ModelOpt-specific branching doesn't belong in the shared ModelConfig base class (base.py's get_builder_cls() was checking args.modelopt_enabled and swapping in ModelOptModelBuilder for every config type). Revert base.py entirely - it is now byte-for-byte identical to NVIDIA/Megatron-LM main again. Instead: - Add ModelOptModelConfig(GPTModelConfig) and ModelOptHybridModelConfig (HybridModelConfig) in post_training/model_builder.py, each overriding only the `builder` ClassVar - construction still goes through gpt_config_from_args/hybrid_config_from_args, which now take an optional model_config_cls to build a compatible subclass without duplicating arg-derivation logic. - Their builders (ModelOptModelBuilder/ModelOptHybridModelBuilder) share a `build_model()` override via `_ModelOptBuildModelMixin`, since modelopt_gpt_hybrid_builder already dispatches on args.export_model_type internally - but each is tied to its own proper parent (GPTModelBuilder/HybridModelBuilder respectively) for build_distributed_models(), rather than both piggybacking on GPTModelBuilder's. - pretrain_gpt.py's and pretrain_hybrid.py's __main__ blocks now select the ModelOpt config vs the plain one based on args.modelopt_enabled, right after parse_and_validate_args() - this works now that args is available in __main__ before pretrain() is called. - maybe_enable_modelopt (the args.modelopt_enabled detection, previously private to training.py) now lives in megatron.post_training.utils, alongside print_distributed_quant_summary - both need modelopt installed at import time, so it's a natural fit. training.py imports it once at module level (in the same try/except as get_tensor_shapes_adjust_fn_for_distillation) and both call sites just guard the call with `if has_nvidia_modelopt:`. pretrain_gpt.py and pretrain_hybrid.py pick it up via the same try/except block they already use for add_modelopt_args. Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com> # Conflicts: # megatron/post_training/checkpointing.py
Contributor
Author
|
/ok to test ad86d92 |
maanug-nv
reviewed
Jul 8, 2026
maanug-nv
approved these changes
Jul 8, 2026
maanug-nv
left a comment
Contributor
There was a problem hiding this comment.
lgtm overall now. left one minor suggestion
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
Contributor
Author
|
/ok to test 0f680d9 |
deepakn94
approved these changes
Jul 14, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29343732328 |
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 ?
Adds a new functional test for testing PTQ + KD in succession using Model Optimizer.
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
Code review
Feel free to message or comment the @mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.
For MRs into `dev` branch
The proposed review process for `dev` branch is under active discussion.MRs are mergable after one approval by either
eharper@nvidia.comorzijiey@nvidia.com.