kaivalnp commented on PR #17013:
URL: https://github.com/apache/lucene/pull/17013#issuecomment-7001024114

   Summary of latest changes:
   
   - Bulk-score 4 vectors for **_all_** quantization levels!
       - Needed to avoid C2 inlining / boxing trap, see 
https://github.com/apache/lucene/pull/17013#discussion_r4624710571.
   - All functions are now identical in "shape" to `PanamaVectorUtilSupport` 
(i.e. number of bytes loaded, intermediate accumulator type, tail operations, 
etc for all bit widths).
       - Small difference: the 4-bit dot product [iterates in chunks and keeps 
2 short 
accumulators](https://github.com/apache/lucene/blob/f6e694652c3d41b5486808c54d48f6bb19a9b178/lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java#L637-L640).
 Bulk-scoring 4 vectors at a time would increase number of short accumulators 
to 8, which in addition to intermediate operations might lead to register 
pressure. The bulk variant operates in chunks of half the size, using 4 short 
accumulators.
   - Make the new scalar quantized JMH benchmark similar to the [raw float 
one](https://github.com/apache/lucene/blob/f6e694652c3d41b5486808c54d48f6bb19a9b178/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/VectorScorerFloat32Benchmark.java#L86)
 (add scalar methods, score 20K random vectors out of 1M in a single function, 
add score validation).
   
   To exercise all paths, I ran the JMH benchmark on various architecture / 
bit-width combinations.
   Results for `VectorScorerQuantizedBenchmark.bulkScoreVector`:
   
   | bits | Graviton4 (128 bit)  | Graviton3 (256 bit)  | Zen3 (AVX2)          
| Zen4 (AVX-512)       |
   
|------|----------------------|----------------------|----------------------|----------------------|
   | 8    | 9.76 -> 5.04 (-48%)  | 8.94 -> 3.59 (-60%)  | 5.57 -> 3.62 (-35%)  
| 4.00 -> 2.75 (-31%)  |
   | 7    | 9.60 -> 5.01 (-48%)  | 8.81 -> 3.59 (-59%)  | 5.49 -> 3.62 (-34%)  
| 4.04 -> 2.72 (-33%)  |
   | 4    | 5.04 -> 2.11 (-58%)  | 5.55 -> 2.43 (-56%)  | 3.41 -> 2.52 (-26%)  
| 2.86 -> 1.74 (-39%)  |
   | 2    | 3.82 -> 1.42 (-63%)  | 4.54 -> 1.73 (-62%)  | 2.31 -> 1.62 (-30%)  
| 1.64 -> 0.86 (-48%)  |
   | 1    | 2.28 -> 0.94 (-59%)  | 3.40 -> 0.85 (-75%)  | 1.67 -> 0.94 (-43%)  
| 1.23 -> 0.55 (-56%)  |
   
   KNN search benchmark on my Graviton3 host (Cohere v3 vectors, 1024d, 500K 
docs, 10K queries, `topK=100`, `fanout=100`, `maxConn=64`, `beamWidth=250`, 
`DOT_PRODUCT`, force-merged to one segment):
   
   | bits | latency main (ms) | latency workspace (ms) | change | recall | 
visited |
   
|------|-------------------|------------------------|--------|--------|---------|
   | 1    | 1.808             | 1.112                  | -38%   | 0.695  | 8098 
   |
   | 2    | 1.964             | 1.204                  | -39%   | 0.814  | 7275 
   |
   | 4    | 2.121             | 1.356                  | -36%   | 0.915  | 6926 
   |
   | 8    | 3.026             | 1.720                  | -43%   | 0.972  | 6864 
   |
   
   ..which is even better than before!
   
   _(raw results formatted in tables for simplicity)_


-- 
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