Pulkitg64 commented on code in PR #16473:
URL: https://github.com/apache/lucene/pull/16473#discussion_r3816358941
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorScorer.java:
##########
@@ -111,6 +111,43 @@ public RandomVectorScorer getRandomVectorScorer(
public RandomVectorScorer getRandomVectorScorer(
VectorSimilarityFunction similarityFunction, KnnVectorValues
vectorValues, short[] target)
throws IOException {
+ if (vectorValues instanceof QuantizedByteVectorValues qv) {
+ FlatVectorsScorer.checkDimensions(target.length, qv.dimension());
+ OptimizedScalarQuantizer quantizer = qv.getQuantizer();
+ ScalarEncoding scalarEncoding = qv.getScalarEncoding();
+ byte[] scratch = new
byte[scalarEncoding.getDiscreteDimensions(qv.dimension())];
+ final byte[] targetQuantized;
+ if (scalarEncoding.isAsymmetric() == false) {
+ targetQuantized = scratch;
+ } else {
+ // This is asymmetric quantization, we will pack the vector
+ targetQuantized = new
byte[scalarEncoding.getQueryPackedLength(scratch.length)];
+ }
+ // Inflate the fp16 query to fp32 and normalize there; quantization
operates on fp32.
Review Comment:
> Do we want to add a TODO:
Created this issue: https://github.com/apache/lucene/issues/16533
> maybe there is some goodness there we can incorporate?
Thanks Mike, I will check how are they doing the quantization with Fp16
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorScorer.java:
##########
@@ -111,6 +111,43 @@ public RandomVectorScorer getRandomVectorScorer(
public RandomVectorScorer getRandomVectorScorer(
VectorSimilarityFunction similarityFunction, KnnVectorValues
vectorValues, short[] target)
throws IOException {
+ if (vectorValues instanceof QuantizedByteVectorValues qv) {
+ FlatVectorsScorer.checkDimensions(target.length, qv.dimension());
+ OptimizedScalarQuantizer quantizer = qv.getQuantizer();
+ ScalarEncoding scalarEncoding = qv.getScalarEncoding();
+ byte[] scratch = new
byte[scalarEncoding.getDiscreteDimensions(qv.dimension())];
+ final byte[] targetQuantized;
+ if (scalarEncoding.isAsymmetric() == false) {
+ targetQuantized = scratch;
+ } else {
+ // This is asymmetric quantization, we will pack the vector
+ targetQuantized = new
byte[scalarEncoding.getQueryPackedLength(scratch.length)];
+ }
+ // Inflate the fp16 query to fp32 and normalize there; quantization
operates on fp32.
Review Comment:
> Do we want to add a TODO:
Created this issue: https://github.com/apache/lucene/issues/16533
> maybe there is some goodness there we can incorporate?
Thanks Mike, I will check how are they doing the quantization with Fp16
--
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]