Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a711b7c
Add HNSW ACE build method
julianmi Nov 29, 2025
fd06f6f
Fix formatting
julianmi Dec 1, 2025
28f14b7
Address review feedback
julianmi Dec 2, 2025
6d464ec
Improve C++ test based on review feedback
julianmi Dec 2, 2025
3426cbd
Automatically derive number of partitions in ACE
julianmi Dec 1, 2025
97f84e1
Merge branch 'main' into hnsw-ace
julianmi Dec 3, 2025
5138bfc
Address review comments
julianmi Dec 3, 2025
29a4e65
Merge branch 'pr/julianmi/1597' into ace-auto-npartitions
julianmi Dec 3, 2025
04479f7
Merge branch 'main' into hnsw-ace
julianmi Dec 4, 2025
6ba5ec2
Fix ACE parameters in tests
julianmi Dec 4, 2025
575527f
Merge branch 'main' into hnsw-ace
julianmi Dec 4, 2025
7bbcb00
Merge branch 'hnsw-ace' into ace-auto-npartitions
julianmi Dec 4, 2025
40a20b9
Pass ACE memory limits in Python interface
julianmi Dec 5, 2025
114095d
Merge branch 'main' into hnsw-ace
julianmi Dec 8, 2025
de93cd1
Merge remote-tracking branch 'origin/hnsw-ace' into ace-auto-npartitions
julianmi Dec 8, 2025
6f09b5b
Merge branch 'main' into hnsw-ace
julianmi Dec 15, 2025
43b5a79
Merge branch 'main' into hnsw-ace
julianmi Dec 16, 2025
527e8e0
Merge remote-tracking branch 'origin/hnsw-ace' into ace-auto-npartitions
julianmi Dec 16, 2025
4c54d35
Align HNSW ACE Python test with CAGRA ACE test
julianmi Dec 17, 2025
6153711
Merge branch 'main' into hnsw-ace
julianmi Dec 17, 2025
5f5954c
Merge branch 'main' into hnsw-ace
julianmi Dec 18, 2025
0e7a9ae
Merge branch 'main' into hnsw-ace
julianmi Dec 19, 2025
1782e86
Merge branch 'main' into hnsw-ace
julianmi Jan 5, 2026
e595771
Update copyright
julianmi Jan 5, 2026
b0925b4
Merge branch 'main' into hnsw-ace
julianmi Jan 6, 2026
5d59c79
Merge branch 'main' into hnsw-ace
julianmi Jan 8, 2026
a9bf831
Merge remote-tracking branch 'origin/hnsw-ace' into ace-auto-npartitions
julianmi Jan 8, 2026
90a05fc
Merge branch 'main' into hnsw-ace
tfeher Jan 9, 2026
c860c9c
Update copyright to 2026
julianmi Jan 9, 2026
5b01b40
Merge branch 'main' into hnsw-ace
julianmi Jan 10, 2026
817bb48
Merge remote-tracking branch 'origin/hnsw-ace' into ace-auto-npartitions
julianmi Jan 10, 2026
31ec3f6
Merge upstream/main into ace-auto-npartitions
julianmi Jan 13, 2026
4fe0abe
Merge branch 'main' into ace-auto-npartitions
julianmi Jan 14, 2026
a926d3a
Merge branch 'main' into ace-auto-npartitions
julianmi Jan 14, 2026
0d2a981
Merge remote-tracking branch 'upstream/main' into ace-auto-npartitions
julianmi Jan 15, 2026
ff921b6
Apply review feedback
julianmi Jan 15, 2026
b8c44f2
Remove the partition size recommendation
julianmi Jan 15, 2026
74122ca
Fix gpu_memory_limited based on review feedback
julianmi Jan 15, 2026
58e13fe
Fix formatting
julianmi Jan 15, 2026
b7a7136
Merge branch 'main' into ace-auto-npartitions
julianmi Jan 16, 2026
c42549e
Add CAGRA workspace size calculations
julianmi Jan 17, 2026
38c2aa2
Merge branch 'main' into ace-auto-npartitions
julianmi Jan 17, 2026
b142808
Merge branch 'main' into ace-auto-npartitions
julianmi Jan 20, 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
33 changes: 28 additions & 5 deletions c/include/cuvs/neighbors/cagra.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,20 @@ struct cuvsAceParams {
/**
* Number of partitions for ACE (Augmented Core Extraction) partitioned build.
*
* When set to 0 (default), the number of partitions is automatically derived
* based on available host and GPU memory to maximize partition size while
* ensuring the build fits in memory.
*
* Small values might improve recall but potentially degrade performance and
* increase memory usage. Partitions should not be too small to prevent issues
* in KNN graph construction. 100k - 5M vectors per partition is recommended
* depending on the available host and GPU memory. The partition size is on
* average 2 * (n_rows / npartitions) * dim * sizeof(T). 2 is because of the
* core and augmented vectors. Please account for imbalance in the partition
* sizes (up to 3x in our tests).
* in KNN graph construction. The partition size is on average 2 * (n_rows /
* npartitions) * dim * sizeof(T). 2 is because of the core and augmented
* vectors. Please account for imbalance in the partition sizes (up to 3x in
* our tests).
*
* If the specified number of partitions results in partitions that exceed
* available memory, the value will be automatically increased to fit memory
* constraints and a warning will be issued.
*/
size_t npartitions;
/**
Expand All @@ -167,6 +174,22 @@ struct cuvsAceParams {
* When true, enables disk-based operations for memory-efficient graph construction.
*/
bool use_disk;
/**
* Maximum host memory to use for ACE build in GiB.
*
* When set to 0 (default), uses available host memory.
* When set to a positive value, limits host memory usage to the specified amount.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_host_memory_gb;
/**
* Maximum GPU memory to use for ACE build in GiB.
*
* When set to 0 (default), uses available GPU memory.
* When set to a positive value, limits GPU memory usage to the specified amount.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_gpu_memory_gb;
};

typedef struct cuvsAceParams* cuvsAceParams_t;
Expand Down
26 changes: 25 additions & 1 deletion c/include/cuvs/neighbors/hnsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,20 @@ enum cuvsHnswHierarchy {
struct cuvsHnswAceParams {
/**
* Number of partitions for ACE partitioned build.
*
* When set to 0 (default), the number of partitions is automatically derived
* based on available host and GPU memory to maximize partition size while
* ensuring the build fits in memory.
*
* Small values might improve recall but potentially degrade performance and
* increase memory usage. 100k - 5M vectors per partition is recommended.
* increase memory usage. The partition size is on average 2 * (n_rows /
* npartitions) * dim * sizeof(T). 2 is because of the core and augmented
* vectors. Please account for imbalance in the partition sizes (up to 3x in
* our tests).
*
* If the specified number of partitions results in partitions that exceed
* available memory, the value will be automatically increased to fit memory
* constraints and a warning will be issued.
*/
size_t npartitions;
/**
Expand All @@ -60,6 +72,18 @@ struct cuvsHnswAceParams {
* When true, enables disk-based operations for memory-efficient graph construction.
*/
bool use_disk;
/**
* Maximum host memory to use for ACE build in GiB.
* When set to 0 (default), uses available host memory.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_host_memory_gb;
/**
* Maximum GPU memory to use for ACE build in GiB.
* When set to 0 (default), uses available GPU memory.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_gpu_memory_gb;
};

typedef struct cuvsHnswAceParams* cuvsHnswAceParams_t;
Expand Down
22 changes: 13 additions & 9 deletions c/src/neighbors/cagra.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -88,10 +88,12 @@ static void _set_graph_build_params(
cuvs::neighbors::cagra::graph_build_params::ace_params ace_p;
if (params.graph_build_params) {
auto ace_params_c = static_cast<cuvsAceParams*>(params.graph_build_params);
ace_p.npartitions = ace_params_c->npartitions;
ace_p.ef_construction = ace_params_c->ef_construction;
ace_p.build_dir = std::string(ace_params_c->build_dir);
ace_p.use_disk = ace_params_c->use_disk;
ace_p.npartitions = ace_params_c->npartitions;
ace_p.ef_construction = ace_params_c->ef_construction;
ace_p.build_dir = std::string(ace_params_c->build_dir);
ace_p.use_disk = ace_params_c->use_disk;
ace_p.max_host_memory_gb = ace_params_c->max_host_memory_gb;
ace_p.max_gpu_memory_gb = ace_params_c->max_gpu_memory_gb;
}
out_params = ace_p;
break;
Expand Down Expand Up @@ -778,10 +780,12 @@ extern "C" cuvsError_t cuvsAceParamsCreate(cuvsAceParams_t* params)
// Allocate and copy the build directory string
const char* build_dir = strdup(ps.build_dir.c_str());

*params = new cuvsAceParams{.npartitions = ps.npartitions,
.ef_construction = ps.ef_construction,
.build_dir = build_dir,
.use_disk = ps.use_disk};
*params = new cuvsAceParams{.npartitions = ps.npartitions,
.ef_construction = ps.ef_construction,
.build_dir = build_dir,
.use_disk = ps.use_disk,
.max_host_memory_gb = ps.max_host_memory_gb,
.max_gpu_memory_gb = ps.max_gpu_memory_gb};
});
}

Expand Down
10 changes: 7 additions & 3 deletions c/src/neighbors/hnsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void _build(cuvsResources_t res,
ace_params.npartitions = params->ace_params->npartitions;
ace_params.build_dir = params->ace_params->build_dir ? params->ace_params->build_dir : "/tmp/hnsw_ace_build";
ace_params.use_disk = params->ace_params->use_disk;
ace_params.max_host_memory_gb = params->ace_params->max_host_memory_gb;
ace_params.max_gpu_memory_gb = params->ace_params->max_gpu_memory_gb;
cpp_params.graph_build_params = ace_params;

using dataset_mdspan_type = raft::host_matrix_view<T const, int64_t, raft::row_major>;
Expand Down Expand Up @@ -151,9 +153,11 @@ void* _deserialize(cuvsResources_t res,
extern "C" cuvsError_t cuvsHnswAceParamsCreate(cuvsHnswAceParams_t* params)
{
return cuvs::core::translate_exceptions([=] {
*params = new cuvsHnswAceParams{.npartitions = 1,
.build_dir = "/tmp/hnsw_ace_build",
.use_disk = false};
*params = new cuvsHnswAceParams{.npartitions = 0,
.build_dir = "/tmp/hnsw_ace_build",
.use_disk = false,
.max_host_memory_gb = 0,
.max_gpu_memory_gb = 0};
});
}

Expand Down
36 changes: 29 additions & 7 deletions cpp/include/cuvs/neighbors/graph_build_types.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -99,15 +99,21 @@ struct ace_params {
/**
* Number of partitions for ACE (Augmented Core Extraction) partitioned build.
*
* When set to 0 (default), the number of partitions is automatically derived
* based on available host and GPU memory to maximize partition size while
* ensuring the build fits in memory.
*
* Small values might improve recall but potentially degrade performance and
* increase memory usage. Partitions should not be too small to prevent issues
* in KNN graph construction. 100k - 5M vectors per partition is recommended
* depending on the available host and GPU memory. The partition size is on
* average 2 * (n_rows / npartitions) * dim * sizeof(T). 2 is because of the
* core and augmented vectors. Please account for imbalance in the partition
* sizes (up to 3x in our tests).
* in KNN graph construction. The partition size is on average 2 * (n_rows / npartitions) * dim *
* sizeof(T). 2 is because of the core and augmented vectors. Please account for imbalance in the
* partition sizes (up to 3x in our tests).
*
* If the specified number of partitions results in partitions that exceed
* available memory, the value will be automatically increased to fit memory
* constraints and a warning will be issued.
*/
size_t npartitions = 1;
size_t npartitions = 0;
/**
* The index quality for the ACE build.
*
Expand All @@ -129,6 +135,22 @@ struct ace_params {
* When true, enables disk-based operations for memory-efficient graph construction.
*/
bool use_disk = false;
/**
* Maximum host memory to use for ACE build in GiB.
*
* When set to 0 (default), uses available host memory.
* When set to a positive value, limits host memory usage to the specified amount.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_host_memory_gb = 0;
/**
* Maximum GPU memory to use for ACE build in GiB.
*
* When set to 0 (default), uses available GPU memory.
* When set to a positive value, limits GPU memory usage to the specified amount.
* Useful for testing or when running alongside other memory-intensive processes.
*/
double max_gpu_memory_gb = 0;

ace_params() = default;
};
Expand Down
Loading