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

Move add_to_queue/get_from_queue to DDPSpawnPlugin #9118

Merged
merged 30 commits into from
Sep 10, 2021

Conversation

daniellepintz
Copy link
Contributor

@daniellepintz daniellepintz commented Aug 25, 2021

What does this PR do?

Fixes #8940

Deprecates add_to_queue/get_from_queue from Lightning Module and moves them to DDPSpawnPlugin, since they are relevant specifically to ddp_spawn, and don't need to be on the generic lightning module.

This is part of the initiative to remove trainer reference from Lightning Module #7315.

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 🙃

@ananthsub ananthsub added the deprecation Includes a deprecation label Aug 25, 2021
@tchaton
Copy link
Contributor

tchaton commented Aug 27, 2021

Dear @daniellepintz,

Mind sharing why this PR won't be finalised ? I still believe this is important for users to have the ability to access to queue easily to bring anything back if needed like best_score from Model Checkpoint or anything.

callback_metrics for example doesn't hold the best value and therefore won't be fully accurate for Optuna.

Best,
T.C

@daniellepintz
Copy link
Contributor Author

@tchaton sorry for the lack of communication. My understanding from reading #7671 is that #9126 resolves the problem described, and in a much cleaner way than this PR by deprecating the add_to_q/get_from_q functions. Maybe I am not fully understanding the Optuna issue, is there another place other than #7671 where it is explained? My issue with this PR is that it is a bit messy and complicated - but if it is needed I can reopen and finish it.

@tchaton
Copy link
Contributor

tchaton commented Aug 29, 2021

Hey @daniellepintz,

Returning callack_metrics should not be enough as for HPO, we are interested by the best value possible and this information is hold by the ModelCheckpoint(s) callbacks.

Therefore, we should extend the add_to_queue/get_from_q to also return ModelCheckpoint callback states and reset them on the main process.

def objective(trial):
    ...
    trainer = Trainer(accelerator="ddp_spawn", gpus=2, callback=ModelCheckpoint(monitor="val_acc"))
    trainer.fit(...)
    return trainer.model_checkpoint.best_score

IMO, I would prefer to add those hooks to DDPSpawn as I can imagine other use-cases where users might want to bring some information from the spawned processes.

Best,
T.C

@daniellepintz
Copy link
Contributor Author

@tchaton sounds good I will reopen the PR and finish it!

@daniellepintz daniellepintz reopened this Sep 1, 2021
@tchaton
Copy link
Contributor

tchaton commented Sep 1, 2021

@tchaton sounds good I will reopen the PR and finish it!

Hey @daniellepintz. Thanks a lot for your understanding !

We might not have users right now but I have the intuition this simple mechanism to access spawned processes states through the queue might become useful in the future. Optuna was our first real use-case.

Best,
T.C

@codecov
Copy link

codecov bot commented Sep 2, 2021

Codecov Report

Merging #9118 (e73b419) into master (58de08d) will decrease coverage by 4%.
The diff coverage is 77%.

@@           Coverage Diff           @@
##           master   #9118    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         179     180     +1     
  Lines       14925   15065   +140     
=======================================
- Hits        13866   13373   -493     
- Misses       1059    1692   +633     

Co-authored-by: ananthsub <[email protected]>
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 ! Thanks.

@daniellepintz Side note, this could be enabled for TPUSpawn too.

@daniellepintz
Copy link
Contributor Author

@tchaton yes it should work for TPUSpawn as well after this PR

@mergify mergify bot added has conflicts and removed ready PRs ready to be merged labels Sep 6, 2021
@mergify mergify bot removed the has conflicts label Sep 6, 2021
@tchaton tchaton requested a review from Borda September 7, 2021 07:43
@mergify mergify bot added the has conflicts label Sep 9, 2021
@daniellepintz
Copy link
Contributor Author

@Borda mind taking a look?

@mergify mergify bot removed the has conflicts label Sep 10, 2021
@mergify mergify bot added the ready PRs ready to be merged label Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Includes a deprecation ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate add_to_queue / get_from_queue
6 participants