Fix MIMO optimizer setup for frozen modules#4790
Draft
liding-nv wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Li Ding <liding@nvidia.com>
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 ?
Problem
get_mimo_optimizer builds an inner optimizer for every non-None module on the local rank, even when that module has zero trainable parameters (e.g. a fully frozen vision encoder during projector-only training). The resulting placeholder optimizers crash later in setup. The wider
_get_param_groupspath also all-gathers param-group keys over the WORLD group, which doesn't match the per-module optimizer group MIMO operates on.Changes
megatron/core/models/mimo/optimizer.py: add_module_has_any_trainable_parameters(module, pg_collection.intra_dist_opt)— an all-reduce-MAX over the module's optimizer group of the local trainable-param count. Skip the optimizer build when no rank in the group has trainable parameters.megatron/core/optimizer/__init__.py: add an optionalprocess_group=Nonekwarg to_get_param_groups/_get_param_groups_and_buffers, plumbed through_get_megatron_emerging_optimizerandget_megatron_optimizer, so the cross-rankall_gather_object(params_key, …)can target a specific group (MIMO passesintra_dist_opt). Default None preserves current behavior for every existing caller.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.