Skip to content

Commit

Permalink
Remove search_list_and_k_ratio param (#253)
Browse files Browse the repository at this point in the history
Signed-off-by: chasingegg <[email protected]>
  • Loading branch information
chasingegg authored Dec 5, 2023
1 parent 63b28e1 commit 65c2abd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/index/diskann/diskann.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ DiskANNIndexNode<T>::RangeSearch(const DataSet& dataset, const Config& cfg, cons
auto beamwidth = static_cast<uint64_t>(search_conf.beamwidth.value());
auto min_k = static_cast<uint64_t>(search_conf.min_k.value());
auto max_k = static_cast<uint64_t>(search_conf.max_k.value());
auto search_list_and_k_ratio = search_conf.search_list_and_k_ratio.value();

auto radius = search_conf.radius.value();
auto range_filter = search_conf.range_filter.value();
Expand All @@ -620,7 +619,7 @@ DiskANNIndexNode<T>::RangeSearch(const DataSet& dataset, const Config& cfg, cons
std::vector<int64_t> indices;
std::vector<float> distances;
pq_flash_index_->range_search(xq + (index * dim), radius, min_k, max_k, result_id_array[index],
result_dist_array[index], beamwidth, search_list_and_k_ratio, bitset);
result_dist_array[index], beamwidth, bitset);
// filter range search result
if (search_conf.range_filter.value() != defaultRangeFilter) {
FilterRangeSearchResultForOneNq(result_dist_array[index], result_id_array[index], is_ip, radius,
Expand Down
8 changes: 0 additions & 8 deletions src/index/diskann/diskann_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class DiskANNConfig : public BaseConfig {
CFG_INT min_k;
// DiskANN uses TopK search to simulate range search by double the K in every round. This is the largest K.
CFG_INT max_k;
// DiskANN uses TopK search to simulate range search, this is the ratio of search list size and k. With larger
// ratio, the accuracy will get higher but throughput will get affected.
CFG_FLOAT search_list_and_k_ratio;
// The threshold which determines when to switch to PQ + Refine strategy based on the number of bits set. The
// value should be in range of [0.0, 1.0] which means when greater or equal to x% of the bits are set,
// use PQ + Refine. Default to -1.0f, negative vlaues will use dynamic threshold calculator given topk.
Expand Down Expand Up @@ -137,11 +134,6 @@ class DiskANNConfig : public BaseConfig {
.set_default(std::numeric_limits<CFG_INT::value_type>::max())
.set_range(1, std::numeric_limits<CFG_INT::value_type>::max())
.for_range_search();
KNOWHERE_CONFIG_DECLARE_FIELD(search_list_and_k_ratio)
.description("the ratio of search list size and k.")
.set_default(2.0)
.set_range(1.0, 5.0)
.for_range_search();
KNOWHERE_CONFIG_DECLARE_FIELD(filter_threshold)
.description("the threshold of filter ratio to use PQ + Refine.")
.set_default(-1.0f)
Expand Down
2 changes: 0 additions & 2 deletions tests/ut/test_diskann.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ TEST_CASE("Invalid diskann params test", "[diskann]") {
json["beamwidth"] = 8;
json["min_k"] = 10;
json["max_k"] = 8000;
json["search_list_and_k_ratio"] = 2.0;
return json;
};
std::shared_ptr<knowhere::FileManager> file_manager = std::make_shared<knowhere::LocalFileManager>();
Expand Down Expand Up @@ -218,7 +217,6 @@ TEST_CASE("Test DiskANNIndexNode.", "[diskann]") {
json["beamwidth"] = 8;
json["min_k"] = 10;
json["max_k"] = 8000;
json["search_list_and_k_ratio"] = 2.0;
return json;
};

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/DiskANN/include/diskann/pq_flash_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace diskann {
_u32 range_search(const T *query1, const double range,
const _u64 min_l_search, const _u64 max_l_search,
std::vector<_s64> &indices, std::vector<float> &distances,
const _u64 beam_width, const float l_k_ratio,
const _u64 beam_width,
knowhere::BitsetView bitset_view = nullptr,
QueryStats *stats = nullptr);

Expand Down
5 changes: 2 additions & 3 deletions thirdparty/DiskANN/src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,7 @@ namespace diskann {
const T *query1, const double range, const _u64 min_l_search,
const _u64 max_l_search, std::vector<_s64> &indices,
std::vector<float> &distances, const _u64 beam_width,
const float l_k_ratio, knowhere::BitsetView bitset_view,
QueryStats *stats) {
knowhere::BitsetView bitset_view, QueryStats *stats) {
_u32 res_count = 0;

bool stop_flag = false;
Expand All @@ -1296,7 +1295,7 @@ namespace diskann {
distances.resize(l_search);
for (auto &x : distances)
x = std::numeric_limits<float>::max();
this->cached_beam_search(query1, l_search, l_k_ratio * l_search,
this->cached_beam_search(query1, l_search, l_search,
indices.data(), distances.data(), beam_width,
false, stats, nullptr, bitset_view);
for (_u32 i = 0; i < l_search; i++) {
Expand Down

0 comments on commit 65c2abd

Please sign in to comment.