github NVIDIA/cccl cuda-coop-cutlass-v0.1.0
cuda.coop.cutlass 0.1.0

51 minutes ago

Documentation · Programming Guide · Concepts · API Reference · Interactive Visualizations · Examples · Developer Guide · PyPI

cuda.coop.cutlass brings NVIDIA CUB's block-level and warp-level collective algorithms from the CUDA Core Compute Libraries (CCCL) to Python GPU kernels written in the CUTLASS CuTe DSL.

Custom GPU kernels regularly combine tiled math and memory movement with block-wide and warp-wide collectives such as Top-K selection, prefix scans, reductions, and sorting. cuda.coop.cutlass lets @cute.kernel and @cute.jit functions call CUB's C++ implementations directly, avoiding hand-written butterfly shuffles or separate C++ wrappers. Version 0.1.0 is now available on PyPI for Python 3.10–3.14 on Linux (x86_64, aarch64) and Windows (x64, Arm64) with CUDA 13.

Highlights 🔗

  • Call CUB directly inside CuTe kernels. Invoke load, store, reduce, inclusive_sum, radix_sort_pairs, topk_max_pairs, histogram, and more right inside a kernel body. Block size, element types, item counts, and shared-memory scratch space are inferred automatically rather than repeated across C++ template parameters. #12311
  • One thread-group model across blocks, warps, and lanes. Every collective takes the cooperating thread group as its first argument (coop.this_block(), coop.this_warp(), or coop.this_warp().group_by(8)), keeping the same call pattern whether an operation spans a whole thread block, one 32-lane warp, or a sub-warp partition.
  • Keep data on chip across Tensor Core and SIMT stages. Feed values already sitting in CuTe register tensors, shared memory (SmemAllocator), or Blackwell Tensor Memory (TmemAllocator) straight into a CUB collective and continue in the same kernel without global-memory round-trips (see Tensor Core and Top-K interop). #12862, #12864
  • C++ CUB speed from pip install. A single pure-Python wheel bundles its verified CCCL headers, compiles each CUB call used by your kernel to NVIDIA LTO-IR, and inlines it into the compiled CuTe cubin at link time with no Python runtime overhead on Linux and Windows (see the Developer Guide). #12777, #12827, #12907
  • Interactive visualizers and runnable examples. Explore how values move across threads and warp lanes step by step in 14 browser-based interactive visualizers, or run 15 self-checking example kernels with full IDE type stubs. #12723, #12877

Quick start 🔗

In this 128-thread kernel, each thread loads four integers, the block computes a 512-element running sum together, and each thread writes back its four results:

import cutlass
from cutlass import cute
import cuda.coop.cutlass as coop


@cute.kernel
def prefix_sum(
    source: cute.Pointer,
    destination: cute.Pointer,
    items_per_thread: cutlass.Constexpr,
):
    block = coop.this_block()
    values = coop.load(block, source, items_per_thread=items_per_thread)
    sums = coop.inclusive_sum(block, values)
    coop.store(block, destination, sums)

coop.this_block() takes the block dimensions from .launch(...), coop.load infers the element type from the typed CuTe pointer or tensor and returns a ThreadData register payload, and the compiler sizes and synchronizes shared-memory scratch space automatically unless an explicit TempStorage is passed.

Walk through the complete runnable prefix_sum.py script in the Programming Guide, and see Programming Concepts and Advanced Topics for multi-block tiling, CuTe register tensor conversions, and shared-memory workspaces.

Install 🔗

On Linux or Windows with a CUDA 13-capable NVIDIA driver, install cuda-coop-cutlass from PyPI with compatible CUDA 13 headers, NVRTC, nvJitLink, and runtime wheels:

python -m pip install "cuda-coop-cutlass[cu13]"

Omit [cu13] if a compatible CUDA 13 system toolkit is already installed, or run python -m pip install "./python/cuda_coop_cutlass[cu13]" from a CCCL checkout to install from source.

Requirements for 0.1.0:

  • Linux (x86_64 or aarch64) or Windows (x64 or Arm64) on CPython 3.10 through 3.14 (py3-none-any wheel; cuda-pathfinder>=1.6.1 is installed automatically on Windows for architecture-aware compiler DLL discovery). #12827
  • nvidia-cutlass-dsl[cu13]>=4.9.0,<4.10 (installed automatically), with CuTe's default setting of PyIR off. #12906
  • CUDA 13 driver and NVRTC (nvJitLink must be at least as new as NVRTC within CUDA 13; on Linux, use NVRTC 13.1 through 13.4 to match the CUDA 13.4 linker in nvidia-cutlass-dsl 4.9.x; on Windows, kernel linking requires nvJitLink 13.5 or later in CUDA 13, which [cu13] installs). #12827, #12839, #12944
  • Compute capability 8.0 (SM80, NVIDIA Ampere) or newer (SM100 or SM103 for tensor_memory_topk.py).

See Installation and requirements and Configuration for environment variables and toolchain details.

Cooperative primitives and interactive visualizations 🔗

The API Reference documents all 11 primitive families below, alongside self-checking executable examples and browser-based interactive explorers:

Family Functions Scopes and behavior Example and visualizers
Load & Store load, store Block, warp, or lane group. Moves tiles between global or shared memory and ThreadData. block_load_store.py, warp_load_store.py · Load, Store
Reduction reduce, sum, reduce_batched All group scopes (reduce_batched: warp or lane group). Reduces items into rank 0, or per payload slot across lanes. reduce.py, reduce_batched.py · Reduce, Batched Reduce
Scan scan, inclusive_sum, exclusive_sum, inclusive_scan, exclusive_scan All group scopes. Computes inclusive or exclusive prefix results, with optional initial values and tile aggregates. scan.py, prefix_sum.py · Scan
Data Rearrangement exchange, shuffle All group scopes. Transposes blocked and striped layouts, scatters to ranks, broadcasts, or shifts items across threads. exchange_shuffle.py · Exchange, Shuffle
Comparison Sorting merge_sort_keys, merge_sort_pairs All group scopes. Sorts keys or key-value pairs ascending or descending, including partial tiles via valid_items. merge_sort.py · Merge Sort
Radix Sorting & Ranking radix_sort_keys, radix_sort_pairs, radix_rank_keys Block scope. Sorts keys or pairs in blocked or striped order, or computes stable radix ranks over bit slices. radix.py · Radix Sort and Rank
Top-K Selection topk_min_keys, topk_max_keys, topk_min_pairs, topk_max_pairs Block scope. Selects the smallest or largest k keys or pairs from a tile without sorting the unselected tail. topk.py, tensor_memory_topk.py · TopK
Neighbor Comparisons adjacent_difference, discontinuity Block scope. Subtracts or compares adjacent tile items and flags segment boundaries. Adjacent Difference, Discontinuity
Histogram histogram Block scope. Counts samples falling into each bin in global or shared memory. Histogram
Run-Length Decode run_length_decode, run_length_decode_into Block scope. Expands per-run values and lengths into dense payloads or writes decoded runs to memory. Run-Length Decode
Compiled Operators compile_operator, DeviceOperator Compiles custom scalar binary functions into device LTO-IR for reduce and scan primitives. Compiled Operators API

C++ CUB parity and frontier inference kernels 🔗

Each CUB specialization used by a kernel compiles to NVIDIA LTO-IR and inlines into the enclosing CuTe cubin through nvJitLink, leaving no Python runtime or device-call boundary in the final SASS. Across single-primitive NVBench microbenchmarks, a 58-workload suite spanning all 11 families, shared-scratch loops, and block Top-K on NVIDIA RTX PRO 6000 Blackwell (SM120) and NVIDIA GB300 (SM103), cuda.coop.cutlass 0.1.0 matches nvcc -O3 C++ CUB (benchmark harnesses in #12676 and #12921):

Frontier inference kernel patterns 🔗

Common decoding and prefill bottlenecks map directly to these collectives (#12921):

  • MoE expert routing (1.4×–5.4× faster than full sort): Fine-grained routers (such as 22 of 512 in NVIDIA Nemotron-3.5-Super, 10 of 512 in Qwen3-Coder-Next, 6 of 128 in Gemma-4-26B-A4B, and 31 of 93 in Qwen3.6) select only the winning experts with coop.topk_max_pairs instead of sorting the discarded tail (topk.py, TopK visualizer).
  • Sparse-attention KV indexing (3.4×–7.0× faster than full sort): Long-context indexers like DeepSeek-V3.2's DSA and Qwen3.5 score thousands of KV candidates per query and retain only the top 64–512 blocks at nvcc -O3 C++ CUB speed (#12921).
  • PyTorch radix Top-K (1.4×–1.7× faster): Replacing the thread-0 256-bin histogram walk in PyTorch's CuTe 8-bit radix Top-K kernel with coop.inclusive_sum and coop.merge_sort_pairs removes the serial bottleneck across all four passes (prefix_sum.py, merge_sort.py).
  • Blackwell tcgen05 Tensor Memory fusion (2.5×–5.2× faster): Keeping FP32 tcgen05.mma accumulators resident in TmemAllocator across dependent coop.topk_max_keys windows avoids HBM round-trips and extra kernel launches on GB300 (Tensor Core and Top-K interop, tensor_memory_topk.py).
  • Warp REDUX.SYNC and shared-scratch loops: 32-lane int32 coop.sum compiles to hardware REDUX.SYNC (1.9×–3.8× faster than manual butterfly shuffles; reduce.py), and FlashInfer-style top-p sampling loops sharing one TempStorage match C++ CUB union kernels within 1%–2% (shared_workspace.py).

See Checking and tuning a kernel for SASS inspection (CUTE_DSL_KEEP=cubin) and generated C++ source dumps (CUDA_COOP_CUTLASS_SOURCE_DUMP_DIR).

Known limitations in 0.1.0 🔗

  • Experimental alpha preview (0.1.x). Public signatures and behavior may evolve in minor releases based on kernel author feedback.
  • CUDA 13 linker compatibility and staged export. On Linux, the nvidia-cutlass-dsl 4.9.x wheel links device code with a CUDA 13.4 nvJitLink, so use [cu13] (which caps NVRTC below 13.5) or a system CUDA 13.1–13.4 toolkit rather than CUDA 13.5 NVRTC. On Windows, cooperative linking requires nvJitLink 13.5 or newer in CUDA 13 (installed by [cu13]) and runs during @cute.jit launches and cute.compile; staged cute.compile_to (ArtifactType.CompiledMlir) exports skip the cooperative device link step. #12827, #12906, #12944
  • Column-major layouts, unswizzled pointers, and concrete descriptors. load and store require unswizzled, element-aligned CuTe pointers or compact column-major tensors with static shapes (wrap other compact tensors in a flat 1D view for address-order access, and stage swizzled tiles into registers with native CuTe copies first). Pass explicit coop.load calls for memory inputs, concrete ThreadData instances for in-place outputs, and concrete TempStorage descriptors for temp_storage. #12861, #12862, #12863, #12893
  • Group scopes and warp partitions. Top-K, radix sort/rank, histogram, neighbor comparisons, and run-length decode accept coop.this_block() in 0.1.0 (use merge_sort_* for warp or lane-group sorting). For 17-to-31-lane reductions, use coop.this_warp().group_by(n, exhaustive=False) guarded by if group.is_member():.

See FAQs for common usage questions, and share bug reports or feature requests on CCCL GitHub Issues.

Contributors and acknowledgments 🔗

cuda.coop.cutlass 0.1.0 was engineered and documented by Trent Nelson in close collaboration with Ashwin Srinath and Diptorup Deb. It builds on the Algorithm and _types parameter-descriptor model introduced by Georgii Evtushenko, original author of the numba-cuda-based cuda.coop package. Special thanks to dePaul Miller for reviewing and landing the external LTO-IR linking, launch-fact introspection, and trace-finalization hooks in the CUTLASS CuTe DSL, and to David Bayer, whose C++ cooperative thread-hierarchy design in CCCL inspired the unified group API. Thanks also to Jake Hemstad, Jacob Faibussowitsch, Keith Kraus, Michael Schellenberger Costa, Bernhard Manfred Gruber, Federico Busato, Anika Jain, and ylwang for CUB, CI, and packaging fixes and reviews.

PR counts credit the first-listed contributor; assists credit co-authors and reviewers whose feedback shaped the change, commits count non-merge PR commits per author, and diff stats sum additions and removals for each author's primary PRs. Backported PRs are counted once under their original pull request number.

Pull requests 🔗

Pull request Area Summary Contributors and reviewers Diff stats
#12311 Package, Compiler, Tests Add standalone cuda.coop.cutlass package, LTO-IR provider compiler, 11 primitive families, examples, and test suite Trent Nelson; Ashwin Srinath; Jake Hemstad +83,449 -7
#12723 Documentation, Visualizations Rework cuda.coop.cutlass documentation, interactive primitive explorers, compiler diagrams, and doc-source verification Trent Nelson; Ashwin Srinath; Jacob Faibussowitsch +8,968 -4,852
#12777 Packaging, CI Add PyPI release infrastructure, archive/provenance validation, and L4 wheel qualification workflow for cuda-coop-cutlass Trent Nelson; Ashwin Srinath; Jacob Faibussowitsch +437 -25
#12785 CUB WarpScan Fix keyed inclusive WarpScan segment lane selection in logical subwarps ylwang; Anika Jain; Federico Busato; Michael Schellenberger Costa +49 -2
#12827 Windows compiler, Linking Locate Windows x64 and Arm64 compiler DLLs via cuda.pathfinder and link CuTe cooperative LTO-IR on Windows Trent Nelson; Ashwin Srinath; Keith Kraus; Jake Hemstad +2,979 -309
#12839 CI Test cuda.coop.cutlass against its CUDA 13.4 toolkit wheels Michael Schellenberger Costa; Bernhard Manfred Gruber +6 -8
#12860 Windows cache, CI Wait on contended Windows provider-cache locks and expand wheel, doc-source, and CI routing checks Trent Nelson; Jake Hemstad +240 -62
#12861 Memory validation Validate CuTe layout, swizzle, alignment, and address space before forming raw CUB pointers Trent Nelson; Ashwin Srinath +195 -107
#12862 Payloads, Typing Adapt readable register payloads, require concrete TempStorage and in-place outputs, and align .pyi stubs Trent Nelson; Diptorup Deb +930 -529
#12863 Payloads, Scalars Validate loop-carried ThreadData aggregate writes and host scalar narrowing conversions Trent Nelson; Diptorup Deb; Ashwin Srinath +433 -68
#12864 Collective bounds, Scratch Guard CUB tile-size bounds and irregular warp scratch indexing, and omit unused shuffle scratch Trent Nelson; Ashwin Srinath; Diptorup Deb +568 -281
#12877 Documentation, Visualizations Refine cuda.coop.cutlass compiler diagrams, interactive explorers, and cache/configuration docs Trent Nelson; Ashwin Srinath +2,203 -1,822
#12893 Memory layouts Require compact column-major CuTe layouts for load and store Diptorup Deb; Trent Nelson +381 -39
#12906 Dependencies, Packaging Require stable nvidia-cutlass-dsl[cu13]>=4.9.0,<4.10 across packaging, CI, and documentation Trent Nelson; Jake Hemstad +26 -26
#12907 Packaging, Provenance Stage self-contained license and verified header-provenance inputs for cuda-coop-cutlass sdists and wheels Trent Nelson; Ashwin Srinath; Jake Hemstad +284 -37
#12917 Release, CI Allow cuda-coop-cutlass release tags from matching release branches Trent Nelson; Jake Hemstad +169 -7
#12944 Windows linking, Dependencies Require nvJitLink 13.5+ on Windows and align platform [cu13] CUDA 13 dependency ranges Trent Nelson; Keith Kraus; Jake Hemstad +221 -56
#12967 Documentation, Examples Use cutlass.AddressSpace in the standalone CuTe integration example Trent Nelson; Diptorup Deb +2 -2

Don't miss a new cccl release

NewReleases is sending notifications on new releases.