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

[Feat] Add graceful detection of signal to exit + SignalConnector and merge SlurmConnector. #9566

Merged
merged 20 commits into from
Sep 17, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Sep 16, 2021

What does this PR do?

Right now, when the script is being killed, a fault tolerant checkpoint would be saved.
However, Lightning can't always ensure it is always fully happening in reproducible part of the codebase.

When running in the cloud, there is 2-3 min to kill the script.

The proposal is to add a mechanism to detect a killing signal as been sent and Lightning will terminate on the next reproducible part in this time windown.

Parts #9567

Does your PR introduce any breaking changes? If yes, please list them.

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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
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 🙃

@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@tchaton tchaton self-assigned this Sep 16, 2021
@tchaton tchaton added this to the v1.5 milestone Sep 16, 2021
@awaelchli awaelchli changed the title [Feat] Add gracefull detection of signal to exit [Feat] Add graceful detection of signal to exit Sep 16, 2021
@tchaton tchaton changed the title [Feat] Add graceful detection of signal to exit [Feat] Add graceful detection of signal to exit + SignalConnector and merge SlurmConnector. Sep 16, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
pytorch_lightning/trainer/connectors/signal_connector.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/connectors/signal_connector.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #9566 (7216a39) into master (982a956) will decrease coverage by 4%.
The diff coverage is 71%.

@@           Coverage Diff           @@
##           master   #9566    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         180     181     +1     
  Lines       15094   15341   +247     
=======================================
- Hits        14021   13623   -398     
- Misses       1073    1718   +645     

Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

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

does signal handling generalize across all clusters/schedulers?

our scheduler offers a dedicated mechanism to check for preemption, which we've integrated in the model checkpoint callback on batch end for whether we ought to save a checkpoint that batch. but i also thought this was atypical in cloud providers workloads where the job scheduler could kill the job at any point

pytorch_lightning/trainer/connectors/signal_connector.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Sep 17, 2021
@tchaton tchaton requested a review from carmocca September 17, 2021 11:35
@carmocca carmocca self-requested a review September 17, 2021 13:32
CHANGELOG.md Outdated Show resolved Hide resolved
tchaton and others added 3 commits September 17, 2021 17:32
Co-authored-by: Sean Naren <sean@grid.ai>
@tchaton tchaton enabled auto-merge (squash) September 17, 2021 17:03
@yifuwang
Copy link
Contributor

Think looks great! Thanks for adding the mechanism @tchaton!

@tchaton tchaton merged commit c7451b3 into master Sep 17, 2021
@tchaton tchaton deleted the add_fault_tolerant_gracefully_detection branch September 17, 2021 19:14
SeanNaren pushed a commit that referenced this pull request Sep 22, 2021
… merge SlurmConnector. (#9566)

Co-authored-by: Sean Naren <sean@grid.ai>
log.info("Set SLURM handle signals.")
sigusr1_handlers.append(self.slurm_sigusr1_handler_fn)

sigterm_handlers.append(self.sigterm_handler_fn)
Copy link
Contributor

@awaelchli awaelchli Oct 27, 2021

Choose a reason for hiding this comment

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

this line got unindented, it was previously under the slurm check.
it means that Lightning can't be killed by sigterm.
As best as I can judge, this is not required for fault tolerant training.

See #10154 for context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fault tolerance ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants