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 framework operates through a continuous loop consisting of two main phases:
- 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).
- 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.
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