Skip to main content
QUICK REVIEW

[论文解读] HPC-Coder: Modeling Parallel Programs using Large Language Models

Daniel Nichols, Aniruddha Marathe|arXiv (Cornell University)|Jun 29, 2023
Parallel Computing and Optimization Techniques参考文献 37被引用 5
一句话总结

本文介绍了 HPC-Coder,一个在 HPC 特定代码和性能数据上微调的大语言模型,能够显著提升生成正确并行代码的能力,在准确标注 OpenMP 指令(准确率达 97%)以及预测相对性能变化(准确率达 88%)方面表现优异——证明了领域专用大语言模型在高性能计算工作负载中的价值。

ABSTRACT

Parallel programs in high performance computing (HPC) continue to grow in complexity and scale in the exascale era. The diversity in hardware and parallel programming models make developing, optimizing, and maintaining parallel software even more burdensome for developers. One way to alleviate some of these burdens is with automated development and analysis tools. Such tools can perform complex and/or remedial tasks for developers that increase their productivity and decrease the chance for error. Until recently, such tools for code development and performance analysis have been limited in the complexity of tasks they can perform, especially for parallel programs. However, with recent advancements in language modeling, and the availability of large amounts of open-source code related data, these tools have started to utilize predictive language models to automate more complex tasks. In this paper, we show how large language models (LLMs) can be applied to tasks specific to high performance and scientific codes. We introduce a new dataset of HPC and scientific codes and use it to fine-tune several pre-trained models. We compare several pre-trained LLMs on HPC-related tasks and introduce a new model, HPC-Coder, fine-tuned on parallel codes. In our experiments, we show that this model can auto-complete HPC functions where generic models cannot, decorate for loops with OpenMP pragmas, and model performance changes in scientific application repositories as well as programming competition solutions.

研究动机与目标

  • 通过开发自动化工具协助开发者编写、优化和维护并行程序,应对 HPC 和科学计算代码日益增长的复杂性。
  • 克服 HPC 代码性能建模中的数据稀缺挑战,因为受硬件、输入和环境依赖影响,大规模、准确的性能测量收集极为困难。
  • 通过在领域特定代码和性能数据上微调大语言模型,而非依赖通用模型,提升 HPC 应用的代码生成与性能预测能力。
  • 证明从代码优化的大语言模型迁移学习可实现有效性能建模,且仅需极少性能数据,从而减少对大规模数据收集的依赖。
  • 开发一个实用且开源的模型(HPC-Coder),支持真实 HPC 开发任务,如代码补全、并行化与性能分析。

提出的方法

  • 在精选的 HPC 和科学计算代码数据集上微调预训练的大语言模型,包括函数级代码片段及其关联的性能测量数据。
  • 结合代码与性能数据进行模型训练,以学习源代码结构与执行行为之间的关系。
  • 通过迁移学习,使用代码优化的大语言模型(如 PolyCoder)作为初始化,并在 HPC 特定任务(如代码生成与指令插入)上进行微调。
  • 采用少样本提示(few-shot prompting)与微调技术,使模型能够基于代码中的语法和语义线索,以高准确率预测 OpenMP 指令在循环中的插入位置。
  • 在大语言模型之上训练性能预测头,用于预测两个代码版本之间的相对性能变化,采用细粒度、整体性的代码表征方式。
  • 在 HPC 特定基准上评估模型,包括代码生成任务、指令标注与性能预测,使用真实科学计算代码库(如 PETSc、Hypre)进行测试。

实验结果

研究问题

  • RQ1在 HPC 特定代码与性能数据上微调的大语言模型,是否能在生成功能正确并行代码方面优于通用大语言模型?
  • RQ2大语言模型在 HPC 代码的 for 循环中,多大程度上能准确预测 OpenMP 指令的插入位置?
  • RQ3在仅使用少量性能数据的情况下,微调后的 LLM 是否能以高准确率预测两个 HPC 代码版本之间的相对性能变化?
  • RQ4从代码优化的大语言模型进行迁移学习,在有限标注性能数据下,对 HPC 性能建模任务的有效性如何?
  • RQ5该模型是否能在多样化的 HPC 应用代码库之间实现泛化,以支持跨项目性能分析与代码生成?

主要发现

  • HPC-Coder 在 HPC 特定代码生成任务中的通过率比其他模型高出 53%,证明其在生成正确且上下文恰当的并行代码方面具有卓越能力。
  • 该模型对循环中插入 OpenMP 指令的标注准确率达 97%,在这一 HPC 特定的并行化任务中显著优于通用大语言模型。
  • HPC-Coder 对代码版本间相对性能变化的预测准确率最高可达 88%,表明大语言模型可在无需大规模性能数据集的情况下学习与性能相关的代码语义。
  • 与最先进的一般模型相比,HPC-Coder 在 HPC 代码上的语言建模得分更优,证实其在捕捉领域特定语法与语义模式方面的有效性。
  • 当使用微调后的 LLM 时,仅需极少数据即可实现性能预测,因为模型通过迁移学习将代码结构与性能行为相关联。
  • 该模型在代码生成与性能建模两方面均取得成功,表明针对特定领域的微调对于开发高影响力的 HPC 软件工程工具至关重要。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。