-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Describe the issue:
While working on a bug in my project I noticed some strange behavior between Linux and MacOS with regards to the output of numpy.dot().
On Linux, the output of a specific numpy.dot() operation (details in the code to reproduce) is (with NumPy 2.2.6)
[-0.50000000000000011102 -0.50000000000000011102 -0.50000000000000000000]
and on MacOS (ARM) the output is (with NumPy 2.3.4)
[-0.50000000000000000000 -0.50000000000000011102 -0.50000000000000000000]
In my limited testing capabilities I can confirm that the output from Mac and Linux with NumPy 1.26.4 is identical, but for at least NumPy >= 2.2.2 (I suspect this is actually >= 2.0.0 but haven't been able to test this) the outputs differ and are the demonstrated result.
Reproduce the code example:
import numpy as np
np.set_printoptions(precision=20, floatmode="fixed")
pos_i = np.array([0., 0., 0.], dtype=np.float64)
c = np.array([0.61550000000000071321, 1.06607727205864510900, 7.50000000000000000000], dtype=np.float64)
axinv = np.array(
[
[ 4.06173842404549123586e-01, 0.00000000000000000000e+00, 0.00000000000000000000e+00],
[ 2.34504577250050944004e-01, 4.69009154500102054541e-01, 0.00000000000000000000e+00],
[-4.97419495998112408112e-17, -4.97419495998112408112e-17, 6.66666666666666657415e-02],
], dtype=np.float64
)
dot = np.dot(pos_i-c,axinv)
print(dot)Error message:
Python and NumPy Versions:
Python version (Linux) - 3.10.12
NumPy version (Linux) - 2.2.6
Python version (MacOS) - 3.12.10
NumPy version (MacOS) - 2.3.4
Runtime Environment:
No response
Context for the issue:
This result was noticed during a routine test in QMCPACK PR 5345 due to an operation using numpy.floor() which returned two different values for Linux and MacOS, leading to a test failure. We likely will be changing this test so that it is less sensitive to this sort of discrepancy, however the fact that this happened at all means we may need to revisit all of the occurrences of numpy.dot() in the codebase.