Skip to content

Relax float16 tolerance in cupy trigonometric binary tests#3005

Merged
antonwolfy merged 1 commit into
masterfrom
fix-arctan2-fp16-tolerance
Jul 23, 2026
Merged

Relax float16 tolerance in cupy trigonometric binary tests#3005
antonwolfy merged 1 commit into
masterfrom
fix-arctan2-fp16-tolerance

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The GitHub workflow might fail on third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arctan2:

Mismatched elements: 1 / 6 (16.7%)
 [0, 1]: 0.38037109375 (ACTUAL, dpnp), 0.380615234375 (DESIRED, numpy)
Max absolute difference: 0.0002441

This is the float16 ("e" dtype) parametrization of check_binary("arctan2"), which asserts with a flat atol=1e-5. That tolerance is tighter than the resolution of float16 — one ULP near 0.38 is ~2.4e-4.

This PR proposes to use a float16-aware tolerance. for check_binary.
This mirrors the pattern already used by check_unary_unit in the same file, and leaves the default 1e-5 tolerance unchanged for all higher-precision dtypes.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

check_binary asserted with a flat atol=1e-5, which is tighter than the
resolution of float16 (one ULP near 0.38 is ~2.4e-4). This made
test_arctan2 (and other binary trig tests) flaky for the float16 ("e")
dtype: the Intel OpenCL CPU runtime's transcendental arctan2 can round
the last bit differently depending on the runner CPU microarchitecture,
producing a 1-ULP disagreement with NumPy that exceeded atol=1e-5.

Use a float16-aware tolerance (atol={float16: 1e-3, default: 1e-5}),
mirroring the pattern already used by check_unary_unit in the same file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antonwolfy antonwolfy self-assigned this Jul 22, 2026
@antonwolfy
antonwolfy marked this pull request as ready for review July 22, 2026 14:01

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM
Thank you @antonwolfy

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/index.html

@github-actions

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev3=py314h509198e_10 ran successfully.
Passed: 1375
Failed: 2
Skipped: 5

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

No base build to compare — fix-arctan2-fp16-tolerance into master

@vlad-perevezentsev
vlad-perevezentsev self-requested a review July 23, 2026 10:07
@antonwolfy
antonwolfy merged commit 615dbf5 into master Jul 23, 2026
77 of 83 checks passed
@antonwolfy
antonwolfy deleted the fix-arctan2-fp16-tolerance branch July 23, 2026 10:08
github-actions Bot added a commit that referenced this pull request Jul 23, 2026
The GitHub workflow might fail on
`third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arctan2`:
```
Mismatched elements: 1 / 6 (16.7%)
 [0, 1]: 0.38037109375 (ACTUAL, dpnp), 0.380615234375 (DESIRED, numpy)
Max absolute difference: 0.0002441
```

This is the `float16` (`"e"` dtype) parametrization of
`check_binary("arctan2")`, which asserts with a flat `atol=1e-5`. That
tolerance is tighter than the resolution of float16 — one ULP near 0.38
is ~2.4e-4.

This PR proposes to use a float16-aware tolerance. for `check_binary`.
This mirrors the pattern already used by `check_unary_unit` in the same
file, and leaves the default `1e-5` tolerance unchanged for all
higher-precision dtypes. 615dbf5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants