Agents
For a more token-efficient view of this page, read the raw documentation source. Follow its includes and API references for code examples and docstrings.
cuda.coop.cutlass: Cooperative Primitives for CuTe Kernels#
cuda.coop.cutlass brings CUB’s block and warp primitives to kernels
written in the CUTLASS CuTe DSL. The threads of a block or warp call one
function together to load and store data, reduce, scan, sort, select and more.
This kernel computes a running sum across a block of 128 threads:
@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)
@cute.jit
def launch(
source: cute.Pointer,
destination: cute.Pointer,
items_per_thread: cutlass.Constexpr,
):
kernel = prefix_sum(source, destination, items_per_thread)
kernel.launch(grid=1, block=128)
The Programming Guide shows the whole program and explains each line.
Installation#
On Linux with a CUDA 13-capable NVIDIA driver, install the published package with its CUDA Toolkit 13.4 headers, NVRTC and nvJitLink:
python -m pip install 'cuda-coop-cutlass[cu13]'
To build from source, run the following from the CCCL repository root:
python -m pip install './python/cuda_coop_cutlass[cu13]'
With a compatible system toolkit already installed, omit the [cu13] extra
from either command.
Requirements#
Python 3.10 or later.
CUDA Toolkit 13 and a compatible driver. On Linux with CuTe DSL 4.9.0.dev1, use NVRTC 13.1 through 13.4.
A GPU architecture supported by your CuTe compiler. The earliest target in CuTe DSL 4.9.0.dev1 is compute capability 8.0 (SM80).
CUTLASS CuTe DSL 4.9.0.dev1 or later in the 4.x series. The package depends on
nvidia-cutlass-dsl[cu13], which brings CuTe’s CUDA 13 libraries.
One tested Linux configuration pairs an NVIDIA L4 with CUDA Toolkit 13.4 and CuTe DSL 4.9.0.dev1. It uses CuTe’s default setting of PyIR off.
The wheel includes the CCCL headers it needs. The toolkit’s NVRTC compiles the CUB device code to LTO-IR. CuTe’s final linker must be at least as new as NVRTC within the same CUDA major series. The Linux CUDA 13 wheel for CuTe DSL 4.9.0.dev1 uses a CUDA 13.4 linker. CUDA Toolkits 13.3 and 13.4 have been tested with this wheel. CUDA 13.5 LTO-IR needs a newer linker. See nvJitLink compatibility and Compiler requirements.
Documentation#
- Programming Guide
- Executable examples
- Programming concepts
cuda.coop.cutlassAPI Reference- Advanced topics
- Configuration
- FAQs
- Which package and import should I use?
- Why use
ThreadDatafor per-thread values? - What does Load return?
- How do I stage a tile in shared memory?
- When does
ThreadDataneed an explicit element type? - Who chooses a producer’s memory copy and synchronization?
- Why or when would I provide my own
TempStorage? - Why use
TempStoragewithsharing="exclusive"? - Does releasing storage wait for its users?
- Can I use a
TempStorageinside anifor a loop? - Does TopK return sorted results?
- Does sorting each block sort the whole array?
- When should I use Adjacent Difference or Discontinuity?
- Can I zero-pad a partial Histogram tile?
- Does Histogram retain counters between calls?
- Why do windowed and bulk Run Length Decode use different calls?
- How do I pad run inputs and recognize the end of decoded output?
- How does Batched Warp Reduction differ from ordinary Reduce?
- Can I call a primitive inside an
ifor a loop? - How do I process more than one block?
- How do I carry a scan aggregate across loop iterations?
- How do I change a payload’s element type?
- How do
"min"and"max"treat NaN, and can a scan start from infinity? - Why does import work but kernel compilation fail?
- Glossary
- Visualizations
- Developer Guide
- Introduction to CUTLASS for cuda.coop.cutlass Developers
- Minimal CuTe DSL Integration Example
- Following a prefix sum
- Compiler requirements
- Compiler phases and handoffs
- Compiler integration
- Primitive families
- Planning the CUB call
- Exact launch facts
- One provider bundle per trace
- Scratch allocation after tracing
- Finding the implementation
- Keeping documentation in sync
- Debugger Walkthrough
- Working on a primitive
- Checking a change