-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Add generator=
kwarg for DataLoader & random samplers
#39737
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
Conversation
generator=
kwarg for DataLoader & random samplersgenerator=
kwarg for DataLoader & random samplers
💊 CI failures summary and remediationsAs of commit d95ff17 (more details on the Dr. CI page):
🕵️ 7 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
generator=
kwarg for DataLoader & random samplersgenerator=
kwarg for DataLoader & random samplers
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.
the generator for DataLoader should also be used for base_seed
in iterators
generator=
kwarg for DataLoader & random samplersgenerator=
kwarg for DataLoader & random samplers
a210e86
to
7ca2056
Compare
generator=
kwarg for DataLoader & random samplersgenerator=
kwarg for DataLoader & random samplers
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.
can we test the base_seed reproducibility by doing something similar to test_worker_seed
?
7ca2056
to
d249c04
Compare
test/test_dataloader.py
Outdated
dataset = SynchronizedSeedDataset(num_workers, batch_size, num_workers) | ||
dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=num_workers, generator=torch.Generator().manual_seed(42)) | ||
actual_seeds = set(int(batch) for batch in dataloader) | ||
expected_seeds = set(6909045637428952499 + i for i in range(num_workers)) |
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.
don't do this. seeding is only guaranteed to be consistent on the same device & version. just do two runs and compare results
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.
👌
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.
merge when green. thanks!
Windows CI is having a big hiccup because of some |
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.
Thanks for the PR.
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.
@albanD is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Hi @ShawnZhong , do you mind also updating the notes at https://pytorch.org/docs/stable/data.html#randomness-in-multi-process-data-loading https://pytorch.org/docs/stable/notes/faq.html#my-data-loader-workers-return-identical-random-numbers about this too? Thanks :) |
Summary: Fix pytorch#39572 Add `generator=` kwarg for DataLoader & random samplers cc: SsnL, deeppatel4557, albanD, mitar Pull Request resolved: pytorch#39737 Differential Revision: D22019132 Pulled By: albanD fbshipit-source-id: 835e08b86c5396bc0b0e41057661306b15394d6e
Fix #39572
Add
generator=
kwarg for DataLoader & random samplerscc: @ssnl, @deeppatel4557, @albanD, @mitar