microsoft / microsoft/onnxruntime

Detailed Inference Statistics Output for onnxruntime_perf_test

Open
#17,313 3 comments 1 reaction 0 assignees View on GitHub
ep:TensorRT feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

## Motivation
I'm interested in evaluating the performance improvement offered by TensorRT in comparison to ONNX Runtime on my specific device. I aim to compare their raw computation capabilities without factoring in the data transfers (D2H/H2D) between the host and the device.

The documentation does not provide clarity on the type of latency that `onnxruntime_perf_test` calculates.
For instance, the output of the tool might resemble the following:
```
Total time cost: 58.8053
Total iterations: 1000
Average time cost: 58.8053 ms
Total run time: 58.8102 s
Min Latency is 0.0559777 sec
Max Latency is 0.0623472 sec
P50 Latency is 0.0587108 sec
P90 Latency is 0.0599845 sec
P95 Latency is 0.0605676 sec
P99 Latency is 0.0619517 sec
P999 Latency is 0.0623472 sec
```

In contrast, the `trtexec` tool provides a more detailed performance summary, including latency, enqueue time, and GPU compute time.
`trtexec` output example:
```
[08/21/2023-14:59:38] [I] === Performance summary ===
[08/21/2023-14:59:38] [I] Throughput: 3716.81 qps
[08/21/2023-14:59:38] [I] Latency: min = 0.17041 ms, max = 0.243042 ms, mean = 0.184305 ms, median = 0.179932 ms, percentile(90%) = 0.194153 ms, percentile(95%) = 0.195312 ms, percentile(99%) = 0.197144 ms
[08/21/2023-14:59:38] [I] Enqueue Time: min = 0.00512695 ms, max = 0.0793457 ms, mean = 0.0145594 ms, median = 0.0107422 ms, percentile(90%) = 0.0219727 ms, percentile(95%) = 0.0222168 ms, percentile(99%) = 0.0236816 ms
[08/21/2023-14:59:38] [I] H2D Latency: min = 0 ms, max = 0 ms, mean = 0 ms, median = 0 ms, percentile(90%) = 0 ms, percentile(95%) = 0 ms, percentile(99%) = 0 ms
[08/21/2023-14:59:38] [I] GPU Compute Time: min = 0.17041 ms, max = 0.243042 ms, mean = 0.184305 ms, median = 0.179932 ms, percentile(90%) = 0.194153 ms, percentile(95%) = 0.195312 ms, percentile(99%) = 0.197144 ms
[08/21/2023-14:59:38] [I] D2H Latency: min = 0 ms, max = 0 ms, mean = 0 ms, median = 0 ms, percentile(90%) = 0 ms, percentile(95%) = 0 ms, percentile(99%) = 0 ms
[08/21/2023-14:59:38] [I] Total Host Walltime: 3.00043 s
[08/21/2023-14:59:38] [I] Total GPU Compute Time: 2.05537 s
[08/21/2023-14:59:38] [I] Explanations of the performance metrics are printed in the verbose logs.
[08/21/2023-14:59:38] [V]
[08/21/2023-14:59:38] [V] === Explanations of the performance metrics ===
[08/21/2023-14:59:38] [V] Total Host Walltime: the host walltime from when the first query (after warmups) is enqueued to when the last query is completed.
[08/21/2023-14:59:38] [V] GPU Compute Time: the GPU latency to execute the kernels for a query.
[08/21/2023-14:59:38] [V] Total GPU Compute Time: the summation of the GPU Compute Time of all the queries. If this is significantly shorter than Total Host Walltime, the GPU may be under-utilized because of host-side overheads or data transfers.
[08/21/2023-14:59:38] [V] Throughput: the observed throughput computed by dividing the number of queries by the Total Host Walltime. If this is significantly lower than the reciprocal of GPU Compute Time, the GPU may be under-utilized because of host-side overheads or data transfers.
[08/21/2023-14:59:38] [V] Enqueue Time: the host latency to enqueue a query. If this is longer than GPU Compute Time, the GPU may be under-utilized.
[08/21/2023-14:59:38] [V] H2D Latency: the latency for host-to-device data transfers for input tensors of a single query.
[08/21/2023-14:59:38] [V] D2H Latency: the latency for device-to-host data transfers for output tensors of a single query.
[08/21/2023-14:59:38] [V] Latency: the summation of H2D Latency, GPU Compute Time, and D2H Latency. This is the latency to infer a single query.
```

## Feature Request:

I would like to request a more detailed statistics output `onnxruntime_perf_test`, similar to what is available in the `trtexec`. This enhanced output would assist users in accurately comparing the performance of different inference runtimes, e.g. TensorRT vs ONNX Runtime.

I propose the inclusion of inference metrics such as:

- Minimum, maximum, and mean latency values.
- Median latency value.
- Latency percentiles, including the 90th, 95th, and 99th percentiles.
- Enqueue time statistics.
- GPU compute time statistics.
- Host-to-device (H2D) latency statistics.
- Device-to-host (D2H) latency statistics.
- Total host walltime and total GPU compute time.

Thanks

Contributor guide

Open the contributing guide

Research direction

Start with the onnxruntime_perf_test entry point and review how its current latency statistics are collected and printed. Compare the requested categories with the trtexec performance summary in this issue. Done means the tool reports the requested latency, enqueue, transfer, GPU compute, walltime, and percentile statistics with clear metric definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.