Open kmaehashi opened 3 years ago
This happened again: https://ci.preferred.jp/cupy.linux.cuda11x-cuda-python/93968/
FAILED cupy_tests/test_cusparse.py::TestSparseMatrixConversion::test_denseToSparse[_param_15_{density=0.5, format='coo', shape=(3, 4)}]
01:00:58.626466 STDOUT 1593] | _ TestSparseMatrixConversion.test_denseToSparse[_param_15_{density=0.5, format='coo', shape=(3, 4)}] _ |
01:00:58.626469 STDOUT 1593] | |
01:00:58.626475 STDOUT 1593] | self = <<cupy_tests.test_cusparse.TestSparseMatrixConversion object at 0x7fea8d89a800> parameter: {'density': 0.5, 'format': 'coo', 'shape': (3, 4)}> |
01:00:58.626580 STDOUT 1593] | dtype = <class 'numpy.float32'> |
01:00:58.626585 STDOUT 1593] | |
01:00:58.626612 STDOUT 1593] | @skip_HIP_0_size_matrix() |
01:00:58.626614 STDOUT 1593] | @testing.for_dtypes('fdFD') |
01:00:58.626619 STDOUT 1593] | def test_denseToSparse(self, dtype): |
01:00:58.626706 STDOUT 1593] | if not cusparse.check_availability('denseToSparse'): |
01:00:58.626710 STDOUT 1593] | pytest.skip('denseToSparse is not available') |
01:00:58.626721 STDOUT 1593] | x = cupy.random.uniform(0, 1, self.shape).astype(dtype) |
01:00:58.626760 STDOUT 1593] | x[x < self.density] = 0 |
01:00:58.626770 STDOUT 1593] | > y = cusparse.denseToSparse(x, format=self.format) |
01:00:58.626776 STDOUT 1593] | |
01:00:58.626802 STDOUT 1593] | dtype = <class 'numpy.float32'> |
01:00:58.626805 STDOUT 1593] | self = <<cupy_tests.test_cusparse.TestSparseMatrixConversion object at 0x7fea8d89a800> parameter: {'density': 0.5, 'format': 'coo', 'shape': (3, 4)}> |
01:00:58.626859 STDOUT 1593] | x = array([[0. , 0. , 0. , 0. ], |
01:00:58.626862 STDOUT 1593] | [0. , 0.86181563, 0. , 0. ], |
01:00:58.626867 STDOUT 1593] | [0. , 0. , 0. , 0. ]], dtype=float32) |
01:00:58.626910 STDOUT 1593] | |
01:00:58.626912 STDOUT 1593] | cupy_tests/test_cusparse.py:930: |
01:00:58.626917 STDOUT 1593] | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
01:00:58.626947 STDOUT 1593] | /root/.local/lib/python3.10/site-packages/cupy/cusparse.py:1742: in denseToSparse |
01:00:58.626950 STDOUT 1593] | y = cupyx.scipy.sparse.coo_matrix((data, (row, col)), shape=x.shape) |
01:00:58.626954 STDOUT 1593] | algo = 0 |
01:00:58.626987 STDOUT 1593] | buff = array([0, 0, 0, ..., 0, 0, 0], dtype=int8) |
01:00:58.626990 STDOUT 1593] | buff_size = 1431 |
01:00:58.626995 STDOUT 1593] | col = array([0], dtype=int32) |
01:00:58.627032 STDOUT 1593] | data = array([9.034914e+23], dtype=float32) |
01:00:58.627034 STDOUT 1593] | desc_x = <cupy.cusparse.DnMatDescriptor object at 0x7fea8d89a8f0> |
01:00:58.627039 STDOUT 1593] | desc_y = <cupy.cusparse.SpMatDescriptor object at 0x7fea8d89ab90> |
01:00:58.627074 STDOUT 1593] | format = 'coo' |
01:00:58.627076 STDOUT 1593] | handle = 94564811359120 |
01:00:58.627082 STDOUT 1593] | nnz = 1 |
01:00:58.627119 STDOUT 1593] | num_cols_tmp = array(4) |
01:00:58.627122 STDOUT 1593] | num_rows_tmp = array(3) |
01:00:58.627126 STDOUT 1593] | row = array([0], dtype=int32) |
01:00:58.627157 STDOUT 1593] | x = array([[0. , 0. , 0. , 0. ], |
01:00:58.627159 STDOUT 1593] | [0. , 0.86181563, 0. , 0. ], |
01:00:58.627167 STDOUT 1593] | [0. , 0. , 0. , 0. ]], dtype=float32) |
01:00:58.960171 STDOUT 1593] | y = <cupyx.scipy.sparse.coo.coo_matrix object at 0x7fea8d89ab60> |
01:00:58.960267 STDOUT 1593] | /root/.local/lib/python3.10/site-packages/cupyx/scipy/sparse/coo.py:83: in __init__ |
01:00:58.960271 STDOUT 1593] | elif _util.isshape(arg1): |
01:00:58.960276 STDOUT 1593] | arg1 = (array([9.034914e+23], dtype=float32), (array([0], dtype=int32), array([0], dtype=int32))) |
01:00:58.960358 STDOUT 1593] | copy = False |
01:00:58.960360 STDOUT 1593] | dtype = None |
01:00:58.960364 STDOUT 1593] | self = <cupyx.scipy.sparse.coo.coo_matrix object at 0x7fea8d89abf0> |
01:00:58.960408 STDOUT 1593] | shape = (3, 4) |
01:00:58.960410 STDOUT 1593] | /root/.local/lib/python3.10/site-packages/cupyx/scipy/sparse/_util.py:24: in isshape |
01:00:58.960413 STDOUT 1593] | return isintlike(m) and isintlike(n) |
01:00:58.960437 STDOUT 1593] | m = array([9.034914e+23], dtype=float32) |
01:00:58.960440 STDOUT 1593] | n = (array([0], dtype=int32), array([0], dtype=int32)) |
01:00:58.960443 STDOUT 1593] | x = (array([9.034914e+23], dtype=float32), (array([0], dtype=int32), array([0], dtype=int32))) |
01:00:58.960466 STDOUT 1593] | /root/.local/lib/python3.10/site-packages/cupyx/scipy/sparse/_util.py:11: in isintlike |
01:00:58.960468 STDOUT 1593] | return bool(int(x) == x) |
01:00:58.960470 STDOUT 1593] | x = array([9.034914e+23], dtype=float32) |
01:00:58.960488 STDOUT 1593] | cupy/_core/core.pyx:1130: in cupy._core.core.ndarray.__richcmp__ |
01:00:58.960492 STDOUT 1593] | ??? |
01:00:58.960502 STDOUT 1593] | cupy/_core/core.pyx:1596: in cupy._core.core.ndarray.__array_ufunc__ |
01:00:58.960518 STDOUT 1593] | ??? |
01:00:58.960519 STDOUT 1593] | cupy/_core/_kernel.pyx:1171: in cupy._core._kernel.ufunc.__call__ |
01:00:58.960522 STDOUT 1593] | ??? |
01:00:58.960545 STDOUT 1593] | cupy/_core/_kernel.pyx:129: in cupy._core._kernel._preprocess_args |
01:00:58.960546 STDOUT 1593] | ??? |
01:00:58.960549 STDOUT 1593] | cupy/_core/_scalar.pyx:340: in cupy._core._scalar.scalar_to_numpy_scalar |
01:00:58.960570 STDOUT 1593] | ??? |
01:00:58.960571 STDOUT 1593] | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
01:00:58.960574 STDOUT 1593] | |
01:00:58.960619 STDOUT 1593] | > ??? |
01:00:58.960622 STDOUT 1593] | E OverflowError: Python int too large to convert to C long |
01:00:58.960627 STDOUT 1593] | |
01:00:58.960668 STDOUT 1593] | |
01:00:58.960670 STDOUT 1593] | cupy/_core/_scalar.pyx:127: OverflowError
Ah, ok got it. The data
is initially created with cupy.empty
here:
https://github.com/cupy/cupy/blob/1b12a402e666d0662a3203e8169efbd3c4c6d3ec/cupy/cusparse.py#L1741-L1742
and when that random value exceeds 2**64, the above error happens, because the value it is tested whether it is a shape-like:
https://github.com/cupy/cupy/blob/1b12a402e666d0662a3203e8169efbd3c4c6d3ec/cupyx/scipy/sparse/coo.py#L83 https://github.com/cupy/cupy/blob/1b12a402e666d0662a3203e8169efbd3c4c6d3ec/cupyx/scipy/sparse/_util.py#L9-L13
Minimum reproducer:
>>> z = cupy.array([9.034914e+23], dtype=cupy.float32)
>>> int(z) == z
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cupy/_core/core.pyx", line 1130, in cupy._core.core.ndarray.__richcmp__
return numpy.equal(self, other)
File "cupy/_core/core.pyx", line 1596, in cupy._core.core.ndarray.__array_ufunc__
])
File "cupy/_core/_kernel.pyx", line 1147, in cupy._core._kernel.ufunc.__call__
return _fusion_thread_local.call_ufunc(self, *args, **kwargs)
File "cupy/_core/_kernel.pyx", line 128, in cupy._core._kernel._preprocess_args
else: # scalars or invalid args
File "cupy/_core/_scalar.pyx", line 340, in cupy._core._scalar.scalar_to_numpy_scalar
return _python_scalar_to_numpy_scalar(x)
File "cupy/_core/_scalar.pyx", line 127, in cupy._core._scalar._python_scalar_to_numpy_scalar
return numpy_type(x)
OverflowError: Python int too large to convert to C long
The *_matrix
constructor needs to be fixed to avoid unnecessary computation/synchronization when creating a spmat from (data, (row, col))
.
https://jenkins.preferred.jp/job/chainer/job/cupy_stable/TEST=cupy-py36,label=mn1-p100/691/testReport/junit/tests.cupy_tests.test_cusparse/TestSparseMatrixConversion/test_denseToSparse__param_17__density_0_5__format__coo___shape__4__3___/
Error message:
Stacktrace: