Run chains in parallel and increase max treedepth in CmdStan

I am using CmdStan on a linux machine and I want to increase the max treedepth and run 2 chains in parallel. However, I did not find the information how to do it in the CmdStan User’s Guide.

I am running the
model_filename sample data file=data_filename.R
command.

What do I need to add? Thanks in advance!

For max treedepth you need to run the exe as

model_filename sample algorithm=hmc engine=nuts max_depth=X data file=data_filename.R

For multiple chains you need to just run multiple executables. But you need to be careful to specify a different output filename for each of them.

model_filename sample algorithm=hmc engine=nuts max_depth=X data file=data_filename.R output file=chain-1.csv &
model_filename sample algorithm=hmc engine=nuts max_depth=X data file=data_filename.R output file=chain-2.csv &

You can also use this bash script (this one uses 4 chains):

for i in {1..4}
    do
      ./model_filename sample algorithm=hmc engine=nuts max_depth=X data file=data_filename.R output file=chain-${i}.csv &
    done
1 Like

Great, thank you!