Skip to content

Commit 71f1593

Browse files
committed
restore HNSW example
1 parent a14d4f0 commit 71f1593

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

examples/cpp/src/hnsw_openai_example.cu

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -71,21 +71,7 @@ int cagra_build_search_ace(raft::resources const& res)
7171
params.ef_construction = 200;
7272
params.hierarchy = cuvs::neighbors::hnsw::HnswHierarchy::GPU;
7373

74-
// hnsw::build()
75-
auto index_params =
76-
cagra::index_params::from_hnsw_params(dataset_host_view.extents(),
77-
params.M,
78-
params.ef_construction,
79-
cagra::hnsw_heuristic_type::SAME_GRAPH_FOOTPRINT,
80-
params.metric);
81-
82-
std::cout << "Building CAGRA index (search graph)" << std::endl;
83-
auto cagra_index = cagra::build(res, index_params, dataset_host_view);
84-
85-
// Convert CAGRA index to HNSW
86-
std::cout << "Converting CAGRA index to HNSW" << std::endl;
87-
hnsw::index_params hnsw_params;
88-
auto hnsw_index = hnsw::from_cagra(res, hnsw_params, cagra_index);
74+
auto hnsw_index = hnsw::build(res, params, dataset_host_view);
8975

9076
std::string hnsw_index_path = "hnsw_index.bin";
9177
cuvs::neighbors::hnsw::serialize(res, hnsw_index_path, *hnsw_index);
@@ -100,16 +86,16 @@ int main()
10086
{
10187
raft::resources res;
10288

103-
// Set pool memory resource with 1 GiB initial pool size. All allocations use the same pool.
104-
rmm::mr::pool_memory_resource<rmm::mr::device_memory_resource> pool_mr(
105-
rmm::mr::get_current_device_resource(), 1024 * 1024 * 1024ull);
106-
rmm::mr::set_current_device_resource(&pool_mr);
89+
// // Set pool memory resource with 1 GiB initial pool size. All allocations use the same pool.
90+
// rmm::mr::pool_memory_resource<rmm::mr::device_memory_resource> pool_mr(
91+
// rmm::mr::get_current_device_resource(), 1024 * 1024 * 1024ull);
92+
// rmm::mr::set_current_device_resource(&pool_mr);
10793

10894
// Alternatively, one could define a pool allocator for temporary arrays (used within RAFT
10995
// algorithms). In that case only the internal arrays would use the pool, any other allocation
11096
// uses the default RMM memory resource. Here is how to change the workspace memory resource to
11197
// a pool with 2 GiB upper limit.
112-
// raft::resource::set_workspace_to_pool_resource(res, 2 * 1024 * 1024 * 1024ull);
98+
raft::resource::set_workspace_to_pool_resource(res, 2 * 1024 * 1024 * 1024ull);
11399

114100
// ACE build and search example.
115101
cagra_build_search_ace(res);

0 commit comments

Comments
 (0)