Skip to content
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

Replace httpstan wrapper with BridgeStan #424

Open
simeoncarstens opened this issue Feb 14, 2023 · 0 comments · May be fixed by #480
Open

Replace httpstan wrapper with BridgeStan #424

simeoncarstens opened this issue Feb 14, 2023 · 0 comments · May be fixed by #480
Labels
Stan Relates to Stan model support

Comments

@simeoncarstens
Copy link
Member

Stan support in Chainsail currently relies on wrapper around httpstan. So for every log-probability / gradient evaluation, the wrapper sends a HTTP request to the httpstan API that runs in a separate Docker container. This is very, very slow and very, very clunky.

Recently, BrigeStan was released. It allows

efficient in-memory access through Python, Julia, and R to the methods of a Stan model, including log densities, gradients, Hessians, and constraining and unconstraining transforms

and is exactly what we need. I did some preliminary tests and using BridgeStan yields a x1000 speed-up over using the existing httpstan wrapper 🤯 plus it might be easier to maintain; we could just bake it in as a system dependency into the user code container. My experiments stopped there because of the trouble of developing this under NixOS - BridgeStan requires stanc (the Stan compiler) and downloads binaries for that, which have an hardcoded RPATH, and furthermore, it requires GCC + dependencies. So under NixOS, without having packaged BridgeStan properly, developing this feature is very tiresome.

So the goal would be to replace the httpstan wrapper linked above with a wrapper around BridgeStan. Note, though, that the Stan model still has to be compiled before the log-probability and its gradient can be evaluated via BridgeStan. That would likely need to be done in the constructor of the wrapper.

@simeoncarstens simeoncarstens added the Stan Relates to Stan model support label Feb 14, 2023
@simeoncarstens simeoncarstens linked a pull request Jul 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stan Relates to Stan model support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant