feat: Auto-detect and convert Tunix post-training checkpoints on load - #4951
feat: Auto-detect and convert Tunix post-training checkpoints on load#4951hsuan-lun-chiang wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request implements on-the-fly detection and conversion of Tunix-formatted checkpoints during the pre-training load process, avoiding manual checkpoint conversion. The feedback highlights several critical issues: first, setting metadata to None on exception in model_creation_utils.py will cause an AttributeError when accessing metadata.item_metadata later; second, _drop_adapter_level must recurse into lists, tuples, and namedtuples to handle nested optimizer states; and third, an _add_adapter_level helper is required to correctly wrap optimizer state fields in base when restoring adapter checkpoints to prevent structure mismatches.
0494c94 to
90aea05
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
b89495f to
8343327
Compare
- Add auto-detection for Tunix-formatted checkpoints (checks for `model_params`) - Implement on-the-fly conversion logic (`_load_tunix_full_state_from_path`) during load - Seamlessly reshape Tunix `TrainState` in memory (strip `inject_hyperparams`, drop `base` adapter) - Support both full state and parameters-only restores
8343327 to
f3ede74
Compare
Overview
This PR updates the checkpoint loader in MaxText to auto-detect and dynamically convert Tunix post-training checkpoints on load, allowing downstream MaxText pre-training runs to restore from Tunix DPO/SFT checkpoints seamlessly.
Key Changes
model_paramscollection).inject_hyperparamswrapper states (_drop_inject_hyperparams)._drop_adapter_level) when mapping from adapter states to base pre-training states, handling dicts, lists, tuples, and namedtuples._add_adapter_level) when querying metadata or loading checkpoints withhas_base=True.model_creation_utils.from_pretrained: Directs parameter inspection and single-item PyTree restore tomodel_paramswhen loading Tunix checkpoints.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.