New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade IVFFlatScanner and exhaustive_L2sqr_seq #3074
base: main
Are you sure you want to change the base?
Upgrade IVFFlatScanner and exhaustive_L2sqr_seq #3074
Conversation
5e06ecb
to
1c9b02a
Compare
@mdouze Matthijs, could you please check whether this test failure is critical. It seems that it is about epsilons on certain architectures. On the other hand, it is seems that it is the code for dedup-ing. |
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.
I don't see how right away but it would be good if the code could be less repetitive. The loop over iCounter is very similar in 3 locations. This makes maintenance harder.
faiss/utils/distances.cpp
Outdated
// support for a particular kind of IDSelector classes. This | ||
// may be useful if the lion's share of samples are filtered out. | ||
|
||
struct EmptySelectorHelper { |
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.
please call it IDSelectorAll
Indeed when you delete elements it makes the index empty but IDSelector is also used for searching a subset of ids.
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.
I agree. Let me think how to get rid of this redundancy while keeping the code clear
1c9b02a
to
b66ca2c
Compare
@mdouze , I've upgraded the code, please take a look, whether it is simple enough or whether it needs to simplified further |
OK the current version is complex but less repetitive. I'll import to fbcode. Weird that the errors still appear. I thought I relaxed these tests. Did you rebase on latest Faiss? |
@mdouze has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Do you have numbers (even very rough) that show where this modification speeds up search? |
@mdouze , my mistake, let me rebase and run the test |
b66ca2c
to
a17f345
Compare
I've used Two cases: d=64 and d=768. I'm not sure whether the results are super reliable for d=64 (I'm running one on a VM), but it seems that it became a bit slower, while for d=768 the speedup is visible and reproducible. I think that I either need to add some threshold for d (say, starting from d=512, otherwise the new version is plain slower), or make it optional, or check the code further. So, please don't land this diff yet. d=64, Baseline:
d=64, Candidate:
d=768, Baseline:
d=768, Candidate:
|
@mdouze , additionally, I will modify |
I'm still playing with it |
5884d8c
to
d046e65
Compare
Signed-off-by: Alexandr Guzhva <alexanderguzhva@gmail.com>
d046e65
to
49390f1
Compare
What is the current status of this PR? |
@mdouze Technically, it works and I can rebase it on the master branch. But this diff improves the performance for large dim datasets, but may degrade the performance for smaller dim datasets. I've enabled it in Zilliz version of faiss, because it mostly operates with dim like 512+. But I'm not sure for the general purpose case. Is the benchmarking set that Gergely works on ready to be tried? |
Speeds up
IVFFlatScanner
by helping the branch predictor and computing distances for 4 elements per loop.Same upgrade for
exhaustive_inner_product_seq()
andexhaustive_L2sqr_seq()
calls.