← Back to Pull requests

refactor(hdbscan): take the brute-force cosine zero rows from ZeroRowCosineDistances #4008

Open
unknown opened this pull request with 162 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 07, 2026 13:59 UTC
Author

Description

The HDBSCAN brute-force distance matrix (hdbscan_dense_batch_impl.i) computed cosine distances with CosineDistances and then, in a serial loop, set every row and column of a zero-norm point to 1, as scikit-learn does. ZeroRowCosineDistances (service_kernel_math.h), which DBSCAN and the HDBSCAN medoid computation already get from createPairwiseDistances, does the same per tile from the norms it already holds. The brute-force path now uses it; the diagonal is still reset to 0 afterwards.

15 lines fewer. One behavior change: the old loop matched rows whose coordinates are all exactly 0, while ZeroRowCosineDistances tests the stored norm, so a row whose squared norm underflows (float [1e-25, 0], double [1e-170, 0]) is now a zero row too, at distance 1 from every other row, where it used to get -inf or NaN. That matches scikit-learn's cosine_distances and the GPU path (fix_zero_norm_cosine tests the squared norm). Covered by hdbscan brute_force: a zero row is at cosine distance 1 like in scikit-learn, which now also runs underflowing rows and fails on the base; bazel test --config=host //cpp/oneapi/dal/algo/hdbscan:tests and test_batch_dpc pass.

No public API or ABI changes.

🤖 Generated with Claude Code

Diff: 162 lines (+121 / -41) across 2 files Reviewer: Alexandr-Solovev Review duration: 21976m
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 162 lines diff across 2 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
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
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.305
Real PR Conversation Timeline
1 comments
"Review active on #4008"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 46.7% 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: 34.9% (LOW) · Higher = larger blast radius
34.9%
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: 46.7% · Lower = rushed or shallow review
46.7%
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.6% · Safe to merge
18.6%