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] Add a cluster environment teardown to clean up environment state #6942

Merged
merged 7 commits into from
Apr 15, 2021

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Apr 10, 2021

What does this PR do?

Discussion in #6853
Fixes part of #6303

https://github.com/PyTorchLightning/pytorch-lightning/blob/f852a4f5925211d6bb9dac231b9185e3e6814b13/pytorch_lightning/plugins/training_type/ddp.py#L283-L285

This is a bug for users who have subsequent calls to

trainer.fit(...)
trainer.test(...)

and who launched with torchelastic. The world size environment variable is mistakenly removed, causing the trainer.test call to fail. As a result, we introduce a teardown hook on the cluster environment to resolve this issue. the teardown for torchelastic and slurm are no-ops, but for the lightning environment, we can remove the world size after the sub-process calls finish.

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?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Apr 10, 2021

Hello @ananthsub! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-15 15:39:47 UTC

@codecov
Copy link

codecov bot commented Apr 10, 2021

Codecov Report

Merging #6942 (f852a4f) into master (b85cfbe) will increase coverage by 0%.
The diff coverage is 92%.

❗ Current head f852a4f differs from pull request most recent head cc6457e. Consider uploading reports for the commit cc6457e to get more accurate results

@@           Coverage Diff           @@
##           master   #6942    +/-   ##
=======================================
  Coverage      92%     92%            
=======================================
  Files         194     194            
  Lines       12345   12391    +46     
=======================================
+ Hits        11320   11422   +102     
+ Misses       1025     969    -56     

@awaelchli awaelchli added the bug Something isn't working label Apr 12, 2021
@ananthsub ananthsub marked this pull request as ready for review April 15, 2021 15:03
@ananthsub ananthsub changed the title [fix] Don't remove world size from environment if we haven't called children scripts in ddp [fix] Add a cluster environment teardown to clean up environment state Apr 15, 2021
@ananthsub ananthsub self-assigned this Apr 15, 2021
@ananthsub ananthsub added this to the 1.3 milestone Apr 15, 2021
@awaelchli awaelchli added priority: 0 High priority task distributed Generic distributed-related topic labels Apr 15, 2021
@ananthsub ananthsub added the ready PRs ready to be merged label Apr 15, 2021
@mergify mergify bot requested a review from a team April 15, 2021 15:29
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@carmocca carmocca enabled auto-merge (squash) April 15, 2021 15:37
@carmocca carmocca merged commit f6f81f0 into Lightning-AI:master Apr 15, 2021
@ananthsub ananthsub deleted the ddp-post-dispatch-env branch April 15, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working distributed Generic distributed-related topic priority: 0 High priority task ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants