QuSema: Detecting Silent Bugs in Quantum Libraries via Quantum-knowledge-enhanced Agents

📅 2026-10-07
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the challenge of detecting silent bugs in quantum computing libraries, which typically evade detection due to the absence of execution-based oracles. To overcome this limitation, we propose a source-level semantic oracle enhanced by quantum domain knowledge. Methodologically, we construct an autonomous testing agent based on an Agentic Loop architecture that integrates large language model reasoning with domain expertise. By iteratively analyzing documentation and code logic, the agent generates executable tests to verify behavioral deviations, thereby transcending traditional approaches reliant on runtime exceptions. Experimental evaluations on Qiskit and PennyLane demonstrate that our method outperforms mainstream coding assistants in testing efficacy. It successfully identifies 40 confirmed new bugs, including 30 silent bugs, achieving both a high detection rate and low computational overhead.
📝 Abstract
Quantum libraries are now critical infrastructure for quantum algorithm development, yet their correctness remains difficult to test. Existing testing techniques mainly rely on failure-based or comparison-based oracles, exposing bugs only when executions fail, violate runtime checks, or disagree with another implementation. Their applicability is limited when suitable execution-based oracles are unavailable, leaving some silent bugs undetected. Such missed bugs can produce incorrect results that propagate into experimental conclusions, simulation studies, and algorithmic designs. Here we present QuSema, an autonomous testing agent for finding silent bugs in quantum libraries. QuSema uses constraints from quantum semantics and documentation as a source-level semantic oracle to assess whether implementation logic can produce invalid outputs from valid inputs. It operates through an agentic loop that repeatedly inspects library API documentation and source code, reasons about the intended behavior of quantum operations, identifies potential semantic deviations, and validates them by generating executable tests through library APIs. Guided by quantum-domain reasoning, QuSema turns high-level behavioral mismatches into concrete, user-triggerable bug reports, enabling it to uncover non-crash defects. We implement QuSema for Qiskit and PennyLane. On a benchmark of 20 historical silent bugs, QuSema achieves higher mean bug relocation counts than Claude Code and Codex, with the DeepSeek configuration costing less than Claude Code. QuSema also discovers 40 previously unknown bugs confirmed by the developers, including 30 silent bugs.
Problem

Research questions and friction points this paper is trying to address.

Quantum libraries
Silent bugs
Software testing
Test oracle
Quantum computing
Innovation

Methods, ideas, or system contributions that make the work stand out.

Silent Bug Detection
Quantum-knowledge-enhanced Agents
Semantic Oracle
Autonomous Testing
Agentic Loop
🔎 Similar Papers
No similar papers found.
💼 Related Jobs
No related jobs found.
Y
Yujin Song
Nanyang Technological University, Singapore
Kaining Zhang
Kaining Zhang
Wuhan University
computer visionimage matching3d vision
Q
Qixin Zhang
Nanyang Technological University, Singapore
S
Shuai Wang
Hong Kong University of Science and Technology, Hong Kong, China
Pingchuan Ma
Pingchuan Ma
Hong Kong University of Science and Technology
Software EngineeringData ManagementCausal Discovery
Yuxuan Du
Yuxuan Du
Nanyang Technological University
Quantum machine learningQuantum computingAI for Quantum Science