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 15, 08:30 UTC
[Build] Fixes for CMake install (#18570)
Luka Govedič committed
May 27, 2025 at 20:49 UTC
a3896c7f0216d6930a912924e9149f31087232c5
4 files changed
+25
-7
CMakeLists.txt
+5
@@ -23,6 +23,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/utils.cmake)
23
# Suppress potential warnings about unused manually-specified variables
24
set(ignoreMe "${VLLM_PYTHON_PATH}")
25
26
+# Prevent installation of dependencies (cutlass) by default.
27
+install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
28
+
29
#
30
# Supported python versions. These versions will be searched in order, the
31
# first match will be selected. These should be kept in sync with setup.py.
@@ -785,5 +788,7 @@ endif()
788
# For CUDA we also build and ship some external projects.
789
if (VLLM_GPU_LANG STREQUAL "CUDA")
790
include(cmake/external_projects/flashmla.cmake)
791
+
792
+ # vllm-flash-attn should be last as it overwrites some CMake functions
793
include(cmake/external_projects/vllm_flash_attn.cmake)
794
endif ()
cmake/external_projects/vllm_flash_attn.cmake
+18
-2
@@ -46,22 +46,38 @@ else()
46
endif()
47
48
49
+# Ensure the vllm/vllm_flash_attn directory exists before installation
50
+install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn\")" ALL_COMPONENTS)
51
+
52
+# Make sure vllm-flash-attn install rules are nested under vllm/
53
+# This is here to support installing all components under the same prefix with cmake --install.
54
+# setup.py installs every component separately but uses the same prefix for all.
55
+# ALL_COMPONENTS is used to avoid duplication for FA2 and FA3,
56
+# and these statements don't hurt when installing neither component.
57
+install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" ALL_COMPONENTS)
58
+install(CODE "set(OLD_CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS)
59
+install(CODE "set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/vllm/\")" ALL_COMPONENTS)
60
+
61
# Fetch the vllm-flash-attn library
62
FetchContent_MakeAvailable(vllm-flash-attn)
63
message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}")
64
65
+# Restore the install prefix
66
+install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS)
67
+install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
68
+
69
# Copy over the vllm-flash-attn python files (duplicated for fa2 and fa3, in
70
# case only one is built, in the case both are built redundant work is done)
71
install(
72
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
57
- DESTINATION vllm_flash_attn
73
+ DESTINATION vllm/vllm_flash_attn
74
COMPONENT _vllm_fa2_C
75
FILES_MATCHING PATTERN "*.py"
76
)
77
78
install(
79
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
64
- DESTINATION vllm_flash_attn
80
+ DESTINATION vllm/vllm_flash_attn
81
COMPONENT _vllm_fa3_C
82
FILES_MATCHING PATTERN "*.py"
83
)
cmake/utils.cmake
+1
-1
@@ -76,7 +76,7 @@ function (hipify_sources_target OUT_SRCS NAME ORIG_SRCS)
76
set(CSRC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/csrc)
77
add_custom_target(
78
hipify${NAME}
79
- COMMAND ${CMAKE_SOURCE_DIR}/cmake/hipify.py -p ${CMAKE_SOURCE_DIR}/csrc -o ${CSRC_BUILD_DIR} ${SRCS}
79
+ COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/hipify.py -p ${CMAKE_SOURCE_DIR}/csrc -o ${CSRC_BUILD_DIR} ${SRCS}
80
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/hipify.py ${SRCS}
81
BYPRODUCTS ${HIP_SRCS}
82
COMMENT "Running hipify on ${NAME} extension source files.")
setup.py
+1
-4
@@ -251,11 +251,8 @@ class cmake_build_ext(build_ext):
251
252
# CMake appends the extension prefix to the install path,
253
# and outdir already contains that prefix, so we need to remove it.
254
- # We assume only the final component of extension prefix is added by
255
- # CMake, this is currently true for current extensions but may not
256
- # always be the case.
254
prefix = outdir
258
- if '.' in ext.name:
255
+ for _ in range(ext.name.count('.')):
256
prefix = prefix.parent
257
258
# prefix here should actually be the same for all components