skillfed

nutpie

Sample Stan or PyMC models

nutpie v0.16.11 305.0K downloads/30d#7,800 on PyPI205
Permissive license MIT Active released

What it is and what it does

nutpie is a Bayesian sampling library that wraps nuts-rs, a Rust implementation of the No-U-Turn Sampler algorithm. It compiles probabilistic models and samples from their posterior distributions, returning results as ArviZ InferenceData objects compatible with standard Bayesian workflows. The package targets users who want faster sampling, particularly for hierarchical and complex models where gradient evaluation is a bottleneck.

The library integrates with existing model ecosystems, accepting model definitions in native syntax and producing compatible output. It supports both blocking and non-blocking sampling modes, allowing interactive control (pause, resume, abort) over long-running inference tasks. Dependencies include data handling (pandas, pyarrow, xarray), statistical output (arviz), and storage (zarr, obstore), reflecting its role as a sampler within existing Bayesian analysis pipelines.

Use it for:

  • Accelerate sampling for hierarchical models by replacing default samplers without rewriting model code.
  • Sample large models where gradient evaluation dominates runtime, using Rust backend for speed.
  • Interactively monitor and control long-running Bayesian inference via pause/resume without blocking.
  • Combine with arviz for post-sampling diagnostics and visualization of posterior traces.
  • Prototype models, then accelerate sampling without changing model definitions.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

nutpie provides a fast NUTS sampler for Bayesian inference on PyMC and Stan models, using a Rust-based implementation.

Yes, if you use Bayesian modeling and want faster sampling with minimal code changes. The package is actively maintained with recent releases, has no known vulnerabilities, and offers pre-built wheels for modern Python versions. Install friction is moderate due to Rust compilation on source builds, but pre-built wheels mitigate this for standard platforms. The MIT license poses no restrictions. Verify that sampling efficiency gains apply to your specific models before adopting as a primary sampler.

Install

nutpie on PyPI

pip

pip install nutpie

uv

uv add nutpie

poetry

poetry add nutpie

Installing nutpie

Before you install

Medium install friction due to Rust compilation requirement. Pre-built wheels available for Python 3.12–3.14 across macOS, Linux, and Windows reduce friction for standard platforms. Eight runtime dependencies add some complexity but are widely used data and statistical libraries.

License in practice

MIT license is permissive and imposes no significant restrictions on use, modification, or redistribution in commercial or private projects.

Quickstart

pip install nutpie

import nutpie

# After defining a model:
compiled_model = nutpie.compile_pymc_model(pymc_model)
trace = nutpie.sample(compiled_model)

Requires Python ≥3.12. For source builds, a Rust compiler and maturin are needed. Stan support requires bridgestan and a C++ compiler.

Verify before relying

  • Whether the claimed higher effective sample size per gradient evaluation is validated in peer-reviewed benchmarks.
  • Performance characteristics and convergence speed relative to standard samplers in real-world hierarchical models.
  • Whether the SIMD support feature provides measurable speedup and which models benefit most.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.12)
Install friction medium — platform-specific wheel
Runtime dependencies 8 — pyarrow, arro3-core, pandas, platformdirs, xarray, arviz, obstore, zarr
Maintenance actively maintained — 45 days since the last release
Last repo commit
First released
Downloads 305,005/month — #7,800 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: nutpie-0.16.11-cp312-cp312-macosx_10_12_x86_64.whl; nutpie-0.16.11-cp312-cp312-macosx_11_0_arm64.whl; nutpie-0.16.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; nutpie-0.16.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; nutpie-0.16.11-cp312-cp312-win_amd64.whl; nutpie-0.16.11-cp313-cp313-macosx_10_12_x86_64.whl; nutpie-0.16.11-cp313-cp313-macosx_11_0_arm64.whl; nutpie-0.16.11-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; nutpie-0.16.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; nutpie-0.16.11-cp313-cp313-win_amd64.whl; nutpie-0.16.11-cp314-cp314-macosx_10_12_x86_64.whl; nutpie-0.16.11-cp314-cp314-macosx_11_0_arm64.whl; nutpie-0.16.11-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; nutpie-0.16.11-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; nutpie-0.16.11-cp314-cp314-win_amd64.whl

Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: Rust

Tags

bayesian sampling nutsposterior sampling mcmcstan inference samplernuts algorithm implementationbayesian model samplinghierarchical model inferencegradient-based sampling
bayesian-inferencemcmc-samplingrust-accelerated

More Scientific/Engineering packages