Skip to content

Final stretch of standardizing Butina - #241

Open
Matthew-Neba wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
Matthew-Neba:butina-standardization
Open

Final stretch of standardizing Butina#241
Matthew-Neba wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
Matthew-Neba:butina-standardization

Conversation

@Matthew-Neba

Copy link
Copy Markdown
Contributor

Summary

  • Standardize Butina clustering behavior with RDKit.
  • Ensure deterministic higher-index tie-breaking and consistent cluster ordering (exactly matching RDkit), took a small hit in performance due to the extra work done

Signed-off-by: Matthew Neba <mattneba4343@gmail.com>
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Standardizes Butina clustering output with RDKit.

  • Uses higher point indices to break equal-neighbor-count ties consistently.
  • Orders cluster IDs and centroids by descending cluster size and centroid index.
  • Consolidates packed-candidate encoding and decoding across fused and non-fused implementations.
  • Replaces version-dependent ArgMax handling with a deterministic packed 64-bit reduction.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or compatibility failures identified.

The packed reduction preserves descending neighbor-count and higher-index ordering, temporary centroid storage remains correctly sized and stream-safe, and cluster IDs stay aligned with reordered centroids.

Important Files Changed

Filename Overview
src/butina.cu Implements deterministic higher-index tie-breaking, coordinated cluster/centroid remapping, and internal centroid storage when centroid output is omitted; no actionable defect identified.
src/butina_common.cuh Adds shared helpers for decoding packed Butina candidates while preserving inactive-candidate handling.
src/fused_butina.cu Updates fused centroid selection to use the renamed shared candidate-decoding helper without changing behavior.

Reviews (1): Last reviewed commit: "Final stretch of standardizing Butina" | Re-trigger Greptile

Comment thread src/butina.cu
//! Uses CUB's DeviceReduce::ArgMax when available (CCCL >= 2.8.0), otherwise falls back to custom kernel.
class ArgMaxRunner {
public:
ArgMaxRunner([[maybe_unused]] size_t num_items, cudaStream_t stream)

@scal444 scal444 Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This backup path was here because older versions of CCCL ship with olders versions of CUDA. The first CUDA that natively ships sufficient CCCL is 12.9 https://docs.nvidia.com/cuda/archive/12.9.1/cuda-toolkit-release-notes/index.html#cuda-toolkit-major-components

I'm hoping to support 12.5 for a few more release cycles due to some users being stuck on older AWS instances. Can you check on this?

EDIT: I see your replacement is in-kernel cubmax, not devicemax - so it may be this concern is invalid. If you can quickly double-check the API is supported in older cccl, this is probably good to go. Thanks!

@Matthew-Neba

Copy link
Copy Markdown
Contributor Author

Yeah, I just double checked it on 12.5, it works. Since the O(n^2) distance thresholding step dominates the runtime anyways (>60%), and some added complexity would'hv been needed to make the new changes work with DeviceReduce (which would'hv improved runtime by 1.5% at 30k fingerprints), decided to go for the in kernel cubmax.

@Matthew-Neba
Matthew-Neba requested a review from scal444 August 1, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants