[Paper Review] HPC-Coder: Modeling Parallel Programs using Large Language Models
This paper introduces HPC-Coder, a large language model fine-tuned on HPC-specific code and performance data, enabling superior performance in generating correct parallel code, accurately labeling OpenMP pragmas (97% accuracy), and predicting relative performance changes with up to 88% accuracy—demonstrating the value of domain-specific LLMs for high-performance computing workloads.
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.
Motivation & Objective
- Address the growing complexity of HPC and scientific code by developing automated tools to assist developers in writing, optimizing, and maintaining parallel programs.
- Overcome the data scarcity challenge in performance modeling of HPC code, where collecting large-scale, accurate performance measurements is difficult due to hardware, input, and environmental dependencies.
- Improve code generation and performance prediction for HPC applications by fine-tuning a large language model on domain-specific code and performance data, rather than relying on general-purpose models.
- Demonstrate that transfer learning from code-optimized LLMs enables effective performance modeling with minimal performance data, reducing the need for extensive data collection.
- Develop a practical, open-source model (HPC-Coder) that supports real-world HPC development tasks such as code completion, parallelization, and performance analysis.
Proposed method
- Fine-tune a pre-trained large language model on a curated dataset of HPC and scientific code, including function-level code snippets and associated performance measurements.
- Train the model using a combination of code and performance data to learn the relationship between source code structure and execution behavior.
- Apply transfer learning by initializing with a code-optimized LLM (e.g., PolyCoder) and fine-tuning it on HPC-specific tasks such as code generation and pragma insertion.
- Use few-shot prompting and fine-tuning to enable the model to predict OpenMP pragmas for loops with high accuracy, leveraging syntactic and semantic cues in the code.
- Train a performance prediction head on top of the LLM to predict relative performance changes between two code versions, using a fine-grained, holistic code representation.
- Evaluate the model on HPC-specific benchmarks, including code generation tasks, pragma labeling, and performance prediction, using real-world scientific codebases (e.g., PETSc, Hypre).
Experimental results
Research questions
- RQ1Can a large language model fine-tuned on HPC-specific code and performance data outperform general-purpose LLMs in generating functionally correct parallel code?
- RQ2To what extent can an LLM accurately predict where OpenMP pragmas should be inserted in for loops within HPC codes?
- RQ3Can a fine-tuned LLM predict relative performance changes between two versions of HPC code with high accuracy using only a small amount of performance data?
- RQ4How effective is transfer learning from a code-optimized LLM in enabling performance modeling tasks in HPC with limited labeled performance data?
- RQ5Can the model generalize across diverse HPC application repositories to support cross-project performance analysis and code generation?
Key findings
- HPC-Coder achieves a 53% higher pass rate than other models in HPC-specific code generation tasks, demonstrating superior capability in generating correct and contextually appropriate parallel code.
- The model labels for loops with OpenMP pragmas with 97% accuracy, significantly outperforming general-purpose LLMs in this HPC-specific parallelization task.
- HPC-Coder predicts relative performance changes between code versions with up to 88% accuracy, showing that LLMs can learn performance-relevant code semantics without requiring massive performance datasets.
- The model achieves better language modeling scores on HPC code than state-of-the-art general models, confirming its effectiveness in capturing domain-specific syntactic and semantic patterns.
- Performance prediction is feasible with minimal data when using a fine-tuned LLM, as the model correlates code structure with performance behavior through transfer learning.
- The model’s success in both code generation and performance modeling suggests that domain-specific fine-tuning is essential for high-impact HPC software engineering tools.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.