Skip to content

Commit

Permalink
assign_index should default to null (#3855)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3855

Laser clients are calling RCQ search with a query size of 1 and the bulk of the overhead came from IndexFlat add/search. With a small query size, using IndexFlatL2 does lots of unnecessary copies to the IndexFlatL2.

By default, we should fall back to https://fburl.com/code/jpt236mz branch unless the client overrides `assign_index` with `assign_index_factory`.

Reviewed By: bshethmeta

Differential Revision: D62644305

fbshipit-source-id: 2434e2b238968304dc5b346637f8ca956e6bd548
  • Loading branch information
mengdilin authored and facebook-github-bot committed Sep 13, 2024
1 parent 52ce3f5 commit dbdd63b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions faiss/impl/residual_quantizer_encode_steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,6 @@ void refine_beam_mp(
std::unique_ptr<Index> assign_index;
if (rq.assign_index_factory) {
assign_index.reset((*rq.assign_index_factory)(rq.d));
} else {
assign_index.reset(new IndexFlatL2(rq.d));
}

// main loop
Expand Down Expand Up @@ -701,7 +699,9 @@ void refine_beam_mp(
assign_index.get(),
rq.approx_topk_mode);

assign_index->reset();
if (assign_index != nullptr) {
assign_index->reset();
}

std::swap(codes_ptr, new_codes_ptr);
std::swap(residuals_ptr, new_residuals_ptr);
Expand Down

0 comments on commit dbdd63b

Please sign in to comment.