Introduction
Testing quantum programs presents a unique set of challenges compared to classical software. Quantum states are inherently probabilistic and non-deterministic, meaning that traditional input-output assertions often fail to capture subtle logic errors. As the quantum state space grows exponentially with the number of qubits, existing state-of-the-art testing tools—which largely rely on random input generation—struggle to provide adequate coverage. These random methods tend to become "trapped" in high-probability regions, leaving vast areas of the potential state space, and the bugs residing within them, completely unexplored. To address this, we present NovaQ, a framework that utilizes diversity-guided test case generation to efficiently navigate the complex quantum state space.
The NovaQ Framework
NovaQ is designed to move beyond the limitations of random sampling by implementing a feedback-driven search for novel quantum states. The framework consists of two primary components: a distribution-based test case generator and a novelty-driven evaluator.
Distribution-Based Test Case Generation
Instead of generating purely random values, NovaQ employs Gaussian distributions to sample parameters for universal $U$ gates ($\theta, \phi, \lambda$). The system uses a "seed" mechanism where the mean and variance of these distributions are iteratively mutated. This allows the generator to refine its search based on previous results rather than starting from scratch for every test case.
Novelty-Driven Evaluation
The "brain" of NovaQ is its evaluator, which calculates three internal metrics for every generated test case: Magnitude, Phase, and Entanglement. To make these continuous values actionable, NovaQ discretizes the 3D metric space into a $10 \times 10 \times 10$ grid. The framework tracks the frequency with which each "cell" in this grid is visited. Test cases that land in rarely visited or previously unexplored cells are assigned a high Novelty Score. This score is then used to prioritize the seeds that produced these novel states for the next round of mutation, effectively guiding the search toward unexplored behaviors.
Experimental Evaluation
We evaluated NovaQ against a baseline random generation method (as used in QuraTest) across several standard quantum algorithms, including Grover’s Algorithm (3 to 12 qubits), Phase Estimation (PE), and the Quantum Fourier Transform (QFT). To assess bug detection capabilities, we created a benchmark by injecting synthetic faults—randomly replacing gates—and measuring the accuracy with which each method identified these errors.
Key Results and Insights
The Phase Breakthrough
A critical finding of this research is that random testing is particularly ineffective at exploring the phase dimension of quantum states. As shown in the comparison below, NovaQ’s novelty-driven approach forces the generator into diverse phase configurations that random sampling almost never reaches.
Scalability and Efficiency
The performance gap between NovaQ and random testing widens significantly as circuit complexity increases. While NovaQ is approximately 10% more effective for a 3-qubit system, it achieves over 107% better state coverage for a 12-qubit system. In a 1,500-test run on a 12-qubit circuit, NovaQ covered 197 grid cells compared to the baseline's 95.
Fault Detection Accuracy
NovaQ consistently outperformed the baseline in identifying injected bugs. For the 12-qubit Grover algorithm, NovaQ achieved a 92.1% bug detection accuracy, while the baseline trailed at 85.5%. Furthermore, NovaQ reaches higher levels of diversity much faster than random methods; its coverage growth rate remains steep even after thousands of tests, whereas random methods tend to plateau early.
Conclusion and Future Work
NovaQ demonstrates that diversity-guided generation is a powerful paradigm for quantum program testing, particularly for the increasingly complex circuits of the NISQ (Noisy Intermediate-Scale Quantum) era. While the current study focused on test cases generated via Inverse Quantum Fourier Transform (IQFT) layers and synthetic bugs, future work will involve testing a wider variety of initial circuit structures and applying the tool to "wild" bugs found in open-source quantum libraries like Qiskit.
Summary updated