Hello,
Yesterday, I installed cmdstanr on my MacBook Pro M1 2021, but I noticed that the times to get the same model through rstan are much larger (about three times).
Here is the detail of the times with cmdstanr:
All four chains finished successfully.
Mean chain execution time: 1067.0 seconds.
Total execution time: 1162.9 seconds.
While these are the times with rstan:
Chain 2: Elapsed Time: 236,488 seconds (Warm-up)
Chain 2: 114.685 seconds (Sampling)
Chain 2: 351.173 seconds (Total)
Chain 4:
Chain 4: Elapsed Time: 229,562 seconds (Warm-up)
Chain 4: 126.206 seconds (Sampling)
Chain 4: 355,768 seconds (Total)
Chain 1:
Chain 1: Elapsed Time: 234,668 seconds (Warm-up)
Chain 1: 126.342 seconds (Sampling)
Chain 1: 361.01 seconds (Total)
Chain 3:
Chain 3: Elapsed Time: 220.462 seconds (Warm-up)
Chain 3: 159.392 seconds (Sampling)
Chain 3: 379,854 seconds (Total)
These are the commands to run the model via cmdstanr:
comp_model <- cmdstan_model("MS_Normal_Gumbel_K2_test.stan")
out2 <- comp_model$sample(data = stan_dat,
init = init_par,
seeds = 123,
chains = 4,
parallel_chains = 4,
iter_sampling = 1000,
iter_warmup = 1000,
adapt_delta = 0.99,
step_size = 0.1,
max_treedepth = 10)
This is the command to run the same model via rstan:
out2 <- stan(file = "MS_Normal_Gumbel_K2_test.stan",
data = stan_dat, iter = 2000,
cores = 4, init = init_par, include = TRUE,
control = list(adapt_delta = 0.99, stepsize = 0.1, adapt_gamma = 0.75, adapt_t0 = 10, max_treedepth = 10),
pars = c("betaL1_new","betaL2_new","betaS1_new","betaS2_new",
"ltauL1", "betaTp01_new", "betaTp10_new","pit", "log_lik", "lp__"))
This behavior seems very strange to me since we noticed a performance improvement while running the same model on Windows. I tried to set the variables following this topic: https://discourse.mc-stan.org/t/stan-compile-with-apple-accelerate-blas-lapack/32164/5 but without results.
I wanted to ask if you think this behavior is plausible or if you have any suggestions on improving cmdstanr performance.
Some info that might be useful:
- Macbook Pro M1 2021
- Sequoia 15.1.1
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.1.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
- CmdStan Version: 2.36
- rstan Version: 2.32.6
- Compiler/Toolkit:
clang++ --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
Thank you!