arXiv:2611.18838
Metamorphic Testing of Quantum Software based on Stabilizer States
Adrián Marín Boyero, Fynn Otto, Albert Rico, Otfried Gühne, Malte Lochau
Abstract
A major challenge in quantum computing is to systematically check if a quantum program implements its desired functionality. For classical programs, testing is widely used; each test case comprises a pair of sample input and expected output to be compared with the actual output. To increase the number of test cases, however, one has to solve the test-oracle problem: for each additional test input one has to know the correct output. Metamorphic testing tackles this problem by utilizing metamorphic relations between input and output domains to automatically derive new test cases from existing ones. However, adapting metamorphic testing to the quantum realm is not straightforward, since quantum states cannot be directly inspected. We propose a framework of quantum metamorphic testing (QMT) in which the metamorphic relations incorporate the measurement procedures required to assess quantum outputs. We apply our QMT framework to testing the preparation of stabilizer states, which are central to protocols like measurement-based quantum computing or quantum error correction. We utilize structural properties of stabilizer states to systematically derive measurement circuits for new test cases from existing ones. We implement this framework in Qiskit, and demonstrate that it reduces by an order of magnitude the testing run time compared to testing with randomly generated input states. We further show effectiveness by revealing synthetic program faults injected by circuit mutations, as well as a real bug in the Qiskit compiler.
AI Summary
The paper asks how to generate additional quantum-software tests without independently constructing an output oracle and measurement procedure for each input. It formalizes quantum metamorphic relations as transformations of classical inputs, measurement strategies, and expected outcome distributions, with a composition rule. The application tests graph-state preparation using qubit permutations, local complementation, and CNOT-based graph transformations. Known stabilizer measurements are transported to follow-up tests. Permutations and local complementation preserve Pauli weight; CNOT-based tests instead insert inverse entangling operations before the source measurements. This reuses low-weight checks rather than searching for them anew, a task whose associated minimum-weight decision problem is NP-complete. The Qiskit evaluation uses 24-qubit random graphs postselected to admit stabilizers of weight at most four, with 204 tests per trial. Across 500 runtime trials, independently generated tests take 64.02 seconds on average, versus approximately 2.3–3.48 seconds for metamorphic variants. Across 2,500 mutation trials, mixed-relation variants achieve fault detection comparable to the baseline; median detection time is about 0.27 seconds versus 1.7 seconds. Local complementation alone misses more faults. A separate 1,010-case compiler campaign identifies nontermination in `LookaheadSwap`: 132 compilations time out, or 45.5% of those using that router. This bug is detected by timeouts, not violated metamorphic relations. Stated limitations include dependence on transformation correctness, randomized sampling, and restricted fault models and inputs. Equivalent mutations are undetectable. Hardware-specific noise robustness and extensions beyond stabilizer states remain future work.
Error found: The reported 18–28-fold runtime reduction is established only for postselected graph-state tests with low-weight stabilizers, so the abstract's wording about randomly generated input states needs that qualification. The supplied results do not numerically substantiate the discussion's detection-effectiveness claims across the remaining mutation classes.
Written by gpt-6.1-sol from the paper's full text. Automated: it can be wrong.