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

Prevent metric dtype conversion when metric is part of LightningModule #1583

Merged
merged 17 commits into from
Mar 7, 2023

Conversation

FarzanT
Copy link
Contributor

@FarzanT FarzanT commented Mar 3, 2023

What does this PR do?

Fixes #1561

Added a simple check to prevent applying .half() and .float() calls that are passed on the LightningModule to metric states and defaults. Instead, users will have to use set_dtype(), as proposed in #493.

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 🙃

@codecov
Copy link

codecov bot commented Mar 4, 2023

Codecov Report

Merging #1583 (cfee14a) into master (0208d74) will decrease coverage by 0%.
The diff coverage is 38%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1583   +/-   ##
======================================
- Coverage      88%     88%   -0%     
======================================
  Files         225     225           
  Lines       11926   11938   +12     
======================================
+ Hits        10547   10555    +8     
- Misses       1379    1383    +4     

@mergify mergify bot added the has conflicts label Mar 5, 2023
@mergify mergify bot removed the has conflicts label Mar 6, 2023
@SkafteNicki SkafteNicki added the bug / fix Something isn't working label Mar 6, 2023
@SkafteNicki SkafteNicki added this to the v0.12 milestone Mar 6, 2023
@mergify mergify bot added the ready label Mar 6, 2023
src/torchmetrics/metric.py Show resolved Hide resolved
@Borda Borda changed the title Prevent metric state dtype conversion when metric is part of LightningModule Prevent metric dtype conversion when metric is part of LightningModule Mar 6, 2023
@Borda Borda enabled auto-merge (squash) March 6, 2023 14:23
@mergify mergify bot removed the has conflicts label Mar 6, 2023
@Borda
Copy link
Member

Borda commented Mar 6, 2023

seems that the GPU tests are hanging... 🤔

@Borda Borda merged commit 21b23b6 into Lightning-AI:master Mar 7, 2023
Borda pushed a commit that referenced this pull request Mar 10, 2023
…dule` (#1583)

Co-authored-by: Nicki Skafte Detlefsen <skaftenicki@gmail.com>

(cherry picked from commit 21b23b6)
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
Development

Successfully merging this pull request may close these issues.

DeepSpeed still changes metric states from fp32 to fp16
4 participants