Simulators and datasets for simulation-based inference benchmarks in JAX/NumPyro
Project description
sbibm-jax
A JAX/NumPyro library including several SBI benchmarks. Includes a port of sbibm
Overview
sbibm-jax ports the Simulation-Based Inference Benchmark (sbibm) from PyTorch/Pyro to JAX, NumPyro, and diffrax. Each task defines a prior, a simulator, reference observations, and reference posterior samples for benchmarking SBI methods. Tasks can be used directly, or consumed as pre-generated / on-the-fly HuggingFace datasets. It is the benchmark companion to GenSBI.
Installation
Using uv (recommended):
uv add sbibm-jax
Or using pip:
pip install sbibm-jax
The default JAX dependency is the CUDA 12 build (jax[cuda12]) for GPU support; on a CPU-only machine install a CPU build of JAX instead.
Optional extras:
pip install sbibm-jax[hf] # build/export HuggingFace datasets
pip install sbibm-jax[loader] # consume datasets via grain: TaskDataset / OnlineTaskDataset
pip install sbibm-jax[pypesto] # the beer_molbiosystems PEtab task (compiles AMICI)
Usage
1. Benchmark tasks
Use a task's prior, simulator, and reference data directly:
import jax
from sbibm_jax import get_task, get_available_tasks
print(get_available_tasks()) # every task name
task = get_task("two_moons")
key = jax.random.PRNGKey(0)
theta = task.get_prior(key, num_samples=1000) # (1000, dim_theta)
simulator = task.get_simulator(key)
x = simulator(key, theta) # (1000, dim_x)
# Reference data for observation #1
x_o = task.get_observation(num_observation=1) # (1, dim_x)
theta_o = task.get_true_parameters(num_observation=1) # (1, dim_theta)
posterior = task.get_reference_posterior_samples(num_observation=1) # (N, dim_theta)
2. Offline datasets (pre-generated)
TaskDataset streams the pre-generated benchmark splits from the Hub with grain. Requires the [loader] extra. Loaders yield (theta, x) already tokenized to shape (batch, dim, 1):
from sbibm_jax.data import TaskDataset
ds = TaskDataset(
"two_moons",
normalize=True, # apply gen-time mean/std from metadata.json
)
train = ds.get_train_loader(batch_size=256) # infinite: shuffle -> repeat -> batch
theta, x = next(iter(train)) # theta: (256, dim_theta, 1), x: (256, dim_x, 1)
posterior = ds.get_reference(num_observation=1)
kind="joint" concatenates (theta, x) along the feature axis; get_val_loader / get_test_loader serve the validation and test splits.
3. Online datasets (simulate on the fly)
OnlineTaskDataset reads the same metadata.json (shapes + normalization stats) but draws fresh (theta, x) from the task's prior and simulator each batch — the splits are never downloaded. Finite-simulator, vector-theta tasks only:
from sbibm_jax.data import OnlineTaskDataset
ds = OnlineTaskDataset(
"two_moons",
repo="aurelio-amerio/SBI-benchmarks",
normalize=True,
)
loader = ds.get_online_train_loader(batch_size=256, seed=0, num_workers=4) # num_workers=0 disables prefetch workers
theta, x = next(iter(loader)) # a fresh draw every batch
Available tasks
Call get_available_tasks() for the full list — analytical, ODE, image, and time-series tasks. Each lives under src/sbibm_jax/tasks/<name>/.
License
MIT — see LICENSE. If you use sbibm-jax, please also consider citing the original sbibm benchmark.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sbibm_jax-0.1.1.tar.gz.
File metadata
- Download URL: sbibm_jax-0.1.1.tar.gz
- Upload date:
- Size: 17.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
473c13358c8e3308ee9f51edb57a960891c8c9909b3110a56e1f5b403dbad191
|
|
| MD5 |
8450633515162615b0b04b47522ec4f0
|
|
| BLAKE2b-256 |
f86e2464b7f85a46a653e44cd31cdf1cf5517d30e201151db9beab745b345a37
|
File details
Details for the file sbibm_jax-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sbibm_jax-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b590b09d1db193056835fbe46b64cd8821caba7ba5600be9e9eba8c7128813d0
|
|
| MD5 |
d6d4e48b16df47ba4d406f5d4e355bbb
|
|
| BLAKE2b-256 |
05df3ce42459a3af33bee87026d1f9d64f191be3724edee17083a3e432930ac6
|