Skip to content

Add RAFT option to make_blobs - #8482

Open
NIne-WIngEd wants to merge 1 commit into
NVIDIA:mainfrom
NIne-WIngEd:enh-make-blobs-raft-clean
Open

Add RAFT option to make_blobs#8482
NIne-WIngEd wants to merge 1 commit into
NVIDIA:mainfrom
NIne-WIngEd:enh-make-blobs-raft-clean

Conversation

@NIne-WIngEd

Copy link
Copy Markdown

Adds an opt-in RAFT path to cuml.datasets.make_blobs.

The existing CuPy path stays the default.

Added focused tests for seeded reproducibility and C/F layouts.

Fixes #7363.

@NIne-WIngEd
NIne-WIngEd requested review from a team as code owners August 16, 2026 02:45
@NIne-WIngEd
NIne-WIngEd requested a review from csadorf August 16, 2026 02:45
@copy-pr-bot

copy-pr-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5c4e8ae1-4aa7-43b3-af9c-cb230866b218

📥 Commits

Reviewing files that changed from the base of the PR and between 0d3a802 and 8bcdb37.

📒 Files selected for processing (4)
  • python/cuml/cuml/datasets/CMakeLists.txt
  • python/cuml/cuml/datasets/_blobs.pyx
  • python/cuml/cuml/datasets/blobs.py
  • python/cuml/tests/test_make_blobs.py

Included review availability: Your plan includes up to 12 reviews per rolling hour; 10 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added an optional RAFT-backed execution path for make_blobs dataset generation.
    • Supports generated or explicitly provided centers, configurable dtypes and memory layouts, reproducible random states, and optional center output.
    • Added GPU-backed dataset generation with validation for supported inputs and clear errors for unsupported configurations.
  • Bug Fixes
    • Improved consistency and parity between supported dataset-generation paths.

Walkthrough

Adds an optional RAFT-backed make_blobs path. The change includes a Cython GPU bridge, input validation, native dispatch, documentation, and tests for parity, reproducibility, layouts, dtypes, centers, and invalid inputs.

Changes

RAFT-backed make_blobs

Layer / File(s) Summary
GPU bridge and build integration
python/cuml/cuml/datasets/CMakeLists.txt, python/cuml/cuml/datasets/_blobs.pyx
Adds the Cython module to the build. The wrapper allocates CuPy outputs, dispatches float32 and float64 native overloads, synchronizes the handle, and returns generated data and labels.
RAFT API path and validation
python/cuml/cuml/datasets/blobs.py, python/cuml/tests/test_make_blobs.py
Adds use_raft=False, validates RAFT-supported arguments, invokes native generation, documents restrictions, and tests parity, reproducibility, centers, layouts, dtypes, and validation errors.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 8bcdb

The PR adds an opt-in RAFT path while preserving the existing default behavior; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

  • NVIDIA/cuml#8481: Implements the same RAFT-backed make_blobs path in the same dataset files and tests.

Suggested reviewers: dantegd

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding a RAFT option to make_blobs.
Description check ✅ Passed The description accurately covers the opt-in RAFT path, default CuPy behavior, tests, and linked issue.
Linked Issues check ✅ Passed The changes implement the RAFT option, add a Python wrapper, and preserve the existing CuPy path as required by issue #7363.
Out of Scope Changes check ✅ Passed The build configuration, implementation, documentation, tests, and copyright update support the stated objectives without unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@csadorf csadorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for the contribution! I have a few change requests and questions before we can move forward.

return_centers=False,
order="F",
dtype="float32",
use_raft=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Whether we use RAFT or CuPy for the actual implementation is an implementation detail and should not be exposed within the Python API. The routing should be purely internal. I ran some preliminary benchmarks and it seems that the RAFT implementation is generally much faster.

We should maintain the CuPy implementation only to overcome any present limitations or if there is a non-trivial regime where CuPy is generally faster (which does not seem to be the case).

<int64_t>n_centers,
row_c,
<const float*>ctr_p,
<const float*>0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The native API already accepts per-cluster standard deviations through the cluster_std device pointer. Could we pass an array here instead of restricting the RAFT path to a scalar cluster_std? That would preserve the existing Python API and eliminate one fallback case.


if return_centers and made_ctr:
raise ValueError(
"`return_centers=True` with generated centers is not supported "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we preserve return_centers=True by generating the centers in the Python compatibility layer and passing them explicitly to RAFT? That would allow generated-center calls to use RAFT without narrowing the existing API.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be clear, we should only do that for this specific condition.


# Native labels are integers; Python make_blobs has historically returned
# them in the requested floating dtype, so keep that behavior here.
h.sync()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make_blobs is decorated with mlfunc, so its CuPy operations run on Stream.ptds, and the default RAFT handle also uses cudaStreamPerThread. Why do we need to sync here?

Comment on lines +116 to +117
# Native labels are integers; Python make_blobs has historically returned
# them in the requested floating dtype, so keep that behavior here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This in-line comment seems to be at the wrong spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake Cython / Python Cython or Python issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a RAFT-based implementation for cuml.datasets.make_blobs

3 participants