-
Notifications
You must be signed in to change notification settings - Fork 184
Dispatch to use fp32 distance computation in NN Descent depending on data dimensions #1415
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
Changes from all commits
5e8600d
74ef509
cb5994f
3e41b53
cf9153a
06880ff
d23e5ea
0948bd5
bc6b4a5
6ca087c
c2e6f3e
5bb77ee
5d40d35
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,16 @@ namespace cuvs::neighbors::nn_descent { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| * @{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @brief Dtype to use for distance computation | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `AUTO`: Automatically determine the best dtype for distance computation based on the dataset | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * dimensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `FP32`: Use fp32 distance computation for better precision at the cost of performance and | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * memory usage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `FP16`: Use fp16 distance computation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| enum class DIST_COMP_DTYPE { AUTO = 0, FP32 = 1, FP16 = 2 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @brief Parameters used to build an nn-descent index | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `graph_degree`: For an input dataset of dimensions (N, D), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -37,13 +47,19 @@ namespace cuvs::neighbors::nn_descent { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| * the graph for. More iterations produce a better quality graph at cost of performance | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `termination_threshold`: The delta at which nn-descent will terminate its iterations | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `return_distances`: Boolean to decide whether to return distances array | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - `dist_comp_dtype`: dtype to use for distance computation. Defaults to `AUTO` which | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * automatically determines the best dtype for distance computation based on the dataset dimensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Use `FP32` for better precision at the cost of performance and memory usage. This option is only | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * valid when data type is fp32. Use `FP16` for better performance and memory usage at the cost of | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * precision. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| struct index_params : cuvs::neighbors::index_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t graph_degree = 64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t intermediate_graph_degree = 128; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t max_iterations = 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| float termination_threshold = 0.0001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool return_distances = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| DIST_COMP_DTYPE dist_comp_dtype = DIST_COMP_DTYPE::AUTO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
Author
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. @divyegala It already defaults to AUTO here, which would be taken in
Member
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. That file is the source of C API, and this default is for the C++ API.
Contributor
Author
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 believe all the defaults of cpp are passed when we call cuvs/c/src/neighbors/nn_descent.cpp Lines 167 to 182 in 1959a0d
C doesn't support default struct init and so nothing is initialized in the c struct: cuvs/c/include/cuvs/neighbors/nn_descent.h Lines 38 to 46 in 1959a0d
Member
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 haven't kept up with the changes to the C API, my apologies. We used to explicitly default initialize in the create function previously. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** @brief Construct NN descent parameters for a specific kNN graph degree | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Please default initialize the index creation with this new parameter.