Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
4a99eaa
[FlowANN step 1/12] Refactor CAGRA traversal to accept graph providers
ZhaoHaoRu Oct 29, 2026
b29b06d
[FlowANN step 2/12] Add graph storage and the CUDA-copy queue runtime
ZhaoHaoRu Oct 29, 2026
befcb9e
[FlowANN step 3/12] Add optional GDRCopy queue transport
ZhaoHaoRu Oct 29, 2026
56f36a4
[FlowANN step 4/12] Add single-CTA tiered graph search for dense vectors
ZhaoHaoRu Oct 29, 2026
8034510
[FlowANN step 5/12] Add multi-CTA tiered graph search
ZhaoHaoRu Oct 29, 2026
4af0ec1
[FlowANN step 6/12] Add dense index construction with grouping and re…
ZhaoHaoRu Oct 29, 2026
b6a1624
[FlowANN step 7/12] Add VPQ vector compression to tiered construction…
ZhaoHaoRu Oct 29, 2026
282a915
Fix provider candidate tails and preserve resident invalid IDs
ZhaoHaoRu Nov 2, 2026
afe8a2c
Merge FlowANN step 1 review fixes into step 2
ZhaoHaoRu Nov 2, 2026
a75bd4c
Add regressions for graph replacement and context moves
ZhaoHaoRu Nov 2, 2026
cf42977
Keep graph replacement transactional and sessions stable across conte…
ZhaoHaoRu Nov 2, 2026
7d46ec7
Complete invalid queue requests and unblock GPU waiters on poller fai…
ZhaoHaoRu Nov 2, 2026
eb61427
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
ae20f4b
Fix GDRCopy page-sized mappings and installed runtime discovery
ZhaoHaoRu Nov 2, 2026
48b0b68
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
582905e
Bound pending requests, retry parents, and guard search resources
ZhaoHaoRu Nov 2, 2026
33aa307
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
ce7f3f0
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
9bef370
Account for static shared memory and select supported AUTO search
ZhaoHaoRu Nov 2, 2026
8f24b79
Pass clamped graph degrees to iterative construction and copy its act…
ZhaoHaoRu Nov 2, 2026
118daac
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
f1eba3d
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
bd869ef
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
204933f
Test pending-ring and device-queue backpressure and empty search
ZhaoHaoRu Nov 2, 2026
0bb7a1a
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
c062e4b
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
084a207
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
5a7ec4b
Initialize queue capacity in the backpressure regression fixture
ZhaoHaoRu Nov 2, 2026
886032a
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
a5ea9ea
Cover iterative construction with degrees larger than the dataset
ZhaoHaoRu Nov 2, 2026
7e24549
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
e1a9fdc
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
2628058
Rate-limit emergency host flag reads to preserve queue throughput
ZhaoHaoRu Nov 2, 2026
e3298c5
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
cf53ec0
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
7eda224
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
04c20d0
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
6050244
Use the native CUDA stream handle in the regression kernel launch
ZhaoHaoRu Nov 2, 2026
742c612
Use the native CUDA stream handle in the regression kernel launch
ZhaoHaoRu Nov 2, 2026
b128ea3
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
a3a8be9
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
650966e
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
8144d20
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
c4a7f2c
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
641d2d1
Defer emergency host reads until normal queue completion can progress
ZhaoHaoRu Nov 2, 2026
a3f0d3c
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
15ae502
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
9d94fc9
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
c22f9f2
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
b2d14ab
Use the shared RAPIDS formatting configuration for CMake
ZhaoHaoRu Nov 2, 2026
8323bb4
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
c1b0530
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
90e7fc3
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
8c5beac
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
3dda182
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
539ed96
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
6b790d9
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
87862d5
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
1ed13a9
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
c107679
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
52b9968
Format FlowANN review corrections with repository tools
ZhaoHaoRu Nov 2, 2026
e556cc3
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
38194a7
Limit CMake changes to the GDRCopy runtime path and FlowANN source in…
ZhaoHaoRu Nov 2, 2026
eae77b4
Limit CMake changes to the GDRCopy runtime path and FlowANN source in…
ZhaoHaoRu Nov 2, 2026
28d5045
Limit CMake changes to the GDRCopy runtime path and FlowANN source in…
ZhaoHaoRu Nov 2, 2026
fa8a038
Limit CMake changes to the GDRCopy runtime path and FlowANN source in…
ZhaoHaoRu Nov 2, 2026
a5f4081
Limit CMake changes to the GDRCopy runtime path and FlowANN source in…
ZhaoHaoRu Nov 2, 2026
8c68fbb
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
79fe023
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
c24f8b9
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
69ee46a
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
8e6ec90
Keep the initial iterative graph large enough for distinct neighbors
ZhaoHaoRu Nov 2, 2026
c4070c3
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
57a19b4
Clamp iterative degrees for ordinary and tiered construction callers
ZhaoHaoRu Nov 2, 2026
eea2950
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
adbc73f
Merge NVIDIA cuVS main into FlowANN step 1
ZhaoHaoRu Nov 2, 2026
231345e
Merge FlowANN step 1 review fixes into step 2
ZhaoHaoRu Nov 2, 2026
13eb469
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
65096d6
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
6f8412c
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
c23e038
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
b2b4ca5
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
73285d9
Adapt FlowANN step 2 to upstream dataset data and manifest views
ZhaoHaoRu Nov 2, 2026
c75dcca
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
6b31d32
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
14265f7
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
f33bc19
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
95d358a
Adapt FlowANN step 4 to upstream dataset data and manifest views
ZhaoHaoRu Nov 2, 2026
dcae1ac
Adapt FlowANN step 5 to upstream dataset data and manifest views
ZhaoHaoRu Nov 2, 2026
5999959
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
2381710
Adapt FlowANN step 7 to upstream dataset data and manifest views
ZhaoHaoRu Nov 2, 2026
88eed5c
Adapt FlowANN step 6 to upstream dataset data and manifest views
ZhaoHaoRu Nov 2, 2026
3d7af78
Validate VPQ owner through data and codebook views
ZhaoHaoRu Nov 2, 2026
2ba50ea
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
56eab60
Format upstream dataset API adaptations
ZhaoHaoRu Nov 2, 2026
5423d1d
Format upstream dataset API adaptations
ZhaoHaoRu Nov 2, 2026
fdcd472
Adapt dense graph helper views and supply dataset template type expli…
ZhaoHaoRu Nov 2, 2026
40eedfc
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
b5d618f
Use upstream row-major bridge for non-iterative graph builders
ZhaoHaoRu Nov 2, 2026
93d17c8
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
59c8127
Construct empty padded views with the upstream dataset factory
ZhaoHaoRu Nov 2, 2026
c43edc8
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
c1dc34e
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
5ae81af
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
e9c7dde
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
c00129e
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
d06aaa4
Use the upstream row-major view for cosine norm reduction
ZhaoHaoRu Nov 2, 2026
e204115
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
048d283
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
6392c66
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
0fe3860
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
f533db5
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
1353ed7
Preserve output-width invalid IDs for mapped providers and remove a r…
ZhaoHaoRu Nov 2, 2026
6ac3fc5
Merge FlowANN step 1 review fixes into step 2
ZhaoHaoRu Nov 2, 2026
95d1dd5
Cover abort draining, concurrent lease failures and recovery after in…
ZhaoHaoRu Nov 2, 2026
0f7db48
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
ca636a2
Latch queue aborts and report each lease failure while allowing inval…
ZhaoHaoRu Nov 2, 2026
16a0e93
Define relocatable GDRCopy runtime deployment paths for shared and st…
ZhaoHaoRu Nov 2, 2026
21f252e
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
25f103f
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
edd1f96
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
3f228f1
Retain padded single-CTA query batching and check every published par…
ZhaoHaoRu Nov 2, 2026
cd6098e
Support padded multi-CTA query batches from the first multi-CTA stage
ZhaoHaoRu Nov 2, 2026
7ef82c3
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
d59289e
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
e60e5dd
Cover 64-bit invalid results for filtered tiered searches
ZhaoHaoRu Nov 2, 2026
ed0acc0
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
8fcef88
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
4ae9082
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
1dd08b3
Format query-batching and output-width regression coverage
ZhaoHaoRu Nov 2, 2026
cca81a5
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
e03dd4e
Format query-batching and output-width regression coverage
ZhaoHaoRu Nov 2, 2026
f8f6b79
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
4d1fcf4
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
2957ff3
Initialize required subgraph metadata in the invalid-result regression
ZhaoHaoRu Nov 2, 2026
06061a1
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
b42d661
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
c208367
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
12844a5
Format poller failure reporting with the repository C++ style
ZhaoHaoRu Nov 2, 2026
53320fb
Merge FlowANN step 2 review fixes into step 3
ZhaoHaoRu Nov 2, 2026
f1eb7be
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
52ccfc3
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
a02f218
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
42b1277
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
725aa90
Honor external GDRCopy runtime paths in standalone static C builds
ZhaoHaoRu Nov 2, 2026
b8af510
Merge FlowANN step 3 review fixes into step 4
ZhaoHaoRu Nov 2, 2026
ef76f45
Bound FlowANN batches and size seed hashmaps; unify invalid output IDs
ZhaoHaoRu Nov 2, 2026
a016c16
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
d5c99d6
Bound multi-CTA batches and strengthen padded-query correctness checks
ZhaoHaoRu Nov 2, 2026
69f10b9
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
9281caf
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
e520803
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
47bf022
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
4523720
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
cb5a2a0
Preserve global seed hash history and correct padded fixture distances
ZhaoHaoRu Nov 2, 2026
2836bf8
Use exact expected distances for the multi-CTA padded fixture
ZhaoHaoRu Nov 2, 2026
ccd08fb
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
5db386a
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
b780bed
Cover seed hash growth, AUTO fallback, and explicit shared capacity r…
ZhaoHaoRu Nov 2, 2026
5883bcb
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
aebf117
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
97191d9
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
4fad216
Limit seed regression result copies to the sampled query count
ZhaoHaoRu Nov 2, 2026
40f06dd
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
adf1c2e
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
2592a8d
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
db4bfc2
Match the seed regression graph metadata to its sixteen cross edges
ZhaoHaoRu Nov 2, 2026
a1f299e
Merge FlowANN step 4 review fixes into step 5
ZhaoHaoRu Nov 2, 2026
b46de8d
Merge FlowANN step 5 review fixes into step 6
ZhaoHaoRu Nov 2, 2026
3d3b738
Merge FlowANN step 6 review fixes into step 7
ZhaoHaoRu Nov 2, 2026
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
9 changes: 9 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ option(BUILD_CAGRA_HNSWLIB "Build CAGRA+hnswlib interface" ON)
option(BUILD_MG_ALGOS "Build with multi-GPU support" ON)

option(CUVSC_STATIC_CUVS_LIBRARY "Link against statical version of libcuvs" OFF)
set(CUVS_FLOWANN_GDRCOPY_INSTALL_RPATH "$ORIGIN" CACHE STRING
"Install RPATH for external GDRCopy runtime libraries")

# Check if cuVS is already available. If so, it is the user's responsibility to ensure that the
# CMake package is also available at build time of the Python cuvs package.
Expand Down Expand Up @@ -123,6 +125,13 @@ set_target_properties(
VISIBILITY_INLINES_HIDDEN ON
)

if(CUVSC_STATIC_CUVS_LIBRARY)
# Imported cuvs_static can carry GDRCopy without exporting its build-time feature flags.
# Keep the runtime deployment setting available to standalone C builds too.
set_property(TARGET cuvs_c APPEND PROPERTY INSTALL_RPATH
"${CUVS_FLOWANN_GDRCOPY_INSTALL_RPATH}")
endif()

# Setup the VERSION and SOVERSION of our library
#
# Long term goal is that every release that breaks the C ABI will update `cuvs_abi_version` allowing
Expand Down
110 changes: 106 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(CUVS_COMPILE_DYNAMIC_ONLY "Only build the shared library and skip the static library." OFF)
option(CUVS_NVTX "Enable nvtx markers" OFF)
option(CUVS_RAFT_CLONE_ON_PIN "Explicitly clone RAFT branch when pinned to non-feature branch" ON)

option(CUVS_ENABLE_FLOWANN_SEARCH "Enable experimental FlowANN tiered-graph search" OFF)
option(CUVS_ENABLE_FLOWANN_BUILD "Enable the experimental integrated FlowANN graph builder" OFF)
option(CUVS_FLOWANN_USE_GDRCOPY "Use GDRCopy for FlowANN GPU-to-CPU command queues" ON)
set(CUVS_FLOWANN_GDRCOPY_INSTALL_RPATH "\$ORIGIN" CACHE STRING
"Runtime search paths for externally deployed GDRCopy; never inferred from the build host")

if(CUVS_ENABLE_FLOWANN_SEARCH AND BUILD_CPU_ONLY)
message(FATAL_ERROR "CUVS_ENABLE_FLOWANN_SEARCH requires a CUDA-enabled build")
endif()
if(CUVS_ENABLE_FLOWANN_BUILD AND NOT CUVS_ENABLE_FLOWANN_SEARCH)
message(FATAL_ERROR "CUVS_ENABLE_FLOWANN_BUILD requires CUVS_ENABLE_FLOWANN_SEARCH")
endif()
if(BUILD_CPU_ONLY)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_TESTS OFF)
Expand Down Expand Up @@ -113,7 +124,6 @@ elseif(NOT BUILD_SHARED_LIBS)
set(cuvs_compile_mode "static_only")
set(_cuvs_lib_targets cuvs_static)
endif()

# Needed because GoogleBenchmark changes the state of FindThreads.cmake, causing subsequent runs to
# have different values for the `Threads::Threads` target. Setting this flag ensures
# `Threads::Threads` is the same value across all builds so that cache hits occur
Expand All @@ -127,6 +137,9 @@ message(VERBOSE "cuVS: Build cuVS unit-tests: ${BUILD_TESTS}")
message(VERBOSE "cuVS: Build CPU only components: ${BUILD_CPU_ONLY}")
message(VERBOSE "cuVS: Build ANN benchmarks: ${BUILD_CUVS_BENCH}")
message(VERBOSE "cuVS: Build only the shared library: ${CUVS_COMPILE_DYNAMIC_ONLY}")
message(VERBOSE "cuVS: Enable FlowANN tiered-graph search: ${CUVS_ENABLE_FLOWANN_SEARCH}")
message(VERBOSE "cuVS: Enable FlowANN integrated build: ${CUVS_ENABLE_FLOWANN_BUILD}")
message(VERBOSE "cuVS: Use GDRCopy for FlowANN queues: ${CUVS_FLOWANN_USE_GDRCOPY}")
message(VERBOSE "cuVS: Enable detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "cuVS: Disable deprecation warnings " ${DISABLE_DEPRECATION_WARNINGS})
message(VERBOSE "cuVS: Disable OpenMP: ${DISABLE_OPENMP}")
Expand Down Expand Up @@ -169,6 +182,22 @@ if(NOT BUILD_CPU_ONLY)
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)

if(CUVS_ENABLE_FLOWANN_SEARCH AND CUVS_FLOWANN_USE_GDRCOPY)
rapids_find_generate_module(
GDRCopy
HEADER_NAMES gdrapi.h
LIBRARY_NAMES gdrapi
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)
rapids_find_package(
GDRCopy REQUIRED
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)
set(CUVS_FLOWANN_GDRCOPY_DEPENDENCIES GDRCopy::GDRCopy CUDA::cuda_driver)
endif()
else()
add_compile_definitions(BUILD_CPU_ONLY)
endif()
Expand Down Expand Up @@ -233,6 +262,10 @@ if(NOT BUILD_CPU_ONLY)
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_compile_definitions(
cuvs_cpp_headers INTERFACE $<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:CUVS_ENABLE_FLOWANN_SEARCH>
$<$<BOOL:${CUVS_ENABLE_FLOWANN_BUILD}>:CUVS_ENABLE_FLOWANN_BUILD>
)
target_link_libraries(cuvs_cpp_headers INTERFACE raft::raft rmm::rmm)

generate_inst_matrix(
Expand Down Expand Up @@ -959,6 +992,44 @@ if(NOT BUILD_CPU_ONLY)
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated_kernels/cagra/search_single_cta"
KERNEL_LINK_LIBRARIES jit_lto_kernel_usage_requirements
)
if(CUVS_ENABLE_FLOWANN_SEARCH)
set(flowann_ns "cuvs::neighbors::cagra::experimental::flowann::detail")
generate_jit_lto_kernels(
jit_lto_files
NAME_FORMAT
"flowann_search_single_cta_@topk_by_bitonic_sort_str@_@bitonic_sort_and_merge_multi_warps_str@_data_@data_abbrev@"
MATRIX_JSON_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/src/neighbors/detail/flowann/search_single_cta_matrix.json"
KERNEL_INPUT_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/src/neighbors/detail/flowann/search_single_cta_kernel.cu.in"
FRAGMENT_TAG_FORMAT
"${flowann_ns}::fragment_tag_search_single_cta<${neighbors_ns}::tag_@data_abbrev@, ${neighbors_ns}::tag_index_@source_index_abbrev@, ${neighbors_ns}::tag_index_@index_abbrev@, ${cagra_ns}::tag_dist_@distance_abbrev@, @topk_by_bitonic_sort@, @bitonic_sort_and_merge_multi_warps@>"
FRAGMENT_TAG_HEADER_FILES
"<cuvs/detail/jit_lto/flowann/flowann_fragments.hpp>"
"<cuvs/detail/jit_lto/common_fragments.hpp>"
"<cuvs/detail/jit_lto/cagra/cagra_fragments.hpp>"
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated_kernels/flowann/search_single_cta"
KERNEL_LINK_LIBRARIES jit_lto_kernel_usage_requirements
KERNEL_EXTRA_COMPILE_OPTIONS --maxrregcount=64
)
generate_jit_lto_kernels(
jit_lto_files
NAME_FORMAT "flowann_search_multi_cta_data_@data_abbrev@"
MATRIX_JSON_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/src/neighbors/detail/flowann/search_multi_cta_matrix.json"
KERNEL_INPUT_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/src/neighbors/detail/flowann/search_multi_cta_kernel.cu.in"
FRAGMENT_TAG_FORMAT
"${flowann_ns}::fragment_tag_search_multi_cta<${neighbors_ns}::tag_@data_abbrev@, ${neighbors_ns}::tag_index_@source_index_abbrev@, ${neighbors_ns}::tag_index_@index_abbrev@, ${cagra_ns}::tag_dist_@distance_abbrev@>"
FRAGMENT_TAG_HEADER_FILES
"<cuvs/detail/jit_lto/flowann/flowann_fragments.hpp>"
"<cuvs/detail/jit_lto/common_fragments.hpp>"
"<cuvs/detail/jit_lto/cagra/cagra_fragments.hpp>"
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated_kernels/flowann/search_multi_cta"
KERNEL_LINK_LIBRARIES jit_lto_kernel_usage_requirements
KERNEL_EXTRA_COMPILE_OPTIONS --maxrregcount=64
)
endif()
generate_jit_lto_kernels(
jit_lto_files
NAME_FORMAT
Expand Down Expand Up @@ -1486,6 +1557,9 @@ if(NOT BUILD_CPU_ONLY)
src/neighbors/brute_force.cu
src/neighbors/brute_force_serialize.cu
src/neighbors/cagra.cpp
$<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:src/neighbors/flowann.cu>
$<$<BOOL:${CUVS_ENABLE_FLOWANN_BUILD}>:src/neighbors/flowann_build.cu>
$<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:src/neighbors/flowann_queue.cpp>
${cagra_build_inst_files}
${cagra_extend_inst_files}
src/neighbors/cagra_optimize.cu
Expand Down Expand Up @@ -1592,6 +1666,12 @@ if(NOT BUILD_CPU_ONLY)
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:Debug>>:${CUVS_DEBUG_CUDA_FLAGS}>"
)

target_compile_definitions(
cuvs_objs
PRIVATE
$<$<AND:$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>,$<BOOL:${CUVS_FLOWANN_USE_GDRCOPY}>>:CUVS_FLOWANN_USE_GDRCOPY>
)

target_compile_definitions(
cuvs_objs
PRIVATE CUVS_CUTILE_ENABLED=${CUVS_CUTILE_ENABLED}
Expand All @@ -1608,6 +1688,7 @@ if(NOT BUILD_CPU_ONLY)
nvidia::cutlass::cutlass
rtcx::rtcx
${CUVS_CTK_MATH_DEPENDENCIES}
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>
kvikio::kvikio
Expand Down Expand Up @@ -1687,10 +1768,30 @@ if(NOT BUILD_CPU_ONLY)
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:NCCL::NCCL>>
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>>
$<$<BOOL:${CUVS_NVTX}>:CUDA::nvtx3>
PRIVATE $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX> $<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco> CUDA::nvJitLink CUDA::nvrtc rtcx::rtcx kvikio::kvikio
PRIVATE $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco>
CUDA::nvJitLink
CUDA::nvrtc
rtcx::rtcx
kvikio::kvikio
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
INTERFACE $<LINK_ONLY:kvikio::kvikio>
)
if(CUVS_ENABLE_FLOWANN_SEARCH)
target_link_libraries(cuvs INTERFACE $<LINK_ONLY:$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>>)
endif()
if(CUVS_ENABLE_FLOWANN_SEARCH AND CUVS_FLOWANN_USE_GDRCOPY)
# GDRCopy is an external runtime dependency. Default to an install-relative path;
# packagers may supply an explicit deployment path, independent of the build prefix.
set_property(TARGET cuvs APPEND PROPERTY INSTALL_RPATH
"${CUVS_FLOWANN_GDRCOPY_INSTALL_RPATH}")
# Consumers must resolve this runtime dependency even when it is installed outside the
# linker's default search paths. Its headers remain private to the queue implementation.
target_link_libraries(
cuvs INTERFACE $<LINK_ONLY:GDRCopy::GDRCopy> $<LINK_ONLY:CUDA::cuda_driver>
)
endif()

endif()

Expand Down Expand Up @@ -1735,6 +1836,7 @@ if(NOT BUILD_CPU_ONLY)
CUDA::nvJitLink
CUDA::nvrtc
rtcx::rtcx
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
$<$<BOOL:${CUVS_NVTX}>:CUDA::nvtx3>
$<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco>
Expand Down
24 changes: 24 additions & 0 deletions cpp/include/cuvs/detail/jit_lto/flowann/flowann_fragments.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* FlowANN is described in "Disentangling Graph Dependencies for Efficient
* Billion-Scale GPU Vector Search" (OSDI 2026).
*/

#pragma once

namespace cuvs::neighbors::cagra::experimental::flowann::detail {

template <typename DataTag,
typename SourceIndexTag,
typename IndexTag,
typename DistanceTag,
bool TopkByBitonicSort,
bool BitonicSortAndMergeMultiWarps>
struct fragment_tag_search_single_cta {};

template <typename DataTag, typename SourceIndexTag, typename IndexTag, typename DistanceTag>
struct fragment_tag_search_multi_cta {};

} // namespace cuvs::neighbors::cagra::experimental::flowann::detail
62 changes: 61 additions & 1 deletion cpp/src/neighbors/detail/cagra/cagra_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ auto iterative_build_graph(raft::resources const& res,
{
size_t intermediate_degree = params.intermediate_graph_degree;
size_t graph_degree = params.graph_degree;
// Other callers also pass the original parameters after checking local degree copies.
check_graph_degree<T, IdxT>(intermediate_degree, graph_degree, dataset.n_rows());

const auto& iter_params =
std::get<cagra::graph_build_params::iterative_search_params>(params.graph_build_params);
Expand Down Expand Up @@ -755,11 +757,15 @@ auto iterative_build_graph(raft::resources const& res,
final_graph_size = static_cast<uint64_t>(dataset.n_rows());
}

// Every initial row must have enough distinct non-self neighbors for the
// first search-and-optimize iteration, including very small datasets.
auto small_graph_degree = std::max(graph_degree / 2, std::min(graph_degree, (uint64_t)24));
// Determine initial graph size.
uint64_t initial_graph_size = (final_graph_size + 1) / 2;
while (initial_graph_size > graph_degree * 64) {
initial_graph_size = (initial_graph_size + 1) / 2;
}
initial_graph_size = std::max(initial_graph_size, small_graph_degree + 1);
RAFT_LOG_DEBUG("# initial graph size = %lu", (uint64_t)initial_graph_size);

// Preallocate the kNN graph at last-iteration size (N × (intermediate_degree+1)) from the large
Expand Down Expand Up @@ -793,7 +799,6 @@ auto iterative_build_graph(raft::resources const& res,

// Determine graph degree and number of search results while increasing
// graph size.
auto small_graph_degree = std::max(graph_degree / 2, std::min(graph_degree, (uint64_t)24));
RAFT_LOG_DEBUG("# small_graph_degree = %lu", (uint64_t)small_graph_degree);
RAFT_LOG_DEBUG("# graph_degree = %lu", (uint64_t)graph_degree);
RAFT_LOG_DEBUG("# topk = %lu", (uint64_t)topk);
Expand Down Expand Up @@ -1062,6 +1067,61 @@ auto build_cagra_host_graph_from_knn_params(raft::resources const& res,
return cagra_graph;
}

/** Build only the final optimized host graph from a dense dataset view. */
template <typename T, typename IdxT = uint32_t, typename DatasetViewT>
requires cuvs::neighbors::is_dense_row_major_dataset_view_v<DatasetViewT>
auto build_graph(raft::resources const& res,
index_params const& params,
DatasetViewT const& dataset) -> raft::host_matrix<IdxT, int64_t>
{
auto const n_rows = static_cast<size_t>(dataset.n_rows());
auto const dim = static_cast<size_t>(dataset.dim());
auto intermediate_degree = params.intermediate_graph_degree;
auto graph_degree = params.graph_degree;
common::nvtx::range<common::nvtx::domain::cuvs> function_scope(
"cagra::detail::build_graph(%zu, %zu)", intermediate_degree, graph_degree);
check_graph_degree<T, IdxT>(intermediate_degree, graph_degree, n_rows);

auto const dataset_extents =
raft::matrix_extent<int64_t>(static_cast<int64_t>(n_rows), static_cast<int64_t>(dim));
auto knn_build_params = resolve_cagra_default_knn_graph_build_params<IdxT>(
res, params, dataset_extents, intermediate_degree);
validate_cagra_knn_graph_build_constraints<T>(params, knn_build_params);

if (std::holds_alternative<cagra::graph_build_params::iterative_search_params>(
knn_build_params)) {
auto adjusted_params = params;
adjusted_params.intermediate_graph_degree = intermediate_degree;
adjusted_params.graph_degree = graph_degree;
auto device_graph = [&]() {
if constexpr (cuvs::neighbors::is_host_dataset_view_v<DatasetViewT>) {
auto padded = cuvs::neighbors::make_device_padded_dataset(res, dataset.data_view());
auto graph = iterative_build_graph<T, IdxT>(res, adjusted_params, padded->view());
raft::resource::sync_stream(res);
return graph;
} else {
return iterative_build_graph<T, IdxT>(res, adjusted_params, dataset);
}
}();
auto host_graph =
raft::make_host_matrix<IdxT, int64_t>(device_graph.extent(0), device_graph.extent(1));
raft::copy(host_graph.data_handle(),
device_graph.data_handle(),
host_graph.size(),
raft::resource::get_cuda_stream(res));
raft::resource::sync_stream(res);
return host_graph;
}
return build_cagra_host_graph_from_knn_params<T, IdxT>(
res,
params,
knn_build_params,
static_cast<int64_t>(n_rows),
intermediate_degree,
graph_degree,
cuvs::neighbors::dense_row_major_view(dataset));
}

/**
* Build from a host row-major matrix without uploading the full dataset early when IVF-PQ graph
* construction can consume host batches directly. Iterative CAGRA search needs the rows on device
Expand Down
Loading
Loading