# Optimal compiler flags M4 Max

**URL:** <https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559>\
**Category:** General\
**Tags:** cmdstanpy\
**Created:** [October 25, 2025, 8:28am UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559 "2025-10-25T08:28:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Matthews](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sean_matthews/32/4276_2.png) [@Sean\_Matthews](https://discourse.mc-stan.org/u/Sean_Matthews)\
**Post date:** [October 25, 2025, 8:28am UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559/1 "2025-10-25T08:28:00Z")

</div>

Very simple question (I’ve searched, but I can’t find a matching answer).

I have a Mac M4 Max. How should I set compiler flags (in cmdstanpy) for optimal performance?

All advice appreciated.

---

<div class="post-metadata">

**Author:** ![jr-leary7](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jr-leary7/32/19495_2.png) [@jr-leary7](https://discourse.mc-stan.org/u/jr-leary7)\
**Post date:** [October 27, 2025, 6:50pm UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559/2 "2025-10-27T18:50:59Z")

</div>

On my M2 Mac Mini I use `-03 -march=native -mtune=native` when compiling `cmdstan` and it works quite well.

---

<div class="post-metadata">

**Author:** ![Sean\_Matthews](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sean_matthews/32/4276_2.png) [@Sean\_Matthews](https://discourse.mc-stan.org/u/Sean_Matthews)\
**Post date:** [October 27, 2025, 11:28pm UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559/3 "2025-10-27T23:28:39Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/1/9/190baba5d6cf7e2bde3ad3a6c819fe8b7fb79243.png) [@system](https://discourse.mc-stan.org/u/system)\
**Post date:** [October 22, 2026, 11:29pm UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559/4 "2026-10-22T23:29:04Z")

</div>

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.
