← Back to Pull requests

perf(dbscan): resume the GPU seed search and find neighborhoods by GEMM #4006

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

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.fit on an Intel GPU, dpnp input on the device, make_blobs(cluster_std=1), min_samples=5, float32; main and 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_dpc and test_spmd_dpc pass on an Intel GPU.

2. Find euclidean and cosine neighborhoods by GEMM

On GPU, get_cores and update_points_queue measure 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.

  • Euclidean data are centered first (compute_sums, compute_means, get_centered from stat/cov.hpp), so the expansion keeps the spread of float32 data far from the origin.

  • Any distance within the expansion's rounding bound of epsilon, 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.

  • SPMD and data with up to 4 columns keep the exact kernels.
  • Performance. scikit-learn-intelex DBSCAN.fit on 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 main comes 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_dpc and test_spmd_dpc pass on an Intel GPU.

    No public API or ABI changes.

    🤖 Generated with Claude Code

    Diff: 403 lines (+302 / -101) across 5 files Reviewer: Alexandr-Solovev Review duration: 21976m
    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
    0.45
    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
    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
    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: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    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: 23.9% · Safe to merge
    23.9%