Skip to content

Potential bug in DataLoader2 when seed = 0 #1097

@NivekT

Description

@NivekT

🐛 Describe the bug

If you try to set the seed = 0 as such:

dp = IterableWrapper(range(20)).shuffle()
rs = MultiProcessingReadingService(num_workers=2)

dl = DataLoader2(datapipe=dp, reading_service=rs)
dl.seed(0)

The seed will not be set because this line returns False. I think the true intention is to skip over None, but 0 also gets skipped as it is currently implemented.

https://github.com/pytorch/data/blob/7d9747588173f38e3ce0d5c58ba3746dacb4438f/torchdata/dataloader2/dataloader2.py#L203

I suppose we can say seed = 0 is invalid but it is probably better to check for self._seed is not None instead.

Versions

main

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions