Fix test tolerances for float16 precision in math tests#2828
Open
antonwolfy wants to merge 4 commits intomasterfrom
Open
Fix test tolerances for float16 precision in math tests#2828antonwolfy wants to merge 4 commits intomasterfrom
antonwolfy wants to merge 4 commits intomasterfrom
Conversation
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/2828/index.html |
Contributor
|
Array API standard conformance tests for dpnp=0.20.0dev4=py313h509198e_21 ran successfully. |
Collaborator
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.
This PR fixes test failures when testing with
DPNP_TEST_ALL_INT_TYPES=1against conda-forge's NumPy, where float16 precision is used in various scenarios requiring relaxed tolerances.Issue
Tests were failing with tolerance violations when using int8/uint8 dtypes or when outputs have float16 precision. Float16 has approximately 3 decimal digits of precision, making the original strict tolerances (atol=1e-5, rtol=1e-7) inappropriate.
Changes
1. test_explog.py (commit f00eda8)
_rtol_dictto handle float16 output dtype2. test_hyperbolic.py (commit dbb7199)
_rtol_dictto handle float16 output dtype3. test_misc.py + testing framework (commit 9b108ec)
Framework enhancement:
_resolve_tolerance()intesting/_loops.pyto support callable tolerance functions(result_dtype, **test_kwargs)enabling dynamic tolerance based on test parameters_check_tolerance_keys()Test implementation:
_interp_atol()method that dynamically adjusts tolerance based ondtype_xThis approach was necessary because test_interp has float16 precision in intermediate computation (sin(fx)) rather than output, requiring inspection of input dtypes rather than output dtypes.