Skip to content

Commit 7ab8d26

Browse files
committed
Include graph size to the estimate
1 parent 1f86a58 commit 7ab8d26

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cpp/src/neighbors/detail/cagra/cagra_helpers.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ inline std::pair<size_t, size_t> ivf_pq_build_mem_usage(
150150
size_t kmeans_pinned_host = 2 * pinned_rows * dim * dtype_size; // two staging double-buffers
151151
size_t kmeans_host_mem = kmeans_indices_host + kmeans_pinned_host;
152152

153+
// Add graph to index on GPU
154+
size_t create_index_gpu_mem = n_rows * graph_degree * sizeof(uint32_t);
155+
153156
// Search phase (build_knn_graph):
154157
constexpr size_t kWorkspaceRatio = 5;
155158
size_t top_k = intermediate_graph_degree + 1;
@@ -168,7 +171,8 @@ inline std::pair<size_t, size_t> ivf_pq_build_mem_usage(
168171
+ (sizeof(float) + sizeof(int64_t)) * top_k); // refined_*
169172

170173
// Phases run sequentially (train/extend -> search -> optimize)
171-
size_t total_dev = std::max({kmeans_gpu_mem, search_phase_dev, gpu_workspace_size});
174+
size_t total_dev =
175+
std::max({kmeans_gpu_mem, search_phase_dev, gpu_workspace_size, create_index_gpu_mem});
172176

173177
// The graph (and its optimize workspace) stays resident across phases
174178
size_t total_host =

0 commit comments

Comments
 (0)