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

Sharded Plugin 3/n: Expose step input to DDP plugin #4686

Merged
merged 13 commits into from
Nov 18, 2020

Conversation

SeanNaren
Copy link
Contributor

@SeanNaren SeanNaren commented Nov 15, 2020

What does this PR do?

Relates to #4178

ShardedDDP needs to move the device to the GPU before passing through to the model. This is not the case for DDP which handles this internally. Allows other custom DDP parallel plugins an opportunity to modify the input before passing into the wrapper!

cc @williamFalcon @tchaton @awaelchli @Borda

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 in short, see 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; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

@SeanNaren SeanNaren added the distributed Generic distributed-related topic label Nov 15, 2020
@SeanNaren SeanNaren added this to the 1.1 milestone Nov 15, 2020
@@ -61,21 +61,23 @@ def train(self):
return self.ddp_train(process_idx=self.task_idx, mp_queue=None, model=model)

def training_step(self, args):
return self._step(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. this is better haha.

@codecov
Copy link

codecov bot commented Nov 15, 2020

Codecov Report

Merging #4686 (add1dc1) into master (5fd1afb) will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #4686   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files         117     117           
  Lines        8939    8941    +2     
======================================
+ Hits         8306    8308    +2     
  Misses        633     633           

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.

LGTM !

@Borda Borda added the feature Is an improvement or enhancement label Nov 18, 2020
@pep8speaks
Copy link

pep8speaks commented Nov 18, 2020

Hello @SeanNaren! Thanks for updating this PR.

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

Comment last updated at 2020-11-18 14:16:08 UTC

return self._step(args)

def _step(self, args):
args = self.ddp_plugin.on_before_forward(self.trainer.get_model(), *args)
Copy link
Contributor

Choose a reason for hiding this comment

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

love it

@SeanNaren SeanNaren merged commit 8283680 into master Nov 18, 2020
@SeanNaren SeanNaren deleted the feature/817-fairscale-3n-redo branch November 18, 2020 15:45
rohitgr7 pushed a commit that referenced this pull request Nov 21, 2020
* Allow ddp plugin to move the input to a different device if needed

* Swapped name to on_before_forward to align with hooks in the future

* Update pytorch_lightning/plugins/ddp_plugin.py

Co-authored-by: Jirka Borovec <[email protected]>

* Pass variable arg type to hook, add example

* Remove blank space (pep check)

* Added blank line

Co-authored-by: William Falcon <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Generic distributed-related topic feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants