zuko
Normalizing flows in PyTorch
What it is and what it does
Zuko bridges a gap in PyTorch's probabilistic modeling: the built-in Distribution and Transform classes cannot be sent to GPU or treated as trainable modules. Zuko wraps these concepts in LazyDistribution and LazyTransform—modules whose forward pass returns a distribution or transformation—enabling conditional probability modeling and normalizing flows to work seamlessly within PyTorch's training pipeline.
The package provides a suite of flow architectures (NSF, RealNVP, MAF, NICE, and others) that can be instantiated with configurable hyperparameters and trained end-to-end. It also supports custom flows built from individual components like masked autoregressive transforms and rotation transforms, making it suitable for both standard use cases and research-driven extensions.
Use it for:
- Train a neural spline flow to model complex conditional distributions for density estimation or variational inference tasks.
- Build custom generative models by composing flow components like masked autoregressive transforms and base distributions.
- Implement probabilistic inference pipelines where conditional distributions must be parameterized by neural networks.
- Experiment with different normalizing flow architectures (RealNVP, MAF, NSF, etc.) for research or production density modeling.
- Sample from learned conditional distributions p(x|c) after training a flow on paired data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Zuko implements normalizing flows in PyTorch as trainable neural modules, enabling conditional probability distributions and transformations that can be sent to GPU and optimized with standard PyTorch workflows.
Yes. Zuko fills a genuine need in PyTorch's probabilistic modeling ecosystem—making normalizing flows trainable and GPU-compatible. It is actively maintained, has no known vulnerabilities, low install friction, and a permissive MIT license. Install it if you need conditional probability distributions or flow-based generative models in PyTorch.
Install
zuko on PyPI
pip
pip install zukouv
uv add zukopoetry
poetry add zukoInstalling zuko
Before you install
Low friction: pure Python wheel with only numpy and torch as runtime dependencies. Active maintenance with a release 157 days ago and ongoing repository activity.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects without warranty.
Quickstart
pip install zuko
import torch
import zuko
flow = zuko.flows.NSF(3, 5, transforms=3, hidden_features=[128] * 3)
optimizer = torch.optim.Adam(flow.parameters(), lr=1e-3)
for x, c in trainset:
loss = -flow(c).log_prob(x)
optimizer.zero_grad()
loss.backward()
optimizer.step()
Requires Python 3.10 or later and PyTorch installed.
Verify before relying
- Whether the package supports GPU acceleration beyond PyTorch's standard .to() mechanism.
- Performance characteristics and scalability limits for large-dimensional flows.
- Availability and completeness of tutorials for each flow type listed in the documentation.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, torch |
| Maintenance | actively maintained — 157 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 76,257/month — #14,640 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: zuko-1.6.0-py3-none-any.whl
Keywords: torch, normalizing flows, probability, distribution, generative, deep learning
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
pyro-pplPyro is a deep probabilistic programming…
permissive · top 5,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
pytorchcvProvides a collection of pretrained computer…
unclear · top 15,000 on PyPI
torchsdeSolves stochastic differential equations (SDEs)…
permissive · top 5,000 on PyPI
gpytorchGPyTorch is a PyTorch-based Gaussian process…
permissive · top 5,000 on PyPI
opacusOpacus enables training PyTorch models with…
permissive · top 15,000 on PyPI
pytorchThis package is a redirect or placeholder; the…
unclear · top 15,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
torch-optimizerProvides a collection of alternative…
permissive · top 15,000 on PyPI
pytorch_optimizerProvides a collection of modern optimizers,…
permissive · top 15,000 on PyPI