-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Undefined minimum with numpy compiled using intel compilers #27840
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
This is a fully valid subscripted array and just repeats the two values returning a contiguous copy. |
Interesting: >>> rows = np.array([0,0])
>>> val = np.array([0.11])
>>> val[rows]
array([0.11, 0.11])
>>> np.array([0.11, 0.11]).min()
nan |
Also interesting that it matters if they are floats or ints: >>> np.array([0, 0]).min()
0
>>> np.array([0.1, 0.1]).min()
nan
>>> np.array([-1, -1]).min()
-1
>>> np.array([-1.1, -1.1]).min()
nan |
Well, such a compiler sensitive thing was likely to be SIMD related. Length 1 is not very interesting because there is no reduction. Since this is apparently compiler dependent, there is a decent chance it is a compiler bug (incorrect optimization). You may be able to make it work if you set CC @r-devulap and @seiko2plus. I am also not sure if this may just be fixed in newer versions, since 1.25 is pretty old. (also there were a lot of discussions about intel compiler problems recently I haven't quite kept up with). |
The issue is present with numpy up to version 1.26.4. I haven't tried 1.26.5 as it doesn't have a spack recipe yet. Similarly, the version of spack-stack that I am working with does not have any recipes for numpy v2.x. I may try upgrading to a newer version of spack and seeing if the problem still exists for v2.1.2. That said, disabling one of two CPU features was successful: > export NPY_DISABLE_CPU_FEATURES=AVX512F && python -c "import numpy as np; print(np.array([-1.1, -1.1]).min())"
-1.1
> export NPY_DISABLE_CPU_FEATURES=AVX512CD && python -c "import numpy as np; print(np.array([-1.1, -1.1]).min())"
-1.1 Disabling any other combination of AVX or SSE features returned |
After setting |
You can disable it at build time rather than runtime. Although, of course the real issue here is probably a compiler bug. But depending on how old the compiler is, I am not sure that is worth thinking about... (But it may be a shame to drag this hack around indefinitely.) |
@seberg That's a good point RE building. The 'classic' Intel compilers are officially retired, though NOAA is still in the process of migrating to the newer LLVM compilers (which do not have this issue) and I suspect many groups will be using the classic compilers for at least a few years to come. I believe the last update to the classic compilers came at the beginning of this year. |
@DavidHuber-NOAA is it possible to patch #26281 and see if your bug goes away? |
Hmmm, that bug does seem likely relate and probably can be included as a patch in the spack build. |
@r-devulap Thanks for the suggestion. Unfortunately, after including that patch, I am still getting |
spack/spack#47941 was merged. Closing this issue. |
Describe the issue:
When attempting to use an
ndarray
method (likemin()
) with an invalid subscripted array, the returning value is not repeatable when Numpy is compiled with GNU and Intel Classic compilers (note that Intel LLVM compilers behave like GNU). With Intel, the returning value is NaN, with GNU, it is the expected result.Reproduce the code example:
Error message:
N/A in both cases
Python and NumPy Versions:
Numpy: 1.25.2
Python: 3.11.7 (main, Aug 29 2024, 15:22:52) [GCC Intel(R) C++ gcc 9.2 mode]
Note that this is repeatable on other systems with different versions of gcc
Runtime Environment:
Compiled via spack.
[{'numpy_version': '1.25.2',
'python': '3.11.7 (main, Aug 29 2024, 15:22:52) [GCC Intel(R) C++ gcc 9.2 '
'mode]',
'uname': uname_result(system='Linux', node='hfe02', release='4.18.0-553.22.1.el8_10.x86_64', version='#1 SMP Wed Sep 25 09:20:43 UTC 2024', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX'],
'not_found': ['AVX512_KNL',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Haswell',
'filepath': '/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/openblas-0.3.24-tmyu6qy/lib/libopenblas-r0.3.24.so',
'internal_api': 'openblas',
'num_threads': 1,
'prefix': 'libopenblas',
'threading_layer': 'disabled',
'user_api': 'blas',
'version': '0.3.24'}]
Context for the issue:
Found while debugging matplotlib/matplotlib#28762
The text was updated successfully, but these errors were encountered: