perf(dbscan): resume the GPU seed search and find neighborhoods by GEMM #4006
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 403 lines diff across 5 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
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4006"
general
weight: 0.35
Alexandr-Solovev
Description
Two GPU DBSCAN speedups, one commit each.
1. Resume the search for the next cluster seed where the last one stopped
After each cluster, the GPU DBSCAN looks for the next seed, the smallest core row that has no cluster yet (
kernels_fp::start_next_cluster). It scanned from row 0 every time, with a single sub-group, so the scans cost O(rows x clusters), and with thousands of clusters they took most of the run.Every core row before the smallest unassigned one stays assigned, so each scan now starts at the row the previous scan found. The start is inclusive: in SPMD a rank's candidate is not necessarily the global seed, so it can still be unassigned. Labels are unchanged.
Performance. scikit-learn-intelex
DBSCAN.fiton an Intel GPU, dpnp input on the device,make_blobs(cluster_std=1),min_samples=5, float32;mainand this branch interleaved, median of 3 runs, identical labels:| data | clusters | speedup |
|---|---|---|
| 100000 x 2, 100 centers, eps 0.05 | 3953 | 5.6x |
| 200000 x 2, 100 centers, eps 0.03 | 6080 | 8.1x |
| 100000 x 8, 20 centers, eps 2 | 20 | 1.0x |
Tests. No behavior change;
test_batch_dpcandtest_spmd_dpcpass on an Intel GPU.2. Find euclidean and cosine neighborhoods by GEMM
On GPU,
get_coresandupdate_points_queuemeasure every distance by a scalar loop over the columns, one row per sub-group. On a single rank with more than 4 columns, euclidean and cosine neighborhoods now come from GEMM tiles over about 1 GB of distances (get_cores_gemm,update_points_queue_gemm), using the squared row norms for the expansion |x|^2 + |y|^2 - 2 x.y.compute_sums,compute_means,get_centeredfromstat/cov.hpp), so the expansion keeps the spread of float32 data far from the origin.4 (d + 2) eps_machine (|x|^2 + |y|^2), is recomputed from the coordinates (gemm_within), so points exactly epsilon apart stay neighbors, as with the exact kernels.Performance. scikit-learn-intelex
DBSCAN.fiton an Intel GPU, dpnp input on the device,make_blobs(cluster_std=1),min_samples=5, float32.main, the first commit and both commits were interleaved over 2 rounds, median of 3 runs each, and labels are identical in all of them:| data | metric | vs commit 1 | vs
main||---|---|---|---|
| 100000 x 8, eps 2 | euclidean | 3.1x | 3.1x |
| 200000 x 8, eps 2 | euclidean | 2.7x | 2.7x |
| 100000 x 32, eps 5 | euclidean | 13x | 13x |
| 100000 x 8, eps 0.02 | cosine | 1.8x | 1.8x |
| 100000 x 2, 100 centers, eps 0.05 | euclidean (exact kernels) | 0.95-1.07x | 5.3-6.0x |
The 100000 x 2 case doesn't use GEMM, so its speedup over
maincomes from commit 1. Its gap to commit 1 changes sign between runs.Tests.
dbscan wide data with neighbors at exactly epsilon match the definition: 150 pairs exactly epsilon apart, offset by 1000 and 8 columns wide. It fails without the boundary re-check.test_batch_dpcandtest_spmd_dpcpass on an Intel GPU.No public API or ABI changes.
🤖 Generated with Claude Code