Skip to content

fix: reject an existing checkpoint step with a clear error - #63

Merged
sypsyp97 merged 3 commits into
sypsyp97:mainfrom
cslht11:fix/checkpoint-resave
Nov 2, 2026
Merged

sypsyp97 merged 3 commits into
sypsyp97:mainfrom
cslht11:fix/checkpoint-resave

Conversation

@cslht11

@cslht11 cslht11 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Re-running a solver with the same checkpoint_directory crashes in
save_checkpoint (diffct/_solver_state.py): rank.mkdir() raises
FileExistsError once step-.../rank-... already exists, so a resumed or
repeated run can never re-checkpoint into the folder it created itself. I hit
this re-running cgls twice into an existing directory.

Two tweaks: create the rank directory with exist_ok=True, and unlink a
rank's own .npy file before recreating it (other ranks may still be writing
the same step concurrently).

No functional change beyond the fixed crash: 12/12 in
tests/test_solver_checkpoint_edges.py with the patch - the new
test_reusing_a_checkpoint_directory_replaces_steps fails on main.

cslht11 and others added 3 commits November 1, 2026 05:22
Saving an iteration whose files already exist crashed with
FileExistsError from the exclusive rank-file creation. Re-saving now
replaces only this rank's previous files, so ranks writing the same
step concurrently never touch each other; a regression test pins the
directory contents and the deterministic results.
@sypsyp97 sypsyp97 changed the title fix: let a reused checkpoint directory replace earlier steps fix: reject an existing checkpoint step with a clear error Nov 2, 2026
@sypsyp97

sypsyp97 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks for the report. Replacing a published step in place can lose it if the write fails part way, and other ranks cannot roll back with it. So I changed this to a clear error instead: a solver that reaches an existing step now raises a ValueError on all ranks that names the path and says to use a new checkpoint_directory or resume=. The earlier checkpoint stays intact. Tests are updated to match.

@sypsyp97
sypsyp97 merged commit 653bc8b into sypsyp97:main Nov 2, 2026
11 checks passed
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.

2 participants