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

Add MCore FSDP2 support #11216

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

Add MCore FSDP2 support #11216

wants to merge 20 commits into from

Conversation

BoxiangW
Copy link
Collaborator

@BoxiangW BoxiangW commented Nov 7, 2024

What does this PR do ?

Add MCore FSDP2 support

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)

@BoxiangW BoxiangW self-assigned this Nov 8, 2024
@BoxiangW BoxiangW added feature request/PR for a new feature Run CICD labels Nov 8, 2024
@BoxiangW BoxiangW added Run CICD and removed Run CICD labels Nov 8, 2024
@BoxiangW BoxiangW added Run CICD and removed Run CICD labels Nov 8, 2024
@@ -193,6 +195,7 @@ def __init__(
ckpt_load_optimizer: bool = True,
ckpt_save_optimizer: bool = True,
ddp: Union[DDPLiteral, DistributedDataParallelConfig] = "megatron",
fsdp: bool = False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we rename it torch_fsdp because we know we'll have mcore_fsdp eventually?

Copy link
Collaborator Author

@BoxiangW BoxiangW Nov 22, 2024

Choose a reason for hiding this comment

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

Do you think we can make this arg a string? ['mcore', 'torch'] or None.
Or expand this arg to fsdp defualts to false, and use_torch_fsdp defaults to false?
So:
fsdp=Ture, use_torch_fsdp=True -> torch_fsdp
fsdp=Ture -> mcore_fsdp (to be supported)
nothing -> ddp

Just trying to make the interface less confusing?

@BoxiangW BoxiangW marked this pull request as ready for review November 22, 2024 23:17
Copy link
Contributor

github-actions bot commented Dec 2, 2024

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:153:0: C0301: Line too long (123/119) (line-too-long)
nemo/lightning/megatron_parallel.py:249:0: C0301: Line too long (127/119) (line-too-long)
nemo/lightning/megatron_parallel.py:250:0: C0301: Line too long (140/119) (line-too-long)
nemo/lightning/megatron_parallel.py:251:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/megatron_parallel.py:557:0: C0301: Line too long (129/119) (line-too-long)
nemo/lightning/megatron_parallel.py:564:0: C0301: Line too long (135/119) (line-too-long)
nemo/lightning/megatron_parallel.py:862:0: C0301: Line too long (137/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1092:0: C0301: Line too long (136/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1659:0: C0301: Line too long (128/119) (line-too-long)
nemo/lightning/megatron_parallel.py:1698: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:317:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:341:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:367:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:393:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:529: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:639:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:675:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:682:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:716:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:724:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:740:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:767:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:779:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:801:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:810:4: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:832:8: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1352:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1527:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1533: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:1543:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1548:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1553:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1581:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1627:8: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1649:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1722:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/megatron_parallel.py:1761:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/megatron_parallel.py:1775:0: C0116: Missing function or method docstring (missing-function-docstring)

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

Thank you for improving NeMo's documentation!

from megatron.core.distributed import TorchFullyShardedDataParallel as McoreTorchFSDP

HAVE_MCORE_TORCH_FSDP2 = True
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request/PR for a new feature Run CICD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants