-
Notifications
You must be signed in to change notification settings - Fork 423
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
Silently failing DDP syncing when initializing Metric with jsonargparse #1651
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ingCLI) `Metric`s silently fail to sync across gpus when initialized with jsonargparse (as used in the LightningCLI) This PR fixes this issue. This happens due the following combination of factors. - jsonargparse has a docstring parsing function enabled when installed with `pip install jsonargparse[signatures]` - `torchmetrics.Metric` has a docstring that mentions an optional` distributed_available_fn` - If `distributed_available_fn` is not set in `**kwargs`, `Metric.__init__` sets a default pytorch function which enables ddp syncing of metrics\ - When a metric is initialized in a yaml config, jsonargparse recognizes the `distributed_available_fn` field in the docstring and passes a default value of `distributed_available_fn=None` - Hence, any subclass of `Metric` initialized by jsonargparse has `distributed_available_fn = None`. These metrics silently fail to sync across gpus.
SkafteNicki
approved these changes
Mar 27, 2023
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1651 +/- ##
======================================
- Coverage 88% 88% -1%
======================================
Files 228 228
Lines 12448 12448
======================================
- Hits 10960 10897 -63
- Misses 1488 1551 +63 |
justusschock
approved these changes
Mar 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Metric
s silently fail to sync across gpus when initialized with jsonargparse (as used in the LightningCLI)This PR fixes this issue.
This happens due the following combination of factors.
pip install jsonargparse[signatures]
torchmetrics.Metric
has a docstring that mentions an optionaldistributed_available_fn
distributed_available_fn
is not set in**kwargs
,Metric.__init__
sets a default pytorch function which enables ddp syncing of metricsdistributed_available_fn
field in the docstring ofMetric.__init__
and passes a default value ofdistributed_available_fn=None
when initializing the metric object.Metric
initialized by jsonargparse hasdistributed_available_fn = None
. These metrics silently fail to sync across gpus.What does this PR do?
Fix broken ddp syncing of metrics.
Did you have fun?
I had a fun two days debugging this issue :-).