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

[BUG] cuNumeric and Numpy get different output on BinaryOp nextafter when the input data type is float16 #1097

Closed
XiaLuNV opened this issue Nov 30, 2023 · 4 comments

Comments

@XiaLuNV
Copy link
Contributor

XiaLuNV commented Nov 30, 2023

Software versions

Python : 3.10.9 | packaged by conda-forge
Platform : Linux 5.15.0-83-generic #92-Ubuntu
Cunumeric : 24.01
Numpy : 1.23.5
CTK package : cuda-version-12.4
GPU driver : 550.00
GPU devices :
GPU 0: NVIDIA H100
GPU 1: NVIDIA H100

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

For tests
https://github.com/nv-legate/cunumeric/blob/branch-24.01/tests/integration/test_binary_ufunc.py
for op = 'nextafter'
When the type of input data is float16, the results between Numpy and cuNumeric are different.
It failed on allclose(out_np, out_num).

Observed behavior

First 5 differences for allclose:
Numpy cuNumeric
index (0, 0): 0.07916259765625 0.0791015625
index (0, 1): 0.373291015625 0.373046875
index (0, 2): 0.93408203125 0.93359375
index (0, 3): 0.4189453125 0.418701171875
index (0, 4): 0.234375 0.2342529296875

With diff_limit=5

cunumeric.nextafter failed the test
Inputs:
[[0.0791 0.373 0.9336 0.4187 0.2343 ]
[0.5723 0.5723 0.417 0.626 0.2203 ]
[0.622 0.4778 0.974 0.773 0.02715]
[0.2211 0.1203 0.1753 0.4294 0.6577 ]]
dtype: float16
2
dtype: uint64
NumPy output:
[[0.07916 0.3733 0.934 0.419 0.2344 ]
[0.5728 0.5728 0.4172 0.6265 0.2205 ]
[0.6226 0.478 0.9746 0.7734 0.02716]
[0.2212 0.12036 0.1754 0.4297 0.658 ]]
dtype: float16
cuNumeric output:
[[0.0791 0.373 0.9336 0.4187 0.2343 ]
[0.5723 0.5723 0.417 0.626 0.2203 ]
[0.622 0.4778 0.974 0.773 0.02715]
[0.2211 0.1203 0.1753 0.4294 0.6577 ]]
dtype: float16

Example code or instructions

Adds 
np.random.uniform(size=(4, 5)).astype("e")
in https://github.com/nv-legate/cunumeric/blob/branch-24.01/tests/integration/test_binary_ufunc.py#L131

Stack traceback or browser console output

No response

@manopapad
Copy link
Contributor

This is an issue with limited accuracy of operations on half-width floats. Can you please try doing it similarly to what the einsum test is doing? https://github.com/nv-legate/cunumeric/blob/branch-24.01/tests/integration/test_einsum.py#L234

@XiaLuNV
Copy link
Contributor Author

XiaLuNV commented Dec 6, 2023

It works. Thanks.

@manopapad
Copy link
Contributor

Excellent! Please make a PR with the fixes when you can.

@XiaLuNV
Copy link
Contributor Author

XiaLuNV commented Dec 6, 2023

The PR about this was merged. Say #1100.

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

No branches or pull requests

2 participants