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

Make WandbLogger run initialization lazy for non-spawn distributed operation #17573

Merged
merged 3 commits into from
May 5, 2023

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented May 5, 2023

What does this PR do?

Fixes #17487

Prior to 2.0, when strategy="ddp_spawn" was the default distributed strategy, the wandb logger had to solve the following problem:

  • Avoid creating empty duplicate runs in main process and rank-0 worker process
  • Avoid creating multiple runs when repeatedly calling fit/validate/test.

These were addressed by enabling the wandb-service feature (#11650), which would re-attach subprocesses to the one run created by the main process. This would avoid creating duplicated runs under different circumstances. However, the drawback to the solution is that the experiment had to be created in the main process for the service to reattach properly. This is inconsistent with other loggers who create their runs lazily, and leads to inconveniences like in #17487.

This PR removes the run initialization in WandbLogger.__init__ to make it truly lazy. The justification is that today in 2.0, the default strategy is ddp proper, with which the above issues never existed. To not break the usage with ddp_spawn, for users who still use that strategy, I "hacked" the __getstate__ so that when mp.spawn is called, the special wandb-service still gets enabled (and the run gets initialized in the main process).

cc @Borda @awaelchli @morganmcg1 @borisdayma @scottire @parambharat

@awaelchli awaelchli added logger: wandb Weights & Biases bug Something isn't working labels May 5, 2023
@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label May 5, 2023
@awaelchli awaelchli added this to the 2.0.x milestone May 5, 2023
@awaelchli awaelchli marked this pull request as ready for review May 5, 2023 03:04
@awaelchli awaelchli added the fun Staff contributions outside working hours - to differentiate from the "community" label label May 5, 2023
@mergify mergify bot added the ready PRs ready to be merged label May 5, 2023
@carmocca carmocca merged commit 71559b6 into master May 5, 2023
@carmocca carmocca deleted the bugfix/wandb-lazy-experiment branch May 5, 2023 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fun Staff contributions outside working hours - to differentiate from the "community" label logger: wandb Weights & Biases pl Generic label for PyTorch Lightning package ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LightningCLI creates wandb experiment when using --help
4 participants