Stanc3 O1 optimisation bug


There is something very wrong with my code when I run it with the STANC O1 settings (as per 34.5 Optimization | Stan User’s Guide).

The step size gets driven down to almost nothing. The results are very different from when I run it without the O1 settings.

Is there any way of turning on the individual optimisations one-at-a-time to see which one is responsible (rather than having a set of them enabled with O1)?

Failing this, I can try to go through the optimised code, but it’s close to 2k lines, so I’m trying to avoid this if possible.

I’m using cmdstan-2.30.1 via cmdstanr 0.5.2.


Can you share the Stan code? No need for data, as it is sufficient to compare the generated C++ code with and without O1.

Diffing the code with O1 vs without O1 probably helps to reduce the number of lines to be examined

Yes, just to echo @avehtari it would be very useful if you were able to share the model code which triggers this behavior @JulianK!