You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Performance Improvements
Improved clustering and prediction efficiency by reusing temporary resources and reducing unnecessary memory allocation.
Optimized nearest-centroid distance calculations and norm handling, including for TF32-enabled workloads.
Improved processing of large nearest-neighbor workloads through batching.
The changes update norm policies and row batching in fused 1-NN, revise norm and workspace handling in nearest-centroid computation, and update K-means fitting and prediction to use these paths. Balanced prediction now reuses scratch buffers across minibatches.
Changes: K-means nearest-neighbor flow
Layer / File(s)
Summary
Backend norm policies and Cutile batching cpp/src/distance/detail/fused_distance_nn.cuh, cpp/src/distance/fused_distance_nn-inl.cuh, cpp/src/distance/detail/fused_distance_nn/cutile/fused_1nn_tile.cu
Backend plans now identify when no norms are read. Cutile 1-NN launches query rows in batches based on candidate size and device L2 cache size.
Nearest-centroid norms and workspace cpp/src/cluster/detail/kmeans_common.cuh, cpp/src/cluster/detail/minClusterDistanceCompute.cu
minClusterAndDistanceCompute accepts a distance-computation flag. The 1-NN path selects, computes, or skips norms according to the backend policy and places required buffers in aligned output storage. The row-norm implementation now uses a shared lane-group kernel.
K-means fitting and prediction integration cpp/src/cluster/detail/kmeans.cuh, cpp/src/cluster/detail/kmeans_common.cuh
The inertia pass selects and forwards per-batch TF32 norms. Prediction avoids materializing weights when it can use the original or normalized weights, and delegates norm handling to nearest-centroid computation. A null weights pointer now represents unit weights.
Balanced prediction reuses distance, workspace, and output buffers across minibatches. Missing norms are prefilled for the specified packed-binary metrics; otherwise, prediction can pass a null norm pointer.
This backport changes how K-means computes norms, reuses scratch buffers, and batches cuTile nearest-neighbor launches. No concrete defect was established in the reviewed changes. A very narrow floating-point precision question in the new norm kernel remains unverified and was not scored. Merging looks reasonable once the CI runs requested on this head pass.
Architecture risk: Medium · up to e94bb
The change affects 1 system.
Changed systems:cpp
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — cpp (service) was modified; 7 changed files map to changed impact.
Before / after behavior
observed — Modified behavior in cpp/src/cluster/detail/kmeans.cuh: cluster_cost adds an optional TF32-norm view parameter, defaulting to std::nullopt.
observed — Modified behavior in cpp/src/cluster/detail/kmeans.cuh: cluster_cost forwards the TF32-norm view to distance computation instead of always passing std::nullopt.
observed — Modified behavior in cpp/src/cluster/detail/kmeans.cuh: The final inertia pass now determines whether each batch’s assignment plan uses TF32 norms. For host data, it computes norms with that choice; when TF32 norms are selected, it also passes the corresponding TF32 norm view to the cost calculation.
observed — Modified behavior in cpp/src/cluster/detail/kmeans.cuh: The final inertia calculation now passes the optional TF32 norm view to cluster_cost.
Reliability and maintainability
inferred — Risk-relevant change factors for cpp: blast_radius_2; blast_radius_4; direct_dependents_2
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names a backport of a K-means change into release/26.12 and lists its three main themes: allocations, norms computation, and row batching. The raw summary shows changes in K-means scratch bu…
Description check
The description states that the change cherry-picks commit 471e6d7 from main into release/26.12 and explains that the original PR was merged into main by mistake. This…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names a backport of a K-means change into release/26.12 and lists its three main themes: allocations, norms computation, and row batching. The raw summary shows changes in K-means scratch buffers, norm selection, and cuTile 1-NN row batching, so the title matches the changeset. It does not name the release branch target in detail, but it identifies the main change and the PR it backports.
Full details: Description check
Explanation
The description states that the change cherry-picks commit 471e6d7 from main into release/26.12 and explains that the original PR was merged into main by mistake. This relates directly to the changeset, which is the backported K-means change, so it is not off-topic. It gives little technical detail about the code changes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picks 471e6d7 from main into
release/26.12. #3047 was intended for 26.12 and was merged into main by mistake.