Skip to content

Commit 920f8cb

Browse files
authored
[Improvement] Allow Configurable DRAM in DiskANN SSD Wrapper (rapidsai#1598)
Notes: During the final param parsing to DiskANN index building API, we convert the dram budgets to GB Authors: - Tarang Jain (https://github.com/tarang-jain) Approvers: - MithunR (https://github.com/mythrocks) URL: rapidsai#1598
1 parent bae4cdb commit 920f8cb

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

cpp/bench/ann/src/diskann/diskann_benchmark.cpp

Lines changed: 8 additions & 2 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

@@ -36,9 +36,15 @@ void parse_build_param(const nlohmann::json& conf,
3636
{
3737
param.R = conf.at("R");
3838
param.L_build = conf.at("L_build");
39-
if (conf.contains("alpha")) { param.num_threads = conf.at("alpha"); }
39+
if (conf.contains("alpha")) { param.alpha = conf.at("alpha"); }
4040
if (conf.contains("num_threads")) { param.num_threads = conf.at("num_threads"); }
4141
if (conf.contains("QD")) { param.QD = conf.at("QD"); }
42+
if (conf.contains("build_dram_budget_megabytes")) {
43+
param.build_dram_budget_megabytes = conf.at("build_dram_budget_megabytes");
44+
}
45+
if (conf.contains("search_dram_budget_megabytes")) {
46+
param.search_dram_budget_megabytes = conf.at("search_dram_budget_megabytes");
47+
}
4248
param.dataset_base_file = cuvs::bench::configuration::singleton().get_dataset_conf().base_file;
4349
for (const auto& index : cuvs::bench::configuration::singleton().get_indices()) {
4450
// The nlohmann::json operator== comparator compares each key and value by content. Reference:

cpp/bench/ann/src/diskann/diskann_wrapper.h

Lines changed: 20 additions & 11 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
#pragma once
@@ -17,6 +17,8 @@
1717
#include <utils.h>
1818

1919
#include <chrono>
20+
#include <cmath>
21+
#include <cstdio>
2022
#include <memory>
2123
#include <vector>
2224

@@ -172,12 +174,14 @@ class diskann_ssd : public algo<T> {
172174
struct build_param {
173175
uint32_t R;
174176
uint32_t L_build;
175-
uint32_t build_pq_bytes = 0;
176-
float alpha = 1.2;
177-
int num_threads = omp_get_max_threads();
178-
uint32_t QD = 192;
179-
std::string dataset_base_file = "";
180-
std::string index_file = "";
177+
uint32_t build_pq_bytes = 0;
178+
float alpha = 1.2;
179+
int num_threads = omp_get_max_threads();
180+
uint32_t QD = 192;
181+
std::string dataset_base_file = "";
182+
std::string index_file = "";
183+
uint32_t build_dram_budget_megabytes = std::numeric_limits<uint32_t>::max();
184+
uint32_t search_dram_budget_megabytes = std::numeric_limits<uint32_t>::max();
181185
};
182186
using search_param_base = typename algo<T>::search_param;
183187

@@ -232,12 +236,17 @@ template <typename T>
232236
diskann_ssd<T>::diskann_ssd(Metric metric, int dim, const build_param& param) : algo<T>(metric, dim)
233237
{
234238
// Currently set the indexing RAM budget and the search RAM budget to max value to avoid sharding
235-
uint32_t build_dram_budget = std::numeric_limits<uint32_t>::max();
236-
uint32_t search_dram_budget = std::numeric_limits<uint32_t>::max();
239+
float build_dram_budget = static_cast<float>(param.build_dram_budget_megabytes) / 1024.0f;
240+
float search_dram_budget = static_cast<float>(param.search_dram_budget_megabytes) / 1024.0f;
241+
char search_buf[16];
242+
char build_buf[16];
243+
std::snprintf(search_buf, sizeof(search_buf), "%.2f", search_dram_budget);
244+
std::snprintf(build_buf, sizeof(build_buf), "%.2f", build_dram_budget);
245+
const std::string search_dram_budget_gb(search_buf);
246+
const std::string build_dram_budget_gb(build_buf);
237247
index_build_params_str =
238248
std::string(std::to_string(param.R)) + " " + std::string(std::to_string(param.L_build)) + " " +
239-
std::string(std::to_string(search_dram_budget)) + " " +
240-
std::string(std::to_string(build_dram_budget)) + " " +
249+
search_dram_budget_gb + " " + build_dram_budget_gb + " " +
241250
std::string(std::to_string(param.num_threads)) + " " + std::string(std::to_string(false)) +
242251
" " + std::string(std::to_string(false)) + " " + std::string(std::to_string(0)) + " " +
243252
std::string(std::to_string(param.QD));

0 commit comments

Comments
 (0)