From 6262fa511bc809bd96174e2c86fe9769bb559bc1 Mon Sep 17 00:00:00 2001 From: wanglei875 Date: Sat, 5 Dec 2026 16:09:50 +0800 Subject: [PATCH] [Common] Dispatch non-FP8 gated activation forward to vectorized pointwise kernel Signed-off-by: wanglei875 --- transformer_engine/common/cast/dispatch/gated.cuh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transformer_engine/common/cast/dispatch/gated.cuh b/transformer_engine/common/cast/dispatch/gated.cuh index 02a0740f635..eac48addd19 100644 --- a/transformer_engine/common/cast/dispatch/gated.cuh +++ b/transformer_engine/common/cast/dispatch/gated.cuh @@ -50,8 +50,11 @@ void quantize_gated_fwd_helper(const NVTETensor nvte_input, NVTETensor nvte_outp switch (output->scaling_mode) { case NVTE_DELAYED_TENSOR_SCALING: { + // Only dispatch the FP8 TMA kernel when quantizing to FP8; for non-FP8 outputs + // (e.g. BF16/FP16/FP32), the vectorized pointwise kernel avoids TMA/shared-memory + // overhead and achieves higher memory bandwidth. const bool use_tma_kernels = - (cols % 32 == 0) && is_supported_by_CC_100() && + is_fp8_dtype(output->dtype()) && (cols % 32 == 0) && is_supported_by_CC_100() && fp8::cast_gated_tma_fits_device( input.dtype(), output->dtype()); if (use_tma_kernels) {