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
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.onnxfile.--tokenizer(required) — local directory or Hugging Face id, e.g../tok/orBAAI/bge-small-en-v1.5. An ONNX file doesn't include a tokenizer, so there is no default here.--config-dir— directory withmodules.jsonand*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--outputshould 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(default16) — sequences per inference request. Latency is reported per document (batch time divided by batch size), so it's comparable across batch sizes.--context-size(default512, also spelled--seq-lenor--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(defaultauto) — which model output to embed.autopreferssentence_embedding, thenlast_hidden_state, thentoken_embeddings, then the first output. You can also pass an index (--output 1) or an exact name.--pooling(defaultauto) —cls,mean,max,lasttoken(lastworks too), ornone.--normalize(defaultauto) —trueorfalse, whether to L2-normalize the embeddings.autoturns it on when the config has a Normalize module, off otherwise.--warmup-batches(default2) — 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(defaultdata/fineweb-10mb.txt) — text file to benchmark on.--seed(default23) — bleh.--no-shuffle— keep the file's line order instead.--no-pack— by default, all text is concatenated and sliced into fullcontext-sizeblocks, so every batch is dense and the tok/s numbers are honest.--no-packgoes 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— passtrust_remote_code=Truewhen loading the tokenizer. Off by default; only enable it for tokenizers you trust.--output-format(defaulttable) —table,json, orcsv.--output-file— also write the report to this file.--no-progress— hide the progress bars.-q/--quietdoes the same but also quiets per-batch chatter; the config block, results, and version line always print either way.-v/--verboseadds extra detail.
Results
Mean latency (per doc)— average time per document/sequence: each timed batch's wall time divided by--batch-size, then averaged over batches (std, andp50/p95injson, come from the same per-doc samples).Mean ingest— tokens/sec, averaged over batches from non-pad tokens (attention-mask sum) only.Batches/Tokens/Elapsed— totals for the timed loop (warmup and tokenization excluded).
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onnx_benchy-0.2.0.tar.gz.
File metadata
- Download URL: onnx_benchy-0.2.0.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e79971fe911d8078a5a31f472a790bf9b28f32ba63b0e409e023b5ea2fe4acf7
|
|
| MD5 |
9f7da14d15f376aaa20ab5a14a13ddf4
|
|
| BLAKE2b-256 |
6532bbd774b7f976c010ca21e74769502cfd4a47cba8f77095ef608b14ec431e
|
Provenance
The following attestation bundles were made for onnx_benchy-0.2.0.tar.gz:
Publisher:
publish.yml on electroglyph/onnx_benchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onnx_benchy-0.2.0.tar.gz -
Subject digest:
e79971fe911d8078a5a31f472a790bf9b28f32ba63b0e409e023b5ea2fe4acf7 - Sigstore transparency entry: 2742982989
- Sigstore integration time:
-
Permalink:
electroglyph/onnx_benchy@cfc70086230d10776f6f8dd37ed9e77c123022f2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/electroglyph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cfc70086230d10776f6f8dd37ed9e77c123022f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file onnx_benchy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: onnx_benchy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0d57735eabeafae4ca8d8f2e0ce179ed075938b8449ca255345d1e2100d806a
|
|
| MD5 |
a212fb6c82a8ae42024e9274a15d08d2
|
|
| BLAKE2b-256 |
7827e8ad2e54f0678e5971f39aa5412734b6ea74ccba794d1600aeb14108e48f
|
Provenance
The following attestation bundles were made for onnx_benchy-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on electroglyph/onnx_benchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onnx_benchy-0.2.0-py3-none-any.whl -
Subject digest:
c0d57735eabeafae4ca8d8f2e0ce179ed075938b8449ca255345d1e2100d806a - Sigstore transparency entry: 2742982992
- Sigstore integration time:
-
Permalink:
electroglyph/onnx_benchy@cfc70086230d10776f6f8dd37ed9e77c123022f2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/electroglyph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cfc70086230d10776f6f8dd37ed9e77c123022f2 -
Trigger Event:
push
-
Statement type: