Unable to get mid-epoch resumption working
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Description
I am using the Streaming in conjunction with pytorch lightning, but loading my dataloaders (including state resumption) separate of the pl logic.
Within my pl.Trainer I have the following to include the training dataloader state dict in the checkpoint:
def on_save_checkpoint(self, checkpoint):
dataloader = self.trainer.train_dataloader
if isinstance(dataloader, list):
dataloader = dataloader[0]
checkpoint['dataloader_state'] = dataloader.state_dict()
And then in my dataset class, I implement the logic to load this checkpoint, and specifically get the dataloader state (if resuming). As an example, this is the dict I extract:
self.dataloader_state = {
'epoch': 0,
'initial_physical_nodes': 1,
'num_canonical_nodes': 1,
'sample_in_epoch': 100,
'shuffle_seed': 9176
}
This is from a checkpoint saved at step 25 w/ a batch size of 4; so far so good. Now I load my dataset + dataloader (same as before), and instantiate from the state dict:
train_dataloader.load_state_dict(self.dataloader_state)
And for debugging purposes:
for i, batch in enumerate(train_dataloader):
print(i)
And the prints start from 0. If I understand correctly, with resumption this should not be the case, right?
I ask because when involved in my actual pl lightning code, it does not seem to be resuming from the correct step either.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PyTorch Lightning on_save_checkpoint hook and the dataloader state_dict/load_state_dict calls shown in the issue. Trace how Streaming restores sample_in_epoch during iteration, then compare the restored loader's first batches with the checkpoint values. Done means mid-epoch iteration resumes at the expected sample or step rather than starting at index 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100