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

Fix incorrect caching of MetricCollection #2571

Merged

Conversation

relativityhd
Copy link
Contributor

@relativityhd relativityhd commented May 28, 2024

What does this PR do?

Fixes #2570. Also provides a better test for #2211. A somewhat larger change is that for this fix (especially the testcases) the compute method needs to return deepcopied values.

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
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 🙃


📚 Documentation preview 📚: https://torchmetrics--2571.org.readthedocs.build/en/2571/

Also update tests to correctly test for Lightning-AI#2211.
Also add return deepcopy values of compute
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 add chlog entry

@SkafteNicki SkafteNicki added the bug / fix Something isn't working label May 30, 2024
@SkafteNicki SkafteNicki added this to the v1.3.x milestone May 30, 2024
@mergify mergify bot removed the has conflicts label May 30, 2024
@Borda
Copy link
Member

Borda commented May 31, 2024

@SkafteNicki this is everywhere: RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment

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.

we need to make this work without deepcopy of the values

src/torchmetrics/metric.py Outdated Show resolved Hide resolved
src/torchmetrics/metric.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69%. Comparing base (599991d) to head (8efc828).
Report is 94 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #2571   +/-   ##
======================================
- Coverage      69%     69%   -0%     
======================================
  Files         314     314           
  Lines       17673   17679    +6     
======================================
+ Hits        12186   12189    +3     
- Misses       5487    5490    +3     

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.

Okay, changing the deepcopy to clone works out. Thanks for the contribution!

@SkafteNicki SkafteNicki enabled auto-merge (squash) May 31, 2024 11:25
@mergify mergify bot added the ready label Jun 1, 2024
@SkafteNicki SkafteNicki merged commit 6a23b38 into Lightning-AI:master Jun 1, 2024
61 checks passed
Borda pushed a commit that referenced this pull request Aug 2, 2024
* Fix incorrect caching of MetricCollection

Also update tests to correctly test for #2211.
Also add return deepcopy values of compute

* Update Changelog

* fix issues with deepcopy by using .clone

---------

Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <[email protected]>
(cherry picked from commit 6a23b38)
Borda pushed a commit that referenced this pull request Aug 2, 2024
* Fix incorrect caching of MetricCollection

Also update tests to correctly test for #2211.
Also add return deepcopy values of compute

* Update Changelog

* fix issues with deepcopy by using .clone

---------

Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <[email protected]>
(cherry picked from commit 6a23b38)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working ready
Projects
None yet
3 participants