-
-
Notifications
You must be signed in to change notification settings - Fork 776
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: support NumPy 2.0 : NEP 52 (Python API cleanup) #8314
base: main
Are you sure you want to change the base?
Conversation
14d3b3a
to
33c9b22
Compare
Done, modulo
Details of namespace comparison is under the fold
|
Done modulo
|
Paused to run locally tests from
|
cross-ref numpy/numpy#26370 : de98f8f works around it, might be able to drop the workaround |
Curiously,
A significant fraction of remaining test failures are due to float16. |
Decision needed:
More generally, what is the CuPy action when NumPy deprecates something? (match the deprecation, just remove an API when numpy removes it, something else?) |
This pull request is now in conflicts. Could you fix it @ev-br? 🙏 |
These tests fail with "arrays of different dtypes are returned" on NumPy 1.26.4 with weak promotion (export NPY_PROMOTION_STATE=weak), but pass under NumPy '2.1.0.dev0+git20240419.da95f8e'. Therefore, this commit can be reverted when NumPy 2.0 becomes the minimum supported version.
The NumPy < 2 idiom, int( np.array(seed).astype(np.uint64, casting='safe') ) does not work in NumPy 2.0
Test that either both NumPy and CuPy raise OverflowErrors, or both do not.
Otherwise, `arange(3, dtype=cupy.uint8).round(-2)` raises: `-2` cannot be cast to the array unsigned dtype.
The issue this: consider `cupy.uint8(2) / (-2)`. Since -2 is a python scalar, the ufunc selects a 'BB->d' loop based on the type of the other argument. Then the ufunc kernel declared `in1_type in1` which is initialized `uint8_t in1(-2)`. With only 'int64, int64 -> float64' and 'uint64, uint64_5 -> float64' loops (this PR), the problem appears only for uint64(...) / (-2), and that's probably rare enough.
Needed to make `pytest tests/cupy_tests/indexing_tests/` pass.
1. axis='' as an alias for axis=None : remote from tests 2. silence DeprecationWarnings for axis=None and s != None
c01ad40
to
dc148b1
Compare
A bug with numpy scalars was fixed in NumPy 2.0.0rc2
This (tries to) build artifacts based on Evgeni's PR to CuPy which should have most fixes needed to run with NumPy 2 and thus allow testing downstream projects with NumPy 2 if they also need CuPy. This includes most/all necessary Python fixes as well as fixes to make promotion align with NumPy (NEP 50). See also: * cupy/cupy#8323 * cupy/cupy#8314 * cupy/cupy#8306
Work towards #8306.
The current checklist is
cupy
imports withnumpy==2.0.0rc1
pytest tests/cupy
passes the collection stagepytest tests/cupyx
passes the collection stagecupy
andnumpy
namespaces matchndarray
methods matchdevice
arguments to various functions (needs decision on the behavior)numpy.linalg
numpy.core
,numpy._lib
numpy.exceptions
numpy.strings
numpy.dtypes
is out of scope for this PR.