Skip to content

add bulk off-heap scoring for uint8 quantized vectors using panama vector api#16203

Open
iprithv wants to merge 1 commit into
apache:mainfrom
iprithv:bulk-offheap-scoring
Open

add bulk off-heap scoring for uint8 quantized vectors using panama vector api#16203
iprithv wants to merge 1 commit into
apache:mainfrom
iprithv:bulk-offheap-scoring

Conversation

@iprithv

@iprithv iprithv commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

add off-heap bulk scoring support for uint8 quantized vectors (via MemorySegment direct access in the Lucene99 scorer). processes neighbor batches from HNSW with direct offset reads and falls back for int4 / non-contiguous cases.

benchmarks (amd ryzen 7 7800x3d, avx-512):

  • float32 bulk: ~1.5x speedup
  • uint8 bulk (clean icache): ~5-7% slower
  • uint8 bulk (polluted icache): ~2x faster

related: #15155 #15257 #14980
also I tried this for int4 bulk but saw ~2.3x slower on avx-512 due to nibble unpacking overhead..

@github-actions github-actions Bot added this to the 10.5.0 milestone Jun 5, 2026
@iprithv iprithv force-pushed the bulk-offheap-scoring branch 4 times, most recently from 2336b8b to 94e8a44 Compare June 5, 2026 18:29
@iprithv iprithv changed the title Add bulk off-heap scoring for quantized vectors using Panama Vector API. add bulk off-heap scoring for uint8 quantized vectors using panama vector api Jun 5, 2026
@iprithv iprithv force-pushed the bulk-offheap-scoring branch 3 times, most recently from c47bf55 to 8a127b8 Compare June 5, 2026 18:54
@iprithv iprithv marked this pull request as ready for review June 5, 2026 19:09
@iprithv iprithv force-pushed the bulk-offheap-scoring branch from 8a127b8 to fdab794 Compare June 5, 2026 19:11
@iprithv

iprithv commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@rmuir could you please help review this? thanks!

IntVector acc1 = IntVector.zero(INT_SPECIES);
IntVector acc2 = IntVector.zero(INT_SPECIES);
IntVector acc3 = IntVector.zero(INT_SPECIES);
IntVector acc4 = IntVector.zero(INT_SPECIES);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this unrolling for integer-based math should be necessary. It should only be needed for the floating point due to causing change in result. I see some existing code in this file does it where I think it shouldn't, but I'm not convinced and let's avoid the trend. Can we try to remove the unrolling?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

acc1-acc4 aren't loop unrolling actually, they're the 4 document vectors d1-d4. each accumulates a separate result (q·d1, q·d2,...), same as sv1-sv4 in the float bulk methods right above. can't merge them into one. should I rename them maybe?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it isn't "just like the float bulk methods above". it isn't necessary for integer math.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry, but these are 4 separate output values, not 4 accumulators for the same result. acc1 goes to scores[0] (q·d1), acc2 goes to scores[1] (q·d2).... we need all 4 because each one is a different dot product against a different document vector. If we used a single accumulator we'd lose 3 of the 4 results. maybe I'm misunderstanding?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we doing 4 at a time?

@iprithv iprithv Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah, now I understand what you mean.. for integer math the bulk 4 at a time doesn't really buy us anything since there's no FP dependency chain to break, and the qv load would stay in cache anyway across separate calls..right?
I can try to remove the uint8 bulk methods and have the caller just call the single pair dot product 4 times instead..?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry about the confusion earlier. removed the uint8 bulk kernels and now bulkVectorOp just calls the single pair :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rmuir wanted to touch base with you on this, in case it got buried. Thanks!

@iprithv iprithv requested a review from rmuir June 10, 2026 06:56
@iprithv iprithv force-pushed the bulk-offheap-scoring branch 2 times, most recently from b69f01d to a52caf7 Compare June 10, 2026 10:43
@romseygeek romseygeek modified the milestones: 10.5.0, 10.6.0 Jun 26, 2026
@iprithv iprithv force-pushed the bulk-offheap-scoring branch from a52caf7 to 6774c6d Compare June 30, 2026 00:13
@iprithv

iprithv commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

moved changes entry to 10.6!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants