feat: save full training state (optimizers, step) in checkpoints#56
Open
Kuonirad wants to merge 3 commits intoSamsungSAILMontreal:mainfrom
Open
feat: save full training state (optimizers, step) in checkpoints#56Kuonirad wants to merge 3 commits intoSamsungSAILMontreal:mainfrom
Kuonirad wants to merge 3 commits intoSamsungSAILMontreal:mainfrom
Conversation
- Modified `save_train_state` to save a dictionary containing model state, optimizer states, and training step. - Updated `load_checkpoint` to handle the new dict format while maintaining backward compatibility with old weight-only checkpoints. - Updated `create_model` to broadcast loaded checkpoint metadata (optimizers/step) from rank 0 to all ranks and restore optimizer states. - Updated `init_train_state` to resume training step from checkpoint.
- Modified `save_train_state` to save a dictionary containing model state, optimizer states, training step, and optional EMA state. - Updated `load_checkpoint` to handle the new dict format while maintaining backward compatibility. - Updated `create_model` to broadcast loaded checkpoint metadata (optimizers/step) from rank 0 to all ranks and restore optimizer states. - Updated `init_train_state` to return loaded checkpoint data and resume training step. - Updated `launch` to load EMA state if available and save the online state (plus EMA helper) instead of just the EMA weights, ensuring correct resumption.
- Implemented automatic checkpoint detection: scans `checkpoint_path` for the latest `step_X` file if no specific checkpoint is provided. - Added full RNG state persistence (torch, cuda, numpy, random) to checkpoints to ensure deterministic resumption. - Modified `save_train_state` and `load_checkpoint` to handle the augmented state dictionary. - Updated `torch.load` usage to allow complex objects (`weights_only=False`) required for optimizer/RNG states. - Cleaned up dataset configuration placeholder. - Verified bitwise-identical resumption via script.
Kuonirad
commented
Dec 17, 2025
Author
Kuonirad
left a comment
There was a problem hiding this comment.
saved full training state (optimizers, step) in checkpoints
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.
save_train_stateto save a dictionary containing model state, optimizer states, and training step.load_checkpointto handle the new dict format while maintaining backward compatibility with old weight-only checkpoints.create_modelto broadcast loaded checkpoint metadata (optimizers/step) from rank 0 to all ranks and restore optimizer states.init_train_stateto resume training step from checkpoint.