← Back to Pull requests

Stream BenchYAML builds with PQ or full precision as well as ASH #852

Closed
unknown closed this pull request without merging on Nov 29, 2026 20:33 UTC
View on GitHub
unknown unknown commented on Nov 28, 2026 07:12 UTC
Author

Stream BenchYAML builds with PQ or full precision as well as ASH

Stacked on #856. Review that first; GitHub moves this PR's base to main when #856 merges.

BenchYAML's construction.streaming: Yes built only ASH indexes. In-progress PQ codes, which a database uses while it builds an index, could be timed only with a JMH benchmark. This change lets any streaming case use ASH, PQ or no compression. In-progress PQ builds can then be benchmarked from a YAML file, and PQ and ASH compared for live graph builds that might one day replace full-precision ones. One use is checking a fix for #845 on both PQ paths.

Each construction compression defines how a streaming index starts and what an insert does:

  • ASH: unchanged. A StreamingASHIndex starts warm (coldStartSize: [0]) or cold, and may train while vectors arrive.

  • PQ: the PQ model is trained first. Each arriving vector is encoded into MutablePQVectors and then added to the graph, which scores with those codes. With refineAfter: [N], once N vectors have arrived, inserts wait while the codebook is fine-tuned on them (ProductQuantization.refine), the codes so far are re-encoded, and the graph's edges are rescored (GraphIndexBuilder.rescore). This is what a compaction that inherits a codebook does. The refine keeps the model's anisotropic threshold, and once it's done, inserts no longer take the lock.

  • None: each arriving vector is added to the graph with exact scores.
  • The rest is shared: one insert thread per construction worker in file order, the timings, the memory report, and the onDisk write and reload. Searches use the codes the index built. For ASH and PQ, those codes are stored beside the index, both on disk and in the saved-index cache, and reloaded with it. The codes file gains a PQ format for this, and batch builds still store only ASH codes, as before. onDisk None indexes are searched with search.compression, as other on-disk builds are.

    PQ and None take no cold start: coldStartSize and trainWhileStreaming are rejected unless omitted, [0] or No. refineAfter requires PQ and is 0 or at least the PQ k, so every centroid is refined from its own vectors. BQ streaming is rejected, because MutableBQVectors is not safe for concurrent writes.

    Also:

  • With construction.workers set, PQ training and the streaming refine run on the construction pool, as ASH training already does. Default runs keep the library's pools, so earlier results are unchanged.

  • Fixes the guide's cold-start description: a cold ASH index searches its recorded vectors exactly and builds its graph only once its first model is ready.

  • Adds the examples index-parameters/streaming-pq (cohere-english-v3-1M, PQ with D/8 subspaces, with and without a refinement after 128,000 vectors) and index-parameters/streaming-fp (the same build with exact scores).
  • Streaming times are comparable only with other streaming runs: insert order and threads differ from batch builds.

    Tests


  • TestGridASHIntegration:

  • - PQ codes built on arrival match one-pass encoding.
    - After a refinement, every code comes from the refined model and nodes added before it stay reachable.
    - A refined anisotropic model keeps its threshold.
    - PQ and None stream, then search, in memory and on disk; on disk, PQ is searched with the reloaded codes.
    - PQ codes round-trip through the codes file, and only for indexes that built them.
    - Cold starts outside ASH, refineAfter outside PQ or below k, and BQ are rejected.
    - The examples parse.
    - The existing ASH streaming tests are unchanged.
  • The io.github.jbellis.jvector.example tests (56) pass on Ice Lake (8 cores) with JDK 22 and JDK 25.
  • Diff: 463 lines (+347 / -116) across 5 files Reviewer: MarkWolters Review duration: 2241m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 463 lines diff across 5 files
    0.46
    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.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #852"
    general weight: 0.35
    Reviewers
    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: 45.6% (MEDIUM) · Higher = larger blast radius
    45.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: 18% · Safe to merge
    18%