Fix PyTorch DDP sampler epoch forwarding in the data loader wrappers - #1017
Open
Tendourisu wants to merge 1 commit into
Open
Fix PyTorch DDP sampler epoch forwarding in the data loader wrappers#1017Tendourisu wants to merge 1 commit into
Tendourisu wants to merge 1 commit into
Conversation
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
Fix PyTorch DDP sampler epoch forwarding in the data loader wrappers.
In DDP mode,
create_torch_data_loader()creates aDistributedSamplerand passes it intoTorchDataLoader, but the training loop receives the outerDataLoaderImpl. Previously neitherTorchDataLoadernorDataLoaderImplexposedset_epoch()or__len__(), so the existing guarded call inscripts/train_pytorch.pynever executed. As a result, in DDP training that spans multiple full dataset cycles, the sampler kept reusing the epoch 0 index order instead of reshuffling each epoch.Background
Relevant code paths:
The training loop contains the guarded
set_epoch()call:openpi/scripts/train_pytorch.py
Lines 510 to 512 in 15a9616
A
DistributedSampleris created and passed toTorchDataLoaderhere:openpi/src/openpi/training/data_loader.py
Lines 305 to 337 in 15a9616
TorchDataLoaderdoes not implementset_epoch()or__len__():openpi/src/openpi/training/data_loader.py
Lines 381 to 468 in 15a9616
The outer
DataLoaderImplwrapper also does not implement either method:openpi/src/openpi/training/data_loader.py
Lines 530 to 540 in 15a9616
Changes
set_epoch()and__len__()toTorchDataLoaderset_epoch()and__len__()fromDataLoaderImpl