Command Palette
Search for a command to run...
CAKE: 프런티어 커널 진화를 위한 컴파일러–에이전트 공동 설계
CAKE: 프런티어 커널 진화를 위한 컴파일러–에이전트 공동 설계
초록
GPU 커널 에이전트 연구와 GPU 프로그래밍 언어 연구는 서로 독립적으로 발전해 왔으며, 그 간극 속에서 전문가 수준의 커널이 사장되고 있다. 커널 에이전트는 컴파일러를 고정된 블랙박스로 취급한다. 제안, 변이, 순위화 기법은 개선되지만, 실행 환경이 돌려주는 것은 컴파일러 오류, 정확성 결과, 종단 간 실행 시간뿐이다. 이 신호들은 어떤 프로그램 결정이 동기화 실패, 하드웨어 계약 위반, 파이프라인 지연을 초래했는지 결코 알려주지 않으며, 프런티어 워크로드가 결여된 역량을 드러내도 성장할 수 없다. 한편 에이전트가 작성할 수 있는 언어는 에이전트를 위해 설계된 것이 아니다. 타일 수준 DSL은 전문가 커널과 단순히 올바른 커널을 가르는 워프 전문화, 배리어 조율, 메모리 계층 배치를 감춘다. 저수준 DSL은 그러한 제어를 노출하지만, 에이전트의 오류 가능성을 높이고 오류 위치 파악을 어렵게 만드는 레이아웃 계산을 요구한다. 본 논문은 이 둘을 공동 설계하는 Cake를 제시한다. 에이전트는 Cake IR을 작성하는데, 이는 레이아웃 대수 없이 세밀한 제어를 제공하고, 검증기와 비용 모델이 컴파일 전에 프로그램을 추론할 수 있는 충분한 정보를 담는, 타입이 지정되고 하드웨어를 명시적으로 드러내는 스케줄 표현이다. 하네스는 국소화된 정확성 및 성능 진단으로 응답하며, 그 자체가 진화의 대상이 되어 반복되는 실패는 일회성 우회책이 아니라 새로운 검증기 규칙, IR 프리미티브, 비용 모델 보정, 재사용 가능한 전술로 축적된다. B200에서 구현을 숨긴 Flash-KMeans 클린 스타트를 표현별 3회 실행으로 비교한 결과, 8천만 토큰 예산에서 Cake IR을 사용한 최적 후보는 튜닝된 FlashML 기준선 대비 중앙값 1.144배에 도달한 반면, 직접 CUDA/PTX는 0.928배에 그쳤다. 클린 스타트 벤치마크를 넘어, 에이전트가 생성한 Kimi Delta Attention은 공식 FlashKDA 대비 기하 평균 2.05배의 속도 향상을 달성했고 종단 간 서빙에서 검증되었다. 디스패처 기반 KNN 및 KMeans 계열은 400개 이상의 형상에서 1.42배~2.12배의 성능을 개선했으며, 네 건의 커널 변경이 업스트림 PR로 제공된다. Cake는 Ampere부터 Blackwell까지의 NVIDIA GPU를 대상으로 하며, 단일 형상 진화와 라이브러리 통합에 필요한 일반화 및 디스패치 단계를 분리한다.
One-sentence Summary
Researchers from NVIDIA and Carnegie Mellon University propose Cake, a compiler-agent co-design for GPU kernel evolution whose typed, hardware-explicit Cake IR provides fine-grained control without a layout algebra and enables localized verifier and cost-model diagnostics that evolve with recurring failures, achieving on B200 a 1.144× speedup over the tuned FlashML baseline for FlashKMeans versus 0.928× for direct CUDA/PTX and a 2.05× geometric-mean speedup over FlashKDA for Kimi Delta Attention.
Key Contributions
- Cake provides a typed, hardware-explicit IR and co-designed compiler harness for GPU kernel agents, giving fine-grained control without a layout algebra and enabling verifier and cost-model reasoning before compilation.
- The harness is an evolvable target: recurring kernel failures become new verifier rules, IR primitives, cost-model calibrations, and reusable tactics, with localized correctness and performance diagnostics returned to the agent.
- On implementation-hidden Flash-KMeans clean starts on B200, the best Cake IR candidate at an 80-million-token budget reaches a median 1.144× the tuned FlashML baseline versus 0.928× for direct CUDA/PTX; agent-generated Kimi Delta Attention achieves a 2.05× geometric-mean speedup over official FlashKDA and is validated in end-to-end serving, and dispatcher-backed KNN and KMeans families improve performance by 1.42× to 2.12× across more than 400 shapes.
Introduction
Coding agents increasingly write and revise GPU kernels, but most systems treat the programming environment as a fixed black box: they compile, test, measure latency, and edit, so a crash does not identify the violated safety or hardware condition, and a single latency number does not explain which program decision limits performance. Existing GPU DSLs are also awkward for agent-driven kernel development because high-level tile DSLs hide the warp specialization, barrier choreography, and memory-tier placement that expert kernels need, while low-level DSLs require layout algebra expertise and can produce brittle code. The authors introduce Cake, a system that makes the compiler an evolving collaborator for kernel agents. Cake has agents edit a typed IR rather than raw CUDA, returns localized correctness and performance diagnostics instead of pass/fail feedback, and turns repeated failures into verifier rules, calibration tasks, or new primitives under corpus tests and human merge gates.
Method
The authors leverage a bottom-up approach to design the Cake IR, rather than starting with a predefined vocabulary. The process begins with a corpus of production kernels and hardware design principles. Agents identify recurring schedules or missing capabilities, revise the IR and its compiler support, and then port and validate kernels against the revised system. This cycle repeats for new kernel families or gaps exposed by validation, continuously growing the IR.
Refer to the framework diagram:
The Cake IR records explicit machine schedules, detailing how the machine should be driven, including warp roles, buffer staging, barrier gates, and instruction forms. A program combines explicit operations, declared resources, warp roles, and grid configuration. Key properties include a type-checked vocabulary for compute and memory movement, declared resources for memory and synchronization state, explicit warp group roles, and auto-derived metadata where mechanical consequences are lowered rather than authored. This design allows analyses to reason from explicit schedule decisions before code generation. The system targets NVIDIA GPUs from Ampere through Blackwell, mapping the attached GPU exactly and emitting performance estimates where calibration is available.
The compiler harness serves as the agent-facing environment around the Cake IR. Humans provide high-level descriptions of intended analyses, while agents implement, maintain, and refine them under validation. Before compilation, the harness checks the typed schedule for synchronization, memory-safety, data-flow, and resource violations. It also verifies numerical correctness against reference outputs and uses a calibrated cost model to estimate performance and rank candidates.
Compiler evolution follows two complementary paths to improve the system alongside kernel development.
As shown in the figure below:
In the first path, agents inspect production kernels and hardware documentation to identify missing patterns, such as new instruction forms or synchronization idioms, and formulate compiler change proposals. These proposals are checked against design principles before implementation. In the second path, agents use feedback from failed candidates, including sanitizer reports and debugging logs, to distill recurring failure modes into new analyses. For instance, an opaque runtime crash becomes a verifier rule, and a repeated illegal lowering pattern becomes a static check. These two paths are coupled; new primitives expose hardware facts enabling stronger analysis, while new analyses constrain the design space for future primitives. Changes are test-gated across the kernel corpus to ensure primitives and analyses evolve together.
The external workload contract acts as the stable authority for the agent workflow, which consists of four stages. First, agents generate structurally distinct Cake IR candidates. Second, they filter these candidates using IR construction checks, verifier hard gates, and cost-model ranking to avoid unnecessary GPU usage. Third, survivors are evaluated against an external oracle with benchmarking and profiler evidence. Finally, the resulting evidence is routed to the candidate, verifier, cost model, or IR vocabulary based on the diagnosis.
To transition from a tuned shape to a library, the system employs a separate generalization stage. This stage groups measured seeds into shape buckets, produces specialized or shared variants, and orders their guards behind an explicit fallback. Validation covers representative inputs, boundary cases, and fallback paths. The system reuses a single physical schedule across as much of the shape domain as possible, introducing new routes only when a material schedule change is required, ensuring routing complexity is justified by measured workload gain.
Experiment
The evaluation spans clean-start evolution, frontier-kernel synthesis, known-kernel reproduction, and dispatcher-inclusive library generalization. Clean-start Flash-KMeans experiments show Cake IR surpasses a tuned baseline while the direct CUDA/PTX arm does not, and frontier kernels such as KDA, Gated DeltaNet, MiniMax sparse attention, TinyGEMM, and Alpha-MoE are synthesized without low-level references and improve over black-box baselines. Known-kernel reproduction validates production-quality output by matching or exceeding highly optimized expert references in nearly all fixed comparisons. The validated corpus and generalized portfolios further confirm broad architecture support, correct outputs, and consistent dispatcher-level speedups across many shapes.
The harness exposes seven analysis and validation categories spanning pre-compile gates, an execution gate, reporting, and non-blocking hints. Pre-compile checks reject candidates for synchronization, memory-use, resource, instruction, data-flow, and schedule-structure violations before execution, while numerical validation compares compiled outputs against an authoritative external reference. Performance analysis estimates cost and identifies broad bottleneck classes, but on-device measurement and profiling remain the final ground truth. Program safety, hardware conformance, data consistency, and schedule semantics act as pre-compile gates that block invalid candidates with localized reasons. Numerical validation is an execution gate requiring agreement with an authoritative external reference before final acceptance. Performance analysis returns estimated cost and broad bottleneck attribution without replacing on-device measurement as the final ground truth. Optimization guidance is advisory and suggests promising revisions without blocking compilation.
In matched clean-start Flash-KMeans runs at the 80-million-token budget, the CAKE IR arm reached a plateau in all three runs, while the direct CUDA/PTX arm did not plateau in any run. The CAKE IR arm also used less median active evolve time and ended with a higher best median performance at the 80M budget. Direct CUDA/PTX ended with a best median performance below the reference level. CAKE IR reached the plateau in every run by the 80M-token budget, whereas direct CUDA/PTX reached it in none. Median active evolve time was substantially lower for CAKE IR than for direct CUDA/PTX. At the 80M-token budget, CAKE IR's best median performance was above the reference while direct CUDA/PTX's was below it.
The evaluation combines pre-compile checks for synchronization, memory, resource, instruction, data-flow, and schedule-structure violations with an execution-time numerical gate against an authoritative reference, while performance analysis and optimization guidance remain advisory. In matched clean-start Flash-KMeans runs at an 80-million-token budget, the CAKE IR arm reached a performance plateau in all three runs, used less median active evolve time, and finished above the reference, whereas direct CUDA/PTX plateaued in none and stayed below the reference. These results indicate that the CAKE IR path gives more reliable convergence and better final performance under the same budget.