Skip to content
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

Optimize distance computations for IVFPQ #468

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

NikolaosPapailiou
Copy link
Collaborator

@NikolaosPapailiou NikolaosPapailiou commented Jul 29, 2024

Implemented a new query to quantized vectors distance implementation that is:

  • Computing distance tables between each query and each pq_centroid
  • Uses the query distance tables during query-vector distance computations

Tested the performance of all methods using SIFT-1M:

  • asymmetric(previous default)
    query_time_vs_accuracy
  • symmetric:
    • ~1,3x speedup, accuracy reduction
      query_time_vs_accuracy
  • new distance based on query to pq_centroid distance tables:
    • more than 2x speedup, no accuracy reduction
      query_time_vs_accuracy

When comparing latency for a larger dataset of 60M vectors of 200 dimensions, the original latency was ~100s and after this it is 9s.

@NikolaosPapailiou NikolaosPapailiou changed the title Use symmetric distance for IVFPQ Optimize distance computations for IVFPQ Jul 30, 2024
@NikolaosPapailiou NikolaosPapailiou marked this pull request as ready for review July 30, 2024 13:00
Copy link
Collaborator

@jparismorgan jparismorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for adding the charts as well!

Could you also add a TODO to query_finite_ram() to update to this? Or you could update query_finite_ram() in this PR if you'd like, though it's fine with me to do in a follow-up once we support it via Python (I can do it then if you'd prefer, no worries).

src/include/index/ivf_pq_index.h Show resolved Hide resolved
src/include/index/ivf_pq_index.h Outdated Show resolved Hide resolved
src/include/index/ivf_pq_index.h Outdated Show resolved Hide resolved
@NikolaosPapailiou NikolaosPapailiou merged commit 5fa9718 into main Jul 30, 2024
6 checks passed
@NikolaosPapailiou NikolaosPapailiou deleted the npapa/ivf-pq-symmetric-distance branch July 30, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants