Skip to content

Make nutpie the default nuts sampler (if installed)#8248

Draft
ricardoV94 wants to merge 13 commits intopymc-devs:v6from
ricardoV94:nutpie_default
Draft

Make nutpie the default nuts sampler (if installed)#8248
ricardoV94 wants to merge 13 commits intopymc-devs:v6from
ricardoV94:nutpie_default

Conversation

@ricardoV94
Copy link
Copy Markdown
Member

@ricardoV94 ricardoV94 commented Apr 12, 2026

Also adds a pip install pymc[nutpie]

Closes #8079
Closes #8111
Closes #8250

First need to update nutpie to use modern pytensor imports, and more importantly arviz 1.0: pymc-devs/nutpie#297

This will create a bit of a tricky pymc-nutpie circular optional dependency. We have to make sure neither breaks the other before we release. There's also a soft warning machinery now to ask users to update, before we totally remove support for old nutpie functionality/API

@ricardoV94 ricardoV94 changed the title Make nutpies the default nuts sample Make nutpie the default nuts sample Apr 12, 2026
@ricardoV94 ricardoV94 added this to the v6 milestone Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 90.34483% with 14 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v6@d77d6c3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pymc/sampling/mcmc.py 82.35% 12 Missing ⚠️
pymc/backends/arviz.py 90.47% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##             v6    #8248   +/-   ##
=====================================
  Coverage      ?   89.88%           
=====================================
  Files         ?      124           
  Lines         ?    20064           
  Branches      ?        0           
=====================================
  Hits          ?    18035           
  Misses        ?     2029           
  Partials      ?        0           
Files with missing lines Coverage Δ
pymc/model/core.py 93.29% <100.00%> (ø)
pymc/progress_bar/__init__.py 100.00% <ø> (ø)
pymc/progress_bar/progress.py 94.21% <100.00%> (ø)
pymc/pytensorf.py 88.40% <100.00%> (ø)
pymc/sampling/deterministic.py 95.83% <100.00%> (ø)
pymc/sampling/forward.py 96.75% <100.00%> (ø)
pymc/sampling/jax.py 93.85% <ø> (ø)
pymc/sampling/parallel.py 62.81% <100.00%> (ø)
pymc/smc/sampling.py 96.55% <100.00%> (ø)
pymc/stats/log_density.py 97.61% <100.00%> (ø)
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pymc/sampling/mcmc.py Outdated
@ricardoV94 ricardoV94 changed the title Make nutpie the default nuts sample Make nutpie the default nuts sampler Apr 15, 2026
@ricardoV94 ricardoV94 force-pushed the nutpie_default branch 2 times, most recently from f4179b5 to 19542dd Compare April 15, 2026 10:23
@github-actions github-actions Bot added the bug label Apr 16, 2026
@ricardoV94 ricardoV94 force-pushed the nutpie_default branch 4 times, most recently from 3f0ee4d to e70fd2d Compare April 23, 2026 13:56
@ricardoV94 ricardoV94 changed the title Make nutpie the default nuts sampler Make nutpie the default nuts sampler (if installed) Apr 23, 2026
@ricardoV94 ricardoV94 force-pushed the nutpie_default branch 2 times, most recently from 6b9025d to ba423ad Compare April 23, 2026 17:09
@ricardoV94
Copy link
Copy Markdown
Member Author

testing wise nutpie pins zarr >= 3.0, but pymc zarr use is only compat with < 3.0

@ricardoV94 ricardoV94 force-pushed the nutpie_default branch 5 times, most recently from 7a54dc4 to 54d5e6a Compare April 23, 2026 22:08
The "A list or tuple of random_seed no longer specifies the specific
random_seed of each chain" `UserWarning` was added in Dec 2024 to flag
the behavior change during the deprecation window. By now the current
behavior (list/tuple treated as an entropy source by
`np.random.default_rng`) is well-established, so the warning adds
noise without value. `get_random_generator(...).spawn(chains)` keeps
consuming multi-seed lists as entropy.
Emit a `FutureWarning` when the caller opts out of `InferenceData`. The
long-term plan is to only return `InferenceData`. Existing tests that
exercise the deprecated MultiTrace path now assert the warning via
`pytest.warns(FutureWarning, match="return_inferencedata=False")`.

nutpie can't produce a `MultiTrace`, so the auto-selection gate (in
`Default to nutpie`) already routes `return_inferencedata=False` to the
pymc sampler.
Also deprecate nuts_sampler_kwargs in favor of the existing per-step
`nuts={...}` kwarg
JAX is not fork-safe and can deadlock under multiprocessing's fork start
method. When a JAX backend is detected and the user has not specified an
`mp_ctx`, fall back to `forkserver` (or `spawn`). Warn instead of switch
if the user explicitly asked for fork.

Applies to both `pm.sample` and `pm.sample_smc`.
Needed until conda-forge ships a nutpie release that supports arviz>=1.0.
Until then the conda env can't co-install nutpie and pymc's arviz pin,
so we get nutpie via pip-from-git-main in every CI job. Once a compatible
nutpie is on conda-forge, drop this commit and put `nutpie>=<that version>`
back into `environment-test.yml` and `windows-environment-test.yml`.
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.

BUG: pm.sample ignores discard_tuned_samples if using nuts_sampler="nutpie" Use nutpie by default (*conditions apply)

2 participants