-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[WIP] NumPy 1.24 #8620
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
[WIP] NumPy 1.24 #8620
Conversation
np.bool was removed in NumPy 1.24.
This always produced invalid results (though they were consistent between Numba and NumPy) but now this fails in NumPy 1.24 with an exception: ``` TypeError: The `dtype` and `signature` arguments to ufuncs only select the general DType and not details such as the byte order or time unit. You can avoid this error by using the scalar types `np.float64` or the dtype string notation. ``` Note that the exception message is misleading, and using the dtype string notation does not provide a workaround.
/azp run |
Azure Pipelines failed to run 1 pipeline(s). |
Well, I know exactly what went wrong now. Thanks, bot! |
Guessing I've ended up with duplicate matrix entries or something like that. |
I believe this was written in error and should always have been float16.
The modified regex matches the existing message produced by NumPy < 1.24, and the new improved message in 1.24.
gpuci run tests |
Oops, I haven't updated the gpuCI test scripts to test with NumPy 1.24. |
gpuci run tests |
Setting an array element with a sequence is removed in NumPy 1.24.
gpuci run tests |
This is so that a proper solution can be implemented. This reverts commit 08416ad.
`init_ufunc_dispatch()` should set an exception if it's going to fail. Without setting an exception, an unrecognized ufunc method (e.g. `resolve_dtypes()` in NumPy 1.24) results in: ``` SystemError: initialization of _internal failed without raising an exception ``` This commit modifies it to set an exception notifying the user of the error. Now when an unrecognized ufunc method is encountered, the traceback ends in: ``` from numba.np.ufunc import _internal RuntimeError: Unexpected ufunc method resolve_dtypes() ```
The Windows build did not like a variable-length stack array.
Looks like the failure persists after going back to rc2, so it's not related to the 1.24 release. |
I wrongly assumed that this test only checked inputs, but it also checks outputs, and it is the output check that is failing. This test probably needs updating to check using reconstruction (check that |
This reverts commit 22980fe.
This test only checked for a plain match when comparing outputs. However, in some cases a reconstruction check can be necessary, as in `test_linalg_svd`.
gpuci run tests |
gpuci run tests |
@@ -4893,6 +4893,7 @@ def create_harcoded_variant(self, basefunc, ty): | |||
eval(compile(funcstr, '<string>', 'exec')) | |||
return locals()['foo'] | |||
|
|||
@unittest.skipIf(numpy_version >= (1, 24), "NumPy < 1.24 required") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also fails for me on numpy 1.23.4 (openSUSE Tumbleweed packaging):
[ 2303s] ======================================================================
[ 2303s] ERROR: test_MachAr (numba.tests.test_np_functions.TestNPMachineParameters)
[ 2303s] ----------------------------------------------------------------------
[ 2303s] Traceback (most recent call last):
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 4783, in test_MachAr
[ 2303s] self.check(machar, attrs)
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 4762, in check
[ 2303s] got = cfunc(*args)
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
[ 2303s] error_rewrite(e, 'typing')
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
[ 2303s] raise e.with_traceback(None)
[ 2303s] numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
[ 2303s] Use of unsupported NumPy function 'numpy.MachAr' or unsupported use of the function.
[ 2303s]
[ 2303s] File "../../../../../../usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 102:
[ 2303s] def machar(*args):
[ 2303s] return np.MachAr()
[ 2303s] ^
[ 2303s]
[ 2303s] During: typing of get attribute at /usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py (102)
[ 2303s]
[ 2303s] File "../../../../../../usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 102:
[ 2303s] def machar(*args):
[ 2303s] return np.MachAr()
[ 2303s] ^
[ 2303s]
[ 2303s]
[ 2303s] ======================================================================
[ 2303s] FAIL: test_np_MachAr_deprecation_np122 (numba.tests.test_np_functions.TestNPMachineParameters)
[ 2303s] ----------------------------------------------------------------------
[ 2303s] Traceback (most recent call last):
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/support.py", line 599, in inner
[ 2303s] self.subprocess_test_runner(test_module=self.__module__,
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/support.py", line 584, in subprocess_test_runner
[ 2303s] self.assertEqual(status.returncode, 0, streams)
[ 2303s] AssertionError: 1 != 0 :
[ 2303s] captured stdout:
[ 2303s] captured stderr: E
[ 2303s] ======================================================================
[ 2303s] ERROR: test_np_MachAr_deprecation_np122 (numba.tests.test_np_functions.TestNPMachineParameters)
[ 2303s] ----------------------------------------------------------------------
[ 2303s] Traceback (most recent call last):
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/support.py", line 607, in inner
[ 2303s] func(self)
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 4836, in test_np_MachAr_deprecation_np122
[ 2303s] f()
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
[ 2303s] error_rewrite(e, 'typing')
[ 2303s] File "/usr/lib/python3.8/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
[ 2303s] raise e.with_traceback(None)
[ 2303s] numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
[ 2303s] Use of unsupported NumPy function 'numpy.MachAr' or unsupported use of the function.
[ 2303s]
[ 2303s] File "../../../../../../usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 4835:
[ 2303s] def test_np_MachAr_deprecation_np122(self):
[ 2303s] <source elided>
[ 2303s] category=NumbaDeprecationWarning,)
[ 2303s] f = njit(lambda : np.MachAr().eps)
[ 2303s] ^
[ 2303s]
[ 2303s] During: typing of get attribute at /usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py (4835)
[ 2303s]
[ 2303s] File "../../../../../../usr/lib/python3.8/site-packages/numba/tests/test_np_functions.py", line 4835:
[ 2303s] def test_np_MachAr_deprecation_np122(self):
[ 2303s] <source elided>
[ 2303s] category=NumbaDeprecationWarning,)
[ 2303s] f = njit(lambda : np.MachAr().eps)
[ 2303s] ^
[ 2303s]
[ 2303s]
[ 2303s] ----------------------------------------------------------------------
[ 2303s] Ran 1 test in 0.271s
[ 2303s]
[ 2303s] FAILED (errors=1)
[ 2303s]
[ 2303s]
[ 2303s] ----------------------------------------------------------------------
[ 2303s] Ran 9684 tests in 2243.604s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have messed something up for old NumPy versions because I've only been testing with 1.24 in the matrix here - I've opened #8690 to run CI on this branch but with the other NumPy versions to check for this and maybe any other problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnavigator thanks for the report, this seems a bit strange as NumPy 1.23 definitely has MachAr
still. Maybe there's an issue with Numba's overload construction for it that is triggered in the openSUSE builds. Perhaps open a new issue to discuss/track? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have messed something up for old NumPy versions because I've only been testing with 1.24 in the matrix here - I've opened #8690 to run CI on this branch but with the other NumPy versions to check for this and maybe any other problems.
I think there's potentially something else going on. Looking at the NumPy source, there's MachAr
exported in both 1.23 and 1.24.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no np.MachAr
in 1.24, but np.core.MachAr
is there - it's been left in but is not public / documented, AIUI. I think that will be removed too in a future release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Looks like I have some outdated patch which still includes
--- a/numba/np/arraymath.py
+++ b/numba/np/arraymath.py
@@ -4203,7 +4207,7 @@ def _gen_np_machar():
return impl
-_gen_np_machar()
+# _gen_np_machar()
def generate_xinfo(np_func, container, attr):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmarkall Thanks, I was indeed looking under numpy.core
, where it still exists.
@bnavigator Ah, thanks for checking, guess that's the root cause of the problem!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the noise. My mistake. I can confirm that the current PR with 7d3826e as the latest commit works for both NumPy 1.23.4 and after an update to 1.24.1 when packaging numba 0.56.4 for openSUSE Tumbleweed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnavigator no worries, thanks for checking that it's now all working! This is essentially an independent verification of the update in this patch, which is really useful to have!
From PR numba#8691 feedback.
PR numba#8691 feedback.
gpuci run tests |
@stuartarchibald This PR contains the same changes as #8691, but tests all slices with NumPy 1.24 (therefore demonstrating that all tests pass with 1.24) - I'd like to keep this open until #8691 can run on the buildfarm, so if further changes are made I can validate (to some degree) they don't break anything at all with NumPy 1.24. |
@gmarkall ah yes, thanks for reminding me, good idea to keep this open for the reasons noted. |
Now that #8691 is ready to go except for CI on that branch itself, I think this is no longer needed. |
Current status: All is well with NumPy 1.24, so this needs some tidying up and other accompanying changes to be ready for review. To-do list:
Original, outdated description follows:
For testing against NumPy 1.24.0rc1. Presently all seems to be good (all tests passing with NumPy 1.24) so it is not expected that any major changes are needed, assuming there are no further NumPy changes requiring attention.
I will keep this up to date with
main
and update to use newer RCs when they appear - when the final release is available, I will make this Ready For Review in order to support NumPy 1.24.The use of
resolve_dtypes
will be added as a separate PR, because it is not needed to make all existing functionality in Numba work with 1.24 - its use will eventually simplify Numba' ufunc typing logic.