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

Add half precision testing [1/n] #77

Merged
merged 21 commits into from
Mar 26, 2021
Merged

Add half precision testing [1/n] #77

merged 21 commits into from
Mar 26, 2021

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Mar 14, 2021

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 to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Issue #57
Adds testing interface for half precision and apply to few metrics.
Follow up PRs will add the testing to remaining metrics and add documentation to metrics where it will not work.

Note, that we cannot really do anything about it not working for some of the metrics as some pytorch operations (e.g torch.log) does not support half precision + cpu.

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 🙃

@SkafteNicki SkafteNicki added documentation Improvements or additions to documentation test / CI testing or CI labels Mar 14, 2021
@codecov
Copy link

codecov bot commented Mar 14, 2021

Codecov Report

Merging #77 (bf78331) into master (64f3c12) will increase coverage by 0.21%.
The diff coverage is 100.00%.

❗ Current head bf78331 differs from pull request most recent head 569657e. Consider uploading reports for the commit 569657e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master      #77      +/-   ##
==========================================
+ Coverage   96.67%   96.89%   +0.21%     
==========================================
  Files         148       74      -74     
  Lines        4632     2319    -2313     
==========================================
- Hits         4478     2247    -2231     
+ Misses        154       72      -82     
Flag Coverage Δ
Linux 79.17% <60.00%> (-0.02%) ⬇️
Windows 79.17% <60.00%> (-0.02%) ⬇️
cpu 96.89% <100.00%> (+0.34%) ⬆️
gpu ?
macOS 96.89% <100.00%> (+0.34%) ⬆️
pytest 96.89% <100.00%> (+0.21%) ⬆️
python3.6 95.67% <100.00%> (-0.86%) ⬇️
python3.8 ?
python3.9 96.89% <100.00%> (+0.34%) ⬆️
torch1.3.1 95.67% <100.00%> (+0.35%) ⬆️
torch1.4.0 ?
torch1.8.1 96.89% <100.00%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...cs/functional/regression/mean_squared_log_error.py 100.00% <ø> (ø)
torchmetrics/regression/mean_squared_log_error.py 100.00% <ø> (ø)
torchmetrics/regression/psnr.py 100.00% <ø> (ø)
...etrics/functional/regression/mean_squared_error.py 100.00% <100.00%> (ø)
torchmetrics/functional/regression/psnr.py 96.96% <100.00%> (+0.09%) ⬆️
torchmetrics/utilities/imports.py 78.57% <100.00%> (+0.79%) ⬆️
...rics/functional/classification/hamming_distance.py
__w/1/s/torchmetrics/__init__.py
.../s/torchmetrics/classification/confusion_matrix.py
__w/1/s/torchmetrics/regression/ssim.py
... and 71 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64f3c12...569657e. Read the comment docs.

@Borda Borda marked this pull request as draft March 14, 2021 16:58
@SkafteNicki SkafteNicki marked this pull request as ready for review March 16, 2021 14:05
@SkafteNicki SkafteNicki changed the title [WIP] Add half precision testing [1/n] Add half precision testing [1/n] Mar 16, 2021
@Borda
Copy link
Member

Borda commented Mar 17, 2021

can we rather use this function version? Lightning-AI/pytorch-lightning#6434

@SkafteNicki
Copy link
Member Author

can we rather use this function version? PyTorchLightning/pytorch-lightning#6434

Of course :]

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

tests/helpers/testers.py Outdated Show resolved Hide resolved
Comment on lines 96 to 97
@pytest.mark.skipif(
not _TORCH_GREATER_EQUAL_1_6,
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we really should skip here or show a more meaningful error message.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@justusschock you got any proposal?

Copy link
Contributor

Choose a reason for hiding this comment

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

@justusschock more meaningful message in test or the class itself? wouldn't be easier to test for half precision tensors in the base metric class and check if torch version >= 1.6

@Borda
Copy link
Member

Borda commented Mar 23, 2021

@SkafteNicki mind resolve conflicts... :]

@Borda Borda added the ready label Mar 24, 2021
@Borda Borda self-requested a review March 24, 2021 19:18
@SkafteNicki SkafteNicki enabled auto-merge (squash) March 25, 2021 08:33
@Borda Borda added this to the 0.3 milestone Mar 25, 2021
tests/helpers/testers.py Outdated Show resolved Hide resolved
@SkafteNicki SkafteNicki merged commit 7a379e9 into master Mar 26, 2021
@SkafteNicki SkafteNicki deleted the half_testing1 branch March 26, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation ready test / CI testing or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants