Skip to content

Add memory resource parameter to cudf::hash_join constructors - #23223

Merged
rapids-bot[bot] merged 5 commits into
NVIDIA:mainfrom
PointKernel:add-mr-hash-join
Jul 15, 2026
Merged

Add memory resource parameter to cudf::hash_join constructors#23223
rapids-bot[bot] merged 5 commits into
NVIDIA:mainfrom
PointKernel:add-mr-hash-join

Conversation

@PointKernel

Copy link
Copy Markdown
Member

Description

Follow-up to #23220.

This PR adds an mr parameter to the cudf::hash_join constructors to control the memory usage of the internal cuco data structures, to better align with the temporary mr effort (#20780). The resource must remain valid for the lifetime of the hash_join object.

Checklist

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

@PointKernel PointKernel added feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Jul 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 10, 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.

@PointKernel

Copy link
Copy Markdown
Member Author

/ok to test 8e12597


/**
* @copydoc hash_join(cudf::table_view const&, null_equality, rmm::cuda_stream_view)
* @brief Construct a hash join object for subsequent probe calls.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

copydoc causes Doxygen check failures, and the only way to fix them is to duplicate the documentation instead of using copydoc.

@PointKernel

Copy link
Copy Markdown
Member Author

/ok to test c2c5d7d

@PointKernel
PointKernel marked this pull request as ready for review July 13, 2026 17:08
@PointKernel
PointKernel requested a review from a team as a code owner July 13, 2026 17:08
@coderabbitai

coderabbitai Bot commented Jul 13, 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: 8a10a59d-7665-4efb-87b4-65502396481e

📥 Commits

Reviewing files that changed from the base of the PR and between c2c5d7d and 269cfbb.

📒 Files selected for processing (3)
  • cpp/include/cudf/detail/join/hash_join.hpp
  • cpp/include/cudf/join/hash_join.hpp
  • cpp/src/join/hash_join/hash_join.cu
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpp/include/cudf/join/hash_join.hpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Hash joins now accept an optional device memory resource parameter to control temporary GPU memory allocations.
    • Default behavior remains unchanged when the memory resource is not specified.
  • Tests
    • Added coverage to verify memory-resource statistics are updated during hash-join construction and execution.
  • Documentation
    • Updated the public API documentation for hash-join constructors to include the new memory-resource parameter.

Walkthrough

Hash join constructors now accept an explicit device memory resource, propagate it to internal hash-table allocations, and retain default-resource behavior for public overloads. A test verifies allocation tracking and inner-join results with a statistics resource adaptor.

Changes

Hash Join Memory Resource

Layer / File(s) Summary
Public constructor contract
cpp/include/cudf/detail/join/hash_join.hpp, cpp/include/cudf/join/hash_join.hpp
Public and detail constructors document and accept the additional device memory resource parameter, with a current-device-resource default on public overloads.
Internal allocation propagation
cpp/src/join/hash_join/hash_join.cu
Constructor definitions and declarations propagate the resource into the internal hash join and use it for the Cuco hash-table allocator.
Memory resource validation
cpp/tests/join/join_tests.cpp
A test uses a statistics resource adaptor, checks peak allocation tracking, runs an inner join, and validates the output.

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

Suggested reviewers: wence-, misiugodfrey, mhaseeb123

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a memory resource parameter to cudf::hash_join constructors.
Description check ✅ Passed The description is directly related to the changeset and matches the implemented memory resource update and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cpp/include/cudf/detail/join/hash_join.hpp`:
- Around line 71-82: Replace the `@copydoc` directive above the detail-header
hash_join overload with duplicated documentation matching the corresponding
public declaration, including its parameter descriptions and the existing
load_factor documentation. Update only the documentation for hash_join; retain
the declaration and signatures unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 09118cc4-427a-46fb-974e-790095f0c448

📥 Commits

Reviewing files that changed from the base of the PR and between 151de69 and c2c5d7d.

📒 Files selected for processing (4)
  • cpp/include/cudf/detail/join/hash_join.hpp
  • cpp/include/cudf/join/hash_join.hpp
  • cpp/src/join/hash_join/hash_join.cu
  • cpp/tests/join/join_tests.cpp

Comment thread cpp/include/cudf/detail/join/hash_join.hpp Outdated

@bdice bdice 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.

This seems almost-right. We're using the passed-in mr because this is object-oriented, so we're treating the hash table more like output memory than temporary memory. However, this also needs to store a cuda::mr::any_resource<device_accessible> as a member of the cudf::hash_join object -- we don't want to put requirements on the lifetime of a ref. The resource should be reified and kept alive by the object holding the memory.

Compare to rmm::device_buffer, because this class is now more like a data container. https://github.com/rapidsai/rmm/blob/main/cpp/include/rmm/device_buffer.hpp

For container-like classes, we use cuda::mr::any_resource<cuda::mr::device_accessible> as the mr parameter rather than a ref, to allow construction from resource rvalues to avoid making a copy. Then store _mr{std::move(mr)} as a member.

@PointKernel

PointKernel commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

@bdice Good point on ownership. Rather than adding a member, I switched the constructor mr parameter to cuda::mr::any_resource<cuda::mr::device_accessible> (matching rmm::device_buffer/device_uvector) and move it into the cuco map's allocator. rmm::mr::polymorphic_allocator already stores an owning any_resource member, and the map holds the allocator by value, so the resource is reified and kept alive for exactly the hash table's lifetime without a separate hash_join member.

@bdice bdice 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.

Excellent, thanks for the ownership fix!

@PointKernel

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit 3227419 into NVIDIA:main Jul 15, 2026
259 of 261 checks passed
@PointKernel
PointKernel deleted the add-mr-hash-join branch July 15, 2026 16:42
rapids-bot Bot pushed a commit that referenced this pull request Jul 20, 2026
#23263)

Follow-up to #23220 and #23223.

This PR adds an `mr` parameter to the `cudf::distinct_hash_join` constructors to control the memory usage of the internal cuco hash table, to better align with the temporary mr effort (#20780).

Authors:
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - Muhammad Haseeb (https://github.com/mhaseeb123)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #23263
rapids-bot Bot pushed a commit that referenced this pull request Jul 21, 2026
…3264)

Follow-up to #23220 and #23223.

This PR adds an `mr` parameter to the `cudf::filtered_join` constructors to control the memory usage of the internal cuco hash table, to better align with the temporary mr effort (#20780).

Authors:
  - Yunsong Wang (https://github.com/PointKernel)
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - David Wendt (https://github.com/davidwendt)
  - Vyas Ramasubramani (https://github.com/vyasr)

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

Labels

feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants