Skip to content

Commit 67e65f4

Browse files
Emy Sunfacebook-github-bot
authored andcommitted
Add hnsw search params for bounded queue option
Summary: So we can dynamically change it Differential Revision: D61029191
1 parent a56ee81 commit 67e65f4

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

faiss/impl/HNSW.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ HNSWStats HNSW::search(
847847
}
848848
int k = extract_k_from_ResultHandler(res);
849849

850+
bool search_bounded_queue_opt =
851+
params ? params->search_bounded_queue : search_bounded_queue;
852+
850853
if (upper_beam == 1) {
851854
// greedy search on upper levels
852855
storage_idx_t nearest = entry_point;
@@ -857,7 +860,7 @@ HNSWStats HNSW::search(
857860
}
858861

859862
int ef = std::max(params ? params->efSearch : efSearch, k);
860-
if (search_bounded_queue) { // this is the most common branch
863+
if (search_bounded_queue_opt) { // this is the most common branch
861864
MinimaxHeap candidates(ef);
862865

863866
candidates.push(nearest, d_nearest);

faiss/impl/HNSW.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct ResultHandler;
4646
struct SearchParametersHNSW : SearchParameters {
4747
int efSearch = 16;
4848
bool check_relative_distance = true;
49+
bool search_bounded_queue = true;
4950

5051
~SearchParametersHNSW() {}
5152
};

0 commit comments

Comments
 (0)