1 of 1

HPC Code Migration Using Large Language Models

Scientific Achievement

Large Language Models (LLMs) have achieved remarkable success in a wide array of domains, including natural language processing, code analysis, and code generation. This research explores the potential of LLMs to tackle the challenge of code migration in high-performance computing (HPC). We have developed a novel LLM-based approach for migrating OpenMP Fortran code to an equivalent C++ version, achieving promising results.

Significance and Impact

Traditional approaches typically require the manual development and maintenance of tools for migrating legacy HPC codes. In contrast, LLM-based approaches provide a more automated and unified solution. Reusable pipelines can be employed to generate datasets and train LLMs to address code migration challenges, thereby significantly reducing the need for manual tool development and accelerating scientific discoveries and innovations.

Technical Approach

  • Exploring both manual and LLM-based dataset generation approaches
  • Leveraging commercial and open-weights large language models
  • Combining prompt engineering with fine-tuning for improved model outputs

PI/Facility Lead: Chunhua Liao/Lawrence Livermore National Laboratory

Collaborating Institutions: University of Connecticut and Iowa State University

ASCR Program: [SciDAC/RAPIDS-2] ASCR PM: Kalyan Perumalla.

Publication: Lei, et al., "Creating a Dataset for High-Performance Computing Code Translation using LLMs: A Bridge Between OpenMP Fortran and C++," 2023 IEEE High Performance Extreme Computing Conference, doi: 10.1109/HPEC58863.2023.10363534. Datasets: HPC_Fortran_CPP

Fig. 1 LLM-Based Automated Dataset Generation using Holistic Feedback

We use open-source code snippets as seeds and prompt GPT-4 to generate training datasets using feedback from large language models (LLMs), compilers, and unit testing.

Fig. 2 Accuracies of Different Models Translating OpenMP Fortran to C++

Using the dataset from Fig.1, we fine-tuned two open-weight models, WizardCoder and DeepSeek-Coder, improving their translation accuracies by 20.1x and 1.55x respectively, nearly matching the top commercial model, GPT-4, which has a 0.262 CodeBLEU.

This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344. LLNL-PRES-862641