# Stanc optimization and generated quantities

**URL:** <https://discourse.mc-stan.org/t/stanc-optimization-and-generated-quantities/40653>\
**Category:** Developers\
**Created:** [November 18, 2025, 10:25pm UTC](https://discourse.mc-stan.org/t/stanc-optimization-and-generated-quantities/40653 "2025-11-18T22:25:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamConnerSax](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/adamconnersax/32/9901_2.png) [@adamConnerSax](https://discourse.mc-stan.org/u/adamConnerSax)\
**Post date:** [November 18, 2025, 10:25pm UTC](https://discourse.mc-stan.org/t/stanc-optimization-and-generated-quantities/40653/1 "2025-11-18T22:25:45Z")

</div>

I recently realized that in my setup (Mac OS X 26.1 on an M1 Macbook pro, using cmdstan 2.37) I was not giving the optimization flag to stanc. So I changed that option. And immediately my “generated quantities” runs became hugely slow: things which had taken a few seconds instead took tens of minutes. The modeling runs were unaffected (or maybe faster?).

I’d be happy to test it on a reproducible setup. My current code is…not that. Is one of the examples or a common test well set up to test this workflow?

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [November 19, 2025, 1:20pm UTC](https://discourse.mc-stan.org/t/stanc-optimization-and-generated-quantities/40653/2 "2025-11-19T13:20:24Z")

</div>

That’s very interesting. I would not expect it to make any difference in the standalone generated quantities case, as most of the optimizations are around autodiff

Any code you can share would be useful!
