Skip to content

Commit bcccfe9

Browse files
committed
llm patch
Signed-off-by: vegetableysm <[email protected]>
1 parent 0cbaada commit bcccfe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+16947
-198
lines changed

CMakeLists.txt

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ project(vineyard LANGUAGES C CXX VERSION ${VINEYARD_VERSION})
3232

3333
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
3434
option(USE_STATIC_BOOST_LIBS "Build with static-linked boost libraries" OFF)
35+
option(LINK_STATIC_LIBC "Link with static libstdc++ if the BUILD_SHARED_LIBS is OFF and the compiler is gcc" ON)
3536
option(USE_EXTERNAL_ETCD_LIBS "Build with external etcd-cpp-apiv3 library rather than the submodule one" OFF)
3637
option(USE_EXTERNAL_REDIS_LIBS "Build with external redis-plus-plus library rather than the submodule one" ON)
3738
option(USE_EXTERNAL_HIREDIS_LIBS "Build with external hiredis library rather than the submodule one" ON)
39+
option(USE_EXTERNAL_METASERVICE_LIBS "Use external MetaService libraries" OFF)
3840
option(VINEYARD_USE_ASAN "Using address sanitizer to check memory accessing" OFF)
3941
option(VINEYARD_USE_LTO "Using IPO/LTO support for link-time optimization" OFF)
4042
option(USE_LIBUNWIND "Using libunwind to retrieve the stack backtrace when exception occurs" ON)
4143
option(USE_INCLUDE_WHAT_YOU_USE "Simply the intra-module dependencies with iwyu" OFF)
4244
option(USE_JSON_DIAGNOSTICS "Using json diagnostics to check the validity of metadata" OFF)
4345
option(USE_CUDA "Enabling GPU (CUDA) support" OFF)
46+
option(ENABLE_VINEYARD_MONITOR "Enable vineyard monitor" OFF)
4447

4548
option(BUILD_VINEYARD_SERVER "Build vineyard's server" ON)
4649
option(BUILD_VINEYARD_SERVER_REDIS "Enable redis as the metadata backend" OFF)
@@ -70,6 +73,9 @@ option(BUILD_VINEYARD_BENCHMARKS "Generate make targets for vineyard benchmarks"
7073
option(BUILD_VINEYARD_BENCHMARKS_ALL "Include make targets for vineyard benchmarks to ALL" OFF)
7174
option(BUILD_VINEYARD_COVERAGE "Build vineyard with coverage information, requires build with Debug" OFF)
7275
option(BUILD_VINEYARD_PROFILING "Build vineyard with profiling information" OFF)
76+
option(BUILD_ENV_RUNC "Build vineyard in runc env" OFF)
77+
option(BUILD_FABRIC_RDMA "Build vineyard fabric with RDMA support" OFF)
78+
option(BUILD_VLLM_CACHE "Build vineyard with vllm cache support" OFF)
7379

7480
include(CheckCXXCompilerFlag)
7581
include(CheckLibraryExists)
@@ -493,6 +499,7 @@ endmacro()
493499
macro(find_cuda)
494500
# find cuda runtime library
495501
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
502+
enable_language(CUDA)
496503
find_package(CUDA REQUIRED)
497504
endmacro(find_cuda)
498505

@@ -675,7 +682,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
675682
endif()
676683
set(FABRIC_MAKEFILE "${CMAKE_SOURCE_DIR}/thirdparty/libfabric/Makefile")
677684

678-
if(IBVERBS_LIB AND RDMACM_LIB)
685+
if(BUILD_FABRIC_RDMA AND IBVERBS_LIB AND RDMACM_LIB)
679686
set(RDMA_LIBS ${RDMACM_LIB} ${IBVERBS_LIB} ${RT_LIB})
680687

681688
add_custom_command(
@@ -696,6 +703,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
696703
--disable-perf
697704
--disable-efa
698705
--disable-mrail
706+
--disable-uffd-monitor
707+
--with-cuda=no
699708
--enable-verbs > /dev/null
700709
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/thirdparty/libfabric
701710
)
@@ -719,6 +728,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
719728
--disable-perf
720729
--disable-efa
721730
--disable-mrail
731+
--with-cuda=no
732+
--disable-uffd-monitor
722733
--disable-verbs > /dev/null
723734
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/thirdparty/libfabric
724735
)
@@ -751,11 +762,23 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
751762
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libfabric.a)
752763
endif()
753764

765+
if (BUILD_VINEYARD_TESTS)
766+
include("cmake/FindGTest.cmake")
767+
endif()
768+
754769
# boost is only required by some components
755770
if(BUILD_VINEYARD_SERVER OR BUILD_VINEYARD_IO OR BUILD_VINEYARD_GRAPH)
756771
find_boost()
757772
endif()
758773

774+
if(BUILD_VINEYARD_LLM_CACHE)
775+
find_gflags()
776+
endif()
777+
778+
if (ENABLE_VINEYARD_MONITOR)
779+
add_definitions(-DENABLE_VINEYARD_MONITOR)
780+
endif()
781+
759782
# build vineyardd
760783
if(BUILD_VINEYARD_SERVER)
761784
find_gflags()
@@ -844,8 +867,13 @@ if(BUILD_VINEYARD_SERVER)
844867
install_vineyard_target(vineyardd)
845868
if(NOT BUILD_SHARED_LIBS)
846869
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
847-
target_compile_options(vineyardd PRIVATE -static-libgcc -static-libstdc++ -Os)
848-
target_add_link_options(vineyardd PRIVATE OPTIONS -static-libgcc -static-libstdc++ -Os)
870+
if (LINK_STATIC_LIBC)
871+
target_compile_options(vineyardd PRIVATE -static-libgcc -static-libstdc++ -Os)
872+
target_add_link_options(vineyardd PRIVATE OPTIONS -static-libgcc -static-libstdc++ -Os)
873+
else()
874+
target_compile_options(vineyardd PRIVATE -Os)
875+
target_add_link_options(vineyardd PRIVATE OPTIONS -Os)
876+
endif()
849877
endif()
850878
target_link_libraries(vineyardd PRIVATE ${GRPC_GRPC++_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
851879
endif()
@@ -1072,6 +1100,11 @@ if(BUILD_VINEYARD_LLM_CACHE)
10721100
list(APPEND VINEYARD_INSTALL_LIBS vineyard_llm_cache)
10731101
endif()
10741102

1103+
if(BUILD_VLLM_CACHE)
1104+
include("cmake/FindAIO.cmake")
1105+
add_subdirectory(modules/vllm-kv-cache)
1106+
endif()
1107+
10751108
if(BUILD_VINEYARD_TESTS)
10761109
add_subdirectory(test)
10771110
endif()

cmake/FindAIO.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# FindAIO.cmake
2+
3+
# Try to find the AIO library
4+
# Define the following cached variables:
5+
# AIO_FOUND - Was AIO found?
6+
# AIO_INCLUDE_DIRS - Where to find the AIO includes
7+
# AIO_LIBRARIES - The libraries needed to use AIO
8+
9+
set(AIO_HOME $ENV{AIO_HOME})
10+
11+
find_path (AIO_INCLUDE_DIRS
12+
NAMES libaio.h
13+
PATHS ${AIO_HOME}/include /usr/local/include /usr/include
14+
)
15+
16+
find_library (AIO_LIBRARIES
17+
NAMES aio
18+
PATHS ${AIO_HOME}/lib /usr/local/lib /usr/lib/x86_64-linux-gnu
19+
)
20+
21+
include (FindPackageHandleStandardArgs)
22+
find_package_handle_standard_args(AIO DEFAULT_MSG
23+
AIO_INCLUDE_DIRS AIO_LIBRARIES)
24+
25+
if (AIO_FOUND)
26+
add_library(AIO::aio SHARED IMPORTED)
27+
set_target_properties(AIO::aio PROPERTIES
28+
INTERFACE_INCLUDE_DIRECTORIES "${AIO_INCLUDE_DIRS}"
29+
IMPORTED_LOCATION "${AIO_LIBRARIES}"
30+
INTERFACE_COMPILE_DEFINITIONS "CMAKE_INCLUDE"
31+
)
32+
endif()
33+
34+
mark_as_advanced(AIO_INCLUDE_DIRS AIO_LIBRARIES)

cmake/FindGFlags.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
include(FindPackageHandleStandardArgs)
2020

21-
set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")
21+
set(GFLAGS_ROOT_DIR $ENV{GFLAGS_ROOT_DIR} CACHE PATH "Folder contains Gflags")
2222

2323
# We are testing only a couple of files in the include directories
2424
if(WIN32)
2525
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
2626
PATHS ${GFLAGS_ROOT_DIR}/src/windows)
2727
else()
2828
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
29-
PATHS ${GFLAGS_ROOT_DIR})
29+
HINTS ${GFLAGS_ROOT_DIR}/include)
3030
endif()
3131

3232
if(MSVC)
@@ -42,7 +42,9 @@ if(MSVC)
4242

4343
set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG})
4444
else()
45-
find_library(GFLAGS_LIBRARY gflags)
45+
find_library(GFLAGS_LIBRARY gflags
46+
HINTS ${GFLAGS_ROOT_DIR}
47+
PATH_SUFFIXES lib)
4648
endif()
4749

4850
find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)

cmake/FindGTest.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# FindGTest.cmake
2+
3+
# Try to find the GTest library
4+
# Define the following cached variables:
5+
# GTest_FOUND - Was GTest found?
6+
# GTest_INCLUDE_DIRS - Where to find the GTest includes
7+
# GTest_LIBRARIES - The libraries needed to use GTest
8+
9+
set(GTEST_HOME $ENV{GTEST_HOME})
10+
11+
find_path (GTEST_INCLUDE_DIRS
12+
NAMES gtest/gtest.h
13+
PATHS ${GTEST_HOME}/include /usr/local/include /usr/include
14+
)
15+
16+
find_library (GTEST_LIBRARIES
17+
NAMES gtest gtest_main
18+
PATHS ${GTEST_HOME}/lib /usr/local/lib /usr/lib
19+
)
20+
21+
include (FindPackageHandleStandardArgs)
22+
find_package_handle_standard_args(GTEST DEFAULT_MSG
23+
GTEST_INCLUDE_DIRS GTEST_LIBRARIES)
24+
25+
message("GTest include dirs: ${GTEST_INCLUDE_DIRS} GTest libraries: ${GTEST_LIBRARIES}")
26+
27+
if (GTEST_FOUND)
28+
add_library(GTEST::gtest SHARED IMPORTED)
29+
set_target_properties(GTEST::gtest PROPERTIES
30+
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}"
31+
IMPORTED_LOCATION "${GTEST_LIBRARIES}"
32+
INTERFACE_COMPILE_DEFINITIONS "CMAKE_INCLUDE"
33+
)
34+
else()
35+
message(WARNING "GTest not found.")
36+
set(GTEST_INCLUDE_DIRS "")
37+
set(GTEST_LIBRARIES "")
38+
endif()
39+
40+
mark_as_advanced(GTEST_INCLUDE_DIRS GTEST_LIBRARIES)

cmake/FindGlog.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
include(FindPackageHandleStandardArgs)
2020

21-
set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")
21+
set(GLOG_ROOT_DIR $ENV{GLOG_ROOT_DIR} CACHE PATH "Folder contains Google glog")
2222

2323
if(WIN32)
2424
find_path(GLOG_INCLUDE_DIR glog/logging.h
2525
PATHS ${GLOG_ROOT_DIR}/src/windows)
2626
else()
2727
find_path(GLOG_INCLUDE_DIR glog/logging.h
28-
PATHS ${GLOG_ROOT_DIR})
28+
HINTS ${GLOG_ROOT_DIR}/include)
2929
endif()
3030

3131
if(MSVC)
@@ -40,10 +40,12 @@ if(MSVC)
4040
set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG})
4141
else()
4242
find_library(GLOG_LIBRARY glog
43-
PATHS ${GLOG_ROOT_DIR}
43+
HINTS ${GLOG_ROOT_DIR}
4444
PATH_SUFFIXES lib lib64)
4545
endif()
4646

47+
message("GLOG_ROOT_DIR: ${GLOG_ROOT_DIR}, GLOG_INCLUDE_DIR: ${GLOG_INCLUDE_DIR}, GLOG_LIBRARY: ${GLOG_LIBRARY}")
48+
4749
find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY)
4850

4951
if(GLOG_FOUND)

cmake/FindLibUnwind.cmake

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,32 @@
1414
# LIBUNWIND_LIBRARIES - The libraries needed to use libunwind
1515
# LIBUNWIND_INCLUDE_DIR - Location of unwind.h and libunwind.h
1616

17-
FIND_PATH(LIBUNWIND_INCLUDE_DIR libunwind.h)
18-
if(NOT LIBUNWIND_INCLUDE_DIR)
19-
message(STATUS "failed to find libunwind.h")
20-
elseif(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
21-
message(STATUS "libunwind.h was found, but unwind.h was not found in that directory.")
22-
SET(LIBUNWIND_INCLUDE_DIR "")
23-
endif()
17+
set(UNWIND_HOME $ENV{UNWIND_HOME})
18+
19+
if (UNWIND_HOME)
20+
find_path (LIBUNWIND_INCLUDE_DIR
21+
NAMES libunwind.h
22+
PATHS ${UNWIND_HOME}/include
23+
)
24+
find_library (LIBUNWIND_LIBRARIES
25+
NAMES unwind
26+
PATHS ${UNWIND_HOME}/lib
27+
)
28+
else()
29+
FIND_PATH(LIBUNWIND_INCLUDE_DIR libunwind.h)
30+
if(NOT LIBUNWIND_INCLUDE_DIR)
31+
message(STATUS "failed to find libunwind.h")
32+
elseif(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
33+
message(STATUS "libunwind.h was found, but unwind.h was not found in that directory.")
34+
SET(LIBUNWIND_INCLUDE_DIR "")
35+
endif()
2436

25-
FIND_LIBRARY(LIBUNWIND_GENERIC_LIBRARY "unwind")
26-
if(NOT LIBUNWIND_GENERIC_LIBRARY)
27-
MESSAGE(STATUS "failed to find unwind generic library")
37+
FIND_LIBRARY(LIBUNWIND_GENERIC_LIBRARY "unwind")
38+
if(NOT LIBUNWIND_GENERIC_LIBRARY)
39+
MESSAGE(STATUS "failed to find unwind generic library")
40+
endif()
41+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY})
2842
endif()
29-
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY})
3043

3144
# For some reason, we have to link to two libunwind shared object files:
3245
# one arch-specific and one not.
@@ -41,15 +54,32 @@ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
4154
endif()
4255

4356
if(LIBUNWIND_ARCH)
44-
FIND_LIBRARY(LIBUNWIND_SPECIFIC_LIBRARY "unwind-${LIBUNWIND_ARCH}")
45-
if(NOT LIBUNWIND_SPECIFIC_LIBRARY)
46-
MESSAGE(STATUS "failed to find unwind-${LIBUNWIND_ARCH}")
47-
endif()
48-
if(LIBUNWIND_SPECIFIC_LIBRARY)
49-
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
57+
if (UNWIND_HOME)
58+
find_library (LIBUNWIND_SPECIFIC_LIBRARY
59+
NAMES unwind-${LIBUNWIND_ARCH}
60+
PATHS ${UNWIND_HOME}/lib
61+
)
62+
if (NOT LIBUNWIND_SPECIFIC_LIBRARY)
63+
message(STATUS "failed to find unwind-${LIBUNWIND_ARCH}")
64+
endif()
65+
if (LIBUNWIND_SPECIFIC_LIBRARY)
66+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
67+
else()
68+
if(APPLE)
69+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES})
70+
endif()
71+
endif()
5072
else()
51-
if(APPLE)
52-
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES})
73+
FIND_LIBRARY(LIBUNWIND_SPECIFIC_LIBRARY "unwind-${LIBUNWIND_ARCH}")
74+
if(NOT LIBUNWIND_SPECIFIC_LIBRARY)
75+
MESSAGE(STATUS "failed to find unwind-${LIBUNWIND_ARCH}")
76+
endif()
77+
if(LIBUNWIND_SPECIFIC_LIBRARY)
78+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
79+
else()
80+
if(APPLE)
81+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES})
82+
endif()
5383
endif()
5484
endif()
5585
endif(LIBUNWIND_ARCH)

0 commit comments

Comments
 (0)