Skip to content

Fix _maybe_set_distributed_sampler_epoch to handle MultiDataLoader - #1078

Open
tachukao wants to merge 1 commit into
meta-pytorch:masterfrom
tachukao:export-D114246690
Open

Fix _maybe_set_distributed_sampler_epoch to handle MultiDataLoader#1078
tachukao wants to merge 1 commit into
meta-pytorch:masterfrom
tachukao:export-D114246690

Conversation

@tachukao

Copy link
Copy Markdown

Summary:
_maybe_set_distributed_sampler_epoch only handles plain
torch.utils.data.DataLoader instances. When the train dataloader is a
MultiDataLoader (used by the Cascade multi-task pipeline), the
isinstance(dataloader, DataLoader) check fails silently and
set_epoch() is never called on any child sampler.

This means DistributedSampler.epoch stays at 0 for the entire run,
so the sampler draws the same random indices every epoch.

Fix: recurse into MultiDataLoader.individual_dataloaders and call
_maybe_set_distributed_sampler_epoch on each child.

Reviewed By: galrotem

Differential Revision: D114246690

Summary:
`_maybe_set_distributed_sampler_epoch` only handles plain
`torch.utils.data.DataLoader` instances. When the train dataloader is a
`MultiDataLoader` (used by the Cascade multi-task pipeline), the
`isinstance(dataloader, DataLoader)` check fails silently and
`set_epoch()` is never called on any child sampler.

This means `DistributedSampler.epoch` stays at 0 for the entire run,
so the sampler draws the same random indices every epoch.

Fix: recurse into `MultiDataLoader.individual_dataloaders` and call
`_maybe_set_distributed_sampler_epoch` on each child.

Reviewed By: galrotem

Differential Revision: D114246690
@meta-cla meta-cla Bot added the cla signed label Jul 30, 2026
@meta-codesync

meta-codesync Bot commented Jul 30, 2026

Copy link
Copy Markdown

@tachukao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114246690.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant