Score native bulk similarity two targets per downcall #866
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.45) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 419 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #866"
general
weight: 0.35
MarkWolters
Score native bulk similarity two targets per downcall
Since #819, the Panama provider scores four targets per pass in bulk, but the native provider still loops over single-pair calls. This PR adds native bulk kernels.
What
dot_product_f32_x2,cosine_f32_x2andeuclidean_f32_x2score one query against two targets. They share the query loads and return results bit-identical to the single-pair kernels.NativeVectorUtilSupport's bulkdotProduct,cosineandsquareDistanceuse them. An odd last target goes through the single-pair kernel.uint64_t. That keeps the JDK downcall stub at 319 bytes, under C2's 325-byte inlining limit, so the heap segment wrappers are scalar-replaced and the bulk path allocates nothing.Why two targets, not four: a 4-target kernel gets a 600-byte stub, which doesn't inline. It allocated 432 B per call and made sift-128 search 14–16% slower.
Results
Search QPS. Recall is identical in every arm.
| Dataset | Vectors (base / queries) | ISA | Search threads | Overquery | Panama |
mainnative | This PR, native | PR vsmainnative ||---|---|---|---|---|---:|---:|---:|---:|
| sift-128 | 1M / 10k | AVX-512 | 16 | ×1 | 101,937 | 102,619 | 100,789 | −1.8% |
| sift-128 | 1M / 10k | AVX-512 | 16 | ×5 | 36,322 | 35,994 | 35,517 | −1.3% |
| sift-128 | 1M / 10k | AVX-512 | 16 | ×20 | 11,638 | 11,514 | 11,526 | +0.1% |
| sift-128 | 1M / 10k | AVX2 | 16 | ×1 | 114,286 | 102,056 | 108,813 | +6.6% |
| sift-128 | 1M / 10k | AVX2 | 16 | ×5 | 39,791 | 36,159 | 38,177 | +5.6% |
| sift-128 | 1M / 10k | AVX2 | 16 | ×20 | 12,820 | 11,558 | 12,386 | +7.2% |
| Cohere 1024-d | 100k / 10k | AVX-512 | 1 (pinned) | n/a | 1,620 | 1,350 | 1,494 | +10.6% |
| Cohere 1024-d | 100k / 10k | AVX2 | 1 (pinned) | n/a | 1,662 | 1,361 | 1,542 | +13.3% |
Build time (s)
| Dataset | Vectors | ISA | Build threads | Panama |
mainnative | This PR, native ||---|---|---|---|---:|---:|---:|
| sift-128 | 1M | AVX-512 | 8 | 97.6 | 91.5 | 85.7 (noisy: native runs ranged 82–95) |
| sift-128 | 1M | AVX2 | 8 | 89.3 | 89.4 | 87.7 |
| Cohere 1024-d | 100k | AVX-512 | 7 | 17.97 | 20.00 | 19.69 |
| Cohere 1024-d | 100k | AVX2 | 7 | 18.96 | 20.93 | 19.31 |
Machine: m6idn.4xlarge. Xeon Platinum 8375C, 8 cores / 16 vCPUs. sift search uses the JVM's shared thread pool, which comes to 16 threads on this machine. Cohere search runs on a single thread pinned to one CPU.
Setup
main, its native provider and Panama interleaved; medians of 3 rounds.-XX:UseAVX=2for Panama andJVECTOR_MAX_ISA=avx2for native.Tests:
NativeBulkScoringTestchecks that bulk results match single-pair results bit for bit across lengths 1–3072, group sizes 0–32 and edge values. It passes with no ISA cap and capped at AVX2 and SSE4.2.BulkScoringBenchmark(JMH) shows 0 B/op allocation, and bulk is faster than single-pair at 128-d and 1024-d.Related: #771, #821