diff --git a/sgl-kernel/CMakeLists.txt b/sgl-kernel/CMakeLists.txt index e41cf6f0a..880428161 100644 --- a/sgl-kernel/CMakeLists.txt +++ b/sgl-kernel/CMakeLists.txt @@ -56,7 +56,7 @@ FetchContent_Populate(repo-cutlass) FetchContent_Declare( repo-deepgemm GIT_REPOSITORY https://github.com/sgl-project/DeepGEMM - GIT_TAG 54f99a8af537b3c6eb4819b69907ccbe2b600792 + GIT_TAG fc08e5775a5db960690a41248655168c55bef228 GIT_SHALLOW OFF ) FetchContent_Populate(repo-deepgemm) @@ -548,10 +548,21 @@ set(DEEPGEMM_SOURCES "${repo-deepgemm_SOURCE_DIR}/csrc/python_api.cpp" ) -Python_add_library(deep_gemm_cpp MODULE USE_SABI ${SKBUILD_SABI_VERSION} WITH_SOABI ${DEEPGEMM_SOURCES}) +Python_add_library(deep_gemm_cpp MODULE WITH_SOABI ${DEEPGEMM_SOURCES}) + +# DeepGEMM's Python package (`deep_gemm/__init__.py`) expects the extension module name to be `_C`, +# i.e. it does `from . import _C`. Make sure the built module is importable as `deep_gemm._C`. +set_target_properties(deep_gemm_cpp PROPERTIES + OUTPUT_NAME "_C" + PREFIX "" +) # Link against necessary libraries, including nvrtc for JIT compilation. -target_link_libraries(deep_gemm_cpp PRIVATE ${TORCH_LIBRARIES} c10 cuda nvrtc mscclpp_static) +find_library(TORCH_PYTHON_LIB + NAMES torch_python + PATHS "${TORCH_INSTALL_PREFIX}/lib" "${TORCH_INSTALL_PREFIX}/lib64" +) +target_link_libraries(deep_gemm_cpp PRIVATE ${TORCH_LIBRARIES} "${TORCH_PYTHON_LIB}" c10 cuda nvrtc mscclpp_static) # Add include directories needed by DeepGEMM. target_include_directories(deep_gemm_cpp PRIVATE diff --git a/sgl-kernel/build.sh b/sgl-kernel/build.sh index b29d4d64a..d8ad84965 100755 --- a/sgl-kernel/build.sh +++ b/sgl-kernel/build.sh @@ -46,6 +46,7 @@ echo "PYTHON_TAG: ${PY_TAG}" echo "Output: ${DIST_DIR}/" echo "Buildx cache: ${BUILDX_CACHE_DIR}" echo "Builder: ${BUILDER_NAME}" +echo "USE_CCACHE: ${USE_CCACHE}" echo "----------------------------------------" # Optional profiling build-args (empty string disables) @@ -61,6 +62,7 @@ docker buildx build \ --build-arg ARCH="${ARCH}" \ --build-arg PYTHON_VERSION="${PYTHON_VERSION}" \ --build-arg PYTHON_TAG="${PY_TAG}" \ + --build-arg USE_CCACHE="${USE_CCACHE}" \ "${BUILD_ARGS[@]}" \ --cache-from type=local,src=${BUILDX_CACHE_DIR} \ --cache-to type=local,dest=${BUILDX_CACHE_DIR},mode=max \ diff --git a/sgl-kernel/csrc/elementwise/concat_mla.cu b/sgl-kernel/csrc/elementwise/concat_mla.cu index 7d5b8595c..32144aa8a 100644 --- a/sgl-kernel/csrc/elementwise/concat_mla.cu +++ b/sgl-kernel/csrc/elementwise/concat_mla.cu @@ -215,3 +215,4 @@ void concat_mla_absorb_q(at::Tensor a, at::Tensor b, at::Tensor out) { cudaError_t err = cudaGetLastError(); TORCH_CHECK(err == cudaSuccess, "CUDA kernel launch failed: ", cudaGetErrorString(err)); } +// For ci build