Skip to content

cuda.coop: add Numba Exchange and Shuffle - #11208

Draft
tpn wants to merge 8 commits into
codex/cuda-coop-numba-logical-warp-load-storefrom
codex/cuda-coop-numba-exchange-shuffle
Draft

cuda.coop: add Numba Exchange and Shuffle#11208
tpn wants to merge 8 commits into
codex/cuda-coop-numba-logical-warp-load-storefrom
codex/cuda-coop-numba-exchange-shuffle

Conversation

@tpn

@tpn tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why this is needed

The preceding stack extends Load and Store through block, physical-Warp, and
logical-Warp providers. This PR adds Exchange and Shuffle as independently
registered primitive families, exercising the provider, result, storage, and
synchronization seams without changing generic activation, dispatch, caching,
or phase orchestration.

Reviewer-visible behavior

  • Adds portable exchange for block, physical-Warp, and logical-Warp
    striped/blocked layout conversion.
  • The qualified API preserves that shared surface and adds Block-only
    warp-striped, scatter, guarded/flagged, ranks/flags, and warp-time-slicing
    extensions.
  • Warp Exchange exposes the shared striped/blocked modes; scatter is not
    exposed for Warp groups.
  • Adds portable Block shuffle for unit up and down operations.
  • The qualified API preserves that shared surface and additionally supports
    scalar offset and rotate forms.
  • All public mode selectors are lowercase strings.
  • Exchange and Shuffle return fresh payloads and preserve caller inputs,
    including ranks that CUB may modify internally.
  • Storage-bearing forms use implementation-owned leading-pointer storage with
    block or exact-mask Warp reuse synchronization and disjoint slices per
    logical group.
  • Payload dtypes and extents, signed ranks, integral flags, selectors, and
    runtime distance ABIs are validated before provider specialization.
blocked = coop.exchange(
    coop.this_block(),
    striped,
    mode="striped_to_blocked",
)
shifted = coop.shuffle(
    coop.this_block(),
    blocked,
    mode="down",
)

Validation

  • The exact head passed 168 focused public-surface and Exchange/Shuffle tests.
  • The exact final-stack wheel at 9b299e894f passed 607 contract, packaging,
    public-surface, and activation tests outside the source tree.
  • That wheel passed 50 real NVRTC LTO/nvJitLink compile tests and all 366
    runtime tests on an RTX PRO 6000.
  • Changed-file pre-commit and git diff --check passed.

Stack and scope

This draft is stacked on #11207. Shuffle boundary-output projections, Reduce,
Scan, callbacks, and Python operator compilation remain deferred.

Invalid runtime rotate bounds and runtime offset values outside the
signed-32-bit provider ABI trap the device and invalidate that CUDA context;
the implementation tests these paths in isolated processes.

@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-logical-warp-load-store branch 2 times, most recently from a1439f9 to 8ac30b9 Compare September 4, 2026 18:05
tpn added 7 commits September 4, 2026 11:06
Define backend-neutral CUB BlockExchange, WarpExchange, and
BlockShuffle specializations. Add portable group contracts for
out-of-place results, storage, synchronization, and preconditions.

Signed-off-by: Trent Nelson <trent@trent.me>
Register family-owned inference and provider selection for block and
Warp Exchange plus block Shuffle. Lower storage-bearing CUB calls with
scope-aware reuse barriers, input preservation, checked runtime Rotate
distances, and exact logical-Warp masks.

Signed-off-by: Trent Nelson <trent@trent.me>
Exercise installed-wheel exports, strict typing, metadata, and package
contents for both portable and qualified APIs. Cover invalid selectors,
payloads, ranks, flags, and scalar Shuffle calls.

Signed-off-by: Trent Nelson <trent@trent.me>
Describe supported layouts, scatter preconditions, storage ownership,
barriers, Shuffle boundaries, and runtime Rotate traps. Update API
coverage without promising deferred boundary results.

Signed-off-by: Trent Nelson <trent@trent.me>
State the signed int32 provider ABI for Offset and distinguish ABI
overflow traps from ordinary out-of-block source behavior. Exercise both
overflow directions in isolated subprocesses.

Signed-off-by: Trent Nelson <trent@trent.me>
Require string selectors across portable and qualified APIs, including
planner, rewrite, and provider validation. Reuse the portable Exchange
mode alias and keep qualified extensions block-only so Warp retains the
shared layout contract.

Signed-off-by: Trent Nelson <trent@trent.me>
Accept structural read-only payloads for Exchange and Shuffle inputs,
including Exchange ranks and valid flags. Keep mutable result typing for
both portable and qualified APIs.

Reject enum-backed modes and distance compatibility objects before
provider selection so runtime validation matches literal-only stubs.

Signed-off-by: Trent Nelson <trent@trent.me>
@tpn
tpn force-pushed the codex/cuda-coop-numba-exchange-shuffle branch from 7587282 to 03793c5 Compare September 4, 2026 18:10
Mirror portable input and result annotations in qualified markers.

Keep Block Exchange ranks and flags as qualified-only controls.

Treat time slicing the same way and assert the shared runtime contract.

Signed-off-by: Trent Nelson <trent@trent.me>
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