BUG: `pm.sample(nuts_sampler="blackjax")` fails during warmup with every blackjax >= 1.6
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9.8k
- Forks
- 2.3k
- Avg merge
- 21h 39m
- Merged PRs (30d)
- 5
Description
Describe the issue:
pm.sample(nuts_sampler="blackjax") fails during warmup with every blackjax >= 1.6, in all configurations, on all pymc versions (verified on 5.27.1 and 6.1.0).
Root cause: blackjax 1.6 removed the progress_bar parameter from blackjax.window_adaptation (progress bars moved to a context manager, with blackjax.progress_bar(): warmup.run(...)), and window_adaptation now forwards unknown **extra_parameters into the NUTS kernel. pymc unconditionally injects progress_bar into the sampler kwargs (nuts_kwargs["progress_bar"] = progressbar, pymc/sampling/jax.py:359 in 6.1.0) and _blackjax_inference_loop only pops it after blackjax.window_adaptation(**adaptation_kwargs) has already been called (pymc/sampling/jax.py:277 vs the window_adaptation call above it). The stale kwarg therefore reaches the blackjax NUTS kernel and raises during the first adaptation step.
A fix would be to pop progress_bar from adaptation_kwargs before calling window_adaptation and, for blackjax >= 1.6, use the new context-manager API (or drop the flag).
Reproduceable code example:
# pip install "pymc==6.1.0" "blackjax==1.6" (also fails with pymc 5.27.1 + blackjax 1.6)
import numpy as np
import pymc as pm
with pm.Model():
x = pm.Normal("x", 0.0, 1.0)
pm.Normal("obs", x, 1.0, observed=np.array([0.3, -0.1, 0.5]))
idata = pm.sample(
draws=50, tune=50, chains=1,
nuts_sampler="blackjax",
progressbar=False,
)
Error message:
TypeError: build_kernel.<locals>.kernel() got an unexpected keyword argument 'progress_bar'
(raised from `blackjax/adaptation/window_adaptation.py` during `adapt.run`, wrapped by JAX tracing frames)
PyMC version information:
pymc 5.27.1 and 6.1.0, blackjax 1.6, jax 0.10.x, Python 3.12, macOS (arm64) and Linux. Works with blackjax <= 1.5 (whose window_adaptation still accepted progress_bar).
Context for the issue:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pymc/sampling/jax.py, especially _blackjax_inference_loop and the nuts_kwargs construction around the lines mentioned in the report. Reproduce the example with blackjax 1.6, then verify that blackjax-based sampling completes during warmup with progressbar disabled and that compatibility with blackjax 1.5 is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100