Realizing Quantum Adversarial Defense on a Trapped-ion Quantum Processor Alex Jin, Tarun Dutta, Anh Tu Ngo, Anupam Chattopadhyay, Manas Mukherjee Abstract Classification is a fundamental task in machine learning, typically performed using classical models. Quantum machine learning (QML), however, offers distinct advantages, such as enhanced representational power through high-dimensional Hilbert spaces and energy-efficient reversible gate operations. Despite these theoretical benefits, the robustness of QML classifiers against adversarial attacks and inherent quantum noise remains largely under-explored. In this work, we implement a data re-uploading-based quantum classifier on an ion-trap quantum processor using a single qubit to assess its resilience under realistic conditions. We introduce a novel convolutional quantum classifier architecture leveraging data re-uploading and demonstrate its superior robustness on the MNIST dataset. Additionally, we quantify the effects of polarization noise in a realistic setting, where both bit and phase noises are present, further validating the classifier’s robustness. Our findings provide insights into the practical security and reliability of quantum classifiers, bridging the gap between theoretical potential and real-world deployment. keywords Quantum Machine Learning, Adversarial Attack, Adversarial Defense, Ion-trap, Genetic Algorithm † † equal-contributors: These authors contributed equally to this work. † † equal-contributors: These authors contributed equally to this work. † † equal-contributors: These authors contributed equally to this work. † † equal-contributors: These authors contributed equally to this work. 1 Introduction Classification is a fundamental aspect of learning, present in both natural cognition and artificial intelligence. For example, children learn to classify food preferences, and traders distinguish shares to buy or sell. The data obtained from real-life situations, such as images and soundtracks, is often noisy. Yet, modern classical machine learning (ML) models can classify data into multiple classes with nearly 100% accuracy. The complexity and dimensionality of data often require the exploration of higher-dimensional hyperspaces in order to achieve better class separation. Quantum machine learning offers an alternative approach by naturally leveraging the large-dimensional Hilbert spaces of quantum systems. Another potential advantage of quantum mechanics is the ability to explore Hilbert spaces more efficiently through superposition and unitary/reversible evolution, which could allow QML classifiers to achieve comparable or superior classification performance with fewer computational resources and reduced energy consumption. Despite the success of classical ML-based classifiers, they remain prone to certain noise and distortions that may occur in realistic data or could be injected to compromise the accuracy of a classifier through adversaries. The latter, also known as an adversarial attack, is a concern of this article. This is a nascent but fast-growing research field, mostly taking cues from classical classifiers. In the case of classical classifiers, certain strategies perform better than others depending on the classification task. However, there is no universal strategy that provides both high robustness and efficacy on adversarial datasets. Quantum machine learning (QML) offers new resources, such as superposition, compared to its classical counterpart. Therefore, some of the valid research questions to ask are: Can QML provide inherent robustness against adversarial attacks? Will the cost of training a quantum model against adversarial attacks be lower? Finally, can we quantify the robustness of real-world quantum classifiers? In order to study this problem, we must first choose a model and a corresponding algorithm for the classification task. Below, we justify the choice of model for this study. In quantum classifiers, regardless of the algorithm, parameter optimization is performed on a classical computer. Consequently, these algorithms are variational quantum-classical hybrid algorithms McClean et al. 2016 . On noisy intermediate-scale quantum (NISQ) computing hardware, variational-type hybrid algorithms are believed to offer practical advantages over fully quantum algorithms like Shor’s factorization algorithm Shor 1999 . Quantum classifier algorithms are broadly categorized into three types: explicit, implicit, and data re-uploading Pérez-Salinas et al. 2020 , based on how classical data and optimization parameters are represented Jerbi et al. 2023 . Significant progress has been made towards establishing a unified framework for all quantum classifiers Schuld 2021 . Among these, explicit algorithms are the most studied; according to the Representer Theorem Schölkopf et al. 2001 , they guarantee superior training accuracy with the same training set compared to implicit ones. Two recent theoretical advancements are particularly relevant to our discussion. First, a unified framework has been developed to compare the performance and resource requirements of all three quantum classifier types. Second, a robustness quantification method, inspired by differential privacy in classical computing, has been proposed—leveraging quantum depolarizing noise for masking. While these theoretical insights provide valuable benchmarks, experimental validation of these findings on NISQ hardware remains scarce. The data re-uploading algorithm (DRA) shows promise for achieving provable quantum advantages in training efficiency and reduced data requirements Jerbi et al. 2023 . Previous experimental work by our group demonstrated that DRA matches the classification accuracy of classical neural networks with comparable resources. Our previous experimental studies confirmed that DRA can achieve classification accuracy comparable to classical neural networks while using similar computational resources. Notably, we demonstrated that DRA enables autonomous training without reliance on classical simulations, a significant advantage over most existing variational algorithm implementations Dutta et al. 2024 . Here, we extend previous research by implementing adversarial attacks on quantum classifiers, demonstrating that such attacks can significantly degrade classification accuracy—much like in classical machine learning. To address this vulnerability, we also propose and experimentally demonstrate a new quantum classifier approach that exhibits higher robustness against such attacks. We quantify the robustness of our solution using depolarization noise, following the methodology outlined in ref. Weber et al. 2021 . As mentioned in much of the literature in this field, applications on real quantum hardware remain rare and often a predicament to improve on the models Ren et al. 2022 . In a real NISQ device, noise sources extend beyond depolarization to include bit and phase flips. By accounting for these effects, our work provides a more comprehensive evaluation of the robustness and potential quantum advantage of our proposed quantum classifier against adversarial attacks in a practical setting. As in classical machine learning, no universal solution exists for defending against all adversarial attacks. However, our approach serves as a foundation for further training on such datasets to improve robustness. In terms of quantifying robustness, the currently proposed hypothesis, based on classical classifiers, largely aligns with the QML model. However, in realistic scenarios, a detailed understanding of the error budget is essential. In the following, we first present our results on the successful design of an efficient method for generating adversarial datasets based on the original MNIST data. We then describe our initial attempt to counter this attack using a simplistic QML strategy. We then introduce our novel convolutional quantum classifier (CQC) architecture, and demonstrate its effectiveness in mitigating these adversarial attacks. A detailed comparison between the two approaches is provided in the methods section. Finally, we benchmark our strategy using a quantifiable definition of robustness, considering only depolarization noise. To our knowledge, this is the first experimental measurement of quantum classifier robustness under adversarial attacks. Our analysis establishes a method for distinguishing different noise components in quantum systems, extending beyond depolarization noise. In Fig. 1 , we outline the overall architecture of our inference architectures as well as specifying the injection of adversarial and noisy data. Figure 1 : QAML architecture. Left : Examples of image data with variations due to noise or adversarial perturbations. Top right (DRA Architecture) : A hybrid quantum-classical model where input images are first processed by a classical feature extractor, reducing them to a low-dimensional feature space. These extracted features are re-uploaded along with trainable variational parameters to a quantum classifier. Bottom right (DRA-CQC Architecture) : A fully quantum model that directly processes raw pixel values without classical feature extraction. Trainable parameters are applied through convolution, and the data is processed via DRA. This method shows greater resilience to noise and stronger robustness against adversarial attacks. 2 Results The data re-uploading algorithm is a promising algorithm in the general explicit quantum classifier family. Mathematically, a data re-uploading model defines a mapping f:\mathscr{X}\rightarrow\mathscr{F}\rightarrow\mathscr{Y} , where \bar{x}\in\mathscr{X} are vectors of classical data in \mathbb{R}^{n} , \mathscr{F} is the quantum feature space mapped using \rho_{\bar{\theta}}(\bar{x}) , and \bar{y}\in\mathscr{Y} are m-dimensional vectors of the output space. The resulting composite map can be expressed as expectation values of the following form: \displaystyle f_{\bar{\theta}}(\bar{x})=\mathrm{Tr}[\rho_{\bar{\theta}}(\bar{x})O_{\bar{\theta}}], (1) where \bar{\theta} are the variational parameters of our circuit, and \rho_{\bar{\theta}}(\bar{x})=U(\bar{x},\bar{\theta})|0\rangle\langle 0|U^{\dagger}(\bar{x},\bar{\theta}) . In general, U consists of L parameterized layers in the form of U(\bar{x},\bar{\theta})=\prod_{l=1}^{L}U_{l}(\bar{\theta}_{l},\bar{x}) , and its precise definition is called the ansatz of a model. Finally, we have an (variational) observable O_{\bar{\theta}}=V_{L}(\bar{\theta})^{\dagger}OV_{L}(\bar{\theta}) . In a recent study, it has been shown that all parameterized quantum circuits fall under the general umbrella of linear quantum models, and that data re-uploading models are exponentially more resource efficient in terms of the number of qubits and training data points Jerbi et al. 2023 . Therefore, data re-uploading algorithm is a natural candidate for exploring QML algorithms, particularly in the NISQ-era. We will first introduce the results obtained from two approaches used for the classification of the MNIST data: (a) principal component analysis followed by DRA and (b) convolutional quantum classifier using DRA. Table 1 : Train/Test Accuracy, Noise Resilience, and Perturbation Robustness 0 0 footnotetext: Table Summary Comparison of Train/Test Accuracy, Noise Resilience, and Adversarial Robustness for Quantum Classifiers. This table presents the training and test accuracies of different quantum classifiers under simulation (noiseless) and real quantum hardware (noisy) conditions for binary and multiclass classification tasks. Adversarial robustness is evaluated against attacks specifically designed for each test set in both noiseless (simulation) and noisy (quantum hardware) environments. Individual results of the Binary classification test accuracy on our quantum hardware are shown in Fig. 3 and Fig. 2 . Binary (0,1) Multiclass (0,1,2) Multiclass (0,1,2,3) PCA-based Preprocessor linear PCA kernel PCA - Quantum Trainable parameters 9 9 - Classifier Training accuracy 100% 95.53% - (simulation) Test accuracy 99.61% 93.32% - (simulation) Test accuracy 99.52% 2 2 2 From noisy simulation matching ion-trap quantum device. 64.05% 2 2 2 From noisy simulation matching ion-trap quantum device. - (quantum computer) Adversarial accuracy 45.14% 48.00% - (simulation) Adversarial accuracy 45.24% 2 2 2 From noisy simulation matching ion-trap quantum device. 44.00% 2 2 2 From noisy simulation matching ion-trap quantum device. - (quantum computer) DRA-CQC 1 1 1 Data Re-uploading Algorithm-based Convolutional Quantum Classifier. Preprocessor - - - Trainable parameters 90 108 135 Training accuracy 99.16% 94.97% 92.49% (simulation) Test accuracy 98.28% 94.10% 91.64% (simulation) Test accuracy 92.00% 3 3 3 From ion-trap quantum device. 93.49% 2 2 2 From noisy simulation matching ion-trap quantum device. 85.81% 2 2 2 From noisy simulation matching ion-trap quantum device. (quantum computer) Adversarial accuracy 90.00% 82.00% - (simulation) Adversarial accuracy 88.00% 3 3 3 From ion-trap quantum device. 78.10% 2 2 2 From noisy simulation matching ion-trap quantum device. - (quantum computer) 2.0.1 Performance of PCA and CQC An alternative approach for embedding high-dimensional classical data into a quantum circuit involves dimensionality reduction techniques Van Der Maaten et al. 2009 . Among these, principal component analysis (PCA) is a widely utilized tool which we call as the simplistic quantum classifier. In this approach, classical datasets, such as MNIST, are first projected onto a lower-dimensional feature space. These compressed feature vectors are then mapped onto a data re-uploading architecture (DRA) by linearly combining the features with a vector of trainable parameters, with the resulting values used to parameterize quantum gates. To enhance classification accuracy, the data is re-uploaded multiple times using different sets of trainable parameters before performing quantum measurements to classify the input image. Intuitively, the efficacy of this architecture is linked to the quality of separation achieved by the classical feature extraction process. We refer interested readers to Pérez-Salinas et al. 2021 ; Pérez-Salinas et al. 2020 for the theoretical foundations and experimental implementation of such DRA architectures. On the other hand, the Data Re-uploading Convolutional Quantum Classifier (DRA-CQC) architecture, the details of it is explained in 4.3 , relies on the successive convolution of the pixels of an image. In the DRA-CQC architecture, our NISQ device takes as input raw pixel values of the image patches and outputs an array of probabilities of the predicted classes. We can see from table ( 1 ) that we are able to achieve reasonable training and test accuracy for both the binary and 3-class problems from the MNIST dataset using PCA-based DRA. However, such a classification schema is susceptible to perturbation from two perspectives. First, as shown in the table, we notice a significant drop in test accuracy from noiseless simulation to noisy simulation of our NISQ device for the 3-class problem. Second, there is also a drop in both the training and test accuracies even for noiseless simulation when the problem is related to higher number of classes, binary to 3-class. On the contrary, the DRA-CQC approach demonstrates strong robustness against both noise and increased classification complexity. Even when extending to the 4-class problem, noise in the system reduces test accuracy by only 6%. We believe the robustness lies in the averaging of the noise due to the convolution. A more quantitative assessment of robustness is provided by dedicated robustness measurements. While test accuracy serves as a general indicator of an algorithm’s resistance to arbitrary noise, it does not effectively measure robustness against curated adversarial noise specifically designed to induce misclassification. We employed a Genetic Algorithm (GA)-based adversarial image generator to produce images that closely resemble the MNIST dataset. For example, with an average pixel value perturbation of 12.6% using an attack strength of 1.0 for both w_{0} and w_{1} (see 4 ), these generated images were misclassified when evaluated on a trained classifier, despite their resemblance to the benign images. The classification results for both the PCA-based and DRA-CQC classifiers are presented in Table ( 1 ). Notably, the PCA-based classifier performs no better than random guessing, highlighting its vulnerability to adversarial perturbations. In contrast, the DRA-CQC classifier demonstrates significant robustness, exhibiting only a moderate decrease in accuracy. Specifically, for the binary classification task, accuracy drops by merely 4%, while for the three-class classification task, the decline is limited to 14%. 2.1 Quantifying robustness against adversaries Figure 2 : Resilience against adversaries. a . Predicted values of a trained DRA-CQC on an MNIST test set consisting of 100 images of handwritten figures of 0s and 1s. The decision boundaries for predicted value from our NISQ device and numerical simulation are the y- and x- axes, respectively. The blue band covers the 1 standard deviation of experimental uncertainty benchmarked against the simulation outputs. b . Similar as a, but the MNIST test set is adversarially attacked. c . Resilience against adversaries of all 100 test set images certified at probability 0.9. r_{F} at 0 represent uncertified data points. The colors are added to illustrate whether our experimental measurements produced correct labels. d . Two example benign input images used in a and two example adversarial input images (closest to the benign images under the L_{2} -norm) used in b, with their corresponding predicted values circled in the previous plots. In security-sensitive domains, such as autonomous vehicle decision-making and medical data classification, quantifying the robustness of machine learning systems against adversarial interference is critically important. This entails analyzing the model’s behavior under intentional input perturbations, typically constrained by a fidelity threshold of 1-\epsilon . In classical machine learning, this robustness is often quantified using the concept of certified accuracy at a given radius r, where L_{p} -norms are commonly used to measure the magnitude of perturbations. Adversarial robustness, a key metric in this context, evaluates the ability of a trained model to resist manipulation by adversarial attacks, ensuring accurate predictions even under deliberate data alterations. More precisely, given a trained classical machine learning model f:\mathbb{R}^{n}\rightarrow\mathscr{K} , mapping n-dimensional inputs into K distinct output classes, the model is said to be certified at radius \epsilon if its output classes on the test set remain unchanged when the input is perturbed by at most \epsilon , usually measured in terms of l_{0} -, l_{2} -, or l_{\infty} -norms. For QML classifiers, an analogous definition has been given in Weber et al. 2021 as the following. Given a set of labeled test data \mathscr{T}=\{(\sigma_{i},y_{i})\}_{i=1}^{|\mathscr{T}|} , the certified test set accuracy at fidelity 1-\epsilon is defined as \displaystyle\frac{1}{|\mathscr{T}|}\sum_{(\sigma,y)\in\mathscr{T}}\text{1}\{\mathbb{A}(\sigma)=y\land r_{F}(\sigma)\leq 1-\epsilon\}, (2) where \sigma represents a quantum state, y represents a classical label, 1 is an indicator function, and \mathbb{A} is a quantum classifier. r_{F} is the minimum robustness fidelity defined as r_{F}=\frac{1}{2}(1+\sqrt{1-p_{B}-p_{A}(1-2p_{B})+2\sqrt{p_{A}p_{B}(1-p_{A})(1-p_{B})}}) , where 1\geq p_{A}\geq p_{B}\geq 0 , are the highest two values of the classifier’s output probability vector. We now show a concrete experimental verification of this robustness quantifier using the DRA-CQC architecture. The details of this architecture is explained in 4.3 . In the DRA-CQC architecture, our NISQ device takes as input raw pixel values of the image patches and outputs an array of probabilities of the predicted classes. In Fig. 2 , we illustrate both simulated and predicted output probabilities on the binary classification task of predicting a subset of 0s and 1s from the MNIST dataset. We also give the minimum robustness fidelity, r_{F} , as defined in 2 , of each of the predicted outputs. As an interesting sidenote, a quick tally shows that 25\% (3 out of 12) of the uncertified points are incorrectly classified where as 5.7\% (5 out of 88) of the certified points are incorrectly labeled, as shown in Fig. 2 c. 2.2 Robustness against depolarization noise Figure 3 : Robustness against depolarization noise. a Robustness analysis of all 100 test set images measured on our experimental NISQ device. Colors indicate whether the experimental measurements produced correct labels for classifications. b The same example input images as used in Fig. 2 . Higher robustness values correspond to stronger resistance to noise effects. Depolarization noise or depolarization channel refers to a type of quantum noise induced by the environment or the system, where the coherence of a quantum state is reduced and is driven toward a completely mixed state \frac{I}{d} , where I is the identity matrix and d is the dimension of the Hilbert space. Mathematically, for a quantum state \sigma , depolarization can be described as: \displaystyle\sigma^{\prime}=(1-p)\sigma+p\frac{I}{d}, (3) where p refers to the depolarization probability, p\in[0,1] . In Du et al. 2021 , it has been shown that for a given quantum state \sigma , robustness can be guaranteed for any adversarial state \rho with, \displaystyle T(\rho,\sigma)