Ultralytics YOLO INT8 engines larger than FP32: 23.76 MB zero-filled block in TensorRT 11.4 plan on RTX PRO 6000 Blackwell

オープン
#4,905 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
12/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp, python
領域
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 の本文から書いたものです。

説明

Module:ONNX

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=0 builds 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, ModelOpt disable_mha_qdq=True, and quantizing only Conv (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_v2 of 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT のほかの issue

NVIDIA/TensorRT の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。