Fix _atomic_save staging local checkpoints through $TMPDIR#21744
Open
c-pozzi wants to merge 7 commits into
Open
Fix _atomic_save staging local checkpoints through $TMPDIR#21744c-pozzi wants to merge 7 commits into
_atomic_save staging local checkpoints through $TMPDIR#21744c-pozzi wants to merge 7 commits into
Conversation
for more information, see https://pre-commit.ci
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #21744 +/- ##
=======================================
Coverage 87% 87%
=======================================
Files 270 270
Lines 23975 24000 +25
=======================================
+ Hits 20750 20773 +23
- Misses 3225 3227 +2 |
The test verified the EXDEV/PermissionError workaround in _atomic_save that handled fsspec's cross-device staging. Since Lightning-AI#21744 stages local checkpoints next to the destination, that code path is unreachable for local files — the test's mocks (os.rename, os.chmod) never fire on the new code path, leaving the test inert.
justusschock
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #21253.
_atomic_savewrites local checkpoints through$TMPDIRinstead of straight to the target. On SLURM/HPC where$TMPDIRis on a small partition, this fails with "no space left on device" even though the destination disk has space.The staging happens inside fsspec's
LocalFileSystem.transaction—tempfile.mkstemp()is called without adir=argument, so the temp file lands in$TMPDIR. Full trace in the investigation comment.Fix
For local paths, skip
fs.transactionand stage next to the destination instead:os.replaceis atomic on the same filesystem, so this preserves the no-partial-files guarantee that the transaction was providing.os.fsyncon the file (and best-effort on the parent dir) make the save crash-durable, not just atomic-at-the-namespace level. Object storage paths (S3, GCS, Azure) are unchanged.Tests
Four new tests in
test_cloud_io.py:$TMPDIR(regression for Directly save checkpoint to specified disk location #21253)FileNotFoundError(parity with current behavior)Symlink semantics
When the destination path is itself a symlink,
os.replacefollows POSIXrename(2)and replaces the symlink with the new file (the link target is untouched). This is consistent with what the current code does on same-FS renames; the only case where behavior differs is when the destination was a symlink pointing across filesystems — that's the exact bug being fixed here, so anyone hitting it was already broken. Parent directories that are symlinks continue to work correctly (the OS resolves them transparently).Before submitting
Co-authored with Claude Code.