4

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:

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?

lhk
  • 27,458
  • 30
  • 122
  • 201
  • did you get anywhere with this? I've just tried `cmdstanpy` which reduces compile times (for a small model) from 75 (with pystan 2.19.1.1) to 20 seconds (with cmdstan 2.21.0). still annoyingly long for iterating, but a lot better – Sam Mason Dec 14 '19 at 23:40
  • note: I presume most of this speed up is due to a more recent version of stan that includes a [change](https://github.com/stan-dev/cmdstan/pull/713) to improve compilation time. pystan seems to be lagging behind cmdstan so that seems like the easiest way to get that optimisation at the moment – Sam Mason Dec 15 '19 at 14:41

0 Answers0