Library / SDK
pyro-ppl/pyro avatar
pyro-ppl/pyro

Pyro: a universal PPL on top of PyTorch

Deep universal probabilistic programming with Python and PyTorch

9,055 stars1,021 forksPythonApache-2.0

At a glance

What is it?
Pyro is a probabilistic programming library that treats any PyTorch computation as a probability distribution. It is best suited to teams that already have PyTorch in production and need custom inference, and least suited to anyone who wants a fixed set of prebuilt models.
Who is it for?
Adopt Pyro if your team already writes PyTorch and your model needs inference code you control, such as custom guides or amortized encoders. Do not adopt it if you want a fixed catalogue of prebuilt models or a sampler that runs without any variational code you write yourself.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 9 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The gap Pyro fills between a neural network library and a statistics package

A PyTorch user who wants a posterior distribution has two bad options. Hand-write the inference math, which means deriving gradients through a sampler and keeping that derivation correct as the model changes. Or leave PyTorch entirely and rewrite the model in a language with a fixed inference engine. Pyro occupies the space between those two. Its stated design goal is to represent any computable probability distribution, and the README describes it as built on PyTorch with a small core of composable abstractions. The audience is therefore narrow but specific: researchers and engineers who already think in PyTorch tensors and nn.Module, and who need a posterior over parameters rather than a point estimate. Someone who wants to fit a standard regression and read off coefficients does not need this. Someone who has a PyTorch model with latent variables and wants variational inference without writing the estimator by hand is the intended user.

How a Pyro model becomes a differentiable objective

The README states the flexibility principle directly: automation when you want it, control when you need it, through high-level abstractions for generative and inference models plus expert access to customize inference. The mechanism that makes this work is that Pyro primitives are ordinary Python functions that run inside a PyTorch trace. A model is Python code with sample statements in it. An inference algorithm is also Python code, a guide, that proposes values for those sample statements. Because both sides are PyTorch, the whole thing is differentiable end to end, and the evidence lower bound becomes a loss you optimize with a standard PyTorch optimizer. That is the architectural bet: no separate model compiler, no declarative graph format, no domain-specific syntax. The cost of that bet is visible in the same sentence. Automation is the default, but the moment your model needs a nonstandard posterior, the documentation expects you to write the guide yourself. Pyro gives you the vocabulary and the gradient plumbing, not the answer.

Installing Pyro and the version pinning that catches people out

The stable path is one command: pip install pyro-ppl. Source installs clone the repository and check out master, which the README says is pinned to the latest release, then run pip install . from the repository root. The dev branch is a different install, via pip install git+https://github.com/pyro-ppl/pyro.git, and that is where recent features live. The trap is the extras group. The examples and tutorials in the repository depend on packages beyond Pyro itself, and the README installs them with pip install pyro-ppl[extras]. It then adds a warning that models must come from the same release version of the Pyro source as the installed package. That matters because the extras pin a broader dependency set, and mixing a pip-installed pyro-ppl with a git checkout of the examples is the usual way to get an import error that looks like a Pyro bug and is not. There is also a Docker path, with instructions in docker/README.md, for anyone who would rather not resolve this by hand.

Where Pyro stops being the right tool

Pyro is not a modelling language with a sampler attached. If your model fits a standard form, a tool that writes the inference for you will get you to a posterior with far less code, because you never touch a guide. With Pyro, a wrong or too-flexible guide produces a biased posterior that still converges to a plausible-looking loss curve, and nothing in the library will tell you which happened. That is the real failure mode: silent approximation error, not a crash. The second constraint is the PyTorch dependency. Pyro inherits PyTorch's release cadence and its device story, so a team on a locked-down framework version may find the pinned dependencies in a given Pyro release disagree with what they already ship. The third is scale. The README claims Pyro scales to large data sets with little overhead compared to hand-written code, which is a fair claim for minibatch training, but the comparison is against hand-written code, not against a compiled sampler. Anyone expecting a general-purpose MCMC engine that handles a thousand-dimensional posterior without tuning is reading the wrong project.

Pyro against Stan, and why the difference is the guide

Stan is the obvious alternative for a Bayesian modeller and the contrast is instructive. In Stan you declare parameters, a model block, and a likelihood, and the toolchain compiles that to C++ and runs a tuned Hamiltonian Monte Carlo sampler or a variational approximation. You do not write inference code. In Pyro you write the model and, for anything beyond the built-in paths, you also write the guide. That is more work and more room for error, and it buys two things Stan does not offer in the same package: amortized inference, where a neural network learns to map data to posterior parameters so you can do fast inference on new observations, and gradients that flow into arbitrary PyTorch components, so a probabilistic layer can sit inside a larger network and train jointly. The README's own framing supports this reading. Pyro is described as universal, meaning it can represent any computable distribution, and that universality is exactly what forces the user to supply more of the inference design. Stan trades expressiveness for a safer default. Pyro trades the safe default for reach.

Maintenance, releases and the Apache-2.0 terms

The release history shows 1.9.1 in June 2024, 1.9.0 in February 2024, and 1.8.6 in July 2023, with the default branch named dev and a last push in September 2026. That cadence suggests a project that ships deliberately rather than continuously, so pinning a version and reading the release notes before upgrading is the sensible default. The README also documents that Pyro became a Linux Foundation project in 2019 and is maintained by community contributors including a team at the Broad Institute, following its origin at Uber AI. That governance structure matters for anyone evaluating long-term support, because it means no single vendor controls the roadmap. The licence is Apache-2.0, a permissive licence that permits commercial and closed-source use and includes an explicit patent grant. It does not impose copyleft obligations on your model code. This is a description of the licence text, not legal advice; if your organisation has specific patent or attribution requirements, have counsel read the LICENSE file in the repository rather than relying on the summary here.

Editorial conclusion

Adopt Pyro if your team already writes PyTorch and your model needs inference code you control, such as custom guides or amortized encoders. Do not adopt it if you want a fixed catalogue of prebuilt models or a sampler that runs without any variational code you write yourself. Before committing, install pyro-ppl, run one of the examples from the docs, and check that your PyTorch version satisfies the pinned dependency in the release you install.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. pyro-ppl/pyro on GitHub
  4. README
  5. Releases
Community notes

Community notes