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

Metric aggregation #3321

Merged
merged 23 commits into from
Sep 14, 2020
Merged

Metric aggregation #3321

merged 23 commits into from
Sep 14, 2020

Conversation

justusschock
Copy link
Member

Allows aggregation on the same device as well as across multiple devices in DDP

Fixes #3245

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • 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? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@justusschock justusschock self-assigned this Sep 2, 2020
@pep8speaks
Copy link

pep8speaks commented Sep 2, 2020

Hello @justusschock! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-09-13 15:02:08 UTC

@mergify mergify bot requested a review from a team September 2, 2020 11:29
@justusschock
Copy link
Member Author

@SkafteNicki Do we need a default reduce op for base classes? I don't think so, since currently it's all gathered and no op is done during ddp sync

Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

Really nice changes:
I completely agree that we do not need the reduce_op argument anymore for the base class.

pytorch_lightning/metrics/converters.py Show resolved Hide resolved
pytorch_lightning/metrics/metric.py Show resolved Hide resolved
pytorch_lightning/metrics/metric.py Show resolved Hide resolved
pytorch_lightning/metrics/metric.py Show resolved Hide resolved
tests/metrics/test_metrics.py Show resolved Hide resolved
@mergify mergify bot requested a review from a team September 3, 2020 09:24
@justusschock
Copy link
Member Author

@SkafteNicki I fixed the tests to be compliant to our current behaviour. All changes to aggregation will be done in following PRs :)

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

a bit much with all the black formatting :)
just two feedbacks:

  1. reduce op docstring is left over
  2. stacking only works if all the dims are the same, is this assumption correct?

pytorch_lightning/metrics/classification.py Outdated Show resolved Hide resolved
pytorch_lightning/metrics/classification.py Show resolved Hide resolved
pytorch_lightning/metrics/converters.py Outdated Show resolved Hide resolved
pytorch_lightning/metrics/metric.py Show resolved Hide resolved
pytorch_lightning/metrics/sklearns.py Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team September 3, 2020 18:51
@mergify mergify bot requested a review from a team September 3, 2020 18:52
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
@SkafteNicki
Copy link
Member

we have one test that are failing: test_model_pickable[DummyNumpyMetric] in file tests/metrics/test_metrics.
The test succeeds when we are using DummyTensorMetric but fails with DummyNumpyMetric. I wonder if the error is fixed, if the the special aggregation for TensorMetric also is implemented for NumpyMetric?

@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #3321 into master will decrease coverage by 5%.
The diff coverage is 93%.

@@           Coverage Diff            @@
##           master   #3321     +/-   ##
========================================
- Coverage      85%     80%     -5%     
========================================
  Files         104     118     +14     
  Lines        8149    9750   +1601     
========================================
+ Hits         6950    7844    +894     
- Misses       1199    1906    +707     

@mergify mergify bot requested a review from a team September 10, 2020 19:45
@Borda Borda added the ready PRs ready to be merged label Sep 10, 2020
@Borda Borda self-requested a review September 10, 2020 19:57
@Borda
Copy link
Member

Borda commented Sep 10, 2020

we have one test that are failing: test_model_pickable[DummyNumpyMetric] in file tests/metrics/test_metrics.
The test succeeds when we are using DummyTensorMetric but fails with DummyNumpyMetric. I wonder if the error is fixed, if the the special aggregation for TensorMetric also is implemented for NumpyMetric?

it seems to be appearing just in this PR, it is not presented in master... it shall be patched so we do not break master...

@Borda Borda removed the ready PRs ready to be merged label Sep 10, 2020
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

let's fix the failing test...

@mergify mergify bot requested a review from a team September 10, 2020 21:31
@mergify
Copy link
Contributor

mergify bot commented Sep 10, 2020

This pull request is now in conflict... :(

@s-rog
Copy link
Contributor

s-rog commented Sep 11, 2020

Should lightning support variable sizes (in batch dimension) in gather all?

@SkafteNicki
Copy link
Member

@Borda I fixed the failing test, can I merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metric Aggregation
7 participants