> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ovalbee.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ovalbee.com/_mcp/server.

# Benchmark runtime

> Measure the latency and throughput (FPS) of a model's exported formats (ONNX Runtime, TensorRT, and PyTorch for YOLO) on the current GPU and produce a comparison report. Give it an images dataset and every format is timed end to end per image, with preprocess, model and postprocess (decode and NMS) reported separately; without one it times the forward pass on random input. Provide the trained model and the node finds its exports automatically.

Runs on: gpu  Dockerfile

> **Note**
>
> First run can take longer while the worker pulls the configured Docker image.

## Overview

Measures how fast a trained model runs once it is exported, and compares the formats side by side. Give it a dataset of images and it times the whole pipeline per image - preprocess, model, postprocess (decode and NMS) - and reports the three stages separately, so you can see what share of the latency NMS takes. Without a dataset it times the forward pass alone on random input.

Point the node at the model, not at an export. It finds the exports that were created from that model, times each one on the GPU it is running on, and writes a report with latency, throughput, and the speedup between formats. The badge shows the throughput of the fastest format.

```mermaid
flowchart LR
  n1["Export model"] --> n2["Benchmark runtime"] --> n3["Report"]
```

## Prerequisites

| Requirement                    | What you need                                                                                                                                         |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| **GPU worker**                 | A worker with an NVIDIA GPU. The node refuses to measure on CPU, because CPU numbers would not describe the deployment target.                        |
| **ONNX export**                | An existing ONNX export of the model, from an Export to ONNX node. It is both a benchmarked format and the source the TensorRT engine is built from.  |
| **TensorRT export (optional)** | Needed only to include TensorRT in the comparison. Without it the report covers ONNX Runtime alone.                                                   |
| **Images dataset (optional)**  | Needed for end-to-end timing. Pick images like the ones the model will see in use: the cost of NMS depends on how many boxes the model finds in them. |

## How it works

Finds the export assets that were created from the model, one per format.

Builds a fresh TensorRT engine from the ONNX export when a TensorRT export exists, so the engine matches the TensorRT version on this worker.

Downloads the sample of images and decodes it once, before any timing.

Times each format, at batch size 1 unless you set another. On images, each batch goes through preprocess, model and postprocess in turn, each stage timed on its own with the GPU synchronized; on random input only the forward pass is timed, over the measured iterations.

Writes the comparison report, records the fastest throughput on the badge, and stores the numbers on the model asset.

## FAQ

#### Why did the run fail saying no export was found?

The model has no ONNX or TensorRT export yet. Run an Export node on it first, then benchmark.

#### Why does a TensorRT export alone not work?

A serialized TensorRT engine only loads on the exact TensorRT version that built it, and every export node builds with its own version. The benchmark rebuilds the engine from the ONNX export instead, so a model with a TensorRT export but no ONNX export fails with a message asking for the ONNX one.

#### Do the numbers include image loading, preprocessing and NMS?

With an images dataset, yes except for reading and decoding the files, which happens once before timing. Preprocess is the resize or letterbox, scaling and layout of a decoded image into the model's input tensor (float16 for FP16 ONNX files). Model is the host-to-device copy, the forward pass and the copy of the outputs back. Postprocess is the confidence filter, plus decode and NMS when the graph has no NMS inside. Preprocess and postprocess run on the CPU in this node, so they measure that path and not a GPU-side one. Without a dataset only the forward pass is timed, on random input.

#### Why does the confidence threshold matter?

NMS cost grows with the number of boxes that clear the threshold. At 0.001, the value accuracy evaluation uses, thousands of weak boxes reach NMS; at 0.25 far fewer do. The report shows the mean number of boxes over the threshold and left after NMS next to each format. A graph exported with NMS inside applied the threshold it was exported with, and a DETR-style model (DEIM, EdgeCrafter) has no NMS at all.

#### Which models are read how?

A graph with a single output of shape batch by 4+classes by anchors is read as a raw YOLO head (decode, then class-aware NMS). A single output of shape batch by boxes by 6 is read as NMS already done; when the export recorded an nms flag on the file, that flag decides. The LibreYOLO export also records how its graph is read, and the node follows it: boxes as corners rather than centre and size, the image letterboxed to the top-left corner rather than centred, every class over the threshold as a candidate, the rows output of a graph with NMS inside (which also returns the raw head), and for LibreYOLO9E2E no NMS at all, only the top-scoring anchors over the threshold. Outputs named labels, boxes and scores are read as a DETR-style head, and the image is fed together with its original size. Other output layouts are timed without a postprocess stage.

#### Can I compare results measured on different machines?

Not directly. Latency and throughput depend on the GPU, the driver, and the library versions, all of which the report records for exactly this reason. Compare formats within one report, and rerun on the target hardware before trusting a cross-machine comparison.

#### When do I need to set Input Size?

Only when an export has dynamic spatial dimensions and the shape cannot be read from the model. Otherwise the shape comes from each exported model, which keeps the comparison honest across formats.

#### Where does the precision in the report come from?

From what the export node recorded when it built the file. When nothing was recorded, the runner reports the precision it detects from the model input and output types.

#### Is there a PyTorch baseline?

For YOLO models, on an images dataset, when the worker image has Ultralytics installed and the model has a PyTorch export (switch on the PyTorch format in the YOLO export node): that checkpoint is run through its own predict path in FP32 and its preprocess, inference and postprocess times are taken from the framework. For other frameworks, or without a dataset, there is no PyTorch row. With the instance's safe-weights setting on, a PyTorch export is a pickle and is not opened, so there is no PyTorch row either; the ONNX and TensorRT rows still run. Speedups in the report are relative to the slowest benchmarked format.

#### Why does an FP16 ONNX file show a slower preprocess?

An FP16 ONNX graph takes float16 input, so the image tensor is converted to half precision on the CPU. That conversion is part of what a deployment of that file pays, and the preprocess stage shows it.

#### Why do repeated runs give slightly different numbers?

GPU clocks, thermal state, and other load on the card all move the result. Raise **Measured Iterations** for a steadier mean, and keep the card otherwise idle while benchmarking.

## Inputs

**`Model`** `model` — required

Trained model to benchmark. Its ONNX and TensorRT exports are found automatically, so run an Export node on the model first. Key: `MODEL`.

---

**`Images`** `dataset`

Dataset whose images the formats are timed on, end to end per image - preprocess, model and postprocess (decode and NMS where the graph has none inside) are reported separately, as p50, p95 and mean. NMS time depends on how many boxes clear the confidence threshold, which only real images reproduce. Leave empty to time the forward pass alone on random input, as earlier versions did. Key: `IMAGES`.

---

**`Number of images`** `integer` — required, default: 100

How many images to take from the dataset, spread evenly over it. Each is downloaded and decoded once before timing starts, one timed pass runs over all of them. Ignored without an images dataset. Minimum: `1`. Key: `IMAGES_COUNT`.

---

**`Batch size`** `integer` — required, default: 1

Images per inference call. 1 measures single-image latency, the deployment case of a camera or an API, a larger batch measures throughput. Latency is reported per image either way. A model exported with a fixed batch is timed at that batch. Minimum: `1`. Key: `BATCH_SIZE`.

---

**`Confidence threshold`** `number` — required, default: 0.001

Boxes scoring below this are dropped in postprocess, and for a raw YOLO head it decides how many boxes reach NMS. 0.001 is what accuracy evaluation uses (it makes NMS the most expensive), 0.25 is the Ultralytics predict default. A graph exported with NMS inside already applied the threshold it was exported with, so a lower value here has no effect on it. Ignored without an images dataset. Minimum: `0`. Maximum: `1`. Step: `0.001`. Key: `CONF_THRESHOLD`.

---

**`NMS IoU`** `number` — required, default: 0.7

Overlap above which NMS suppresses a box, for a raw YOLO head. 0.7 is the Ultralytics default. DETR-style graphs (DEIM, EdgeCrafter) have no NMS and ignore it. Minimum: `0`. Maximum: `1`. Step: `0.01`. Key: `NMS_IOU`.

---

**`Also run ONNX Runtime on CPU`** `boolean` — required, default: false

Add a row for the ONNX export on the CPU provider, to see what a deployment without a GPU would get. The GPU formats are always measured. Key: `ONNX_CPU`.

---

**`Input size`** `integer`

Square input size in pixels, needed only for models with dynamic input dimensions. Leave empty to take the size from each export, a dynamic export falls back to 640 on an images dataset and to 224 on random input. Minimum: `1`. Key: `INPUT_SIZE`.

---

**`Warmup iterations`** `integer` — required, default: 50

Number of warmup inferences (discarded) run before timing, to let the GPU reach steady state. Minimum: `0`. Key: `WARMUP_ITERS`.

---

**`Measured iterations`** `integer` — required, default: 500

Number of timed inferences used to compute mean / p95 latency and FPS. Minimum: `1`. Key: `MEASURE_ITERS`.

---

## Outputs

**`Report`** `report`

Asset ID containing the runtime benchmark report. Shown as an artifact. Key: `REPORT_ID`.

---

**`FPS`** `string`

Throughput of the fastest benchmarked format, shown as a badge on the node. Shown on the node as a badge. Key: `FPS`.

---

## Models and configuration

Exports are found through the link an Export node writes back to the model it converted, so you never select an export by hand. One export per format is benchmarked: ONNX Runtime on the GPU (and on the CPU when **Also run ONNX Runtime on CPU** is ticked), TensorRT, and a PyTorch baseline for YOLO.

The input shape is read from each exported model, which keeps every format on the same input. **Warmup iterations** are discarded so the GPU reaches steady state before timing starts. On random input, **Measured iterations** are the timed passes behind the mean and p95 latency; on an images dataset, one pass over the **Number of images** is timed and **Measured iterations** is not used. **Batch size** defaults to 1 and a model exported with a fixed batch is timed at that batch.

When the run finishes, the latency (mean, p50, p95), throughput, batch size, precision, GPU model and driver of each format are recorded on the model version in the registry, next to the scores its training reported; on images the per-stage milliseconds and the mean box counts are added. That makes speed a property of the model you can compare on later, not just a number in one report. Re-benchmarking a format replaces its numbers: they describe the GPU and the settings of that run.

## Report

The report is attached to the node as an artifact and opens in the preview widget.

**Overview** carries four cards: the model and the formats that were benchmarked, the auto-detected hardware, the benchmark settings, and a plain-language result naming the fastest format with its latency and throughput.

**Pipeline stages** (images dataset only) lists, for every format, the p50 and p95 of preprocess, model and postprocess in milliseconds per image, the end-to-end mean, the share of it spent in postprocess, and the mean number of boxes over the confidence threshold and left after NMS.

**Runtime Comparison** is the part to read first. A table lists every format with its precision, mean and p95 latency, throughput, and speedup relative to the slowest benchmarked format, followed by a throughput bar chart. A scope note below the chart states what was covered, and points out the missing format when only one export was available.

**Methodology** records the environment (torch, ONNX Runtime, TensorRT, CUDA, and driver versions, plus the measurement timestamp) and explains how timing was done. Keep it in mind when comparing two reports: different versions mean different numbers.

## Runtime

The node runs in its own container on a GPU worker and drives ONNX Runtime through the CUDA execution provider. If that provider fails to load, the run stops rather than silently falling back to CPU; the CPU row is a separate, explicit option.

Building the TensorRT engine happens inside the run and dominates the total time for larger models, so a benchmark that includes TensorRT takes considerably longer than an ONNX-only one.

The image carries TensorRT, NVIDIA software under [NVIDIA's license](https://docs.nvidia.com/deeplearning/tensorrt/latest/reference/sla.html).

## JSON config

Machine-readable node interface for automation and advanced usage.

#### Show JSON

```json
{
  "name": "Benchmark runtime",
  "description": "Measure the latency and throughput (FPS) of a model's exported formats (ONNX Runtime, TensorRT, and PyTorch for YOLO) on the current GPU and produce a comparison report. Give it an images dataset and every format is timed end to end per image, with preprocess, model and postprocess (decode and NMS) reported separately; without one it times the forward pass on random input. Provide the trained model and the node finds its exports automatically.",
  "category": "Evaluate",
  "namespace": "ovalbee",
  "templateKey": "evaluate/benchmark_runtime",
  "version": "v1",
  "inputs": [
    {
      "key": "MODEL",
      "label": "Model",
      "type": "model",
      "description": "Trained model to benchmark. Its ONNX and TensorRT exports are found automatically, so run an Export node on the model first.",
      "required": true,
      "default": null,
      "visibleWhen": null,
      "options": {
        "scope": "my"
      }
    },
    {
      "key": "IMAGES",
      "label": "Images",
      "type": "dataset",
      "description": "Dataset whose images the formats are timed on, end to end per image - preprocess, model and postprocess (decode and NMS where the graph has none inside) are reported separately, as p50, p95 and mean. NMS time depends on how many boxes clear the confidence threshold, which only real images reproduce. Leave empty to time the forward pass alone on random input, as earlier versions did.",
      "required": false,
      "default": null,
      "visibleWhen": null,
      "options": {
        "creatable": false
      }
    },
    {
      "key": "IMAGES_COUNT",
      "label": "Number of images",
      "type": "number",
      "description": "How many images to take from the dataset, spread evenly over it. Each is downloaded and decoded once before timing starts; one timed pass runs over all of them. Ignored without an images dataset.",
      "required": true,
      "default": 100,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1
      }
    },
    {
      "key": "BATCH_SIZE",
      "label": "Batch size",
      "type": "number",
      "description": "Images per inference call. 1 measures single-image latency, the deployment case of a camera or an API; a larger batch measures throughput. Latency is reported per image either way. A model exported with a fixed batch is timed at that batch.",
      "required": true,
      "default": 1,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1
      }
    },
    {
      "key": "CONF_THRESHOLD",
      "label": "Confidence threshold",
      "type": "number",
      "description": "Boxes scoring below this are dropped in postprocess, and for a raw YOLO head it decides how many boxes reach NMS. 0.001 is what accuracy evaluation uses (it makes NMS the most expensive); 0.25 is the Ultralytics predict default. A graph exported with NMS inside already applied the threshold it was exported with, so a lower value here has no effect on it. Ignored without an images dataset.",
      "required": true,
      "default": 0.001,
      "visibleWhen": null,
      "options": {
        "type": "float",
        "min": 0,
        "max": 1,
        "step": 0.001
      }
    },
    {
      "key": "NMS_IOU",
      "label": "NMS IoU",
      "type": "number",
      "description": "Overlap above which NMS suppresses a box, for a raw YOLO head. 0.7 is the Ultralytics default. DETR-style graphs (DEIM, EdgeCrafter) have no NMS and ignore it.",
      "required": true,
      "default": 0.7,
      "visibleWhen": null,
      "options": {
        "type": "float",
        "min": 0,
        "max": 1,
        "step": 0.01
      }
    },
    {
      "key": "ONNX_CPU",
      "label": "Also run ONNX Runtime on CPU",
      "type": "boolean",
      "description": "Add a row for the ONNX export on the CPU provider, to see what a deployment without a GPU would get. The GPU formats are always measured.",
      "required": true,
      "default": false,
      "visibleWhen": null
    },
    {
      "key": "INPUT_SIZE",
      "label": "Input size",
      "type": "number",
      "description": "Square input size in pixels, needed only for models with dynamic input dimensions. Leave empty to take the size from each export; a dynamic export falls back to 640 on an images dataset and to 224 on random input.",
      "required": false,
      "default": null,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1
      }
    },
    {
      "key": "WARMUP_ITERS",
      "label": "Warmup iterations",
      "type": "number",
      "description": "Number of warmup inferences (discarded) run before timing, to let the GPU reach steady state.",
      "required": true,
      "default": 50,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 0
      }
    },
    {
      "key": "MEASURE_ITERS",
      "label": "Measured iterations",
      "type": "number",
      "description": "Number of timed inferences used to compute mean / p95 latency and FPS.",
      "required": true,
      "default": 500,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1
      }
    }
  ],
  "outputs": [
    {
      "key": "REPORT_ID",
      "label": "Report",
      "type": "report",
      "description": "Asset ID containing the runtime benchmark report.",
      "artifact": true,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "FPS",
      "label": "FPS",
      "type": "string",
      "description": "Throughput of the fastest benchmarked format, shown as a badge on the node.",
      "artifact": false,
      "badge": true,
      "badgeOpens": null,
      "hidden": false
    }
  ],
  "runtime": {
    "type": "docker",
    "devices": [
      "gpu"
    ],
    "dockerImage": "ovalbee/node-runtime-benchmark:0.0.29"
  },
  "widgets": {
    "widget": {
      "id": "report-preview",
      "settings": {
        "reportAsset": {
          "type": "variable",
          "value": "self.outputs.REPORT_ID"
        },
        "name": {
          "type": "input",
          "value": "Open benchmark"
        }
      }
    }
  }
}
```

## References

#### Sources and related pages

* [Export](/node-library/nodes/models-yolo-export-yolo) produces the ONNX and TensorRT files this node benchmarks for YOLO models.
* [ONNX Runtime CUDA execution provider](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html) documents the provider used to run the ONNX export.
* [NVIDIA TensorRT documentation](https://docs.nvidia.com/deeplearning/tensorrt/latest/index.html) covers engine building and the version compatibility rule behind the ONNX requirement.