Skip to content

Support user callback with nutpie sampler - #8488

Open
saheli56 wants to merge 1 commit into
pymc-devs:mainfrom
saheli56:fix-nutpie-user-callback
Open

saheli56 wants to merge 1 commit into
pymc-devs:mainfrom
saheli56:fix-nutpie-user-callback

Conversation

@saheli56

Copy link
Copy Markdown

Description

Resolves #8292.

Currently, passing callback to pm.sample with nuts_sampler=nutpie raises a ValueError. This PR lifts that restriction for nutpie by multiplexing the user callback alongside pb_manager.update via progress_callback.

Key points:

  • When nuts_sampler=nutpie, the user callback is invoked with list[nutpie.ChainProgress] tracking per-chain sampling progress.
  • Works consistently whether progressbar=True or progressbar=False.
  • Non-nutpie external samplers (numpyro, blackjax) continue raising ValueError.
  • Documented the callback parameter signature in pm.sample docstring.
  • Added unit and regression tests in tests/sampling/test_mcmc_external.py.

Related Issue

Closes #8292

Allow users to pass a custom callback to pm.sample when using nuts_sampler='nutpie'. The user callback is multiplexed with pb_manager.update and receives list[nutpie.ChainProgress] per update. Non-nutpie external samplers continue raising ValueError.
@welcome

welcome Bot commented Oct 13, 2026

Copy link
Copy Markdown

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 pymc | 🛠️ Build #35122604 | 📁 Comparing 76c8628 against latest (91e6da3)

  🔍 Preview build  

4 files changed
± glossary.html
± api/generated/pymc.sample.html
± _modules/pymc/sampling/mcmc.html
± _modules/pymc/dims/distributions/scalar.html

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Support user callback with nutpie sampler

1 participant