Resume from ckpt path - #536
Merged
Merged
Conversation
… test_train_pvnet()
…et with wandb.finish to ensure new files created, comparing state dict and comparing optimizer state for each step added
lm2612
marked this pull request as ready for review
August 4, 2026 10:32
felix-e-h-p
reviewed
Aug 4, 2026
| # Compare state_dict | ||
| for key, value in ckpt0['state_dict'].items(): | ||
| assert key in ckpt1['state_dict'], f"model parameter {key} present in {ckpt_epoch1_path[0]} not found in {ckpt_epoch1_path[1]}" | ||
| assert ckpt1['state_dict'][key] == pytest.approx(value, abs=1e-9), f"model weights different for {key} by {ckpt1['state_dict'][key]-value}" |
Contributor
There was a problem hiding this comment.
Think can be reduced to:
torch.testing.assert_close(ckpt1['state_dict'][key], value, atol=1e-9, rtol=0)
felix-e-h-p
reviewed
Aug 4, 2026
| ckpt0 = torch.load(ckpt_epoch1_path[0], map_location="cpu", weights_only=False) | ||
| ckpt1 = torch.load(ckpt_epoch1_path[1], map_location="cpu", weights_only=False) | ||
|
|
||
| # Compare state_dict |
Contributor
There was a problem hiding this comment.
Think this loop and the optimizer state one could be collapsed into like a helper and then just a couple assert lines - not important but just to reduce lines a little
Contributor
Author
There was a problem hiding this comment.
thanks, just added a helper function to clean it up a bit
felix-e-h-p
requested changes
Aug 4, 2026
felix-e-h-p
left a comment
Contributor
There was a problem hiding this comment.
All good, cheers! Just couple changes perhaps
felix-e-h-p
approved these changes
Aug 5, 2026
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.
Pull Request
Description
We might want to continue training from same checkpoint e.g., if training run fails or crashes. This includes full state resume, including model weights and optimizer state.
Fixes #541
I've added an option for
ckpt_pathin config. This should be the full path to the checkpoint that includes model weights, optimizer state, etc. This will be passed to the Lightning trainer inpvnet/training/train.py. If it is not specified, it will be ignored:How Has This Been Tested?
New test
test_checkpoint_loadintests/training/test_train.py. This will use the output fromtest_train_pvnetafter the first epoch, and restart two training runs from there. Then we check that the saved checkpoints are identical.Checklist: