Skip to content

[cudax] Harden cooperative Reduce reuse - #11209

Draft
tpn wants to merge 2 commits into
codex/cuda-coop-numba-exchange-shufflefrom
codex/cuda-coop-cudax-reduce-reuse-prereq
Draft

[cudax] Harden cooperative Reduce reuse#11209
tpn wants to merge 2 commits into
codex/cuda-coop-numba-exchange-shufflefrom
codex/cuda-coop-cudax-reduce-reuse-prereq

Conversation

@tpn

@tpn tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why this is needed

The next cuda.coop Numba-CUDA-MLIR layer lowers hierarchy-aware reductions
through cuda::experimental::coop::reduce. Consecutive reductions cannot
safely reuse CUB scratch until every member has finished, and independently
synchronized mapped Warp groups must not alias one shared scratch object.

Embedded compiler providers also need to consume CUDAX group headers without
pulling in cooperative_groups.h.

This is a separate prerequisite so the CUDAX correctness change can be
reviewed independently from the Python Reduce API.

Reviewer-visible behavior

  • Isolates mapped-Warp reduction scratch by physical block-Warp ownership.
  • Adds the collective barriers required before block, cluster, grid, and
    mapped-group scratch is reused.
  • Covers consecutive broadcast and root-only reductions, nested and viewed
    mapped groups, and static and dynamic block extents.
  • Adds _CUDAX_DISABLE_COOPERATIVE_GROUPS_INTEROP as an opt-out for embedded
    compilation while preserving the existing default interop behavior.

Validation

Focused CUDAX targets passed on an RTX PRO 6000 with CUDA 13.3 under both
C++17 and C++20:

  • Group embedding without cooperative-groups interop.
  • Warp, block, cluster, and grid Reduce.
  • Mapped warps within a block.

Changed-file pre-commit, including clang-format, gersemi, codespell, and
secret scanning, and git diff --check passed.

Stack and scope

This draft is stacked on #11208. It does not add a Python API or compiler
lowering. Grid Reduce still requires a per-launch workspace policy before a
Numba backend can expose it safely.

@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 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 Sep 4, 2026
@tpn
tpn force-pushed the codex/cuda-coop-numba-exchange-shuffle branch from 7587282 to 03793c5 Compare September 4, 2026 18:10
@tpn
tpn force-pushed the codex/cuda-coop-cudax-reduce-reuse-prereq branch from ee61c0a to 64d2fcd Compare September 4, 2026 18:11
tpn added 2 commits September 4, 2026 11:20
Mapped warp groups synchronize independently, but reduce used one shared
scratch object. Concurrent siblings could corrupt CUB storage, partials,
and broadcast results. Passing owning groups by value could also destroy
copied synchronizer state.

Give each physical block warp its own temporary and value slot. Use the
exact static block extent when available and the architectural 32-warp
bound otherwise. Reject noncontiguous mappings until a safe physical
membership traversal is available.

Add the collective barriers required before block, cluster, grid, and
mapped-group scratch is reused by a later call. Add repeated regressions
for direct, nested, and viewed mappings with static and dynamic extents,
plus block, cluster, and grid scratch reuse.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Signed-off-by: Trent Nelson <trent@trent.me>
Embedded compiler providers cannot always include cooperative_groups.h. Add an opt-out that suppresses the include and conversion overloads while preserving the default interoperability behavior.

Signed-off-by: Trent Nelson <trent@trent.me>
@tpn
tpn force-pushed the codex/cuda-coop-cudax-reduce-reuse-prereq branch from 64d2fcd to be03724 Compare September 4, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant