Skip to content

Add shared cuda.coop Block and Warp Load and Store - #11182

Open
tpn wants to merge 1 commit into
codex/hostjit-assert-review-20260919from
codex/cuda-coop-numba-block-load-store
Open

tpn wants to merge 1 commit into
codex/hostjit-assert-review-20260919from
codex/cuda-coop-numba-block-load-store

Conversation

@tpn

@tpn tpn commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Why this is needed

Python kernel compilers need shared contracts for cooperative operations:
which threads participate, how items are distributed across them, and what
temporary storage each algorithm requires. This introduces those contracts
in cuda-coop, with the compiler adapter following separately in #11200.

What changes

  • Add the common cuda.coop API, group descriptors, ThreadData and
    TempStorage interfaces, compiler-independent planning, and bundled CCCL
    headers. The base pip install cuda-coop has no Python package dependencies.
  • Include all Block Load/Store algorithms: direct, striped, vectorize,
    transpose, warp_transpose, and warp_transpose_timesliced.
  • Include physical Warp and logical Warp Load/Store for widths 1, 2, 4, 8,
    16, and 32, using direct, striped, vectorize, or transpose.
  • Plan storage and reuse synchronization for each execution group. The first
    three algorithms are storage-free; transpose algorithms carry the required
    allocation, alignment, and synchronization contracts.
  • Add typed explicit backend registration:
from cuda import coop

coop.register("numba-cuda-mlir")

"numba_cuda_mlir" is an accepted spelling. Registration imports the requested
adapter lazily and reports an unavailable adapter clearly. This PR contains
no compiler adapter; #11200 supplies the Numba-CUDA-MLIR implementation.

load fills its supplied output in place and returns None. store also
returns None. Both accept an element offset and a valid-item count relative
to the selected group's tile. Group descriptors remain usable from ordinary
Python; cooperative operations need a supported kernel compiler.

This PR temporarily targets #11523 so CI includes its Windows HostJIT build fix.

Validation

Fresh installed-wheel checks at bd1da34d032b:

  • Host contracts and packaging (full suites): 433 passed on Python 3.10; 433 passed on Python 3.14.

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

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

A HostJIT histogram benchmark failed on the first attempt and passed on one targeted retry without source changes. The retry passed all 70 examples and 125 host benchmarks; the original failure remains recorded in attempt 1.

@copy-pr-bot

copy-pr-bot Bot commented Sep 3, 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.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Sep 3, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Sep 3, 2026
@tpn

tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2cc52b9

@github-actions

This comment has been minimized.

@tpn

tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tpn
tpn requested a balanced review from Copilot September 4, 2026 15:27
Comment thread python/cuda_coop/cuda/coop/_core/api/__init__.py
Comment thread python/cuda_coop/cuda/coop/_core/api/_dispatch.py

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.

🔵 Needs a closer look

It introduces broad private-compiler integration and remains a draft pending exact-head CUDA 12/13 and Windows CI qualification.

Pull request overview

Adds the first executable cuda.coop backend, lowering cooperative CUB Block Load/Store through Numba-CUDA-MLIR while retaining a backend-neutral portable API.

Changes:

  • Adds portable APIs, descriptors, planning contracts, typing stubs, and bundled-header resolution.
  • Implements transactional Numba-CUDA-MLIR activation, rewriting, lowering, provenance tracking, and artifact caching.
  • Adds packaging, documentation, examples, extensive tests, and CI integration.
File summaries
File Description
python/cuda_coop/cuda/coop/_core/** Portable API and planning core
python/cuda_coop/cuda/coop/_headers/** Header and toolkit resolution
python/cuda_coop/cuda/coop/numba_mlir/** Compiler backend and lowering
python/cuda_coop/cuda/coop/*.py* Public package exports and typing
python/cuda_coop/tests/contracts/** Core and header contracts
python/cuda_coop/tests/backends/numba_mlir/** Backend unit, compile, and runtime tests
python/cuda_coop/tests/packaging/** Wheel, metadata, installation, and typing tests
python/cuda_coop/tests/support/** Shared test utilities
python/cuda_coop/examples/numba_mlir/** Block Load/Store examples
python/cuda_coop/CMakeLists.txt Header bundling and provenance
python/cuda_coop/pyproject.toml Package and dependency metadata
python/cuda_coop/README.md Usage and compatibility guidance
python/cuda_coop/LICENSE Package licensing
ci/build_cuda_coop_python.sh Linux wheel build
ci/windows/build_cuda_coop_python.ps1 Windows wheel build
ci/test_cuda_coop_python.sh Staged backend validation
ci/validate_cuda_coop_wheel.py Wheel-content validation
ci/matrix.yaml CI coverage matrix
ci/project_files_and_dependencies.yaml Change-impact mapping
ci/test/inspect_changes/*cuda_coop* Change-detection fixtures
ci/test/inspect_changes/{core_dirty,libcudacxx_*}.output Dependency expectations
docs/python/coop.rst User documentation
docs/python/coop_api.rst API reference
docs/python/index.rst Documentation navigation
docs/python/api_reference.rst API index integration
docs/conf.py Documentation configuration
Review details
  • Files reviewed: 108/158 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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: f04f099d-94d7-4da1-866f-4eee8897eca1

📥 Commits

Reviewing files that changed from the base of the PR and between 44e505b and 886e6e0.

📒 Files selected for processing (10)
  • python/cuda_coop/README.md
  • python/cuda_coop/cuda/coop/_headers/__init__.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py
  • python/cuda_coop/tests/contracts/core/test_core_group_load_store.py
  • python/cuda_coop/tests/contracts/headers/test_resolution.py
  • python/cuda_coop/tests/packaging/typing/numba_consumer.py
🚧 Files skipped from review as they are similar to previous changes (8)
  • python/cuda_coop/cuda/coop/_headers/init.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py
  • python/cuda_coop/tests/contracts/headers/test_resolution.py
  • python/cuda_coop/tests/packaging/typing/numba_consumer.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py
  • python/cuda_coop/README.md
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added the experimental cuda.coop Python package for cooperative CUDA programming.
    • Added portable thread-group, per-thread data, temporary-storage, and block load/store APIs.
    • Added Numba-CUDA-MLIR support, including direct load/store operations and practical examples.
    • Added universal pure-Python wheel packaging with bundled CUDA/CCCL headers and validation.
  • Documentation

    • Added installation guidance, API references, usage examples, supported algorithms, configuration details, and limitations.
  • Tests

    • Added broad contract, typing, packaging, compilation, runtime, and CI workflow coverage, including Windows and nightly validation.

Walkthrough

Added the cuda.coop Python package with portable and Numba-CUDA-MLIR cooperative APIs, compiler lowering, bundled-header handling, universal-wheel validation, documentation, extensive tests, and CI coverage.

Changes

cuda.coop package and CI

Layer / File(s) Summary
Public API and cooperative contracts
python/cuda_coop/cuda/coop/...
Added portable and qualified cooperative thread-group, thread-data, temporary-storage, load, and store APIs with typing contracts and validation.
Compiler planning and lowering
python/cuda_coop/cuda/coop/numba_mlir/...
Added backend activation, operation registration, launch resolution, provenance analysis, payload inference, temporary-storage planning, NVRTC compilation, caching, and Block Load/Store lowering.
Headers and wheel packaging
python/cuda_coop/CMakeLists.txt, python/cuda_coop/pyproject.toml, ci/validate_cuda_coop_wheel.py
Added CCCL/CUDAX header installation, provenance metadata, toolkit discovery, universal-wheel configuration, and artifact validation.
Documentation and examples
docs/python/*, python/cuda_coop/README.md, python/cuda_coop/examples/*
Added installation, API, backend, validation, storage, header, caching, and Block Load/Store documentation with executable examples.
Tests and CI integration
python/cuda_coop/tests/*, ci/*
Added contract, compiler, runtime, packaging, typing, Windows, matrix, project, and inspection coverage.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 886e6

The assessed package, compiler, validation, and test paths do not retain an actionable regression from the previously identified concerns. The change is ready to merge after normal checks.


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.

Actionable comments posted: 7

🧹 Nitpick comments (5)
python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py (1)

641-641: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: source_order is reused here as the loop target after it served as the running counter at Lines 581-592. Rename the unpacked variable, for example use_order, to avoid shadowing the counter.

python/cuda_coop/tests/backends/numba_mlir/unit/test_nvrtc.py (1)

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

suggestion: Add the standard pytestmark = [pytest.mark.backend_numba_mlir, pytest.mark.unit] assignment to the three unit-test modules. The CI stage runs the unit directory directly, so missing markers do not currently deselect these tests. The markers preserve consistent unit-test classification and marker-based selection.

python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py (1)

168-168: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: created tracking is dead.

refresh_typing_context starts as True, so the |= created at line 177 cannot change it and self._state.typingctx.refresh() always runs. Either start from False to make the invocable-creation signal meaningful, or drop the flag and call refresh() unconditionally.

python/cuda_coop/cuda/coop/_core/block/load_store.py (1)

278-283: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

suggestion: Normalize items_per_thread with normalize_positive_int("items_per_thread", items_per_thread). The exported make_block_load_spec and make_block_store_spec paths currently reject valid numbers.Integral values such as np.int64(4), although the shared normalizer and other integer bindings accept them. Convert the value to a plain int before it reaches ITEMS_PER_THREAD and the semantic key.

python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py (1)

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

suggestion: Assert an actual rewrite match. _run_single_phase_to_provider_boundary can return after recognizing only the ThreadData constructor, so the positive load tests can pass when their coop call is not in rewrite._matches. Track bool(rewrite._matches) for each block and assert that at least one coop call matched.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1e4533f7-2cf8-4484-b1eb-eba9328a7e1b

📥 Commits

Reviewing files that changed from the base of the PR and between d0e21c2 and 799b189.

📒 Files selected for processing (158)
  • ci/build_cuda_coop_python.sh
  • ci/matrix.yaml
  • ci/project_files_and_dependencies.yaml
  • ci/test/inspect_changes/core_dirty.output
  • ci/test/inspect_changes/cuda_coop_python.dirty_files
  • ci/test/inspect_changes/cuda_coop_python.output
  • ci/test/inspect_changes/cuda_coop_python_cudax.dirty_files
  • ci/test/inspect_changes/cuda_coop_python_cudax.output
  • ci/test/inspect_changes/cuda_coop_python_license.dirty_files
  • ci/test/inspect_changes/cuda_coop_python_license.output
  • ci/test/inspect_changes/cuda_coop_python_pyproject.dirty_files
  • ci/test/inspect_changes/cuda_coop_python_pyproject.output
  • ci/test/inspect_changes/cuda_coop_python_pyproject_near_miss.dirty_files
  • ci/test/inspect_changes/cuda_coop_python_pyproject_near_miss.output
  • ci/test/inspect_changes/cuda_coop_python_windows_ci.dirty_files
  • ci/test/inspect_changes/cuda_coop_python_windows_ci.output
  • ci/test/inspect_changes/libcudacxx_both.output
  • ci/test/inspect_changes/libcudacxx_public_only.output
  • ci/test/inspect_changes/libcudacxx_thrust.output
  • ci/test_cuda_coop_python.sh
  • ci/validate_cuda_coop_wheel.py
  • ci/windows/build_cuda_coop_python.ps1
  • docs/conf.py
  • docs/python/api_reference.rst
  • docs/python/coop.rst
  • docs/python/coop_api.rst
  • docs/python/index.rst
  • python/cuda_coop/CMakeLists.txt
  • python/cuda_coop/LICENSE
  • python/cuda_coop/README.md
  • python/cuda_coop/cuda/coop/__init__.py
  • python/cuda_coop/cuda/coop/__init__.pyi
  • python/cuda_coop/cuda/coop/_core/__init__.py
  • python/cuda_coop/cuda/coop/_core/_adapter.py
  • python/cuda_coop/cuda/coop/_core/_algorithm.py
  • python/cuda_coop/cuda/coop/_core/_auto_registration.py
  • python/cuda_coop/cuda/coop/_core/_bindings.py
  • python/cuda_coop/cuda/coop/_core/_symbols.py
  • python/cuda_coop/cuda/coop/_core/_types.py
  • python/cuda_coop/cuda/coop/_core/api/__init__.py
  • python/cuda_coop/cuda/coop/_core/api/__init__.pyi
  • python/cuda_coop/cuda/coop/_core/api/_dispatch.py
  • python/cuda_coop/cuda/coop/_core/api/_payload.py
  • python/cuda_coop/cuda/coop/_core/api/load_store.py
  • python/cuda_coop/cuda/coop/_core/api/load_store.pyi
  • python/cuda_coop/cuda/coop/_core/api/temp_storage.py
  • python/cuda_coop/cuda/coop/_core/api/temp_storage.pyi
  • python/cuda_coop/cuda/coop/_core/api/thread_data.py
  • python/cuda_coop/cuda/coop/_core/api/thread_data.pyi
  • python/cuda_coop/cuda/coop/_core/api/thread_group.py
  • python/cuda_coop/cuda/coop/_core/api/thread_group.pyi
  • python/cuda_coop/cuda/coop/_core/block/__init__.py
  • python/cuda_coop/cuda/coop/_core/block/_common.py
  • python/cuda_coop/cuda/coop/_core/block/load_store.py
  • python/cuda_coop/cuda/coop/_core/dtype_policy.py
  • python/cuda_coop/cuda/coop/_core/group/__init__.py
  • python/cuda_coop/cuda/coop/_core/group/_contracts.py
  • python/cuda_coop/cuda/coop/_core/group/_dispatch.py
  • python/cuda_coop/cuda/coop/_core/group/_model.py
  • python/cuda_coop/cuda/coop/_core/group/_resolution.py
  • python/cuda_coop/cuda/coop/_core/group/load_store.py
  • python/cuda_coop/cuda/coop/_core/launch.py
  • python/cuda_coop/cuda/coop/_core/thread_group.py
  • python/cuda_coop/cuda/coop/_headers/__init__.py
  • python/cuda_coop/cuda/coop/_headers/_identity.py
  • python/cuda_coop/cuda/coop/_headers/_toolkit.py
  • python/cuda_coop/cuda/coop/_typing.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/__init__.py
  • python/cuda_coop/cuda/coop/numba_mlir/__init__.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/__init__.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_activation.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_artifacts.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_caching.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner_support.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planning.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_rewriting.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_numba_mlir_compat.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_nvrtc.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_operations.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_parameters.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_arguments.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_group_metadata.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_invocables.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_launch.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_payload.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_support.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_scalar_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_enums.py
  • python/cuda_coop/cuda/coop/numba_mlir/_enums.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_group_marker.py
  • python/cuda_coop/cuda/coop/numba_mlir/_lowering/__init__.py
  • python/cuda_coop/cuda/coop/numba_mlir/_lowering/_core.py
  • python/cuda_coop/cuda/coop/numba_mlir/_lowering/_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_semantic.py
  • python/cuda_coop/cuda/coop/numba_mlir/_temp_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_temp_storage.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_data.py
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_data.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_group.py
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_group.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_types.py
  • python/cuda_coop/cuda/coop/numba_mlir/py.typed
  • python/cuda_coop/cuda/coop/py.typed
  • python/cuda_coop/examples/numba_mlir/block_load.py
  • python/cuda_coop/examples/numba_mlir/block_store.py
  • python/cuda_coop/pyproject.toml
  • python/cuda_coop/tests/__init__.py
  • python/cuda_coop/tests/backends/numba_mlir/__init__.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/__init__.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_block_load_store_compile.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_installed_activation_compile.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/__init__.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/__init__.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/_lazy_fake_family.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_caching.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_family_registration.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_lowering_plan.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_invocable_identity.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_invocable_lifecycle.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_launch_dimension_rewrites.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_nvrtc.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_public_foundation.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_runtime_activation.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_storage_rewrites.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_thread_data.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_thread_groups.py
  • python/cuda_coop/tests/contracts/__init__.py
  • python/cuda_coop/tests/contracts/core/test_core_bindings.py
  • python/cuda_coop/tests/contracts/core/test_core_block_load_store.py
  • python/cuda_coop/tests/contracts/core/test_core_group_load_store.py
  • python/cuda_coop/tests/contracts/core/test_core_group_resolution.py
  • python/cuda_coop/tests/contracts/core/test_core_thread_group.py
  • python/cuda_coop/tests/contracts/core/test_core_types.py
  • python/cuda_coop/tests/contracts/headers/test_identity.py
  • python/cuda_coop/tests/contracts/headers/test_resolution.py
  • python/cuda_coop/tests/contracts/headers/test_toolkit.py
  • python/cuda_coop/tests/packaging/test_headers.py
  • python/cuda_coop/tests/packaging/test_installed.py
  • python/cuda_coop/tests/packaging/test_metadata.py
  • python/cuda_coop/tests/packaging/test_typing.py
  • python/cuda_coop/tests/packaging/test_wheel.py
  • python/cuda_coop/tests/packaging/typing/invalid_consumer.py
  • python/cuda_coop/tests/packaging/typing/numba_consumer.py
  • python/cuda_coop/tests/packaging/typing/portable_consumer.py
  • python/cuda_coop/tests/support/__init__.py
  • python/cuda_coop/tests/support/group_planning.py
  • python/cuda_coop/tests/support/paths.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread ci/validate_cuda_coop_wheel.py Outdated
Comment thread python/cuda_coop/cuda/coop/_core/api/thread_group.pyi
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_caching.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_arguments.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_provenance.py Outdated
Comment thread python/cuda_coop/tests/backends/numba_mlir/unit/test_launch_dimension_rewrites.py Outdated
@tpn

tpn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the current review threads in the four signed commits through
a83bc76575.

  • Aligned the portable core and backend storage model for DIRECT, including
    plan identity and storage-free code generation.
  • Made provider scalar validation declarative and hardened topology, storage,
    cache, marker-discovery, duplicate-argument, and provenance paths.
  • Kept the root-member identity tag and documented why it is required.
  • Removed the public algorithm enums and made portable and qualified Load/Store
    use the same inferred dtypes, protocol types, exports, and lowercase string
    selectors.
  • Centralized private compiler-IR access in the guarded compatibility shim.
  • Added the requested focused regressions and classification/style cleanups.

The exact-head wheel was installed outside the source tree and passed 248
contract/packaging tests, 480 GPU-hidden unit/compile tests, and 57 RTX PRO
6000 runtime tests. The PR remains a draft while exact-head remote CUDA 12/13
and Windows qualification is pending.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 9421804 to 58d3e31 Compare September 6, 2026 06:42
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_caching.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_caching.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_numba_mlir_compat.py Outdated
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_nvrtc.py Outdated
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch from 4c93484 to 7703d64 Compare September 8, 2026 22:35

@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: 3

🧹 Nitpick comments (5)
python/cuda_coop/tests/contracts/core/test_core_group_load_store.py (1)

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

suggestion: restore _GROUP_OPERATION_FAMILIES after this test. _register_group_operation_family writes _GridOperation to the module-level registry, and this test does not undo that write. Add a fixture that snapshots and restores the registry so test-only state does not leak into the pytest process.

python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py (1)

62-71: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: The allowed algorithm tokens are duplicated. _lowering/_load_store.py lines 54-61 declares the same six tokens in a local allowed set, and _resolve_algorithm there repeats the "only 'direct'" rejection. Export one shared frozenset and reuse it in both modules so the planner and the provider cannot drift.

python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py (1)

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

important: This test does not distinguish its four parameter cases. source_kind is a free variable of the Python function, and run_frontend only builds IR; it does not fold the comparisons. All four branches stay in the IR for every parameter value, so value is always a phi over the index, the element, the NumPy cast, and the backend cast. The four cases compile identical IR, and a regression in one scalar source stays hidden because the merged phi still resolves to int32.

Build one kernel per source kind so each provenance path is planned alone.

Proposed fix
-    def memory(source, destination):
-        index = cuda.threadIdx.x
-        if source_kind == "index":
-            value = index
-        elif source_kind == "element":
-            value = source[index]
-        elif source_kind == "numpy-cast":
-            value = np.int32(index + 1)
-        else:
-            value = types.int32(index + 1)
-        module.store(module.this_block(), destination, value)
+    def index_source(source, destination):
+        module.store(module.this_block(), destination, cuda.threadIdx.x)
+
+    def element_source(source, destination):
+        module.store(module.this_block(), destination, source[cuda.threadIdx.x])
+
+    def numpy_cast_source(source, destination):
+        module.store(
+            module.this_block(), destination, np.int32(cuda.threadIdx.x + 1)
+        )
+
+    def compiler_cast_source(source, destination):
+        module.store(
+            module.this_block(), destination, types.int32(cuda.threadIdx.x + 1)
+        )
+
+    memory = {
+        "index": index_source,
+        "element": element_source,
+        "numpy-cast": numpy_cast_source,
+        "compiler-cast": compiler_cast_source,
+    }[source_kind]
python/cuda_coop/tests/backends/numba_mlir/unit/test_storage_rewrites.py (1)

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

suggestion: Add pytest.importorskip("numba_cuda_mlir") before the module-level backend imports. No conftest.py in this backend test tree provides a collection guard, so pytest raises an import error instead of skipping when numba_cuda_mlir is unavailable.

python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_arguments.py (1)

73-95: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

suggestion: Apply the runtime_factory_kw_prerequisites check to positional runtime factory kwargs. The load spec declares oob_default as requiring num_valid_items. The positional branch can omit a statically resolved num_valid_items from the seen sets, while the prerequisite loop skips positional values. This allows oob_default to reach the factory without its required control.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7dd8757c-bc9f-4e42-93fe-ddce8db31e48

📥 Commits

Reviewing files that changed from the base of the PR and between 799b189 and 30d5f9f.

📒 Files selected for processing (78)
  • ci/matrix.yaml
  • ci/validate_cuda_coop_wheel.py
  • docs/python/coop.rst
  • docs/python/coop_api.rst
  • python/cuda_coop/README.md
  • python/cuda_coop/cuda/coop/_core/_source_dump.py
  • python/cuda_coop/cuda/coop/_core/api/__init__.py
  • python/cuda_coop/cuda/coop/_core/api/_dispatch.py
  • python/cuda_coop/cuda/coop/_core/api/_payload.py
  • python/cuda_coop/cuda/coop/_core/api/temp_storage.py
  • python/cuda_coop/cuda/coop/_core/api/temp_storage.pyi
  • python/cuda_coop/cuda/coop/_core/api/thread_data.py
  • python/cuda_coop/cuda/coop/_core/api/thread_data.pyi
  • python/cuda_coop/cuda/coop/_core/api/thread_group.py
  • python/cuda_coop/cuda/coop/_core/api/thread_group.pyi
  • python/cuda_coop/cuda/coop/_core/block/load_store.py
  • python/cuda_coop/cuda/coop/_core/group/_contracts.py
  • python/cuda_coop/cuda/coop/_core/group/_model.py
  • python/cuda_coop/cuda/coop/_core/group/load_store.py
  • python/cuda_coop/cuda/coop/_core/thread_group.py
  • python/cuda_coop/cuda/coop/_headers/__init__.py
  • python/cuda_coop/cuda/coop/_typing.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/__init__.py
  • python/cuda_coop/cuda/coop/numba_mlir/__init__.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_caching.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_errors.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner_support.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planning.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_rewriting.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_numba_mlir_compat.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_nvrtc.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_arguments.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_support.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_scalar_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_lowering/_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_temp_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_temp_storage.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_data.py
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_data.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_group.py
  • python/cuda_coop/cuda/coop/numba_mlir/_thread_group.pyi
  • python/cuda_coop/examples/numba_mlir/block_store.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_installed_activation_compile.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_scalar_store_typing.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_caching.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_family_registration.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_lowering_plan.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_launch_dimension_rewrites.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_nvrtc.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_public_foundation.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_runtime_activation.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_storage_rewrites.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_thread_data.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_thread_groups.py
  • python/cuda_coop/tests/contracts/core/test_core_block_load_store.py
  • python/cuda_coop/tests/contracts/core/test_core_group_load_store.py
  • python/cuda_coop/tests/contracts/core/test_core_temp_storage.py
  • python/cuda_coop/tests/contracts/core/test_core_thread_data.py
  • python/cuda_coop/tests/contracts/core/test_core_thread_group.py
  • python/cuda_coop/tests/contracts/core/test_source_dump.py
  • python/cuda_coop/tests/contracts/headers/test_resolution.py
  • python/cuda_coop/tests/packaging/test_headers.py
  • python/cuda_coop/tests/packaging/test_wheel.py
  • python/cuda_coop/tests/packaging/typing/invalid_consumer.py
  • python/cuda_coop/tests/packaging/typing/numba_consumer.py
  • python/cuda_coop/tests/packaging/typing/portable_consumer.py
  • python/cuda_coop/tests/support/group_planning.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread python/cuda_coop/cuda/coop/_headers/__init__.py
Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py Outdated
Comment thread python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py Outdated
@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch 5 times, most recently from 9f74170 to 44e505b Compare September 16, 2026 03:34
@tpn
tpn marked this pull request as ready for review September 16, 2026 16:19
@tpn
tpn requested review from a team as code owners September 16, 2026 16:19
@tpn
tpn requested review from shwina and wmaxey September 16, 2026 16:19
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Sep 16, 2026

@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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a8d3b432-b41a-4777-b841-32a3861289d3

📥 Commits

Reviewing files that changed from the base of the PR and between 30d5f9f and 44e505b.

📒 Files selected for processing (39)
  • ci/matrix.yaml
  • docs/python/coop.rst
  • python/cuda_coop/README.md
  • python/cuda_coop/cuda/coop/_core/_source_dump.py
  • python/cuda_coop/cuda/coop/_core/api/load_store.py
  • python/cuda_coop/cuda/coop/_core/api/load_store.pyi
  • python/cuda_coop/cuda/coop/_core/group/_model.py
  • python/cuda_coop/cuda/coop/_core/group/load_store.py
  • python/cuda_coop/cuda/coop/_core/thread_group.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_descriptor_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planner.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_group_planning.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_nvrtc.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_provenance.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite_support.py
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.py
  • python/cuda_coop/cuda/coop/numba_mlir/_group_load_store.pyi
  • python/cuda_coop/cuda/coop/numba_mlir/_lowering/_core.py
  • python/cuda_coop/cuda/coop/numba_mlir/_temp_storage.py
  • python/cuda_coop/cuda/coop/numba_mlir/_types.py
  • python/cuda_coop/examples/numba_mlir/block_load.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_block_load_store_compile.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_installed_activation_compile.py
  • python/cuda_coop/tests/backends/numba_mlir/compile/test_storage_diagnostics.py
  • python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_data_movement.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_hierarchy.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_group_lowering_plan.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_nvrtc.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_parameter_names.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_storage_rewrites.py
  • python/cuda_coop/tests/backends/numba_mlir/unit/test_thread_data.py
  • python/cuda_coop/tests/contracts/core/test_core_group_load_store.py
  • python/cuda_coop/tests/contracts/core/test_core_thread_group.py
  • python/cuda_coop/tests/contracts/core/test_source_dump.py
  • python/cuda_coop/tests/packaging/typing/portable_consumer.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread python/cuda_coop/cuda/coop/numba_mlir/_compiler/_rewrite.py Outdated
Comment thread python/cuda_coop/README.md Outdated
Comment thread python/cuda_coop/tests/backends/numba_mlir/runtime/test_block_load_store.py Outdated
@tpn

tpn commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

For the remaining non-inline notes from the September 11 review, 886e6e0 isolates the test-only group registry and makes the four scalar provenance cases use separate kernels.

I kept three suggestions out of this patch:

  • Sharing the algorithm-token set is a refactor without a demonstrated correctness difference; the next PR also extends executable algorithm support.
  • Backend test collection requires the Numba dependency. The backend CI stages install it explicitly, so adding an optional-dependency skip here would not address a supported CI failure.
  • The public Load planner already rejects oob_default without valid_items. A malformed positional call to the private provider also fails during materialization, before compilation. An additional rewrite check would only move that private diagnostic earlier.

The six inline findings have individual replies and resolutions. Local source and installed-wheel checks pass; CI for the published head is still pending.

@github-actions

This comment has been minimized.

@tpn
tpn force-pushed the codex/cuda-coop-numba-block-load-store branch 2 times, most recently from f723981 to f43a204 Compare September 18, 2026 21:53
@tpn tpn changed the title Add Numba-CUDA-MLIR Block Load and Store to cuda.coop Add shared cuda.coop Block and Warp Load and Store Sep 18, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Introduce the backend-neutral API, cooperative group planning, and

bundled CCCL headers in a dependency-free Python package. Provide

explicit backend registration without bundling a compiler adapter.

Signed-off-by: Trent Nelson <trent@trent.me>
@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 requested a review from a team as a code owner September 20, 2026 02:56
@tpn
tpn changed the base branch from main to codex/hostjit-assert-review-20260919 September 20, 2026 02:56
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 28m: Pass: 100%/556 | Total: 7d 07h | Max: 2h 26m | Hits: 99%/855833

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