More with Less: Efficient Parallel Scientific Code Translation via an Agent-Skill Workflow
Organizations: Department of Computer Science & Engineering, South China University of Technology, Guangzhou, Guangdong 510006 · Department of Computer Science, Michigan Technological University, Houghton, Michigan 49931
Abstract
Translating parallel scientific codes between HPC programming frameworks is a critical but labor-intensive task. Existing LLM-based approaches rely on fixed sequential pipelines with undifferentiated repair strategies and correctness criteria that do not match scientific computing practice. We present an agent-skill framework that separates translation, compilation diagnosis, and execution validation into three autonomous agents coordinated by a verdict-driven orchestrator, routing each failure to a targeted repair skill rather than retrying blindly. An automated output check drives the self-correction loop, complemented by an offline LLM-based verification that exposes false positives escaping compiler and runtime checks. We evaluate the framework on 30 HeCBench kernels translated bidirectionally among CUDA, OpenMP, and SYCL with three open-source LLMs. Our framework attains the higher verified correctness rate in all 18 model and direction combinations over a state-of-the-art baseline while consuming up to 52.4% fewer tokens, remaining consistent across models and directions without architectural modification.
Figures & tables
| Agent | Skill | Trigger condition | Verdict | Routed to |
| CompilationAgent | ErrorClassifierSkill | Linker errors (undefined reference, multiple definition, ld failure) | PATCH | PatchSkill |
| Leftover source-framework keywords (e.g., host , device ) | PATCH | PatchSkill | ||
| Target-framework API or directive misuse (e.g., sycl:: , omp target , cudaMalloc ) | PATCH | PatchSkill | ||
| Genuine memory-allocation failures (out of memory, invalid device pointer) | MEMORY | MemoryRepair | ||
| Missing headers or source files | PATCH | PatchSkill | ||
| C++ syntax, type, or scope errors | PATCH | PatchSkill |
| Skill | Core Prompt Content |
| AnalyzerSkill (shared) | System: You are a code analysis assistant. Describe what a program does in plain, framework-independent terms. User: Analyze the following {source_language} code. Focus only on the real execution logic and numerical behavior. Include: what problem the program solves, inputs and expected outputs, computation stages, correctness criteria, and numerical concerns. Do NOT focus on {target_language} API names, {target_language and runtime constructs} or synchronization details. Keep the response under 250 words. |
| MemoryPlanningSkill | System: You are an expert in {target_language} parallelism. User: Given the following {source_language} code, produce a memory plan for {target_language} execution. List each buffer with: variable name, size, lifetime, and sharing behavior. Identify where reduction , atomic , critical , or barrier clauses are needed. Respond as a bullet list only. |
| TranslatorSkill | [BEGIN CODE SUMMARY] {code_summary} [END CODE SUMMARY] [BEGIN MEMORY PLAN] {memory_plan} [END MEMORY PLAN] Generate new code to refactor the following parallelized {source_language} program to instead use C++ code written with {target_language} directives. |
| PatchSkill | The following code was compiled with {compiler} {flags} and produced the following compile error: {compile_log} Re-factor the above code with a fix to eliminate the stated error. |
| SemanticRepair | System: You are a coding assistant that fixes numerical logic errors in {target_language} code. User: The translated code was executed and produced incorrect or unexpected output. Translated stdout: {run_stdout} Translated stderr: {run_stderr} Identify and fix the numerical logic error. |
| SyncRepair | System: You are an expert in {target_language} parallel programming synchronization. User: The following {target_language} code crashes or produces non-deterministic results (exit code {run_exit_code}, stderr: {run_stderr}). Add missing barriers, atomic operations, or reduction clauses as needed. |
| correctness (%) on top / kilo-tokens (translation/repair) below | ||||||||
| System | Model | CUDA OpenMP | OpenMP CUDA | CUDA SYCL | SYCL CUDA | OpenMP SYCL | SYCL OpenMP | Avg. |
| LASSI | DeepSeek V4 Flash | 86.7% 1327k (59/41) | 87.5% 1058k (44/56) | 46.7% 1690k (11/89) | 83.3% 1174k (48/52) | 33.3% 1514k (11/89) | 53.3% 1945k (42/58) | 65.5% 1451k |
| Ours | DeepSeek V4 Flash | 93.3% 718k (72/28) | 95.8% 835k (53/47) | 70.0% 1600k (33/67) | 93.3% 1191k (45/55) | 79.2% 1325k (35/65) | 100.0% 753k (73/27) | 88.7% 1071k |
| LASSI | GLM 5.2 | 46.7% 1364k (50/50) | 60.0% 741k (55/45) | 3.3% 1429k (10/90) | 53.3% 2260k (22/78) | 3.3% 1258k (10/90) | 26.7% 1618k (44/56) | 34.5% 1445k |
| Ours | GLM 5.2 | 93.3% 648k (55/45) | 79.2% 609k (52/48) | 60.0% 967k (40/60) | 90.0% 828k (48/52) | 58.3% 1042k (32/68) | 86.7% 2014k (20/80) | 78.6% 1018k |
| LASSI | Kimi K2.7 Code | 56.7% 3204k (32/68) | 73.3% 1088k (58/42) | 50.0% 2058k (14/86) | 93.3% 1189k (60/40) | 26.7% 2731k (10/90) | 6.7% 3775k (24/76) | 54.8% 2341k |
| System | Model | In-loop | Compl. verif. | FP | ||
| Ours | DeepSeek V4 Flash | 168 | 88.7 | 71.4 | 17.3 | 29 |
| Ours | GLM 5.2 | 168 | 78.6 | 68.5 | 10.1 | 17 |
| Ours | Kimi K2.7 Code | 168 | 94.6 | 86.3 | 8.3 | 14 |
| LASSI | DeepSeek V4 Flash | 168 | 65.5 | 46.4 | 19.1 | 32 |
| LASSI | GLM 5.2 | 168 | 34.5 | 28.0 | 6.5 | 11 |
| LASSI | Kimi K2.7 Code | 159 | 57.9 | 49.1 | 8.8 | 14 |
| Escape mode | Count (%) | Representative case | Key evidence |
| Placeholder / stub implementation | 31 (26.5) | LASSI, CUDA OpenMP, contract | All-zero checksums; the kernel only zero-fills the output |
| Numerical error | 28 (23.9) | LASSI, OpenMP CUDA, distort | Per-channel maximum error of 255 |
| Verification skipped | 25 (21.4) | LASSI, CUDA OpenMP, pointwise | PASS printed with reference validation removed |
| Parameter mismatch | 12 (10.3) | Ours, SYCL CUDA, distort | Hard-coded while the test argument is |
| Index / buffer / memory error | 9 (7.7) | LASSI, OpenMP CUDA, car | RMSE of 61,218; channel dimension ignored |
| RNG / seed issue | 4 (3.4) | Ours, SYCL OpenMP, kiss | One RNG seed per thread instead of one per element |
Code Translation
Code translation converts programs between languages, frameworks, and representations while aiming to preserve behavior and sometimes improve safety or performance.
See all 47 papers