Repository navigation
Add Trainer.save/load checkpointing for resumable runs - #13
Merged
Merged
Conversation
Trainer.state_dict/load_state_dict (and save/load wrappers) capture everything needed to resume a multi-minute image run: energy weights, optimizer moments, the EMA copy, loss parameters (e.g. NCE log_z), the PCD replay buffer (owned by the loss, captured generically via loss_fn.buffer), and the step counter and metric history. Mirrors the plain-dict state_dict convention of EMA and ReplayBuffer; load restores into a matching freshly-constructed Trainer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
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.
Image-scale runs take minutes; until now an interruption lost everything.
Trainer.save(path)/Trainer.load(path)(plusstate_dict/load_state_dict) checkpoint and resume a full run:log_z) when the loss is annn.Moduleloss_fn.bufferwithout coupling to any loss classMirrors the plain-dict
state_dict/load_state_dictconvention already used byEMAandReplayBuffer;loadrestores into a matching freshly-constructedTrainer(same load-into-existing pattern).save/loadare thintorch.save/torch.loadwrappers.Tests
test_trainer_checkpoint_roundtrip_and_resume: trains a PCD trainer 30 steps, saves, loads into a differently-initialized trainer, and asserts energy params, EMA weights, buffer contents, optimizer state, andstep_count/history all match — then resumes and confirms the counter continues 30→35.Docs: new "Saving and resuming" section in
docs/training.md.🤖 Generated with Claude Code