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

is-instance check to determine the type of a plugin for teardown decision #8741

Merged
merged 2 commits into from
Aug 9, 2021

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Aug 5, 2021

What does this PR do?

Addresses a comment on recently merged PR #8685 (comment) which got missed/misinterpreted regarding the check for a type of plugin.

The plugin types classified as "interactive_compatible_types" do not relate directly to the plugin types that require a special place for teardown. These are the plugins that use the multiprocessing "spawn" method to create new processes but the DP plugin is NOT of this type and with the recent changes now does not have a teardown anymore.
Also, with #8685 custom accelerators would not receive a teardown.

This PR fixes that.

NOTE: labelling this as 1.5 bugfix as #8685 was also labelled this way.

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?

I made sure I had fun coding 🙃

@awaelchli awaelchli changed the title add isinstance check isinstance check to determine the type of a plugin for teardown logic Aug 5, 2021
@awaelchli awaelchli changed the title isinstance check to determine the type of a plugin for teardown logic isinstance check to determine the type of a plugin for teardown decision Aug 5, 2021
@awaelchli awaelchli changed the title isinstance check to determine the type of a plugin for teardown decision is-instance check to determine the type of a plugin for teardown decision Aug 5, 2021
@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #8741 (894941d) into master (efec3d4) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #8741   +/-   ##
======================================
- Coverage      93%     93%   -0%     
======================================
  Files         169     169           
  Lines       14071   14070    -1     
======================================
- Hits        13040   13039    -1     
  Misses       1031    1031           

@awaelchli awaelchli added bug Something isn't working logger Related to the Loggers labels Aug 5, 2021
@awaelchli awaelchli added this to the v1.5 milestone Aug 5, 2021
@awaelchli awaelchli marked this pull request as ready for review August 5, 2021 09:39
@@ -947,7 +946,7 @@ def _run(self, model: "pl.LightningModule") -> Optional[Union[_EVALUATE_OUTPUT,

# teardown if necessary (similar calls for spawn plugins are excluded as they have
# been included at the end of `new_process` functions)
if self._distrib_type not in DistributedType.interactive_compatible_types():
if not isinstance(self.training_type_plugin, DDPSpawnPlugin):
Copy link
Contributor

Choose a reason for hiding this comment

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

  • should we add a test to confirm DDP spawn and other parallel plugins all work as expected to avoid potential regressions here in the future?
  • for custom plugins, this doesn't generalize unless they all extend DDP Spawn. should the plugin denote that it uses multiprocessing spawn method to create new processes, and that we need this in order to determine the appropriate teardown?

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 it does not generalize to plugins that do spawn but are not subclassing our ddp spawn plugin, but this was a tradeoff introduced in #8685. However, the change in this PR covers the case of plugins that don't spawn and therefore get a teardown at the right place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely, agreed that we should fix this first. I meant the custom plug-in support as a follow up beyond the scope of this PR

@ananthsub ananthsub added the ready PRs ready to be merged label Aug 5, 2021
@mergify mergify bot requested a review from a team August 5, 2021 15:44
@mergify mergify bot requested a review from a team August 5, 2021 16:21
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 !

@tchaton tchaton merged commit d41de6c into master Aug 9, 2021
@tchaton tchaton deleted the bugfix/isinstance-check-plugin branch August 9, 2021 14:31
four4fish pushed a commit to four4fish/pytorch-lightning that referenced this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger Related to the Loggers ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants