-
Notifications
You must be signed in to change notification settings - Fork 24
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
feature!: verify and set default VamanaBuildParameters #96
feature!: verify and set default VamanaBuildParameters #96
Conversation
include/svs/index/vamana/index.h
Outdated
|
||
// Check User set values | ||
// Validate number parameters are positive | ||
if (parameters.alpha < 0.0f) { |
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.
if (parameters.alpha < 0.0f) { | |
if (parameters.alpha <= 0.0f) { |
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.
Good catch, fixed!
tests/svs/orchestrators/vamana.cpp
Outdated
CATCH_REQUIRE(index.get_max_candidates() == 64); | ||
CATCH_REQUIRE(index.get_full_search_history() == true); | ||
} | ||
} |
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 think these tests should go to svs/index/vamana/index.cpp where the logic is implemented. Also, can we add similar tests for dynamic_index?
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.
Good idea, moved and added similar tests in dynamic_index_2.cpp
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.
Good work, @yuejiaointel! I look forward to not having to care about the default value of alpha
. :) I think we can make a couple of improvements. Please see my suggestions.
bindings/python/src/vamana.cpp
Outdated
py::arg("prune_to") = std::numeric_limits<size_t>::max(), | ||
py::arg("num_threads") = std::numeric_limits<size_t>::max(), | ||
py::arg("alpha") = svs::FLOAT_MAX, | ||
py::arg("graph_max_degree") = svs::UNSIGNED_INTEGER_MAX, |
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.
We are not setting graph_max_degree
based on other parameters. The default is always 32. Let's leave it as 32 so users immediately see what the default is.
py::arg("graph_max_degree") = svs::UNSIGNED_INTEGER_MAX, | |
py::arg("graph_max_degree") = 32, |
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.
Thx, renamed it to be GRAPH_MAX_DEGREE_DEFAULT with value 32
bindings/python/src/vamana.cpp
Outdated
py::arg("num_threads") = std::numeric_limits<size_t>::max(), | ||
py::arg("alpha") = svs::FLOAT_MAX, | ||
py::arg("graph_max_degree") = svs::UNSIGNED_INTEGER_MAX, | ||
py::arg("window_size") = svs::UNSIGNED_INTEGER_MAX, |
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.
Same as graph_max_degree
.
py::arg("window_size") = svs::UNSIGNED_INTEGER_MAX, | |
py::arg("window_size") = 64, |
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.
Thx, renamed it to be WINDOW_SIZE_DEFAULT with value 64
bindings/python/src/vamana.cpp
Outdated
py::arg("graph_max_degree") = svs::UNSIGNED_INTEGER_MAX, | ||
py::arg("window_size") = svs::UNSIGNED_INTEGER_MAX, | ||
py::arg("max_candidate_pool_size") = svs::UNSIGNED_INTEGER_MAX, | ||
py::arg("prune_to") = svs::UNSIGNED_INTEGER_MAX, |
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.
py::arg("prune_to") = svs::UNSIGNED_INTEGER_MAX, | |
py::arg("prune_to") = svs::UNSIGNED_INTEGER_PLACEHOLDER, |
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.
Thx, renamed!
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.
Thank you for accommodating my suggestions. I think the code looks good now. We should also update the docs.
include/svs/lib/preprocessor.h
Outdated
// Maximum values used as default initializers | ||
inline constexpr size_t UNSIGNED_INTEGER_PLACEHOLDER = std::numeric_limits<size_t>::max(); | ||
inline constexpr float FLOAT_PLACEHOLDER = std::numeric_limits<float>::max(); | ||
inline constexpr float GRAPH_MAX_DEGREE_DEFAULT = 32; |
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.
Can you please look at the docs corresponding to the PR and confirm these *_DEFAULT
values are visible? Users should be able to see the default value without reading the code. Ideally, there should be numbers visible in the VamanaBuildParameters
doc as currently; alternatively, there should be separate doc entries for the *_DEFAULT
consts.
include/svs/index/vamana/index.h
Outdated
if (parameters.alpha == svs::FLOAT_PLACEHOLDER) { | ||
// Check if it's a supported distance type | ||
if (is_L2) { | ||
parameters.alpha = 1.2f; |
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.
Good idea with the *_DEFAULT
values! (I was only suggesting numerical values). What do you think about adding two more for the two alpha values for maintainability, e.g., ALPHA_MAXIMIZE_DEFAULT
and ALPHA_MINIMIZE_DEFAULT
? Feel free to say no.
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.
Good idea, added!
/intelci |
/intelci |
/intelci |
/intelci |
3 similar comments
/intelci |
/intelci |
/intelci |
@@ -159,3 +162,14 @@ inline constexpr bool have_avx512_avx2 = true; | |||
#endif | |||
|
|||
} // namespace svs::arch | |||
|
|||
namespace svs { |
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.
Thank you for the good work.
Since some of these parameters are vamana-specific, could we move these parameters to svs::index::vamana namespace? Or change the name to Vamana specific.
For example, GRAPH_MAX_DEGREE_DEFAULT -> VAMANA_GRAPH_MAX_DEGREE_DEFAULT.
ALPHA_*, USE_FULL_SEARCH_HISTORY_DEFAULT, WINDOW_SIZE_DEFAULT should also be changed to Vamana specific
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.
Thx for suggestion, fixed!
/intelci |
/intelci |
/intelci |
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.
The signature for VamanaBuildParameters
looks good in the docs! That was my main concern. I am leaving suggestions for removing duplication like the repetition of defaults for the defaults that are shown in the signature and for reStructuredText (vs Markdown) formatting.
Co-authored-by: Mihai Capotă <[email protected]>
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.
Thanks a lot for your contribution (and for your patience), @yuejiaointel! SVS users will benefit greatly from the new defaults.
@yuejiaointel, please try changing the CIBuildWheel workflow to use Ubuntu 22.04: |
Ubuntu 24.04 didn't help... |
/intelci |
BREAKING CHANGE: Removed the deprecated
num_threads
argument and added ause_full_search_history
argument inVamanaBuildParameters
in Python bindings. This change ensures consistency between the Python API and the C++ implementation ininclude/svs/index/vamana/build_params.h
.Added default value setting and checking based on doc requirement, and added additional tests.
Pin CMake < 4 as a workaround until our dependencies require CMake >= 3.5.