Battle Against Fluctuating Quantum Noise: Compression-Aided Framework to
  Enable Robust Quantum Neural Network
Recently, we have been witnessing the scale-up of superconducting quantum
computers; however, the noise of quantum bits (qubits) is still an obstacle for
real-world applications to leveraging the power of quantum computing. Although
there exist error mitigation or error-aware designs for quantum applications,
the inherent fluctuation of noise (a.k.a., instability) can easily collapse the
performance of error-aware designs. What's worse, users can even not be aware
of the performance degradation caused by the change in noise. To address both
issues, in this paper we use Quantum Neural Network (QNN) as a vehicle to
present a novel compression-aided framework, namely QuCAD, which will adapt a
trained QNN to fluctuating quantum noise. In addition, with the historical
calibration (noise) data, our framework will build a model repository offline,
which will significantly reduce the optimization time in the online adaption
process. Emulation results on an earthquake detection dataset show that QuCAD
can achieve 14.91% accuracy gain on average in 146 days over a noise-aware
training approach. For the execution on a 7-qubit IBM quantum processor,
IBM-Jakarta, QuCAD can consistently achieve 12.52% accuracy gain on earthquake
detection.
Zhirui Hu, Youzuo Lin, Qiang Guan, Weiwen Jiang
# Battle Against Fluctuating Quantum Noise:

###### Abstract

Recently, we have been witnessing the scale-up of superconducting quantum computers; however, the noise of quantum bits (qubits) is still an obstacle for real-world applications to leveraging the power of quantum computing. Although there exist error mitigation or error-aware designs for quantum applications, the inherent fluctuation of noise (a.k.a., instability) can easily collapse the performance of error-aware designs. What's worse, users can even not be aware of the performance degradation caused by the change in noise. To address both issues, in this paper we use Quantum Neural Network (QNN) as a vehicle to present a novel compression-aided framework, namely _QuCAD_, which will adapt a trained QNN to fluctuating quantum noise. In addition, with the historical calibration (noise) data, our framework will build a model repository offline, which will significantly reduce the optimization time in the online adaption process. Emulation results on an earthquake detection dataset show that QuCAD can achieve 14.91% accuracy gain on average in 146 days over a noise-aware training approach. For the execution on a 7-qubit IBM quantum processor, ibm-jakarta, QuCAD can consistently achieve 12.52% accuracy gain on earthquake detection.

## I Introduction

We are currently in the Noisy Intermediate-Scale Quantum (NISQ) era where noise and scalability have been two well-known and critical issues in quantum computing. Nowadays, we have been witnessing the rapid development of superconducting quantum computers and the scalability issue is gradually mitigated. As an example, IBM took only 6 years to scale up its quantum computers from 5 to 433 qubits and the development of quantum research[1, 2, 3, 4, 5] is advancing rapidly. However, the high noise in quantum computing is still an obstacle for real-world applications to take advantage of quantum computing. There are many sources of noise in quantum computing, such as gate errors and readout errors. As shown in Fig. 1, the color of qubits and their connections indicates the Pauli-X and CNOT gate error from the IBM Belem backend.

Unlike CMOS noise that is within a small range under \(10^{-15}\) so classical computing is more focused on performance efficiency rather than noise[6, 7, 8], the noise on qubits can reach \(10^{-2}\) to \(10^{-4}\). Moreover, as shown in Fig. 1, noise from 1-year-long profiling on the IBM Belem backend is fluctuating in a wide range, called "fluctuating quantum noise". Although there exist works to improve the robustness of quantum circuits to noise, such as error mitigation [9] and noise-aware designs [10, 11, 12], these works commonly perform the optimization based on the noise at one moment. The fluctuating quantum noise can easily make the quantum circuit lose its robustness. Thus, new innovations are needed to deal with the fluctuating noise.

In this paper, we propose a novel framework, namely "QuCAD", to address the above issues. To illustrate our framework, we use Quantum Neural Network (QNN) -- a.k.a, variational quantum circuit (VQC) as an example -- since the learning approach has been shown to be an effective way for a wide range of applications from different domains (such as chemistry [13], healthcare [14], and finance [15]); and meanwhile, [16] recently has shown the potential quantum speedups using VQC. To deal with fluctuating quantum noise, a straightforward method is to apply a noise-aware training approach to retrain QNN before each inference; however, it will obviously incur high costs. More importantly, as the quantum noise changes in a wide range, we observe that a set of parameters will deviate from the loss surface, which impedes the noise-aware training to find optimal solutions.

To address this problem, we made an investigation and found that these parameters will lead to short circuits after the logical-to-physical compilation. Equivalent to classical neural networks, these QNN parameters can be regarded as compression levels. Therefore, QNN compression can be helpful to optimize the model in a noisy environment. Based on our observations, in QuCAD, we develop a novel noise-aware QNN compression algorithm. It will interplay with other two components: (1) a model repository constructor that can build a repository of compressed models offline using representative historical data; and (2) a model repository manager that can make an online adaption of models to the fluctuating noise. As such, QuCAD can automatically and efficiently obtain the QNN models adapted to run-time noise for high performance.

The main contributions of this paper are as follows.

* We reveal that the fluctuating quantum noise will collapse the performance of quantum neural networks (QNNs).
* We develop a noise-aware QNN compression algorithm to adapt pretrained QNN model to a given noise.
* On top of the noise-aware compression algorithm, we further propose a 2-stage framework to adapt QNN model to fluctuating quantum noise automatically.

Fig. 1: The fluctuating noise observed on IBM backend bele
Evaluation is conducted on both IBM Aer simulator and IBM quantum processor ibm-jakarta. Experiment results on MNIST, earthquake detection dataset, and Iris show the effectiveness and efficiency of QuCAD. Especially, QuCAD achieves superior performance among the competitors on all datasets. It achieves 16.32%, 38.88%, and 15.36% accuracy gain compared with the default configuration without optimization. Even compared with noise-aware training before every execution, QuCAD can still achieve over a 15% accuracy improvement on average; meanwhile, QuCAD can reduce the training time to over 100\(\times\) at the online stage. For the execution on a 7-qubit IBM quantum processor ibm-jakarta, QuCAD can consistently achieve a 13.7% accuracy gain on the earthquake detection dataset.

The remainder of the paper is organized as follows. Section 2 reviews the related work and provides observations, challenges and motivations. Section 3 presents the proposed QuCAD framework. Experimental results are provided in Section 4 and concluding remarks are given in Section 5.

## II Related Work, Challenge, and Motivation

### _Related Work_

There are two commonly applied approaches to mitigate the effect of quantum noise. One is to adjust quantum circuits by noise-aware training [12] and mapping [11]. Noise-aware training is an adversary method, which injects noise into the training process so that the parameter of model can be learned from both datasets and devices. Noise-aware mapping is to minimize the sum of accumulated noise by changing the mapping from logical qubits to physical qubits. Another method is to estimate the ideal outputs by post-processing measurement data, e.g., zero-error noise extrapolation [17], probabilistic error cancellation[18], and virtual distillation[19]. However, these two kinds of approaches are based on noise at one moment, so we can hardly maintain the performance without redoing these methods as noise changes anytime.

There are a few works addressing the fluctuating-noise issue, which can be quantitatively analyzed in two aspects: the noise of device and the distance between ideal results and noisy results. [20] evaluated the stability of NISQ devices with multiple metrics that characterize stability. [21, 22] defined Hellinger distance, computational accuracy and result reproducibility to expound the distance between ideal result and noisy observation. These works show the significance of reproducing results in a long-term execution on a quantum device. However, it is still not clear what effects the fluctuating noise will make on quantum applications.

### _Observation, Challenge and Motivation_

This section will provide our observations on the simulation performance of a quantum neural network model on a noisy quantum computer over a period of one year.

**Observation 1: Fluctuating noise can collapse the model accuracy of a noise-aware trained QNN model.**

Fig. 2 (a) shows the daily accuracy of a QNN model on the quantum processor in Fig. 1, which demonstrates that the accuracy can be varied significantly along with the fluctuating noise. The QNN model is trained using the noise-aware training method [12] based on the calibration (noise) data on day 1 (8/10/22). Its accuracy is over 80% from day 1 to day 22; however, when error rates increased on day 24, the accuracy decreased to 22%. This observation shows that the noise-aware design can obtain a robust quantum circuit to a certain range of noise, but the performance can be collapsed when the noise rate goes beyond a threshold.

**Challenge 1: Noise on qubits can create breakpoints beyond the optimization surface, creating difficulties in training**

Relying on training only to adapt to noise may miss the opportunity to find the optimal solution. Fig. 3(a)-(b) shows an example of the results of a quantum circuit with 2 parameters (x-axis and y-axis) in a perfect environment (simulation) and in a noisy environment (realistic). From the difference shown in Fig. 3(c), we can see that the breakpoints in the loss landscape are with much lower noise. Given the optimization started from a random point, in order to reach these breakpoints, it requires a dedicated learning rate for each parameter, which is almost impossible in a training algorithm.

**Motivation 1: Not only relying on training but also involving compression to battle against quantum noise.**

Looking closer at these breakpoints in Fig. 3(c), we observe that the parameter value of 0 creates these breakpoints. We also observe such breakpoints around other specific values, like \(\frac{\pi}{2}\), \(\pi\), \(\frac{2\pi}{2}\), etc. We further investigate the root cause and we found the improvement in performance is caused by the reduction of physical circuit length. More specifically, due to the transpilation (i.e., logical-to-physic qubit mapping), the logical quantum gate with different values will result in varied circuit lengths on physical qubits. Analog to the classical neural networks, the reduction of the network complexity is known as compression. Based on the above understanding, it motivates us to employ compression techniques to address the quantum noise. For the same noise setting as Fig. 2(a), we perform the model compression on Day 1, and results are reported in Fig. 2(b). It is clear that the results of compression (i.e., yellow points) are much better than the noise-aware training (i.e., blue points). However, we still observe a significant accuracy drop between March 15 to May 29.

**Observation 2: Behaviors of fluctuating noise on different qubits has heterogeneity.**

To explore the root cause of the accuracy drop, we investigate the change of CNOT noise on all pairs of qubits on three dates: (1) Feb. 12, (2) March 15, and (3) April 25. Fig.4 (a) reports the results. It is clear that the qubits on March 15 and April 25 have much higher noise than that on Feb. 12. A more interesting observation is that the fluctuating noise on different qubits has heterogeneity. Specifically, on Feb. 12, \(\langle q_{3},q_{4}\rangle\) has the highest noise, while \(\langle q_{1},q_{2}\rangle\) becomes the noisiest one on March 15 and April 25. Along with the heterogeneous

Fig. 3: Noise-aware training may miss optimal solution: (a) Optimization surface of 2-parameter VQC under noise free environment. (b) Optimization surface of the same VQC under a noisy environment. (c) Difference between (a) and (b).

Fig. 2: The accuracy of QNN on 4-class MNIST from August 2021 to August 2022 on IBM backend been using Qiskit Simulation.
changes of noise on qubits, the compressed QNN model may lose its robustness, which causes the accuracy degradation between March 15 to May 29.

**Motivation 2: Adding noise awareness in compression to battle against fluctuating quantum noise**

To address the above challenges, only conducting noise-agnostic compression with the objective of minimizing circuit length is not enough; on the other hand, we need to take the heterogeneous noise on qubits into consideration. This motivates us to develop a "noise-aware compression" on QNNs, which can involve the noise level at each qubit to guide how the model will be compressed. Details will be introduced in Sec III-A. We use an example to illustrate the necessity of noise-aware compression. As shown in Fig. 4 (b), on March 15 and April 25, we observe significant changes in the noise of qubits, which makes the original compressed model suffer an accuracy drop from 79% to 22.5% and 56.5%. By using a noise-aware compression on these dates, we resume the accuracy to 38.5% and 80% on March 15 and April 25, respectively.

With noise-aware compression, now, the problem is how frequently should we perform the compression. Due to the fluctuation of quantum noise, one straightforward idea is to leverage the noise-aware compression before using it, so that it can adapt to the new noise. However, this can be too costly.

**Observation 3: Models can be re-utilized.**

Let's see the original model in Fig. 4(b), which experienced a dramatic accuracy drop on March 15. However, after 9 days, on March 24, the accuracy of this model resumed to 80.5%. Therefore, the previous model can be re-utilized later.

**Motivation 3: A model repository can avoid model optimization every day to improve efficiency.**

The above observation inspires us to build a model repository to keep a set of models. At run time, instead of directly performing optimization (i.e., compression) for a new noise, we can first check if models in the repository can adapt to the noise. In this way, it is possible to reuse pre-optimized models and significantly reduce the optimization cost at run time.

With the above observations and motivations, we propose a novel framework QuCAD in the following section to devise a noise-aware compression algorithm, build a model repository upon historical data offline, and manage it at run time.

## III Compression-Aided Framework

This section will introduce our proposed compression-aided framework, namely QuCAD, to battle against fluctuating quantum noise. Before introducing details, we first formally formulate the problem as follows: Given a QNN model \(M\), the quantum processor \(Q\) with history calibration (noise) data \(D_{\mathrm{t}}\), the current calibration data \(D_{\mathrm{c}}\) of \(Q\), the problem is how to leverage the calibration data (i.e., \(D_{t}\) and \(D_{c}\)) to find a model \(M^{\prime}\) with the objective of maximizing the accuracy of \(M^{\prime}\) on \(Q\) with \(D_{c}\).

### _Framework Overview_

Fig. 5 shows the overview of the QuCAD framework. It contains 3 main components: (1) a noise-aware compression algorithm, (2) an offline model repository constructor, and (3) an online model repository manager. The noise-aware compression algorithm is the core of QuCAD in both offline and online optimizations.

The offline optimization includes the following steps to build a model repository. We will first use the historical calibration data to obtain their corresponding performance for the given QNN model \(M\). Then, a clustering algorithm is developed to create several groups in terms of calibration data and corresponding model performance. The centroid of calibration data in each group (\(D^{\prime}\)) will be used to optimize model \(M\) the compression algorithm to generate the compressed model \(M^{\prime}\). The pair of \(\langle M^{\prime},D^{\prime}\rangle\) will be placed into the model repository.

The online optimization will get the current calibration data \(D_{\mathrm{c}}\) of quantum computer \(Q\) as input. We match \(D_{c}\) with the existing calibration data \(D^{\prime}\) of items \(\langle M^{\prime},D^{\prime}\rangle\) in the model repository, aiming at finding the most similar one. The model repository manager will use the difference between calibration data \(D_{c}\) and \(D^{\prime}\) to make a judgment whether model \(M^{\prime}\) can be directly used under \(D_{c}\). If the distance is over a pre-set threshold then performance degradation is predicted, we will regard the current calibration data as a new centroid and generate a new model by noise-aware compression and put it into the model repository. Otherwise, we will output matched model directly.

### _Noise-Aware Compression_

Quantum neural network compression was recently proposed [23] to reduce circuit length, where an Alternating direction method of multipliers (ADMM) approach is applied. In this paper, we will also employ ADMM as the optimizer for noise-aware compression, and the new challenge here is how to involve noise awareness in the compression process. In the previous work, the authors conducted compression upon the logical quantum circuit. However, to involve noise in the compression of quantum gates, we need to fix the physic qubits of each quantum gate. _Therefore, we will take the quantum circuit after routing on restricted topology as input, instead of the logical quantum circuit._

Before introducing our proposed algorithm, we first define the notations and the optimization problem which will be used in ADMM. We denote \(\mathbf{T}\) as a table of compression-level, which are breakpoints in the example of _Motivation 1_. We denote the function of a VQC under a noise-free (a.k.a., perfect, denoted by \(p\)) environment as \(W_{p}(\mathbf{\theta})\)

Fig. 4: Noise-aware compression is needed: (a) CNOT gate noise on three days. (b) Noise-aware compressing and tuning models on the three days in (a) and testing the on the following days.

Fig. 5: Illustration of the proposed Compression-Aided Framework (QuCAD).
where \(\mathbf{\theta}=[\theta_{1},\theta_{2},\cdots,\theta_{n}]\) are a set of trainable parameters, and \(\theta_{i}\) is the parameter of gate \(g_{i}\). With the consideration of noise, the function of VQC will be changed to \(W_{n}(\mathbf{\theta})\). On top of these, the deviation caused by noise can be defined as \(N(\mathbf{\theta})=W_{n}(\mathbf{\theta})-W_{p}(\mathbf{\theta})\). For a quantum gate \(g_{i}\), it is associated with a physic qubit \(q_{k}\) or a pair of physic qubits \(\langle q_{k},q_{l}\rangle\). For simplicity, we denote such an association as a function \(\langle q_{k},q_{l}\rangle=A(g_{i})\), and we use \(k=l\) to represent \(g_{i}\) is associated with one qubit \(q_{i}\). We denote \(\mathbf{C}\) as a table of calibration data, and the notation \(n_{k,l}\in\mathbf{C}\) or the function \(C(q_{k},q_{l})\) to represent the noise rate on qubit \(q_{k}\) and \(q_{l}\) (or \(q_{k}\) if \(k=l\)). Then, the problem can be formulated as below.

\[\min_{\mathbf{\theta}}\quad W_{p}(\mathbf{\theta})+N(\mathbf{\theta}) \tag{1}\]

Now, to enable using ADMM to perform noise-aware compression, we first decompose the optimization problem in Eq. 1 to two sub-problems and solve them separately: (1) maximize accuracy and (2) minimize the deviation caused by noise. The first subproblem can be solved by a gradient-based optimizer. For the second problem, we will use a set of auxiliary variables and an indicator function to resolve it, which will be introduced later. Therefore, we reformulate the optimization problem that can be solved by ADMM as below.

\[\min_{\{\theta_{i}\}}\quad f(W_{p}(\mathbf{\theta}))+N(\mathbf{Z})+\sum_{\forall z_{i }\in\mathbf{Z}}s_{i}(z_{i}), \tag{2}\]

where \(\mathbf{Z}\) is a set of auxiliary variables for subproblem decomposition and \(z_{i}\in\mathbf{Z}\) is corresponding to \(\theta_{i}\in\mathbf{\theta}\); function \(f\) represents training loss on the given dataset; \(\mathbf{T^{admm}}\) is gate-related compression table build on \(T\); and \(s_{i}(z_{i})\) is an indicator, which will indicate whether the parameter \(\theta_{i}\) will be pruned or not.

In the \(r^{th}\) iteration of ADMM optimization, one key step is to determine whether or not to compress a parameter. According to the parameter \(\theta_{i}\), compression table \(T\), and noise data \(n_{k,l}\), we will build a mask. Fig. 6 illustrates the process to create the mask, which is composed of three steps. First, by comparing the parameter \(\theta_{i}\) with each compression level in table \(T\), we generate two tables: \(\mathbf{T^{admm}}\) and \(\mathbf{D}\). The \(i^{th}\) element in \(\mathbf{T^{admm}}\) is denoted as \(T_{i}^{admm}\), which is the nearest compression level of parameter \(\theta_{i}\); while \(d_{i}\) is the minimum distance between parameter \(\theta_{i}\) and any compression level. _Note that in a noise-agnostic compression [23], a mask will be generated by using table \(\mathbf{D}\). In the second step, we further consider gate noise and generate a priority table \(\mathbf{P}\)._ Notation \(p_{i}\in\mathbf{P}\) indicates the priority of gate \(g_{i}\) to be pruned; then, we have \(p_{i}=\frac{C(A(g_{i}))}{d_{i}}\), where \(A(g_{i})\) is the qubits associated with \(g_{i}\) and \(C(A(g_{i}))\) is the noise rate. Based on \(p_{i}\), we formulate the mask \(mask(g_{i},\mathbf{C})^{r}\) for gate \(g_{i}\) on the given calibration data \(\mathbf{C}\) in the \(r^{th}\) iteration as below.

\[mask(g_{i},\mathbf{C})^{r}=\begin{cases}0&\text{ if }p_{i}^{r}<threshold\\ 1&\text{ if }otherwise.\end{cases} \tag{3}\]

In the above formula, the mask equals \(1\) indicating that the gate \(g_{i}\) has a high priority, which is larger than a pre-set threshold, to be compressed. To maintain high accuracy, we will utilize the compression level \(T_{i}^{admm}\) if \(g_{i}\) is masked to be compressed.Based on these understandings, we define the indicator function \(s_{i}(z_{i})\):

\[s_{i}(z_{i})=\begin{cases}0&\text{ if }z_{i}=T_{i}^{admm}\times mask(g_{i},\mathbf{C} )^{r}\\ &or\ mask(g_{i},\mathbf{C})^{r}=0\\ +\infty&\text{ if }otherwise.\end{cases} \tag{4}\]

Note that \(s_{i}\) is used in Eq. 2 to restrict the value of \(z_{i}\). It requires its value to be 0 for a valid solution. In the above formula, we set \(s_{i}(z_{i})=0\) in two cases: (1) if \(mask(g_{i},\mathbf{C})^{r}=0\), indicating we do not require the compression on gate \(g_{i}\); or (2) \(\theta_{i}=T_{i}^{admm}\times mask(g_{i},\mathbf{C})^{r}\), indicating that the parameter \(\theta_{i}\) has to be compressed to be the compression level \(T_{i}^{admm}\).

For each round, we will get \(\mathbf{\theta}^{r}\) and \(\mathbf{Z}^{r}\) alternately. At last, we will get the optimized parameters \(\mathbf{\theta}\) to minimize Eq. 1. Then, we will employ noise injection to fine-tune parameters \(\mathbf{\theta}\) to further improve the performance, where we will freeze the compressed parameters to not be tuned using the final \(mask\).

### _Offline Model Repository Constructor_

As discussed in _Motivation 3_, it is possible to use the noise-aware compression to perform optimization before using the QNN, but it is too costly and there exist opportunities to improve efficiency by building a model repository so that the model can be reused. In this subsection, we will explain how to build the repository using a modified noise-aware k-means clustering algorithm.

There are two inputs of the model repository constructor: (1) offline calibration data, denoted as \(\mathbf{C}=[\mathbf{c_{1}},\mathbf{c_{2}},...,\mathbf{c_{n}}]\in R^{n\times d}\); and (2) the corresponding QNN accuracy under the calibrations, denoted as \(\mathbf{p}=[p_{1},p_{2},...,p_{n}]\in R^{n}\), where \(n\) is the number of calibration data and \(d\) is the total number of noise rates in each calibration data. Our objective is to split calibration data (\(\mathbf{C}\)) into \(k\) groups, and the samples in the same group are with similar calibration data and performance; meanwhile, the centroid \(\mathbf{r_{i}}\) is representative of each group (\(\mathbf{g_{i}}\)). Then, we can use the representative centroid \(\mathbf{r_{i}}\) to do noise-aware compression and the compressed model will be added to the repository.

_Objective Function and Distance._ To achieve our goal, we first define performance-aware weight, which is \(\mathbf{w}=[w_{1},w_{2},...,w_{d}]\), where \(w_{j}\) is the absolute correlation coefficient \(\rho=|\frac{\text{cov}(X,Y)}{\sigma_{x}\sigma_{y}}|\) between the model performance \(\mathbf{p}\) and the \(j^{th}\) dimension in calibration data \(\mathbf{C}_{\cdot,\mathbf{j}}\). The weighted distance (noted as \(dist_{L1}^{w}\)) between two samples (\(\mathbf{c_{i}}\) and \(\mathbf{c_{j}}\))of calibration data can be defined as

\[dist_{L1}^{w}(\mathbf{c_{i}},\mathbf{c_{j}})=dist_{L_{1}}(\mathbf{w}\cdot \mathbf{c_{i}},\mathbf{w}\cdot\mathbf{c_{j}}) \tag{5}\]

where \(dist_{L_{1}}\) is the Manhattan distance between two vectors;

The objective function is designed to partition the data into \(K\) clusters such that the sum of weighted Manhattan (\(L_{1}\)) absolute errors (WSAE) of all their clusters is minimized. Therefore, the objective function WSAE is designed as:

\[WSAE=\sum_{\mathbf{g_{i}}\in\mathbf{C}}\sum_{\mathbf{v}\in\mathbf{g_{i}}}dist_{L _{1}}^{w}(\mathbf{r_{i}},\mathbf{c}) \tag{6}\]

\(\mathbf{G}\) is all groups, \(\mathbf{r_{i}}\) is the representative of group \(\mathbf{g_{i}}\in\mathbf{G}\), and \(\mathbf{c}\in\mathbf{g_{i}}\) is the candidate calibration in group \(\mathbf{g_{i}}\). Since the noise is considered in model performance, the clustering not only considers the value of noise but also the effects of noise on the given QNN model.

### _Online Model Repository Manager_

After building the model repository, the next question is how to use it for online algorithms. We provide the following guidance to

Fig. 6: Noise-aware mask generation in ADMM process.
use the repository efficiently.

**Guidance 1**: _The cluster results can help to judge whether to generate new models into the model repository manager. At the offline stage, we can get the average weighted distance:_

\[\overline{(dist_{L1}^{v})_{i}}=\frac{\sum_{\forall\mathbf{c}\in\mathbf{g_{i}}} dist_{L_{1}}(\mathbf{r_{i}},\mathbf{c})}{n_{i}}\]

_between the centroid(_\(\mathbf{r_{i}}\)_) and all samples (_\(\forall\mathbf{c}\in\mathbf{g_{i}}\)_) in the_ \(i^{th}\) _cluster, where_ \(n_{i}\) _is the number of samples in the_ \(i^{th}\) _cluster. We set_ \(max_{i}(\overline{(dist_{L1}^{v})_{i}})\) _as a threshold_ \(th_{w}\) _to decide whether to add a new centroid (i.e., new representative) in the model repository. If the_ \(min_{j}(disj)>th_{w}\) _where_ \(disj\) _is the_ \(dist_{L1}^{w}\) _distance between the_ \(j^{th}\) _centrol and the current calibration data, we will add the current calibration data to the model repository._

**Guidance 2**: _The cluster results can be utilized to predict the performance of the given model with current calibration data. Specifically, we can obtain the average accuracy of each cluster, say_ \(\overline{acc_{i}}\) _for the_ \(i^{th}\) _cluster. According to users' requirement on QNN model accuracy_ \(A\)_, we can set cluster_ \(g_{i}\) _as an invalid cluster if its average accuracy_ \(a\bar{c}c_{i}\) _is less than_ \(A\)_. Then, at the online stage, if the current calibration matches the centroid in an invalid cluster, we will set the current calibration data as an invalid data, and output a failure report._

## IV Experiments

### _Experiments Setup_

**Datasets and model.** We evaluate our framework on three classification tasks. (1) We extract 4 class (0,1,3,6) from MNIST [24] with the former 90% samples for training and latter 200 samples for testing. To process MNIST data, we apply angle encoding [25] to encode \(4\times 4\) images to 4 qubits, and adopt 2 repeats of a VQC block (4RY +4CRY +4RY +4RX +4CRX +4RX +4RZ + 4CRZ +4CRZ) as the original model. (2) We extract 1500 samples of the earthquake detection dataset from FDSN [26]. Each sample has a positive or negative label. We utilize 90% and 10% samples for training and testing, respectively. We encode features to 4 qubits and employ the same VQC as MNIST. (3) We use Iris [27] dataset with 66.6% and 33.4% samples for training and testing. Features are encoded to 4 qubits with 3 repeats of VQC blocks.

**Calibrations and Environment Settings.** We pull history calibrations from Aug. 10, 2021 to Sep. 20, 2022 from IBM backend (ibm_belem) using Qiskit Interface. The front 243 days are used for offline optimization and the remaining 146 days' data are used for online tests. We generate noise models from history calibration data and integrate them into Qiskit noise simulator for online simulation. Besides, we also deploy QuCAD on ibm-jakarta and evaluate the output model of QuCAD on a real IBM quantum processor, ibm-jakarta. Our codes are based on Qiskit APIs and Torch-Quantum [28].

**Competitors.** We employ different approaches for comparison, including: (1) Baseline: training in a noise-free environment without optimization. (2) Noise-aware Training Once [12]: applying noise injection on the first day for training. (3) Noise-aware Training Everyday: extend the noise-aware training everyday. (4) One-time Compression[23]: applying compression with the objective of minimizing circuit length on the first day. (5) QuCAD w/o offline: generating the models by our framework without an offline stage. (6) QuCAD: generating the models by our framework during the offline and online stages.

### _Main Results of our proposed QuCAD_

**Effective evaluation on noisy simulation.** Table I reports the comparison results of different methods on MNIST, Iris, and earthquake detection datasets. Columns "Mean accuracy" and "Variance" gives the statistical information of model accuracy on the continuously 146 days. Column "Days over 0.8" stands for the number of days that the model accuracy is higher than 80%, which is similar to "Days over 0.7" and "Days over 0.5" columns. From this table, we can clearly see that our proposed QuCAD outperforms all competitors. Specifically, on these 3 datasets, QuCAD achieves improvements of 16.32%, 38.88%, and 15.36% respectively, compared with the baseline. Although there exists one case that the 'days over 0.8' of 'QuCAD w/o offline' is 1 day more than that of 'QuCAD' on Iris, QuCAD has many days to have accuracy over 70%. Besides, QuCAD has the lowest variance except for the baseline on Iris, showing the stability of QuCAD. Kindly note that the mean accuracy of the baseline on Iris is much lower than QuCAD. We also observed that QuCAD outperforms competitors on the number of days over different accuracy requirements, which again demonstrates the effectiveness of our framework.

Compared with noise-aware training, even one-time compression has a significant improvement on all datasets, which validates our observation in Fig. 3. On the other hand, QuCAD w/o offline outperforms one-time compression, indicating that online adaptation is needed. Furthermore, compared with 'QuCAD w/o offline', QuCAD achieves improvements of 3.36%, 1.14%, and 1.41%, showing the effectiveness of offline optimization in QuCAD.
**Efficiency evaluation.** We recorded the training time at the online stage in Fig. 7 on 4-class MNIST. In the figure, the bars represent the mean accuracy (i.e., right axis) and each point with a number corresponds to a normalized training time (i.e., left axis). From the results, we can see that QuCAD can achieve 146\(\times\) and 110.3\(\times\) speedup over "compression everyday" and "noise-aware train every data", respectively. This shows the efficiency of our framework, which mainly comes from the reduction of the number of online optimization. More specifically, the centroids generated offline can well represent the calibrations at the online stage if the distribution of calibrations doesn't change much.

**Evaluation on real quantum computers.** We also evaluate QuCAD on the earthquake detection dataset using IBM quantum processor ibm-jakarta with different calibration data at different time. Results are shown in Fig. 8. QuCAD can consistently outperform the two competitors by 13.7% and 12.52% on average. Besides, we can see that the accuracy of QuCAD on different days is more stable than others, which reflects our methods can adapt QNN models to fluctuating noise.

### _Ablation Study_

**QuCAD vs. Practical Upper Bound.** We further investigate the performance of 8 representative days in Fig. 9(a). We apply the result of noise-aware compression every day as a practical upper bound. From the results, we can observe that QuCAD has a competitive performance compared to the practical upper bound, showing QuCAD can get approximate optimal results.

**Noise-Aware vs. Noise-Agnostic Compression.** We further evaluate the proposed compression algorithm on those 8 representative days, as shown in Fig. 9(b). Results show that noise-aware compression can outperform noise-agnostic compression on most days, showing the effectiveness of our proposed noise-aware compression. We also observe both compression approaches obtained the same accuracy on 5/4 and 7/14. There are two possible reasons: (1) there is no great difference among qubits; and (2) The noise level is small and the simple compression is enough to get a good performance.

**Model repository constructor.** We also did an ablation study on the clustering algorithm developed in the model repository constructor. We compare our proposed noise-aware distance \(dist_{L,1}^{w}\)and the standard 'L2 norm' distance. Results reported in Table II show that our method can get 2.89% higher mean accuracy of 6 clusters on average and obtain 2.23% accuracy gain on that for all samples consistently. Results indicate that our proposed method can improve the quality of the centroids and make centroids represent other samples better in a cluster.

## V Conclusion

In this work, we reveal the fluctuating noise in quantum computing and it will significantly affect the performance of quantum applications. To battle against fluctuating noise, we further observe that the high noise level may create breakpoints in the loss surface, and in turn, the noise-aware training may find inferior solutions. By investigating the breakpoints, we observe that quantum neural network compression can be a hammer to the noise issue. And we build a compression-aided framework, namely QuCAD, which can automatically adapt a given model to fluctuating quantum noise. Evaluations on MNIST, earthquake detection dataset, and Iris show the effectiveness and efficiency of QuCAD. specifically, QuCAD can obtain stable performance on the earthquake detection task using a real IBM quantum processor.
