Overview
Mixed-precision GEMM is essential for efficient AI inference workloads. This implementation supports:- Narrow precision tensors: int4, int8, uint8, fp8
- Wide precision tensors: fp16, bf16
- Two transformation modes:
- Convert-only: Direct type conversion
- Convert-scale: Type conversion followed by element-wise scaling
Architecture
The mixed-input GEMM uses a warp-specialized persistent kernel design:Implementation
Running Examples
Performance Profiling
Key Concepts
Scale Granularity
Scale Granularity
Scale granularity determines how many elements share the same scale factor:Example: For M=1024, K=6144, L=16 with granularity (1, 256):
- scale_granularity_m: Number of M-mode elements per scale
- scale_granularity_k: Number of K-mode elements per scale
- Scale tensor shape: (1024, 24, 16)
- Each element in M has its own scale
- Every 256 elements in K share a scale
Warp Specialization Benefits
Warp Specialization Benefits
Warp specialization improves performance by:
- Reduced synchronization: Warps operate independently
- Better register allocation: Each warp type has optimized register usage
- Increased parallelism: Different operations happen concurrently
- Cache efficiency: Specialized warps have more predictable access patterns
Transformation Storage Location
Transformation Storage Location
Transformed data can be stored in:Shared Memory (SMEM):
- Used for K-major layouts
- Allows all MMA warps to access
- Higher SMEM usage
- Used for M-major layouts (Blackwell only)
- Direct accumulator access
- Saves SMEM bandwidth
Data Type Support
Constraints
Source Code
Mixed Input GEMM
Complete source:
examples/python/CuTeDSL/blackwell/mixed_input_gemm/mixed_input_gemm.py