Large language models improve translation between quantum programming languages

Large Language Models for Quantum Code Translation: An Exploratory Study

Software Engineering

Summary

Quantum programming is hard partly because different software tools use different languages. The authors study how large language models (LLMs), like AI that understands code, can translate quantum programs from one language to another. They test this on three quantum coding systems and find that the AI can translate programs correctly most of the time without prior examples, and even better with a single example. This suggests LLMs might help programmers work across different quantum software platforms more easily.

What this means in practice

Authors

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.