onnx_benchy
onnx_benchy measures how fast an ONNX text-embedding model runs. You give it
a .onnx file and a tokenizer, it feeds the model real text in batches and
reports per-batch latency and tokens-per-second for each ONNX Runtime backend
on your machine (CPU, CUDA, TensorRT, and the rest).
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 -e . # CPU build
pip install -e ".[cuda]" # GPU build, in a separate venv
The CPU and GPU variants both import as onnxruntime, so they can't live in
the same environment. If you want to benchmark both, use two venvs. The tool
itself doesn't care which one is installed; it just uses whatever providers
onnxruntime.get_available_providers() reports.
Options
Model and tokenizer
model— path to the.onnxfile. Loaded in place; the file is never copied or moved. If the export uses external data,model.onnx_datahas to sit next to it or loading fails.--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. Anything else the ONNX Runtime build reports (Azure and other edge/preview providers) is skipped.
- If you pass one or more, only those run. A requested backend that isn't available is skipped with a warning; if none remain, the run exits with an error.
--allspells out the default "run everything" behavior.--list-backendsprints available providers and exits.
Each backend gets its own session with a single provider, so the timings belong to that backend alone. At startup the tool logs what the session actually runs on, since a provider being installed doesn't always mean the model executed on it.
Batch shape
--batch-size(default16) — sequences per inference request.--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. Withauto, an already-pooled (rank 2) output meansnone; otherwise the tool reads the Sentence-Transformers pooling config, falling back tomeanwith a warning if there isn't one. An explicit flag always wins.--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, to get past GPU init and memory allocation. Not counted in the results.
How long to run
--tokens— stop after this many input tokens. Only non-padding tokens count.--minutes— stop after this many minutes of timed benchmarking per backend. Warmup and tokenization aren't included.
Whichever limit hits first stops the run, and it's checked after every batch.
If you pass neither, both default on (100000 tokens, 2.0 minutes), so a
bare command always finishes on its own. Pass one and the other is unlimited.
Data and misc
--data(defaultdata/fineweb-10mb.txt) — text file to benchmark on, one document per line. A ~10 MB FineWeb sample ships with the repo; point this anywhere else for custom text. If the run needs more tokens than the file holds, it wraps around and keeps going.--seed(default23) — fixes the corpus order: the shuffle is deterministic, so every run with the same seed processes documents in the exact same order. Change the seed to get a different (but equally reproducible) order.--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— never touch the network. The tokenizer must be local or already cached, otherwise the run fails fast instead of downloading.--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.
Every report starts by echoing the effective configuration (including what
the auto settings resolved to and where from) and ends with a
benchmark by onnx_benchy version X.Y.Z line.
What the numbers mean
- Mean latency — average time per batch, plus/minus the standard deviation across batches. Shown in milliseconds, or seconds when the average passes 1000 ms.
- Mean ingest — average tokens per second, again mean ± std over batches, counting only non-padding tokens. Tokenization happens up front and isn't timed, so this is the rate at which the model itself (plus pooling and normalization) consumes tokens.
- The JSON output also includes the overall
total_tokens / elapsedrate and p50/p95 latency as a cross-check.
Benchmark text
data/fineweb-10mb.txt is ~10 MB of real web text (one document per line)
taken from HuggingFaceFW/fineweb, config sample-10BT (license: ODC-By).
To regenerate it you need network access:
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.1.0.tar.gz.
File metadata
- Download URL: onnx_benchy-0.1.0.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46cd487b2d3d2b29e46f82a58d5cccba0ba571e52a368bcf0aea0e9dcb5bd615
|
|
| MD5 |
bbe2754fa2b6cff81647f7df54561a45
|
|
| BLAKE2b-256 |
da583c11aa4823e407505dfdf4b13a714519bae65d7904b376049d6e7ff10655
|
File details
Details for the file onnx_benchy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: onnx_benchy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
137d12241d7d0866f9f106755718e3309fba7def76dd62cb05b783c9e409f22e
|
|
| MD5 |
357ab0bb5453ee8954feb4514b89cf02
|
|
| BLAKE2b-256 |
ac92b0224aa0afb35c18341c545407a5c8b39ae06e1503ebf4911df447fa6ea3
|