Repository navigation
Add MTP-only training mode - #7021
Merged
Merged
Conversation
Freeze backbone parameters and skip their autograd graph so MTP layers train with reduced optimizer and activation memory. Signed-off-by: Yaniv Galron <ygalron@nvidia.com>
svcnvidia-nemo-ci
marked this pull request as draft
September 1, 2026 14:49
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. |
YanivDorGalron
marked this pull request as ready for review
September 1, 2026 14:54
janEbert
approved these changes
Sep 1, 2026
zhongbozhu
approved these changes
Sep 1, 2026
guihong-nv
approved these changes
Sep 1, 2026
Phlip79
approved these changes
Sep 1, 2026
jaredcasper
approved these changes
Sep 1, 2026
fanshiqing
approved these changes
Sep 2, 2026
Member
|
/ok to test 3b907ec |
Signed-off-by: Yaniv Galron <ygalron@nvidia.com>
Member
|
/ok to test 0f20933 |
Signed-off-by: Yaniv Galron <ygalron@nvidia.com>
maanug-nv
reviewed
Sep 3, 2026
| return model_list | ||
|
|
||
|
|
||
| def _add_model_freeze_pre_wrap_hook(model_config, args): |
Contributor
There was a problem hiding this comment.
one nit. since only 2 settings from args are needed here, can we pass those explicitly? imo limiting state that's exposed in these small funcs keeps them focused, avoids vaguely related logic from being added just because args is available.
maanug-nv
approved these changes
Sep 3, 2026
ericharper
enabled auto-merge
September 3, 2026 01:35
Contributor
|
/ok to test 9abda94 |
Signed-off-by: Yaniv Galron <ygalron@nvidia.com>
Contributor
|
/ok to test 603059e |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/33795081261 |
4 tasks done
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.
Freeze backbone parameters and skip their autograd graph so MTP layers train with reduced optimizer and activation memory.
Description
Add
--freeze-base-model-for-mtpto train only Multi-Token Prediction (MTP) layers while keeping the base model frozen.When enabled, this change:
mtp.layers.*parameters trainabletorch.no_grad()during training--mtp-num-layersand rejects use with--freeze-all-layersThis reduces optimizer state, gradient storage, and backbone activation memory during MTP-only training.
Testing
Ran targeted tests on one GPU using
torch.distributed.run: