You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TST: a flaky test on macOS arm64 (RuntimeWarning: invalid value encountered in matmul) #30162
Hum, looks like I was insanely lucky when I reproduced it locally after only ~5 attempts. I was not yet able to hit the bug (which I assume is a race) a single time since, despite dozens of subsequent attempts. Would be great to know if there's anything I can do to increase the likelyhood of hitting the race.
I don't see any changes in the details of the runner from the start of the CI job in the "Set up job" step across recent CI jobs. It is using macos-14.
changed the title [-]BUG: a flaky test on macOS arm64 (RuntimeWarning: invalid value encountered in matmul)[/-][+]TST: a flaky test on macOS arm64 (RuntimeWarning: invalid value encountered in matmul)[/+]on Nov 6, 2025
Thanks @neutrinoceros. I can get it to reproduce as well on a M2 macmini. I think if we are using Accelerate we should always call numpy._core._multiarray_umath._blas_supports_fpe(False). The problem is how to detect Accelerate. Another option is to give up and always call that when we are on macOS arm64.
what's the expected gain from not always calling Accelerate on this target
Not sure I understand. Accelerate gives a performance boost over OpenBLAS, it is supplied by Apple much like MKL is supplied by Intel. Both closed source libraries can match the hardware more optimally than open source solutions can.
In #30102 we assumed the warnings would be reliably emitted by the python-level matmul test. It seems this is not true, the check is flaky and so the FPE status is not ignored. I opened #30255 to always ignore FPE status in BLAS calls when Accelerate is used.
Activity
neutrinoceros commentedon Nov 6, 2025
Hum, looks like I was insanely lucky when I reproduced it locally after only ~5 attempts. I was not yet able to hit the bug (which I assume is a race) a single time since, despite dozens of subsequent attempts. Would be great to know if there's anything I can do to increase the likelyhood of hitting the race.
neutrinoceros commentedon Nov 6, 2025
Ah, got it a second time. I tried both Python 3.11 and 3.14 and I think both my lucky tries were on 3.11.
here's the script I'm running
(I'm building from scratch every time because I have no idea if this bug may be affected (possibly hidden) by partial rebuilds)
mattip commentedon Nov 6, 2025
Documenting the failure:
CI run failure
I don't see any changes in the details of the runner from the start of the CI job in the "Set up job" step across recent CI jobs. It is using macos-14.
neutrinoceros commentedon Nov 6, 2025
and for reference I'm running macos 15.7.1
I'm going to try and loop over my reprod script, see if I can reliably get a failure in a reasonable amount of time.
[-]BUG: a flaky test on macOS arm64 (RuntimeWarning: invalid value encountered in matmul)[/-][+]TST: a flaky test on macOS arm64 (RuntimeWarning: invalid value encountered in matmul)[/+]mattip commentedon Nov 9, 2025
@neutrinoceros do you have a M4 mac? We added code to ignore FPEs when Acclerate uses SME, but this seems to be something else. @Developer-Ecosystem-Engineering could you take a look?
neutrinoceros commentedon Nov 9, 2025
My mac is an M2. Is it expected to make a difference ?
neutrinoceros commentedon Nov 17, 2025
with gh-29820 being resolved, I retried this on the latest state of
main, and I can still reproduce the error.mattip commentedon Nov 18, 2025
Thanks @neutrinoceros. I can get it to reproduce as well on a M2 macmini. I think if we are using Accelerate we should always call
numpy._core._multiarray_umath._blas_supports_fpe(False). The problem is how to detect Accelerate. Another option is to give up and always call that when we are on macOS arm64.neutrinoceros commentedon Nov 18, 2025
naive question; what's the expected gain from not always calling Accelerate on this target ?
mattip commentedon Nov 18, 2025
Not sure I understand. Accelerate gives a performance boost over OpenBLAS, it is supplied by Apple much like MKL is supplied by Intel. Both closed source libraries can match the hardware more optimally than open source solutions can.
In #30102 we assumed the warnings would be reliably emitted by the python-level matmul test. It seems this is not true, the check is flaky and so the FPE status is not ignored. I opened #30255 to always ignore FPE status in BLAS calls when Accelerate is used.
neutrinoceros commentedon Nov 18, 2025
maybe my question didn't make sense; I'm a bit out of my depth here. In any case, thanks for addressing the issue !