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

Implement vectorized adaptive HMC #2902

Open
eb8680 opened this issue Jul 15, 2021 · 6 comments
Open

Implement vectorized adaptive HMC #2902

eb8680 opened this issue Jul 15, 2021 · 6 comments
Labels
enhancement good first issue help wanted Issues suitable for, and inviting external contributions

Comments

@eb8680
Copy link
Member

eb8680 commented Jul 15, 2021

Pyro's HMC and NUTS implementations are feature-complete and well-tested, but they are quite slow in models like the one in our Bayesian regression tutorial that operate on small tensors for reasons that are largely beyond our control (mostly having to do with the design and implementation of torch.autograd), which is unfortunate because these are often the subjects of new users' first encounters with Pyro. Running multiple MCMC chains in parallel is one way of dealing with this problem, but Pyro's MCMC algorithms currently only support process-level parallelism with torch.multiprocessing, which is slower, memory-hungry and also error-prone on some platforms like Google Colab and Windows.

This issue proposes implementing the "ChEES-HMC" algorithm described in this paper as a new MCMC kernel where vectorization over individual MCMC chains happens via broadcasting in an additional plate context, similar to the vectorization over guide samples in our Trace*_ELBO implementations. While this algorithm is unlikely to replace NUTS in all contexts, vectorization over a large number of independent chains may be especially useful in alleviating PyTorch-related performance issues in small models.

Note that this proposal is more narrowly scoped than the general suggestion in #2539 to support broadcasting-based parallelization in our existing MCMC kernels, which as @fehiepsi said in #2539 is probably best deferred until better auto-vectorization functionality a la JAX's vmap is added to PyTorch.

This would be a great starting point for a contributor with some probabilistic ML expertise who is interested in adding a high-impact feature to Pyro while learning more about some of the internal inference APIs. If that sounds like you, please speak up! We're happy to help review draft code or discuss design issues.

@eb8680 eb8680 added enhancement help wanted Issues suitable for, and inviting external contributions good first issue labels Jul 15, 2021
@karthikayan4u
Copy link

Hello @eb8680 , I am completely new to open source contribution. Although there are lot of alien terms for me in the above proposal, I am very open to learn and work on this proposal. Please, share some resources on the same.

@eb8680
Copy link
Member Author

eb8680 commented Aug 24, 2021

Hi @karthikayan4u, thanks for your interest in contributing to Pyro! The immediate background information necessary to understand this proposal is in the paper I linked to about ChEES-HMC.

Do you have much experience with applied Bayesian statistics or probabilistic programming, or have you perhaps taken a class based on either the Bishop or Murphy textbooks on probabilistic machine learning? If not, this might be a difficult place to start, and I would suggest making your first contribution an example or tutorial, which is the most valuable thing you can do for almost any open source project and also a great way to familiarize yourself with Pyro. One particularly easy and helpful task would be porting a version of the CVAE tutorial on the Pyro web page to NumPyro.

@karthikayan4u
Copy link

I have very less knowledge on those topics you mentioned. So, I will start with the task you suggested. Meanwhile, I will try to take those classes you mentioned and come back to work on this proposal. Thank you @eb8680 .

@Militeee
Copy link

Militeee commented Sep 4, 2023

Hello @eb8680, did anybody implement it in the end? If not, I would be super interested in implementing some probabilistic ML algorithm like this one. I had a couple of courses in PML based on Bishop's book and I have been a Pyro user for quite a while now, so hopefully I should not be totally clueless. I will still need some help with the Pyro internals but I am super happy to learn more.

Cheers,
S.

@martinjankowiak
Copy link
Collaborator

@Militeee no, this is still an open issue. please take a crack at it if you're interested : ) one way to do that would be to open a new targeted issue where you describe what you plan to implement. that would also be a first opportunity for other developers to give you feedback before you write much code

@Militeee
Copy link

Militeee commented Sep 6, 2023

Brilliant, I'll read the paper and open a new issue as soon as I have a plan for the implementation. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue help wanted Issues suitable for, and inviting external contributions
Projects
None yet
Development

No branches or pull requests

4 participants