K-Search: LLM Kernel Generation via Co-Evolving Intrinsic World Model
Organizations: UC Berkeley
Abstract
Optimizing GPU kernels is critical for efficient modern machine learning systems yet remains challenging due to the complex interplay of design factors and rapid hardware evolution. Existing automated approaches typically treat Large Language Models (LLMs) merely as stochastic code generators within heuristic-guided evolutionary loops. These methods often struggle with complex kernels requiring coordinated, multi-step structural transformations, as they lack explicit planning capabilities and frequently discard promising strategies due to inefficient or incorrect intermediate implementations. To address this, we propose Search via Co-Evolving World Model and build K-Search based on this method. By replacing static search heuristics with a co-evolving world model, our framework leverages LLMs' prior domain knowledge to guide the search, actively exploring the optimization space. This approach explicitly decouples high-level algorithmic planning from low-level program instantiation, enabling the system to navigate non-monotonic optimization paths while remaining resilient to temporary implementation defects. We evaluate K-Search on diverse, complex kernels from FlashInfer, including GQA, MLA, and MoE kernels. Our results show that K-Search significantly outperforms state-of-the-art evolutionary search methods, achieving an average 2.10x improvement and up to a 14.3x gain on complex MoE kernels. On the GPUMode TriMul task, K-Search achieves state-of-the-art performance on H100, reaching 1030us and surpassing both prior evolution and human-designed solutions.
Figures & tables
| Symbol | Definition |
|---|---|
| Kernel program implementation | |
| Observation tuple from execution | |
| Evaluator function | |
| Scalar objective score | |
| History | |
| Search state |
| Kernel | Arch. | Model Context | Characteristics & Challenges |
|---|---|---|---|
| MLA Paged Prefill | Hopper | DeepSeek-V3 Liu et al. (2024) | Implements attention with paged KV cache and split ckv (compressed, no RoPE) and kpe (RoPE). Bandwidth-bound in long contexts; requires matrix absorption and Split-K optimization. |
| MLA Paged Decode | Hopper | DeepSeek-V3 | Targets large dynamic batches. Latency-bound at low batch sizes. Uses Persistent Data Layout and specialized Hopper-instructions to minimize memory movement. |
| GQA Paged Decode | Hopper | Qwen3-A3B-30B Yang et al. (2025) | Memory bound. Optimizations include fusing multiple query heads per KV head to reuse KV loads, and using vectorized/async paged-KV gather with pipelined global to shared memory prefetch. |
| FP8 MoE | Blackwell | DeepSeek-V3 | Challenges include irregular data-dependent routing, load balancing, and managing FP8 packing/scaling overhead. |
| Submission ID | Lang. | Model | Iter. | Latency ( , ) |
|---|---|---|---|---|
| shiyegao | CUDA | – | – | |
| Zeyu Shen | Triton | – | – | |
| TTT | Triton | GPT-OSS-20B w/ RL | 25,600 | |
| K-Search (Ours) | Triton | GPT-5.2 + Gemini-3-Pro | 300 | 1030 |
GPU Kernel Optimization
GPU kernel optimization improves the speed and memory efficiency of computations by tailoring code to GPU hardware and workloads.
See all 209 papers