-
-
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
Add optional methods for log_prob, grad_log_prob, hessian, un/constrain pars #701
Conversation
Codecov Report
@@ Coverage Diff @@
## master #701 +/- ##
==========================================
+ Coverage 89.98% 90.35% +0.37%
==========================================
Files 12 12
Lines 3653 3794 +141
==========================================
+ Hits 3287 3428 +141
Misses 366 366
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Awesome @andrjohns! Will review this later today. |
@rok-cesnovar The WSL backend seems to be a bit brittle still. I'll be working through the WSL fixes PR soon (after the Math library system libs PR), should we disable the WSL-backend for now until I've got the next PR stable and in? |
I am also fine leaving it as is. Will just ignore the failure on that test for the time being. |
And before I forget, we can also cut down on the compilation time needed here in the future. The only function that needs to be compiled for each model specifically is the The idea would be to compile the |
The changes look great to me, and we can merge as is. Thanks again, this is awesome! I have a few ideas/thoughts to discuss:
Caching this would be great, but we can handle this once this is in. |
Great!
Nope, it's not relying on anything introduced recently (as far as I know), just existing headers in the Stan library (with the
Good idea! I can add that tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks so much!
Submission Checklist
Summary
This PR adds the (optional) ability to compile and expose several methods from the Stan model so that they can be called by
cmdstanr
. After fitting the model, the user just needs to call the$init_model_methods()
method, and R will compile and expose the following methods to the fit object:log_prob
grad_log_prob
constrain_pars
unconstrain_pars
Additionally, if the user calls
$init_model_methods()
with thehessian = TRUE
flag, a Hessian member function will also be compiled and exposed. I've defaulted this toFALSE
since it requires all functions in the Stan model to befvar<var>
compatible, and I've already run into some issues withbernoulli_logit_glm
in the basic testing (Math issue/PR to come).These methods and the dependencies (
Rcpp
andRcppEigen
) are left as suggests/optional, since I don't think we wantcmdstanr
to require compilation/linking at installation.Copyright and Licensing
Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Andrew Johnson
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: