Skip to main content

sbibm-jax

A JAX/NumPyro library including several SBI benchmarks. Includes a port of sbibm

Build Tests Coverage PyPI

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbibm_jax-0.1.3.tar.gz (28.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sbibm_jax-0.1.3-py3-none-any.whl (28.9 MB view details)

Uploaded Python 3

File details

Details for the file sbibm_jax-0.1.3.tar.gz.

File metadata

  • Download URL: sbibm_jax-0.1.3.tar.gz
  • Upload date:
  • Size: 28.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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

Hashes for sbibm_jax-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c3ee90675980ea3914a19f7ad4a9ef7aee6c4ced54c17b89b7dc29796f11c17d
MD5 99f16b8680e0a8fa036415e5a7134210
BLAKE2b-256 8c09fc37b0d9b57513cd596e8550c5362c2b4913d34a04d733d74e08ca5e0d27

See more details on using hashes here.

File details

Details for the file sbibm_jax-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sbibm_jax-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 28.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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

Hashes for sbibm_jax-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d75d736af3c00ec9c8f60f739861062bc36bcc2fd1064aed456e7cc2b27870f
MD5 c20adaa0db73abdfc2181c17d300de69
BLAKE2b-256 83eb3dd5c8ee5791fbc473c08fc43e81a843aa416ebf901165b64ea6a099ce08

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page