IntelPython / dpnp

Data Parallel Extension for NumPy
BSD 2-Clause "Simplified" License
97 stars 22 forks source link

dpnp.linalg.cholesky gives incorrect result #489

Open reazulhoque opened 3 years ago

reazulhoque commented 3 years ago

The following reproducer provides incorrect result

import dpnp as inp
import numpy

a = numpy.array([[1, -2], [2, 5]])
ia = inp.array(a)

result = inp.linalg.cholesky(ia)
expected = numpy.linalg.cholesky(a)
print(result, expected)
numpy.testing.assert_array_equal(expected, result)

Output:

Running on: Intel(R) Graphics [0x9bca]
DPCtrl SYCL queue used
SYCL kernels link time: 0.182842 (sec.)

1 64 1 94781700026248 <__str__ TODO> [[1. 0.]
 [2. 1.]]
Traceback (most recent call last):
  File "cholesky_reproducer.py", line 10, in <module>
    numpy.testing.assert_array_equal(expected, result)
  File "/localdisk/work/rhoque/conda_envs/ms141/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 931, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/localdisk/work/rhoque/conda_envs/ms141/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not equal

Mismatched elements: 3 / 4 (75%)
Max absolute difference: 9.47817e+13
Max relative difference: 1.
 x: array([[1., 0.],
       [2., 1.]])
 y: array([[             1,             64],
       [             1, 94781700026248]])
shssf commented 3 years ago

On the master (some fixes in cholesky implemented recently) I tried the program you mentioned:

output

dpnp$ python ./gg.py 
Running on: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
queue initialization time: 0.000126593 (sec.)
SYCL kernels link time: 0.0485176 (sec.)

[[1. 0.]
 [2. 1.]] [[1. 0.]
 [2. 1.]]

I didn't try it with DPctl and with GPU yet.