# Is @fastmath less accurate on M-series macs?

**URL:** https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875
**Category:** General Usage
**Tags:** numerics
**Created:** [January 17, 2025, 2:08pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875 "2025-01-17T14:08:46Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 17, 2025, 2:08pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/1 "2025-01-17T14:08:47Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 17, 2025, 2:10pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/2 "2025-01-17T14:10:58Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)
#### Post date: [January 17, 2025, 2:12pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/3 "2025-01-17T14:12:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 17, 2025, 2:14pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/4 "2025-01-17T14:14:02Z")

</div>

> [@giordano](#):
>
> The whole point of `@fastmath` is to trade off accuracy with speed

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

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 17, 2025, 2:17pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/5 "2025-01-17T14:17:13Z")

</div>

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.)

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 17, 2025, 2:19pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/6 "2025-01-17T14:19:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [January 17, 2025, 2:25pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/7 "2025-01-17T14:25:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 17, 2025, 2:31pm UTC](https://discourse.julialang.org/t/is-fastmath-less-accurate-on-m-series-macs/124875/8 "2025-01-17T14:31:09Z")

</div>

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.
