mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-31 18:08:57 +08:00
[Build] Fixes for CMake install (#18570)
This commit is contained in:
parent
51e98e4ffd
commit
a3896c7f02
@ -23,6 +23,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/utils.cmake)
|
|||||||
# Suppress potential warnings about unused manually-specified variables
|
# Suppress potential warnings about unused manually-specified variables
|
||||||
set(ignoreMe "${VLLM_PYTHON_PATH}")
|
set(ignoreMe "${VLLM_PYTHON_PATH}")
|
||||||
|
|
||||||
|
# Prevent installation of dependencies (cutlass) by default.
|
||||||
|
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Supported python versions. These versions will be searched in order, the
|
# Supported python versions. These versions will be searched in order, the
|
||||||
# first match will be selected. These should be kept in sync with setup.py.
|
# first match will be selected. These should be kept in sync with setup.py.
|
||||||
@ -785,5 +788,7 @@ endif()
|
|||||||
# For CUDA we also build and ship some external projects.
|
# For CUDA we also build and ship some external projects.
|
||||||
if (VLLM_GPU_LANG STREQUAL "CUDA")
|
if (VLLM_GPU_LANG STREQUAL "CUDA")
|
||||||
include(cmake/external_projects/flashmla.cmake)
|
include(cmake/external_projects/flashmla.cmake)
|
||||||
|
|
||||||
|
# vllm-flash-attn should be last as it overwrites some CMake functions
|
||||||
include(cmake/external_projects/vllm_flash_attn.cmake)
|
include(cmake/external_projects/vllm_flash_attn.cmake)
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
@ -46,22 +46,38 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure the vllm/vllm_flash_attn directory exists before installation
|
||||||
|
install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn\")" ALL_COMPONENTS)
|
||||||
|
|
||||||
|
# Make sure vllm-flash-attn install rules are nested under vllm/
|
||||||
|
# This is here to support installing all components under the same prefix with cmake --install.
|
||||||
|
# setup.py installs every component separately but uses the same prefix for all.
|
||||||
|
# ALL_COMPONENTS is used to avoid duplication for FA2 and FA3,
|
||||||
|
# and these statements don't hurt when installing neither component.
|
||||||
|
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" ALL_COMPONENTS)
|
||||||
|
install(CODE "set(OLD_CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS)
|
||||||
|
install(CODE "set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/vllm/\")" ALL_COMPONENTS)
|
||||||
|
|
||||||
# Fetch the vllm-flash-attn library
|
# Fetch the vllm-flash-attn library
|
||||||
FetchContent_MakeAvailable(vllm-flash-attn)
|
FetchContent_MakeAvailable(vllm-flash-attn)
|
||||||
message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}")
|
message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}")
|
||||||
|
|
||||||
|
# Restore the install prefix
|
||||||
|
install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" ALL_COMPONENTS)
|
||||||
|
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
|
||||||
|
|
||||||
# Copy over the vllm-flash-attn python files (duplicated for fa2 and fa3, in
|
# Copy over the vllm-flash-attn python files (duplicated for fa2 and fa3, in
|
||||||
# case only one is built, in the case both are built redundant work is done)
|
# case only one is built, in the case both are built redundant work is done)
|
||||||
install(
|
install(
|
||||||
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
|
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
|
||||||
DESTINATION vllm_flash_attn
|
DESTINATION vllm/vllm_flash_attn
|
||||||
COMPONENT _vllm_fa2_C
|
COMPONENT _vllm_fa2_C
|
||||||
FILES_MATCHING PATTERN "*.py"
|
FILES_MATCHING PATTERN "*.py"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
|
DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/
|
||||||
DESTINATION vllm_flash_attn
|
DESTINATION vllm/vllm_flash_attn
|
||||||
COMPONENT _vllm_fa3_C
|
COMPONENT _vllm_fa3_C
|
||||||
FILES_MATCHING PATTERN "*.py"
|
FILES_MATCHING PATTERN "*.py"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ function (hipify_sources_target OUT_SRCS NAME ORIG_SRCS)
|
|||||||
set(CSRC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/csrc)
|
set(CSRC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/csrc)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
hipify${NAME}
|
hipify${NAME}
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/cmake/hipify.py -p ${CMAKE_SOURCE_DIR}/csrc -o ${CSRC_BUILD_DIR} ${SRCS}
|
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/hipify.py -p ${CMAKE_SOURCE_DIR}/csrc -o ${CSRC_BUILD_DIR} ${SRCS}
|
||||||
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/hipify.py ${SRCS}
|
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/hipify.py ${SRCS}
|
||||||
BYPRODUCTS ${HIP_SRCS}
|
BYPRODUCTS ${HIP_SRCS}
|
||||||
COMMENT "Running hipify on ${NAME} extension source files.")
|
COMMENT "Running hipify on ${NAME} extension source files.")
|
||||||
|
|||||||
5
setup.py
5
setup.py
@ -251,11 +251,8 @@ class cmake_build_ext(build_ext):
|
|||||||
|
|
||||||
# CMake appends the extension prefix to the install path,
|
# CMake appends the extension prefix to the install path,
|
||||||
# and outdir already contains that prefix, so we need to remove it.
|
# and outdir already contains that prefix, so we need to remove it.
|
||||||
# We assume only the final component of extension prefix is added by
|
|
||||||
# CMake, this is currently true for current extensions but may not
|
|
||||||
# always be the case.
|
|
||||||
prefix = outdir
|
prefix = outdir
|
||||||
if '.' in ext.name:
|
for _ in range(ext.name.count('.')):
|
||||||
prefix = prefix.parent
|
prefix = prefix.parent
|
||||||
|
|
||||||
# prefix here should actually be the same for all components
|
# prefix here should actually be the same for all components
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user