-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: _npy_cabs is no longer exported in 2.1.0 #27270
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
Comments
|
EDIT: I was looking at the wrong numpy version. |
Odd. For me on pip on NumPy 2.1.0, that command does not show those symbols:
It does show those symbols in 2.0.1, though. |
I was looking at the wrong numpy version, sorry. |
This is almost certainly a consequence of gh-26286, which landed in 2.1.0. And SciPy 1.14.1 building against numpy 2.1.0 explains why I am still a bit confused about what is going wrong here. My first guess was that What I think is happening is that It should be reproducible locally in a |
It looks like statsmodels/tsa/statespace/_representation.pyx.in is using BLAS functionality (through SciPy), and that seems to require linking However, the That looks like a bug to me. I'm away for most of today and on holiday till mid next week, but hopefully that's enough of a pointer to identify the fix. |
Quick update: I reproduced the issue and found (by reading the Cython-generated C sources) that the
statsmodels/src/math.pxd provides The link lines are correct though it looks like, they include Building against numpy 2.1.0:
Building against numpy 2.0.0:
Not yet sure why |
Looking at the symbols in the From the
Local build of 0.14.2 on macOS arm64 14.x,
Same local build but with
Compare to SciPy's
It doesn't seem easy to explain why the symbols in the statsmodels wheel on PyPI went missing ( @bashtage could you build new statsmodels wheels with the release procedure on the 0.14.x branch perhaps, so we have logs to look at and can see if it's reproducible? |
What happens if you build with NumPy 2.0 and SciPy 1.13 and then run against NumPy 2.1 and the latest SciPy. I don't have a Mac but have been unable to reproduce using CI runners. |
I get the global symbols after the build:
All looks good. The only thing I can think of that may have happened is that the statsmodels wheel builds, which used I'd suggest either rebuilding the macOS 0.14.2 wheels with a higher build number (see https://snarky.ca/what-to-do-when-you-botch-a-release-on-pypi/), or tagging 0.14.3 and uploading that to PyPI after verifying the wheels are fine. |
We have a similar issue in our CI, see this run for example. Numpy 2.1.1, SciPy 1.14.1 and statsmodels 0.14.2. Also happening only on macOS. |
This isn't a NumPy bug. The issue is that when SciPy exported the symbol, statamodels would link to the SciPy one when built. If SciPy doesn't export it, which it stopped in 1.14.1, then statamodels will link against NumPy when built against SciPy 1.14.1. The problem arises when building against 1.13.x and the running on >=1.14.1, but then only on OSX. |
I just triggered a rebuild https://github.com/MacPython/statsmodels-wheels/actions/runs/10819773348/job/30018391314 and the test fails (for some reason CIBW doesn't fail, but if you click in you will see
|
I cannot get OSX to work on any Python now. The key compilation lines are
Those last 4 seem suspicious to me. Any idea why I would be seeing them? |
It looks like CIBW is broken on OSX. It appears to be downloading arm64 wheels for the build, but then downloading x86_64 for the test, all for an x86_64 build. |
I've seen a similar error when migrating my data from a x86 mac to an ARM mac. I had to reinstall an ARM version of GCC, delete all temporary build files, and delete ccache's cache (it doesn't take the computer architecture into account) |
I have traced the issue to how CIBW behaves when the runner is arm64. For now it does not work correctly when building x86_64 wheels that need to link to the NumPy math library. It does work correctly you only need headers. The workaround is to limit the rubber to macos-13 rather than macos-latest which lets wheels for both arches be correctly built. |
You are manually trying to link to numpy/_core/lib/libnpymath.a, which is being pulled from the ARM wheel rather than the target platform (because pip downloads native wheels, not cross-compiled ones). |
FWIW I built statsmodels/main just now, and ran the test suite. I have numpy2.1.1 and scipy1.14.1, python3.12.5. The whole test suite ran without crashing, although there were two failures. I am on macOS 14.6.1 with an M3 processor. I can also Is this time to close this issue from numpy's side? |
This is 100% not a NumPy bug. This issue has to do with how CIBW works when hosted on either x86_64 or arm64. On x86_64, it will emulate arm and so correctly cross-compile when you need to link against the numpy math library. When hosted on arm, it will not emulate and so just cross compiles, and as a result, it attempts to link x86_64 binaries against an arm64 numpy math library. Hence when it gets to running, it can't find the symbol. I think this issue was hidden by SciPy's export of npy_abs. SciPy correctly compiled and linked against the correct arch library, and then made this symbol available. When SciPy stopped exporting it, there was no npy_cabs to find, and hence the crash. The solution is to use macos-13 for building x86_64 wheels, and macos-14 (or macos-latest) for arm64. |
This is a known NumPy limitation, as you can see from the docs.
a) You can emulate or cross compile. If you are emulating, you are not cross-compiling. You are making a native compile on an emulated system. b) Apple does not support emulating Apple Silicon from Intel. Only the other way around. So cibuildwheel certainly does not emulate ARM from Intel. If this works on Intel, it's probably working by accident. If you link to NumPy's static library, you must do a native compile (emulated or physical). You currently must use |
And #20880 would allow a solution to this, I think, but looks like it's progressing a bit slowly. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
The symbol for npy_cabs is no longer exported. This causes certain modules in statamodels to crash on import due to missing symbol in the .so (confirmed on OSX).
Reproduce the code example:
Install SciPy 1.14.1 and NumPy 2.1.0 and then import statamodels.tsa.api.
Error message:
Python and NumPy Versions:
NumPy 2.1.0
Runtime Environment:
No response
Context for the issue:
I am a maintainer of statamodels. Reported in statsmodels/statsmodels#9333
See also scipy/scipy#21434
SciPy also used to export this symbol. I suspect it was picking up what NumPy exported and so when built against 2.0.x it would export npy_cabs. When built against NumPy 2.1.x, SciPy 1.14.1 does not.
The text was updated successfully, but these errors were encountered: