-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Possible inefficency of $unconstrain_variables()
#920
Comments
Thanks for reporting and sorry for the delay. @andrjohns is this speed difference to be expected? |
@crsh Thanks for flagging! I've implemented fixes/optimisations via #960, and your example is now benchmarking for me as: > microbenchmark(
+ upars <- cmdstan_fit_H0$unconstrain_draws()
+ , times = 3
+ )
Unit: milliseconds
expr min lq mean median uq max neval
upars <- cmdstan_fit_H0$unconstrain_draws() 14.29379 14.7255 15.84829 15.15721 16.62554 18.09387 3 And also just to flag that you can just call |
Closed by #960 |
For context, I have implemented methods to support
CmdStanFit
-objects inbridgesampling::bridge_sampler()
. While the new methods work as expected, they are very slow compared to thestanfit
-methods forrstan
. On my 2017 MacBook Pro, My example takes about 1.000 ms withrstan::unconstrain_pars()
but almost 20.000 ms withfit$unconstrain_pars()
:Note that this does not include the additional compilation time required by
$init_model_methods()
.I have spent quite some time profiling this issue and from what I can tell, it is this line that is responsible for most of the difference:
cmdstanr/R/fit.R
Line 526 in d3b455f
I know next to nothing about C++, so I was wondering whether this is an issue with the implementation of
$unconstrain_variables()
, whether there is a problem with my setup, or whether I'm possibly making a mistake somewhere. Any pointers would be appreciated.CmdStanR version number
packageVersion("cmdstanr")
The text was updated successfully, but these errors were encountered: