I'm trying to integrate PyStan into my workflow, but just compiling a seemingly simple model can take 10+ minutes.
This slow compilation time shouldn't be an issue once the model is finished. But for development, it would be nice to iterate through small changes more quickly. Maybe it would make sense to remove compiler optimizations in favour of faster compilation times.
Searching online, I found two related discussion threads:
- https://github.com/stan-dev/pystan/issues/214
- https://discourse.mc-stan.org/t/why-is-it-so-slow-for-stan-to-compile-model/6004
Both are discussing the option to introduce custom compiler flags. A PR with this feature has been merged, StanModel
now exposes extra_compile_args
But it doesn't behave as expected. I looked at the source code here and it really just adds additional compiler options. It doesn't override or remove the existing ones. So the code will always be compiled with -O2
How can I influence the compiling of stan models in PyStan, to trade reduced performance for faster compilation?