arXiv:2509.14279cs.SEcs.AI2025-09被引 54

用智能代理自动优化CUDA内核,提升性能与正确性。

Towards Robust Agentic CUDA Kernel Benchmarking, Verification, and Optimization

  • 用LLM将PyTorch代码转为CUDA内核并迭代优化
  • 在新基准上实现比原torch代码更快的运行时性能
  • 支持操作融合与多种优化策略,适合高性能计算研究者

大型语言模型(LLMs)在软件工程任务中展现出了扩展测试时计算的有效性,但这些方法通常聚焦于高层解决方案,对低层CUDA内核实现的优化关注有限。现有内核生成基准存在可被利用的漏洞,测试条件多样性不足,难以真实评估泛化能力。为此,我们提出robust-kbench,一个用于在多样化场景下严格评估内核性能与正确性的新基准。同时,我们构建了一个全面的智能体框架,实现CUDA内核的自动发现、验证与优化。该流程使前沿LLM能将torch代码转换为CUDA内核,并在我们的鲁棒评估环境中持续改进其运行时间。序列化工作流首先将PyTorch代码转化为等价的CUDA内核,然后通过针对CUDA生态设计的新型进化元生成过程优化其运行时性能,由基于LLM的验证器保障正确性并高效过滤。在robust-kbench上的评估显示,该方法生成的内核在实际应用中(包括前向和反向传播)优于原torch实现,支持操作融合与多种运行时优化策略。验证工作流能准确分类错误内核,显著提升硬件验证效率。

原文摘要 · Abstract (English)

Recent advances in large language models (LLMs) demonstrate their effectiveness in scaling test-time compute for software engineering tasks. However, these approaches often focus on high-level solutions, with limited attention to optimizing low-level CUDA kernel implementations. Additionally, existing kernel generation benchmarks suffer from exploitable loopholes and insufficient diversity in testing conditions, hindering true generalization assessment. To address these limitations, we introduce robust-kbench, a new benchmark for rigorous evaluation of kernel performance and correctness across varied scenarios. Furthermore, we present a comprehensive agentic framework that automates CUDA kernel discovery, verification, and optimization. This pipeline enables frontier LLMs to translate torch code to CUDA kernels and iteratively improve their runtime within our robust evaluation setting. Our sequential workflow first translates PyTorch code into equivalent CUDA kernels. It then optimizes their runtime using a novel evolutionary meta-generation procedure tailored to the CUDA ecosystem, guided by LLM-based verifiers for correctness and efficient filtering. Evaluated on robust-kbench, our approach produces CUDA kernels outperforming torch implementations for practical applications, including forward and backward passes. It can fuse operations and deploy various runtime optimization strategies. The verifier workflow accurately classifies incorrect kernels, enhancing hardware verification efficiency.

CUDA优化智能代理代码生成性能评测

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。