-
Notifications
You must be signed in to change notification settings - Fork 87
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
CAGRA API update and allow async host refinement #131
Changes from 6 commits
4416b0b
946e106
7c6644e
2c3f5e4
4d5ff0c
545032b
d2c1dad
9823831
f310971
c1136c5
bb87c97
8506c6a
3a6e776
42aa3eb
68f490b
95f6064
3e22b13
fd66402
8b1fbb8
e688453
f5dff7d
71c779a
2540dbf
72d7b62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
#include "common.hpp" | ||
#include <cuvs/distance/distance.hpp> | ||
#include <cuvs/neighbors/common.hpp> | ||
#include <cuvs/neighbors/ivf_pq.hpp> | ||
#include <cuvs/neighbors/nn_descent.hpp> | ||
#include <raft/core/device_mdspan.hpp> | ||
#include <raft/core/host_device_accessor.hpp> | ||
#include <raft/core/host_mdspan.hpp> | ||
|
@@ -385,35 +387,65 @@ struct index : cuvs::neighbors::index { | |
* @defgroup cagra_cpp_index_build CAGRA index build functions | ||
* @{ | ||
*/ | ||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const float, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<float, uint32_t>; | ||
|
||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const float, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<float, uint32_t>; | ||
|
||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const int8_t, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<int8_t, uint32_t>; | ||
|
||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const int8_t, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<int8_t, uint32_t>; | ||
|
||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<uint8_t, uint32_t>; | ||
|
||
auto build(raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> dataset) | ||
-> cuvs::neighbors::cagra::index<uint8_t, uint32_t>; | ||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const float, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<float, uint32_t>; | ||
|
||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const float, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<float, uint32_t>; | ||
|
||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const int8_t, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<int8_t, uint32_t>; | ||
|
||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const int8_t, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
tfeher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<int8_t, uint32_t>; | ||
tfeher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<uint8_t, uint32_t>; | ||
|
||
auto build( | ||
raft::resources const& handle, | ||
const cuvs::neighbors::cagra::index_params& params, | ||
raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> dataset, | ||
std::optional<cuvs::neighbors::nn_descent::index_params> nn_descent_params = std::nullopt, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is awkward- a user is going to have to set std::nullopt for at least one of nn-descent_params or ivf_pq params. I think we should make these build_params for cagra. Actually, I think what we should do is take away the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second though- since you need refine_ratio on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cjnolet , i am not sure whether I understand correctly what you are proposing. An abstract graph_build_params struct that is inherited from different variants, e.g.
for the ivf_pq variant? To my understanding this would require to either implement interfaces individually or use of polymorphism/pointers that can be casted/dispatched. Do I understand your proposal correctly? As an alternative cleanup step we could also combine additional variant-specific-parameters into
What do you think should we go for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think your last idea looks great. It's clean, explicit, and tells the user right away what graph_build_params variants are supported. |
||
std::optional<float> refine_rate = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::index_params> pq_build_params = std::nullopt, | ||
std::optional<cuvs::neighbors::ivf_pq::search_params> search_params = std::nullopt, | ||
bool construct_index_with_dataset = true) -> cuvs::neighbors::cagra::index<uint8_t, uint32_t>; | ||
/** | ||
* @} | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the documentation from cagra.cuh shall be moved here. @cjnolet to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct- we should document every function / prototype exposed in
include/cuvs/**.hpp
. It seems repetitive but the API docs are fully indexed and searchable so when a user finds one of these functions through search, it's guaranteed to have the docs carried along with it.