Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shuffle for distributed sampler #2789

Merged
merged 10 commits into from
Aug 2, 2020
Merged

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented Aug 1, 2020

What does this PR do?

Fixes #2703

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 馃檭

@mergify mergify bot requested a review from a team August 1, 2020 13:27
@awaelchli
Copy link
Member

awaelchli commented Aug 1, 2020

could you also add a test for this? maybe mark it as wip in the meantime

@awaelchli awaelchli added the bug Something isn't working label Aug 1, 2020
@codecov
Copy link

codecov bot commented Aug 1, 2020

Codecov Report

Merging #2789 into master will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #2789   +/-   ##
======================================
  Coverage      91%     91%           
======================================
  Files          76      76           
  Lines        6787    6788    +1     
======================================
+ Hits         6150    6151    +1     
  Misses        637     637           

@rohitgr7 rohitgr7 changed the title Fix shuffle for distributed sampler [WIP] Fix shuffle for distributed sampler Aug 1, 2020
@rohitgr7
Copy link
Contributor Author

rohitgr7 commented Aug 1, 2020

@awaelchli need a little help here with the test. Not sure why is it giving this error.

train_sampler = trainer.train_dataloader.sampler
AttributeError: 'NoneType' object has no attribute 'sampler'

Can't test it locally.

@awaelchli
Copy link
Member

awaelchli commented Aug 1, 2020

Yes, the train_dataloader is None because the test that runs in the main process never sees the trainer state getting updated. When using ddp, the fit and test is running in subprocesses. You can create a callback and put your assertions in e.g. on_train_start and on_test_start methods. Also, remember to skip ddp related tests on the windows platform.

@rohitgr7
Copy link
Contributor Author

rohitgr7 commented Aug 1, 2020

Oh! okay. Thanks :)

@awaelchli
Copy link
Member

@rohitgr7 I drafted it here in the latest commit. Need to wait for CI since I also can't test distributed things locally.

@rohitgr7
Copy link
Contributor Author

rohitgr7 commented Aug 1, 2020

Nice! It passed.

@rohitgr7 rohitgr7 changed the title [WIP] Fix shuffle for distributed sampler Fix shuffle for distributed sampler Aug 1, 2020
@williamFalcon williamFalcon merged commit 8baec1a into master Aug 2, 2020
@williamFalcon
Copy link
Contributor

What happens in the case where the user does not want to shuffle train data?

@rohitgr7
Copy link
Contributor Author

rohitgr7 commented Aug 2, 2020

Add this sampler manually and pass replace_ddp_sampler=False. Maybe we should mention this thing in docs.

@Borda Borda deleted the fix_distrib_shuffle branch August 2, 2020 10:08
@williamFalcon
Copy link
Contributor

yes. Mind updating that?

rohitgr7 added a commit that referenced this pull request Aug 2, 2020
@rohitgr7 rohitgr7 mentioned this pull request Aug 2, 2020
7 tasks
mergify bot added a commit that referenced this pull request Aug 3, 2020
* docs update and follow up of #2789

* pep8

* Update trainer.py

* Update trainer.py

Co-authored-by: edenlightning <66261195+edenlightning@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace_sampler_ddp doesn't create a shuffled sampler
3 participants