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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix num batches in case of multiple dataloaders and percent_check #1920

Merged
merged 16 commits into from
Jun 18, 2020
Merged

Fix num batches in case of multiple dataloaders and percent_check #1920

merged 16 commits into from
Jun 18, 2020

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented May 21, 2020

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 to update the docs?
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Fixes #1899.

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 May 21, 2020 19:50
@rohitgr7
Copy link
Contributor Author

Still needs to figure out why tests are failing. Need some help.

@rohitgr7 rohitgr7 changed the title Fix num batches Fix num batches in case of multiple dataloaders and percent_check May 21, 2020
@Borda Borda added the bug Something isn't working label May 21, 2020
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in _reset_eval_dataloader you need to update the type hint for the retun to
Tuple[List[int], List[DataLoader]]:

pytorch_lightning/trainer/data_loading.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/evaluation_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/evaluation_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/evaluation_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/data_loading.py Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team May 21, 2020 20:58
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more thing to make a test pass:
in tests/deprecated.py change max_batches=1 to max_batches=[1]

pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented May 21, 2020

Hello @rohitgr7! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-06-18 07:40:19 UTC

@awaelchli
Copy link
Member

I will help fix the rest of the tests tomorrow

@mergify mergify bot requested a review from a team May 21, 2020 21:55
@rohitgr7
Copy link
Contributor Author

I will write new test cases tomorrow.

@awaelchli awaelchli changed the title Fix num batches in case of multiple dataloaders and percent_check [WIP] Fix num batches in case of multiple dataloaders and percent_check May 22, 2020
@rohitgr7
Copy link
Contributor Author

rohitgr7 commented May 22, 2020

@awaelchli I was thinking to add just 1 test in which we will test both multiple val and test dataloaders with different sizes by just comparing num_batches for both. This is sufficient or should I add more tests and assertions??

@awaelchli
Copy link
Member

Testing the num_batches for multiple with different sizes is good. However, a more important test imo is checking also that the dataloaders get consumed by that amount.
We could easily do this with a custom dataloader that just returns the index of the sample. Then we check how many samples we have drawn from each dataloader. What do you think?

@rohitgr7
Copy link
Contributor Author

rohitgr7 commented May 22, 2020

@awaelchli Yeah, good idea. But can't figure out how to do that within tests.

@rohitgr7 rohitgr7 requested review from awaelchli and removed request for a team May 25, 2020 18:53
@mergify mergify bot requested a review from a team May 25, 2020 18:53
@awaelchli
Copy link
Member

I think the test is good and covers the base case, thanks for adding it! I will try to generalize it a bit more if you don't mind and post here.

@awaelchli
Copy link
Member

hey @rohitgr7 I was able to parameterize the test and make it consistent for train, val, test.
Would you mind to merge this branch into yours and push it?
https://github.com/awaelchli/pytorch-lightning/tree/fix_num_batches
Then I think the PR is ready for review/merge :)

@awaelchli
Copy link
Member

There is also a PR #1959 that adds support for multiple train dataloaders, so if that one gets merged first we need to make a few adjustments here :)

@mergify
Copy link
Contributor

mergify bot commented May 26, 2020

This pull request is now in conflict... :(

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented May 26, 2020

This pull request is now in conflict... :(

@rohitgr7
Copy link
Contributor Author

I made a small mistake with git there! Apologies.

@awaelchli
Copy link
Member

yes I saw, no big deal, now we just need to fix this small merge conflict :)

@rohitgr7
Copy link
Contributor Author

Just a suggestion! Can we have *_percent_check to be a list too where len(*_percent_check) == len(*_dataloaders)? In case if it is int then it will be same for all the dataloaders passed. Don't know how this can be useful in any case, just a thought.

@awaelchli
Copy link
Member

Not sure how useful that is, but how about you open an issue for that?

@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

❗ No coverage uploaded for pull request base (num_batches_missing_test@db84ca9). Click here to learn what that means.
The diff coverage is n/a.

@@                    Coverage Diff                     @@
##             num_batches_missing_test   #1920   +/-   ##
==========================================================
  Coverage                            ?     88%           
==========================================================
  Files                               ?      69           
  Lines                               ?    5249           
  Branches                            ?       0           
==========================================================
  Hits                                ?    4606           
  Misses                              ?     643           
  Partials                            ?       0           

@awaelchli
Copy link
Member

awaelchli commented Jun 17, 2020

@williamFalcon @Borda Thanks, it's very kind you were able to add us as authors there. I already submitted a new PR #2226 with the missing test, because was not able to push here.

EDIT: sorry I don't understand all this co-author stuff, I hope I did not create a mixup.

@Borda
Copy link
Member

Borda commented Jun 17, 2020

we can still merge this one, @rohitgr7 🐰

@rohitgr7
Copy link
Contributor Author

@Borda Getting some problems with the tests here. Not sure why it's not showing any conflict to me locally when I rebase on the master. @awaelchli has already created a new PR that is working perfectly. I think we can close this one and merge that one.

@mergify mergify bot requested a review from a team June 18, 2020 07:34
@Borda Borda changed the base branch from master to num_batches_missing_test June 18, 2020 07:37
@mergify
Copy link
Contributor

mergify bot commented Jun 18, 2020

This pull request is now in conflict... :(

@Borda Borda merged commit 4cc7223 into Lightning-AI:num_batches_missing_test Jun 18, 2020
@Borda
Copy link
Member

Borda commented Jun 18, 2020

@rohitgr7 @awaelchli the simples solution from this situation is that I merger this PR to #2226 and then the other PR will be merged in master so this PR will have status merged for sats purposes and also this PR will be listed in changelog to be in release contributors list... hole all fine 🐰

@rohitgr7
Copy link
Contributor Author

Thanks @Borda for the fix.

@Borda Borda modified the milestones: 0.8.x, 0.8.0 Jun 18, 2020
williamFalcon pushed a commit that referenced this pull request Jun 23, 2020
* Init fix num_batches

* Fix num_batches in case of multiple dataloaders

* Apply suggestions from code review

* Changes based on suggestions

* Flake8

* Add test to check num_batches

* generalize dataloader percent check test

* fix formatting

* remove hparams

* tests

* CHANGELOG

* Update CHANGELOG.md

* max_batches can be int

* conflict and rebase

* add back the test


fix


fix message


0.0 works


Revert "fix message"

This reverts commit 839cacf8b8610f4e697e654ef6f3d2501bf23984.

* update changelog

* Update CHANGELOG.md

* Fix num batches in case of multiple dataloaders and percent_check (#1920)

* git conflict

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>

* missing union

* doc update suggestion by @rohitgr7

* extend test

* changelog

* docs add note about multiple loaders

* update changelog

* remove unused variable

Co-authored-by: rohitgr7 <rohitgr1998@gmail.com>
Co-authored-by: Jirka Borovec <Borda@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.

Incorrect number of batches when multiple test loaders are used and test_percent_check is specified
6 participants