Repository navigation
Fix numpy2.0 incompatbility issues - #9602
Conversation
|
BFID |
|
I have to rerun smoketest entirely. It turns out the buildfarm is relying on scipy1.14rc1 which is now yanked due to a OSX problem. I changed the buildfarm to use scipy1.13.1 and only reran the one failed OSX job. However, it failed with: Now, I need to rerun all platforms to see if it is OSX specific. |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the patch. On inspection it seems like this will fix the compatibility issues discovered in testing NumPy 2.0's rc2 build. As noted in the comments, the issue in relation to matrix power needs addressing.
| dtype = np.result_type(x_dt, y_dt, np.float64) | ||
|
|
||
| if dtype == np.complex_: | ||
| if dtype == np.complex128: |
There was a problem hiding this comment.
I searched for other occurrences of np.complex_ in the code base and could not find any.
|
There's a consistent problem with $ python runtests.py -k test_linalg_matrix_power
*** stack smashing detected ***: terminated
Fatal Python error: Aborted
Current thread 0x00007fa498e93280 (most recent call first):
File "/home/siu/dev/numba/numba/tests/test_linalg.py", line 2422 in check
File "/home/siu/dev/numba/numba/tests/test_linalg.py", line 2440 in test_linalg_matrix_power
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/case.py", line 579 in _callTestMethod
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/case.py", line 623 in run
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/case.py", line 678 in __call__
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/suite.py", line 122 in run
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/suite.py", line 84 in __call__
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/runner.py", line 217 in run
File "/home/siu/dev/numba/numba/testing/main.py", line 170 in run
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/main.py", line 274 in runTests
File "/home/siu/dev/numba/numba/testing/main.py", line 371 in run_tests_real
File "/home/siu/dev/numba/numba/testing/main.py", line 386 in runTests
File "/home/siu/dev/envs/numba.py311np2/lib/python3.11/unittest/main.py", line 102 in __init__
File "/home/siu/dev/numba/numba/testing/main.py", line 207 in __init__
File "/home/siu/dev/numba/numba/testing/__init__.py", line 54 in run_tests
File "/home/siu/dev/numba/numba/testing/_runtests.py", line 25 in _main
File "/home/siu/dev/numba/numba/runtests.py", line 9 in <module>
File "<frozen runpy>", line 88 in _run_code
File "<frozen runpy>", line 229 in run_module
File "/home/siu/dev/numba/runtests.py", line 22 in <module>
Extension modules: mkl._mklinit, mkl._py_mkl_service, numpy._core._multiarray_umath, numpy._core._multiarray_tests, numpy.linalg._umath_linalg, scipy._lib._ccallback_c, numba.core.typeconv._typeconv, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, numba._helperlib, numba._dynfunc, numba._dispatcher, numba.core.runtime._nrt_python, numba.np.ufunc._internal, numba.experimental.jitclass._box, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.linalg._propack._spropack, scipy.sparse.linalg._propack._dpropack, scipy.sparse.linalg._propack._cpropack, scipy.sparse.linalg._propack._zpropack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, numba.mviewbuf, numba.types.itertools, scipy.special._ufuncs_cxx, scipy.special._cdflib, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.special._ellip_harm_2, scipy.special.cython_special (total: 57)
Aborted (core dumped)Observations so far:
This might be a MKL-openblas conflict or something with openmp. |
|
Confirmed that the yanked scipy=1.14.0rc1 wheel doesn't have the stack smashing issue even with numpy+MKL |
|
Update to future readers. The following explanation is not accurate. OOB discussions has concluded that the issue is further down the call chain, but it is indeed due to a different in ABI. The difference is that scipy wheels are built without g77 wrappers for BLAS. The issue is resolved as of SciPy 1.14. This appears to be a scipy problem. Consider the following disassembled code for SCIPY 1.13.1 wheel: SCIPY 1.13.1 conda-forge: The wheel version is allocate 0x10 stack space while the conda-forge version is allocating 0x28 stack space. I believe this can explain the stack smashing. Essentially, the wheel version is expecting a different ABI for |
|
I can't quite align the explanation with what I can see in the SciPy code. The void F_FUNC(zdotuwrp,ZDOTUWRP)(double_complex *ret, CBLAS_INT *n, double_complex *zx, \
CBLAS_INT *incx, double_complex *zy, CBLAS_INT *incy){
*ret = F_FUNC(wzdotu,WZDOTU)(n, zx, incx, zy, incy);
}So there isn't a return value to allocate space for. The return value arrives in A couple of other anomalies I see in this explanation:
|
|
Reading the assembly again, i think the extra stack space is the frame-pointer: which is later read back and check: Maybe this is just two builds with different compiler flags. Something about frame-pointer checking for security. |
|
The conda-forge version is probably compiled with |
Testing for these cython exports was only added in scipy 1.14.0: scipy/scipy#20422 |
|
Edit: the PR I linked to was already in 1.12, so it's not that. |
conda-forge::scipy1.13.1 has a higher error on osx-64. The test is reporting difference of: Max absolute difference among violations: 6.605827e-15 Max relative difference among violations: 1.13509129e-13
|
new BFID: |
|
smoketest passed |
gmarkall
left a comment
There was a problem hiding this comment.
This looks good to me - I see no more uses of np.complex_ or __getstate__() so I expect it to resolve the issues observed with the build on conda-forge of Numba 0.60.0rc1 with NumPy 2.0.0rc2 (conda-forge/numba-feedstock#142)
|
Having followed the discussion about the tolerance loosening in OOB conversation, and inspecting the function of the test (matrix powers where some of the powers are relatively large) I think the loosening of the tolerance seems appropriate, so I think this is OK to RTM. |
Fix numpy2.0 incompatbility issues
Fixes #9598
Fixes #9599