QSpark: Towards Reliable Qiskit Code Generation

Kiana Kheiri, Aamna Aamir, Andriy Miranskyy, Chen Ding · 2025

Read QSpark: Towards Reliable Qiskit Code Generation by Kiana Kheiri, Aamna Aamir, Andriy Miranskyy, Chen Ding (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2507-12642.txt.

Introduction

Language models asked to write quantum computing code often produce circuits that fail, and Kiana Kheiri and co-authors fine-tuned a coder model to do better. They trained Qwen2.5-Coder-32B with two reinforcement learning methods on a richly annotated synthetic dataset of Qiskit programs. On the Qiskit HumanEval benchmark, the ORPO variant solved 56.29 percent of tasks in one try, beating general-purpose baselines, while GRPO reached 49 percent.

Both also scored respectably on the original HumanEval. GRPO handled basic and intermediate tasks well. Neither method solved any of the five advanced tasks, marking where AI help for quantum programming still runs out.

Catalog record

CREATORKiana Kheiri, Aamna Aamir, Andriy Miranskyy, Chen Ding
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE34 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2507-12642

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

QSpark: Towards Reliable Qiskit Code Generation Kiana Kheiri, Aamna Aamir, Andriy Miranskyy, Chen Ding Abstract Quantum circuits must be error-resilient, yet LLMs like Granite-20B-Code and StarCoder often output flawed Qiskit code. We fine-tuned a 32 B model with two RL methods, Group Relative Policy Optimization (GRPO) and Odds-Ratio Preference Optimization (ORPO), using a richly annotated synthetic dataset. On the Qiskit HumanEval benchmark, ORPO reaches 56.29% Pass@1 ( ≈ + 10 \approx+10 pp over Granite-8B-QK) and GRPO hits 49%, both beating all general-purpose baselines; on the original HumanEval they score 65.90% and 63.00%. GRPO excels on basic tasks (42/54), ORPO on intermediate ones (41/68), and neither solves the five advanced tasks, highlighting clear gains yet room for progress in AI-assisted quantum programming. [[email protected], ] *1 [ [email protected] ] [[email protected], ] [[email protected] ] keywords Quantum computing, Qiskit, Large Language Models, Code generation, Reinforcement learning, Quantum software engineering † † copyrightyear: 2025 † † copyright: Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). † † address: Toronto Metropolitan University, Toronto, Canada 1 Introduction Imagine writing a quantum teleportation protocol with just a natural language prompt. Although this might sound futuristic, recent advancements in AI bring us closer to such a reality. Quantum computing has the potential to solve certain classes of problems faster than classical computing, but programming quantum computers remains a specialized and challenging task Ajagekar et al. 2019 . Developing correct and optimized quantum programs requires expertise in quantum mechanics, quantum algorithms, and software engineering, a combination that is not widespread among developers. Even with high-level frameworks like IBM’s Qiskit Javadi-Abhari et al. 2024 , which provide libraries to design and run quantum circuits, writing quantum code is often an error-prone process that requires careful handling of quantum-specific concepts (for example, superposition, entanglement, non-cloning) and resource constraints. As quantum hardware scales up, the complexity of the software needed to harness it also increases, calling for more sophisticated development methodologies Vishwakarma et al. 2024 . In recent years, researchers have begun to explore how advances in artificial intelligence, particularly large language models (LLMs), can help make quantum programming more accessible and efficient (see Dupuis et al. 2024 and ( Murillo et al. 2025 , Sec. 4.7) for review). Early work in this area, such as Cruz-Benito et al. Cruz-Benito et al. 2018 , demonstrated that deep learning-based approaches could effectively provide customized assistance during the quantum coding process, paving the way for more advanced AI-driven tools. Large language model (LLM) based coding assistants have already transformed classical software development by providing code autocompletion, generation, and error detection. However, applying these models to quantum programming presents unique challenges. Quantum programming uses a distinct set of languages, libraries, and idioms (such as constructing quantum circuits gate by gate) that differ significantly from classical programming Murillo et al. 2025 . The code examples available for training are scarce compared to the vast repositories of classical code since quantum computing is an emerging field with relatively few expert developers and open-source projects. Moreover, quantum code must adhere to the rules of quantum mechanics and often requires domain knowledge (for example, understanding the effects of certain gate sequences or the need for qubit reuse and error mitigation). As a result, even advanced coding AIs may generate incorrect or suboptimal quantum code without domain-specific training. In fact, the need for specialized tooling in quantum software has been highlighted by the Quantum Software Engineering community Murillo et al. 2025 ; Bausch and Leditzky 2018 , which argues that simply porting classical development techniques to the quantum realm is insufficient due to fundamental differences in how quantum programs operate. To bridge this gap, our work proposes a Qiskit-based quantum computing coding assistant, an AI-driven tool designed to help developers write and refine quantum programs using the Qiskit SDK. Our assistant focuses specifically on Qiskit, IBM’s widely used quantum SDK, and supports tasks such as circuit construction, optimization, and code debugging. We envision a system that can understand high-level intentions (e.g., “prepare a Bell state” or “optimize this circuit section”) and provide context-sensitive suggestions or code snippets, much like modern code assistants do for classical languages. Using a large language model trained on quantum programming data, the assistant can generate Qiskit code, recommend quantum algorithmic patterns, and catch common mistakes, all within the developer’s workflow. The goal is to lower the barrier to entry for quantum programming and to accelerate the development process for experts and beginners alike. In this paper, we detail the design of such a Qiskit-based coding assistant, discuss the training and integration of the underlying LLM model, and evaluate its effectiveness in aiding quantum programmers. We begin by reviewing related work in two key areas: quantum programming environments and AI-assisted coding tools for quantum software. This overview will contextualize our contributions and highlight how our approach builds on recent advances. By merging the power of Qiskit and LLMs, we aim to push the boundaries of developer tools in quantum computing, making quantum programming not only more efficient but also more accessible to a broader audience. 2 Literature Review 2.1 Quantum Programming Environments and Tools Several efforts have been made to create better software environments for developing quantum applications. IBM’s Qiskit is one of the leading frameworks, providing an open source SDK with tools for circuit design, simulation, and execution on quantum hardware Dupuis et al. 2024 . In addition to Qiskit, practical resources such as Silva (2018) provide essential hands-on strategies for programming quantum rigs using Python, the quantum assembly language, and cloud-based platforms, including IBM QExperience Silva 2018 . This resource highlights the inherent challenges in quantum programming and emphasizes the need for developer-friendly methodologies and tools. Researchers have also acknowledged that improving quantum software development requires higher-level abstractions and more systematic design approaches. For example, Ammermann et al. Ammermann et al. 2024 introduce a view-based development approach that unifies diverse stakeholder perspectives within a quantum IDE. This model suggests that future quantum IDEs may provide synchronized views, such as algorithm logic, circuit layout, and hardware mapping, to better manage the complexity of quantum programs. Another notable platform is QuantumPath, developed by Hevia et al. Hevia et al. 2022 , which takes an engineering-oriented approach to quantum software creation. QuantumPath provides an application lifecycle management platform for quantum software, supporting developers from algorithm conception through testing, deployment, and maintenance. Providing an ecosystem of modules and enforcing best practices, it simplifies the development of hybrid quantum-classical solutions for real-world use. These efforts highlight a common theme: quantum software development requires more than just programming libraries. It also needs robust tools and processes, similar to classical software engineering, but tailored for the quantum domain. Our proposed Qiskit-based assistant complements these initiatives by focusing on the coding phase of quantum development. It can be viewed as a plugin designed to enhance quantum programming environments such as Qiskit, providing intelligent support during the development process. 2.2 AI-Assisted Quantum Code Generation With the growing use of AI in coding-related tasks, it is natural that researchers have started applying LLMs to quantum programming. Dupuis et al. Dupuis et al. 2024 introduced the Qiskit Code Assistant, an AI model specifically trained to

Read the complete text