Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a8c862f
decouple distance type
divyegala Nov 3, 2025
ac63cd1
more updates
divyegala Nov 3, 2025
1b6a045
more fixes
divyegala Nov 3, 2025
681c457
fix
divyegala Nov 3, 2025
b677206
add patch to faiss
divyegala Nov 3, 2025
f23bb38
one more cast
divyegala Nov 3, 2025
83625ef
combine faiss patches
divyegala Nov 4, 2025
692cfc5
correct path
divyegala Nov 4, 2025
aae2a97
install c headers
divyegala Nov 4, 2025
8055f35
correct dir structure
divyegala Nov 4, 2025
1605aa3
separate components
divyegala Nov 4, 2025
04558a6
find cuvs_cpp_headers in python
divyegala Nov 4, 2025
badbdbe
remove breaking change, make cuvs and cuvs_static separate packages
divyegala Nov 4, 2025
3f67d1a
revert
divyegala Nov 4, 2025
76fe703
put headers in main export list
divyegala Nov 4, 2025
33200be
merge upstream
divyegala Nov 4, 2025
1703c00
remove c api install from static conda package
divyegala Nov 4, 2025
afe06a8
Merge branch 'main' into cpp-headers-static-component
divyegala Nov 7, 2025
ad0cd41
Correct issues in adding cpp-headers target
robertmaynard Nov 13, 2025
ed34f0b
Correct issues found in CI / code review
robertmaynard Nov 14, 2025
ff2da42
remove out of date task comment
robertmaynard Nov 14, 2025
a35df39
Restore cuvs_cpp_headers
robertmaynard Nov 14, 2025
3df7f5f
Correct style issues found by CI
robertmaynard Nov 14, 2025
e201577
Correct breaks in find_package(cuvs) found by devcontainers
robertmaynard Nov 14, 2025
c682ecd
Refactor generate_cuvs_export to auto bring in cuvs::cuvs_static
robertmaynard Nov 17, 2025
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
122 changes: 122 additions & 0 deletions conda/recipes/libcuvs/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,61 @@ cache:
- mkl-devel =2023

outputs:
- package:
name: libcuvs-headers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very close to what we would want in a -dev package but perhaps reversed -- where libcuvs would be only runtime libs while libcuvs-dev would be runtime libs plus headers. See proposal in rapidsai/build-planning#46.

What is our main goal in splitting out the headers? I am curious if that approach for -dev packages still makes sense or not. It might be different in a world with JIT where runtime always requires headers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the headers for both the cuvs and cuvs-static packages to work in a -dev sense, but don't want to have two conda packages that clobber the same headers so that is why they are in cpp-headers.

The extra complexity is that I am also planning for splitting out the C API from the libcuvs conda package. That would allow us to have libcuvs-c-dev which only installs the libcuvs.so, libcuvs_c.so and the C headers

In most cases, ${lib}-dev will likely just be a metapackage that pulls in ${lib} and ${lib}-headers

It looks like we match the proposal in 46

version: ${{ version }}
build:
string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }}
dynamic_linking:
overlinking_behavior: "error"
prefix_detection:
ignore_binary_files: True
script:
content: |
cmake --install cpp/build --component cuvs_cpp_headers
requirements:
build:
- cmake ${{ cmake_version }}
- ${{ stdlib("c") }}
host:
- librmm =${{ minor_version }}
- libraft-headers =${{ minor_version }}
- nccl ${{ nccl_version }}
- cuda-version =${{ cuda_version }}
- cuda-cudart-dev
- cuda-profiler-api
- libcublas-dev
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
run:
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- libraft-headers =${{ minor_version }}
- librmm =${{ minor_version }}
- nccl
- cuda-cudart
- libcublas
- libcurand
- libcusolver
- libcusparse
ignore_run_exports:
by_name:
- cuda-cudart
- cuda-version
- libaio
- libboost
- libcublas
- libcurand
- libcusolver
- libcusparse
- librmm
- mkl
- nccl
about:
homepage: ${{ load_from_file("python/libcuvs/pyproject.toml").project.urls.Homepage }}
license: ${{ load_from_file("python/libcuvs/pyproject.toml").project.license.text }}
summary: ${{ load_from_file("python/libcuvs/pyproject.toml").project.description }}

- package:
name: libcuvs
version: ${{ version }}
Expand All @@ -97,6 +152,65 @@ outputs:
- cmake ${{ cmake_version }}
- ${{ stdlib("c") }}
host:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- librmm =${{ minor_version }}
- libraft-headers =${{ minor_version }}
- nccl ${{ nccl_version }}
- cuda-version =${{ cuda_version }}
- cuda-cudart-dev
- cuda-profiler-api
- libcublas-dev
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
run:
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- libraft-headers =${{ minor_version }}
- librmm =${{ minor_version }}
- nccl
- cuda-cudart
- libcublas
- libcurand
- libcusolver
- libcusparse
ignore_run_exports:
by_name:
- cuda-cudart
- cuda-version
- libaio
- libboost
- libcublas
- libcurand
- libcusolver
- libcusparse
- librmm
- mkl
- nccl
about:
homepage: ${{ load_from_file("python/libcuvs/pyproject.toml").project.urls.Homepage }}
license: ${{ load_from_file("python/libcuvs/pyproject.toml").project.license.text }}
summary: ${{ load_from_file("python/libcuvs/pyproject.toml").project.description }}

- package:
name: libcuvs-static
version: ${{ version }}
build:
string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }}
dynamic_linking:
overlinking_behavior: "error"
prefix_detection:
ignore_binary_files: True
script:
content: |
cmake --install cpp/build --component cuvs_static
cmake --install cpp/build --component hnswlib
requirements:
build:
- cmake ${{ cmake_version }}
- ${{ stdlib("c") }}
host:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- librmm =${{ minor_version }}
- libraft-headers =${{ minor_version }}
- nccl ${{ nccl_version }}
Expand All @@ -109,7 +223,9 @@ outputs:
- libcusparse-dev
run:
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- libraft-headers =${{ minor_version }}
- librmm =${{ minor_version }}
- nccl
- cuda-cudart
- libcublas
Expand Down Expand Up @@ -152,6 +268,7 @@ outputs:
- librmm =${{ minor_version }}
- libraft-headers =${{ minor_version }}
- nccl ${{ nccl_version }}
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- cuda-version =${{ cuda_version }}
- openblas # required by some CPU algos in benchmarks
Expand All @@ -162,6 +279,7 @@ outputs:
- libcusolver-dev
- libcusparse-dev
run:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- libraft-headers =${{ minor_version }}
Expand Down Expand Up @@ -237,6 +355,7 @@ outputs:
- ninja
- ${{ stdlib("c") }}
host:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- cuda-version =${{ cuda_version }}
- libraft-headers =${{ minor_version }}
Expand All @@ -249,6 +368,7 @@ outputs:
- libcusolver-dev
- libcusparse-dev
run:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- nccl
Expand Down Expand Up @@ -298,6 +418,7 @@ outputs:
- cmake ${{ cmake_version }}
- ${{ stdlib("c") }}
host:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- cuda-cudart-dev
- cuda-profiler-api
Expand All @@ -317,6 +438,7 @@ outputs:
- libboost-devel =1.87
- mkl-devel =2023
run:
- ${{ pin_subpackage("libcuvs-headers", exact=True) }}
- ${{ pin_subpackage("libcuvs", exact=True) }}
- ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }}
- cuda-cudart
Expand Down
105 changes: 58 additions & 47 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(BUILD_SHARED_LIBS "Build cuvs shared libraries" ON)
option(BUILD_TESTS "Build cuvs unit-tests" ON)
option(INSTALL_CPP_HEADERS "Install cuVS C++ headers" ON)
option(BUILD_C_LIBRARY "Build cuVS C API library" ON)
option(BUILD_CUVS_BENCH "Build cuVS ann benchmarks" OFF)
option(BUILD_CAGRA_HNSWLIB "Build CAGRA+hnswlib interface" ON)
Expand All @@ -70,10 +71,12 @@ if(BUILD_CPU_ONLY)
set(BUILD_TESTS OFF)
set(BUILD_C_LIBRARY OFF)
set(BUILD_CAGRA_HNSWLIB OFF)
set(INSTALL_CPP_HEADERS OFF)
elseif(NOT BUILD_SHARED_LIBS)
set(BUILD_TESTS OFF)
set(BUILD_C_LIBRARY OFF)
set(BUILD_CAGRA_HNSWLIB OFF)
set(INSTALL_CPP_HEADERS OFF)
endif()

if(NOT BUILD_SHARED_LIBS AND CUVS_COMPILE_DYNAMIC_ONLY)
Expand All @@ -88,9 +91,11 @@ set(_cuvs_lib_targets cuvs cuvs_static)
if(CUVS_COMPILE_DYNAMIC_ONLY)
set(cuvs_compile_mode "shared_only")
set(_cuvs_lib_targets cuvs)
set(INSTALL_CPP_HEADERS ON)
elseif(NOT BUILD_SHARED_LIBS)
set(cuvs_compile_mode "static_only")
set(_cuvs_lib_targets cuvs_static)
set(INSTALL_CPP_HEADERS ON)
endif()

# Needed because GoogleBenchmark changes the state of FindThreads.cmake, causing subsequent runs to
Expand Down Expand Up @@ -207,6 +212,18 @@ endif()
# ##################################################################################################
# * cuvs ---------------------------------------------------------------------
if(NOT BUILD_CPU_ONLY)
if(INSTALL_CPP_HEADERS)
add_library(cuvs_cpp_headers INTERFACE)
add_library(cuvs::cuvs_cpp_headers ALIAS cuvs_cpp_headers)
target_include_directories(
cuvs_cpp_headers
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(cuvs_cpp_headers INTERFACE raft::raft rmm::rmm)
endif()

add_library(
cuvs-cagra-search OBJECT
src/neighbors/cagra_search_float.cu
Expand Down Expand Up @@ -300,10 +317,7 @@ if(NOT BUILD_CPU_ONLY)
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(cuvs-cagra-search PRIVATE raft::raft)
target_include_directories(
cuvs-cagra-search PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
)
target_link_libraries(cuvs-cagra-search PRIVATE raft::raft cuvs::cuvs_cpp_headers)
target_compile_options(
cuvs-cagra-search PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUVS_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUVS_CUDA_FLAGS}>"
Expand Down Expand Up @@ -545,16 +559,10 @@ if(NOT BUILD_CPU_ONLY)

target_link_libraries(
cuvs_objs
PRIVATE raft::raft rmm::rmm ${CUVS_CTK_MATH_DEPENDENCIES}
PRIVATE raft::raft rmm::rmm cuvs::cuvs_cpp_headers ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX> $<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>
)

target_include_directories(
cuvs_objs
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
INTERFACE "$<INSTALL_INTERFACE:include>"
)

# Endian detection
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
Expand Down Expand Up @@ -613,17 +621,11 @@ if(NOT BUILD_CPU_ONLY)
$<$<BOOL:${CUVS_NVTX}>:NVTX_ENABLED>
)

target_include_directories(
cuvs
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)

target_link_libraries(
cuvs
PUBLIC rmm::rmm
raft::raft
cuvs::cuvs_cpp_headers
${CUVS_CTK_MATH_DEPENDENCIES}
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:NCCL::NCCL>>
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>>
Expand Down Expand Up @@ -675,16 +677,11 @@ SECTIONS
# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(cuvs_static PRIVATE $<HOST_LINK:${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld>)

target_include_directories(
cuvs_static
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(
cuvs_static
PUBLIC rmm::rmm
raft::raft
cuvs::cuvs_cpp_headers
${CUVS_CTK_MATH_DEPENDENCIES}
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:NCCL::NCCL>>
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>>
Expand Down Expand Up @@ -730,20 +727,43 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
include(GNUInstallDirs)
include(CPack)

install(
TARGETS ${_cuvs_lib_targets}
DESTINATION ${lib_dir}
COMPONENT cuvs
EXPORT cuvs-exports
)
if(TARGET cuvs_cpp_headers)
install(
TARGETS cuvs_cpp_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT cuvs_cpp_headers
EXPORT cuvs-exports
)

install(
DIRECTORY include/cuvs
COMPONENT cuvs
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cuvs/version_config.h
COMPONENT cuvs_cpp_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cuvs
)
endif()

if(BUILD_C_LIBRARY)
if(TARGET cuvs)
install(
TARGETS cuvs
DESTINATION ${lib_dir}
COMPONENT cuvs
EXPORT cuvs-exports
)
endif()

if(TARGET cuvs_static)
install(
TARGETS cuvs_static
DESTINATION ${lib_dir}
COMPONENT cuvs_static
EXPORT cuvs-static-exports
)

list(APPEND cuvs_components cuvs_static)
list(APPEND cuvs_export_sets cuvs-static-exports)
endif()

if(TARGET cuvs_c)
install(
TARGETS cuvs_c
DESTINATION ${lib_dir}
Expand All @@ -762,18 +782,9 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
COMPONENT cuvs
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cuvs/core/
)
endif()

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cuvs/version_config.h
COMPONENT cuvs
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cuvs
)

if(TARGET cuvs_c)
list(APPEND cuvs_components c_api)
list(APPEND cuvs_export_sets cuvs-c-exports)
set(CUVS_C_TARGET cuvs_c)
endif()

# Use `rapids_export` for 22.04 as it will have COMPONENT support
Expand All @@ -782,7 +793,7 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
EXPORT_SET cuvs-exports
COMPONENTS ${cuvs_components}
COMPONENTS_EXPORT_SET ${cuvs_export_sets}
GLOBAL_TARGETS cuvs ${CUVS_C_TARGET}
GLOBAL_TARGETS cuvs cuvs_cpp_headers cuvs_static cuvs_c
NAMESPACE cuvs::
)

Expand All @@ -793,7 +804,7 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
EXPORT_SET cuvs-exports
COMPONENTS ${cuvs_components}
COMPONENTS_EXPORT_SET ${cuvs_export_sets}
GLOBAL_TARGETS cuvs ${CUVS_C_TARGET}
GLOBAL_TARGETS cuvs cuvs_cpp_headers cuvs_static cuvs_c
NAMESPACE cuvs::
)
endif()
Expand Down
Loading