-
-
Notifications
You must be signed in to change notification settings - Fork 44
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 1.20 on MacOSX: spurious RuntimeWarning: invalid value encountered in reciprocal #229
Comments
This is a little weird. A simple |
@rgommers If you see the code and output above, np.linalg.norm does not raise the warning. I suspect this has to do with a difference in low-level implementation. |
That |
@rgommers I created a minimal POC that reproduces the issue without dask. >>> import numpy
>>> _ = numpy.ones(120) ** -1
<stdin>:1: RuntimeWarning: invalid value encountered in reciprocal With this one, too, the issue disappears when I either switch from numpy 1.20 (conda-forge) to either numpy 1.20.1 (pip wheel) or to numpy 1.19 (conda-forge). The issue gets a lot less frequent with an array size of 80, completely disappears at 65, and disapperas again at 150. |
This looks like a numpy issue. I had expected this to be the M1 (ARM64) build, because that's what's different for the conda-forge build of numpy 1.20. So what's a little surprising is that your |
@rgommers the pypi wheel is unaffected though. Exclusively the conda-forge build exhibits the issue. |
Thanks for posting a simple reproducer @crusaderky! FWIW I was able to reproduce the same
I also see the same Unfortunately I don't have a sense for what a good next step would be to determine where the conda list:
Also, hi @rgommers 👋 good to see you here : ) |
Hey @jrbourbeau, long time no see 👋
So not a conda-forge issue (which was unlikely anyway). My guess is it is related to the introduction of SIMD instructions in We can leave this open till it's resolved in a new NumPy release, but there's nothing to do in this repo. |
Great, thanks for linking to the upstream issue! |
There is no wheel for macOS ARM64 yet on PyPI. But the experimental nightly build ARM64 wheel has the same issue (as expected): numpy/numpy#18143 (comment) |
@ogrisel, this is for macOS x86_64. |
The upstream issue was fixed recently in numpy/numpy#19926. Once we are on 1.22, this should therefore go away. |
Closing this as fixed by 1.22 / #251 |
Reopen of #228
XREF dask/dask#7189
CC @jrbourbeau @jakirkham @isuruf
Issue:
numpy 1.20 on MacOSX randomly emits RuntimeWarnings when many small elementary operations are executed in very fast sequence. In the below POC, da.linalg.norm under the hood invokes operator.sum and operator.pow many times.
The problem disappears after switching the numpy package from conda-forge to the pypi wheel, leaving everything else unaltered.
This has been reproduced on both Python 3.7 and 3.8.
The number of emitted warnings goes down drastically if I invert the
for run
andfor axis
; in other words, if I do the exact same operations on the exact same numpy arrays 5 times in a row, I get a lot less warnings than if I frequently switch which numpy arrays I'm working on.Environment (
conda list
):Details about
conda
and system (conda info
):The text was updated successfully, but these errors were encountered: