Scope is all you need: Transforming LLMs for HPC Code

Tal Kadosh, Niranjan Hasabnis, Vy A. Vo, Nadav Schneider, Neva Krien, Abdul Wasay, Nesreen K. Ahmed, Ted Willke, Guy Tamir, Yuval Pinter, Timothy G. Mattson, Gal OrenarXiv 2023 · DOI

Abstract

High-Performance Computing (HPC) requires specialized code understanding that general-purpose Large Language Models (LLMs) often lack due to their reliance on human-centric semantics. This paper introduces TOKOMPILER, a machine-informed tokenizer that prioritizes structural logic over variable naming conventions. By integrating TOKOMPILER with the COMPCODER model, researchers demonstrate that smaller, domain-specific models can outperform significantly larger general-purpose models in HPC tasks while achieving greater efficiency in training and inference.

Introduction

The current trend in AI development follows a "bigger is better" paradigm, where massive LLMs trained on natural language are fine-tuned on code. However, for High-Performance Computing (HPC)—where the primary goals are code optimization, parallelization (OpenMP/MPI), and compilation—this approach is often inefficient. General-purpose models like PolyCoder are "human-centered," relying heavily on the semantic meaning of variable names. In the performance-critical world of HPC, these human-centric biases can be a distraction. Furthermore, the computational cost of training these massive models creates a significant barrier for researchers without massive industrial resources.

Methodology: TOKOMPILER and COMPCODER

The researchers developed TOKOMPILER, a novel tokenization pipeline designed to make code "machine-informed" rather than "human-centered." The process involves several key innovations:

  1. Anonymization: Variable names, numbers, and strings are replaced with generic placeholders (e.g., var_1, num_842). This prevents the model from relying on common naming conventions and forces it to learn the underlying logic.
  2. AST-Awareness: The pipeline uses an Abstract Syntax Tree (AST) to capture the structural hierarchy of the code, which is then converted back into a semantic-less representation.
  3. Token Splitting and Randomization: To prevent the model from associating specific placeholders with fixed types, tokens are split (e.g., var_1 becomes [var, 1]) and recurring tokens are assigned random numbers during training.
Figure 1: Comparison of tokenization strategies between general-purpose BPE and the structural TOKOMPILER approach.

These techniques were integrated into the PolyCoder architecture to create COMPCODER, a model focused purely on the structural logic of Fortran, C, and C++ code. The study utilized HPCorpus, a massive dataset of 155 million functions mined from 300,000 GitHub repositories, specifically filtered to remove natural language noise like comments and READMEs.

Key Insights and Results

The core finding is that for compilation-centric tasks, human-readable names are essentially noise. By forcing the model to focus on the AST structure, it gains a deeper understanding of functional logic. This leads to an "efficiency paradox": a smaller model with better tokenization can outperform a much larger general-purpose model.

  • Superior Accuracy: COMPCODER achieved a normalized perplexity score of approximately 1.6, significantly outperforming the standard PolyCoder, which scored ~2.46 on Fortran tasks.
  • Enhanced Efficiency: COMPCODER reduced training time by nearly 50% in specific scenarios (e.g., 246 minutes versus 435 minutes for Fortran) due to processing fewer, more structurally dense tokens.
  • Scaling Advantage: A COMPCODER model with only 638M parameters outperformed a 2.8B parameter general-purpose model on C/C++ tasks, proving that domain specificity beats raw scale.

Limitations and Future Work

While COMPCODER excels at structural logic, it is less effective for tasks requiring natural language understanding, such as code summarization or writing documentation. Because it strips away human semantics, it cannot explain what a piece of code does in plain English.

Future research will explore integrating even more abstract representations, such as Data-Flow Graphs (DFG) and Intermediate Representations (IR) used by compilers. The ultimate goal is to fine-tune these models for specific downstream HPC tasks, such as the automatic insertion of OpenMP pragmas for parallelization or the optimization of MPI distributions.

Summary updated

BibTeX
@misc{kadosh2023scope,
  author = {Tal Kadosh and Niranjan Hasabnis and Vy A. Vo and Nadav Schneider and Neva Krien and Abdul Wasay and Nesreen K. Ahmed and Ted Willke and Guy Tamir and Yuval Pinter and Timothy G. Mattson and Gal Oren},
  title = {{Scope is all you need: Transforming LLMs for HPC Code}},
  year = {2023},
  eprint = {2308.09440},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.09440},
}
Figure