From 3ef9fd0f989d7dfc5e3633c0dcfc64acbaf2f8c5 Mon Sep 17 00:00:00 2001 From: Michael Goin Date: Mon, 23 Feb 2026 20:11:27 -0500 Subject: [PATCH] [Bugfix] Fix DSV3 kernels breaking _C and _moe_C on unsupported arches (#35123) Signed-off-by: mgoin --- CMakeLists.txt | 1 - csrc/dsv3_fused_a_gemm.cu | 4 ++++ csrc/moe/dsv3_router_gemm_entry.cu | 6 ++++++ csrc/moe/torch_bindings.cpp | 2 +- csrc/torch_bindings.cpp | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f7f69468d..55127a514f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -783,7 +783,6 @@ if(VLLM_GPU_LANG STREQUAL "CUDA") SRCS "${DSV3_FUSED_A_GEMM_SRC}" CUDA_ARCHS "${DSV3_FUSED_A_GEMM_ARCHS}") list(APPEND VLLM_EXT_SRC ${DSV3_FUSED_A_GEMM_SRC}) - list(APPEND VLLM_GPU_FLAGS "-DENABLE_DSV3_FUSED_A_GEMM=1") message(STATUS "Building dsv3_fused_a_gemm for archs: ${DSV3_FUSED_A_GEMM_ARCHS}") else() message(STATUS "Not building dsv3_fused_a_gemm as no compatible archs found " diff --git a/csrc/dsv3_fused_a_gemm.cu b/csrc/dsv3_fused_a_gemm.cu index 5b8374303ad..65dff9c84ba 100644 --- a/csrc/dsv3_fused_a_gemm.cu +++ b/csrc/dsv3_fused_a_gemm.cu @@ -745,3 +745,7 @@ void dsv3_fused_a_gemm(torch::Tensor& output, torch::Tensor const& mat_a, stream); } } + +TORCH_LIBRARY_IMPL_EXPAND(TORCH_EXTENSION_NAME, CUDA, m) { + m.impl("dsv3_fused_a_gemm", &dsv3_fused_a_gemm); +} diff --git a/csrc/moe/dsv3_router_gemm_entry.cu b/csrc/moe/dsv3_router_gemm_entry.cu index 1ba97bd7640..38fb681c223 100644 --- a/csrc/moe/dsv3_router_gemm_entry.cu +++ b/csrc/moe/dsv3_router_gemm_entry.cu @@ -20,10 +20,12 @@ #include #include +#include #include #include +#include "core/registration.h" #include "dsv3_router_gemm_utils.h" static constexpr int DEFAULT_NUM_EXPERTS = 256; @@ -161,3 +163,7 @@ void dsv3_router_gemm(at::Tensor& output, // [num_tokens, num_experts] } } } + +TORCH_LIBRARY_IMPL_EXPAND(TORCH_EXTENSION_NAME, CUDA, m) { + m.impl("dsv3_router_gemm", &dsv3_router_gemm); +} diff --git a/csrc/moe/torch_bindings.cpp b/csrc/moe/torch_bindings.cpp index 22b00f20ad5..43859945145 100644 --- a/csrc/moe/torch_bindings.cpp +++ b/csrc/moe/torch_bindings.cpp @@ -127,7 +127,7 @@ TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, m) { // DeepSeek V3 optimized router GEMM for SM90+ m.def("dsv3_router_gemm(Tensor! output, Tensor mat_a, Tensor mat_b) -> ()"); - m.impl("dsv3_router_gemm", torch::kCUDA, &dsv3_router_gemm); + // conditionally compiled so impl registration is in source file #endif } diff --git a/csrc/torch_bindings.cpp b/csrc/torch_bindings.cpp index c16b9c223f6..39b6bc98a84 100644 --- a/csrc/torch_bindings.cpp +++ b/csrc/torch_bindings.cpp @@ -242,7 +242,7 @@ TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { // DeepSeek V3 fused A GEMM (SM 9.0+, bf16 only, 1-16 tokens). ops.def( "dsv3_fused_a_gemm(Tensor! output, Tensor mat_a, Tensor mat_b) -> ()"); - ops.impl("dsv3_fused_a_gemm", torch::kCUDA, &dsv3_fused_a_gemm); + // conditionally compiled so impl registration is in source file // Quantized GEMM for AWQ. ops.def(