Skip to content

Feat: Unified Benchmarking Suite for SBI Solvers - #1756

Closed
Sumit6307 wants to merge 2 commits into
sbi-dev:mainfrom
Sumit6307:feat/benchmarking-suite
Closed

Sumit6307 wants to merge 2 commits into
sbi-dev:mainfrom
Sumit6307:feat/benchmarking-suite

Conversation

@Sumit6307

Copy link
Copy Markdown

Summary

This PR introduces a new top-level module, sbi.benchmark, designed to streamline the evaluation and comparison of simulation-based inference algorithms (NPE, FMPE, SNRE, etc.). It provides a standardized interface for defining tasks, running benchmarks, and visualizing performance metrics like C2ST.

Motivation

Currently, benchmarking different solvers in sbi requires writing custom loops to handle simulation, training, sampling, and metric computation. This leads to code duplication and inconsistent comparisons. This PR aims to:

  • Standardize Evaluation: Provide a single entry point to run multiple solvers on canonical tasks.
  • Improve Developer Experience: Allow researchers to easily benchmark new methods against existing baselines.
  • Enhance Reproducibility: Encapsulate task definitions (simulator + prior + ground truth).

Key Features

1. New Module: sbi.benchmark

  • BenchmarkTask (in tasks.py): Abstract base class for defining benchmark scenarios.
    • Implemented GaussianMixtureTask: A standard mixture-of-gaussians task with analytical ground truth sampling.
  • BenchmarkRunner (in runner.py): Orchestrates the benchmarking pipeline.
    • Accepts a list of tasks and a list of solvers (e.g., ["NPE", "FMPE"]).
    • Handles training, posterior sampling, and metric calculation automatically.
  • BenchmarkResult (in results.py):
    • Aggregates results into a Pandas DataFrame.
    • Provides plot_c2st() for immediate visualization of performance.

2. Integration

  • Utilizes existing metrics from sbi.utils.metrics (specifically c2st).
  • Compatible with existing sbi.inference solvers.

Example Usage

from sbi.benchmark import BenchmarkRunner, GaussianMixtureTask

# 1. Define Task
task = GaussianMixtureTask(seed=42)

# 2. Run Benchmark with multiple solvers
runner = BenchmarkRunner(
    tasks=[task],
    solvers=["NPE"],  # Can also include "FMPE" etc.
    num_simulations=1000,
    num_observation_samples=1000
)

# 3. Get results and plot
results = runner.run(num_epochs=10)
results.plot_c2st()
print(results.get_summary())

@Sumit6307

Copy link
Copy Markdown
Author

Hi @janfb , please have a look at this PR. Thanks!

@janfb

janfb commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Thank you @Sumit6307 for creating this PR. I appreciate your initiative! However, as noted clearly in our contribution guidelines we see it as best practice to first create an issue to discuss a potential new feature or bug fix, before opening a PR. The idea is to prevent extra work on our side in case we are already working on something, and also on the contributor side. For example, with this PR, while it looks good overall, there exists already a comprehensive SBI benchmark (https://github.com/sbi-benchmark/sbibm) and we also have a minimal version of the benchmark internally in sbi as CLI tool, mini-sbibm (also mentioned in our contribution guidelines).

Thus, I will close this PR as duplicate. If you want to contribute on the benchmarking side, there is also an open issue on mini-sbibm, see #1396.

Another note: looking at the changes introduced in this PR, I can see that the benchmarking interface looks very similar to sbibm and that some tasks, e.g., the two-moons, have many lines of commented out lines that look like a "thinking" output of an AI coding tool.

To be clear, I appreciate your intention to contribute to sbi, that's great! I would kindly ask you to have a look at the complete https://sbi.readthedocs.io/en/latest/contributing.html

@Sumit6307

Copy link
Copy Markdown
Author

Thank you @Sumit6307 for creating this PR. I appreciate your initiative! However, as noted clearly in our contribution guidelines we see it as best practice to first create an issue to discuss a potential new feature or bug fix, before opening a PR. The idea is to prevent extra work on our side in case we are already working on something, and also on the contributor side. For example, with this PR, while it looks good overall, there exists already a comprehensive SBI benchmark (https://github.com/sbi-benchmark/sbibm) and we also have a minimal version of the benchmark internally in sbi as CLI tool, mini-sbibm (also mentioned in our contribution guidelines).

Thus, I will close this PR as duplicate. If you want to contribute on the benchmarking side, there is also an open issue on mini-sbibm, see #1396.

Another note: looking at the changes introduced in this PR, I can see that the benchmarking interface looks very similar to sbibm and that some tasks, e.g., the two-moons, have many lines of commented out lines that look like a "thinking" output of an AI coding tool.

To be clear, I appreciate your intention to contribute to sbi, that's great! I would kindly ask you to have a look at the complete https://sbi.readthedocs.io/en/latest/contributing.html

@janfb
Thank you for the detailed feedback and for explaining this so clearly.

I apologize for not opening an issue first and for missing the existing work around sbibm and mini-sbibm. I understand now why discussing ideas beforehand is important and will make sure to follow the contribution guidelines going forward.

I appreciate you pointing me to issue #1396 — I’ll take a closer look at mini-sbibm and the open benchmarking-related issues and continue contributing there.

Thanks again for your time and for encouraging new contributors.

@janfb

janfb commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for understanding @Sumit6307 . I will close this PR and I am looking forward to your comments under #1396

@janfb janfb closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants