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

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

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

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

評価

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

説明

Module:Performance

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
  1. Q/K/V layout. In the FP16 and FP8 engines the Q/K/V GEMM writes [3, M, 1024] and _gemm_mha_v2 reads 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).
  2. 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_Dyna kernel after a GEMM with a bias.
  3. 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.
  4. 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

環境構築

はじめの一歩

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

NVIDIA/TensorRT のほかの issue

NVIDIA/TensorRT の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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