用智能提示优化让小模型也能写出高效可靠的GPU并行代码
Bridging the Gap: Empowering Small Models in Reliable OpenACC-based Parallelization via GEPA-Optimized Prompting
- 通过遗传-帕累托框架迭代优化提示词,自动改进OpenACC指令生成
- 小模型编译成功率从66.7%提升至93.3%,部分达100%,性能超CPU基线
- 无需微调模型,即可让轻量级LLM胜任高性能计算中的并行代码生成
OpenACC降低了GPU卸载的门槛,但编写高性能指令仍需深入理解内存层级、数据移动与并行策略。大语言模型(LLMs)虽有望实现自动化并行代码生成,但简单提示常导致语法错误、无法编译或性能不及CPU基线。本文提出一种系统性提示优化方法,通过GEPA(GEnetic-PAreto)框架,基于专家标注的正确示例和条款级匹配反馈,迭代演化提示词。在PolyBench测试集上,使用优化提示后,小模型的编译成功率显著提升:GPT-4.1 Nano从66.7%增至93.3%,GPT-5 Nano从86.7%升至100%,达到甚至超过其大型版本性能。此外,获得功能型GPU加速的程序数增加21%。结果表明,提示优化能有效释放小型、低成本LLM在稳定高效GPU卸载指令生成中的潜力,为高性能计算提供经济可行的自动化路径。
原文摘要 · Abstract (English)
OpenACC lowers the barrier to GPU offloading, but writing high-performing pragma remains complex, requiring deep domain expertise in memory hierarchies, data movement, and parallelization strategies. Large Language Models (LLMs) present a promising potential solution for automated parallel code generation, but naive prompting often results in syntactically incorrect directives, uncompilable code, or performance that fails to exceed CPU baselines. We present a systematic prompt optimization approach to enhance OpenACC pragma generation without the prohibitive computational costs associated with model post-training. Leveraging the GEPA (GEnetic-PAreto) framework, we iteratively evolve prompts through a reflective feedback loop. This process utilizes crossover and mutation of instructions, guided by expert-curated gold examples and structured feedback based on clause- and clause parameter-level mismatches between the gold and predicted pragma. In our evaluation on the PolyBench suite, we observe an increase in compilation success rates for programs annotated with OpenACC pragma generated using the optimized prompts compared to those annotated using the simpler initial prompt, particularly for the "nano"-scale models. Specifically, with optimized prompts, the compilation success rate for GPT-4.1 Nano surged from 66.7% to 93.3%, and for GPT-5 Nano improved from 86.7% to 100%, matching or surpassing the capabilities of their significantly larger, more expensive versions. Beyond compilation, the optimized prompts resulted in a 21% increase in the number of programs that achieve functional GPU speedups over CPU baselines. These results demonstrate that prompt optimization effectively unlocks the potential of smaller, cheaper LLMs in writing stable and effective GPU-offloading directives, establishing a cost-effective pathway to automated directive-based parallelization in HPC workflows.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。