Skip to content

Commit

Permalink
Add hnsw search params for bounded queue option (#3748)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3748

So we can dynamically change it

Reviewed By: asadoughi

Differential Revision: D61029191

fbshipit-source-id: 19a6775c1218762dac7a7805e13efab9bb43cfa5
  • Loading branch information
Emy Sun authored and facebook-github-bot committed Aug 13, 2024
1 parent 80a2462 commit 2968ab1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion faiss/impl/HNSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ HNSWStats HNSW::search(
}
int k = extract_k_from_ResultHandler(res);

bool bounded_queue =
params ? params->bounded_queue : this->search_bounded_queue;

if (upper_beam == 1) {
// greedy search on upper levels
storage_idx_t nearest = entry_point;
Expand All @@ -857,7 +860,7 @@ HNSWStats HNSW::search(
}

int ef = std::max(params ? params->efSearch : efSearch, k);
if (search_bounded_queue) { // this is the most common branch
if (bounded_queue) { // this is the most common branch
MinimaxHeap candidates(ef);

candidates.push(nearest, d_nearest);
Expand Down
1 change: 1 addition & 0 deletions faiss/impl/HNSW.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct ResultHandler;
struct SearchParametersHNSW : SearchParameters {
int efSearch = 16;
bool check_relative_distance = true;
bool bounded_queue = true;

~SearchParametersHNSW() {}
};
Expand Down

0 comments on commit 2968ab1

Please sign in to comment.