@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0c99629ede
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 4, 10:00 UTC

[Build] Make bundled DeepGEMM wheel portable across Python versions (#41476)

Signed-off-by: mgoin <mgoin64@gmail.com>

Michael Goin committed May 1, 2026 at 17:45 UTC 0c99629ede51524f00b88cb758c895fd76a5f6f9
1 file changed +23 -4
cmake/external_projects/deepgemm.cmake
+23 -4
@@ -59,11 +59,26 @@ if(DEEPGEMM_ARCHS)
59 # Build the _C pybind11 extension from DeepGEMM's C++ source.
60 # This is a CXX-only module — CUDA kernels are JIT-compiled at runtime.
61 #
62 - Python_add_library(_deep_gemm_C MODULE WITH_SOABI
63 - "${deepgemm_SOURCE_DIR}/csrc/python_api.cpp")
62 + # Free-threaded Python doesn't yet support the stable ABI, so skip USE_SABI
63 + # there. (The other vLLM extensions get this guard for free via
64 + # define_extension_target; this target uses raw Python_add_library.)
65 + run_python(IS_FREETHREADED_PYTHON
66 + "import sysconfig; print(1 if sysconfig.get_config_var(\"Py_GIL_DISABLED\") else 0)"
67 + "Failed to determine whether interpreter is free-threaded")
68 + if (NOT IS_FREETHREADED_PYTHON)
69 + Python_add_library(_deep_gemm_C MODULE WITH_SOABI USE_SABI 3
70 + "${deepgemm_SOURCE_DIR}/csrc/python_api.cpp")
71 + else()
72 + Python_add_library(_deep_gemm_C MODULE WITH_SOABI
73 + "${deepgemm_SOURCE_DIR}/csrc/python_api.cpp")
74 + endif()
75
76 # The pybind11 module name must be _C to match DeepGEMM's Python imports.
66 - set_target_properties(_deep_gemm_C PROPERTIES OUTPUT_NAME "_C")
77 + # Place the build artifact in a subdir so it doesn't collide with vLLM's own
78 + # `_C.abi3.so` in the build tree (the install destination still differs).
79 + set_target_properties(_deep_gemm_C PROPERTIES
80 + OUTPUT_NAME "_C"
81 + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/deep_gemm")
82
83 target_compile_definitions(_deep_gemm_C PRIVATE
84 "-DTORCH_EXTENSION_NAME=_C")
@@ -75,11 +90,15 @@ if(DEEPGEMM_ARCHS)
90 "${deepgemm_SOURCE_DIR}/third-party/cutlass/tools/util/include"
91 "${deepgemm_SOURCE_DIR}/third-party/fmt/include")
92
93 + # Keep Stable ABI for the module, but *not* for CUDA/C++ files.
94 + # This prevents Py_LIMITED_API from affecting nvcc and C++ compiles.
95 target_compile_options(_deep_gemm_C PRIVATE
96 $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
97 $<$<COMPILE_LANGUAGE:CXX>:-O3>
98 $<$<COMPILE_LANGUAGE:CXX>:-Wno-psabi>
82 - $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-declarations>)
99 + $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-declarations>
100 + $<$<COMPILE_LANGUAGE:CUDA>:-UPy_LIMITED_API>
101 + $<$<COMPILE_LANGUAGE:CXX>:-UPy_LIMITED_API>)
102
103 # torch_python is required because DeepGEMM uses pybind11 type casters
104 # for at::Tensor (via PYBIND11_MODULE), unlike vLLM's own extensions which