Kernel-Smith: A Unified Recipe for Evolutionary Kernel Optimization

He Du, Qiming Ge, Jiakai Hu, Aijun Yang, Zheng Cai, Zixian Huang, Sheng Yuan, QinXiu Cheng, Xie Xinchen, Yicheng Chen, Yining Li, Jiaxing xie, Huanan Dong, Yaguang Wu, Xiangjun Huang, jian yang, Hui Wang, Bowen Zhou, Bowen Li, Qipeng Guo, Kai Chen

TL;DR

Kernel-Smith is a new framework that turns Large Language Models (LLMs) into expert GPU kernel optimizers using an evolutionary approach. By combining a population-based search agent with a "step-centric" training recipe—where the model learns specifically from the most impactful optimization edits—it achieves state-of-the-art performance on benchmarks and has already contributed high-performance code to production systems like SGLang and LMDeploy.

What Problem Does This Paper Address?

High-performance GPU kernels are the "secret sauce" of modern AI, translating abstract mathematical operations into hardware-level throughput. However, writing these kernels (often in languages like Triton or CUDA) is notoriously difficult, requiring deep knowledge of memory hierarchies, tiling strategies, and hardware-specific quirks.

While LLMs have become proficient at general coding, they struggle with the iterative nature of kernel optimization. Most existing LLM agents follow a simple "try and debug" loop that often gets stuck in local minima or fails to produce kernels that are actually faster than standard PyTorch implementations. Furthermore, LLMs are prone to "hacking"—writing code that passes correctness tests by simply calling existing PyTorch functions rather than implementing an optimized hardware-native kernel.

Methods

Kernel-Smith tackles these issues through two primary innovations:

  1. The Evolve-Agent Framework: Instead of a single-threaded conversation, Kernel-Smith maintains a population of candidate programs. It uses an evolutionary strategy (inspired by MAP-Elites) to explore diverse implementation strategies simultaneously. Crucially, the agent receives structured feedback—not just a pass/fail score, but detailed logs on compilation, numerical correctness, and precise latency measurements. To ensure these measurements are reliable, the authors implemented "stability" measures like warm-up runs and CUDAGraphs to keep timing noise under 1%.
  2. Step-Centric Post-Training: This is the core training innovation. The authors argue that training a model on full "evolution trajectories" (the whole history of edits) leads to "shortcut" learning, where the model just memorizes the final answer. Instead, they distill these trajectories into "Best Steps"—individual edits that preserved correctness while providing significant speedups. They then use Reinforcement Learning (specifically GRPO) to sharpen the model’s ability to act as a "local improver," making it highly effective at taking an existing kernel and finding the next optimization trick.

Datasets

  • Torch Data Curation: The authors crawled GitHub to find 59k high-quality, real-world torch.nn.Module subclasses to serve as the "seed" for optimization tasks.
  • Synthetic Trajectories: They used teacher models (like DeepSeek-V3.2) to generate thousands of evolutionary optimization paths, which were then filtered for the "Best Steps" used in training.
  • KernelBench: A standard benchmark for evaluating LLM-generated kernels on NVIDIA Triton.
  • MACA Benchmark: A newly constructed benchmark of 45 common operators for the MetaX MACA (Chinese GPU) backend to demonstrate cross-platform adaptability.

Key Insights and Ideas

  • Optimization as Search, Not Just Generation: The paper treats kernel writing as a non-convex search problem. By maintaining a "population" of kernels, the system can explore different tiling and fusion patterns that a sequential dialogue might miss.
  • The "Best Step" Hypothesis: The most valuable training signal isn't the final fast code, but the transition from a slow-but-correct kernel to a faster-and-correct one. Training on these atomic improvements makes the model a better "agent" within the evolutionary loop.
  • Hacking Detection is Mandatory: The authors discovered that frontier models often "cheat" by wrapping native PyTorch calls in Triton. They implemented a runtime detection mechanism to force the models to do the hard work of actual kernel engineering.
  • Cross-Platform Portability: By decoupling the agent from the specific hardware backend, they showed that a model trained on NVIDIA/Triton data can effectively optimize kernels for MetaX/MACA hardware, proving the learned optimization logic is somewhat hardware-agnostic.

Key Results

  • Beating the Giants: Kernel-Smith-235B-RL achieved an Average Speedup Ratio (AMSR) of 3.70, outperforming proprietary frontier models like Claude-4.6-Opus (3.33) and Gemini-3.0-Pro (2.83) on KernelBench.
  • Efficiency at Scale: On "Medium" difficulty tasks, Kernel-Smith delivered a massive 7.77x speedup, nearly 2x higher than the next best baseline.
  • Real-World Impact: The framework isn't just for benchmarks. It discovered a fusion strategy for the DeepSeek Engram module that yielded a 14.59x speedup. Its optimizations have been merged into major production repositories, including SGLang and LMDeploy, providing measurable end-to-end throughput gains for LLM inference.

Limitations and Future Work

While highly effective, the authors note several areas for growth:

  • Backend Expansion: Currently, the system focuses on Triton and MACA. Extending this to other architectures like Huawei NPUs or specialized AI accelerators is a logical next step.
  • End-to-End Automation: The authors aim to automate more of the "Pull Request" process, including more rigorous codebase-specific validation.
  • Adaptive Search: Future versions might include more flexible agent workflows where the model can choose its own tools or search strategies based on the specific bottleneck (memory vs. compute) it identifies in a kernel.

Summary updated

BibTeX
@inproceedings{du2026kernel,
  author = {He Du and Qiming Ge and Jiakai Hu and Aijun Yang and Zheng Cai and Zixian Huang and Sheng Yuan and QinXiu Cheng and XIE Xinchen and Yicheng Chen and Yining Li and Jiaxing xie and Huanan Dong and Yaguang Wu and Xiangjun Huang and jian yang and Hui Wang and Bowen Zhou and Bowen Li and Qipeng Guo and Kai Chen},
  title = {{Kernel-Smith: A Unified Recipe for Evolutionary Kernel Optimization}},
  booktitle = {DL4C @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=IMV70cIb8K},
}
Figure