stan icon indicating copy to clipboard operation
stan copied to clipboard

CmdStan issue with two chains and thinning

Open bob-carpenter opened this issue 8 years ago • 6 comments

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-carpenter avatar Nov 02 '16 22:11 bob-carpenter

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.

goedman avatar Nov 02 '16 22:11 goedman

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.

bob-carpenter avatar Nov 03 '16 20:11 bob-carpenter

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.

syclik avatar Nov 26 '16 02:11 syclik

Thanks Daniel!

goedman avatar Nov 26 '16 02:11 goedman

this is still a problem as of stan 2.20.0

mitzimorris avatar Sep 27 '19 10:09 mitzimorris

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.

rok-cesnovar avatar Apr 26 '20 08:04 rok-cesnovar

No longer leads to an error

WardBrian avatar Feb 14 '24 17:02 WardBrian