Skip to main content

nnbench: A small framework for benchmarking machine learning models

Welcome to nnbench, a framework for benchmarking machine learning models. The main goals of this project are

  1. To provide a portable, easy-to-use solution for model evaluation that leads to better ML experiment organization, and
  2. To integrate with experiment and metadata tracking solutions for easy adoption.

On a high level, you can think of nnbench as "pytest for ML models" - you define benchmarks similarly to test cases, collect them, and selectively run them based on model type, markers, and environment info.

What's new is that upon completion, you can stream the resulting data to any sink of your choice (including multiple at the same), which allows easy integration with experiment trackers and metadata stores.

See the quickstart for a lightning-quick demo, or the examples for more advanced usages.

Installation

⚠️ nnbench is an experimental project - expect bugs and sharp edges.

Install it directly from source, for example either using pip or uv:

pip install nnbench
# or
uv add nnbench

A ⚡️- quick demo

To understand how nnbench works, you can run the following in your Python interpreter:

# example.py
import nnbench
from nnbench.reporter import ConsoleReporter


@nnbench.benchmark
def product(a: int, b: int) -> int:
    return a * b


@nnbench.benchmark
def power(a: int, b: int) -> int:
    return a ** b


reporter = ConsoleReporter()
# first, collect the above benchmarks directly from the current module...
benchmarks = nnbench.collect("__main__")
# ... then run the benchmarks with the parameters `a=2, b=10`...
result = nnbench.run(benchmarks, params={"a": 2, "b": 10})
reporter.write(result)  # ...and print the results to the terminal.

# results in a table look like the following:
# ┏━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
# ┃ Benchmark ┃ Value ┃ Wall time (ns) ┃ Parameters        ┃
# ┡━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
# │ product   │ 20    │ 1917           │ {'a': 2, 'b': 10} │
# │ power     │ 1024  │ 583            │ {'a': 2, 'b': 10} │
# └───────────┴───────┴────────────────┴───────────────────┘

Watch the following video for a high level overview of the capabilities and inner workings of nnbench.

nnbench overview video thumbnail

For a more realistic example of how to evaluate a trained model with a benchmark suite, check the Quickstart. For even more advanced usages of the library, you can check out the Examples in the documentation.

Contributing

We encourage and welcome contributions from the community to enhance the project. Please check discussions or raise an issue on GitHub for any problems you encounter with the library.

For information on the general development workflow, see the contribution guide.

License

The nnbench library is distributed under the Apache-2 license.

Metadata

Release files for nnbench 0.5.0

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

Source distribution (sdist)

Source distribution for nnbench 0.5.0
File Size Uploaded
nnbench-0.5.0.tar.gz 37.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nnbench 0.5.0
File Interpreter ABI Platform
nnbench-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 76.2 kB

Release files / nnbench-0.5.0.tar.gz

Download URL nnbench-0.5.0.tar.gz
Size 37.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5ede180dea2694d3ff58db01c29c86e8795a30af92fddcb96526f9f1bc9f54ff
BLAKE2b-256 checksum
How to use checksums
0b6fbb3fbb988b3f578107764406a71e6c84944603378e2365f85634738023b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 6, 2025.

Transparency log

Release files / nnbench-0.5.0-py3-none-any.whl

Download URL nnbench-0.5.0-py3-none-any.whl
Size 38.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c80984e1bd4cec6d3d8b81aaf9e1dcd7e6b1b175528ab6be050f42b60b9ea83
BLAKE2b-256 checksum
How to use checksums
d2c036db3a576b56c0e947f67208fd0892adae7afb97e0a467dbda6fd8b89b35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 6, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release 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