Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAISS with cuVS enabled in cuvs-bench #561

Merged
merged 33 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
689716c
fix
tarang-jain Dec 19, 2024
8e3a02e
updates
tarang-jain Jan 6, 2025
27dda5f
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 6, 2025
10618fb
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 8, 2025
c0ff9ba
more changes
tarang-jain Jan 8, 2025
21f92fd
working
tarang-jain Jan 9, 2025
20e462c
update yaml
tarang-jain Jan 10, 2025
3f86225
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 13, 2025
8d098bd
update configs
tarang-jain Jan 14, 2025
f8beec6
cagra wrapper
tarang-jain Jan 15, 2025
63ecfde
Merge branch 'branch-25.02' into faiss-cuvs
tarang-jain Jan 15, 2025
c37f028
cagra wrapper
tarang-jain Jan 21, 2025
1cb5b73
merge upstream
tarang-jain Jan 22, 2025
61fd247
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 22, 2025
6d8c396
Merge branch 'faiss-cuvs' of https://github.com/tarang-jain/cuvs into…
tarang-jain Jan 22, 2025
c11c317
automatic pool resource management
tarang-jain Jan 22, 2025
25765ed
rm algo-specific in benchmark.hpp
tarang-jain Jan 22, 2025
26fbe30
refine
tarang-jain Jan 22, 2025
508bd5c
Merge branch 'branch-25.02' into faiss-cuvs
tarang-jain Jan 22, 2025
e4d97db
kHost queries
tarang-jain Jan 22, 2025
fed8c3b
raft_log_level
tarang-jain Jan 22, 2025
52eac3b
cleanup
tarang-jain Jan 22, 2025
9066e2d
rm raft::raft
tarang-jain Jan 23, 2025
bc5714f
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 23, 2025
986f476
conditionally link raft::raft
tarang-jain Jan 23, 2025
ddd711a
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 23, 2025
b3511fa
conditionally link raft::raft only for faiss_gpu
tarang-jain Jan 24, 2025
880966a
Merge branch 'branch-25.02' of https://github.com/rapidsai/cuvs into …
tarang-jain Jan 24, 2025
4a82d13
inherit faiss_gpu
tarang-jain Jan 27, 2025
18d1e62
raft::raft in invidual targets
tarang-jain Jan 27, 2025
4b07e90
merge upstream
tarang-jain Jan 27, 2025
6cffe02
style
tarang-jain Jan 27, 2025
d288548
Merge branch 'branch-25.02' into faiss-cuvs
tarang-jain Jan 28, 2025
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
8 changes: 8 additions & 0 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ list(APPEND CMAKE_MODULE_PATH "${CUVS_SOURCE_DIR}")
option(CUVS_ANN_BENCH_USE_FAISS_GPU_FLAT "Include faiss' brute-force knn algorithm in benchmark" ON)
option(CUVS_ANN_BENCH_USE_FAISS_GPU_IVF_FLAT "Include faiss' ivf flat algorithm in benchmark" ON)
option(CUVS_ANN_BENCH_USE_FAISS_GPU_IVF_PQ "Include faiss' ivf pq algorithm in benchmark" ON)
option(CUVS_ANN_BENCH_USE_FAISS_GPU_CAGRA "Include faiss' cagra algorithm in benchmark" ON)
option(CUVS_ANN_BENCH_USE_FAISS_CPU_FLAT "Include faiss' cpu brute-force algorithm in benchmark" ON)
option(CUVS_ANN_BENCH_USE_FAISS_CPU_IVF_FLAT "Include faiss' cpu ivf flat algorithm in benchmark"
ON
Expand Down Expand Up @@ -124,6 +125,7 @@ function(ConfigureAnnBench)
target_link_libraries(
${BENCH_NAME}
PRIVATE ${ConfigureAnnBench_LINKS}
$<$<BOOL:${GPU_BUILD}>:raft::raft>
nlohmann_json::nlohmann_json
Threads::Threads
$<TARGET_NAME_IF_EXISTS:raft::raft_logger>
Expand Down Expand Up @@ -290,6 +292,12 @@ if(CUVS_ANN_BENCH_USE_FAISS_GPU_FLAT AND CUVS_FAISS_ENABLE_GPU)
)
endif()

if(CUVS_ANN_BENCH_USE_FAISS_GPU_CAGRA AND CUVS_FAISS_ENABLE_GPU)
ConfigureAnnBench(
NAME FAISS_GPU_CAGRA PATH src/faiss/faiss_gpu_benchmark.cu LINKS ${CUVS_FAISS_TARGETS}
)
endif()

if(CUVS_ANN_BENCH_USE_GGNN)
include(cmake/thirdparty/get_glog)
ConfigureAnnBench(
Expand Down
64 changes: 63 additions & 1 deletion cpp/bench/ann/src/faiss/faiss_gpu_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void parse_build_param(const nlohmann::json& conf,
typename cuvs::bench::faiss_gpu_ivf_flat<T>::build_param& param)
{
parse_base_build_param<T>(conf, param);
if (conf.contains("use_cuvs")) {
param.use_cuvs = conf.at("use_cuvs");
} else {
param.use_cuvs = false;
}
}

template <typename T>
Expand All @@ -60,6 +65,16 @@ void parse_build_param(const nlohmann::json& conf,
} else {
param.use_float16 = false;
}
if (conf.contains("use_cuvs")) {
param.use_cuvs = conf.at("use_cuvs");
} else {
param.use_cuvs = false;
}
if (conf.contains("bitsPerCode")) {
param.bitsPerCode = conf.at("bitsPerCode");
} else {
param.bitsPerCode = 8;
}
}

template <typename T>
Expand All @@ -70,11 +85,52 @@ void parse_build_param(const nlohmann::json& conf,
param.quantizer_type = conf.at("quantizer_type");
}

template <typename T>
void parse_build_param(const nlohmann::json& conf,
typename cuvs::bench::faiss_gpu_cagra<T>::build_param& param)
{
if (conf.contains("graph_degree")) {
param.graph_degree = conf.at("graph_degree");
} else {
param.graph_degree = 64;
}
if (conf.contains("intermediate_graph_degree")) {
param.intermediate_graph_degree = conf.at("intermediate_graph_degree");
} else {
param.intermediate_graph_degree = 128;
}
if (conf.contains("cagra_build_algo")) { param.cagra_build_algo = conf.at("cagra_build_algo"); }
}

template <typename T>
void parse_search_param(const nlohmann::json& conf,
typename cuvs::bench::faiss_gpu<T>::search_param& param)
{
param.nprobe = conf.at("nprobe");
if (conf.contains("nprobe")) { param.nprobe = conf.at("nprobe"); }
if (conf.contains("refine_ratio")) { param.refine_ratio = conf.at("refine_ratio"); }
}

template <typename T>
void parse_search_param(const nlohmann::json& conf,
typename cuvs::bench::faiss_gpu_cagra<T>::search_param& param)
{
if (conf.contains("itopk")) { param.p.itopk_size = conf.at("itopk"); }
if (conf.contains("search_width")) { param.p.search_width = conf.at("search_width"); }
if (conf.contains("max_iterations")) { param.p.max_iterations = conf.at("max_iterations"); }
if (conf.contains("algo")) {
if (conf.at("algo") == "single_cta") {
param.p.algo = faiss::gpu::search_algo::SINGLE_CTA;
} else if (conf.at("algo") == "multi_cta") {
param.p.algo = faiss::gpu::search_algo::MULTI_CTA;
} else if (conf.at("algo") == "multi_kernel") {
param.p.algo = faiss::gpu::search_algo::MULTI_KERNEL;
} else if (conf.at("algo") == "auto") {
param.p.algo = faiss::gpu::search_algo::AUTO;
} else {
std::string tmp = conf.at("algo");
THROW("Invalid value for algo: %s", tmp.c_str());
}
}
if (conf.contains("refine_ratio")) { param.refine_ratio = conf.at("refine_ratio"); }
}

Expand Down Expand Up @@ -105,6 +161,8 @@ auto create_algo(const std::string& algo_name,
a = make_algo<T, cuvs::bench::faiss_gpu_ivfsq>(metric, dim, conf);
} else if (algo_name == "faiss_gpu_flat") {
a = std::make_unique<cuvs::bench::faiss_gpu_flat<T>>(metric, dim);
} else if (algo_name == "faiss_gpu_cagra") {
a = make_algo<T, cuvs::bench::faiss_gpu_cagra>(metric, dim, conf);
}
}

Expand All @@ -125,6 +183,10 @@ auto create_search_param(const std::string& algo_name, const nlohmann::json& con
} else if (algo_name == "faiss_gpu_flat") {
auto param = std::make_unique<typename cuvs::bench::faiss_gpu<T>::search_param>();
return param;
} else if (algo_name == "faiss_gpu_cagra") {
auto param = std::make_unique<typename cuvs::bench::faiss_gpu_cagra<T>::search_param>();
parse_search_param<T>(conf, *param);
return param;
}
// else
throw std::runtime_error("invalid algo: '" + algo_name + "'");
Expand Down
Loading
Loading