Skip to main content

onnx_benchy

onnx_benchy measures how fast an ONNX text-embedding model runs

onnx_benchy model.onnx --tokenizer BAAI/bge-small-en-v1.5
onnx_benchy model.onnx --tokenizer ./my-tokenizer/ --cuda --cpu \
  --batch-size 16 --context-size 512 --tokens 500000 --minutes 2

onnx_benchy run

Install

pip install onnx-benchy            # CPU build
pip install "onnx-benchy[cuda]"    # GPU build, in a separate venv

From source, for development:

git clone https://github.com/electroglyph/onnx_benchy
cd onnx_benchy
pip install -e .          # CPU build
pip install -e ".[cuda]"  # GPU build, in a separate venv

Options

Model and tokenizer

  • model — path to the .onnx file.
  • --tokenizer (required) — local directory or Hugging Face id, e.g. ./tok/ or BAAI/bge-small-en-v1.5. An ONNX file doesn't include a tokenizer, so there is no default here.
  • --config-dir — directory with modules.json and *Pooling/config.json, used to detect pooling and normalization settings. Default: the folder the model file is in.
  • --list-outputs — print the model's output names, shapes, and dtypes, then exit. Handy for figuring out what --output should point at.

Backends

One flag per backend: --cpu, --cuda, --tensorrt, --rocm, --migraphx, --openvino, --coreml, --directml, --qnn.

  • If you pass none of them, every supported backend available on the machine is benchmarked.

Batch shape

  • --batch-size (default 16) — sequences per inference request. Latency is reported per document (batch time divided by batch size), so it's comparable across batch sizes.
  • --context-size (default 512, also spelled --seq-len or --max-length) — tokens per sequence. Long documents are split, short ones padded. If it's larger than the tokenizer's own limit, it's clamped down with a warning.
  • --output (default auto) — which model output to embed. auto prefers sentence_embedding, then last_hidden_state, then token_embeddings, then the first output. You can also pass an index (--output 1) or an exact name.
  • --pooling (default auto) — cls, mean, max, lasttoken (last works too), or none.
  • --normalize (default auto) — true or false, whether to L2-normalize the embeddings. auto turns it on when the config has a Normalize module, off otherwise.
  • --warmup-batches (default 2) — untimed batches run before measuring.

How long to run

  • --tokens — stop after this many input tokens.
  • --minutes — stop after this many minutes, warmup and tokenization aren't included.

Whichever limit hits first stops the run, and it's checked after every batch.

Data and misc

  • --data (default data/fineweb-10mb.txt) — text file to benchmark on.
  • --seed (default 23) — bleh.
  • --no-shuffle — keep the file's line order instead.
  • --no-pack — by default, all text is concatenated and sliced into full context-size blocks, so every batch is dense and the tok/s numbers are honest. --no-pack goes back to one document per sequence with truncate-and-pad, which keeps document boundaries intact at the cost of some padding.
  • --offline — self-explanatory.
  • --trust-remote-code — pass trust_remote_code=True when loading the tokenizer. Off by default; only enable it for tokenizers you trust.
  • --output-format (default table) — table, json, or csv.
  • --output-file — also write the report to this file.
  • --no-progress — hide the progress bars. -q/--quiet does the same but also quiets per-batch chatter; the config block, results, and version line always print either way. -v/--verbose adds extra detail.

Results

  • Mean latency (per doc) — average time per document/sequence: each timed batch's inference time divided by --batch-size, then averaged over batches. The ± is the standard error of the mean (std / sqrt(n)); std, 95% CI, and p50/p95 are in json (sem/std columns in csv).
  • Mean ingest — tokens/sec, averaged over batches from non-pad tokens (attention-mask sum) only, ± SEM as above.
  • Batches / Tokens / Elapsed — totals for the timed loop (warmup excluded; batch assembly and epoch wrap-around reprep run untimed, so only inference + pooling/norm is timed).

With default packing, a "document" is one dense context-size chunk sliced from the concatenated corpus; with --no-pack it's one source line per sequence (truncate-and-pad).

Benchmark text

data/fineweb-10mb.txt is ~10 MB of data taken from HuggingFaceFW/fineweb, config sample-10BT (license: ODC-By). To regenerate it:

python scripts/fetch_fineweb.py

Provenance (source revision, sizes, hash) lives in data/fineweb-10mb.meta.json.

Metadata

Release files for onnx-benchy 0.3.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 onnx-benchy 0.3.0
File Size Uploaded Provenance Actions
onnx_benchy-0.3.0.tar.gz 4.3 MB With provenance Details for onnx_benchy-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for onnx-benchy 0.3.0
File Interpreter ABI Platform Actions
onnx_benchy-0.3.0-py3-none-any.whl Python 3 none any Details for onnx_benchy-0.3.0-py3-none-any.whl

Total release size: 4.4 MB

Release files / onnx_benchy-0.3.0.tar.gz

Download URL onnx_benchy-0.3.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
ffa445c391958709b98867290b3b829a2bd60d8daa92b5ddcf2ce47825ff6492
BLAKE2b-256 checksum
How to use checksums
6af022394a2a3417b8a02545c7b12dd1d248baf24df823efd3a81e1406cf3274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / onnx_benchy-0.3.0-py3-none-any.whl

Download URL onnx_benchy-0.3.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0be4e01952b24d70ad63f6492b3b2b964444e5ac3944686095de174899f9711
BLAKE2b-256 checksum
How to use checksums
17af5219ad56e1fef6ae826f95db541d5edeefdfb99ab55a9a22ed148774aafd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Security for onnx-benchy 0.3.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for onnx_benchy-0.3.0.tar.gz

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 Sep 7, 2026.

Transparency log

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