Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake based build system #2830

Merged
merged 76 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
e3a60a4
cmake based build system
bnellnm Feb 10, 2024
b500bb4
comment out newer bits
bnellnm Feb 10, 2024
cc2407d
merge
bnellnm Feb 11, 2024
c9ac7ad
try adding CMakeLists.txt to MANIFEST.in
bnellnm Feb 11, 2024
3123f57
try adding it to dockerfile
bnellnm Feb 11, 2024
a4d99ea
add another path to CMAKE_PREFIX_PATH
bnellnm Feb 11, 2024
41dbdc9
try again
bnellnm Feb 11, 2024
ac9d94b
hack to test punica build
bnellnm Feb 11, 2024
102675d
try again
bnellnm Feb 11, 2024
dfbafe3
try again
bnellnm Feb 11, 2024
39a8589
cleanup path stuff. try hacking arches again
bnellnm Feb 11, 2024
f66b286
fix typo
bnellnm Feb 11, 2024
b2784e0
change function to macro
bnellnm Feb 11, 2024
5464e30
flag hacking
bnellnm Feb 12, 2024
22e3803
strip arches out of CMAKE_CUDA_FLAGS
bnellnm Feb 12, 2024
e55fc13
more shenanigans
bnellnm Feb 12, 2024
6fd7b59
try again
bnellnm Feb 12, 2024
7c26517
fiddling around
bnellnm Feb 13, 2024
b0a8531
add some debugging code
bnellnm Feb 13, 2024
d0622c3
try exact python version match for debugging
bnellnm Feb 13, 2024
49c0a9c
try with more permissive python version(s)
bnellnm Feb 13, 2024
3cea6a4
add debugging
bnellnm Feb 13, 2024
812fab6
add debugging
bnellnm Feb 13, 2024
2654e84
try using find_package(Python3...)
bnellnm Feb 13, 2024
d5b6a2d
try multiple find_package calls for python
bnellnm Feb 13, 2024
e70ebce
try multiple find_packages for python
bnellnm Feb 13, 2024
06f9d55
arch flag parsing in cmake, yay
bnellnm Feb 14, 2024
ef12d5d
filter out unsupported arches
bnellnm Feb 14, 2024
4d74867
filter out unsupported arches
bnellnm Feb 14, 2024
9ee738d
cleanups + add comments
bnellnm Feb 14, 2024
1e08118
wip
bnellnm Feb 20, 2024
3d04255
hacked up rocm support
bnellnm Feb 20, 2024
84bdbc3
fix merge issue
bnellnm Feb 20, 2024
6ad7e54
run format.sh
bnellnm Feb 20, 2024
1d50fa7
fix enable_language
bnellnm Feb 20, 2024
10e3526
cleanups
bnellnm Feb 22, 2024
b56afb1
more hipify cleanups
bnellnm Feb 22, 2024
b3f3b55
comment
bnellnm Feb 22, 2024
7f0c908
fix ruff
bnellnm Feb 22, 2024
a8a8bd8
code cleanups
bnellnm Feb 22, 2024
d9ed8b9
add comments
bnellnm Feb 22, 2024
55b73e9
tweaks
bnellnm Feb 22, 2024
298fbf2
restore accidentally removed comment
bnellnm Feb 22, 2024
9bb0aeb
remove cmake logging
bnellnm Feb 23, 2024
17349a5
add 'supported' target
bnellnm Feb 23, 2024
6fa22b5
cleanup comments, add variables for supported torch versions
bnellnm Feb 24, 2024
ed3f191
replace IS_CUDA with VLLM_GPU_LANG
bnellnm Feb 26, 2024
d9cc840
update comment + remove some debug logging
bnellnm Feb 26, 2024
3999ed2
review comments + some tweaks to setup.py
bnellnm Feb 26, 2024
c669467
move utilities to utils.cmake, change find python process to use bina…
bnellnm Feb 27, 2024
4c9f6b0
fix typo
bnellnm Feb 27, 2024
96d86cc
add path to include of utils.cmake
bnellnm Feb 27, 2024
fcbd89f
try another path for utils.cmake
bnellnm Feb 27, 2024
2f0ed6d
add utils.cmake to Dockerfile + MANIFEST.in
bnellnm Feb 27, 2024
086de5c
remove mpi include directories
bnellnm Feb 27, 2024
0ff8825
refactor setup.py so cmake configuration is separate from cmake build
bnellnm Feb 28, 2024
f625d6d
let --debug control build type if CMAKE_BUILD_TYPE is not set
bnellnm Feb 28, 2024
efda6fb
add some type annotations to setup.py
bnellnm Feb 28, 2024
3fc98a6
add comment
bnellnm Feb 28, 2024
a68fec9
review comments + move most of the arch/compiler flag code to utils.c…
bnellnm Feb 28, 2024
094c448
typo
bnellnm Feb 28, 2024
d461230
utils.cmake typo
bnellnm Feb 28, 2024
8ff0116
more detailed comment for libtorch_python.so
bnellnm Feb 28, 2024
2e48dd7
use cmake_parse_arguments for define_gpu_extension_target
bnellnm Feb 29, 2024
5fc7a6a
convert some macros to functions
bnellnm Feb 29, 2024
baa1fa8
use underscores for variables set in macros
bnellnm Feb 29, 2024
5c0bd32
turn override_gpu_arches back into a macro
bnellnm Feb 29, 2024
34e1f00
fix override_gpu_arches
bnellnm Feb 29, 2024
384d897
fixes for punica configuration
bnellnm Feb 29, 2024
59204f6
debugging
bnellnm Feb 29, 2024
ec6ae13
debug
bnellnm Feb 29, 2024
fa42ea9
revamp punica installation logic
bnellnm Feb 29, 2024
c3be2cf
remove debugging cruft + add more detail to comment
bnellnm Mar 6, 2024
2225ece
merge marlin changes
bnellnm Mar 6, 2024
5393d4c
fix merge error
bnellnm Mar 13, 2024
af254ce
merge setup.py
bnellnm Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup path stuff. try hacking arches again
  • Loading branch information
bnellnm committed Mar 18, 2024
commit 39a8589b11df0c3af2ffa5af8731a2dad9bc2043
57 changes: 21 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,31 @@ cmake_minimum_required(VERSION 3.21)
project(vllm_extensions LANGUAGES CXX)

#
# Find where user site-packages are installed and add it to cmake's search path.
# Find where user site-packages and torch are installed and add it to cmake's search path.
#

if(NOT DEFINED PYTHON_EXECUTABLE)
set(PYTHON_EXECUTABLE python3)
endif()

execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"import site; print(site.getusersitepackages())"
OUTPUT_VARIABLE SITE_PATH
ERROR_VARIABLE SITE_PATH_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(SITE_PATH STREQUAL "")
message(FATAL_ERROR "Failed to locate site-packages path,"
" full error message:\n${SITE_PATH_ERR}")
endif()

list(APPEND CMAKE_PREFIX_PATH ${SITE_PATH})

###############
function (append_cmake_prefix_path PKG EXPR)
if(NOT DEFINED PYTHON_EXECUTABLE)
set(PYTHON_EXECUTABLE python3)
endif()

execute_process(
execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"import torch; print(torch.utils.cmake_prefix_path)"
OUTPUT_VARIABLE TORCH_PATH
ERROR_VARIABLE TORCH_PATH_ERR
"${PYTHON_EXECUTABLE}" "-c" "import ${PKG}; print(${EXPR})"
OUTPUT_VARIABLE PREFIX_PATH
ERROR_VARIABLE PREFIX_PATH_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(TORCH_PATH STREQUAL "")
message(FATAL_ERROR "Failed to locate torch cmake_prefix_path,"
" full error message:\n${TORCH_PATH_ERR}")
endif()
if(PREFIX_PATH STREQUAL "")
message(FATAL_ERROR "Failed to locate ${PKG} path,"
" full error message:\n${PREFIX_PATH_ERR}")
endif()

list(APPEND CMAKE_PREFIX_PATH ${TORCH_PATH})
list(APPEND CMAKE_PREFIX_PATH ${SITE_PATH})
endfunction()

###############
append_cmake_prefix_path("site" "site.getusersitepackages()")
append_cmake_prefix_path("torch" "torch.utils.cmake_prefix_path")


#
Expand Down Expand Up @@ -84,6 +69,10 @@ if (CUDA_VERSION VERSION_GREATER_EQUAL 11.8)
list(APPEND NVCC_FLAGS "-DENABLE_FP8_E5M2")
endif()

# hack arches to test
# TODO: need to strip out cuda arches < 8.0 for punica
set(CMAKE_CUDA_ARCHITECTURES "75;80;86;89;90")

#
# Check for existence of CUDA/HIP language support
#
Expand Down Expand Up @@ -171,10 +160,6 @@ function(define_module_target MOD_NAME MOD_SRC MOD_NVCC_FLAGS)
install(TARGETS ${MOD_NAME} LIBRARY DESTINATION vllm)
endfunction()

# TODO: hacks punica not supported for less than 8.0
set(CMAKE_CUDA_ARCHITECTURES "80;86;89;90")
set(CUDA_ARCHITECTURES "80;86;89;90")

define_module_target(_C "${VLLM_EXT_SRC}" "${NVCC_FLAGS}")
define_module_target(_moe_C "${VLLM_MOE_EXT_SRC}" "${NVCC_FLAGS}")
define_module_target(_punica_C "${VLLM_PUNICA_EXT_SRC}" "${PUNICA_NVCC_FLAGS}")