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 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 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 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 天内回复
相似的 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 条评论 ·