Skip to content

One atomic write helper for checkpoints and the dataset cache - #81

Merged
CanReader merged 1 commit into
masterfrom
refactor/one-atomic-write
Nov 12, 2026
Merged

CanReader merged 1 commit into
masterfrom
refactor/one-atomic-write

Conversation

@CanReader

Copy link
Copy Markdown
Owner
  • one atomic write helper for checkpoints and the dataset cache

What this changes

serialize::atomic::write_atomic is the only atomic write now. It gains what the copy in mnist.rs had: a per-call counter in the temp name next to the pid, and cleanup of the temp file on any failure, the rename included. write_atomic_bytes covers callers with the bytes in memory, and mnist.rs uses it instead of its own helper. The helper's tests move into atomic.rs and now cover the two error paths: a write that fails midway leaves the old file byte-identical and no temp behind, and a failed rename leaves no temp. In tests/robustness.rs the two "does not destroy the good copy" tests are renamed to what they check, saving over a corrupt file, the test that asserted the temp is absent after a successful save is gone since the rename guarantees that, and the section divider is gone. The two identical doc paragraphs on the savers are one line each.

Why

#72 and #74 each added an atomic write, in different modules with different gaps. One helper, with both sets of behaviour and tests for the paths that matter, is what the reviews on both asked for.

How it was verified

  • cargo test passes
  • cargo clippy --all-targets -- -D warnings is clean
  • Ran cuda_parity on a GPU
  • Trained an example in --release
  • No GPU here, CUDA side not runtime tested

cargo doc with -D warnings is clean. No CUDA code touched.

Checklist

  • Every new or changed backward rule has a gradcheck case
  • Every new kernel has a cuda_parity case
  • tensor/ops and autograd/ops still mirror each other
  • Public items have /// docs

@CanReader
CanReader merged commit 0c43589 into master Nov 12, 2026
12 checks passed
@CanReader
CanReader deleted the refactor/one-atomic-write branch November 12, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant