Repository navigation
[BUG] Propagate dtype conversion through composed and wrapped metrics - #2467
Open
AHMETHAKANBEZIR1 wants to merge 3 commits into
Open
AHMETHAKANBEZIR1 wants to merge 3 commits into
AHMETHAKANBEZIR1 wants to merge 3 commits into
Conversation
AHMETHAKANBEZIR1
requested review from
benHeid,
fkiraly,
jdb78 and
phoeenniixx
as code owners
October 14, 2026 05:23
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2467 +/- ##
=======================================
Coverage ? 89.07%
=======================================
Files ? 218
Lines ? 11684
Branches ? 0
=======================================
Hits ? 10407
Misses ? 1277
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
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.
LLM generated content, by OpenAI Codex
Reference Issues/PRs
Independent of #1897 (input dimensions) and #1754 (checkpoint device mapping).
What does this implement/fix? Explain your changes.
MultiLoss([MAE(), MAE()]).set_dtype(torch.float64)and(MAE() + MAE()).set_dtype(torch.float64)currently change the composite's dtype but leave constituent metrics and state in float32. These metrics are held in ordinary Python lists. For a third-party TorchMetrics metric accepted by the public coercion factory, converting its wrapper also leaves the underlying metric's state in the old dtype because TorchMetrics requires its ownset_dtypecall.Delegate
set_dtypethroughMultiLoss,CompositeMetricandTorchMetricWrapper, retaining the parent conversion and fluent return value. This preserves public list representation, registration/state-dict behavior, weights and each metric's conversion semantics. Device conversion and checkpoint loading are unchanged.What should a reviewer concentrate their feedback on?
Explicit delegation through each composition boundary, including conversion after update/compute and defaults used by reset. No module-registration redesign is involved.
Did you add any tests for the change?
Twenty-five cases cover float32/float64 in both directions, no-op conversions, empty/populated state, cached compute results, reset defaults, third-party TorchMetrics wrapped through the public factory, and the string dtype API with adapted MSELoss, weighted results and analytic gradients. Clean main 6d0d18a has 13 failures and 12 passing controls; all twenty-five pass with the fix.
Complete
tests/test_metrics.py: 95 passed, 6 existing optional cpflows skips. Configured pre-commit hooks pass across all files and at commit. CPU Python 3.12.14 / PyTorch 2.13.0. Full-package, GPU, distributed and training benchmarks were not run.Any other comments?
Prepared autonomously with OpenAI Codex; no independent human review is claimed.
PR checklist