Comparing the results of a floating point computation across a couple of different machines, they are consistently producing different results. Here is a stripped down example that reproduces the behavior:
import numpy as np
from numpy.random import randn as rand
M = 1024
N = 2048
np.random.seed(0)
a = rand(M,N).astype(dtype=np.float32)
w = rand(N,M).astype(dtype=np.float32)
b = np.dot(a, w)
for i in range(10):
b = b + np.dot(b, a)[:, :1024]
np.divide(b, 100., out=b)
print b[0,:3]
Different machines produce different results like
- [ -2.85753540e-05 -5.94204867e-05 -2.62337649e-04]
- [ -2.85751412e-05 -5.94208468e-05 -2.62336689e-04]
- [ -2.85754559e-05 -5.94202756e-05 -2.62337562e-04]
but I can also get identical results, e.g. by running on two MacBooks of the same vintage. This happens with machines that have the same version of Python and numpy, but not necessarily linked against the same BLAS libraries (e.g accelerate framework on Mac, OpenBLAS on Ubuntu). However, shouldn't different numerical libraries all conform to the same IEEE floating point standard and give exactly the same results?