Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid init_ddp for inference #12011

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Avoid init_ddp for inference #12011

wants to merge 6 commits into from

Conversation

athitten
Copy link
Collaborator

@athitten athitten commented Jan 31, 2025

What does this PR do ?

Uses PTL's Enum TrainerFn to check if the stage is TESTING or not and skips init_ddp in nemo/lightning/megatron_parallel.py if TESTING as it can cause OOM during inference.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@athitten athitten assigned cuichenx and unassigned cuichenx Jan 31, 2025
Copy link
Contributor

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.lightning.megatron_parallel
nemo/lightning/megatron_parallel.py:246:0: C0301: Line too long (127/119) (line-too-long)
nemo/lightning/megatron_parallel.py:247:0: C0301: Line too long (140/119) (line-too-long)
nemo/lightning/megatron_parallel.py:248:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/megatron_parallel.py:555:0: C0301: Line too long (129/119) (line-too-long)
nemo/lightning/megatron_parallel.py:562:0: C0301: Line too long (135/119) (line-too-long)
nemo/lightning/megatron_parallel.py:852:0: C0301: Line too long (137/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1082:0: C0301: Line too long (136/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1655:0: C0301: Line too long (128/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1694:0: C0301: Line too long (146/119) (line-too-long)
nemo/lightning/megatron_parallel.py:72:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:75:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:110:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:114:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:338:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:364:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:390:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:526:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:572:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:576:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:642:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:677:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:683:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:689:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:696:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:703:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:737:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:745:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:761:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:788:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:800:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:822:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1348:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1523:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1529:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1535:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1539:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1544:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1549:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1577:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1623:8: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1645:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1718:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1764:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1778:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.strategies.megatron_strategy
nemo/lightning/pytorch/strategies/megatron_strategy.py:299:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.54/10

Mitigation guide:

  • Add sensible and useful docstrings to functions and methods
  • For trivial methods like getter/setters, consider adding # pylint: disable=C0116 inside the function itself
  • To disable multiple functions/methods at once, put a # pylint: disable=C0116 before the first and a # pylint: enable=C0116 after the last.

By applying these rules, we reduce the occurance of this message in future.

Thank you for improving NeMo's documentation!

cuichenx
cuichenx previously approved these changes Feb 3, 2025
Copy link
Collaborator

@cuichenx cuichenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified working. thanks!

@athitten athitten added Run CICD and removed Run CICD labels Feb 3, 2025
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.30%. Comparing base (48f10af) to head (b9b5c61).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12011      +/-   ##
==========================================
- Coverage   30.30%   30.30%   -0.01%     
==========================================
  Files        1387     1387              
  Lines      176283   176285       +2     
  Branches    27091    27092       +1     
==========================================
  Hits        53422    53422              
- Misses     118775   118777       +2     
  Partials     4086     4086              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@athitten athitten force-pushed the athitten/inference_bug branch from b9b5c61 to d637242 Compare February 4, 2025 23:43
@athitten athitten added Run CICD and removed Run CICD labels Feb 4, 2025
Signed-off-by: Abhishree <[email protected]>
Signed-off-by: Abhishree <[email protected]>
@athitten athitten added Run CICD and removed Run CICD labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants