-
Notifications
You must be signed in to change notification settings - Fork 35
Initial implementation of SVS Runtime package #208
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
base: main
Are you sure you want to change the base?
Changes from all commits
b2d6285
71a3f83
3f95bab
111448e
0ca8bbf
923e002
0c490d1
0067a3a
54fe550
4d74c8b
e42d806
8e3b15f
0a9c3d6
32d3d9a
f8791dc
473a74b
8966732
3bbc18c
0540d00
a8361cd
d5d6956
883266f
dc6aa10
ec1cce5
696519b
35afd2a
5b2707e
fdcffe2
ae0f97d
5ab0758
f7fbdfc
ad9bd20
1a1e2df
a551e9b
bcd7cb3
1d100af
c2181e2
73c18ab
c7e039f
597c4b5
b2c61ba
fc11a3a
3e25ae3
33bbe21
dfc84a8
a65a641
1f20a5b
1c92666
df8630f
bb0d1b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Copyright 2025 Intel Corporation | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Build C++ Runtime Bindings | ||
| run-name: ${{ github.event.inputs.run_name || github.event.pull_request.title }} | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_name: | ||
| description: "Custom workflow name" | ||
| required: false | ||
| submodule_url: | ||
| description: "Submodule url (e.g. https://github.com/intel/ScalableVectorSearch.git)" | ||
| required: false | ||
| submodule_sha: | ||
| description: "Submodule sha/branch" | ||
| required: false | ||
| pull_request: | ||
|
|
||
| # This allows a subsequently queued workflow run to interrupt previous runs | ||
| concurrency: | ||
| group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-cpp-runtime-bindings: | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Build Docker image | ||
| run: | | ||
| docker build -t svs-manylinux228:latest -f docker/x86_64/manylinux228/Dockerfile . | ||
|
|
||
| - name: Build libraries in Docker container | ||
| run: | | ||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/workspace \ | ||
| -w /workspace \ | ||
| svs-manylinux228:latest \ | ||
| /bin/bash -c "chmod +x docker/x86_64/build-cpp-runtime-bindings.sh && ./docker/x86_64/build-cpp-runtime-bindings.sh" | ||
|
|
||
| - name: Upload cpp runtime bindings artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: svs-cpp-runtime-bindings | ||
| path: svs-cpp-runtime-bindings.tar.gz | ||
| retention-days: 7 # Reduce retention due to size | ||
|
|
||
| test: | ||
| needs: build-cpp-runtime-bindings | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Build Docker image | ||
| run: | | ||
| docker build -t svs-manylinux228:latest -f docker/x86_64/manylinux228/Dockerfile . | ||
|
|
||
| # Need to download for a new job | ||
| - name: Download shared libraries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: svs-cpp-runtime-bindings | ||
| path: runtime_lib | ||
|
|
||
| - name: List available artifacts | ||
| run: | | ||
| ls -la runtime_lib/ | ||
|
|
||
| - name: Test in Docker container | ||
| run: | | ||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/workspace \ | ||
| -v ${{ github.workspace }}/runtime_lib:/runtime_lib \ | ||
| -w /workspace \ | ||
| svs-manylinux228:latest \ | ||
| /bin/bash -c "chmod +x docker/x86_64/test-cpp-runtime-bindings.sh && ./docker/x86_64/test-cpp-runtime-bindings.sh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| # Copyright 2025 Intel Corporation | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| cmake_minimum_required(VERSION 3.21) | ||
| project(svs_runtime VERSION 0.0.10 LANGUAGES CXX) | ||
| set(TARGET_NAME svs_runtime) | ||
|
|
||
| set(SVS_RUNTIME_HEADERS | ||
| include/svs/runtime/version.h | ||
| include/svs/runtime/api_defs.h | ||
| include/svs/runtime/training.h | ||
| include/svs/runtime/vamana_index.h | ||
| include/svs/runtime/dynamic_vamana_index.h | ||
| include/svs/runtime/flat_index.h | ||
| ) | ||
|
|
||
| set(SVS_RUNTIME_SOURCES | ||
| src/svs_runtime_utils.h | ||
| src/dynamic_vamana_index_impl.h | ||
| src/flat_index_impl.h | ||
| src/api_defs.cpp | ||
| src/training.cpp | ||
| src/vamana_index.cpp | ||
| src/dynamic_vamana_index.cpp | ||
| src/flat_index.cpp | ||
| ) | ||
|
|
||
| option(SVS_RUNTIME_ENABLE_LVQ_LEANVEC "Enable compilation of SVS runtime with LVQ and LeanVec support" ON) | ||
| if (SVS_RUNTIME_ENABLE_LVQ_LEANVEC) | ||
| message(STATUS "SVS runtime will be built with LVQ support") | ||
| else() | ||
| message(STATUS "SVS runtime will be built without LVQ or LeanVec support") | ||
| endif() | ||
|
|
||
| add_library(${TARGET_NAME} SHARED | ||
| ${SVS_RUNTIME_HEADERS} | ||
| ${SVS_RUNTIME_SOURCES} | ||
| ) | ||
|
|
||
| target_include_directories(${TARGET_NAME} PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
| ) | ||
|
|
||
| find_package(OpenMP REQUIRED) | ||
| target_link_libraries(${TARGET_NAME} PUBLIC OpenMP::OpenMP_CXX) | ||
|
|
||
| target_compile_options(${TARGET_NAME} PRIVATE | ||
| -DSVS_ENABLE_OMP=1 | ||
| -fvisibility=hidden | ||
| ) | ||
|
|
||
| if(UNIX AND NOT APPLE) | ||
| # Don't export 3rd-party symbols from the lib | ||
| target_link_options(${TARGET_NAME} PRIVATE "SHELL:-Wl,--exclude-libs,ALL") | ||
| endif() | ||
|
|
||
| target_compile_features(${TARGET_NAME} INTERFACE cxx_std_20) | ||
| set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${SVS_RUNTIME_HEADERS}") | ||
| set_target_properties(${TARGET_NAME} PROPERTIES CXX_STANDARD 20) | ||
| set_target_properties(${TARGET_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON) | ||
| set_target_properties(${TARGET_NAME} PROPERTIES CXX_EXTENSIONS OFF) | ||
| set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) | ||
|
|
||
| if(DEFINED SVS_LVQ_HEADER AND DEFINED SVS_LEANVEC_HEADER) | ||
| # expected that pre-defined headers are implementation headers | ||
| message(STATUS "Using pre-defined LVQ header: ${SVS_LVQ_HEADER}") | ||
| message(STATUS "Using pre-defined LeanVec header: ${SVS_LEANVEC_HEADER}") | ||
| else() | ||
| set(SVS_LVQ_HEADER "svs/extensions/vamana/lvq.h") | ||
| set(SVS_LEANVEC_HEADER "svs/extensions/vamana/leanvec.h") | ||
| endif() | ||
|
|
||
| if ((SVS_RUNTIME_ENABLE_LVQ_LEANVEC)) | ||
| if(RUNTIME_BINDINGS_PRIVATE_SOURCE_BUILD) | ||
| message(STATUS "Building directly from private sources") | ||
| target_link_libraries(${TARGET_NAME} PRIVATE | ||
| svs::svs | ||
| ) | ||
| link_mkl_static(${TARGET_NAME}) | ||
| elseif(TARGET svs_static_library) | ||
| # Links to SVS static library built as part of the main SVS build | ||
| target_link_libraries(${TARGET_NAME} PRIVATE | ||
| svs_devel | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is svs_devel? Is there a reason linking here would be different than lines 131-135? |
||
| svs_static_library | ||
| svs_compile_options | ||
| svs_x86_options_base | ||
| ) | ||
| elseif(TARGET svs::svs) | ||
| message(FATAL_ERROR | ||
| "Pre-built LVQ/LeanVec SVS library cannot be used in SVS main build. " | ||
| "Please build SVS Runtime using bindins/cpp directory as CMake source root." | ||
| ) | ||
| else() | ||
| # Links to LTO-enabled static library, requires GCC/G++ 11.2 | ||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.2" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.3") | ||
| set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v1.0.0-dev/svs-shared-library-1.0.0-NIGHTLY-20251107-773.tar.gz" | ||
| CACHE STRING "URL to download SVS shared library") | ||
| else() | ||
| message(WARNING | ||
| "Pre-built LVQ/LeanVec SVS library requires GCC/G++ v.11.2 to apply LTO optimizations." | ||
| "Current compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" | ||
| ) | ||
| set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v1.0.0-dev/svs-shared-library-1.0.0-NIGHTLY-20251017-faiss.tar.gz") | ||
| endif() | ||
| include(FetchContent) | ||
| FetchContent_Declare( | ||
| svs | ||
| URL ${SVS_URL} | ||
| ) | ||
| FetchContent_MakeAvailable(svs) | ||
| list(APPEND CMAKE_PREFIX_PATH "${svs_SOURCE_DIR}") | ||
| find_package(svs REQUIRED) | ||
| target_link_libraries(${TARGET_NAME} PRIVATE | ||
| svs::svs | ||
| svs::svs_compile_options | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice when svs::svs_compile_options is not included, performance decreases. I tried it because we do not link it in https://github.com/RedisAI/VectorSimilarity/blob/main/src/VecSim/CMakeLists.txt#L47-L52 - should we?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try it and check VecSim performance. |
||
| svs::svs_static_library | ||
| ) | ||
| endif() | ||
| target_compile_definitions(${TARGET_NAME} PRIVATE | ||
| PUBLIC "SVS_LVQ_HEADER=\"${SVS_LVQ_HEADER}\"" | ||
| PUBLIC "SVS_LEANVEC_HEADER=\"${SVS_LEANVEC_HEADER}\"" | ||
| ) | ||
| else() | ||
| # Include the SVS library directly if needed. | ||
| if (NOT TARGET svs::svs) | ||
| add_subdirectory("../.." "${CMAKE_CURRENT_BINARY_DIR}/svs") | ||
| endif() | ||
| target_link_libraries(${TARGET_NAME} PRIVATE | ||
| svs::svs | ||
| svs_compile_options | ||
| svs_x86_options_base | ||
| ) | ||
| endif() | ||
|
|
||
| # installing | ||
| include(GNUInstallDirs) | ||
|
|
||
| set(SVS_RUNTIME_EXPORT_NAME ${TARGET_NAME}) | ||
| set(VERSION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/${SVS_RUNTIME_EXPORT_NAME}ConfigVersion.cmake") | ||
| set(SVS_RUNTIME_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/svs_runtime) | ||
| set(SVS_RUNTIME_COMPONENT_NAME "Runtime") | ||
|
|
||
| install(TARGETS ${TARGET_NAME} | ||
| EXPORT ${SVS_RUNTIME_EXPORT_NAME} | ||
| COMPONENT ${SVS_RUNTIME_COMPONENT_NAME} | ||
| LIBRARY DESTINATION lib | ||
| PUBLIC_HEADER DESTINATION include/svs/runtime | ||
| INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
| ) | ||
|
|
||
| install(DIRECTORY include/svs/runtime | ||
| COMPONENT ${SVS_RUNTIME_COMPONENT_NAME} | ||
| DESTINATION include/svs | ||
| FILES_MATCHING PATTERN "*.h" | ||
| ) | ||
|
|
||
| install(EXPORT ${SVS_RUNTIME_EXPORT_NAME} | ||
| COMPONENT ${SVS_RUNTIME_COMPONENT_NAME} | ||
| NAMESPACE svs:: | ||
| DESTINATION ${SVS_RUNTIME_CONFIG_INSTALL_DIR} | ||
| ) | ||
|
|
||
| include(CMakePackageConfigHelpers) | ||
| configure_package_config_file( | ||
| "${CMAKE_CURRENT_LIST_DIR}/runtimeConfig.cmake.in" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/${SVS_RUNTIME_EXPORT_NAME}Config.cmake" | ||
| INSTALL_DESTINATION "${SVS_RUNTIME_CONFIG_INSTALL_DIR}" | ||
| ) | ||
|
|
||
| # Don't make compatibility guarantees until we reach a compatibility milestone. | ||
| write_basic_package_version_file( | ||
| ${VERSION_CONFIG} | ||
| VERSION ${PROJECT_VERSION} | ||
| COMPATIBILITY ExactVersion | ||
| ) | ||
|
|
||
| install(FILES | ||
| "${CMAKE_CURRENT_BINARY_DIR}/${SVS_RUNTIME_EXPORT_NAME}Config.cmake" | ||
| "${VERSION_CONFIG}" | ||
| COMPONENT ${SVS_RUNTIME_COMPONENT_NAME} | ||
| DESTINATION "${SVS_RUNTIME_CONFIG_INSTALL_DIR}" | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.