arXiv:2610.34841
Large Language Models for Quantum Code Translation: An Exploratory Study
Xiyuan Li, Yuechen Li, Jianjun Zhao
Abstract
Quantum software development is challenged by quantum-mechanical semantics and fragmented software development kits (SDKs), which complicate cross-SDK code translation and execution. In this paper, we propose an LLM-based approach for translating executable programs between high-level quantum SDKs. We develop a quantum-aware translation workflow whose prompt design and validation reflect quantum semantics and accommodate the version evolution of quantum ecosystems. We conduct a preliminary evaluation of 4 LLM configurations on 43 tasks, translating Qiskit programs to PennyLane and Q#. LLMs achieve a zero-shot Pass@1 of up to 72.33%, while one-shot prompting further improves the translation effectiveness. These results suggest potential for quantum code translation by LLMs.
AI Summary
Can LLMs translate executable quantum programs between high-level SDKs while preserving required behavior? This exploratory study evaluates Qiskit-to-PennyLane and Qiskit-to-Q# translation using four LLM configurations on 43 tasks adapted from QuanBench. The workflow supplies source code, task descriptions, assertions, SDK-version constraints, runtime guidance, and quantum-semantic instructions, including qubit ordering and control–target conventions. Generated programs are executed in versioned native environments and checked against benchmark assertions, with ten translation attempts per model–task–target combination. Zero-shot task-averaged Pass@1 ranges from 16.28% to 72.33%. Flash performs best on PennyLane at 72.33%, while GPT performs best on Q# at 71.63%; their respective Pass@3 scores are 86.53% and 82.11%. One verified source–target example improves both metrics for Pro and GLM on both targets. Across 3,440 zero-shot attempts, 1,787 fail: missing generated source artifacts account for 39.2% of failures, compilation errors for 34.9%, and assertion violations for 9.0%. Failure categories are assigned automatically from generation status, execution status, and tracebacks. The stated scope is preliminary: four configurations, two translation directions, and a small benchmark originally designed for code generation rather than translation. One original task is excluded because its reference implementation could not reliably pass its assertions. Passing the available tests does not establish general semantic or structural preservation; dedicated checks for relative phase, bit ordering, and probabilistic outputs, broader benchmarks, and execution-guided repair are left for future work.
LLMs achieve a zero-shot Pass@1 of up to 72.33%, while one-shot prompting further improves the translation effectiveness.
Error found: The supplied paper omits the numerical one-shot results needed to substantiate its claim that both tested models improve on both target SDKs, although its failure counts establish an aggregate improvement.
Written by gpt-6.1-sol from the paper's full text. Automated: it can be wrong.