-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: product quantization fast scan #538
Conversation
7006c22
to
c01a8df
Compare
e021020
to
7112cfd
Compare
Can you show us some performance numbers? |
dataset: glove-100-angular.hdf5 (1183514 vectors, 100 dims, 10000 tests, L2 normalized, IP distance) Faiss here is https://pypi.org/project/faiss-cpu/. Faiss-IVF (nlist = 1000; nprobe = 10): recall = 0.819589999999983, time = 11.370838165283203 s pgvecto.rs-IVF (nlist = 1000; nprobe = 10): recall = 0.7628899999999892, time = 4.944989 s |
The result shows that fast-scan speeds pgvecto.rs a lot (2x ~ 3x) but the effect is not as excellent as that of faiss (64x). The flamegraph (for pgvecto.rs-PQ, ratio = 2, bits = 4; fast_scan = on, rerank_size = 100) shows
|
|
It's expected by me since computation is too fast if fast scan is enabled (float32 in look-up table is quantized to int8, and AVX2 processes 32 vectors in a time). The main difference between our implementation and faiss is whether heap is used.
What do you mean? Is it too fast or too slow? |
It's seems much slower than faiss, but other numbers are faster than faiss. I don't understand the problem here. |
Would it be better if the heap is O(1) for insertion and O(logN) for pop operation? Reference: |
|
Another way to improve the heap operation might be to do it in a batch, which won't pollute cache less at each insertion. |
There is no heap insertion but only I'll try adding fast-path for |
100 dim vector is rare to see in Deep Learning world. Larger dims is more typical. For 1000dim, the cost of the heap might not account for a large proportion. |
66978b2
to
cf3e6ae
Compare
Signed-off-by: usamoi <[email protected]>
Signed-off-by: usamoi <[email protected]>
I'm merging it now because it blocks #549 |
blocked by #537