Hello Stanimals (in particular @wds15) ,

when using `map_rect`

with threading support, shouldn’t the posterior have no dependence (modulo differences due to numerical precision) on the number of threads (leaving the data, random number seed and number of chains constant in this comparison)?

Of course, the number of shards explicitly appears in such Stan code, but the number of threads doesn’t. So I would expect that my posterior should *not* be sensitive to a change in the number of threads while leaving the number of shards constant (obviously this does not apply to the run time).

Have a look at this figure, which is based on an experiment that I did varying the number of threads in a simple survival model:

Here the `intercept_{1,2,3,4}`

correspond to running the same model, with the same data and the same seed, just with different values of `STAN_NUM_THREADS=1,2,3,4`

. `intercept_0`

is a separate model, written without `map_rect`

, that uses the same seed, data and number of chains, as a reference.

For more details, please have a look at this R reproducible R example. Also, in my repository here you also find the corresponding Stan models.

Maybe I did something wrong here in my code which causes this, but I can’t see it…

Cheers,

Eren.