Add configurable checkpoint filenames and state-dict key remapping#1705
Open
Thabhelo wants to merge 2 commits into
Open
Add configurable checkpoint filenames and state-dict key remapping#1705Thabhelo wants to merge 2 commits into
Thabhelo wants to merge 2 commits into
Conversation
Expose filename_format on save_checkpoint for custom model checkpoint basenames, and add Module._backward_compat_state_dict_mapper for loading checkpoints after parameter renames. Closes NVIDIA#1175 and NVIDIA#1173. Signed-off-by: Thabhelo <50872400+Thabhelo@users.noreply.github.com>
Contributor
Greptile SummaryThis PR adds two independent utilities: a
Important Files Changed
Reviews (1): Last reviewed commit: "Add checkpoint filename_format and state..." | Re-trigger Greptile |
Resolve checkpoint indices from formatted basenames when epoch is omitted, reuse _resolve_checkpoint_index for the legacy naming path, and add a test for auto-incrementing custom checkpoint filenames. Signed-off-by: Thabhelo <50872400+Thabhelo@users.noreply.github.com>
Author
|
Greptile triage for 8e60df5:
|
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
filename_formattosave_checkpointso model checkpoint basenames can use custom layouts (e.g. zero-padded epochs) while preserving legacy naming when unset.Module._backward_compat_state_dict_mapperand apply it infrom_checkpointbeforeload_state_dict, mirroring the existing constructor-arg backward-compat hook for refactored parameter names.Closes #1175
Closes #1173
Test plan
pytest test/utils/test_checkpoint.py::test_save_checkpoint_filename_formatpytest test/utils/test_checkpoint.py::test_save_checkpoint_filename_format_invalid_placeholderpytest test/models/test_from_checkpoint.py::test_from_checkpoint_state_dict_mapper