Skip to content

PyMC implementation of WALNUTS sampler #7836

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

Closed
wants to merge 4 commits into from

Conversation

fonnesbeck
Copy link
Member

@fonnesbeck fonnesbeck commented Jun 26, 2025

Description

First pass at implementing WALNUTS, partly as a learning opportunity. It runs with pm.sample but does not yet produce a good sample. Still lots of work to do.

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7836.org.readthedocs.build/en/7836/

@twiecki
Copy link
Member

twiecki commented Jun 26, 2025

Why not hook up to the walnuts implrementation Bob et al provide?

@fonnesbeck
Copy link
Member Author

This borrows directly and heavily from Bob's repo. Its really not a lot of code.

Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 6.87773% with 853 lines in your changes missing coverage. Please review.

Project coverage is 88.81%. Comparing base (3ae5095) to head (4b474b5).

Files with missing lines Patch % Lines
pymc/step_methods/hmc/adaptive_integrators.py 3.41% 424 Missing ⚠️
pymc/step_methods/hmc/walnuts.py 8.41% 381 Missing ⚠️
pymc/step_methods/hmc/p2_quantile.py 14.28% 48 Missing ⚠️

❌ Your patch status has failed because the patch coverage (6.87%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7836      +/-   ##
==========================================
- Coverage   92.91%   88.81%   -4.11%     
==========================================
  Files         107      111       +4     
  Lines       18286    19201     +915     
==========================================
+ Hits        16991    17053      +62     
- Misses       1295     2148     +853     
Files with missing lines Coverage Δ
pymc/step_methods/__init__.py 100.00% <100.00%> (ø)
pymc/step_methods/hmc/__init__.py 100.00% <100.00%> (ø)
pymc/step_methods/hmc/walnuts_constants.py 100.00% <100.00%> (ø)
pymc/step_methods/hmc/p2_quantile.py 14.28% <14.28%> (ø)
pymc/step_methods/hmc/walnuts.py 8.41% <8.41%> (ø)
pymc/step_methods/hmc/adaptive_integrators.py 3.41% <3.41%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@twiecki
Copy link
Member

twiecki commented Jun 26, 2025

This borrows directly and heavily from Bob's repo. Its really not a lot of code.

Sure, but they'll keep iterating on it so we'd always need to keep up with changes. Anyway, I'm not against it, we can always revert back to their implementation if we find it's a great sampler. Or pymc-extras might also be a place.

…ize and state management. Introduced new utility classes for state storage and U-turn checks, and updated the constructor parameters for improved flexibility. Added comprehensive docstring for clarity and reference.
@fonnesbeck
Copy link
Member Author

fonnesbeck commented Jun 26, 2025

Yeah, this should probably be in pymc-extras. I will move it.

I think that if it turns out to be a performant algorithm we will want our own implementation of it (doesn't have to be this one, of course).

@fonnesbeck fonnesbeck closed this Jun 27, 2025
@fonnesbeck
Copy link
Member Author

Moved to pymc-devs/pymc-extras#530

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

Successfully merging this pull request may close these issues.

2 participants