Ultralytics YOLO INT8 engines larger than FP32: 23.76 MB zero-filled block in TensorRT 11.4 plan on RTX PRO 6000 Blackwell
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 12/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- ai, performance
調査の方向性
Start by running build_size.py after make_onnx.py to reproduce the 23.76 MB zero run in the INT8 plan. The issue reports that builder_optimization_level=0 removes it, so compare the plan layout across optimization levels. This is engine-internal work in TensorRT's builder, so a newcomer would need deep familiarity with the tactic and memory allocation code before any change.
索引モデルが issue の本文から書いたものです。
説明
Description
INT8 engines built from Ultralytics YOLO ONNX models quantized with ModelOpt (explicit Q/DQ) are larger than the FP32 engine of the same model: 29.6 MB vs 11.0 MB for YOLO26n. Almost all of the difference is one contiguous run of 23.76 MB of zero bytes inside the serialized plan. zlib compresses the INT8 plan to 2.6 MB.
The zero block is exactly 23.76 MB for both YOLO26n and YOLO11n, and appears with default builder settings on TensorRT 11.2.1.2 and 11.4.0.106:
| TensorRT | ONNX | Plan | zlib-compressed | Longest zero run |
|---|---|---|---|---|
| 11.4.0.106 | yolo26n.onnx (FP32) |
11.01 MB | 8.92 MB | 0 |
| 11.4.0.106 | yolo26n.int8.onnx (Q/DQ) |
29.58 MB | 2.58 MB | 23.76 MB |
| 11.2.1.2 | yolo26n.onnx (FP32) |
10.99 MB | 8.92 MB | 0 |
| 11.2.1.2 | yolo26n.int8.onnx (Q/DQ) |
29.60 MB | 2.63 MB | 23.76 MB |
What we checked:
builder_optimization_level=0builds a 9.8 MB INT8 plan without the zero block. Levels 1, 2, 3 (default) and 5 all give about 29.5 MB.max_aux_streams=0, ModelOptdisable_mha_qdq=True, and quantizing onlyConv(op_types_to_quantize=["Conv"]) leave the size unchanged.- In the Ultralytics export pipeline on TensorRT 11.2.1.2, the YOLO26n INT8 engine also reports
device_memory_size_v2of 41.2 MB, against 15.0 MB for the FP16 engine. - We see the same on DGX Spark (GB10): YOLO26n INT8 is 28.4 MB and FP16 is 6.7 MB on TensorRT 11.2.1.2. See the Ultralytics DGX Spark guide.
Ultralytics format="engine", quantize=8 exports quantize with ModelOpt and then build with TensorRT (modelopt_quantize_onnx). As a result, users get INT8 engines about 4x larger than FP16, which matters on storage-constrained edge devices.
Is this zero block expected, for example as space reserved for a particular tactic? Can it be avoided without dropping to optimization level 0?
Environment
TensorRT Version: 11.4.0.106 and 11.2.1.2 (tensorrt-cu13 pip wheels)
NVIDIA GPU: NVIDIA RTX PRO 6000 Blackwell Server Edition (also seen on DGX Spark GB10)
NVIDIA Driver Version: 595.99.02
CUDA Version: 13.2
CUDNN Version: N/A
Operating System: Ubuntu 24.04.5 LTS
Python Version (if applicable): 3.12.3
PyTorch Version (if applicable): 2.15.0 (CPU, used only for the ONNX export)
Other: ultralytics 8.4.196, nvidia-modelopt 0.47.0, onnx 1.21.0, ONNX opset 18
Baremetal or Container (if so, version): Baremetal
Relevant Files
Model link: yolo26n.pt. Both ONNX files are generated by step 1 below.
Steps To Reproduce
Commands or scripts:
pip install ultralytics==8.4.196 "nvidia-modelopt[onnx]==0.47.0" tensorrt-cu13==11.4.0.106
python make_onnx.py # step 1
python build_size.py # step 2
make_onnx.py:
# Step 1: export Ultralytics YOLO26n to ONNX (FP32) and quantize it to INT8 Q/DQ with ModelOpt
import numpy as np
from modelopt.onnx.quantization import quantize
from ultralytics import YOLO
YOLO("yolo26n.pt").export(format="onnx", imgsz=640) # -> yolo26n.onnx
quantize(
"yolo26n.onnx",
quantize_mode="int8",
calibration_data={"images": np.random.rand(8, 3, 640, 640).astype(np.float32)}, # random data, size is unaffected
calibration_method="max",
calibration_eps=["cpu"],
output_path="yolo26n.int8.onnx",
)
build_size.py:
# Step 2: build both ONNX files with default builder settings and inspect the serialized plans
import re
import zlib
import tensorrt as trt
logger = trt.Logger(trt.Logger.WARNING)
for onnx_file in ("yolo26n.onnx", "yolo26n.int8.onnx"):
builder = trt.Builder(logger)
network = builder.create_network(0)
config = builder.create_builder_config()
assert trt.OnnxParser(network, logger).parse_from_file(onnx_file)
plan = bytes(builder.build_serialized_network(network, config))
zero_run = max((m.end() - m.start() for m in re.finditer(rb"\x00{4096,}", plan)), default=0)
print(
f"TensorRT {trt.__version__} {onnx_file}: plan {len(plan) / 1e6:.2f} MB, "
f"zlib-compressed {len(zlib.compress(plan)) / 1e6:.2f} MB, longest zero run {zero_run / 1e6:.2f} MB"
)
Output:
TensorRT 11.4.0.106 yolo26n.onnx: plan 11.01 MB, zlib-compressed 8.92 MB, longest zero run 0.00 MB
TensorRT 11.4.0.106 yolo26n.int8.onnx: plan 29.58 MB, zlib-compressed 2.58 MB, longest zero run 23.76 MB
Have you tried the latest release?: Yes, 11.4.0.106.
Can this model run on other frameworks?: Yes. Both ONNX files run in ONNX Runtime and produce the expected (1, 84, 8400) output. The INT8 engine builds and runs normally; only its size is affected.
- 主要言語
- C++
- スター
- 13.5k
- フォーク
- 2.4k
- 平均マージ
- 6日 21時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/TensorRT のほかの issue
-
Module:Polygraphy
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 6 日以内に返信
-
Polygraphy NumPy Top-K sorts unsigned and minimum signed integers incorrectly対応中かも @0z5a が 16 日前に担当しました。 オープンModule:Polygraphy
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信
-
Polygraphy INT32 comparison can overflow and falsely pass at zero tolerance対応中かも @0z5a が 16 日前に担当しました。 オープンModule:Polygraphy
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信
-
onnx-graphsurgeon: Graph.toposort() hits RecursionError when a graph has a local function and an If/Loop node対応中かも @gabortar が 39 日前に担当しました。 オープンModule:GraphSurgeon
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 6 日以内に返信
-
Polygraphy parse_meta accepts a shape with a missing bracket対応中かも @SashaMIT が 51 日前に担当しました。 オープンModule:Polygraphy
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 6 日以内に返信
NVIDIA/TensorRT の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
maplibre/maplibre-native#5072 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
tenstorrent/tt-umd#4017 ·
メンテナーはふだん 3 日以内に返信
-
difficulty:easy func:gui prio:low type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NatronGitHub/Natron#1538 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hyprwm/hyprsunset#103 · コメント 1 件 ·