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

[NeMo-UX] Add option to drop optimizer states #11089

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

Conversation

ashors1
Copy link
Collaborator

@ashors1 ashors1 commented Oct 29, 2024

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

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)

@ashors1 ashors1 changed the title Add option to drop optimizer states to NeMo 2.0 [NeMo-UX] Add option to drop optimizer states Oct 29, 2024
Copy link
Collaborator

@mikolajblaz mikolajblaz left a comment

Choose a reason for hiding this comment

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

Thanks @ashors1 for implementing this.

The bucketing part is correct (some naming comments). I would suggest to implement the optimizer files removal which ensures consistent checkpoint and is checkpoint format specific (impl in MCore) as mentioned in one of the (lengthy) comments. Thanks!

nemo/lightning/io/pl.py Outdated Show resolved Hide resolved
nemo/lightning/pytorch/callbacks/model_checkpoint.py Outdated Show resolved Hide resolved
nemo/lightning/pytorch/callbacks/model_checkpoint.py Outdated Show resolved Hide resolved
ashors1 and others added 2 commits November 8, 2024 12:20
@@ -498,6 +525,9 @@ def _save_checkpoint(self, trainer: 'pytorch_lightning.Trainer', filepath: str)
else:
finalize_fn()

if self.save_last_n_optim_states >= 0 and '-last' in filepath:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering (not sure) if this shouldn't be inside the finalize_fn? So called only after current checkpoint was actually finalized

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it makes sense to add it to the finalize function so that we always ensure we have at least n checkpoints with optimizer states. I made this change.

ashors1 and others added 13 commits November 15, 2024 11:23
Signed-off-by: ashors1 <[email protected]>
This reverts commit 868908e.
Signed-off-by: ashors1 <[email protected]>
Signed-off-by: ashors1 <[email protected]>
Signed-off-by: ashors1 <[email protected]>
Signed-off-by: ashors1 <[email protected]>
Signed-off-by: ashors1 <[email protected]>
…VIDIA/NeMo into ashors/nemo-ux-drop-optim-states-async
@ashors1 ashors1 marked this pull request as ready for review December 2, 2024 02:14
@github-actions github-actions bot added the NLP label Dec 2, 2024
@ashors1 ashors1 removed the Run CICD label Dec 2, 2024
@github-actions github-actions bot removed the CI label Dec 5, 2024
@ashors1 ashors1 added Run CICD and removed Run CICD labels Dec 5, 2024
dimapihtar
dimapihtar previously approved these changes Dec 5, 2024
Copy link
Collaborator

@dimapihtar dimapihtar left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you!

Signed-off-by: ashors1 <[email protected]>
ashors1 and others added 5 commits December 6, 2024 09:16
@ashors1 ashors1 added Run CICD and removed Run CICD labels Dec 6, 2024
@ashors1 ashors1 added Run CICD and removed Run CICD labels Dec 6, 2024
Signed-off-by: ashors1 <[email protected]>
@ashors1 ashors1 added Run CICD and removed Run CICD labels Dec 6, 2024
Copy link
Contributor

github-actions bot commented Dec 6, 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.io.pl
nemo/lightning/io/pl.py:82:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/io/pl.py:58:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/io/pl.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:304:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:309:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.callbacks.model_checkpoint
nemo/lightning/pytorch/callbacks/model_checkpoint.py:675:0: C0301: Line too long (146/119) (line-too-long)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:115:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:255:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:262:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:266:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:279:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:22:0: W0611: Unused import lightning.pytorch (unused-import)

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

Thank you for improving NeMo's documentation!

Signed-off-by: ashors1 <[email protected]>
@ashors1 ashors1 added Run CICD and removed Run CICD labels Dec 6, 2024
Copy link
Contributor

github-actions bot commented Dec 6, 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.io.pl
nemo/lightning/io/pl.py:82:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/io/pl.py:58:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/io/pl.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:304:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:309:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.callbacks.model_checkpoint
nemo/lightning/pytorch/callbacks/model_checkpoint.py:675:0: C0301: Line too long (146/119) (line-too-long)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:115:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:255:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:262:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:266:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:279:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:22:0: W0611: Unused import lightning.pytorch (unused-import)

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

Thank you for improving NeMo's documentation!

2 similar comments
Copy link
Contributor

github-actions bot commented Dec 6, 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.io.pl
nemo/lightning/io/pl.py:82:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/io/pl.py:58:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/io/pl.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:304:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:309:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.callbacks.model_checkpoint
nemo/lightning/pytorch/callbacks/model_checkpoint.py:675:0: C0301: Line too long (146/119) (line-too-long)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:115:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:255:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:262:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:266:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:279:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:22:0: W0611: Unused import lightning.pytorch (unused-import)

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

Thank you for improving NeMo's documentation!

Copy link
Contributor

github-actions bot commented Dec 6, 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.io.pl
nemo/lightning/io/pl.py:82:0: C0301: Line too long (130/119) (line-too-long)
nemo/lightning/io/pl.py:58:0: C0115: Missing class docstring (missing-class-docstring)
nemo/lightning/io/pl.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:304:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:309:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/io/pl.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.callbacks.model_checkpoint
nemo/lightning/pytorch/callbacks/model_checkpoint.py:675:0: C0301: Line too long (146/119) (line-too-long)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:115:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:255:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:262:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:266:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:279:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/callbacks/model_checkpoint.py:22:0: W0611: Unused import lightning.pytorch (unused-import)

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

Thank you for improving NeMo's documentation!

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