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

Remove Strategy.on_gpu #11537

Merged
merged 8 commits into from
Jan 19, 2022
Merged

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Jan 19, 2022

What does this PR do?

Part of #10416

Reasons for removal:

  • This can be deduced from the root_device property. The property on_gpu is redundant yet it's also an abstractmethod. Requiring every strategy class to implement this is boilerplate.
  • We don't offer on_ipu or on_X for existing accelerator implementations
  • Given the Accelerator is also customizable/pluggable, the pattern of offering on_gpu and on_tpu flags doesn't scale.

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

Yes: removes the on_gpu property from the Strategy base class.
Reason: The strategy is still an experimental API, and this is part of making it stable

See #11536 for the equivalent PR removing on_tpu

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 🙃

@mergify mergify bot added the ready PRs ready to be merged label Jan 19, 2022
@ananthsub ananthsub enabled auto-merge (squash) January 19, 2022 17:46
@ananthsub ananthsub merged commit f41d1e5 into Lightning-AI:master Jan 19, 2022
@ananthsub ananthsub deleted the feat/rm-on-gpu-strategy branch January 19, 2022 23:18
@@ -296,7 +296,7 @@ def _register_ddp_hooks(self) -> None:
# In 1.8, DDP communication hooks only work with NCCL backend and SPSD (single process single device) mode
# Since 1.9, DDP communication hooks can work on all backends.
if _TORCH_GREATER_EQUAL_1_9 or (
_TORCH_GREATER_EQUAL_1_8 and self.on_gpu and self._is_single_process_single_device
_TORCH_GREATER_EQUAL_1_8 and self.root_device.type == "cuda" and self._is_single_process_single_device
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you choose to check it this way? in some places it may be necessary to differentiate between the model already being on gpu or not yet, but here and in most cases it is only about which accelerator is selected. So an isinstance check would have been more appropriate I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Includes a breaking change ready PRs ready to be merged strategy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants