Skip to content
Open
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions cpp/src/neighbors/detail/cagra/cagra_helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -84,7 +84,16 @@ std::tuple<size_t, size_t, size_t, size_t> optimize_workspace_size(size_t n_rows
}
size_t combine_dev = combine_dev_fixed;

size_t total_host = mst_host + combine_host;
size_t debug_host_size = 0;
if (raft::default_logger().should_log(rapids_logger::level_enum::debug)) {
Comment thread
huuanhhuyn marked this conversation as resolved.
// cagra::detail::graph::optimize() allocates extra memory to calculate
// graph metrics when debug logging is enabled
debug_host_size = n_rows * graph_degree * sizeof(uint32_t) // host_copy_output_graph
+ n_rows * sizeof(uint32_t) // in_edge_count
+ graph_degree * sizeof(uint32_t); // hist
}

size_t total_host = mst_host + combine_host + debug_host_size;
size_t total_host_fixed = mst_host_fixed + combine_host_fixed;
size_t total_dev = std::max(prune_dev, rev_dev + combine_dev);
size_t total_dev_fixed = std::max(prune_dev_fixed, combine_dev_fixed);
Expand Down Expand Up @@ -125,6 +134,10 @@ inline std::pair<size_t, size_t> ivf_pq_build_mem_usage(
params.build_params.n_lists));
size_t kmeans_n_rows = n_rows / kmeans_trainset_ratio;
size_t kmeans_gpu_mem = kmeans_n_rows * dim * sizeof(float);
if (dtype != CUDA_R_32F) {
// kmeans trainset tmp allocation
kmeans_gpu_mem += kmeans_n_rows * dim * dtype_size;
}

// For non-float input, ivf_pq::build first samples into a temporary trainset of type T
if (!input_is_float) { kmeans_gpu_mem += kmeans_n_rows * dim * dtype_size; }
Expand Down
Loading