How fast is setu, and on what#
setu is JAX-native: a learned likelihood and its gradient compile into one fused kernel with no per-call dispatch overhead. This page measures what that buys, and where it stops mattering. Every number comes from one benchmark task and is scoped to it.
Note
These benchmarks are run on a single 3D linear-Gaussian model with three free parameters and a Gaussian likelihood with known shift and covariance. The task is deliberately left simple so the exact posterior is available in closed form and a fast posterior can be checked for correctness. Throughout, the NLE we used here is a masked autoregressive flow (three transforms, width-64 hidden layers). CPU results are from an Apple M3 Pro, GPU results from a Tesla V100. A different task, model size, or device would move these curves; this is not a general performance claim.
The comparison is against sbi, the reference
PyTorch package for simulation-based inference: two setu paths
(setu + NumPyro, setu + PyMC/BlackJAX) against two sbi paths (sbi + Pyro,
sbi + PyMC), with the exact likelihood as the reference floor.
Per-evaluation: one log-likelihood and its gradient#
A single MCMC step needs one log-likelihood and its gradient. This times that call (100 repetitions) as the number of observations grows; both axes are logarithmic, and lower is faster.
At 10 observations setu costs about 0.1 ms against sbi’s 0.55 ms. The gap closes
as the count grows: by 1000 observations setu + NumPyro and sbi + Pyro
nearly coincide, and setu + PyMC/BlackJAX is slower than sbi at the largest
sizes. The end-to-end runs show the same shape.
End-to-end: a full MCMC run#
What a user actually waits for is a full posterior. This times a complete run (500 tuning steps, 500 draws, two chains), taking the median wall-clock over ten repetitions.
The picture matches the per-call one: at 10 observations setu + NumPyro takes
2.5 s against sbi + PyMC at 6.1 s (2.4x), narrowing to 13.6 s against 15.6 s
(1.15x) at 1000. The advantage is real at the small-to-medium scales most
hierarchical models occupy and shrinks toward parity as the problem grows.
setu + PyMC/BlackJAX turns slower than both sbi paths beyond a few hundred
observations, so setu + NumPyro is the path to cite.
Fast is only useful if it is also correct#
Speed is worthless if the posterior is wrong. Because this task has a closed-form posterior, each run is scored with C2ST: a classifier trained to separate sampled draws from exact posterior draws, where 0.5 means indistinguishable and higher means the sampler has drifted.
At small counts every sampler is indistinguishable from exact (near 0.5). The score rises with observations for all of them: as more data sharpens the posterior, the estimator’s finite fidelity shows against an ever-tighter target. This is a property of the learned likelihood, not the sampler. setu stays at least as close to exact as sbi throughout, and closer at the large end (about 0.78 against 0.94 at 1000). The speed comparison is therefore between posteriors of equal or better quality, not a speed-for-accuracy trade.
Why the gap narrows on CPU but holds on the GPU#
One mechanism explains every curve above. A log-likelihood call is fixed overhead plus arithmetic. At small observation counts overhead dominates: Python dispatch, framework bookkeeping, and the boundary crossing into the numerical backend on every step. JAX pays that overhead once by compiling the whole call into a single fused kernel, so setu wins widest exactly where overhead is the entire cost. At large counts the flow’s forward and backward arithmetic dominates instead, and that arithmetic is identical in both frameworks, so the fixed-overhead saving shrinks as a share of the total and the CPU curves converge.
On a GPU the same mechanism widens the gap rather than closing it. The plot
tracks how many times faster setu + NumPyro is than sbi + Pyro per call, on
each device.
On CPU the speedup falls from about 5x to parity as observations grow. On the
GPU it stays near 10x and does not narrow, because sbi’s PyTorch path launches
thirty to fifty separate kernels per step and pays launch latency on each, while
setu compiles the whole computation into one XLA program. The catch is that this
model is far too small to need a GPU: a 30k-parameter flow on 3D data is trivial
arithmetic, so both frameworks are actually slower on the GPU than on the CPU in
absolute terms, and the workload never grows large enough to make the GPU the
bottleneck. The GPU result is therefore an argument about architecture, not a
reason to reach for one here. The GPU runs also sweep parallel versus
sequential chains and hierarchical scales, produced by the code in the
repository’s benchmarks/.
Why there is no sbi-plus-BlackJAX comparison#
A fair like-for-like would also run sbi through BlackJAX, JAX’s NUTS sampler. It cannot be done: sbi wraps its estimator in PyTensor operators backed by PyTorch, and BlackJAX requires every operator in the graph to be JAX-traceable, which a PyTorch-backed operator is not. This is structural, not a missing feature. setu is JAX-native, so exporting a learned likelihood into a fully JAX-compiled sampler is the default path, and the benchmark compares setu’s JAX paths against the JAX paths sbi can actually reach.
Scope and caveats#
One task. A 3D linear-Gaussian model. A higher parameter dimension, a larger flow, or a genuinely intractable simulator would each move the curves; they do not generalize on their own.
setu + NumPyrois the fast path.setu + PyMC/BlackJAXis convenient for staying inside PyMC but is not the one to cite for speed at scale.The learned likelihood has finite fidelity. The C2ST rise is a real limit of neural likelihood estimation, and the reason setu treats validation as a required step, not an afterthought.
The benchmark code and configurations that produced these numbers are in the
repository’s benchmarks/.
Where to go next#
Why validate a learned likelihood covers the calibration checks between a trained estimator and a trusted posterior. Why hierarchical inference is powerful shows where the small-to-medium scales setu favors arise. The shape conventions reference covers the hierarchical layouts the full benchmark also measures.