Is @fastmath less accurate on M-series macs?

I have a repo where the CI fails for macOS-latest but succeeds for windows-latest and ubuntu-lastest. The failed tests are accuracy tests. I have yet to write up an isolated minimal working example. Has anyone encountered precision issues with @fastmath on Macs?

Less accurate than what? The whole point of @fastmath is to trade off accuracy with speed, so yeah, losing accuracy compared to standard IEEE754 arithmetic is very much in the realm of using @fastmath.

3 Likes

From the post I believe the question is why fastmath would be less accurate for mac than for windows or ubuntu.

I just want to know if this trade-off is well-known to be platform-dependent.

There’s no guarantee whatsoever to get exact bit-by-bit same results between different machines, even different CPUs within same operating system.

Julia’s math functions tries to keep consistent results as much as possible, but whenever you call out to external libraries (e.g. BLAS) or use fastmath you’re giving up on any consistency and it’s all down to external factors (CPU, operating system, external libraries, etc.)

3 Likes

Thanks for the answers. Then I need to tweak the CI tests to not demand the exact same accuracy as what I found on my non-Mac laptop.

If you had an MWE, I would be interested As long as you aren’t using Rosetta, they should be giving very similar results.

The results are actually rather similar between platforms. The tests were too stringent and basically said that the deviation from the (practically error-free) BigFloat result shouldn’t be more than a few percent larger than what I got on my laptop.

1 Like