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

Đang mở
#4,880 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
8/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, python
Lĩnh vực
performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
13.5k
Fork
2.4k
Merge trung bình
6 ngày 21 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT

Tất cả issue của NVIDIA/TensorRT

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.