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.

Both loaders read the production Hub repo (aurelio-amerio/SBI-benchmarks) by default. Pass repo="..." for any other repo, or export SBIBM_JAX_USE_TEST=1 to point the defaults at the staging repo (aurelio-amerio/SBI-benchmarks-test).

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",
    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.

Metadata

Release files for sbibm-jax 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sbibm-jax 0.1.5
File Size Uploaded Provenance Actions
sbibm_jax-0.1.5.tar.gz 28.8 MB Without provenance Details for sbibm_jax-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sbibm-jax 0.1.5
File Interpreter ABI Platform Actions
sbibm_jax-0.1.5-py3-none-any.whl Python 3 none any Details for sbibm_jax-0.1.5-py3-none-any.whl

Total release size: 57.6 MB

Release files / sbibm_jax-0.1.5.tar.gz

Download URL sbibm_jax-0.1.5.tar.gz
Size 28.8 MB
Tags Source
SHA-256 checksum
How to use checksums
b379f449d2fa5ea2f5071a5d806ec1b7eb4760f0337155e581d2512aca619fed
BLAKE2b-256 checksum
How to use checksums
916cd644bff57948e08c0ffcdaf2cd9b1f17a19aea60670e1d6b7e5e38def057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}

Release files / sbibm_jax-0.1.5-py3-none-any.whl

Download URL sbibm_jax-0.1.5-py3-none-any.whl
Size 28.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f2746acf8d1a0e70a4228231b5bf1b971fa5637697c7efb3fa15b7c77750b89f
BLAKE2b-256 checksum
How to use checksums
0a3fcc5d2aec63ca583b35693a334cfb5dc844ddf48fe9f48e0c30ed0c1b10e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}

Security for sbibm-jax 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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