Skip to content

Conversation

@juanitorduz
Copy link
Collaborator

@juanitorduz juanitorduz commented Jan 20, 2026

Trying to support #2039

reubenharry and others added 2 commits January 20, 2026 23:18
Add MCLMC inference algorithm as a new MCMCKernel that wraps blackjax's
MCLMC implementation. This provides an alternative gradient-based MCMC
method to NUTS/HMC.

Features:
- MCLMC kernel with automatic step size and trajectory length tuning
- Optional blackjax dependency with informative error message
- postprocess_fn for constrained/unconstrained transformations
- Diagnostics string for progress bar
- Comprehensive test suite

References:
- Microcanonical Hamiltonian Monte Carlo (arXiv:2212.08549)
@juanitorduz
Copy link
Collaborator Author

Hey @reubenharry I tried using your branch, but I made a git mess 🙈 so I decided to open another one to get feedback (I will add you as a coauthor).

Could you please check this one out and see if the implementation (and the tests) are as expected?

@juanitorduz juanitorduz marked this pull request as draft January 20, 2026 22:31
@juanitorduz juanitorduz self-assigned this Jan 20, 2026
@juanitorduz juanitorduz added the enhancement New feature or request label Jan 20, 2026
Co-authored-by: reubenharry <reubenharry@users.noreply.github.com>
Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that we might introduce technical debt by depending on other libraries. Could we turn this into an example/tutorial instead? It's not clear to me the benefit of using numpyro here.

@fehiepsi
Copy link
Member

fehiepsi commented Jan 20, 2026

Maybe adding a section for https://num.pyro.ai/en/stable/tutorials/other_samplers.html would be better?

edit: #2035 has good discussion about the above points

@juanitorduz
Copy link
Collaborator Author

I worry that we might introduce technical debt by depending on other libraries. Could we turn this into an example/tutorial instead? It's not clear to me the benefit of using numpyro here.

Sure! This was a first attempt at trying to see how it would fit. I agree this "optional" dependencies can be hard to maintain.

So what about adding another section with this code in https://num.pyro.ai/en/stable/tutorials/other_samplers.html ?

Or do we want an additional notebook with just a brief explanation of MCLMC?

@martinjankowiak
Copy link
Collaborator

on the other hand the optimal outcome would be that its very easy for numpyro users to use the sampler. if it's hidden in some tutorial...

@juanitorduz
Copy link
Collaborator Author

on the other hand the optimal outcome would be that its very easy for numpyro users to use the sampler. if it's hidden in some tutorial...

True 😄 . I do not have any strong opinion. I just wanted to bring this one alive. That being said, I have seen blackjax making breaking changes and this would be a pain to maintain indeed (in the notebook we would put a disclaimer about these potential changes)

@juanitorduz
Copy link
Collaborator Author

juanitorduz commented Jan 20, 2026

ok! In af9f001 I added blackjax to the tests-deps just to ensure the tests are green.

After that I can try to port it into the notebook (and remove any blackjax dependency) for now and keep the discussion open in #2035 . We can always come back to the commit history and put it back in NumPyro :)

@martinjankowiak
Copy link
Collaborator

how entangled is the blackjax implementation with the rest of blackjax? can the sampler be ripped out with minimal changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants