Skip to content

Conversation

@awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Oct 20, 2021

What does this PR do?

Part of #10059, implements the first 3 steps which are highly coupled. Please read steps 1-3 on the issue to better follow the thought process behind this PR. Steps 1-3 are combined in this PR because they are tightly entangled. Steps 4 and 5 will be independent follow-ups.

Notes to reviewer:

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

A very tiny edge case breaking change in two hooks, LightningModule.add_to_queue and LightningModule.get_from_queue which now accept a _SimpleQueue as input instead of a torch.multiprocessing.SimpleQueue. This is however not expected to make an impact directly, since only the type hint changes while the user interface remains exactly the same.

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)
    No new tests are required. We have enough (quite expensive) ddp spawn tests that will pass and confirm that these refactors and redesigns retain the existing functionality and performance.
  • 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 🙃

Part of #1 (it's a lie, this is just here to avoid noisy GitHub bot)

cc @Borda @justusschock @awaelchli @akihironitta @tchaton @kaushikb11

@awaelchli awaelchli added feature Is an improvement or enhancement refactor design Includes a design discussion labels Oct 20, 2021
Copy link
Contributor

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

Nice!

@mergify mergify bot added the ready PRs ready to be merged label Dec 1, 2021
@four4fish
Copy link
Contributor

This is super cool!! love it!

@mergify mergify bot added the has conflicts label Dec 2, 2021
@mergify mergify bot removed the has conflicts label Dec 2, 2021
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.

Looks great! Awesome work.

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

LGTM. Just one minor comment :)

torch.cuda.empty_cache()


class _FakeQueue(list):
Copy link
Member

Choose a reason for hiding this comment

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

afaik subclassing mutable builtins (especially dict and list) can sometimes lead to unexpected results. Maybe use UserList as base class instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it!

Copy link
Contributor

Choose a reason for hiding this comment

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

@justusschock I don't think that's true nowadays: https://stackoverflow.com/questions/25464647/list-vs-userlist-and-dict-vs-userdict

list is the recommended approach for simple extension
and collections.* for complex extension

Copy link
Contributor

Choose a reason for hiding this comment

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

Quoting Raymond Hettinger (Python core dev):

"FWIW, the UserDict class in Py3.x was relocated to the collections
module. It isn't gone. We made an effort to kill it but found that
there were compelling use cases that were not a cleanly solved by any
other approach."

https://bugs.python.org/issue5402

@codecov
Copy link

codecov bot commented Dec 2, 2021

Codecov Report

Merging #10034 (2579247) into master (9beeabb) will increase coverage by 0%.
The diff coverage is 77%.

@@           Coverage Diff           @@
##           master   #10034   +/-   ##
=======================================
  Coverage      92%      92%           
=======================================
  Files         177      177           
  Lines       16554    16562    +8     
=======================================
+ Hits        15192    15204   +12     
+ Misses       1362     1358    -4     

@awaelchli awaelchli merged commit 98cb7e8 into master Dec 2, 2021
@awaelchli awaelchli deleted the feature/simple-spawn branch December 2, 2021 10:30
@awaelchli awaelchli added strategy: ddp DistributedDataParallel and removed strategy: ddp spawn labels Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

design Includes a design discussion feature Is an improvement or enhancement ready PRs ready to be merged refactor strategy: ddp DistributedDataParallel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants