Introduction
Developing software for quantum computers presents unique challenges for Large Language Models (LLMs). Rapidly evolving frameworks like Qiskit frequently deprecate APIs, and the underlying physics requires code to be not just syntactically correct, but physically executable within hardware constraints. Traditional alignment methods like Reinforcement Learning from Human Feedback (RLHF) are often too slow or expensive to capture these nuances. This paper presents a novel approach using "quantum verifiable rewards"—integrating actual quantum hardware and simulators into the training loop to ground LLM outputs in physical reality.
Model Specialization Pipeline
The researchers developed a specialized 14B-parameter model, starting from the Qwen2.5-Coder-14B base. The specialization process follows a multi-stage pipeline designed to infuse domain-specific knowledge while maintaining general reasoning capabilities.
The pipeline begins with Extended Pretraining (EPT) on an 82-million-token dataset comprising Qiskit documentation, tutorials, and GitHub repositories. To preserve conversational fluency, the resulting "Qiskit Base" model is merged with a general instruct model using Spherical Linear Interpolation (SLERP). This is followed by knowledge distillation using high-quality synthetic data to teach the model the "Chain of Thought" reasoning behind quantum circuit construction.
Quantum Verifiable Rewards
The core innovation of this work is the use of execution-based feedback as a reward signal during post-training. While classical coding assistants often use CPU-based unit tests, this method employs a "hardware-in-the-loop" verification system.
The alignment phase utilizes two primary algorithms:
- Direct Preference Optimization (DPO): An offline approach where the model learns to distinguish between code samples that pass or fail predefined unit tests.
- Group Relative Policy Optimization (GRPO): An online reinforcement learning method. The model generates multiple candidate solutions for a given prompt, which are then executed within a Qiskit Sandbox. This sandbox interfaces with both simulators and real Quantum Processing Units (QPUs). Rewards are assigned based on the success rate of these executions, forcing the model to converge on code that is demonstrably functional on quantum hardware.
Experimental Results
The effectiveness of this approach was evaluated using the Qiskit-HumanEval (QHE) benchmark and its more challenging variant, QHE-hard, which requires the model to identify and import the correct modules without assistance.
The hybrid model, Qwen2.5-Coder-14B-Qiskit-Instruct-DPO-GRPO, demonstrated remarkable parameter efficiency. On the QHE-hard benchmark, it achieved a score of 28.48%, outperforming the significantly larger Qwen3-Coder-480B (25.82%). This suggests that hardware-in-the-loop training allows smaller models to gain a superior "ground truth" understanding of specialized APIs compared to massive models trained on static datasets.
Conclusion
By treating the quantum runtime as the ultimate judge of code quality, researchers have created a highly efficient coding assistant for the quantum era. The use of quantum verifiable rewards through GRPO not only improves accuracy but also helps models learn complex dependencies, such as library imports and hardware-specific optimizations. Future work will focus on scaling these techniques to more complex, multi-step quantum algorithm design and iterative agentic debugging.
Summary updated