Enable load_weights_only in checkpointing - #1996
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an "optimizer" boolean flag to the checkpoint loading process across multiple backends (JAX, Ray JAX, and SkyRL Train) and exposes it via the Tinker API, enabling optional restoration of optimizer and scheduler states. The feedback highlights two main areas of improvement: first, the "optimizer" field in "LoadWeightsRequest" and "LoadWeightsInput" should default to "False" to preserve backward compatibility with older clients; second, a safety check should be added in the JAX backend to prevent a potential "KeyError" if "optimizer_state" is missing from the checkpoint data.
| class LoadWeightsRequest(BaseModel): | ||
| model_id: str | ||
| path: str | ||
| optimizer: bool |
There was a problem hiding this comment.
Adding optimizer as a required boolean field in LoadWeightsRequest without a default value breaks backward compatibility with older clients or SDKs that do not send this field in their payload. Providing a default value (e.g., False) ensures that the API remains backward-compatible and robust against missing fields.
| optimizer: bool | |
| optimizer: bool = False |
Signed-off-by: Charles Tang <j316chuck@users.noreply.github.com>
Signed-off-by: Charles Tang <j316chuck@users.noreply.github.com>
f618708 to
99ca9e0
Compare
6355b87 to
d7240b6
Compare
Summary
optimizerflag through the load-weights API, engine, and JAX/SkyRL-Train backends.load_state_with_optimizer(); weights-only loads leave the live optimizer untouched.Fixes #1993.
Testing
All seven focused API, engine, and checkpoint-loading cases pass.