QuanTest: Entanglement-Guided Testing of Quantum Neural Network Systems

Jinjing Shi, Zimeng Xiao, Heyuan Shi, Yu Jiang, Xuelong Li

Abstract

Quantum Neural Network (QNN) combines the Deep Learning (DL) principle with the fundamental theory of quantum mechanics to achieve machine learning tasks with quantum acceleration. Recently, QNN systems have been found to manifest robustness issues similar to classical DL systems. There is an urgent need for ways to test their correctness and security. However, QNN systems differ significantly from traditional quantum software and classical DL systems, posing critical challenges for QNN testing. These challenges include the inapplicability of traditional quantum software testing methods to QNN systems due to differences in programming paradigms and decision logic representations, the dependence of quantum test sample generation on perturbation operators, and the absence of effective information in quantum neurons. In this paper, we propose QuanTest, a quantum entanglement-guided adversarial testing framework to uncover potential erroneous behaviors in QNN systems. We design a quantum entanglement adequacy criterion to quantify the entanglement acquired by the input quantum states from the QNN system, along with two similarity metrics to measure the proximity of generated quantum adversarial examples to the original inputs. Subsequently, QuanTest formulates the problem of generating test inputs that maximize the quantum entanglement adequacy and capture incorrect behaviors of the QNN system as a joint optimization problem and solves it in a gradient-based manner to generate quantum adversarial examples. results demonstrate that QuanTest possesses the capability to capture erroneous behaviors in QNN systems. The entanglement-guided approach proves effective in adversarial testing, generating more adversarial examples.

Introduction

Quantum Neural Networks (QNNs) represent a significant leap in computational intelligence, merging the principles of deep learning with quantum mechanics to potentially achieve "quantum advantage." However, as these systems move closer to real-world deployment in safety-critical domains, their robustness has come under scrutiny. Much like classical Deep Neural Networks (DNNs), QNNs are susceptible to adversarial attacks—small, carefully crafted perturbations that lead to incorrect predictions.

Comparison between classical deep learning testing and quantum neural network testing.

Testing QNNs presents unique challenges that render classical methods ineffective. In classical testing, "neuron coverage" is a standard metric used to ensure various parts of the network are exercised. In the quantum realm, the "no-cloning" theorem and wave function collapse prevent researchers from observing individual quantum neurons without destroying the system's state. Furthermore, classical perturbations like pixel noise do not translate directly to the high-dimensional Hilbert space of quantum data.

The QuanTest Framework

To address these gaps, we introduce QuanTest, the first automated testing framework that leverages quantum entanglement to guide the generation of adversarial examples. Instead of attempting to measure individual neurons, QuanTest uses Quantum Entanglement Adequacy (QEA) as a proxy for structural coverage. QEA measures the change in entanglement (using the Meyer-Wallach measure) as an input state traverses the QNN, indicating how much of the network's complex logic has been "activated."

The QuanTest framework workflow for adversarial example generation.

The framework operates through a joint optimization process. It learns a unitary perturbation operator ($U_\Delta$)—a mathematically valid quantum rotation—to modify input states. The optimization objective is twofold: maximize QEA to explore the network's behavior and maximize the likelihood of an incorrect prediction. To ensure the generated adversarial examples remain similar to the original inputs, QuanTest employs quantum-specific metrics: Average Fidelity Measure (AFM) and Average Trace Distance (ATD).

Experimental Evaluation

We evaluated QuanTest across nine QNN architectures using standard datasets like MNIST and Fashion-MNIST, encoded into quantum states via amplitude encoding.

Key Findings

  • Enhanced Detection: QuanTest generated between 67.48% and 96.05% more high-quality adversarial samples compared to baseline methods using random coherent noise.
  • Effectiveness of Entanglement Guidance: Incorporating QEA into the optimization process increased the number of discovered adversarial examples by up to 21.32% over "blind" attacks.
  • High Success Rates: The framework achieved an adversarial success rate of up to 96.87%, demonstrating the significant vulnerability of current QNN architectures.
  • Robustness Improvement: By retraining QNN models with the adversarial examples discovered by QuanTest, we observed accuracy improvements of up to 7.1%, suggesting a path forward for building more robust quantum systems.

Conclusion

QuanTest demonstrates that quantum entanglement, a fundamental property of quantum systems, can be effectively repurposed as a guide for systematic testing. Our results confirm that QNNs share the adversarial vulnerabilities of classical networks and that these vulnerabilities may even scale with the size of the quantum system. As quantum computing matures, frameworks like QuanTest will be essential for ensuring the security and reliability of quantum-enhanced machine learning.

Citation: Shi, J., Xiao, Z., Shi, H., Jiang, Y., & Li, X. (2024). QuanTest: Entanglement-Guided Testing of Quantum Neural Network Systems. arXiv:2402.12950v2 [cs.SE].

Summary updated

Abstract

Quantum Neural Network (QNN) combines the Deep Learning (DL) principle with the fundamental theory of quantum mechanics to achieve machine learning tasks with quantum acceleration. Recently, QNN systems have been found to manifest robustness issues similar to classical DL systems. There is an urgent need for ways to test their correctness and security. However, QNN systems differ significantly from traditional quantum software and classical DL systems, posing critical challenges for QNN testing. These challenges include the inapplicability of traditional quantum software testing methods to QNN systems due to differences in programming paradigms and decision logic representations, the dependence of quantum test sample generation on perturbation operators, and the absence of effective information in quantum neurons. In this paper, we propose QuanTest, a quantum entanglement-guided adversarial testing framework to uncover potential erroneous behaviors in QNN systems. We design a quantum entanglement adequacy criterion to quantify the entanglement acquired by the input quantum states from the QNN system, along with two similarity metrics to measure the proximity of generated quantum adversarial examples to the original inputs. Subsequently, QuanTest formulates the problem of generating test inputs that maximize the quantum entanglement adequacy and capture incorrect behaviors of the QNN system as a joint optimization problem and solves it in a gradient-based manner to generate quantum adversarial examples. results demonstrate that QuanTest possesses the capability to capture erroneous behaviors in QNN systems. The entanglement-guided approach proves effective in adversarial testing, generating more adversarial examples.
BibTeX
@article{shi2025quantest,
  author = {Jinjing Shi and Zimeng Xiao and Heyuan Shi and Yu Jiang and Xuelong Li},
  title = {{QuanTest: Entanglement-Guided Testing of Quantum Neural Network Systems}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2025},
  doi = {10.1145/3688840},
}
Figure