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

Document/expose from_pyfunc? #146

Open
WardBrian opened this issue Aug 14, 2024 · 2 comments
Open

Document/expose from_pyfunc? #146

WardBrian opened this issue Aug 14, 2024 · 2 comments

Comments

@WardBrian
Copy link

Hi!

I think it is fairly common for a user to have a log density/its gradient outside of a PyMC or Stan model. I was helping one such user on the Stan forums recently and recommended they check out this package.

I was able to write what I think is a working example of how you can do this in nutpie, but

  1. It's not clear to me if this is really a "supported" functionality that won't be broken by future changes
  2. I had to basically reverse-engineer how to call the function, due the lack of documentation

Is this a use case you all are interested in supporting?

@ColCarroll
Copy link
Member

Not super helpful, but @aseyboldt helped me get nutpie working with JAX in bayeux: https://github.com/jax-ml/bayeux/blob/main/bayeux/_src/mcmc/nutpie.py

Broadly, bayeux accepts a log density in JAX, then uses function transforms to compute gradients, transforms, and log det jacobians. The implementation I linked does this by:

  1. Flattening the inputs to bayeux, to make a log density that works on a single vector (rather than some other structure)
  2. Passing this wrapped (and transformed) log density, along with the gradient, to nutpie
  3. Untransforming the returned samples

@aseyboldt
Copy link
Member

aseyboldt commented Aug 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants