Skip to content

Conversation

@benwtrent
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds an experimental IVF vectors format along with its supporting reader/writer implementations, tests, modifications to the neighbor queue, and updates to the SIMD vectorization utilities.

  • Adds experimental IVF format implementations and tests.
  • Extends SIMD vectorization support with OSQ scoring and associated tests.
  • Updates module exports to include IVFVectorsFormat.

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/src/test/java/org/elasticsearch/index/codec/vectors/IVFVectorsFormatTests.java New tests for the experimental IVF vectors format.
server/src/main/java/org/elasticsearch/index/codec/vectors/NeighborQueue.java Introduction of a custom neighbor queue implementation.
server/src/main/java/org/elasticsearch/index/codec/vectors/IVFVectorsReader.java New reader implementation for IVF vectors indexing.
server/src/main/java/org/elasticsearch/index/codec/vectors/IVFVectorsFormat.java Implementation of the IVF vectors format with feature-flag checks.
server/src/main/java/module-info.java Updated module export to include IVFVectorsFormat.
libs/simdvec/... Enhancements to OSQ-based vector scoring and utility support across SIMD vectorization providers.
Files not reviewed (1)
  • server/src/main/resources/META-INF/services/org.apache.lucene.codecs.KnnVectorsFormat: Language not supported
Comments suppressed due to low confidence (2)

server/src/main/java/org/elasticsearch/index/codec/vectors/IVFVectorsFormat.java:103

  • The toString() method returns "IVFVectorFormat", which is inconsistent with the class name IVFVectorsFormat. Consider changing it to "IVFVectorsFormat" for consistency.
return "IVFVectorFormat";

libs/simdvec/src/main/java/org/elasticsearch/simdvec/internal/vectorization/DefaultESVectorUtilSupport.java:148

  • The fma() method is used without being defined. To improve clarity and correctness, consider using Math.fma(djk, originalResidual[i], proj) or ensure that a proper helper method is provided.
proj = fma(djk, originalResidual[i], proj);

@benwtrent benwtrent marked this pull request as ready for review April 29, 2025 19:02
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Apr 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@benwtrent benwtrent requested a review from mayya-sharipova May 6, 2025 12:00
/**
* Copied from and modified from Apache Lucene.
*/
class NeighborQueue {
Copy link
Contributor

Choose a reason for hiding this comment

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

since you are pulling over NeighborQueue consider pulling over TestNeighborQueue as well?

Copy link
Contributor

@john-wagster john-wagster left a comment

Choose a reason for hiding this comment

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

i've taken a few passes over the code here at this point. I feel like it's in a good enough state to merge and to start getting CI running on it. lgtm.

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

From a code structure and testing perspective, this LGTM.

I can only rubber stamp the codec level / algorithmic side of it as I'm not familiar with that. But I trust the testing infrastructure and how it's been extended.

return centroid;
}

private void readQuantizedCentroid(int centroidOrdinal) throws IOException {
Copy link
Contributor

@mayya-sharipova mayya-sharipova May 7, 2025

Choose a reason for hiding this comment

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

the function name is readQuantizedCentroid but it also reads full centroid. It looks like the second read of full centroid is not necessary in scoring. Should we break this function be only about reading quantized centroid?

@Override
NeighborQueue scorePostingLists(FieldInfo fieldInfo, KnnCollector knnCollector, CentroidQueryScorer centroidQueryScorer, int nProbe)
throws IOException {
NeighborQueue neighborQueue = new NeighborQueue(centroidQueryScorer.size(), true);
Copy link
Contributor

@mayya-sharipova mayya-sharipova May 7, 2025

Choose a reason for hiding this comment

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

Are you supposed to have MIN heap of only nprobe size?
What's the role of nprobe here?

Copy link
Member Author

Choose a reason for hiding this comment

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

For this, we need to be able to explore past nProbe in the case of filtered search. nProbe has no current role.

I think we will end up with a double queue system eventually, but given its all flat, we just score everything. This needs to be improved, for sure.

++centroidsVisited;
// todo do we actually need to know the score???
int centroidOrdinal = centroidQueue.pop();
// todo do we need direct access to the raw centroid???
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for this TODO: it looks like we always do 2 reads of quantized and full centroid, why we need only a single

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the raw to quantize the query vector for the posting list. So, we score with the quantized and then quantize the query vector according to the raw value.

I think we might want to separate out the scoring vs. the iterating for the centroids.

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

@benwtrent Amazing work, Ben and the team! I've left some minor comments, but overall LGTM!

@benwtrent benwtrent merged commit ebe8ea6 into elastic:main May 7, 2025
17 checks passed
@benwtrent benwtrent deleted the ivf-format branch May 7, 2025 19:00
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request May 9, 2025
john-wagster added a commit that referenced this pull request May 9, 2025
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request May 12, 2025
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request May 12, 2025
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request May 13, 2025
elasticsearchmachine pushed a commit that referenced this pull request May 13, 2025
…128005) (#128051)

This reverts commit 8a17a5e.

reapplying ivf format, but with a fix.
richard-dennehy pushed a commit to richard-dennehy/elasticsearch that referenced this pull request May 19, 2025
benchaplin pushed a commit to benchaplin/elasticsearch that referenced this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants