refactor: avoid requiring Megatron for model_utils import#2540
Draft
alexbowe wants to merge 2 commits into
Draft
refactor: avoid requiring Megatron for model_utils import#2540alexbowe wants to merge 2 commits into
alexbowe wants to merge 2 commits into
Conversation
6d3ea98 to
a282964
Compare
Signed-off-by: alexbowe <abowe@nvidia.com>
a282964 to
060555d
Compare
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 ?
Defers Megatron imports in
nemo_rl.distributed.model_utils, so non-Megatron import paths can load the module without requiring the Megatron stack.This is useful because
model_utilsis a broad utility module: importing it should not force every environment, test, or non-Megatron workflow to have Megatron available.Changes:
model_utilsmodule scope.GPTModeltype annotation available to type checkers without importing Megatron at runtime.model_utils.Issues
N/A
Usage
No user-facing API change.
Before your PR is "Ready for review"
Pre checks:
Additional Information
Validation:
PYTHONPYCACHEPREFIX=/tmp/codex-pycache python3 -m py_compile nemo_rl/distributed/model_utils.py tests/unit/distributed/test_model_utils_imports.pygit diff --checkPYTHONPATH=. python -m pytest --confcutdir=tests/unit/distributed tests/unit/distributed/test_model_utils_imports.py -qpassed:1 passed in 1.52sClaude adversarial review found no blockers.