← Back to Pull requests

Make TestReconstructionError exact for BQ and NVQ and stop PQ flakes #854

Closed
unknown closed this pull request without merging on Nov 29, 2026 04:10 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 00:48 UTC
Author

Test-only change.

Problem

TestReconstructionError flakes in CI (for example run 46198768437). It compares the error on two random samples of vectors and requires the ratio to stay near 1.

  • The NVQ test called the binary-quantization helper, so it never tested NVQ.

  • Every limit sat only 3.4–4 standard deviations from random noise, so about 1 seed in 1,000 failed each check.

  • A wrong error value cancels out of the ratio, so the test couldn't catch one for any compressor.
  • Change

    Each compressor's error is now recomputed from its stored codes and must match within float rounding. Nothing depends on the random seed.

  • PQ: sum the squared distances from the stored codes' centroids, with and without global centering and anisotropic weighting, including subvectors of unequal width. Without anisotropic weighting, it also checks that each code is the subspace's nearest centroid.

  • BQ: restore the stored bits as 1/0.

  • NVQ: decode the stored codes with the scalar reference. The sizes cover both the SIMD loop and the tail at every vector width. Providers may decode NVQ values slightly differently (native rounds its constants differently, and SSE4.2 has no fused multiply-add), and the small per-dimension errors amplify that. So the NVQ tolerance adds, per dimension, the change that a one-ulp shift in the decoder's input can cause, computed with the reference decoder.
  • Testing

  • Panama and default providers on JDK 22: 100 seeds each, all passed (earlier BQ/NVQ version: 2,000 seeds).

  • Native provider on Ice Lake: SSE4.2, AVX2 and AVX-512 (JDK 22) and AVX-512 (JDK 25), 50–100 seeds each, all passed. Native on Arm is covered by CI.

  • Dropping one dimension from PQ's error makes the PQ check fail; breaking NVQ's SIMD query shuffle makes the NVQ check fail.

  • The class runs in about a second.
  • Diff: 229 lines (+171 / -58) across 2 files Reviewer: MarkWolters Review duration: 201m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 229 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%
    56%
    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.325
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #854"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 37.0% (MEDIUM) · Higher = larger blast radius
    37.0%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 16% · Safe to merge
    16%