← Back to Pull requests

[python] Stream raw vector batches for local single-query search #11254

Closed
unknown closed this pull request without merging on Nov 19, 2026 07:41 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 15:48 UTC
Author

Closes #11253

Purpose

PyPaimon's local executor currently collects all raw vectors for a single query before it scores the first batch. This change passes Arrow batches directly to the existing scorer, which updates one Top-K heap throughout the scan.

With parallel reads, each split group has at most one read in flight and one batch of lookahead. The calling thread scores whichever batch is ready. If scoring fails, it waits for outstanding reads before closing the readers.

Tests

The new tests cover parallel Top-K results, bounded read-ahead, candidate filtering, and reader cleanup after errors. The regression run passed 202 tests and skipped one S3 checksum test that requires PyArrow 22+. Both versions matched the published L2 Top-10 for GIST1M queries 0, 499 and 999. Dataset

Both versions read the same unindexed GIST1M snapshot (1M rows × 960 dimensions, 12 splits). The table shows medians for query 0 over three runs after one warmup per version, comparing master d90a902d with the patch.

| Executor | Storage | Peak scoring-process RSS (MiB), before → after | Query time (s), before → after |
| --- | --- | ---: | ---: |
| Local (2 CPUs) | Local Parquet | 4,865 → 795 (-83.7%) | 12.90 → 8.57 (-33.6%) |
| Local (2 CPUs) | OSS | 5,158 → 683 (-86.8%) | 13.25 → 9.47 (-28.5%) |
| Ray (2 workers) | Worker-local Parquet | 268 → 268 (0.0%) | 11.69 → 11.54 (-1.3%) |
| Ray (2 workers) | OSS | 282 → 279 (-1.1%) | 18.35 → 18.75 (+2.2%) |

Ray workers already score one split at a time from a batch reader, and their peak RSS stayed close across versions. The Ray rows report the largest scoring worker's peak and include the time to fetch the ten hits.

Diff: 216 lines (+162 / -54) across 2 files Reviewer: wangzhigang1999 Review duration: 953m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 216 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.322
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11254"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.6% (MEDIUM) · Higher = larger blast radius
36.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%
Repository