Performance: NVFP4 encoder slower than FP8 with TensorRT 11.4 on RTX PRO 6000 Blackwell, from copies and unfused quantize kernels around the FP4 GEMMs
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 8/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- performance
調査の方向性
Start by reproducing the NVFP4 and FP8 engine builds with the trtexec commands in the report and comparing the per-layer profile. The work centres on the Myelin kernels named in the report (__myl_SlicResh, __myl_TranMul, __myl_Dyna_...) and the Q/K/V layout feeding the fused MHA kernel, which the payload does not map to source files. Done would mean the NVFP4 engine no longer pays for those extra copies and unfused quantize kernels, which is a compiler-level change.
索引モデルが issue の本文から書いたものです。
説明
Description
BAAI/bge-reranker-v2-m3 (XLM-R large, 24 layers) with NVFP4 W4A4 (ModelOpt NVFP4_DEFAULT_CFG, Q/K/V exported as one MatMul to avoid the batch fault in #4879) runs 45% slower than its FP8 engine at 128 pairs × 320 tokens and 24% slower at 128 × 640. Its FP4 GEMMs are not the problem: at 1,140–1,500 TFLOPS they are 1.7–2.0× faster than the FP8 GEMMs of the FP8 engine, about what CUTLASS reaches on this GPU outside TensorRT. The kernels that TensorRT adds around them cost more than the GEMMs save.
Per-layer profile (trtexec --dumpProfile --separateProfileRun), ms per inference at 128 × 640, grouped by the operations in the Myelin kernel names:
| Kernel group | FP8 engine | NVFP4 engine |
|---|---|---|
| GEMMs | 69.2 | 38.9 |
| Q/K/V slicing, transposes and copies | 0.9 | 38.3 |
| FP4 dynamic quantize as its own kernel | 0 | 18.0 |
| residual add + LayerNorm (+ quantize) | 8.6 | 18.0 |
| GELU (+ quantize) | 15.5 | 21.6 |
| fused MHA | 66.5 | 63.2 |
| FP4 block-scale swizzle | 0 | 2.1 |
| total | 160.8 | 200.1 |
- Q/K/V layout. In the FP16 and FP8 engines the Q/K/V GEMM writes
[3, M, 1024]and_gemm_mha_v2reads it directly, with 2 data-movement kernels in the whole engine. With the FP4 GEMM (cutlass3x_sm120_bstensorop_s16864gemm_block_scaled_ue4m3xe2m1_...), the GEMM writes[M, 3072], and five Myelin kernels per layer build the head-major Q, Kᵀ and V for the MHA kernel (__myl_SlicResh,__myl_TranMul,__myl_ReshMove,__myl_SlicReshTranReshMove,__myl_SlicReshTranMulReshMove). Together they take 1.6 ms per layer, about as long as all four GEMMs of the layer. With Q/K/V as separate MatMuls, the three FP4 GEMMs are not horizontally fused either (6 GEMMs and 11 data-movement kernels per layer). - GELU and quantize. The FP4 dynamic quantize of the FFN-down input runs as its own kernel after GELU (
__myl_Dyna_..., 0.61 ms per layer), reading back the FP16 GELU output. FP8 fuses GELU and the quantize into one kernel. #4735 reports the same separate__myl_Dynakernel after a GEMM with a bias. - LayerNorm and quantize. LayerNorm fused with the FP4 dynamic quantize (
__myl_AddCastMeanSubMulMeanAddSqrtDivMulCast...Dyna_cuda_tile_...) takes 0.36 ms, twice the 0.17 ms of LayerNorm with the FP8 quantize. - TensorRT 11.3.0.99 and 11.4.0.106 produce the same kernel mix and the same times (83.1 / 199.4 ms at 128 × 320 / 128 × 640).
Without the extra kernels and with the quantize fused like FP8, the NVFP4 engine would take about 127 ms at 128 × 640, 21% less than FP8, instead of 24% more.
Environment
TensorRT Version: 11.4.0.106 (also 11.3.0.99)
NVIDIA GPU: RTX PRO 6000 Blackwell Server Edition (SM120)
NVIDIA Driver Version: 595.91.07
CUDA Version: 13.4
CUDNN Version: not used
Operating System: Ubuntu 24.04 (GCP g4-standard-48)
Python Version (if applicable): 3.12
PyTorch Version (if applicable): 2.14.1 (export only)
Baremetal or Container (if so, version): nvcr.io/nvidia/tritonserver:26.09-py3
Relevant Files
Model link: BAAI/bge-reranker-v2-m3, quantized with ModelOpt NVFP4_DEFAULT_CFG (classifier head excluded) and exported to ONNX with get_onnx_bytes_and_metadata(..., weights_dtype="fp16"). The ONNX files (about 700 MB each) can be shared on request.
Steps To Reproduce
Commands or scripts:
trtexec --onnx=model.onnx --saveEngine=model.plan --minShapes=input_ids:1x128,attention_mask:1x128 \
--optShapes=input_ids:32x640,attention_mask:32x640 --maxShapes=input_ids:128x768,attention_mask:128x768 \
--profilingVerbosity=detailed --skipInference
trtexec --loadEngine=model.plan --shapes=input_ids:128x640,attention_mask:128x640 \
--loadInputs=input_ids:ids.bin,attention_mask:mask.bin --warmUp=2000 --duration=10 --noDataTransfers \
--useSpinWait --separateProfileRun --dumpProfile --exportProfile=profile.json --exportLayerInfo=layers.json
Have you tried the latest release?: Yes, 11.4.0.106 behaves the same.
Can this model run on other frameworks? Yes; the PyTorch fake-quant model and the engines agree in accuracy. This report is about speed only.
- 主要言語
- 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 件 ·