Skip to content

Use cuda::stream_ref in remaining core libcudf APIs - #23691

Merged
vyasr merged 10 commits into
NVIDIA:mainfrom
vyasr:codex/cuda-stream-ref-batch-5
Aug 21, 2026
Merged

Use cuda::stream_ref in remaining core libcudf APIs#23691
vyasr merged 10 commits into
NVIDIA:mainfrom
vyasr:codex/cuda-stream-ref-batch-5

Conversation

@vyasr

@vyasr vyasr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

This fifth batch migrates the remaining core libcudf headers and implementations from rmm::cuda_stream_view to cuda::stream_ref.

It intentionally leaves the central stream helpers, such as get_default_stream(), the stream pool, fork_streams, and join_streams, on rmm::cuda_stream_view so this PR does not require Java, pylibcudf, or libcudf_streaming compatibility changes. Those helper updates are split into a downstream follow-up: vyasr#9

Contributes to #23636

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. Java Affects Java cuDF API. pylibcudf Issues specific to the pylibcudf package labels Aug 17, 2026
@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from fa33c11 to 834a687 Compare August 17, 2026 23:02
@vyasr vyasr changed the title Use cuda::stream_ref across remaining RAPIDS surfaces Use cuda::stream_ref across remaining libcudf C++ surfaces Aug 17, 2026
@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from 834a687 to ee2961a Compare August 17, 2026 23:03
cudf::table_view const& table)
{
auto stream = rmm::cuda_stream_default;
auto stream = cuda::stream_ref{};

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.

I think the default constructors like this are deprecated. Please check that. I see this in a few examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed in the split benchmarks/examples PR: #23697. I replaced the nullary cuda::stream_ref{} uses in the examples with explicit cuda::stream_ref{cudaStreamLegacy}.

@bdice bdice Aug 19, 2026

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.

I think you want cudaStreamDefault and not cudaStreamLegacy. We should respect compiling with PTDS enabled, which changes how cudaStreamDefault is interpreted.

[[nodiscard]] bool may_evaluate_null(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream) const override;
cuda::stream_ref stream) const override;

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 file appears to be missing <cuda/stream> includes. Same for cpp/src/ast/jit/expressions.cpp and others in cpp/src/ast. Can you check everything for IWYU?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here. I audited the AST/JIT changes and added direct <cuda/stream> includes where cuda::stream_ref is used, including this file and the corresponding AST/JIT implementation files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Follow-up: I found one remaining IWYU miss while rechecking this thread: cpp/include/cudf/ast/expressions.hpp also declares cuda::stream_ref and was still relying on transitive includes. Fixed in 5ab1aa5855 by adding a direct <cuda/stream> include there as well.

_null_handling{null_handling},
_mr{std::move(mr)},
_d_agg_kinds{0, rmm::cuda_stream_default, cudf::get_current_device_resource_ref()},
_d_agg_kinds{0, cuda::stream_ref{}, cudf::get_current_device_resource_ref()},

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.

I think the nullary constructor is deprecated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here. This now uses an explicit legacy stream construction: cuda::stream_ref{cudaStreamLegacy}.

Comment thread cpp/src/utilities/default_stream.cpp Outdated
#else
rmm::cuda_stream_view const default_stream_value{};
cuda::stream_ref const default_stream_value{};

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 should be explicit and not default-constructed. But should it be set to cudaStreamLegacy or cudaStreamDefault? Probably Legacy?

Suggested change
cuda::stream_ref const default_stream_value{};
cuda::stream_ref const default_stream_value{cuda::stream_ref{cudaStreamLegacy}};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here. I used the explicit legacy/default-stream spelling for the non-PTDS case: cuda::stream_ref const default_stream_value{cudaStreamLegacy}.

Comment thread cpp/tests/wrappers/timestamps_test.cu Outdated
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <cuda/stream_ref>

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.

There are a few files like this with header changes but no changes in the code itself. I don't think the header is used. Can we audit for those files and remove the headers if they're not required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in the split tests PR: #23696. I audited the test-only header additions and removed the unused stream headers.

@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from ee2961a to d6cfbf8 Compare August 17, 2026 23:48
@vyasr vyasr changed the title Use cuda::stream_ref across remaining libcudf C++ surfaces Use cuda::stream_ref across remaining libcudf APIs Aug 17, 2026
@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from d6cfbf8 to dd55488 Compare August 17, 2026 23:49
@vyasr vyasr changed the title Use cuda::stream_ref across remaining libcudf APIs Use cuda::stream_ref in core libcudf APIs Aug 18, 2026
@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from c60ef6b to 75513d2 Compare August 18, 2026 14:20
@vyasr vyasr added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Aug 18, 2026 — with ChatGPT Codex Connector
@vyasr
vyasr marked this pull request as ready for review August 18, 2026 16:43
@vyasr
vyasr requested a review from a team as a code owner August 18, 2026 16:43
@vyasr
vyasr requested review from lamarrr and misiugodfrey August 18, 2026 16:43
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Updated CUDA stream handling across public APIs to use the modern CUDA stream reference interface.
    • Updated stream access and synchronization while preserving existing operation behavior.
    • Applied consistently across datetime, interop, hashing, quantiles, reshaping, filtering, table, and utility operations.
  • Documentation
    • Updated developer guidance and examples to reflect the current CUDA stream interface.
  • Chores
    • Removed legacy stream-header usage and refreshed copyright notices.

Walkthrough

This change migrates cuDF stream APIs and implementations from rmm::cuda_stream_view to cuda::stream_ref. CUDA calls now use get(), synchronization uses sync(), and stream-related headers use <cuda/stream>.

Changes

CUDA stream API migration

Layer / File(s) Summary
Public and internal API migration
cpp/include/cudf/..., cpp/src/...
Stream parameters, return types, stored stream members, constructors, dispatchers, and helper APIs now use cuda::stream_ref.
Native CUDA stream access
cpp/include/cudf/detail/..., cpp/src/...
Kernel launches, CUB calls, CUDA runtime calls, and event operations now obtain native stream handles with stream.get().
Synchronization and default-stream handling
cpp/include/cudf/utilities/..., cpp/src/utilities/...
Synchronous operations now call stream.sync(). Default-stream and stream-pool implementations now use CUDA stream references directly.
Benchmarks, examples, tests, and docs
cpp/benchmarks/..., cpp/examples/..., cpp/tests/..., cpp/doxygen/...
Benchmark and example code construct cuda::stream_ref values, obtain native handles with .get(), and synchronize with .sync(). Documentation examples show the updated stream type.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: 🟠 High · up to c97b1

The stream API migration still contains multiple potential build blockers and a stream-ordering correctness hazard, including outdated synchronization calls, a malformed CUDA error-check statement, and operations that may run on the wrong stream. These issues should be fixed or explicitly accepted before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.48% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: migrating remaining core libcudf APIs to cuda::stream_ref.
Description check ✅ Passed The description directly explains the cuda::stream_ref migration and its compatibility scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from 6893200 to c54a021 Compare August 20, 2026 20:47
@vyasr

vyasr commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@vyasr
vyasr removed request for a team and mythrocks August 21, 2026 01:15
@vyasr

vyasr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@vyasr
vyasr removed the request for review from a team August 21, 2026 02:19
@vyasr
vyasr marked this pull request as ready for review August 21, 2026 03:08
@vyasr
vyasr force-pushed the codex/cuda-stream-ref-batch-5 branch from 5fe10e0 to 03a2c15 Compare August 21, 2026 05:45
@bdice

bdice commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Follow-up: can we document in the developer guide when to use stream.sync() vs. cudf::detail::sync_stream(stream)?

@vyasr

vyasr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: can we document in the developer guide when to use stream.sync() vs. cudf::detail::sync_stream(stream)?

Yup, happy to do that.

…ef-batch-5

# Conflicts:
#	cpp/src/utilities/host_memory.cpp

@misiugodfrey misiugodfrey left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me. I see a few new includes, but I assume they were suggested by IWYU since they seem to be required.

Comment thread cpp/include/cudf/detail/utilities/batched_memset.hpp
@vyasr

vyasr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@vyasr
vyasr merged commit 8c029c2 into NVIDIA:main Aug 21, 2026
142 of 146 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in cuDF Python Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants