diff --git a/transformer_engine/common/cast/dispatch/gated.cuh b/transformer_engine/common/cast/dispatch/gated.cuh index 02a0740f63..eac48addd1 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) {