arXiv:2510.16933cs.DCcs.AI2025-10

用提示工程指导大模型生成高效CUDA代码,提升优化能力。

Tutoring LLM into a Better CUDA Optimizer

  • 通过细化提示引导大模型生成并行计算优化代码。
  • 模型经辅导后性能接近专家水平,未辅导时优化效果有限。
  • 适合对GPU编程优化有需求的研究者和开发者。

大语言模型(LLMs)的进展推动了编程工具(如GitHub Copilot)在代码生成、调试乃至性能优化方面的应用。本文聚焦于最新推理模型在生成预定义、知名任务的优化CUDA代码方面的能力。研究旨在确定大模型可自主完成的代码优化类型与并行模式,并探究通过提示辅导(在提示中提供更详细的指引)是否能进一步提升其表现。生成的代码通过自动评估(正确性与加速比)和人工代码审查进行双重验证,以获得更全面视角。此外,还尝试了交互式方法,让模型在会话中修正自身错误。结果表明,大模型已是相当出色的程序员,但要达到并行计算专家的优化水平,仍需通过提示辅导加以引导。

原文摘要 · Abstract (English)

Recent leaps in large language models (LLMs) caused a revolution in programming tools (like GitHub Copilot) that can help with code generation, debugging, and even performance optimization. In this paper, we focus on the capabilities of the most recent reasoning models to generate optimized CUDA code for predefined, well-known tasks. Our objective is to determine which types of code optimizations and parallel patterns the LLMs can perform by themselves and whether they can be improved by tutoring (providing more detailed hints and guidelines in the prompt). The generated solutions were evaluated both automatically (for correctness and speedup) and manually (code reviews) to provide a more detailed perspective. We also tried an interactive approach where the LLM can fix its previous mistakes within a session. The results indicate that LLMs are quite skilled coders; however, they require tutoring to reach optimized solutions provided by parallel computing experts.

CUDA优化大模型编程提示工程

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