UniPar: A Unified LLM-Based Framework for Parallel and Accelerated Code Translation in HPC

Tomer Bitan, Tal Kadosh, Erel Kaplan, Shira Meiri, Le Chen, Peter Morales, Niranjan Hasabnis, Gal Oren

Abstract

High-Performance Computing (HPC) increasingly relies on diverse hardware architectures, requiring developers to port code across various parallel programming paradigms such as CUDA and OpenMP. Manual translation is error-prone and resource-intensive, while traditional automated tools lack flexibility. This paper presents UniPar, a framework designed to optimize Large Language Models (LLMs) for parallel code translation. By integrating supervised fine-tuning with an agentic compiler-feedback pipeline, UniPar achieves a twofold increase in functional correctness over baseline models.

Introduction

The rapid evolution of HPC hardware has created a "language gap," where legacy codebases must be frequently adapted for new accelerators. Translating between serial code, multi-core OpenMP, and GPU-accelerated CUDA involves complex considerations of memory management and thread synchronization. While LLMs have shown promise in general software engineering, their efficacy in the specialized domain of HPC requires a systematic approach to prompting, fine-tuning, and validation.

The UniPar Framework

UniPar addresses the limitations of "single-shot" LLM inference through a multi-agent architecture designed to mimic the human development cycle of coding, compiling, and testing.

The UniPar multi-agent architecture, featuring Questioner, Compilation, and Execution agents for iterative code refinement.

The pipeline consists of three primary components:

  1. Questioner Agent: Generates the initial translation based on the source kernel and target paradigm.
  2. Compilation Agent: Interacts with system compilers to identify syntax errors. If compilation fails, it feeds error logs back to the model for iterative repair.
  3. Execution Agent: Validates the compiled binary against reference test cases, ensuring functional equivalence between the source and translated code.

The PARATRANS Dataset

To facilitate rigorous evaluation, the researchers introduced PARATRANS, a standardized dataset derived from the HECBENCH suite. It contains 898 training pairs and 76 test pairs of aligned kernels across Serial, OpenMP, and CUDA paradigms. Each entry is pre-verified for compilation and correctness, providing a high-quality ground truth for fine-tuning and benchmarking.

Experimental Insights and the "Few-Shot Trap"

A significant finding of this research is the counter-intuitive impact of few-shot prompting in HPC contexts. While providing examples typically improves LLM performance in general tasks, the authors observed "context dilution" in parallel translation. The inclusion of multiple examples often distracted models from the precise syntactic requirements of the target API, leading to lower compilation rates.

Compilation rates by translation task, number of shots, and application domain. The data illustrates the 'few-shot trap' where additional examples often degrade performance.

Furthermore, hyperparameter optimization revealed that lower temperatures (e.g., 0.2) are critical for technical translation, as they reduce stochasticity and favor the most probable (and often syntactically correct) tokens.

Results and Discussion

The UniPar framework significantly outperforms off-the-shelf models. Baseline GPT-4o-mini achieved a 46% compilation rate and only 15% functional correctness. In contrast, the full UniPar pipeline—leveraging fine-tuned LLaMA-3.3-70B-Instruct and agentic feedback—pushed the compilation rate to 69% and functional correctness to 33%.

Fine-tuning proved essential not just for syntax, but for the underlying logic of translation. A fine-tuned LLaMA model achieved validation rates of 29.4% for CUDA and 38.2% for OpenMP, demonstrating a superior grasp of cross-paradigm mappings compared to its base version.

Conclusion

UniPar demonstrates that while LLMs are not native HPC experts, a unified framework of fine-tuning and iterative feedback can bridge the gap. Future work will focus on expanding the language scope to include SYCL and OpenACC, as well as incorporating performance-aware metrics to ensure that translated code is not only correct but also optimized for the target hardware.

Summary updated

BibTeX
@inproceedings{bitan2025unipar,
  author = {Tomer Bitan and Tal Kadosh and Erel Kaplan and Shira Meiri and Le Chen and Peter Morales and Niranjan Hasabnis and Gal Oren},
  title = {{UniPar: A Unified LLM-Based Framework for Parallel and Accelerated Code Translation in HPC}},
  booktitle = {HPEC},
  year = {2025},
  url = {https://openreview.net/forum?id=6wW5RY98Sz},
}

Loading related content...

Figure