stan
stan copied to clipboard
CmdStan issue with two chains and thinning
Summary:
From Rob Goedman on stan-dev, there's an issue with two chains and thinning.
Reproducible Steps:
When running a mode
My test model:
simple.stan:
data {real sigma;}
parameters {real y;}
model {y ~ normal(0,sigma);}
simple_1.data:
"sigma" <- 1.0
l with settings:
./simple sample num_samples=1000 num_warmup=1000 save_warmup=1 thin=2 adapt engaged=1 gamma=0.05 delta=0.8 kappa=0.75 t0=10.0 init_buffer=75 term_buffer=50 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=1.0 random seed=-1 init=2 id=1 data file=simple_1.data.R output file=simple_samples_1.csv refresh=100
and then run
/Users/rob/Projects/Stan/cmdstan/bin/stansummary simple_samples_*.csv
Current Output:
MacBook-Pro:tmp rob$ /Users/rob/Projects/Stan/cmdstan/bin/stansummary simple_samples_*.csv
Warning: non-fatal error reading adapation data
Warning: non-fatal error reading adapation data
Warning: non-fatal error reading adapation data
Warning: non-fatal error reading adapation data
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: mean: v has size 0, but must have a non-zero size
Abort trap: 6
Expected Output:
The summary printed.
Current Version:
v2.12.0
Bob & Daniel,
It is the combination of save-warmup=1 and thin>1 that creates the problem. For now I just catch the trap in Julia, print a message and collect the chain results. Subsequent inference with the Mamba tools works fine. It just the combined inference summary the stansummary program produces that won't work. I'm pretty sure it has to do with a few comment lines inserted between the end of the warmup samples and the real samples.
Thanks, Rob
Note: I believe it occurs even with a single chain.
Hpefully we'll be fixing all of this in a massive I/O refactor for Stan 3. But this one's worth fixing now before we do that.
I figured it out, but it requires a fix to Stan. It won't be available in CmdStan 2.13.0, but will be in a version shortly after.
Thanks Daniel!
this is still a problem as of stan 2.20.0
I came across this issue. The issue is that stan_csv_reader fails if there are stored warmup samples. So its a stan issue. Transferring. Fix incoming.
No longer leads to an error