fix: make checkpoint resume crash-consistent - #8
Open
KAIWEILIUCC wants to merge 2 commits into
Open
Conversation
Validate runtime, history, step records, and skill snapshots before resuming. Roll back incomplete generations, atomically commit checkpoint files with runtime_state as the final marker, reject concurrent writers, and add fault-injection tests.
There was a problem hiding this comment.
Pull request overview
This PR introduces crash-consistent checkpoint commit + recovery for the SkillOpt-Lite training loop, ensuring that partially written checkpoint artifacts are detected and rolled back so the next run resumes from the last fully committed step.
Changes:
- Added a dedicated crash-consistent checkpoint module with atomic file writes, step commit markers, recovery validation, and artifact pruning.
- Updated the trainer to use the new checkpoint commit/recovery flow, including run fingerprint validation and exclusive writer locking.
- Added fault-injection tests covering crash-at-boundary scenarios and recovery cleanup behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/test_checkpoint.py |
Adds recovery and crash-boundary fault-injection coverage for checkpoint consistency. |
skillopt/engine/trainer.py |
Switches checkpoint persistence/resume logic to the new crash-consistent checkpoint utilities and adds an out_root writer lock + fingerprinting. |
skillopt/engine/checkpoint.py |
New module implementing atomic writes, step commits, recovery validation, pruning, and locking utilities. |
skillopt/engine/__init__.py |
Lazily exposes ReflACTTrainer to avoid eager imports while keeping engine exports stable. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
This PR makes SkillOpt-Lite checkpoint recovery crash-consistent.
Previously, resume logic primarily trusted
runtime_state.jsonor the lastentry in
history.json. A process interruption between checkpoint writes couldleave
runtime_state.json,history.json, step records, and skill snapshotsout of sync. Partial step artifacts could also be reused during the next run.
What changed
runtime_state.jsonhistory.jsonsteps/step_XXXX/step_record.jsonN.N, including:N + 1instead of reusing its partial directory.fsyncos.replacefsyncruntime_state.jsonlast as the commit marker.initial skill.
out_root.lr_history.jsonl.No new command-line arguments or configuration fields are required.
Recovery semantics
If a run is interrupted while executing step
N + 1:Nas the last consistent commit.N.N + 1from the beginning.This prevents a partially written step from being treated as complete.
Tests
Added fault-injection coverage for:
runtime_state.jsonbeing ahead of other artifacts;Commands run: