Skip to content

Unify reduce and rfa policy - #9639

Merged
bernhardmgruber merged 3 commits into
NVIDIA:mainfrom
bernhardmgruber:rfa_policy_unify
Jul 2, 2026
Merged

bernhardmgruber merged 3 commits into
NVIDIA:mainfrom
bernhardmgruber:rfa_policy_unify

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

The RFA path in CUB's reduction is very similar to the normal two-phase path. We could potentially even try to unify it, but that may be more controversial. In any case, the tuning values for the ordinary reduction make equally sense for the RFA reduction (it just uses less of the values), so this PR proposes to just reuse the same tuning policy for RFA than for the ordinary reduction.

@copy-pr-bot

copy-pr-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jun 30, 2026
Comment on lines +819 to +820
typename KernelSource = DeviceReduceKernelSource<
PolicySelector,

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.

Comment: The kernel source will make this really difficult for the dispatch refactor because we already need the policy selector here

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.

We also needed it here in the old version

@bernhardmgruber
bernhardmgruber marked this pull request as ready for review July 1, 2026 07:14
@bernhardmgruber
bernhardmgruber requested review from a team as code owners July 1, 2026 07:14
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

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: 7a71522d-4e95-4c1c-8384-3dbd9a85b1b1

📥 Commits

Reviewing files that changed from the base of the PR and between 2b4a03f and c223c9f.

📒 Files selected for processing (10)
  • c/parallel/src/reduce.cu
  • cub/benchmarks/bench/reduce/deterministic.cu
  • cub/cub/device/device_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh
  • cub/cub/device/dispatch/kernels/kernel_reduce_deterministic.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce_deterministic.cuh
  • cub/test/catch2_test_device_reduce_deterministic.cu
  • cub/test/catch2_test_device_reduce_env.cu
💤 Files with no reviewable changes (1)
  • cub/cub/device/dispatch/tuning/tuning_reduce_deterministic.cuh
✅ Files skipped from review due to trivial changes (1)
  • c/parallel/src/reduce.cu
🚧 Files skipped from review as they are similar to previous changes (8)
  • cub/benchmarks/bench/reduce/deterministic.cu
  • cub/cub/device/dispatch/kernels/kernel_reduce_deterministic.cuh
  • cub/cub/device/device_reduce.cuh
  • cub/test/catch2_test_device_reduce_deterministic.cu
  • cub/cub/device/dispatch/tuning/tuning_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh
  • cub/cub/device/dispatch/dispatch_reduce.cuh
  • cub/test/catch2_test_device_reduce_env.cu

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Deterministic reduce now selects execution policies using determinism-aware tuning across compute capabilities, including GPU-to-GPU behavior.
    • Reduce tuning is now more consistently tied to the selected determinism mode when building the execution environment.
  • Bug Fixes
    • Improved consistency in stable reduction order handling when stronger determinism guarantees are requested.
  • Tests
    • Updated deterministic and environment-driven reduce tests to match the new determinism-aware policy selection.

Walkthrough

Deterministic reduce policy selection now flows through __determinism_t-based reduce policy types instead of rfa_policy and stable-order booleans across tuning, dispatch, kernels, tests, benchmarks, and JIT reduce generation.

Changes

Deterministic reduce policy unification

Layer / File(s) Summary
Determinism-aware tuning policy selector
cub/cub/device/dispatch/tuning/tuning_reduce.cuh, cub/cub/device/dispatch/tuning/tuning_reduce_deterministic.cuh (removed)
policy_selector stores a __determinism_t field, adds get_deterministic_tuning(cc), and policy_selector_from_types now templates on determinism; the standalone deterministic tuning header is removed.
Dispatch and public API wiring to determinism enum
cub/cub/device/device_reduce.cuh, cub/cub/device/dispatch/dispatch_reduce.cuh
Default policy selection now passes determinism tags into policy_selector_from_types for the gpu_to_gpu, not_guaranteed, and remaining branches.
Deterministic dispatch and kernel migration to reduce_policy
cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh, cub/cub/device/dispatch/kernels/kernel_reduce_deterministic.cuh
Deterministic dispatch now uses reduce_policy and agent_reduce_policy, and the deterministic kernel paths switch their local policy types and tuning include.
Benchmark and test updates for reduce_policy
cub/benchmarks/bench/reduce/deterministic.cu, cub/test/catch2_test_device_reduce_deterministic.cu, cub/test/catch2_test_device_reduce_env.cu
Benchmark and test selectors now return reduce_policy/agent_reduce_policy, and environment-based selection uses determinism-tagged reduce policy types.
Parallel reduce JIT determinism conversion
c/parallel/src/reduce.cu
CCCL determinism values are converted to CUDA execution determinism enums before policy selection and generated-source emission.

Possibly related PRs

  • NVIDIA/cccl#9568: Both changes touch determinism handling in c/parallel/src/reduce.cu and the reduce policy path.

Suggested reviewers: davebayer, alliepiper, miscco


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

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

🧹 Nitpick comments (3)
cub/benchmarks/bench/reduce/deterministic.cu (1)

23-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Line 23 should use constexpr auto p; this selector is constexpr and the policy is built entirely from compile-time tuning constants. As per coding guidelines, “All variables that can be evaluated at compile time must be declared constexpr.”

Source: Coding guidelines

cub/test/catch2_test_device_reduce_deterministic.cu (1)

30-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Line 30 should use constexpr auto p; the policy is compile-time-evaluable inside a constexpr selector. As per coding guidelines, “All variables that can be evaluated at compile time must be declared constexpr.”

Source: Coding guidelines

cub/test/catch2_test_device_reduce_env.cu (1)

123-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Declare these env locals as const auto; none of them are modified after construction. As per coding guidelines, “All variables that are not modified must be declared const.”

Also applies to: 138-139, 153-154, 169-170

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cccbfee2-bb4e-4da0-9776-1f32ea6d60d6

📥 Commits

Reviewing files that changed from the base of the PR and between 5ddd2d4 and f29f8ce.

📒 Files selected for processing (9)
  • cub/benchmarks/bench/reduce/deterministic.cu
  • cub/cub/device/device_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh
  • cub/cub/device/dispatch/kernels/kernel_reduce_deterministic.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce_deterministic.cuh
  • cub/test/catch2_test_device_reduce_deterministic.cu
  • cub/test/catch2_test_device_reduce_env.cu
💤 Files with no reviewable changes (1)
  • cub/cub/device/dispatch/tuning/tuning_reduce_deterministic.cuh

@bernhardmgruber
bernhardmgruber requested a review from a team as a code owner July 1, 2026 08:00

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a41f3515-523f-4533-b86d-18311115cb05

📥 Commits

Reviewing files that changed from the base of the PR and between f29f8ce and 2b4a03f.

📒 Files selected for processing (1)
  • c/parallel/src/reduce.cu

Comment thread c/parallel/src/reduce.cu Resolved
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 37m: Pass: 100%/291 | Total: 12d 16h | Max: 2h 36m | Hits: 17%/1152192

See results here.

@bernhardmgruber
bernhardmgruber merged commit 64b6b0e into NVIDIA:main Jul 2, 2026
313 of 314 checks passed
@bernhardmgruber
bernhardmgruber deleted the rfa_policy_unify branch July 2, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants