Skip to content

Commit 07b4b7a

Browse files
[BugFix/Build] Fix sparse kernels not getting built on hopper (vllm-project#14572)
Signed-off-by: Lucas Wilkinson <[email protected]>
1 parent 07964e2 commit 07b4b7a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
422422
# 2:4 Sparse Kernels
423423

424424
# The 2:4 sparse kernels cutlass_scaled_sparse_mm and cutlass_compressor
425-
# require CUDA 12.2 or later (and only work on Hopper and Blackwell).
425+
# require CUDA 12.2 or later (and only work on Hopper).
426+
cuda_archs_loose_intersection(SCALED_MM_ARCHS "9.0a;" "${CUDA_ARCHS}")
426427
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER 12.2 AND SCALED_MM_ARCHS)
427428
set(SRCS "csrc/sparse/cutlass/sparse_scaled_mm_c3x.cu")
428429
set_gencode_flags_for_srcs(

csrc/sparse/cutlass/sparse_scaled_mm_entry.cu

+6-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ void cutlass_scaled_sparse_mm(torch::Tensor& c, torch::Tensor const& a,
5858

5959
// Guard against compilation issues for sm90 kernels
6060
#if defined ENABLE_SPARSE_SCALED_MM_C3X && ENABLE_SPARSE_SCALED_MM_C3X
61-
if (version_num >= 90) {
61+
// We build for 9.0a which is not forward compatible, so restrict this to
62+
// Hopper only
63+
if (version_num == 90) {
6264
cutlass_scaled_sparse_mm_sm90(c, a, bt_nzs, bt_meta, a_scales, b_scales,
6365
bias);
6466
return;
@@ -82,7 +84,9 @@ std::vector<torch::Tensor> cutlass_sparse_compress(torch::Tensor const& a) {
8284

8385
// Guard against compilation issues for sm90 kernels
8486
#if defined ENABLE_SPARSE_SCALED_MM_C3X && ENABLE_SPARSE_SCALED_MM_C3X
85-
if (version_num >= 90) {
87+
// We build for 9.0a which is not forward compatible, so restrict this to
88+
// Hopper only
89+
if (version_num == 90) {
8690
std::vector<torch::Tensor> result_tensors;
8791

8892
auto [a_meta, a_nzs] = cutlass_sparse_compress_sm90(a);

0 commit comments

Comments
 (0)