-
Notifications
You must be signed in to change notification settings - Fork 508
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
Numpy 2.0 compatibility #626
Comments
As NumPy v2.0 is out now, this would be a great boon to have. Are there particular technical issues with getting a new build out that need resolving? Or is this more a matter of (understandably) limited developer time at the moment? |
It is more a question of limited time ;). Actually I would expect POT to work on numpy 2.0 if build from source. The idea is toccheck that all tests pass on numpy 2.0 and update the build wheel github action to run with two different versions of numpy. Then I guess we can do a proper release |
@rflamary This becomes an understandably difficult problem though, as in the tests you are also testing in an environment with Lines 8 to 11 in cba9c7b
The PyTorch and JAX (via |
Unfortunately, not from the # docker run --rm -ti python:3.12 /bin/bash
$ python -m pip --quiet install --upgrade uv
$ uv venv && . .venv/bin/activate
$ uv pip install --upgrade 'numpy>=2.0.0'
$ uv pip install --no-binary pot pot
Resolved 3 packages in 582ms
Built pot==0.9.3
Downloaded 2 packages in 8.31s
Installed 2 packages in 18ms
+ pot==0.9.3
+ scipy==1.13.1
$ uv pip list
Package Version
------- -------
numpy 2.0.0
pot 0.9.3
scipy 1.13.1
$ python -c 'import ot'
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "<string>", line 1, in <module>
File "/.venv/lib/python3.12/site-packages/ot/__init__.py", line 21, in <module>
from . import lp
File "/.venv/lib/python3.12/site-packages/ot/lp/__init__.py", line 23, in <module>
from .emd_wrap import emd_c, check_result, emd_1d_sorted
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/.venv/lib/python3.12/site-packages/ot/__init__.py", line 21, in <module>
from . import lp
File "/.venv/lib/python3.12/site-packages/ot/lp/__init__.py", line 23, in <module>
from .emd_wrap import emd_c, check_result, emd_1d_sorted
File "ot/lp/emd_wrap.pyx", line 1, in init ot.lp.emd_wrap
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it). |
damnit you are right. No worry we will build wheel independently of jax or tensorflow (they depend only on numpy) but indeed we will indedd need to rework the tests also.... |
hum i think this is because of the use of oldest_suported_numpy that build using older numpy: Line 72 in cba9c7b
|
Yeah, to be clear I am no expert here, but from quickly reading bits of the "For downstream package authors" NumPy guide (the NumPy 2.0-specific advice), I think Line 2 in cba9c7b
needs to get swapped for |
OK we will have a look but feel free to do a PR in the meantime (it should be changed in the toml and setup.py files I think). This might be an easier fix than expected |
@rflamary @cedricvincentcuaz I haven't stepped through the changes from |
We discussed with @cedricvincentcuaz and we want a release by the end of the month but next week should be doable. It is OK to push us it means that people need the toolbox ;). I wanted to do a release anyways and this numpy2 stuff is definitely a problem. |
That sounds great! End of month is already soon, so that would be excellent. I'm asking as the student I'm supervising would like to make a release of a library soon, but before or around the start of July 2024 is fine. 👍 Thanks! |
🚀 Feature
We need to upadte the CI for wheels building so that they compile wheel for numpy <2.0 and numpy >=2.0. Maybe we need a versioning scheme that allows those versions (with the numpy2.0 the most up to date but enforce the numpy version?)
Motivation
Pitch
Alternatives
Additional context
The text was updated successfully, but these errors were encountered: