Skip to content

Add Numba-CUDA-MLIR support for cuda.coop Load and Store - #11200

Open
tpn wants to merge 1 commit into
codex/cuda-coop-numba-block-load-storefrom
codex/cuda-coop-numba-block-load-store-algorithms
Open

tpn wants to merge 1 commit into
codex/cuda-coop-numba-block-load-storefrom
codex/cuda-coop-numba-block-load-store-algorithms

Conversation

@tpn

@tpn tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why this is needed

The common API in #11182 needs a compiler integration to execute inside GPU
kernels. This adds Numba-CUDA-MLIR lowering for the complete Block, physical
Warp, and logical Warp Load/Store surface.

Install the extra for the matching CUDA major, then register before compiling:

python -m pip install "cuda-coop[numba-cuda-mlir-cu13]"
from cuda import coop

coop.register("numba-cuda-mlir")
from numba_cuda_mlir import cuda

Registration works with either import order, is safe to repeat, and also
accepts "numba_cuda_mlir". Numba-first automatic registration remains
available. import cuda.coop.numba_mlir as numba_coop registers the backend
and exposes its memory namespaces. The base wheel includes this integration.
The CUDA 12/13 extras install the same wheel and add the required backend
dependencies; the base installation declares no Python package dependencies.

Load/Store behavior

Algorithms Temporary storage Default reuse synchronization
direct, striped, vectorize None None
Block transpose, warp_transpose, warp_transpose_timesliced Per-block Trailing block barrier
Warp transpose Per physical/logical group Trailing barrier with that group's mask

Load mutates its supplied ThreadData and returns None. Transpose Store
preserves its input payload. Partial Load preserves invalid slots unless
oob_default is supplied. Each Warp group addresses its own consecutive tile;
offset is applied afterward and valid_items is relative to that tile.

Block operations support caller-supplied TempStorage; Warp operations use
compiler-owned storage. Shared and exclusive allocations both synchronize
by default. auto_sync=False transfers reuse synchronization to the caller.
Runtime controls must be uniform within the selected group, and callers must
keep valid_items within the tile bounds. Invalid runtime bounds trap before
narrowing to the CUB ABI.

The adapter validates dtypes, alignment, supported group forms, descriptor
provenance, and shared-memory compatibility before provider generation.
Collective helpers must inline into their kernels. The guarded compiler
integration supports Numba-CUDA-MLIR 0.5.x. With this compiler, user dynamic
shared arrays cannot coexist with cooperative backing; user static arrays
require static cooperative backing. Storage-free operations introduce no
such conflict.

This PR includes compile/runtime tests, Load/Store examples, and GPU-hidden
compiler plus GPU runtime CI stages. Stacked on #11182; subsequent algorithm
families start with Exchange and Shuffle in #11208.

Validation

Fresh installed-wheel checks at ecec1c57ed97:

  • Host contracts and packaging (full suites): 434 passed on Python 3.14.
  • Numba backend unit/compiler tests (focused, GPUs hidden): 67 passed on Python 3.14.
  • GPU runtime tests (focused): 19 passed on Python 3.14.

Wheel validation and source, installed-package, and bundled-header comparisons passed.

Remote CI passed at ecec1c57ed97: GitHub Actions run. All exact-head checks and statuses, including pre-commit, are successful or conditionally skipped.

@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-block-load-store-algorithms branch 2 times, most recently from 39755f7 to a4d8965 Compare September 4, 2026 17:54
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 9421804 to 58d3e31 Compare September 6, 2026 06:42
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from a4d8965 to 1b61cfd Compare September 6, 2026 06:42
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch 4 times, most recently from 80778a3 to c76bed3 Compare September 9, 2026 20:58
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch 2 times, most recently from 81dd113 to f115dac Compare September 9, 2026 21:29
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch 2 times, most recently from 198a2cb to e4fd6ae Compare September 9, 2026 22:02
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch 2 times, most recently from dc19bae to 650a97b Compare September 10, 2026 21:18
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 30d5f9f to d306544 Compare September 14, 2026 17:11
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch 2 times, most recently from 6f10d8f to 4c7cdd3 Compare September 14, 2026 18:41
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 9f40a46 to 14c90c5 Compare September 15, 2026 01:57
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from 4c7cdd3 to 017abff Compare September 15, 2026 01:57
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 14c90c5 to de827ef Compare September 15, 2026 18:01
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from 017abff to 7f504c1 Compare September 15, 2026 18:01
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from de827ef to 9f74170 Compare September 15, 2026 23:45
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch 2 times, most recently from 4c37780 to d903da9 Compare September 16, 2026 03:34
@tpn
tpn requested review from ericniebler and shwina and removed request for a team and Copilot September 16, 2026 16:20
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Sep 16, 2026
@github-actions

This comment has been minimized.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from d903da9 to 7869cbe Compare September 16, 2026 23:41
Copilot AI lite review requested due to automatic review settings September 16, 2026 23:41

Copilot AI 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.

🟡 Changes recommended

A critical issue remains with forwarding temp_storage to storage-free factories.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Completes execution support for all six CUB Block Load/Store algorithms across portable and qualified APIs, including storage planning, payload preservation, synchronization, diagnostics, and expanded tests.

Changes:

  • Adds storage-free and storage-bearing provider routing.
  • Preserves transpose-store payloads and partial-load invalid slots.
  • Expands compiler, runtime, contract, documentation, and diagnostic coverage.
File summaries
File Summary
python/cuda_coop/tests/contracts/core/test_core_group_load_store.py Tests algorithm identities and storage contracts.
python/cuda_coop/tests/contracts/core/test_core_block_load_store.py Tests algorithm specializations and preservation behavior.
python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py Tests planning and rewrite behavior.
python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py Adds runtime coverage for all algorithms.
python/cuda_coop/tests/backends/numba_mlir/compile/test_storage_diagnostics.py Tests shared-memory diagnostics.
python/cuda_coop/tests/backends/numba_mlir/compile/test_block_load_store_compile.py Tests provider compilation and caching.
python/cuda_coop/README.md Documents algorithms and storage behavior.
python/cuda_coop/cuda/coop/numba_mlir/_lowering/_load_store.py Registers algorithm-specific providers.
python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py Supports keyword local-array shapes.
python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py Plans storage and provider lowering.
python/cuda_coop/cuda/coop/_core/group/load_store.py Expands algorithm and storage contracts.
python/cuda_coop/cuda/coop/_core/block/load_store.py Adds CUB specializations and preservation wrappers.
docs/python/coop.rst Documents execution and storage behavior.
docs/python/coop_api.rst Updates qualified API documentation.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

This comment has been minimized.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 886e6e0 to f723981 Compare September 18, 2026 19:15
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from 7869cbe to d86f950 Compare September 18, 2026 19:15
@github-actions

This comment has been minimized.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from d86f950 to fadf5c0 Compare September 18, 2026 21:53
@tpn
tpn requested a review from a team as a code owner September 18, 2026 21:53
@tpn
tpn requested review from gevtushenko and removed request for a team September 18, 2026 21:53
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from f723981 to f43a204 Compare September 18, 2026 21:53
@tpn tpn changed the title cuda.coop: execute all Block Load and Store algorithms Add Numba-CUDA-MLIR support for cuda.coop Load and Store Sep 18, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Register the common load/store API with Numba-CUDA-MLIR and lower all
Block and Warp algorithms through CUB, including logical warp groups.
Provide optional compiler dependencies and compile/runtime coverage.

Signed-off-by: Trent Nelson <trent@trent.me>
@github-actions

This comment has been minimized.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from f43a204 to bd1da34 Compare September 20, 2026 02:56
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store-algorithms branch from fadf5c0 to ecec1c5 Compare September 20, 2026 02:56
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 20m: Pass: 100%/558 | Total: 7d 04h | Max: 2h 16m | Hits: 99%/855781

See results here.

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

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants