Skip to content
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

Rebuild for numpy 2.0 #250

Merged

Conversation

regro-cf-autotick-bot
Copy link
Contributor

This PR has been triggered in an effort to update numpy2.

Notes and instructions for merging this PR:

  1. Please merge the PR only after the tests have passed.
  2. Feel free to push to the bot's branch to update this PR if needed.

Please note that if you close this PR we presume that the feedstock has been rebuilt, so if you are going to perform the rebuild yourself don't close this PR until the your rebuild has been merged.


Here are some more details about this specific migrator:

TL;DR: The way we build against numpy has changed as of numpy 2.0. This bot
PR has updated the recipe to account for the changes (see below for details).
The numpy 2.0 package itself is currently only available from a special release
channel (conda-forge/label/numpy_rc) and will not be available on the main
conda-forge channel until the release of numpy 2.0 GA.

The biggest change is that we no longer need to use the oldest available numpy
version at build time in order to support old numpy version at runtime - numpy
will by default use a compatible ABI for the oldest still-supported numpy versions.

Additionally, we no longer need to use {{ pin_compatible("numpy") }} as a
run requirement - this has been handled for more than two years now by a
run-export on the numpy package itself. The migrator will therefore remove
any occurrences of this.

However, by default, building against numpy 2.0 will assume that the package
is compatible with numpy 2.0, which is not necessarily the case. You should
check that the upstream package explicitly supports numpy 2.0, otherwise you
need to add a - numpy <2 run requirement until that happens (check numpy
issue 26191 for an overview of the most important packages).

Note that the numpy release candidate promises to be ABI-compatible with the
final 2.0 release. This means that building against 2.0.0rc1 produces packages
that can be published to our main channels.

If you already want to use the numpy 2.0 release candidate yourself, you can do

conda config --add channels conda-forge/label/numpy_rc

or add this channel to your .condarc file directly.

To-Dos:

  • Match run-requirements for numpy (i.e. check upstream pyproject.toml or however the project specifies numpy compatibility)
    • If upstream is not yet compatible with numpy 2.0, add numpy <2 upper bound under run:.
    • If upstream is already compatible with numpy 2.0, nothing else should be necessary in most cases.
    • If upstream requires a minimum numpy version newer than 1.19, you can add numpy >=x.y under run:.
  • Remove any remaining occurrences of {{ pin_compatible("numpy") }} that the bot may have missed.

PS. If the build does not compile anymore, this is almost certainly a sign that
the upstream project is not yet ready for numpy 2.0; do not close this PR until
a version compatible with numpy 2.0 has been released upstream and on this
feedstock (in the meantime, you can keep the bot from reopening this PR in
case of git conflicts by marking it as a draft).


If this PR was opened in error or needs to be updated please add the bot-rerun label to this PR. The bot will close this PR and schedule another one. If you do not have permissions to add this label, you can use the phrase @conda-forge-admin, please rerun bot in a PR comment to have the conda-forge-admin add it for you.

This PR was created by the regro-cf-autotick-bot. The regro-cf-autotick-bot is a service to automatically track the dependency graph, migrate packages, and propose package version updates for conda-forge. Feel free to drop us a line if there are any issues! This PR was generated by https://github.com/regro/cf-scripts/actions/runs/9120406435 - please use this URL for debugging.

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@xhochy
Copy link
Member

xhochy commented May 17, 2024

Looks like this is not yet compatible:

In file included from external/ml_dtypes/_src/dtypes.cc:33:
external/ml_dtypes/_src/custom_float.h:883:7: error: use of undeclared identifier 'PyArray_TypeNumFromName'
      PyArray_TypeNumFromName(const_cast<char*>(TypeDescriptor<T>::kTypeName));
      ^
external/ml_dtypes/_src/custom_float.h:889:25: error: no member named 'f' in '_PyArray_Descr'
    if (descr && descr->f && descr->f->argmax) {
                 ~~~~~  ^
external/ml_dtypes/_src/custom_float.h:889:37: error: no member named 'f' in '_PyArray_Descr'
    if (descr && descr->f && descr->f->argmax) {
                             ~~~~~  ^
external/ml_dtypes/_src/custom_float.h:969:32: error: cannot initialize a parameter of type 'PyArray_DescrProto *' with an rvalue of type 'PyArray_Descr *' (aka '_PyArray_Descr *')
      PyArray_RegisterDataType(&CustomFloatType<T>::npy_descr);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/ml_dtypes/_src/dtypes.cc:226:8: note: in instantiation of function template specialization 'ml_dtypes::RegisterFloatDtype<Eigen::bfloat16>' requested here
  if (!RegisterFloatDtype<bfloat16>(numpy.get())) {
       ^
In file included from external/ml_dtypes/_src/dtypes.cc:33:
external/ml_dtypes/_src/custom_float.h:408:16: error: excess elements in struct initializer
    /*elsize=*/sizeof(T),
               ^~~~~~~~~
external/ml_dtypes/_src/custom_float.h:964:36: note: in instantiation of static data member 'ml_dtypes::CustomFloatType<Eigen::bfloat16>::npy_descr' requested here
  Py_SET_TYPE(&CustomFloatType<T>::npy_descr, &PyArrayDescr_Type);
                                   ^
external/ml_dtypes/_src/dtypes.cc:226:8: note: in instantiation of function template specialization 'ml_dtypes::RegisterFloatDtype<Eigen::bfloat16>' requested here
  if (!RegisterFloatDtype<bfloat16>(numpy.get())) {
       ^
In file included from external/ml_dtypes/_src/dtypes.cc:33:

Marking as draft until we have updated to the latest version.

@xhochy xhochy marked this pull request as draft May 17, 2024 09:18
@jakirkham
Copy link
Member

Upstream has completed the work to add NumPy 2.0 support: jax-ml/jax#19246

However this does require 0.4.26 whereas this feedstock appears to be on 0.4.23

{% set version = "0.4.23" %}

So likely the first step is updating and then applying the NumPy 2.0 migration after

@jakirkham
Copy link
Member

There is an initial attempt at updating to 0.4.26 in PR: #264

@h-vetinari
Copy link
Member

Rebased on #268 (which seems ready, so no need to build 0.4.26 for numpy 2.0 IMO)

@xhochy
Copy link
Member

xhochy commented Jul 4, 2024

0.4.27 still needs some CUDA 11 fixes. I can integrate this once I have done them (need to find the right patch in the Tensorflow feedstock)

@h-vetinari
Copy link
Member

Currently just with a single build on the cirun server for testing. Will rebase once #268 is in.

@h-vetinari
Copy link
Member

0.4.27 still needs some CUDA 11 fixes. I can integrate this once I have done them (need to find the right patch in the Tensorflow feedstock)

Ah, well, if you prefer, I can back out the bump to 0.4.27 and we keep this on 0.4.26 then?

traversaro and others added 3 commits July 4, 2024 14:14
TL;DR: The way we build against numpy has changed as of numpy 2.0. This bot
PR has updated the recipe to account for the changes (see below for details).
The numpy 2.0 package itself is currently only available from a special release
channel (`conda-forge/label/numpy_rc`) and will not be available on the main
`conda-forge` channel until the release of numpy 2.0 GA.

The biggest change is that we no longer need to use the oldest available numpy
version at build time in order to support old numpy version at runtime - numpy
will by default use a compatible ABI for the oldest still-supported numpy versions.

Additionally, we no longer need to use `{{ pin_compatible("numpy") }}` as a
run requirement - this has been handled for more than two years now by a
run-export on the numpy package itself. The migrator will therefore remove
any occurrences of this.

However, by default, building against numpy 2.0 will assume that the package
is compatible with numpy 2.0, which is not necessarily the case. You should
check that the upstream package explicitly supports numpy 2.0, otherwise you
need to add a `- numpy <2` run requirement until that happens (check numpy
issue 26191 for an overview of the most important packages).

Note that the numpy release candidate promises to be ABI-compatible with the
final 2.0 release. This means that building against 2.0.0rc1 produces packages
that can be published to our main channels.

If you already want to use the numpy 2.0 release candidate yourself, you can do
```
conda config --add channels conda-forge/label/numpy_rc
```
or add this channel to your `.condarc` file directly.

  * [ ] Match run-requirements for numpy (i.e. check upstream `pyproject.toml` or however the project specifies numpy compatibility)
    * If upstream is not yet compatible with numpy 2.0, add `numpy <2` upper bound under `run:`.
    * If upstream is already compatible with numpy 2.0, nothing else should be necessary in most cases.
    * If upstream requires a minimum numpy version newer than 1.19, you can add `numpy >=x.y` under `run:`.
  * [ ] Remove any remaining occurrences of `{{ pin_compatible("numpy") }}` that the bot may have missed.

PS. If the build does not compile anymore, this is almost certainly a sign that
the upstream project is not yet ready for numpy 2.0; do not close this PR until
a version compatible with numpy 2.0 has been released upstream and on this
feedstock (in the meantime, you can keep the bot from reopening this PR in
case of git conflicts by marking it as a draft).
@xhochy xhochy force-pushed the rebuild-numpy2-0-1_hc42ff2 branch from 28093a6 to dc3ef44 Compare July 4, 2024 12:47
@h-vetinari h-vetinari marked this pull request as ready for review July 6, 2024 20:43
@h-vetinari h-vetinari added the automerge Merge the PR when CI passes label Jul 6, 2024
@xhochy xhochy merged commit a528823 into conda-forge:main Jul 8, 2024
27 checks passed
@regro-cf-autotick-bot regro-cf-autotick-bot deleted the rebuild-numpy2-0-1_hc42ff2 branch July 8, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge the PR when CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants