Documentation of external C++ with precomputed gradients needs update?

In this recent thread, @andrjohns mentions that make_callback_var() should be used when writing external C++ functions that use precalculated gradients. I have been using precomputed_gradients() to do this. Is precomputed_gradients() deprecated? If so, is this a very recent development?

Also, I can’t find any mention of make_callback_var() in the current documentation for cmdstan or rstan. What’s the best way to stay up to date on developments like this?

It has not been officially deprecated and there is no current plan of doing that as of right now. The make_callback_var was added about a year and a half ago I believe - it’s definitely been around since summer/fall of 2020.

Both rstan and cmdstan are Stan interfaces and make_callback_var is more of an implementation detail of the backend that powers Stan. We dont really focus on the C++ backend in any of the interface documentation, apart from maybe when discussing including external C++ code, which is more a niche feature anyways.

If you are interested in the Stan Math backend, that docs are available here: Stan Math Library: Getting Started Guide

If you have any requests or comments on the docs, please open an issue in the Math repository. Any feedback is much appreciated.

Thanks for the clarification.

I should have been more clear that the cmdstan (https://mc-stan.org/docs/2_29/cmdstan-guide/using-external-cpp-code.html) and rstan (https://cran.r-project.org/web/packages/rstan/vignettes/external.html) documentation I was referring to was specifically for the use of external C++. These would need updating, no?

1 Like

Yeah, that might be worth expanding.

rstan is still at version 2.21, where precomputed_gradients is still the preferred and recommended way. And the cmdstan docs you linked don’t actually have any gradient related instructions, which it probably should have - at least a minimal example.

Thanks for the suggestion!

Just to clarify on the linked thread, that user was implementing their gradients using the precomp_v_vari function, which had subsequently been removed from the Math library. There aren’t any issues with the precomputed_gradients() function, and no need to change your current code

1 Like