Repository navigation
Conversation
Contributor
|
Before you submit for review:
If you did not complete any of these, then please explain below. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #845. Native graph builds from saved PQ codes slowed down about 60% in #836, which moved diversity scoring from a
centroid-pair table to reading the codebooks in Java.
pq_code_pair_f32, from a copy of the codebooksin which every centroid is zero-padded to one even width. One loop covers every width, so odd and mixed widths are
fast too. No per-pair allocation.
and small (such models have few subspaces). The table is built once, belongs to the model and counts in
ramBytesUsed().Code-pair scoring from saved codes, native, GNR (48 cores), JDK 22 (ns per pair, lower is better):
With in-progress codes this PR is 3-14x faster than #833 and as fast as or faster than main at every shape measured.
With the native kernels capped at AVX2, the table still loses at 8-float subspaces (1024/128: 281-302 ns against
192-194 from the codebooks) and ties or wins from 16 floats, so the cutoff is 16 floats for every ISA.
cohere-english-v3-1M, 128 subspaces of 8 floats, on-disk build, native: 25-31 s on GNR (48 cores) against 40-52 s on
main and 27-30 s at #833; pinned to 8 cores 97-111 s against 202-220 s on main and 106 s at #833. Recall unchanged.
Tests: PQ, retained-memory and native small-vector tests pass on JDK 22 and 25, native and Panama.
TestProductQuantizationcovers odd, mixed, wide and few-subspace shapes, and that the table follows the provider andis counted.
PQDiversityBenchmark(JMH) times code-pair scoring for saved and in-progress codes, including the shapes above.