[Bug Fix] Fix activation.cuh JIT compilation failure on CUDA 13 due to template type/value mismatch (#26444)

Co-authored-by: e01448 <jwmao@birentech.com>
This commit is contained in:
Michael_miao
2026-06-05 22:59:24 +08:00
committed by GitHub
co-authored by e01448
parent 6cfdc18585
commit e7f94d0d40
@@ -86,21 +86,22 @@ struct ActivationKernel {
static constexpr auto kVecSize = device::kMaxVecBytes / sizeof(T);
static constexpr auto kBlockSize = 256u;
using kernel_fn_t = decltype(&act_and_mul_kernel<T, ActivationKind::kSiLU, kUsePDL, false>);
template <ActivationKind kAct, bool kFilterExpert>
static constexpr auto activation_kernel = act_and_mul_kernel<T, kAct, kUsePDL, kFilterExpert>;
static constexpr kernel_fn_t activation_kernel = act_and_mul_kernel<T, kAct, kUsePDL, kFilterExpert>;
static_assert(device::kMaxVecBytes % sizeof(T) == 0, "unsupported data type");
template <bool kFilterExpert>
static auto select_kernel(const std::string& type)
-> decltype(ActivationKernel::template activation_kernel<ActivationKind::kSiLU, kFilterExpert>) {
static kernel_fn_t select_kernel(const std::string& type) {
using namespace host;
if (type == "silu") {
return ActivationKernel::template activation_kernel<ActivationKind::kSiLU, kFilterExpert>;
return activation_kernel<ActivationKind::kSiLU, kFilterExpert>;
} else if (type == "gelu") {
return ActivationKernel::template activation_kernel<ActivationKind::kGELU, kFilterExpert>;
return activation_kernel<ActivationKind::kGELU, kFilterExpert>;
} else if (type == "gelu_tanh") {
return ActivationKernel::template activation_kernel<ActivationKind::kGELUTanh, kFilterExpert>;
return activation_kernel<ActivationKind::kGELUTanh, kFilterExpert>;
} else {
Panic("unsupported activation type: ", type);
}
@@ -130,7 +131,7 @@ struct ActivationKernel {
.with_device(device_)
.verify(input);
const auto hidden_size = D_out.unwrap();
const auto hidden_size = static_cast<uint32_t>(D_out.unwrap());
const auto num_tokens = static_cast<uint32_t>(N.unwrap());
const auto device = device_.unwrap();
if (num_tokens == 0) return;