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 atomic save to checkpoint routine #20011

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

corwinjoy
Copy link
Contributor

@corwinjoy corwinjoy commented Jun 24, 2024

What does this PR do?

Upgrade the _atomic_checkpoint routine to use a transaction. This should make saves atomic so that if an interrupt happens during a file save, any existing file will not be corrupted.

The following links the related issue to the PR: #19970

Fixes #19970

I have skipped updating the changelog since it looks like this gets updated as part of the release.

Before submitting
  • Was this discussed/agreed 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 minor internal changes/refactors)

PR review

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

Reviewer checklist
  • 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

📚 Documentation preview 📚: https://pytorch-lightning--20011.org.readthedocs.build/en/20011/

@github-actions github-actions bot added the fabric lightning.fabric.Fabric label Jun 24, 2024
@corwinjoy corwinjoy changed the title Add atomic save to checkpoint routing Add atomic save to checkpoint routine Jun 24, 2024
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

Looks great. Just a few suggestions

src/lightning/fabric/utilities/cloud_io.py Outdated Show resolved Hide resolved
src/lightning/fabric/utilities/cloud_io.py Outdated Show resolved Hide resolved
src/lightning/fabric/utilities/cloud_io.py Outdated Show resolved Hide resolved
@awaelchli awaelchli added the community This PR is from the community label Jun 25, 2024
@awaelchli awaelchli added this to the 2.4 milestone Jun 25, 2024
@awaelchli awaelchli added the checkpointing Related to checkpointing label Jun 25, 2024
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59%. Comparing base (3f69134) to head (765e1d1).
Report is 76 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (3f69134) and HEAD (765e1d1). Click for more details.

HEAD has 69 uploads less than BASE
Flag BASE (3f69134) HEAD (765e1d1)
python3.10 19 16
cpu 65 48
lightning 39 32
pytest 47 28
examples 9 0
app 9 0
tpu 2 0
lightning_app 3 0
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20011     +/-   ##
=========================================
- Coverage      84%      59%    -25%     
=========================================
  Files         427      422      -5     
  Lines       35504    35407     -97     
=========================================
- Hits        29781    20773   -9008     
- Misses       5723    14634   +8911     

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jun 25, 2024
@awaelchli
Copy link
Contributor

Thanks @corwinjoy
I also made a follow-up issue for the distributed checkpoint saving logic.

@corwinjoy
Copy link
Contributor Author

corwinjoy commented Jun 25, 2024 via email

@awaelchli awaelchli merged commit 967413a into Lightning-AI:master Jun 27, 2024
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkpointing Related to checkpointing community This PR is from the community fabric lightning.fabric.Fabric pl Generic label for PyTorch Lightning package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make checkpoint saving fully atomic
2 participants