-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stanc_options = list(“O1”) not being applied? #791
Comments
Hmm, I'm not sure what's going on because when I run this I see a pretty big speed difference:
@rok-cesnovar Any idea why this wouldn't work for @tomshafer but seems to work fine for me? |
That’s so interesting—exactly what I was hoping to see, but I’ve tried a few different things since, without success (I’m on a 2.6 GHz i7, which should be OK-ish).
|
This is really strange! I get the same thing as Jonah, also on a Mac. Are you using the most-recent Github version of cmdstanr? If not, can you try that? Will post some additional debugging ideas in a bit. |
OK, I think this was a problem with my CmdStan install. Instead of remotes::install_github("stan-dev/cmdstanr")
# Restart session
library(cmdstanr)
options("cmdstanr_verbose" = TRUE)
# Custom make/local
install_cmdstan(overwrite = TRUE, cpp_options = list(
"CXX = /usr/local/opt/llvm/bin/clang++",
"STAN_THREADS = true",
"STAN_NO_RANGE_CHECKS = true",
"PRECOMPILED_HEADERS = true",
"CXXFLAGS_OPTIM = -O3 -mtune=native -march=native",
"CXXFLAGS_OPTIM_TBB = -O3 -mtune=native -march=native",
"CXXFLAGS_OPTIM_SUNDIALS = -O3 -mtune=native -march=native",
"CXXFLAGS += -DEIGEN_USE_BLAS -Wno-deprecated-declarations -Wno-deprecated-builtins",
"LDLIBS += -framework Accelerate"
))
# Restart
library(cmdstanr)
options("cmdstanr_verbose" = TRUE)
# Simulated data
set.seed(1)
n <- 25000
k <- 10
X <- matrix(rnorm(n * k), ncol = k)
y <- rbinom(n, size = 1, prob = plogis(3 * X[,1] - 2 * X[,2] + 1))
mdata <- list(k = k, n = n, y = y, X = X)
# Non-optimized model
mod_no_opt <- cmdstan_model("lr.stan", exe_file = "no_opt_lr", force_recompile = TRUE)
fit_no_opt <- mod_no_opt$sample(data = mdata, seed = 1, chains = 1, refresh = 500)
# Optimized model
mod_opt <- cmdstan_model("lr.stan", exe_file = "opt_lr", stanc_options = list("O1"), force_recompile = TRUE)
fit_opt <- mod_opt$sample(data = mdata, seed = 1, chains = 1, refresh = 500)
> print(fit_no_opt$time()$total)
[1] 16.86377
> print(fit_opt$time()$total)
[1] 7.907304 |
Awesome to hear that it's working now! I am not sure I have any ideas as to what happened. Will close the issue for now, but don't hesitate to post if the issue comes back. Hoping it doesn't though :) |
OK, here’s the issue! Installing from GitHub with
Installing with
Does the release not support |
Great, really appreciate the follow-up! We are working on getting the Github version released ASAP, so this should be resolved in the next few days. |
Describe the bug
I have tried to follow this Discourse post demonstrating
stanc
’s--O1
flag in cmdstanr, but it seems like the flag is not being passed tostanc
.To Reproduce
lr.stan
Expected behavior
fit_opt
is fastermod_opt
shows--O1
is applied tostanc
Instead, the models run in about equal time and the
stanc
call doesn’t have O1 applied.Operating system
macOS 13.4.1
CmdStanR version number
0.5.3
Additional context
CmdStan version 2.32.2
The text was updated successfully, but these errors were encountered: