-
Notifications
You must be signed in to change notification settings - Fork 84
Fix bruteforce cosine #1021
base: main
Are you sure you want to change the base?
Fix bruteforce cosine #1021
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hhy3 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@hhy3 Please associate the related issue to the body of your Pull Request. (eg. “issue: #”) |
src/common/comp/brute_force.cc
Outdated
std::unique_ptr<float[]> norms = nullptr; | ||
if (is_cosine) { | ||
norms = std::make_unique<float[]>(nb); | ||
faiss::fvec_norms_L2(norms.get(), (const float*)xb, dim, nb); |
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.
Is it possible to calculate this from origin data directly? the xb could be much large and concurrent search requests will copy many data to run out of memory
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.
To my understanding, we search growing chunk by chunk, which means the nb cannot be bigger than 1024. So 4KB memory is needed for each search.
The reason why put it here is to accelerate the calculation when nq is big
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.
@liliu-z the sealed segment without index will also go brute force, and the sealed segment is with only 1 chunk, which with size of all rows
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.
@liliu-z the sealed segment without index will also go brute force, and the sealed segment is with only 1 chunk, which with size of all rows
Good catch!
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.
@hhy3 Let's put it in
|
a661b44
to
70634fc
Compare
/kind improvement |
Signed-off-by: zh Wang <[email protected]>
No description provided.