kaivalnp opened a new issue, #16674:
URL: https://github.com/apache/lucene/issues/16674

   ### Description
   
   In the OSQ based vector format, we [recalculate centroids on 
merge](https://github.com/apache/lucene/blob/bc9adc96cc58d1e20761d961a2ab865eaede3962/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsWriter.java#L471)
 when there are deletes.
   If there [aren't any 
deletes](https://github.com/apache/lucene/blob/bc9adc96cc58d1e20761d961a2ab865eaede3962/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsWriter.java#L465),
 the merged centroid is simply a weighted average of segment-level centroids.
   
   I wonder if we can re-use the information of the previous centroid, even 
when there are deletes?
   i.e. start with `previousCentroid * vectorCount`, and _subtract deleted 
vectors_ instead?
   
   If the number of deletes is small, perhaps the work is much lesser? The 
caveat is that vectors may be read at non-contiguous parts of the raw vector 
file if we just read deleted ones.
   
   This can be especially beneficial for cases where raw vectors go beyond RAM, 
by avoiding some paging activity?
   
   Going one step further: the access pattern could be improved further if the 
raw format was more tightly integrated. Currently we perform three passes over 
the raw vectors:
   1. [Merge raw 
vectors](https://github.com/apache/lucene/blob/bc9adc96cc58d1e20761d961a2ab865eaede3962/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsWriter.java#L327)
   2. [Compute the 
centroid](https://github.com/apache/lucene/blob/bc9adc96cc58d1e20761d961a2ab865eaede3962/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsWriter.java#L483-L504)
   3. [Perform scalar 
quantization](https://github.com/apache/lucene/blob/bc9adc96cc58d1e20761d961a2ab865eaede3962/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsWriter.java#L391-L394)
   
   Can we compute the centroid in (1) and use it directly in (3), skipping (2)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to