@@ -7,6 +7,8 @@ option(USE_MANYLINUX "Build for manylinux" OFF)
77option (BUILD_NVBENCH "Build the nvbench binary" OFF )
88option (INSTALL_PY_MODULE "Install python module to scalellm directory" OFF )
99
10+ option (BUILD_KERNEL_ONLY "Build only the CUDA kernel library" OFF )
11+
1012set (CMAKE_CXX_STANDARD 17)
1113set (CMAKE_CXX_STANDARD_REQUIRED ON )
1214set (CMAKE_CXX_EXTENSIONS OFF )
@@ -92,6 +94,9 @@ message(STATUS "TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST}")
9294
9395# configure vcpkg
9496# have to set CMAKE_TOOLCHAIN_FILE before first project call.
97+ if (NOT BUILD_KERNEL_ONLY)
98+ set (VCPKG_MANIFEST_FEATURES service)
99+ endif ()
95100if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
96101 set (CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT} /scripts/buildsystems/vcpkg.cmake"
97102 CACHE STRING "Vcpkg toolchain file" )
@@ -121,64 +126,71 @@ project(
121126 LANGUAGES C CXX CUDA
122127)
123128
124- find_package (CUDAToolkit REQUIRED)
125-
126129# setup CMake module path, defines path for include() and find_package()
127130list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake)
128- enable_language (Rust)
129- find_package (Rust REQUIRED)
130-
131- # include custom cmake modules
132- include (static_analyzers)
133- # TODO: can't use sanitizers with CUDA for now.
134- # include(sanitizers)
135-
136- if (UNIX )
137- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og" )
138- endif ()
131+ # include current and third_party paths
132+ list (APPEND COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /src)
133+ list (APPEND COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /third_party)
139134
140- find_package (Boost REQUIRED)
141- find_package (Threads REQUIRED)
142- # find all dependencies from vcpkg
143- find_package (fmt CONFIG REQUIRED GLOBAL )
135+ # find required common packages
136+ find_package (CUDAToolkit REQUIRED)
144137find_package (glog CONFIG REQUIRED)
145- find_package (gflags CONFIG REQUIRED)
146138find_package (absl CONFIG REQUIRED)
147- find_package (Protobuf CONFIG REQUIRED)
148- find_package (gRPC CONFIG REQUIRED)
149- find_package (re2 CONFIG REQUIRED)
150- find_package (folly CONFIG REQUIRED)
151139find_package (GTest CONFIG REQUIRED)
152- find_package (benchmark CONFIG REQUIRED)
153- find_package (nlohmann_json CONFIG REQUIRED)
154- find_package (prometheus-cpp CONFIG REQUIRED)
155- find_package (RapidJSON CONFIG REQUIRED)
140+
141+ # find packages for service build
142+ if (NOT BUILD_KERNEL_ONLY)
143+ enable_language (Rust)
144+ find_package (Rust REQUIRED)
145+
146+ # include custom cmake modules
147+ include (static_analyzers)
148+ # TODO: can't use sanitizers with CUDA for now.
149+ # include(sanitizers)
150+
151+ if (UNIX )
152+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og" )
153+ endif ()
154+
155+ find_package (Boost REQUIRED)
156+ find_package (Threads REQUIRED)
157+ # find all dependencies from vcpkg
158+ find_package (fmt CONFIG REQUIRED GLOBAL )
159+ find_package (gflags CONFIG REQUIRED)
160+ find_package (Protobuf CONFIG REQUIRED)
161+ find_package (gRPC CONFIG REQUIRED)
162+ find_package (re2 CONFIG REQUIRED)
163+ find_package (folly CONFIG REQUIRED)
164+ find_package (benchmark CONFIG REQUIRED)
165+ find_package (nlohmann_json CONFIG REQUIRED)
166+ find_package (prometheus-cpp CONFIG REQUIRED)
167+ find_package (RapidJSON CONFIG REQUIRED)
168+
169+ find_package (NCCL REQUIRED)
170+
171+ find_package (Jemalloc)
172+ if (Jemalloc_FOUND)
173+ link_libraries (Jemalloc::jemalloc)
174+ endif ()
175+ endif ()
156176
157177if (USE_MANYLINUX)
158178 # manylinux doesn't ship Development.Embed
159179 find_package (Python REQUIRED COMPONENTS Interpreter Development.Module)
160180else ()
161181 find_package (Python REQUIRED COMPONENTS Interpreter Development)
162182endif ()
163-
164- find_package (NCCL REQUIRED)
165-
166- find_package (Jemalloc)
167- if (Jemalloc_FOUND)
168- link_libraries (Jemalloc::jemalloc)
169- endif ()
170-
171183# Important Note: Always invoke find_package for other dependencies
172184# before including libtorch, as doing so afterwards may lead to
173185# unexpected linker errors.
174186if (DEFINED ENV{LIBTORCH_ROOT})
175187 find_package (Torch REQUIRED HINTS "$ENV{LIBTORCH_ROOT} " )
176188 message (STATUS "Using libtorch at $ENV{LIBTORCH_ROOT} " )
177189else ()
178- SET (TORCH_VERSION "2.8 .0" )
190+ SET (TORCH_VERSION "2.9 .0" )
179191 include (FetchContent)
180- if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.9 )
181- set (LIBTORCH_URL "https://download.pytorch.org/libtorch/cu129 /libtorch-shared-with-deps-${TORCH_VERSION} %2Bcu129 .zip" )
192+ if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 13.0 )
193+ set (LIBTORCH_URL "https://download.pytorch.org/libtorch/cu130 /libtorch-shared-with-deps-${TORCH_VERSION} %2Bcu130 .zip" )
182194 elseif (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.8)
183195 set (LIBTORCH_URL "https://download.pytorch.org/libtorch/cu128/libtorch-shared-with-deps-${TORCH_VERSION} %2Bcu128.zip" )
184196 elseif (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.6)
@@ -235,12 +247,10 @@ message(STATUS "CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}")
235247include (CTest)
236248include (GoogleTest)
237249
238- # include current path
239- list (APPEND COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /src)
240- list (APPEND COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /third_party)
241-
242250# add subdirectories
243- add_subdirectory (proto)
244- add_subdirectory (src)
245251add_subdirectory (third_party)
246- add_subdirectory (scalellm)
252+ add_subdirectory (src)
253+ if (NOT BUILD_KERNEL_ONLY)
254+ add_subdirectory (proto)
255+ add_subdirectory (scalellm)
256+ endif ()
0 commit comments