Skip to main content
The CUTLASS Python API provides a high-level interface for constructing, compiling, and running CUDA kernels without specifying many configuration parameters. The API automatically selects sensible defaults for template parameters.

Core Operations

CUTLASS Python provides several operation types:
  • Gemm - General Matrix Multiply operations
  • Conv2d - 2D Convolution operations
  • GroupedGemm - Batched/grouped GEMM operations

Installation

The CUTLASS Python interface is available through the cutlass package:

Basic Usage Pattern

All CUTLASS Python operations follow a consistent pattern:
  1. Create an operation object with data types and layouts
  2. Compile the underlying CUDA kernel (optional - can be done implicitly)
  3. Run the operation with input tensors

Simple Example

Decoupled Compilation

You can separate kernel compilation from execution:

Key Concepts

Data Types

CUTLASS supports various data types through the cutlass.DataType enum:
  • DataType.f16 - FP16 (half precision)
  • DataType.f32 - FP32 (single precision)
  • DataType.f64 - FP64 (double precision)
  • DataType.bf16 - BFloat16
  • DataType.e4m3 - FP8 E4M3
  • DataType.e5m2 - FP8 E5M2
  • DataType.s8 - INT8
  • DataType.s32 - INT32
You can also use native tensor types (e.g., torch.float32, numpy.float16).

Layout Types

Matrix layouts are specified using cutlass.LayoutType:
  • LayoutType.RowMajor - Row-major layout (C/C++ default)
  • LayoutType.ColumnMajor - Column-major layout (Fortran/BLAS default)

Compute Capability

The API automatically detects your GPU’s compute capability, but you can override:

Activation Functions

Activation functions can be fused into epilogues:

Asynchronous Execution

Operations can run asynchronously with explicit synchronization:

Error Handling

The API performs validation and raises exceptions for:
  • Incompatible tensor shapes
  • Mismatched data types
  • Invalid layouts
  • Unsupported compute capabilities

Performance Considerations

The high-level Python API prioritizes ease of use over optimal performance. For production workloads requiring maximum performance, consider:
  1. Explicitly specifying tile descriptions and kernel schedules
  2. Using the lower-level cutlass.backend API
  3. Tuning kernel parameters for your specific workload

Memory Management

The API integrates with existing tensor libraries:
  • PyTorch: Uses torch CUDA tensors directly
  • NumPy: Automatically transfers to/from GPU
  • CuPy: Uses cupy arrays directly
  • RMM: Optional support for RAPIDS Memory Manager

Logging

Enable detailed logging for debugging:

Next Steps