Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Fix W&B callback for distributed training #5223

Merged
merged 4 commits into from
May 26, 2021
Merged

Fix W&B callback for distributed training #5223

merged 4 commits into from
May 26, 2021

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented May 25, 2021

This was totally broken for distributed training 🤦‍♂️

@epwalsh epwalsh requested a review from dirkgr May 25, 2021 23:19
if self._watch_model:
self.wandb.watch(self.trainer.model) # type: ignore[union-attr]
self.wandb.watch(self.trainer.model) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

Is this about Item "None" of "Optional[Something]" has no attribute "watch"? I have been fixing that with assert self.wandb is not None.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's because MyPy sees it as undefined, not Optional.


import wandb

self.wandb = wandb
Copy link
Member

Choose a reason for hiding this comment

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

There is no wandb object? wandb is always global? What if two systems want to use it at the same time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Importing wandb may have side effects since at some point it spawns its own background worker(s).

Copy link
Member

Choose a reason for hiding this comment

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

That is some unfortunate API design.


self.wandb = wandb
self.wandb.init(
self._wandb_kwargs: Dict[str, Any] = dict(
Copy link
Member

Choose a reason for hiding this comment

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

Nothing wrong with this, just dict(...) is kind of an unusual way of writing {...}.

@epwalsh epwalsh merged commit 2d8f390 into main May 26, 2021
@epwalsh epwalsh deleted the wandb-fix branch May 26, 2021 04:58
Abhishek-P pushed a commit to Abhishek-P/allennlp that referenced this pull request Aug 11, 2021
* fix wandb callback for distributed training

* fix

* close out

Co-authored-by: Dirk Groeneveld <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants