TL;DR
Researchers from ETH Zurich have developed a "hardware-aware" machine learning approach to select the fastest GPU kernels for matrix multiplication. By augmenting raw configuration parameters with statically computed estimates of hardware behavior—like occupancy and pipeline balance—their models achieve a 64.2% reduction in selection regret compared to NVIDIA’s own heuristics, delivering significant speedups across diverse workloads.
What Problem Does This Paper Address?
Modern GPU libraries like NVIDIA’s CUTLASS are incredibly flexible. For a single General Matrix Multiplication (GEMM) operation, there can be over 60,000 semantically equivalent ways to implement it, varying in tile shapes, pipeline depths, and scheduling strategies.
The "best" implementation depends on a complex interplay between the problem dimensions (M, N, K), the data types, and the specific hardware architecture (e.g., the NVIDIA Hopper H100). Finding this optimal kernel is a nightmare:
- Exhaustive Autotuning (trying everything) is too slow for production, requiring hours of compilation and benchmarking.
- Analytical Heuristics (hand-written rules) are brittle and hard to maintain as hardware evolves.
- Standard Machine Learning often fails because models struggle to "rediscover" the laws of hardware physics from raw numbers like "tile size = 128."
Methods
The authors introduce hardware-aware representations. Instead of just telling a model what a configuration is (e.g., 4 pipeline stages), they provide features that describe what that configuration does to the hardware.
Key components of their method include:
- Feature Engineering: They developed a suite of statically computable features grouped into:
- Work Decomposition: Estimates of "wave efficiency" (how well the work fills the GPU's multiprocessors).
- Memory Behavior: Arithmetic intensity and cache-relative working sets.
- Resource Pressure: Predicted register and shared-memory usage to estimate "occupancy" (how many blocks can run at once).
- Pipeline Behavior: A "producer-consumer ratio" that estimates if the memory system can keep up with the math units.
- Learning-to-Rank: They trained Gradient-Boosted Trees (XGBoost) and Multi-Layer Perceptrons (MLP) to rank the entire valid catalogue of kernels for a given problem, rather than predicting absolute throughput.
- Biased-Diverse Sampling: To build their massive dataset efficiently, they used a smart sampling strategy that focused on high-performing candidates while maintaining enough "bad" examples for the model to learn what to avoid.
Datasets
The study utilizes a massive, newly constructed dataset:
- Training Corpus: 4.9 million measured CUTLASS kernels across 2,372 unique (shape, layout) groups on NVIDIA GH200 GPUs.
- Exhaustive Evaluation Set: 17 problem shapes (68 groups) where every single valid kernel (nearly 4 million total) was benchmarked to provide a ground-truth "oracle."
- Broad Evaluation: 8,000 unseen BF16 GEMM problems to test generalization.
- DeepBench: An external benchmark suite of 151 GEMMs from real-world speech and language modeling tasks.
Key Insights and Ideas
- Raw Parameters are Deceptive: The authors found that raw knobs like "pipeline stages" have almost zero correlation with performance on their own. However, derived features like
pipeline_fill_frac(how much of the pipeline is actually used) are highly predictive. - Inductive Bias Matters: By providing the model with "mechanistic" features (like the ratio of TMA load time to WGMMA compute time), the model doesn't have to learn the architecture from scratch. This makes the learning process much more data-efficient.
- Transferability: Because the features are based on hardware principles, a model trained on one data type (e.g., BF16) can be "fine-tuned" to a new one (e.g., FP8) using only 5% of the typical training data.
Key Results
- Regret Reduction: The hardware-aware MLP achieved a 6.2% mean selection regret, a massive improvement over NVIDIA’s
nvMMHheuristics (17.3%) and random selection (71.5%). - Real-world Speedup: On a broad set of 8,000 unseen problems, the learned selector provided a 1.14x geometric-mean speedup over
nvMMH. - DeepBench Performance: On the DeepBench suite, the models improved throughput by 12–13% over standard heuristics, winning on up to 96% of the test cases.
- Model Efficiency: Hardware-aware features allowed smaller, simpler models to outperform much larger models that only had access to raw structural parameters.
Limitations and Future Work
- Architecture Specificity: While the approach is general, the specific features in this paper were tailored for the NVIDIA Hopper architecture (SM90a). Adapting to future architectures (like Blackwell) would require updating the static feature formulas.
- Search Space Coverage: The current work focuses on dense GEMM. Extending this to sparse operations or complex fused epilogues (like those in FlashAttention) remains a promising future direction.
- Compilation Overhead: While the selector itself runs in milliseconds, constructing the valid CUTLASS catalogue still involves some static checks that can be slow for extremely large search spaces.
Summary updated