AgentCompile:一种用于直接CUDA推理的LLM引导编译器
AgentCompile: An LLM-Guided Compiler for Direct CUDA Inference
AI总结:
提出AgentCompile,利用LLM提供语义建议,通过模板生成CUDA候选实现并验证,在多个Transformer模型上实现4-5.7倍加速。
摘要:
Transformer推理日益依赖专门的编译器和运行时支持,但实际模型图仍需要语义决策,以确定哪些区域值得专门化以及哪些CUDA实现族是可行的。我们提出AgentCompile,一种LLM引导的CUDA推理编译器,仅将LLM输出用作建议性搜索元数据。给定编译器生成的区域摘要和有界候选空间,LLM提出语义标签、候选优先级、参数提示和风险注释;编译器通过模板生成CUDA候选,检查接口和硬件约束,经验性验证候选,根据测量延迟选择实现,并在专门化不受支持或无利可图时回退。在端到端自回归生成中,AgentCompile在五个代表性工作负载上,相对于PyTorch eager模式,在Qwen3-1.7B、Qwen3-4B和Llama-3.2-1B-Instruct上分别实现了平均5.66倍、4.05倍和4.26倍的加速。我们将开源该项目。
英文摘要:
Transformer inference increasingly relies on specialized compiler and runtime support, while recent LLMs can generate nontrivial CUDA kernels. However, unconstrained generation guarantees neither correctness nor performance. We present \textsc{AgentCompile}, an LLM-guided CUDA inference compiler that combines two complementary uses of LLMs. First, the LLM provides advisory metadata for compiler-derived region summaries and bounded candidate spaces. The compiler then instantiates template-based CUDA candidates, validates correctness, selects implementations by measured latency, and falls back when specialization is unsupported or unprofitable. Second, under compiler-defined contracts, the LLM directly generates five classes of decode-critical kernels to accelerate inference, prompted by distilled optimization principles. \textsc{AgentCompile} integrates these kernels into a serving runtime with paged KV cache, continuous batching, preemption, chunked prefill, and bucketed full-step CUDA Graph replay. Across six evaluated model families, \textsc{AgentCompile} achieves speedups of \textbf{2.23--6.98$\times$} over PyTorch eager for single-request generation, and \textbf{1.04--1.16$\times$} over vLLM for both single-request generation and multi-request serving. Our code is publicly available at https://github.com/veneno1213822/AgentCompile.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。