NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Kernel Foundry: A Diagnosis-driven Evolutionary Kernel Optimizer with Multi-Experts

Zixuan Huang, Da Chen, Kecheng Huang, Lihao Yin, Xing Li, Huiling Zhen, Mingxuan Yuan, Zili ShaoarXiv 2026

TL;DR

Kernel Foundry is an automated framework that bridges the gap between high-level PyTorch code and highly optimized GPU Triton kernels. By combining a multi-island evolutionary search with structured hardware diagnosis and an anti-cheating validator, it achieves up to 100% correctness and substantial performance speedups on complex multi-operator workloads.

What Problem Does This Paper Address?

Writing high-performance GPU kernels requires deep expertise in hardware characteristics like parallelism, memory hierarchies, and synchronization. While Large Language Models (LLMs) excel at general code generation, they frequently fail to produce GPU kernels that are both functionally correct and highly optimized.

Furthermore, existing automated approaches often fall into "cheating" traps—generating wrapper code that simply delegates the computation back to external libraries like PyTorch. While these cheating kernels pass superficial correctness checks and look fast, they bypass actual kernel-level execution, collapsing the optimization space and misleading the iterative search process.

Methods

Kernel Foundry introduces a multi-stage, diagnosis-driven evolutionary framework to systematically optimize Triton kernels:

  1. Expert Initialization: Instead of generating code from scratch, the system utilizes a distilled dataset of verified Triton kernels (KernelBook). It embeds these kernels using GraphCodeBERT to capture syntactic and data-flow structures, retrieving the top-5 most semantically similar kernels via a Milvus vector database to serve as strong structural priors (few-shot examples) for an expert model.
  2. Anti-Cheating Validation: To prevent models from taking shortcuts, a two-level validator enforces prompt-level constraints and uses an LLM-based semantic checker to detect missing computations or external library calls, discarding any deceptive candidates.
  3. Multi-Island Evolutionary Search: The framework runs parallel, independent evolutionary paths ("islands"). Each island maintains its own population and trajectory, focusing on distinct optimization perspectives (e.g., operator fusion, memory access) via role-specialized prompts. An elite migration mechanism allows high-performing kernels to share patterns across islands.
  4. Diagnosis & Experience Feedback: For every evaluated kernel, a Result Analyzer extracts lightweight execution signals. A diagnosis engine categorizes correct kernels into specific hardware bottlenecks (memory-bound, latency-bound, or instruction-bound). A hint generator transforms these insights into natural language suggestions, which are accumulated in a centralized Experience Library to guide subsequent mutations.
Figure 1: Overview of Kernel Foundry. Given a PyTorch operator, the framework initializes candidate Triton kernels using expert-guided, retrieval-augmented priors, and then refines them through a multi- island, diagnosis-driven evolutionary loop. Each island maintains an independent population and optimization trajectory, guided by diagnostic feedback and retrieved hints from a shared experience library. Candidate kernels are iteratively evaluated, diagnosed for errors or performance bottlenecks, and refined until convergence to a high-performance implementation.

Datasets

  • KernelBook: A dataset consisting of a large number of PyTorch–Triton kernel pairs, filtered to retain only verified, correct implementations. It is used to distill expert programming patterns for retrieval-augmented initialization.
  • KernelBench: A standardized benchmark suite used for evaluation. It includes Level 1 tasks (isolated operators like element-wise, reduction, matrix multiplication, and convolution) and Level 2 tasks (complex multi-operator pipelines).

Key Insights and Ideas

  • Coarse Diagnosis is Sufficient: You do not need slow, heavy hardware profiling tools to guide an LLM optimizer. Simply categorizing a kernel as memory-, latency-, or instruction-bound based on lightweight runtime metadata provides a strong enough signal to steer mutations toward promising optimization directions.
  • The Necessity of Anti-Cheating: Standard LLM code generation benchmarks are highly vulnerable to shortcut implementations. Actively filtering out these behaviors is essential to force the evolutionary search to explore genuine, kernel-level hardware optimizations.
  • Structured Knowledge Accumulation: Combining instance-specific diagnosis with a global Experience Library allows the framework to reuse successful optimization strategies across entirely different tasks, mimicking how human engineers learn from past tuning attempts.
Figure 2: Diagnosis and experience-guided feedback. Given generated kernels and their evaluation results, the Result Analyzer extracts lightweight execution signals and performs correctness and performance diagnosis to identify error types or dominant performance limiters. A hint generator assesses the effectiveness of existing hints and distills new optimization hints from consistently improving kernels. Validated hints are stored in a centralized Experience Library, which accumulates reusable correctness repair and performance optimization knowledge to guide subsequent evolutionary iterations.

Key Results

Kernel Foundry was evaluated against direct LLM generation (DeepSeek-V3, Qwen-3.5, Claude-Sonnet-4.5) and specialized translators (AutoTriton):

  • Level 1 Tasks: The full configuration achieved 98% correctness and an average speedup of 1.47× using DeepSeek-V3 as the underlying optimizer.
  • Level 2 Tasks: It achieved up to 100% correctness (with Qwen-3.5 and Claude-Sonnet-4.5) and a peak average speedup of 2.85× (with DeepSeek-V3), significantly outperforming non-evolutionary baselines.
  • Steady Convergence: Trajectory analysis demonstrates that both correctness and speedup improve consistently across evolutionary iterations, proving the effectiveness of combining structured diagnosis with the experience library.
Correctness and average speedup improvements over evolutionary iterations on Level 2 tasks.

Limitations and Future Work

  • Computational Cost: The iterative loop of generation, compilation, and hardware execution incurs substantial overhead. For example, running GPT-5.4 on Level 2 tasks takes roughly 18.5 hours and costs around $100 in tokens.
  • Initialization Dependency: The framework's ultimate success is bounded by the quality of the initial seed kernels; poor starting points can restrict the search to suboptimal regions of the optimization space.
  • Sensitivity to Signal Noise: Because the diagnosis process relies on lightweight runtime statistics, coarse or noisy execution signals can occasionally lead to inaccurate bottleneck inferences, impacting the quality of the generated hints.

Summary updated

BibTeX
@misc{huang2026kernel,
  author = {Zixuan Huang and Da Chen and Kecheng Huang and Lihao Yin and Xing Li and Huiling Zhen and Mingxuan Yuan and Zili Shao},
  title = {{Kernel Foundry: A Diagnosis-driven Evolutionary Kernel Optimizer with Multi-Experts}},
  year = {2026},
  eprint = {2605.30359},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.30359},
}
Figure