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

Fix lr scheduler state not being dumped to checkpoint in deepspeed strategy #11307

Merged
merged 5 commits into from Jan 5, 2022

Conversation

awaelchli
Copy link
Member

@awaelchli awaelchli commented Jan 4, 2022

What does this PR do?

Part of #11188

The added assertion fails on master.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

I made sure I had fun coding 🙃

Part of #1 (it's a lie, this is just here to avoid noisy GitHub bot)

cc @Borda @SeanNaren @awaelchli @rohitgr7

@awaelchli awaelchli changed the title fix deepspeed lr scheduler state dumping Fix lr scheduler state not being dumped to checkpoint in deepspeed strategy Jan 4, 2022
@awaelchli awaelchli added strategy: deepspeed bug Something isn't working labels Jan 4, 2022
@awaelchli awaelchli added this to the 1.5.x milestone Jan 4, 2022
Copy link
Contributor

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this @awaelchli. I assume based on the logic, the scheduler will be loaded if found in the state dict elsewhere in the code

@mergify mergify bot added the ready PRs ready to be merged label Jan 4, 2022
@awaelchli awaelchli enabled auto-merge (squash) January 4, 2022 13:01
@mergify mergify bot added the has conflicts label Jan 4, 2022
@mergify mergify bot removed the has conflicts label Jan 4, 2022
@tridao
Copy link
Contributor

tridao commented Jan 4, 2022

Thanks for fixing this @awaelchli. I assume based on the logic, the scheduler will be loaded if found in the state dict elsewhere in the code

I'm not sure that's the case, since the Deepspeed plugin has lightning_restore_optimizer_and_schedulers set to False.
Would the checkpoint_connector ignore the lr_schedulers key when restoring?

def restore_optimizers_and_schedulers(self) -> None:
        """Restores the optimizers and learning rate scheduler states from the pre-loaded checkpoint."""
        if not self._loaded_checkpoint or not self.trainer.strategy.lightning_restore_optimizer_and_schedulers:
            return

@awaelchli
Copy link
Member Author

Yes you are right, this needs to be taken care of too.

@eelxpeng
Copy link

eelxpeng commented Jan 4, 2022

Right. I tried with current commits. Though lr_schedulers are saved, the lr_scheduler state will not be restored.

@codecov
Copy link

codecov bot commented Jan 5, 2022

Codecov Report

Merging #11307 (395d62a) into master (7eab379) will decrease coverage by 4%.
The diff coverage is 0%.

@@           Coverage Diff            @@
##           master   #11307    +/-   ##
========================================
- Coverage      92%      88%    -4%     
========================================
  Files         194      194            
  Lines       16965    16965            
========================================
- Hits        15593    14960   -633     
- Misses       1372     2005   +633     

@awaelchli awaelchli merged commit a8bd7ac into master Jan 5, 2022
@awaelchli awaelchli deleted the bugfix/deepspeed-lr branch January 5, 2022 08:38
leezu pushed a commit to leezu/pytorch-lightning that referenced this pull request Jan 27, 2022
leezu pushed a commit to leezu/pytorch-lightning that referenced this pull request Jan 28, 2022
leezu pushed a commit to leezu/pytorch-lightning that referenced this pull request Feb 3, 2022
leezu pushed a commit to leezu/pytorch-lightning that referenced this pull request Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged strategy: deepspeed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants