Hierarchical GEMM Structure
CUTLASS organizes GEMM computations into a hierarchical tiled structure that targets different levels of the GPU memory hierarchy and execution model:- Concurrency among threadblocks, warps, and CUDA/Tensor Cores
- Memory locality within shared memory and registers
Tile Size Selection
Threadblock Tile Selection
The threadblock tile size (ThreadblockShape::{kM, kN, kK}) is critical for performance:
- Large Problems
- Small Problems
- Tall/Skinny
Recommended: 128×128×32 or 256×128×32Larger threadblock tiles:
- ✅ Better data reuse
- ✅ Fewer global memory fetches
- ✅ Higher arithmetic intensity
- ⚠️ May reduce occupancy
- ⚠️ Higher register pressure
Warp Tile Configuration
Warp-level tile sizes affect shared memory access patterns:- Larger warp tiles increase data reuse but may cause bank conflicts
- Warp tile should divide evenly into threadblock tile
- Match warp tile aspect ratio to problem characteristics
Pipeline Optimization
Software Pipelining
CUTLASS uses software pipelining to hide memory latency by overlapping computation with data movement:1
Double Buffering in Shared Memory
Allocate two tiles in shared memory:Recommended values:
- One tile for current computation
- One tile for loading next iteration’s data
- Ampere: 3-4 stages
- Hopper: 4-7 stages (with async TMA)
- Blackwell: Dynamic based on problem size
2
Register-Level Pipelining
Double buffer warp-level fragments:
- One fragment for MMA computation
- One fragment for receiving shared memory loads
3
Async Copy
Use asynchronous copy instructions on Ampere and newer:Benefits:
- Hides memory latency
- Reduces register pressure
- Enables deeper pipelines
Multi-Stage Pipeline Configuration
Memory Access Optimization
Threadblock Rasterization
Control how threadblocks are mapped to the GEMM problem to improve L2 cache locality:Alignment Requirements
Ensure proper memory alignment for vectorized loads:Parallelized Reductions (Split-K)
When to Use Split-K
Split-K parallelizes the K dimension reduction, useful when:- M and N are small but K is large
- Not enough parallelism from M×N dimension
- GPU occupancy is low
- Serial Split-K
- Parallel Split-K
Each partition writes partial results; one final reduction pass:
Optimal Split-K Factor
Choose split-K slices based on problem size:Tensor Core Optimization
Instruction Shape Selection
Different architectures support different MMA instruction shapes:Ampere (SM80-SM86)
Ampere (SM80-SM86)
Hopper (SM90)
Hopper (SM90)
Blackwell (SM100)
Blackwell (SM100)
Maximizing Tensor Core Utilization
1
Use appropriate data types
Match your data types to available Tensor Core instructions:
- FP16/BF16: Best performance on modern GPUs
- TF32: Good balance for FP32 workloads
- INT8/FP8: Highest throughput for quantized models
2
Ensure tile sizes are multiples of instruction shape
3
Minimize padding
Pad matrices to multiples of tile sizes:
Epilogue Optimization
The epilogue performs the final transformation: D = α·AB + β·CFused Epilogue Operations
Fuse additional operations into the epilogue to save memory bandwidth:Residual Matrix Support
For transformer models, efficiently fuse residual additions:Advanced Hopper Features
Tensor Memory Accelerator (TMA)
Hopper’s TMA provides hardware-accelerated asynchronous memory copies:- Hardware-managed async copies
- Reduced register pressure
- Better pipelining
- Multi-dimensional addressing
Warp Specialization
Dedicate warps to specific tasks:- Producer warps: Load data via TMA
- Consumer warps: Execute MMA instructions
- Benefits: Better latency hiding, higher throughput
Cluster Launch
Thread block clusters enable communication between threadblocks:- Distributed shared memory access
- Reduction operations across threadblocks
- Flash Attention and other advanced algorithms
Performance Tuning Checklist
1
Profile your baseline
2
Experiment with tile sizes
Test different threadblock configurations:
3
Optimize pipeline depth
4
Test rasterization strategies
5
Consider Split-K for small problems
Next Steps
Profiling Guide
Learn how to use the CUTLASS profiler effectively
Benchmarks
Compare performance across different configurations