nutpie is a high-performance library designed for Bayesian inference, that provides efficient sampling algorithms for probabilistic models. It can sample models that are defined in PyMC or Stan (numpyro and custom hand-coded likelihoods with gradient are coming soon). It provides:
Faster sampling than either the PyMC or Stan default samplers. (An average ~2x speedup on posteriordb compared to Stan)
All the diagnostic information of PyMC and Stan and some more.
GPU support for PyMC models through jax.
A more informative progress bar.
Access to the incomplete trace during sampling.
Experimental normalizing flow adaptation for more efficient sampling of difficult posteriors.
Stan needs access to a compiler toolchain, for which you can find installation instructions here. You can then install nutpie through pip or uv:
# One ofpip install "nutpie[stan]"uv add "nutpie[stan]"
import nutpiemodel ="""data { int<lower=0> N; vector[N] y;}parameters { real mu;}model { mu ~ normal(0, 1); y ~ normal(mu, 1);}"""compiled = ( nutpie .compile_stan_model(code=model) .with_data(N=3, y=[1, 2, 3]))trace = nutpie.sample(compiled)
BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.7.0 to /home/runner/.bridgestan/bridgestan-2.7.0
Done!