refactor(hdbscan): take the brute-force cosine zero rows from ZeroRowCosineDistances #4008
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
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
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
Alexandr-Solovev
Description
The HDBSCAN brute-force distance matrix (
hdbscan_dense_batch_impl.i) computed cosine distances withCosineDistancesand 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 fromcreatePairwiseDistances, 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
ZeroRowCosineDistancestests 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'scosine_distancesand the GPU path (fix_zero_norm_cosinetests the squared norm). Covered byhdbscan 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:testsandtest_batch_dpcpass.No public API or ABI changes.
🤖 Generated with Claude Code