Writing high-performance GPU kernels is a critical bottleneck in modern AI model serving. Traditionally, this task has been a "black art" requiring human experts to manually map algorithms to complex hardware features like memory hierarchies and tensor cores. While modern Large Language Models (LLMs) are surprisingly adept at writing functionally correct code, they consistently struggle to write fast code.
Optimization is intrinsically a search problem over a massive, discontinuous space of parameters (such as tiling sizes and vectorization strategies). Because LLMs lack "hardware intuition," they often perform a random walk, suggesting optimizations that might work in theory but fail in practice due to specific hardware bottlenecks.
KernelBand is a novel framework designed to fix this fundamental mismatch. By formulating kernel optimization as a Multi-Armed Bandit (MAB) problem and leveraging real-time hardware profiling, KernelBand turns the probabilistic guesswork of LLMs into a structured, highly efficient performance search.
The KernelBand Framework
KernelBand bridges the gap between probabilistic code generation and rigorous performance search by introducing a structured decision-making layer between the LLM and the hardware. Its architecture relies on three core mechanisms:
- Multi-Armed Bandit (MAB) Formulation: Instead of letting the LLM guess randomly, KernelBand treats different optimization strategies (e.g., Tiling, Pipelining, Fusion) as "arms" in a bandit problem. It employs the Upper Confidence Bound (UCB) algorithm to explicitly balance exploration (trying new strategies) and exploitation (doubling down on what works).
- Hardware-Aware Pruning: The system uses NVIDIA Nsight Compute to profile kernels in real-time. If a hardware resource (such as DRAM bandwidth) is already 75% saturated, KernelBand "prunes" any strategies that would further stress that resource. This prevents the LLM from wasting time chasing physically impossible speedups.
- Runtime-Behavior Clustering: To navigate the infinite variety of possible kernels, KernelBand groups similar kernels into clusters based on a 5D feature vector (execution time, register pressure, shared memory use, etc.). It operates on the assumption of Lipschitz continuity—the idea that kernels with similar runtime signatures will respond similarly to the same optimization. This allows the framework to share "lessons learned" across different tasks.
Key Insights
KernelBand's approach reveals several fascinating dynamics about how LLMs interact with hardware optimization:
- Learned Stats > LLM Intuition: One of the most striking findings is that replacing the bandit policy with "LLM semantic reasoning" (asking the LLM to pick the strategy based on its own logic) causes performance to plummet. Actual execution statistics are far more reliable than a model's intuition about hardware.
- The Power of Negative Space: By using hardware profiling to mask out saturated strategies, KernelBand significantly reduces the search space. Its strength lies as much in identifying what not to do as in finding what to do.
- Cross-Kernel Knowledge Transfer: Thanks to the clustering mechanism, the system doesn't start from scratch for every new kernel. If it learns that "Tiling" works well for a specific type of memory-bound operation, it immediately applies that knowledge to similar kernels in the same cluster.
Evaluation and Results
The authors evaluated KernelBand on TritonBench-G, an expanded benchmark containing 183 Triton kernels spanning 13 functional categories (e.g., Attention, GEMM, Softmax). Testing was conducted across three distinct NVIDIA GPU architectures (RTX 4090, H20, and A100) using four frontier models: DeepSeek-V3.2, GPT-5, Claude Opus 4.5, and Gemini 3 Flash.
The results demonstrate that KernelBand acts as a powerful "performance amplifier" for any LLM:
- Significant Speedups: KernelBand achieved up to a 1.91× geometric mean speedup on the A100 GPU, consistently outperforming GEAK, the previous state-of-the-art agent.
- Higher Success Rates: It improved the Fast@1 success rate (the probability of finding a speedup on the very first attempt) by 39–140% compared to standard baselines.
- Cost Efficiency: At a fixed API budget (e.g., $0.50 per kernel), KernelBand delivered 35–50% higher speedups than unguided methods by avoiding wasted iterations on low-potential strategies.
Limitations and Future Work
While KernelBand represents a major step forward, it is not without limitations. The Lipschitz continuity assumption can fail during major algorithmic "cliffs" (e.g., changing a simple reduction to a complex parallel scan) or when a minor code change triggers a massive occupancy drop in the hardware. Furthermore, the framework remains entirely dependent on the LLM's ability to generate valid Triton Domain-Specific Language (DSL) code; if the LLM cannot synthesize the basic DSL correctly, KernelBand cannot optimize it. Finally, while the algorithm re-clusters kernels dynamically, the current theoretical proof assumes a static cluster surrogate, leaving a fully dynamic regret analysis as a target for future research.
Summary updated