-
Notifications
You must be signed in to change notification settings - Fork 165
Give an option to either provide dataset or dataset_size in distributed sampler #1479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/data/1479
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled JobAs of commit 1116f96 with merge base aef2409 ( CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@@ -179,19 +182,66 @@ def __iter__(self): | |||
) | |||
|
|||
|
|||
class StatefulDistributedSampler(torch.utils.data.distributed.DistributedSampler): | |||
class StatefulDistributedSampler(Sampler[int]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should continue subclassing DistributedSampler
for StatefulDistributedSampler
- it is easy to udnerstand that by just the naming and we might trigger many type checking issues in downstream code which uses StatefulDistributedSampler
and expects a variant of DistributedSampler
.
Since DistributedSampler
is a common utility in PyTorch, StatefulDistributedSampler
should be expected to be an extension of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to fork it instead of subclassing because I do not want to upstream these changes in torch.utils.data.distributed.DistributedSampler
as it might break other users' code.
Nevertheless, it is redundant to have Dataset as an arg when we just need the length of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets sync if there is a better way to do this - maybe create a new sampler?
Currently the StatefulDistributedSampler takes the dataset as an argument, but only uses the length/size of the dataset.
Adding an option to provide size of the dataset instead, for more flexibility.