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

[feat] Add better support for predict + ddp 2/3 #7215

Merged
merged 50 commits into from
Apr 27, 2021
Merged

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Apr 26, 2021

What does this PR do?

Here is PR 1/2: #7141
This PR adds better support for predict.

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 update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
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 🙃

Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM 😃 small comments

pytorch_lightning/core/datamodule.py Outdated Show resolved Hide resolved
pytorch_lightning/core/lightning.py Outdated Show resolved Hide resolved
pytorch_lightning/overrides/distributed.py Outdated Show resolved Hide resolved
@tchaton tchaton enabled auto-merge (squash) April 26, 2021 17:43
Copy link
Contributor

@kaushikb11 kaushikb11 left a comment

Choose a reason for hiding this comment

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

LGTM!

pytorch_lightning/overrides/distributed.py Show resolved Hide resolved
pytorch_lightning/overrides/distributed.py Show resolved Hide resolved
pytorch_lightning/overrides/distributed.py Show resolved Hide resolved
pytorch_lightning/overrides/distributed.py Show resolved Hide resolved
pytorch_lightning/overrides/distributed.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
pytorch_lightning/utilities/xla_device.py Outdated Show resolved Hide resolved
tests/loggers/test_all.py Outdated Show resolved Hide resolved
tests/loggers/test_base.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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.

why do you make the returning of predictions optional? what difference does it make?

tests/overrides/test_distributed.py Outdated Show resolved Hide resolved
tests/overrides/test_distributed.py Show resolved Hide resolved
Comment on lines 50 to 52
@property
def use_spawn(self) -> bool:
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid this. Can we do isinstance check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I find it less clean.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is this style of adding properties that identify each plugin will not scale long term and at the finest granularity it is the same as an instance check.

it could be part of the accelerator connector refactor one day. The use_spawn could be handled by the connector.

pytorch_lightning/trainer/data_loading.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/predict_loop.py Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
@Borda Borda modified the milestones: v1.3, v1.4 Apr 27, 2021
@@ -75,3 +76,70 @@ def prepare_for_backward(model: DistributedDataParallel, output: Any):
model.reducer.prepare_for_backward([])
else:
model.require_forward_param_sync = False


class UnrepeatedDistributedSampler(DistributedSampler):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is NoPaddingDistributedSampler clearer?

Copy link
Contributor

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

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

Nice cleanup as well @tchaton :)

@tchaton tchaton added the admin Requires admin privileges to merge label Apr 27, 2021
@lexierule lexierule disabled auto-merge April 27, 2021 12:46
@lexierule lexierule merged commit e147127 into master Apr 27, 2021
@lexierule lexierule deleted the predict_loop_1_n branch April 27, 2021 12:46
@Borda
Copy link
Member

Borda commented Apr 27, 2021

why do you make the returning of predictions optional? what difference does it make?

Any comment here? @tchaton

@carmocca carmocca modified the milestones: v1.4, v1.3 Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin Requires admin privileges to merge distributed Generic distributed-related topic feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants