arXiv:2610.34841cs.SEOct 2026

Manuscript Offprint

arXiv:2610.34841

Large Language Models for Quantum Code Translation: An Exploratory Study

Xiyuan Li, Yuechen Li, Jianjun Zhao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Xiyuan Li 1^{1}, Yuechen Li 2^{2}, and Jianjun Zhao 1∗^{1*}

1^{1} Kyushu University

li.xiyuan.868@s.kyushu-u.ac.jp, zhao@ait.kyushu-u.ac.jp

2^{2} Beihang University

liyuechen@buaa.edu.cn

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.

Keywords: Quantum software engineering · Code translation · Large language models

1 Introduction

Quantum computing has attracted growing interest, leading to a diverse ecosystem of software development kits (SDKs) and programming languages, including Qiskit [10], PennyLane [25], and Q# [16]. However, quantum software development remains challenging because quantum-mechanical abstractions, such as superposition, entanglement, and probabilistic measurement, are unfamiliar to many software engineers. Meanwhile, heterogeneous SDK interfaces and backend-specific execution models require developers to reconcile different application programming interfaces (APIs) and runtime constraints, complicating quantum software development and maintenance.

Code translation [2, 12] is a natural software-engineering response to this interoperability problem. For example, a controlled-X gate can be expressed in Qiskit as qc.cx(a, b) and in Q# as Controlled X([q[a]], q[b]);, where a and b index the control and target qubits, respectively. A practical translator should perform this API mapping while preserving the source program's intended behavior or code structure. Large language models (LLMs) are promising

∗^{*} Corresponding author: Jianjun Zhao.

X. Li et al.

candidates for this task because they can interpret code and natural-language specifications, generate code in different programming languages, and have supported activities in quantum software engineering, such as code generation [9], comment generation [27], and static analysis [19]. Such intuition and observations motivate us to investigate whether LLMs can translate quantum programs across heterogeneous SDKs while preserving their required behavior and structure.

To the best of our knowledge, this paper presents the first proposal of LLM-based quantum code translation between high-level SDKs or programming languages to deal with developer-facing quantum programming. We propose a quantum-aware LLM translation workflow from input tasks to translated programs along with the aggregate analysis. In particular, we contribute a prompt-construction method tailored to quantum code translation: it captures quantum-mechanical semantics, such as qubit ordering and the roles of control and target qubits, together with SDK-specific syntax, version constraints, runtime requirements, and task specifications, thereby accommodating the rapid evolution of quantum programming frameworks. We preliminarily evaluate four LLM configurations on 43 benchmark tasks, translating Qiskit programs to PennyLane and Q# and comparing zero-shot with one-shot prompting for two models. The best zero-shot Pass@1 reaches 72.33% on PennyLane and 71.63% on Q#, while one-shot prompting can substantially improve Pass@1. Furthermore, we find that missing source artifacts and SDK compilation errors dominate zero-shot failures, accounting for 39.2% and 34.9%, respectively. These findings suggest the potential of LLM-based quantum code translation while identifying key barriers for future research.

References (22)