Mutual-Supervised Learning for Sequential-to-Parallel Code Translation

Changxin Ke, Rui Zhang, Shuo Wang, Li Ding, Guangli Li, Yuanbo Wen, Shuoming Zhang, Ruiyuan Xu, Jin Qin, Jiaming Guo, Chenxi Wang, Ling Li, Qi Guo, Yunji Chen

Introduction

The transition toward high-performance computing (HPC) has made GPU acceleration essential. However, translating sequential C code into parallel CUDA code remains a significant challenge due to the complexities of thread hierarchies and memory management. Existing automated translation methods are hindered by two primary issues: the scarcity of high-quality aligned datasets and the inadequacy of text-based metrics like BLEU, which fail to capture the functional correctness required for executable code.

Methodology: The QiMeng-MuPa Framework

To address these challenges, we propose QiMeng-MuPa, a mutual-supervised learning framework that iteratively refines a Translator and a Tester. The Translator is responsible for converting source code (C) into target code (CUDA), while the Tester generates unit tests to verify the source code's behavior.

The QiMeng-MuPa framework featuring the Co-Verify and Co-Evolve iterative loop.

The framework operates through a continuous loop consisting of two main phases:

  1. Co-Verify: The Translator generates CUDA kernels, and the Tester produces unit tests. Both are executed on a real engine. If the CUDA output matches the C output, the data is saved as a "Verified Triplet" (Source, Target, Tests).
  2. Co-Evolve: These triplets are used to fine-tune both models via Supervised Fine-Tuning (SFT). This creates a self-improving cycle where better testing leads to higher-quality training data for the translator, and a more capable translator provides more complex examples for the tester to verify.

Experimental Setup

The models were trained using a filtered version of the BabelTower dataset. Starting from over 600,000 functions, the authors applied rigorous compilation and execution filters to narrow the set down to 14,687 valid C functions and 28,756 CUDA kernels. Evaluation was performed on a high-quality benchmark of 233 C-CUDA pairs, with unit tests providing 99% line coverage to ensure rigorous functional verification.

Results and Discussion

QiMeng-MuPa demonstrates significant performance improvements over multiple iterations. By focusing on functional equivalence rather than text similarity, the framework overcomes the "BLEU trap," where code may look correct but fail to execute.

Performance metrics across five rounds of iterative training, showing steady improvement in functional correctness (Pass@k).

Key findings include:

  • Accuracy Improvements: Applying the framework to Qwen2.5-Coder (7B) resulted in a 28.91% increase in Pass@1 accuracy, reaching 85.15% by the fourth round.
  • Competitive Performance: A compact model trained via QiMeng-MuPa achieved results comparable to large-scale models such as GPT-4 and DeepSeek-R1.
  • State-of-the-Art Comparison: The framework outperformed CodeRosetta by 6.92 CodeBLEU points and showed vastly superior functional correctness.
  • Efficiency: Case studies on matrix operations showed that the generated CUDA code could achieve speedups of over 15,000x compared to sequential execution, demonstrating that the model learns effective parallelization strategies.

Conclusion

QiMeng-MuPa provides a robust pathway for automating sequential-to-parallel code translation without the need for massive human-labeled datasets. By leveraging execution-based verification, it ensures that translated code is not only syntactically similar but functionally correct. Future research will focus on integrating Reinforcement Learning to optimize the generated code for maximum hardware efficiency, moving beyond correctness to peak performance.

Summary updated

Abstract

The rise of GPU-based high-performance computing (HPC) has driven the widespread adoption of parallel programming models such as CUDA. Yet, the inherent complexity of parallel programming creates a demand for the automated sequential-to-parallel approaches. However, data scarcity poses a significant challenge for machine learning-based sequential-to-parallel code translation. Although recent back-translation methods show promise, they still fail to ensure functional equivalence in the translated code. In this paper, we propose a novel Mutual-Supervised Learning (MSL) framework for sequential-to-parallel code translation to address the functional equivalence issue. MSL consists of two models, a Translator and a Tester. Through an iterative loop consisting of Co-verify and Co-evolve steps, the Translator and the Tester mutually generate data for each other and improve collectively. The Tester generates unit tests to verify and filter functionally equivalent translated code, thereby evolving the Translator, while the Translator generates translated code as augmented input to evolve the Tester. Experimental results demonstrate that MuSL significantly enhances the performance of the base model: when applied to Qwen2.5-Coder, it not only improves Pass@1 by up to 28.91% and boosts Tester performance by 68.90%, but also outperforms the previous state-of-the-art method CodeRosetta by 1.56 and 6.92 in BLEU and CodeBLEU scores, while achieving performance comparable to DeepSeek-R1 and GPT-4.1. Our code is available at https://github.com/kcxain/musl.
BibTeX
@inproceedings{ke2025mutual,
  author = {Changxin Ke and Rui Zhang and Shuo Wang and Li Ding and Guangli Li and Yuanbo Wen and Shuoming Zhang and Ruiyuan Xu and Jin Qin and Jiaming Guo and Chenxi Wang and Ling Li and Qi Guo and Yunji Chen},
  title = {{Mutual-Supervised Learning for Sequential-to-Parallel Code Translation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=bjUDrU4wPv},
}
Figure