-
Notifications
You must be signed in to change notification settings - Fork 254
Add checkpointing support for Tinker SkyRL backend #992
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
Conversation
Add full checkpoint save/load functionality to SkyRLTrainBackend: - save_checkpoint(): Saves model + optimizer + scheduler state as uncompressed tar - load_checkpoint(): Restores full training state from tar checkpoint - save_sampler_checkpoint(): Exports model weights in HuggingFace format for inference Implementation wraps WorkerDispatch checkpoint methods and handles tar packaging. Uses uncompressed tar to avoid 5-10 minute gzip bottleneck on 6-7GB FSDP checkpoints. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces checkpointing capabilities to the SkyRLTrainBackend, enabling training state to be saved and restored via tar archives. However, a high-severity path traversal vulnerability was identified in the checkpoint loading logic due to the unsafe use of tarfile.extractall(). Additionally, the worker initialization logic uses trust_remote_code=True when loading model configurations, which poses a significant security risk if untrusted model identifiers are processed. Beyond security, there's also a minor race condition and some code duplication that could benefit from refactoring for improved maintainability.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Address PR review feedback: 1. Security: Add filter='data' to tarfile.extractall() to prevent path traversal (TarSlip) attacks where malicious archives could write outside the temp directory 2. Refactor: Extract duplicate validation logic into _validate_model_state() helper method (used by all 3 checkpoint methods) 3. Remove redundant os.path.exists() check that creates TOCTOU race condition - tarfile.open() already raises FileNotFoundError 4. Refactor: Extract common tar creation logic into _create_tar_from_directory() helper method to reduce duplication Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Summary
Implements checkpointing for the SkyRL-Train backend in Tinker, enabling periodic checkpoint saves and training resumption.
Changes
Adds three checkpoint methods to
SkyRLTrainBackend:save_checkpoint()- Saves full training state (model + optimizer + scheduler) as tar archiveload_checkpoint()- Restores full training state from checkpointsave_sampler_checkpoint()- Exports model-only checkpoint in HuggingFace formatImplementation
WorkerDispatch.save_checkpoint()andload_checkpoint()methods