Skip to content

Use CUB bulk for row hashing - #22632

Merged
rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
bdice:use-cub-bulk-row-hashing
May 28, 2026
Merged

rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
bdice:use-cub-bulk-row-hashing

Conversation

@bdice

@bdice bdice commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replaces thrust::tabulate with cub::DeviceFor::Bulk in the row-hashing implementations:

  • MurmurHash3 x86 32-bit
  • xxHash 32-bit
  • xxHash 64-bit

This avoids a known slow path in CCCL's CUDA thrust::tabulate implementation for row-hashing-style functors. See benchmarks below. Also see NVIDIA/cccl#9070 and NVIDIA/cccl#9071.

The hashing logic and row-hasher preprocessing are unchanged; only the launch mechanism is changed.

This also adds a num_cols axis to HASHING_NVBENCH so the benchmark can cover wider tables.

Checklist

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

@bdice
bdice requested a review from a team as a code owner May 21, 2026 21:26
@bdice
bdice requested review from karthikeyann and vuule May 21, 2026 21:26
@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label May 21, 2026
@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Three hash implementations switched from thrust::tabulate to cub::DeviceFor::Bulk with CUDF_CUDA_TRY; the benchmark bench_hash now supports a num_cols axis producing alternating INT64/STRING columns and simplifies memory-read accounting.

Changes

Hash computation refactoring

Layer / File(s) Summary
MurmurHash3 x86_32 refactoring
cpp/src/hash/murmurhash3_x86_32.cu
Headers updated to include cudf/utilities/error.hpp and cub/device/device_for.cuh. Implementation switched to cub::DeviceFor::Bulk with a device lambda computing output_begin[i] = hasher(i), wrapped in CUDF_CUDA_TRY.
XXHash32 refactoring
cpp/src/hash/xxhash_32.cu
Headers adjusted to add CUB and error-handling support while removing Thrust/RMM includes. Implementation replaced with cub::DeviceFor::Bulk launching a device lambda that writes per-row hash results with CUDA error propagation.
XXHash64 refactoring
cpp/src/hash/xxhash_64.cu
Headers updated to include CUB device and CuDF CUDA error-handling. Implementation migrated to cub::DeviceFor::Bulk kernel launch iterating over row indices, assigning hashes from hasher(i), wrapped in CUDF_CUDA_TRY.

Benchmark: variable column generation

Layer / File(s) Summary
bench_hash num_cols axis and accounting
cpp/benchmarks/hashing/hash.cpp
SPDX year updated; bench_hash reads a new num_cols axis, builds a table with alternating INT64/STRING columns sized by num_cols, and replaces per-column memory-read counters with a single memory-read addition based on data->alloc_size().

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed The title 'Use CUB bulk for row hashing' clearly and concisely describes the main change—replacing thrust::tabulate with cub::DeviceFor::Bulk in hashing implementations.
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.
Description check ✅ Passed The pull request description is directly related to the changeset, clearly explaining the replacement of thrust::tabulate with cub::DeviceFor::Bulk in three hash implementations and the addition of a num_cols axis to the benchmark.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@bdice
bdice marked this pull request as draft May 21, 2026 21:48
@copy-pr-bot

copy-pr-bot Bot commented May 21, 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.

bdice added 2 commits May 22, 2026 16:26
…shing

# Conflicts:
#	cpp/src/hash/murmurhash3_x86_32.cu
#	cpp/src/hash/xxhash_32.cu
#	cpp/src/hash/xxhash_64.cu
@bdice bdice added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 22, 2026
@bdice
bdice marked this pull request as ready for review May 22, 2026 19:29

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

🧹 Nitpick comments (1)
cpp/benchmarks/hashing/hash.cpp (1)

104-104: ⚡ Quick win

Consider adding baseline and extra-wide num_cols points.

{2, 64} captures mid/wide behavior, but adding 1 (narrow baseline) and 256 (stress width) would improve comparability and scaling visibility for this benchmark family.

♻️ Proposed tweak
-  .add_int64_axis("num_cols", {2, 64})
+  .add_int64_axis("num_cols", {1, 2, 64, 256})
🤖 Prompt for 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.

In `@cpp/benchmarks/hashing/hash.cpp` at line 104, Update the benchmark axis
definition for num_cols to include baseline and stress points by changing the
.add_int64_axis("num_cols", {2, 64}) call to include 1 and 256 (e.g., {1, 2, 64,
256}) so the benchmark captures narrow baseline and extra-wide stress cases for
better comparability and scaling; modify the single expression invoking
.add_int64_axis("num_cols", ...) accordingly.
🤖 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.

Nitpick comments:
In `@cpp/benchmarks/hashing/hash.cpp`:
- Line 104: Update the benchmark axis definition for num_cols to include
baseline and stress points by changing the .add_int64_axis("num_cols", {2, 64})
call to include 1 and 256 (e.g., {1, 2, 64, 256}) so the benchmark captures
narrow baseline and extra-wide stress cases for better comparability and
scaling; modify the single expression invoking .add_int64_axis("num_cols", ...)
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 05c6f5ca-7c7a-4fd8-84e2-9311cc4d8fe9

📥 Commits

Reviewing files that changed from the base of the PR and between 0ade2e6 and 599ff26.

📒 Files selected for processing (1)
  • cpp/benchmarks/hashing/hash.cpp

Comment thread cpp/benchmarks/hashing/hash.cpp Resolved
@vuule

vuule commented May 22, 2026

Copy link
Copy Markdown
Contributor

IMO the PR description is too large. The testing section is not needed and benchmark results should be in a separate comment.

@bdice

bdice commented May 23, 2026 •

Copy link
Copy Markdown
Contributor Author

IMO the PR description is too large. The testing section is not needed and benchmark results should be in a separate comment.

Agreed, partly -- I was struggling to get my agent to include the right benchmark content (I had several forms of benchmarks, not all of which were useful). While focused on that, I overlooked the tests in the description. Normally I delete the testing section when an agent adds it, it's typically not very valuable. For the benchmark, I was unsure. For large benchmark tables I always use a separate comment. This felt small enough to include inline. Per your request, I will split the benchmark to a comment below.

@bdice

bdice commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

Benchmark

The original CCCL reproducer in NVIDIA/cccl#9070 uses a synthetic wide row-hash functor. Rechecked against unpatched CCCL upstream/main at fcd4ff4ea1 on NVIDIA GB10 with 2^20 rows:

rows cols thrust::tabulate cub::DeviceFor::Bulk speedup
1,048,576 1 90.444 us 89.137 us 1.01x
1,048,576 8 515.583 us 342.653 us 1.50x
1,048,576 64 8.213 ms 2.190 ms 3.75x
1,048,576 256 33.456 ms 8.425 ms 3.97x

The slowdown appears when the row functor is wide enough. For one column, there is effectively no difference.

The updated cuDF HASHING_NVBENCH benchmark now includes a num_cols axis and alternates INT64 and STRING columns. Before/after results for MurmurHash3 on NVIDIA GB10:

Command:

./cpp/build/latest/benchmarks/HASHING_NVBENCH \
  --benchmark hashing \
  --axis num_rows=1048576 \
  --axis num_cols=[2,64] \
  --axis nulls=0 \
  --axis hash_name=murmurhash3_x86_32 \
  --min-samples 5 \
  --min-time 0.05 \
  --timeout 20 \
  --devices 0
rows cols before after speedup
1,048,576 2 370.627 us 226.916 us 1.63x
1,048,576 64 22.620 ms 8.136 ms 2.78x

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

Love this change

@PointKernel PointKernel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean yet fast 🚀

@bdice

bdice commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 294bfa1 into NVIDIA:main May 28, 2026
118 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants