TL;DR
CAKE is a compiler-agent co-design framework that allows AI coding agents to automatically generate expert-level GPU kernels. By replacing the traditional "black-box" compiler loop with a hardware-explicit intermediate representation (CAKE IR) and an evolving compiler harness, CAKE provides the structured feedback necessary for LLMs to routinely match or outperform human-optimized baselines on modern NVIDIA hardware.
What Problem Does This Paper Address?
Writing high-performance GPU kernels requires deep expertise in hardware-level scheduling, warp specialization, and memory-tier placement. While LLM-based coding agents can automatically iterate on GPU code, they typically treat the compiler as a fixed black box. If a proposed kernel crashes or runs slowly, the agent only receives generic error messages or a single end-to-end execution time. This lack of visibility makes it incredibly difficult for an agent to deduce which specific design decision caused a pipeline stall or synchronization failure.
Furthermore, existing domain-specific languages (DSLs) are poorly suited for agents: high-level DSLs (like Triton) hide the low-level hardware controls needed for peak performance, while low-level DSLs demand mastery over complex layout mathematics that lead to brittle, error-prone code.
Methods
CAKE solves this by co-designing the programming language, the compiler harness, and the optimization agent together.
Instead of writing raw CUDA or fighting a complex layout algebra, agents author CAKE IR—a typed, hardware-explicit schedule representation. CAKE IR forces the agent to explicitly declare resources (memory regions, pipelines, synchronization objects) and warp roles, while leaving the mechanical lowering details (like exact memory addresses and phase bits) to the compiler.
The system operates via a dual-loop evolution process:
- Kernel Evolution (Inner Loop): The optimization agent proposes CAKE IR candidates. The compiler harness subjects these to static validation and performance modeling before running them on a physical GPU, providing localized, actionable diagnostics back to the agent.
- Compiler-Harness Evolution (Outer Loop): The compiler itself is an evolutionary target. When agents encounter recurring failure modes or missing hardware capabilities, the harness is updated with new verifier rules, IR primitives, or cost-model calibrations.
Datasets
The authors evaluated CAKE against a validated corpus of over 400 static/compile cases and nearly 400 GPU correctness cases spanning roughly 28 operator families. Key workloads and baselines used for evaluation include:
- Flash-KMeans: An exact $k$-means workload used for implementation-hidden "clean-start" testing.
- Kimi Delta Attention (KDA): A frontier linear attention architecture with recurrent state.
- Known Production Kernels: Baselines drawn from state-of-the-art libraries including TensorRT-LLM, CUTLASS, DeepGEMM, FlashAttention-4, and FlashInfer.
Key Insights and Ideas
- The Compiler as an Evolving Collaborator: Rather than treating the compiler as static infrastructure, treating it as a co-evolving target allows the system to turn recurring agent failures into reusable compiler knowledge.
- Ditching Layout Algebra for LLMs: Forcing an LLM to compute complex layout transformations mathematically is highly inefficient. CAKE proves that letting the agent specify concrete storage/access commitments, while leaving the legality verification to the compiler, yields a much more effective agent search space.
- Separating Specialization from Generalization: CAKE splits the optimization process into two distinct phases: first, aggressively optimizing a kernel for a single exact shape, and second, grouping those optimized "seeds" into a dispatcher-backed library portfolio. This prevents general-purpose routing logic from polluting the core performance signal during the agent's search.
Key Results
- Flash-KMeans Clean Start: In a blind test on an NVIDIA Blackwell B200 GPU, the best agent-generated CAKE IR candidate achieved 1.144× the performance of the tuned FlashML baseline, whereas agents writing direct CUDA/PTX failed to even reach the baseline (0.928×).
- Frontier Kernel Synthesis: For Kimi Delta Attention, CAKE synthesized a prefill kernel that achieved a 2.05× geometric-mean speedup over the official FlashKDA baseline across six B200 shapes. This kernel was validated in end-to-end production serving and upstreamed to the FlashInfer library.
- Library Portfolios: Dispatcher-backed portfolios for KNN and KMeans families improved performance by 1.42× to 2.12× across more than 400 distinct shapes on GB200 hardware.
Limitations and Future Work
- Hardware Lock-in: CAKE currently only targets NVIDIA architectures (Ampere through Blackwell). Porting it to non-NVIDIA hardware would require completely rebuilding the backend lowering paths.
- Uneven Calibration: The internal performance cost model is heavily optimized and calibrated for B200 and H100 GPUs; its predictive accuracy declines significantly on other architectures.
- Human in the Loop: While the kernel generation and harness updates are largely driven by agents, compiler evolution still relies on human engineers to act as "merge gates" to review and approve changes to the core IR and verifier rules.
Summary updated