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

introduce has_len_all_ranks() to check the length of dataloader across ranks #9827

Merged

Conversation

ninginthecloud
Copy link
Contributor

@ninginthecloud ninginthecloud commented Oct 6, 2021

What does this PR do?

Fixes #9785

This PR has changed following:

  1. add new function has_len_all_ranks() (I'm not sure if original has_len() has been widely used by users in public, so I just add a new util function. Feel free to let me know if I just need to replace has_len() directly. ) cc: @tchaton @awaelchli
  2. add new attribute to LightningModuel/LightningDataModule allow_zero_length_dataloader_with_ddp
  3. check the total length of dataloader across all ranks
  4. update tests

test_common.py:test_evaluate[trainer_kwargs2] pytest.param(dict(accelerator="ddp_spawn", gpus=2), marks=RunIf(min_gpus=2))

Does your PR introduce any breaking changes? If yes, please list them.

No.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • 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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Oct 6, 2021

Codecov Report

Merging #9827 (aa78bb5) into master (c33df26) will decrease coverage by 4%.
The diff coverage is 92%.

❗ Current head aa78bb5 differs from pull request most recent head 6b07d00. Consider uploading reports for the commit 6b07d00 to get more accurate results

@@           Coverage Diff           @@
##           master   #9827    +/-   ##
=======================================
- Coverage      92%     89%    -4%     
=======================================
  Files         180     181     +1     
  Lines       16147   16170    +23     
=======================================
- Hits        14934   14357   -577     
- Misses       1213    1813   +600     

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

quick question. How does Detectron2 handles un-balanced batches as Lightning would definitely hanged otherwise.

pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
pytorch_lightning/plugins/training_type/tpu_spawn.py Outdated Show resolved Hide resolved
@ninginthecloud ninginthecloud force-pushed the fix/valueerror_has_len_9785_2 branch from 9a9aa21 to 4ac7426 Compare October 8, 2021 16:58
@carmocca
Copy link
Contributor

This will conflict with #9764, which one do we want to land first?

@ninginthecloud
Copy link
Contributor Author

This will conflict with #9764, which one do we want to land first?

thanks for flagging~ #9764 is already ready to go, so I guess it will land first.

@awaelchli
Copy link
Contributor

awaelchli commented Oct 18, 2021

Hey, just saw this. Sorry for the delay on my response. I won't merge #9764 until 1.5 is released because of our current feature freeze :)

@mergify mergify bot removed the has conflicts label Oct 25, 2021
@ninginthecloud
Copy link
Contributor Author

I noticed that CombinedLoader also relied on has_len() to get the length of dataloader link It's a little complicated to replace has_len() in get_len(). Any suggestions here? cc: @tchaton @awaelchli

@ninginthecloud ninginthecloud force-pushed the fix/valueerror_has_len_9785_2 branch from 70690d5 to aa78bb5 Compare October 26, 2021 05:26
@daniellepintz
Copy link
Contributor

nit: I think you wrote the wrong thing under "Does your PR introduce any breaking changes?"

@mergify mergify bot removed the has conflicts label Oct 28, 2021
@awaelchli awaelchli added data handling Generic data-related topic feature Is an improvement or enhancement labels Oct 28, 2021
@awaelchli awaelchli added this to the v1.5 milestone Oct 28, 2021
@mergify mergify bot added the has conflicts label Nov 1, 2021
@tchaton
Copy link
Contributor

tchaton commented Nov 1, 2021

@ninginthecloud Any chance you can get this PR ready for tomorrow ?

@mergify mergify bot removed the has conflicts label Nov 2, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@rohitgr7 rohitgr7 enabled auto-merge (squash) November 2, 2021 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data handling Generic data-related topic feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace ValueError with warning in has_len()
8 participants