Skip to content

Use nutpie by default#8111

Closed
Jayant-kernel wants to merge 11 commits intopymc-devs:v6from
Jayant-kernel:feature/nutpie-default-8079
Closed

Use nutpie by default#8111
Jayant-kernel wants to merge 11 commits intopymc-devs:v6from
Jayant-kernel:feature/nutpie-default-8079

Conversation

@Jayant-kernel
Copy link
Copy Markdown

@Jayant-kernel Jayant-kernel commented Feb 18, 2026

Closes 8079

@welcome
Copy link
Copy Markdown

welcome Bot commented Feb 18, 2026

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.

@Jayant-kernel
Copy link
Copy Markdown
Author

Jayant-kernel commented Feb 18, 2026

@ricardoV94
I've opened a draft PR for this here:

It implements the auto-selection logic:
if nutpie is installed and the model is suitable (all continuous variables), it will be used by default when nuts_sampler=None. It falls back to pymc
otherwise.

Let me know what you think!

Comment thread pymc/sampling/mcmc.py Outdated
except ImportError:
MemoryStore = type("MemoryStore", (), {})

def _nutpie_is_installed() -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nutpie will be a default dependency once we do these changes, no need to check if it's installed

Comment thread pymc/sampling/mcmc.py Outdated
if (
exclusive_nuts
and _nutpie_is_installed()
and (compile_kwargs is None or not compile_kwargs)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

compile kwargs is not enough to rule out nutpie. Only if it implies a pytensor compilation mode that is not numba or jax backend. Something like nutpie_compatibile_mode = isinstance(get_mode(compile_kwargs.get("mode")).linker, JAXLinker| NumbaLinker)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We also need to propagate this information into the backend kwarg for nutpie

Comment thread tests/sampling/test_nutpie_selection.py Outdated
@@ -0,0 +1,91 @@
# Copyright 2024 - present The PyMC Developers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no reason for a new test file, it should be in test_mcmc, or whatever file tests sample functionality now

@Jayant-kernel Jayant-kernel force-pushed the feature/nutpie-default-8079 branch from 2b5f03f to e566bf7 Compare February 18, 2026 14:14
@Jayant-kernel
Copy link
Copy Markdown
Author

@ricardoV94 T
hanks again for the patience and the detailed review! I've now addressed all the feedback and fixed the CI issues:

  1. Removed _nutpie_is_installed()nutpie is now treated as a default dependency.
  2. Proper Linker Detection — Implemented the check using isinstance(get_mode(...).linker, JAXLinker | NumbaLinker) (using union syntax to satisfy Ruff UP038).
  3. Backend Propagation — Added logic to set backend="jax" or backend="numba" for nutpie based on the PyTensor linker.
  4. Moved Tests — Deleted test_nutpie_selection.py and moved all tests into tests/sampling/test_mcmc.py.
  5. Fixed Pre-commit — Fixed all trailing whitespace, import sorting, and Ruff formatting issues (v0.11.13).

All CI checks (Docs, Pre-commit, etc.) are now passing (green). Ready for re-review!

@twiecki
Copy link
Copy Markdown
Member

twiecki commented Mar 22, 2026

@ricardoV94 wdyt, would be nice to get this default on the v6 branch.

@twiecki twiecki changed the base branch from main to v6 March 22, 2026 23:37
@ricardoV94 ricardoV94 changed the title Implement nutpie auto-selection logic (#8079) Use nutpie by default Apr 12, 2026
@ricardoV94
Copy link
Copy Markdown
Member

Closing in favor of #8248

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.

3 participants