NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

HPC-Coder: Modeling Parallel Programs using Large Language Models

Daniel Nichols, Aniruddha Marathe, Harshitha Menon, Todd Gamblin, Abhinav Bhatele

Abstract

Large Language Models (LLMs) have transformed general software development but often struggle with the specialized requirements of High-Performance Computing (HPC). This paper introduces HPC-Coder, a specialized LLM designed for parallel programming and scientific computing. By fine-tuning open-source models on a curated dataset of HPC code, the researchers created a tool that significantly outperforms general-purpose models in generating MPI/OpenMP code and predicting code performance. HPC-Coder achieves up to 97% accuracy in OpenMP pragma generation and demonstrates substantial speedups over sequential baselines.

Introduction

While tools like GPT-4 and GitHub Copilot have revolutionized general software development, they often fail in the domain of High-Performance Computing (HPC). HPC development relies on specialized parallel programming models such as the Message Passing Interface (MPI) and OpenMP, which are underrepresented in the general-purpose repositories used to train standard LLMs. Furthermore, performance in HPC is a primary objective rather than a secondary concern. Standard LLMs lack an inherent understanding of execution time or hardware efficiency, which are influenced by complex factors like memory layout and network congestion. HPC-Coder bridges this gap by modeling both the syntax of parallel code and the structural patterns that drive performance.

Methodology

The researchers developed HPC-Coder using a multi-step pipeline focused on domain-specific adaptation. The process began with the selection of three open-source base models: GPT-2 (1.5B parameters), GPT-Neo (2.7B), and PolyCoder (2.7B). These models underwent fine-tuning on a massive, newly curated dataset of HPC-related C/C++ code.

The HPC-Coder pipeline: from data collection to downstream task evaluation.

To adapt the models for specific tasks, the team employed specialized data formatting. For OpenMP prediction, the model was trained to see a loop body first and then predict the appropriate #pragma omp statement. Performance modeling was treated as a classification problem; the model was shown two versions of the same code (e.g., before and after a Git commit) and trained to predict which version would be faster. Training was optimized using the DeepSpeed library and ZeRO memory optimizations on NVIDIA A100 GPUs.

Datasets

The study utilized several key datasets to ensure domain relevance:

  • HPC Source Code Dataset: A 1.62 GB collection of high-quality C/C++ files scraped from GitHub, filtered for topics like MPI, CUDA, and OpenMP.
  • HPC Code Completion Benchmark: A new evaluation set of 25 custom HPC problems, including FFT and Cholesky factorizations, implemented in sequential, OpenMP, and MPI versions.
  • Performance Datasets: This included 830 commits from scientific "mini-apps" (Kripke and Laghos) with execution times, and ~1.7 million pairs of competitive programming solutions labeled by relative speed.

Key Insights and Results

A critical finding was the "Catastrophic Forgetting" trade-off. While model perplexity (predictive accuracy for the next word) continued to improve with more training, utility on downstream coding tasks eventually declined. The researchers identified a "sweet spot" at 45,000 training samples to balance general coding logic with HPC expertise.

HPC-specific code generation performance across different models and k-values.

HPC-Coder demonstrated superior performance across several metrics:

  • Code Generation: The model passed HPC-specific coding tests at a rate up to 53% higher than generic models. As seen in the evaluation of HPC code generation scores, the fine-tuned PolyCoder+HPC model significantly outperformed the base PolyCoder model across all $k$ values.
  • OpenMP Accuracy: The model achieved 97% accuracy in generating functionally correct OpenMP pragmas, showing a deep understanding of loop dependencies and necessary clauses like reduction or private.
  • Performance Prediction: By repurposing structural understanding gained during training, the model predicted relative performance changes with 88% accuracy on scientific proxy apps and 92% accuracy on competitive programming data.

Conclusion and Future Work

HPC-Coder proves that domain-specific fine-tuning can effectively bridge the gap between general LLMs and the rigorous requirements of scientific computing. While the model excels at relative performance prediction, future work will address the challenge of predicting absolute execution time, which requires larger hardware-labeled datasets. Additionally, the researchers aim to move beyond generating correct parallel code toward generating the most performant versions and integrating these capabilities into IDE plugins for scientific developers.

Summary updated

BibTeX
@inproceedings{nichols2024hpc,
  author = {Daniel Nichols and Aniruddha Marathe and Harshitha Menon and Todd Gamblin and Abhinav Bhatele},
  title = {{HPC-Coder: Modeling Parallel Programs using Large Language Models}},
  booktitle = {ISC},
  year = {2024},
  doi = {10.23919/isc.2024.10528929},
}
Figure