# Augmentation of Universal Potentials for Broad Applications

Joe Pitfield<EMAIL_ADDRESS>Florian Brix  Zeyuan Tang  Andreas Møller
Slavensky  Nikolaj Rønne  Mads-Peter Verner Christiansen  Bjørk Hammer
<EMAIL_ADDRESS>Center for Interstellar Catalysis, Department of Physics and
Astronomy, Aarhus University, DK-8000 Aarhus C, Denmark

###### Abstract

Universal potentials open the door for DFT level calculations at a fraction of
their cost. We find that for application to systems outside the scope of its
training data, CHGNet[1] has the potential to succeed out of the box, but can
also fail significantly in predicting the ground state configuration. We
demonstrate that via fine-tuning or a $\Delta$-learning approach it is
possible to augment the overall performance of universal potentials for
specific cluster and surface systems. We utilize this to investigate and
explain experimentally observed defects in the Ag(111)-O surface
reconstruction and explain the mechanics behind its formation.

Global Optimisation, Machine Learning, Neural Network Potentials, Gaussian
Process Regression, Surface Reconstruction, Cluster

Atomic structure plays a crucial role in the understanding and development of
new materials and technologies. A great many different compounds have
structures which have been determined by experimental observation through a
variety of techniques [2, 3, 4, 5, 6]. However, the configuration space of
potential structures increases exponentially with degrees of freedom as we
combine surfaces with adsorbates, defects, alloys and interfaces. Theoretical
structure prediction offers the opportunity to screen and predict the
structural properties of such systems. Studies of surface structure [7, 8],
catalysis [9, 10, 11, 12] and interface physics [13, 14, 15, 16] provide
valuable insight into not only the interesting material properties of these
systems, but also the key limitations of first principles methods in
addressing these ever more configurationally complex problems.

Machine learning models offer the ability to limit the amount of expensive
first principles calculations performed, and the possibility of extending the
results of small calculations to larger systems without the corresponding
cubic[17] increase in cost common to density functional theory. Machine
learning has been applied in a variety of ways to alleviate the computational
workload of materials science: neural network potentials [18, 19, 20, 21, 22,
23, 24] and Gaussian process regression [25, 26, 27, 28, 29, 30, 31] for
energetic evaluation, reinforcement[32, 33, 34] and active learning[35, 16]
for candidate structure suggestion.

Such methods reduce the demand for expensive first principles calculations to
be performed where the chosen model is well informed. If the model is not well
informed, such as during the initialisation of such approaches, acquiring
sufficient data often remains expensive. Recent interest has surrounded the
utilisation of comprehensive structural databases such as the Materials
Project[36], the OpenCatalyst Project[37] and PubChem[38] in training
potentials which are broadly applicable. These so-called universal potentials
theoretically remove the expensive initialisation step of any materials
science workflow, promising orders of magnitude decrease in cost for DFT
accuracy calculations. Recent examples include M3GNet[39], MACE[40],
AisNet[41], CHGNet[1] and DPA2 [42]. This work will focus on CHGNet, as it
suggests strong performance with relatively few parameters ($\sim$450,000).

CHGNet is trained on the Materials Project dataset, which is dominated by
structures which fall into the bulk regime. Unsurprisingly, CHGNet has been
demonstrated to perform well when applied to materials in this realm[1].
However, the majority of device physics occurs in regimes where the materials
deviate from perfect bulk crystals: interfaces have drastically varying
conductivities [43, 44, 45, 14, 46, 47, 48], defects play a key role in
electronics [49, 50, 51], surfaces are defining in heterogeneous catalysis
[52, 53, 54], and nano-particulate phases are key in atmospheric[55] and
astro-chemical[56, 57, 58] contexts.

In this letter, we investigate with CHGNet the structural properties of two
sets of materials involving either nano-particles or ultra-thin oxides on a
surface. Varying system sizes and stoichiometries, we find for both types of
materials that the universal potential is sufficiently accurate to identify
the global minimum energy structures of some of the systems studied. However,
we also find cases in which CHGNet lacks such accuracy. These cases form the
basis for testing how to improve the pretrained CHGNet (v0.3.0). We pursue two
avenues for this. Either we fine-tune the network, or we add an extra machine
learning model to the potential prediction in what is known as
$\Delta$-learning[59].

The letter is organized in the following manner: firstly we present two
silicate clusters, and augment the CHGNet energy predictions where necessary,
following either a fine-tuning or $\Delta$-learning strategy. Next, the effect
of the augmentations is discussed as a function of the amount of data used.
The letter proceeds to consider CHGNet predictions for ultra-thin oxides on
the Ag(111) surface. Augmentation is found necessary for experimental
consistency, and the $\Delta$-correction scheme is employed leading to the
construction of a reliable model. Finally, the model is applied to very large
surface defect structures containing more than $1000$ atoms.

Throughout this work, we will utilise optimization methods as implemented in
the "Atomistic Global Optimization X" package, AGOX(v3.6.0)[60] that builds on
the "Atomic Simulation Environment" (ASE)[61]. Density Functional Theory (DFT)
calculations are performed in GPAW[62]. More details on the methods used are
given in Section SII and Section SIV[63].

Figure 1: Parity plot of CHGNet prediction vs DFT energy for four formula unit
Olivine clusters. Three unique low-energy configurations are illustrated and
corresponding datapoints indicated. The solid line is a guide to the eye.
Green, tan and red spheres represent magnesium, silicon and oxygen atoms,
respectively

Figure 1 presents three low energy configurations found for a silicate nano-
particle with four olivine formula units, i.e.
$\bigl{[}\mathrm{Mg}\mathrm{Si}_{2}\mathrm{O}_{4}\bigr{]}_{4}$. For these
configurations, we find that CHGNet correctly predicts the same ordering as
DFT[64]. This is evidenced by the parity plot of CHGNet versus DFT energies
presented. We find similar DFT reproducibility behaviour of CHGNet for a range
of other structures, see Section SI. This result demonstrates that despite
CHGNet being trained largely on extended solid materials, it contains
sufficient chemical insight so as to deal with the chemical consequences of
compounds having finite size whereby many atoms end up in surface sites.

The offset of CHGNet energy to DFT energies apparent from Fig. 1 stems from
the use of different DFT codes and DFT run-time parameters. The CHGNet
architecture comes with 94 parameters, one for each atomic species, known as
the composition model, which may be altered to accomodate such energy
differences. Section SV discusses how to adjust the composition model
parameters and eliminate the offset.

Using CHGNet for a wide variety of materials, we find occasional examples
where it does not provide the same minimum energy configuration as found with
DFT. An example of this is given in Fig. 2(a-c) that present three low-energy
configurations of silicate nano-particles with four pyroxene formula units,
i.e. $\bigl{[}\mathrm{Mg}\mathrm{Si}\mathrm{O}_{3}\bigr{]}_{4}$ (PYR-4). In
this case, the CHGNet model predicts the wrong stability ordering of the
cluster configurations, as seen from the parity plot in Fig. 2(e). The
structure preferred in CHGNet, Fig. 2(a), is hollow, while the one preferred
in DFT[65], Fig. 2(c), is more compact.

To rationalize CHGNet’s behavior for this system, we note that it relies on
extrapolating the total energy of unknown systems by generalizing from local
atomic descriptors in known systems. These descriptors result from graph-
embedding in consecutive deep neural network layers, and predictions for
certain motifs may be off, if these are not present in the training data.

We observe this effect whilst calculating the total dipole moments of these
structures, which yields 1.22 and $<0.01$ $|e|\cdot\textup{\AA}$, for the
CHGNet and DFT minima respectively. The much higher value of the CHGNet
minimum occurs with the presence of magnesium coordinated magnesium in a
triangular motif capped by a single oxygen, cf. upper part of structure in
Fig. 2(a). We theorise that this motif has been incorrectly extrapolated from
structures in which it correlates with stability.

Postulating thusly, the obvious solution is to augment the model with a
collection of such data. In the following we shall take two approaches to such
augmentation.

We first consider the option of fine-tuning CHGNet [66, 67]. Fine-tuning
involves:

  * •

Acquire $N_{\mathrm{sub}}$ pieces of data, that specify structures and
corresponding DFT energies and forces.

  * •

Split the data in training and validation data randomly in some desired ratio,
e.g. 90:10.

  * •

Complete a training step in which the network parameters are updated via
backpropagation of the training data.

  * •

Repeat steps until the model prediction accuracy on the validation set cannot
be improved any further.

Figure 2: (a-c) depict three low energy cluster configurations of PYR-4. (e)
parity plot of the CHGNet vs DFT energies. (d) Fine-tuning prediction of
energies with increasing data. (f) $\Delta-$model prediction of energies with
increasing data. Structures (a-c) are color coded in all cases, with dashed
lines indicating DFT energies.

Figure 2(d) shows the energy prediction for the three low-energy cluster
configurations of PYR-4 as a function of the amount of data, $1\leq
N_{\mathrm{sub}}\leq 2000$, randomly extracted from an established dataset.
Details of this dataset are given in the Section SVI.

As successively more data is used, the fine-tuned CHGNet indeed learns the
relative ordering of the three low-energy cluster configurations, cf Fig.
2(d). Below 50 datapoints used, the fine-tuned CHGNet reacts turbulently to
new data with predictions fluctuating in a jagged manner. When these
fluctuations settle for $N_{\mathrm{sub}}\geq 500$, the fine-tuned CHGNet
matches well the DFT energies of the respective structures.

Having seen that it is indeed possibly to fine-tune CHGNet to learn system
specific information and attain DFT-level accuracy, we now present an
alternative approach: $\Delta$-learning. The motivation for developing a new
approach stems from the fact that depending on the dataset size and the number
of required epochs, the augmentation of a neural network via fine-tuning may
be highly computationally costly, demanding expensive GPUs.

$\Delta$-learning is an established machine learning approach in which one
model learns "as much as it can" and a subsequent model learns the residual
errors. Together, the two models are referred to as a $\Delta$-model.
$\Delta$-learning has previously been successfully applied in the domain of
molecular[68] and materials[69] modelling, amongst others [70, 71, 72, 59, 73,
74, 75, 76].

In the present context, we opt to use a Gaussian Process Regression (GPR)
model for learning the residuals between the CHGNet and DFT values. We select
GPR as an auxiliary model for its performance in the low data regime, both in
terms of speed and reliability. Depending on hyper-parameters, a GPR may
further excel in not correcting the CHGNet predictions outside the regions of
the data used for the GPR training. This is unlike the situation in which a
neural network is used as the auxiliary model, where corrective predictions
could be more far reaching in impact.

In the $\Delta$-model approach we make predictions according to:

$E_{\Delta\mathrm{-model}}(\mathcal{S})=E^{\mathrm{CHGNet}}(\mathcal{S})+\sum^{N}_{i}\Delta
E^{\mathrm{GPR}}(\mathbf{x}_{i}),$

for an unknown structure, $\mathcal{S}$, with local atomic representations
$\mathbf{x}_{i}$. The GPR model prediction for the residual can be seen in
Section SIII.

We note, that it is instructive to think of a $\Delta$-model composed of a
fixed NN and a trainable GPR model, as a GPR model with a prior given by the
NN, which is concurrent with the language within our AGOX implementation.

The $\Delta$-model approach does not require the expensive GPU retraining of
the neural network as was the case with the fine-tuning approach. In practice,
we use a local SOAP-descriptor-based sparse GPR model, see Section SIII for
more details[77, 78]. It would be equally viable to select any equivalently
representative descriptor, including the intrinsic CHGNet features.

Figure 2(f) presents the prediction of the GPR-based $\Delta$-model as a
function of the amount, $N_{\mathrm{sub}}$, of data sub-sampled from the
dataset. The silicate cluster stabilities predicted with the GPR-based
$\Delta$-model are seen to smoothly tend towards the DFT values, i.e. they are
not jagged for $N_{\mathrm{sub}}\leq 50$, and converge for
$N_{\mathrm{sub}}\geq 500$. The ordering becomes correct much earlier for the
$\Delta$-model, being consistently so after as little at 10 data points. This
evidences that the GPR-based auxiliary model is sufficiently versatile to
learn the residuals in the space defined by the silicate clusters considered.

At this point, it is instructive to discuss the origin of the dataset. The
dataset was constructed in consecutive cycles of structural searches followed
by model augmentation. Further details are given in Section SVI. Here it
suffices to highlight that such an active learning acquisition of training
data is only computationally feasible if the model augmentation step is fast
and stable with small additions of data. The differences in consistency
between Figure 2(d,f) in the low data regime confirms that datasets can be
more efficiently incorporated with the GPR-based $\Delta$-model. This leads to
them being overall powerful options when augmenting the predictive power of
CHGNet or similar universal potentials.

We now move to consider an application involving surface reconstructions,
where we will demonstrate the use of the $\Delta$-model approach for system
sizes not computationally accessible for DFT studies. Specifically, we shall
consider three ultra-thin oxide phases that have been observed on Ag(111)[79,
80]. The phases are the $c(4\times 8)$, $c(3\times 5\sqrt{3})$, and $p(4\times
5\sqrt{3})$, that have 0.5, 0.4, and 0.375 oxygen/surface Ag coverages,
respectively. For convenience, we shall refer to the three phases as phase I,
II, and III, respectively.

Figure 3: (a) Parity plot of phase I structures, with colour coded insets
depicting their correspondingly coloured points. DFT and CHGNet agree on the
GM. (b) CHGNet GM for phase II. (c) DFT GM for phase II. (d) $\Delta$-model
predictions for phase II. The DFT energy difference is calculated at -0.53 eV.
(e) CHGNet GM for phase III. (f) DFT GM for phase III. (g) $\Delta$-model
predictions for phase III. The DFT energy difference is -0.76 eV. In all
depictions, red spheres represent oxygen, with all others indicating silver.

Starting with phase I, inserts in Fig. 3(a) present its structure and two
alternative structures found when searching in either the CHGNet or in the
full DFT energy landscape. The parity plot displayed in Fig. 3(a) shows that
CHGNet works quite well for this system. Moving to phase II in Fig. 3(b,c),
the situation changes and now CHGNet predicts a structure with linear O-Ag-O
motifs lining up in rows as the more stable, Fig. 3(b), while DFT has an
elaborate structure with Ag6 triangles as the ground states, Fig. 3(c).

In order to remedy the identified deficiency and to resolve CHGNets prediction
for the correct ground state structure for phase II, we collected, via 10
uncorrelated active learning campaigns, training data for 10 independent
$\Delta$-models. Figure 3(d) shows the mean and uncertainty of predictions by
these 10 models as a function of the amount of training data used. To put the
approach to the test, we collected the data for the same cell as phase II
itself, but for different stoichiometries, specifically omitting the
stoichiometry containing the solution (see SI for details). Clearly, the
models are capable of learning the correct ordering and energy difference of
the two structures.

Finally, in Fig. 3(e-g) the situation for phase III is presented. Again, the
pretrained CHGNet predicts a wrong ground state structure, Fig. 3(e), that
does not have the Ag6 and Ag10 triangular motifs present in the DFT ground
state structure, Fig. 3(f). Now interestingly, the 10 $\Delta$-models that
were trained for phase II, when applied to phase III are able to predict the
correct ordering and energy difference, as shown in Fig. 3(g). This
demonstrates that the $\Delta$-models generalize well and opens for their
application to more advanced materials problems where DFT calculations become
prohibitively large.

Figure 4: a) Reproduction of STM images: Reprinted with permission from Ref.
[80]. Copyright 2016 American Chemical Society, and from Ref. [79] under the
Creative Commons Attribution 3.0 License, respectively. Both images depict the
phase II ultra-thin oxide on Ag(111) under oxygen exposure, where single-width
phase III stripes can be observed consistently. Schematics depicitng b)
neighbouring phase III cells, and c) dispersed III cells. d) Schematic of the
relaxation undergone at the interface between phases II and III.

In Fig. 4 we present such a case. The STM images in Fig. 4(a), obtained
independently by the groups of Refs. 79 and 80, suggest the appearance of
single rows of the phase III structure inside larger domains of phase II.
These defect rows are observed to move dynamically at room temperature and
their presence therefore cannot be ascribed to kinetic limitations. To assess
the possibility of a thermodynamic origin of the rows we adopted a
$\Delta$-model selected from amongst those developed for Fig. 3. In Fig.
4(b,c) two systems are presented that explain why for instance the rows of
phase III do not collapse to wider domains. In Fig. 4(b) two rows of phase III
rows are adjacent to each other, and interfaced to phase II, while in Fig.
4(c) the two rows of phase III have dispersed in to being fully separated by
phase II. With the augmented CHGNet model, we can calculate the energy change
of this process, and find it to be preferred by 0.352 eV meaning that the
interface energy between phase II and III is $-0.176$ eV per
$5\sqrt{3}a/\sqrt{2}$ side length, where $a$ is the lattice constant.

Figure 4(d) shows the considerable relaxations occurring at the interface
between the two phases. Omitting the relaxations perpendicular to the
interface plane the interface energy becomes essentially zero, leading us to
conjecture that stress present within phase II is relieved at the interface
and constitutes the driving mechanism for the presence of the rows of phase
III defects within the large domains of phase II. The reason why the system
does not evolve into alternating single rows of either phase, which would
maximize the amount of favorable interfaces, is that this would also bring the
overall oxygen coverage and hence chemisorption energy gain down, given the
difference in O-coverage of phase II and III.

In conclusion, we have investigated the capability of a universal potential,
CHGNet, in describing selected inorganic clusters and surfaces. In cases where
the accuracy of the plain CHGNet model is insufficient to correctly order low-
energy structures, we demonstrate that either fine-tuning or $\Delta$-learning
offer a means to augment the model. We finally used a $\Delta$-learning
augmented CHGNet model to identify and rationalize negative energy domain
boundaries in the thin film oxides forming on Ag(111).

We acknowledge support by VILLUM FONDEN through Investigator grant, project
no. 16562, and by the Danish National Research Foundation through the Center
of Excellence “InterCat” (Grant agreement no: DNRF150).

## References

  * Deng  _et al._ [2023] B. Deng, P. Zhong, K. Jun, J. Riebesell, K. Han, C. J. Bartel, and G. Ceder, Nature Machine Intelligence 5, 1031 (2023).
  * Fewster [2004] P. F. Fewster, Progress in crystal growth and characterization of materials 48, 245 (2004).
  * Stobinski  _et al._ [2014] L. Stobinski, B. Lesiak, A. Malolepszy, M. Mazurkiewicz, B. Mierzwa, J. Zemek, P. Jiricek, and I. Bieloshapka, Journal of Electron Spectroscopy and Related Phenomena 195, 145 (2014).
  * Černỳ [2017] R. Černỳ, Crystals 7, 142 (2017).
  * Gloystein  _et al._ [2020] A. Gloystein, N. Nilius, J. Goniakowski, and C. Noguera, The Journal of Physical Chemistry C 124, 26937 (2020).
  * Shields and Gupta [2024] S. S. Shields and J. A. Gupta, Surface Science 740, 122403 (2024).
  * Gutiérrez  _et al._ [2001] G. Gutiérrez, A. Taga, and B. Johansson, Physical review B 65, 012101 (2001).
  * Zhang  _et al._ [2018] R. Zhang, L. Li, L. Frazer, K. B. Chang, K. R. Poeppelmeier, M. K. Chan, and J. R. Guest, Physical Chemistry Chemical Physics 20, 27456 (2018).
  * Hendriksen  _et al._ [2010] B. L. Hendriksen, M. D. Ackermann, R. Van Rijn, D. Stoltz, I. Popa, O. Balmes, A. Resta, D. Wermeille, R. Felici, S. Ferrer, _et al._ , Nature chemistry 2, 730 (2010).
  * Polo-Garzon  _et al._ [2019] F. Polo-Garzon, Z. Bao, X. Zhang, W. Huang, and Z. Wu, Acs Catalysis 9, 5692 (2019).
  * Chen  _et al._ [2019] S. Chen, F. Xiong, and W. Huang, Surface Science Reports 74, 100471 (2019).
  * Baker  _et al._ [2022] E. A. D. Baker, J. Pitfield, C. J. Price, and S. P. Hepplestone, Journal of Physics: Condensed Matter 34, 375001 (2022).
  * Hill  _et al._ [2000] C. Hill, R. Beach, and T. McGill, Journal of Vacuum Science & Technology B: Microelectronics and Nanometer Structures Processing, Measurement, and Phenomena 18, 2044 (2000).
  * Schusteritsch  _et al._ [2015] G. Schusteritsch, S. P. Hepplestone, and C. J. Pickard, Physical Review B 92, 054105 (2015).
  * Taylor  _et al._ [2020] N. T. Taylor, F. H. Davies, I. E. M. Rudkin, C. J. Price, T. H. Chan, and S. P. Hepplestone, Computer Physics Communications 257, 107515 (2020).
  * Pitfield  _et al._ [2024] J. Pitfield, N. Taylor, and S. Hepplestone, Physical Review Letters 132, 066201 (2024).
  * Mohr  _et al._ [2015] S. Mohr, L. E. Ratcliff, L. Genovese, D. Caliste, P. Boulanger, S. Goedecker, and T. Deutsch, Physical Chemistry Chemical Physics 17, 31360 (2015).
  * Behler and Parrinello [2007] J. Behler and M. Parrinello, Physical review letters 98, 146401 (2007).
  * Schütt  _et al._ [2018] K. T. Schütt, H. E. Sauceda, P.-J. Kindermans, A. Tkatchenko, and K.-R. Müller, The Journal of Chemical Physics 148 (2018).
  * Unke and Meuwly [2019] O. T. Unke and M. Meuwly, Journal of chemical theory and computation 15, 3678 (2019).
  * Gasteiger  _et al._ [2021] J. Gasteiger, F. Becker, and S. Günnemann, Advances in Neural Information Processing Systems 34, 6790 (2021).
  * Schütt  _et al._ [2021] K. Schütt, O. Unke, and M. Gastegger, in  _International Conference on Machine Learning_ (PMLR, 2021) pp. 9377–9388.
  * Batatia  _et al._ [2022] I. Batatia, D. P. Kovacs, G. Simm, C. Ortner, and G. Csányi, Advances in Neural Information Processing Systems 35, 11423 (2022).
  * Batzner  _et al._ [2022] S. Batzner, A. Musaelian, L. Sun, M. Geiger, J. P. Mailoa, M. Kornbluth, N. Molinari, T. E. Smidt, and B. Kozinsky, Nature communications 13, 2453 (2022).
  * Denzel and Kästner [2018] A. Denzel and J. Kästner, The Journal of Chemical Physics 148 (2018).
  * Koistinen  _et al._ [2019a] O.-P. Koistinen, V. Ásgeirsson, A. Vehtari, and H. Jónsson, Journal of Chemical Theory and Computation 16, 499 (2019a).
  * Koistinen  _et al._ [2019b] O.-P. Koistinen, V. Ásgeirsson, A. Vehtari, and H. Jónsson, Journal of chemical theory and computation 15, 6738 (2019b).
  * Deringer  _et al._ [2021] V. L. Deringer, A. P. Bartók, N. Bernstein, D. M. Wilkins, M. Ceriotti, and G. Csányi, Chemical Reviews 121, 10073 (2021).
  * Bisbo and Hammer [2022] M. K. Bisbo and B. Hammer, Physical Review B 105, 245404 (2022).
  * Merte  _et al._ [2022] L. R. Merte, M. K. Bisbo, I. Sokolović, M. Setvín, B. Hagman, M. Shipilin, M. Schmid, U. Diebold, E. Lundgren, and B. Hammer, Angewandte Chemie 134, e202204244 (2022).
  * Hamamoto  _et al._ [2023] Y. Hamamoto, T. N. Pham, M. K. Bisbo, B. Hammer, and Y. Morikawa, Physical Review Materials 7, 124002 (2023).
  * Jørgensen  _et al._ [2019] M. S. Jørgensen, H. L. Mortensen, S. A. Meldgaard, E. L. Kolsbjerg, T. L. Jacobsen, K. H. Sørensen, and B. Hammer, The Journal of Chemical Physics 151 (2019).
  * Zhou  _et al._ [2019] Z. Zhou, S. Kearnes, L. Li, R. N. Zare, and P. Riley, Scientific reports 9, 10752 (2019).
  * Gogineni  _et al._ [2020] T. Gogineni, Z. Xu, E. Punzalan, R. Jiang, J. Kammeraad, A. Tewari, and P. Zimmerman, Advances in Neural Information Processing Systems 33, 20142 (2020).
  * Smith  _et al._ [2018] J. S. Smith, B. Nebgen, N. Lubbers, O. Isayev, and A. E. Roitberg, The Journal of chemical physics 148, 241733 (2018).
  * Persson  _et al._ [2012] K. A. Persson, B. Waldwick, P. Lazic, and G. Ceder, Physical Review B 85, 235438 (2012).
  * Chanussot  _et al._ [2021] L. Chanussot, A. Das, S. Goyal, T. Lavril, M. Shuaibi, M. Riviere, K. Tran, J. Heras-Domingo, C. Ho, W. Hu, _et al._ , Acs Catalysis 11, 6059 (2021).
  * Kim  _et al._ [2016] S. Kim, P. A. Thiessen, E. E. Bolton, J. Chen, G. Fu, A. Gindulyte, L. Han, J. He, S. He, B. A. Shoemaker, _et al._ , Nucleic acids research 44, D1202 (2016).
  * Chen and Ong [2022] C. Chen and S. P. Ong, Nature Computational Science 2, 718 (2022).
  * Batatia  _et al._ [2023] I. Batatia, P. Benner, Y. Chiang, A. M. Elena, D. P. Kovács, J. Riebesell, X. R. Advincula, M. Asta, W. J. Baldwin, N. Bernstein, _et al._ , arXiv preprint arXiv:2401.00096 (2023).
  * Hu  _et al._ [2023] Z. Hu, Y. Guo, Z. Liu, D. Shi, Y. Li, Y. Hu, M. Bu, K. Luo, J. He, C. Wang, _et al._ , Journal of Chemical Information and Modeling 63, 1756 (2023).
  * Zhang  _et al._ [2023] D. Zhang, X. Liu, X. Zhang, C. Zhang, C. Cai, H. Bi, Y. Du, X. Qin, J. Huang, B. Li, _et al._ , arXiv preprint arXiv:2312.15492 (2023), https://doi.org/10.48550/arXiv.2312.15492.
  * Marks [1990] T. J. Marks, Angewandte Chemie International Edition in English 29, 857 (1990).
  * Chen [1997] G. Chen, Journal of Heat Transfer 119, 220 (1997).
  * Nan  _et al._ [2004] C.-W. Nan, G. Liu, Y. Lin, and M. Li, Applied Physics Letters 85, 3549 (2004).
  * Burger  _et al._ [2016] N. Burger, A. Laachachi, M. Ferriol, M. Lutz, V. Toniazzo, and D. Ruch, Progress in Polymer Science 61, 1 (2016).
  * Zhang  _et al._ [2019] S. Zhang, A. Hao, N. Nguyen, A. Oluwalowo, Z. Liu, Y. Dessureault, J. G. Park, and R. Liang, Carbon 144, 628 (2019).
  * Liu  _et al._ [2019] Q. Liu, F. Wang, W. Shen, X. Qiu, Z. He, Q. Zhang, and Z. Xie, Ceramics International 45, 23815 (2019).
  * Bryan and Gamelin [2005] J. D. Bryan and D. R. Gamelin, Progress in inorganic chemistry 54, 47 (2005).
  * Shklovskii and Efros [2013] B. I. Shklovskii and A. L. Efros,  _Electronic properties of doped semiconductors_ , Vol. 45 (Springer Science & Business Media, 2013).
  * Durand  _et al._ [2015] C. Durand, X. Zhang, J. Fowlkes, S. Najmaei, J. Lou, and A.-P. Li, Journal of Vacuum Science & Technology B 33, 02B110 (2015).
  * Rosenthal [2011] D. Rosenthal, physica status solidi (a) 208, 1217 (2011).
  * Huang and Li [2019] W. Huang and W.-X. Li, Physical Chemistry Chemical Physics 21, 523 (2019).
  * Zaera [2021] F. Zaera, Coordination Chemistry Reviews 448, 214179 (2021).
  * Biswas and Wu [2005] P. Biswas and C.-Y. Wu, Journal of the air & waste management association 55, 708 (2005).
  * Tang  _et al._ [2022] Z. Tang, F. D. S. Simonsen, R. Jaganathan, J. Palotás, J. Oomens, L. Hornekær, and B. Hammer, Astronomy & Astrophysics 663, A150 (2022).
  * Rasmussen  _et al._ [2023] A. P. Rasmussen, G. Wenzel, L. Hornekær, and L. H. Andersen, Astronomy & Astrophysics 674, A103 (2023).
  * Poterya  _et al._ [2024] V. Poterya, I. S. Vinklárek, A. Pysanenko, E. Pluharova, and M. Fárník, ACS Earth and Space Chemistry 8, 369 (2024).
  * Ramakrishnan  _et al._ [2015] R. Ramakrishnan, P. O. Dral, M. Rupp, and O. A. Von Lilienfeld, Journal of chemical theory and computation 11, 2087 (2015).
  * Christiansen  _et al._ [2022] M.-P. V. Christiansen, N. Rønne, and B. Hammer, The Journal of Chemical Physics 157 (2022).
  * Larsen  _et al._ [2017a] A. H. Larsen, J. J. Mortensen, J. Blomqvist, I. E. Castelli, R. Christensen, M. Dułak, J. Friis, M. N. Groves, B. Hammer, C. Hargus, _et al._ , Journal of Physics: Condensed Matter 29, 273002 (2017a).
  * Mortensen  _et al._ [2024] J. J. Mortensen, A. H. Larsen, M. Kuisma, A. V. Ivanov, A. Taghizadeh, A. Peterson, A. Haldar, A. O. Dohn, C. Schäfer, E. Ö. Jónsson, _et al._ , The Journal of Chemical Physics 160 (2024).
  * [63] See Supplemental Material at [URL will be inserted by publisher] for further details and discussions (see also Refs. [81, 62, 82, 65, 78, 77, 83, 84]). The topics covered include: CHGNet out-of-the-box performance, DFT Settings, Local GPR, Global Optimisation, Composition Model, Silicate Dataset Creation, Silver Oxide Dataset Creation.
  * Slavensky  _et al._ [2023] A. M. Slavensky, M.-P. V. Christiansen, and B. Hammer, The Journal of Chemical Physics 159 (2023).
  * Escatllar  _et al._ [2019] A. M. Escatllar, T. Lazaukas, S. M. Woodley, and S. T. Bromley, ACS Earth Space Chem. 3, 2390 (2019).
  * Deng  _et al._ [2024] B. Deng, Y. Choi, P. Zhong, J. Riebesell, S. Anand, Z. Li, K. Jun, K. A. Persson, and G. Ceder, arXiv preprint arXiv:2405.07105 (2024).
  * Focassio  _et al._ [2024] B. Focassio, L. P. M. Freitas, and G. R. Schleder, ACS Applied Materials & Interfaces (2024), https://doi.org/10.1021/acsami.4c03815.
  * Käser  _et al._ [2020] S. Käser, O. T. Unke, and M. Meuwly, New Journal of Physics 22, 055002 (2020).
  * Nandi  _et al._ [2021] A. Nandi, C. Qu, P. L. Houston, R. Conte, and J. M. Bowman, The Journal of Chemical Physics 154, 051102 (2021).
  * Hu  _et al._ [2003] L. Hu, X. Wang, L. Wong, and G. Chen, The Journal of Chemical Physics 119, 11501 (2003).
  * Balabin and Lomakina [2009] R. M. Balabin and E. I. Lomakina, The journal of chemical physics 131, 074104 (2009).
  * Gillan  _et al._ [2013] M. Gillan, D. Alfè, A. Bartók, and G. Csányi, The Journal of chemical physics 139, 244504 (2013).
  * Zaspel  _et al._ [2018] P. Zaspel, B. Huang, H. Harbrecht, and O. A. von Lilienfeld, Journal of chemical theory and computation 15, 1546 (2018).
  * Chmiela  _et al._ [2018] S. Chmiela, H. E. Sauceda, K.-R. Müller, and A. Tkatchenko, Nature communications 9, 3887 (2018).
  * Sauceda  _et al._ [2019] H. E. Sauceda, S. Chmiela, I. Poltavsky, K.-R. Müller, and A. Tkatchenko, The Journal of chemical physics 150, 114102 (2019).
  * Stöhr  _et al._ [2020] M. Stöhr, L. Medrano Sandonas, and A. Tkatchenko, The Journal of Physical Chemistry Letters 11, 6835 (2020).
  * Bartók  _et al._ [2013] A. P. Bartók, R. Kondor, and G. Csányi, Physical Review B—Condensed Matter and Materials Physics 87, 184115 (2013).
  * Rønne  _et al._ [2022] N. Rønne, M.-P. V. Christiansen, A. M. Slavensky, Z. Tang, F. Brix, M. E. Pedersen, M. K. Bisbo, and B. Hammer, The Journal of Chemical Physics 157 (2022), 10.1063/5.0121748.
  * Schnadt  _et al._ [2009] J. Schnadt, J. Knudsen, X. L. Hu, A. Michaelides, R. T. Vang, K. Reuter, Z. Li, E. Lægsgaard, M. Scheffler, and F. Besenbacher, Phys. Rev. B 80, 075424 (2009).
  * Derouin  _et al._ [2016] J. Derouin, R. G. Farber, M. E. Turano, E. V. Iski, and D. R. Killelea, ACS Catalysis 6, 4640 (2016).
  * Perdew  _et al._ [1996] J. P. Perdew, K. Burke, and M. Ernzerhof, Physical review letters 77, 3865 (1996).
  * Larsen  _et al._ [2017b] A. H. Larsen, J. J. Mortensen, J. Blomqvist, I. E. Castelli, R. Christensen, M. Dułak, J. Friis, M. N. Groves, B. Hammer, C. Hargus, E. D. Hermes, P. C. Jennings, P. B. Jensen, J. Kermode, J. R. Kitchin, E. L. Kolsbjerg, J. Kubal, K. Kaasbjerg, S. Lysgaard, J. B. Maronsson, T. Maxson, T. Olsen, L. Pastewka, A. Peterson, C. Rostgaard, J. Schiøtz, O. Schütt, M. Strange, K. S. Thygesen, T. Vegge, L. Vilhelmsen, M. Walter, Z. Zeng, and K. W. Jacobsen, Journal of Physics: Condensed Matter 29, 273002 (2017b).
  * Himanen  _et al._ [2020] L. Himanen, M. O. J. Jäger, E. V. Morooka, F. Federici Canova, Y. S. Ranawat, D. Z. Gao, P. Rinke, and A. S. Foster, Computer Physics Communications 247, 106949 (2020).
  * Laakso  _et al._ [2023] J. Laakso, L. Himanen, H. Homm, E. V. Morooka, M. O. Jäger, M. Todorović, and P. Rinke, The Journal of Chemical Physics 158 (2023).


# Mitiq: A software package for error mitigation on noisy quantum computers

Ryan LaRose  Unitary Fund  Michigan State University, East Lansing, MI  Andrea
Mari  Unitary Fund  Peter J. Karalekas  Unitary Fund  Nathan Shammah  Unitary
Fund  William J. Zeng  Unitary Fund  Goldman, Sachs & Co, New York, NY

(August 27, 2024)

###### Abstract

We introduce an open-source software package for error mitigation in quantum
computation using zero-noise extrapolation. Error mitigation techniques
improve computational performance (with respect to noise) with minimal
overhead in quantum resources by relying on a mixture of quantum sampling and
classical post-processing techniques. Our error mitigation package interfaces
with multiple quantum computing software stacks, and we demonstrate improved
performance on IBM and Rigetti superconducting quantum processors as well as
noisy simulators. We describe the library using code snippets to demonstrate
usage and discuss features and contribution guidelines.

##  I Introduction

Methods to counteract noise are critical for realizing practical quantum
computation. While fault-tolerant quantum computers that use error-correcting
codes are an ideal goal, they require physical resources beyond current
experimental capabilities. It is therefore interesting and important to
develop other methods for dealing with noise on near-term quantum computers.

In recent years, several methods, collectively referred to as quantum error
mitigation methods, have been proposed and developed for this task. Among them
are zero-noise extrapolation Temme  _et al._ (2017); Li and Benjamin (2017),
probabilistic error cancellation Temme  _et al._ (2017); Endo  _et al._
(2018), dynamical decoupling Santos and Viola (2005); Viola and Knill (2005);
Pokharel  _et al._ (2018), randomized compiling Wallman and Emerson (2016),
and subspace expansion McClean  _et al._ (2020). In contrast to quantum error
correction which has yet to be fully demonstrated in experiments, error
mitigation methods have been used experimentally in several papers Kandala
_et al._ (2019); Giurgica-Tiron  _et al._ (2020); Urbanek  _et al._ (2019);
Vuillot ; Quantum  _et al._ (2020). To aid research, improve reproducibility,
and move towards practical applications, it is important to have a unified
framework for implementing error mitigation techniques on multiple quantum
back-ends.

To these ends, we introduce Mitiq: a software package for error mitigation on
noisy quantum computers. Mitiq is an open-source Python library that
interfaces with multiple front-end quantum programming languages to implement
error mitigation techniques on various real and simulated quantum processors.
Mitiq supports Cirq Ho and Bacon (2018), Qiskit Abraham  _et al._ (2019), and
pyQuil Smith  _et al._ (2016) programs and any programs or back-ends that
interface with these packages Karalekas  _et al._ (2020). The library is
extensible in that new front-ends and back-ends can be easily supported as
they become available. Mitiq currently implements zero-noise extrapolation and
is designed to be modular to support additional techniques. Error mitigation
methods can be implemented in few additional lines of code while the library
is still flexible enough for advanced usage.

In Sec. II, we show how to get started with Mitiq and illustrate its main
usage. We then show benchmarking results in Sec. III that demonstrate how
error mitigation with Mitiq improves the performance of noisy quantum
computations. In Sec. IV, we introduce the library structure and describe in
detail the zero-noise extrapolation module. We discuss further software
details and library information in Sec. V including future development,
contribution guidelines, and planned maintenance and support. Finally, in Sec.
VI we discuss the relationship between Mitiq and additional quantum error
mitigation techniques.

##  II Getting started with Mitiq

###  II.1 Requirements and installation

Mitiq is a Python library that can be installed on Mac, Windows, and Linux
operating systems via pip by executing the instruction below at a command
line.

⬇

1pip install mitiq

Codeblock 1: Installing Mitiq through PyPI.

To test installation, one can run the following.

⬇

1import mitiq

2mitiq.about()

Codeblock 2: Testing installation & viewing package versions.

This code prints information about the Mitiq version, versions of installed
packages, and installation path.

⬇

Mitiq: A Python toolkit for implementing error mitigation on quantum computers

================================================

Authored by: Mitiq team, 2020 & later

(https://github.com/unitaryfund/mitiq)

Mitiq Version: 0.1.0

Cirq Version: 0.9.0.dev

NumPy Version: 1.18.5

SciPy Version: 1.4.1

PyQuil Version: 2.21.0

Qiskit Version: 0.15.1

Python Version: 3.6.8

Platform Info: Linux (x86_64)

Install Path: /path/to/mitiq/installation

Codeblock 3: Example output of Codeblock 2.

In this example output, we see several packages. The core requirements of
Mitiq are Cirq (used to internally represent and manipulate quantum circuits),
NumPy (used for general numerical procedures), and SciPy Virtanen  _et al._
(2020) (used for curve fitting). The remaining packages (pyQuil and Qiskit)
are optional quantum software packages which can interface with Mitiq.

Although Mitiq’s internal quantum circuit representation is a Cirq Circuit,
any supported quantum circuit types can be used with Mitiq. The current
supported circuit types are Cirq Circuits, Qiskit QuantumCircuits, and pyQuil
Programs. A Mitiq QPROGRAM is the union of all supported circuit
representations which are installed with Mitiq. For example, if Qiskit is the
only optional package installed, the QPROGRAM type will be the union of a Cirq
Circuit and a Qiskit QuantumCircuit. If pyQuil is also installed, the QPROGRAM
type will also include a pyQuil Program.

The source code for Mitiq is hosted on GitHub at

https://github.com/unitaryfund/mitiq

and is distributed with a permissive open-source software license: GNU GPL v.
3.0. More details about the software, packaging information, and guidelines
for contributing to Mitiq are included in Sec. V.

###  II.2 Main usage

To implement error mitigation techniques in Mitiq, we assume that the user has
a function which inputs a quantum circuit and returns the expectation value of
an observable. This is the noisy function whose errors Mitiq will help
mitigate. We refer to this function as an executor because it executes the
quantum circuit. The signature of this function should be as follows:

⬇

1def executor(circuit: mitiq.QPROGRAM) -> float:

Codeblock 4: Signature of an executor function which is used by Mitiq to
perform quantum error mitigation.

Mitiq treats the executor as a black box to mitigate the expectation value of
the observable returned by this function. The user is responsible for defining
the body of the executor, which generally involves:

  1. 1.

Running the circuit on a real or simulated QPU.

  2. 2.

Post-processing to compute an observable.

  3. 3.

Returning the observable as a floating point value.

Example executor functions are shown in Sec. IV.3. Because Mitiq treats the
executor as a black box, circuits can be run on any quantum processor
available to the user. We include benchmarks run on IBM and Rigetti quantum
processors as well as noisy simulators in Sec. III.

Figure 1: Overview of the zero-noise extrapolation pipeline in Mitiq. (a) An
input quantum program is converted into a set of noise-scaled programs defined
by a noise scaling method and a set of scale factors. (b) These noise-scaled
programs are executed on the back-end according to a user-defined executor
function (see Sec. IV.3 for examples) and return a set of noise-scaled
expectation values. (c) A classical inference technique is used to fit a curve
to these noise-scaled expectation values. Once the best-fit curve is
established, the zero-noise limit is returned to give an error-mitigated
expectation value.

Once the executor is defined, implementing zero-noise extrapolation (ZNE)
needs only a single line:

⬇

1from mitiq import execute_with_zne

2

3zne_value = execute_with_zne(circuit, executor)

Codeblock 5: Using Mitiq to perform zero-noise extrapolation. The circuit is a
supported quantum program type, and the executor is a function which executes
the circuit and returns an expectation value.

The execute_with_zne function uses the executor to evaluate the input circuit
at different noise levels, extrapolates back to the zero-noise limit and then
returns this value as an estimate of the noiseless observable. Figure 1 shows
a high-level workflow.

As described in Sec. IV, there are multiple techniques to scale the noise in a
quantum circuit and infer (extrapolate back to) the zero-noise limit. The
default noise scaling method used by execute_with_zne is random local unitary
folding Giurgica-Tiron  _et al._ (2020) (see Sec. IV.1), and the default
inference technique is Richardson extrapolation (see Sec. IV.2). Different
techniques can be specified as arguments to execute_with_zne as follows.

⬇

1zne_value = execute_with_zne(

2 circuit,

3 executor,

4 scale_noise=<noise scaling method>,

5 factory=<inference method>,

6)

Codeblock 6: Providing arguments to execute_with_zne to use different noise
scaling methods and inference techniques.

These code examples demonstrate the main usage of Mitiq. Alternatives to the
execute_with_zne function are described in Sec. V.1 — these alternatives
implement the same methods but offer different ways to call them which may be
more convenient, depending on context. For many applications, ZNE can
significantly improve the results of a noisy computation Giurgica-Tiron  _et
al._ (2020). In the following section, we show results of benchmarks using
Mitiq on IBM and Rigetti quantum processors as well as noisy simulators. We
then explain Mitiq’s noise scaling methods and inference techniques in more
detail.

##  III Benchmarks with Mitiq

###  III.1 Randomized benchmarking

Figure 2: Zero-noise extrapolation on two-qubit randomized benchmarking
circuits run on (a) the IBMQ “London” quantum processor and (b) the Rigetti
Aspen-8 quantum processor. Results are obtained from 50 randomized
benchmarking circuits which contain, on average, 97 single-qubit gates and 17
two-qubit gates for (a) and 19 single-qubit gates and 7 two-qubit gates for
(b). Noise is increased via random local unitary folding (see Sec. IV.1), and
markers show zero-noise values obtained by different extrapolation techniques
(see Sec. IV.2). (Note that some markers are staggered for visualization but
all are extrapolated to the zero-noise limit.) In this example, the true zero-
noise value is $\langle 00|\rho|00\rangle=1$. For (b), qubits 32 and 33 are
used on the Aspen-8 processor, while for (a) the same two qubits are not
necessarily used for each run. For Richardson extrapolation, we used only
three data points (first, middle, and last) to do the fitting.

Figure 2 shows the results from error mitigation on two-qubit randomized
benchmarking circuits run on both IBM and Rigetti quantum computers. The blue
curve shows the expectation value $\langle 00|\rho|00\rangle$ (which should be
1 for a noiseless circuit where $\rho=|00\rangle\langle 00|$) at different
noise levels, and markers show mitigated observable values obtained from
different inference techniques. Error bars show the standard deviation over
fifty independent runs.

In Fig. 2(a), the expectation value decays, on average, exponentially as noise
is increased by random local unitary folding described in Sec. IV.1. (Note
that such exponential decay is expected if a depolarizing noise model is
assumed.) Accordingly, exponential inference provides a zero-noise value
closest to the true noiseless value. In Fig. 2(b), the exponential decay is
less pronounced and quadratic extrapolation provides the best zero-noise
estimate in this case.

Depending on the noise model as well as base noise level, different inference
techniques can provide better zero-noise estimates. We discuss inference
techniques more in Sec. IV.2 and the limitations of zero-noise extrapolation
more in Sec. VI.1.

###  III.2 Potential energy surface of $H_{2}$

Figure 3: Unmitigated (a) and mitigated (b) energy surfaces of $H_{2}$. The
mitigated energy surfaces use zero-noise extrapolation with random local
unitary folding (see Sec. IV.1) and second-order polynomial inference (see
Sec. IV.2). Panel (c) quantifies the relative error of potential energy
surfaces as the $L_{2}$ distance $||E_{0}(r)-E_{p}(r)||_{2}/||E_{0}(r)||_{2}$
for different (simulated) depolarizing noise strengths $p$.

We now consider a canonical example of computing the potential energy surface
of molecular Hydrogen using the variational quantum eigensolver. We follow
Ref. O’Malley  _et al._ (2016) and use the minimal STO-6G basis and Bravyi-
Kitaev transformation to write the Hamiltonian for $\text{H}_{2}$ as

$H=g_{0}I+g_{1}Z_{0}+g_{2}Z_{1}+g_{3}Z_{0}Z_{1}+g_{4}X_{0}X_{1}+g_{5}Y_{0}Y_{1}.$
(1)

Here, $g_{i}$ are numerical coefficients which depend on the atomic separation
and $I,X,Y,$ and $Z$ are Pauli operators.

Figure 3(a) shows unmitigated energy surfaces at three different noise levels
while Fig. 3(b) shows the mitigated energy surfaces. To compute the mitigated
curves, we use zero-noise extrapolation with random local unitary folding (see
Sec. IV.1) and second-order polynomial inference (see Sec. IV.2). As can be
seen, the mitigated curves overlap with the true noiseless curve much more
closely than the unmitigated curves. The error is quantified in Fig. 3(c).

##  IV Library Structure:
Zero-noise extrapolation module

We now describe the Mitiq library in more detail. An overview of its
structure, shown in Fig. 4, includes two modules to interface with supported
quantum programming languages (Qiskit and pyQuil) as well as a module for
zero-noise extrapolation.

Zero-noise extrapolation was first introduced in Temme  _et al._ (2017); Li
and Benjamin (2017) and works by intentionally increasing (scaling) the noise
of a quantum computation to then extrapolate back to the zero-noise limit.
More specifically, let $\rho$ be a state prepared by a quantum circuit and
$E^{\dagger}=E$ be an observable. We wish to estimate $\text{Tr}[\rho
E]\equiv\langle E\rangle$ as though we had an ideal (noiseless) quantum
computer, but there is a base noise level $\gamma_{0}$ which prevents us from
doing so. For example, $\gamma_{0}$ could be the strength of a depolarizing
channel in the circuit. The idea of zero-noise extrapolation is to compute

$\langle E(\gamma_{i})\rangle=\langle E(\lambda_{i}\gamma_{0})\rangle$ (2)

where (real) coefficients $\lambda_{i+1}>\lambda_{i}$ scale the base noise
$\gamma_{0}$ of the quantum computer. After this, a curve is fit to the data
collected via Eq. (2) which is then extrapolated to the zero-noise limit. This
produces an estimate of the noiseless expectation value $\langle E\rangle$.

To implement zero-noise extrapolation, we thus need two subroutines:

  1. 1.

A means of scaling the noise $\gamma_{i}=\lambda_{i}\gamma_{0}$ for different
scale factors $\lambda_{i}$, and

  2. 2.

A means of fitting a curve to the noisy expectation values and extrapolating
to the zero-noise limit.

In the remainder of this section, we describe how these subroutines are
implemented in Mitiq, showing several methods for both noise scaling as well
as fitting/extrapolation, which we also refer to as inference.

Figure 4: Mitiq structure highlighting modules in red, functions in purple,
and classes in orange. The modules mitiq_qiskit and mitiq_pyquil are used to
interface with Qiskit and pyQuil, respectively, and the zne module contains
functionality for implementing zero-noise extrapolation.

###  IV.1 Noise scaling

In the first formulation of zero-noise extrapolation Temme  _et al._ (2017),
noise is scaled in superconducting processors by implementing pulses at lower
amplitudes for longer time intervals. Because most quantum programming
languages support gate-model circuits and not pulse-level access, it is
convenient to scale noise in a manner which acts on unitary gates instead of
underlying pulses. For this reason, Mitiq implements unitary folding,
introduced in Giurgica-Tiron  _et al._ (2020), as a noise scaling method.

####  IV.1.1 Unitary Folding

Unitary folding works by mapping gates (or groups of gates) $G$ to

$G\mapsto GG^{\dagger}G.$ (3)

This leaves the effect of the circuit invariant but increases its depth. If
$G$ is a subset of the gates in the circuit, we refer the process as local
folding. If $G$ is the entire circuit, we call it global folding.

In Mitiq, folding functions input a circuit and a scale factor — i.e., a
number to increase the depth of the circuit by. (In Eq. (2), each coefficient
$\lambda_{i}$ is a scale factor.) The minimum scale factor is one (which
corresponds to folding no gates), a scale factor of three corresponds to
folding all gates, and scale factors beyond three fold some or all gates more
than once.

For local folding, there is a degree of freedom for which gates to fold first.
This order in which gates are folded can affect how the noise is scaled and
thus the overall effectiveness of zero-noise extrapolation. Because of this,
Mitiq defines several local folding functions in mitiq.zne.scaling, including:

  1. 1.

fold_gates_from_left

  2. 2.

fold_gates_from_right

  3. 3.

fold_gates_at_random

We explain how these functions work with the following example. We first
define a circuit, here in Cirq, which for simplicity creates a Bell state.

⬇

1import cirq

2

3qreg = cirq.LineQubit.range(2)

4circ = cirq.Circuit(

5 cirq.ops.H.on(qreg[0]),

6 cirq.ops.CNOT.on(qreg[0], qreg[1])

7)

8print("Original circuit:", circ, sep="\n")

9# Original circuit:

10# 0: \---H---@---

11# |

12# 1: \-------X---

Codeblock 7: Defining a Bell state circuit in Cirq to be folded.

We can now use a local folding function, e.g. fold_gates_from_left, to fold
this circuit.

⬇

13from mitiq.zne import scaling

14

15folded = scaling.fold_gates_from_left(

16 circ, scale_factor=2.

17)

18print("Folded circuit:", folded, sep="\n")

19# Folded circuit:

20# 0: \---H---H---H---@---

21# |

22# 1: \---------------X---

Codeblock 8: Local folding from left on a Cirq circuit.

We see that the first Hadamard gate $H$ has been transformed as $H\mapsto
HH^{\dagger}H$, to scale the depth of the circuit by a factor of two.

In Mitiq, folding functions do not modify the input circuit. Because of this,
we can input the same circuit to fold_gates_from_right to see the effect of
this method.

⬇

23folded = scaling.fold_gates_from_right(

24 circ, scale_factor=2.

25)

26print("Folded circuit:", folded, sep="\n")

27# Folded circuit:

28# 0: \---H---@---@---@---

29# | | |

30# 1: \-------X---X---X---

Codeblock 9: Local folding from right on a Cirq circuit. The scaling module is
imported in Codeblock 8.

Here, we see that the second (CNOT) gate is folded instead of the first
(Hadamard) gate, as expected when we start folding from the right (or end) of
the circuit instead of the left (or start) of the circuit.

The fold_gates_at_random function folds gates according to the following
rules:

  1. 1.

Gates are selected at random and folded until the input scale factor is
reached.

  2. 2.

No gate is folded more than once for any scale factor less than or equal to
three.

We emphasize that, although these examples used a Cirq Circuit, circuits can
be defined in any supported quantum programming language and the interface is
the same as above. In addition to Cirq, Mitiq supports Qiskit Abraham  _et
al._ (2019) and pyQuil Smith  _et al._ (2016), and additional support will be
added in the future. By default, all folding functions return a circuit with
the same type as the input circuit.

In the previous examples, each folded gate counts equally in the folded
circuit depth. However, this may not be a reasonable assumption for realistic
hardware as different gates have different noise levels. Because of this, each
folding function in Mitiq supports “folding by fidelity.” This works by
passing an input dictionary of gate fidelities (either known or estimated) as
an optional argument to a folding function. More details on folding by
fidelity can be found in Mitiq’s documentation.

Finally, we mention global folding. In contrast to local folding which folds
subsets of gates, global folding folds the entire circuit until the input
scale factor is reached. Below we show an example of global folding using the
same Bell state circuit circ defined in Codeblock 7.

⬇

1from mitiq.zne.scaling import fold_global

2

3folded = fold_global(circ, scale_factor=3.)

4print("Folded circuit:", folded, sep="\n")

5# Folded circuit:

6# 0: \---H---@---@---H---H---@---

7# | | |

8# 1: \-------X---X-----------X---

Codeblock 10: Global folding on a Bell state circuit.

Here, we see that the entire Bell state circuit has been folded once to reach
the input scale factor of three. If the input scale factor is not reached by
an integer number of global folds, fold_global will fold a group of gates from
the end of the circuit such that the scale factor is reached.

####  IV.1.2 Using noise scaling methods in execute_with_zne

As mentioned in Sec. II.2, the default noise scaling method in
execute_with_zne is fold_gates_at_random. Different methods can be used by
passing an optional argument to execute_with_zne. For example, to use global
folding, one can do the following.

⬇

1from mitiq.zne import execute_with_zne

2from mitiq.zne.scaling import fold_global

3

4zne_value = execute_with_zne(

5 circuit,

6 executor,

7 scale_noise=fold_global

8)

Codeblock 11: Using zero-noise extrapolation with global folding by passing
fold_global as an optional argument to execute_with_zne. The circuit and
executor are as in Sec. II.2.

Depending on the noise model of the quantum processor, using a different
folding method may better scale the noise and lead to better results.

To end the discussion on noise scaling, we note that some scaling methods are
deterministic while some are non-deterministic. In particular, global folding
and local folding from left/right return the same folded circuit if the scale
factor is the same, but fold_gates_at_random can return different circuits for
the same scale factor. Because of this, the function execute_with_zne has
another optional argument num_to_average which corresponds to the number of
times to compute expectation values at the same scale factor. For example, if
num_to_average = 3, the noise scaling method is called three times at each
scale factor, and the expectation value at this scale factor is the average
over the three runs. Such averaging can smooth out effects due to non-
deterministic noise scaling and lead to better results in zero-noise
extrapolation. Fig. 3(b) uses fold_gates_at_random with num_to_average = 5.

###  IV.2 Classical inference: Factory objects

In Mitiq, a Factory object is a self-contained representation of a classical
inference technique. In effect, it performs the “extrapolation” part of zero-
noise extrapolation. This representation is hardware-agnostic and even
quantum-agnostic since it only deals with classical data — namely, the input
and output of a noisy computation. The main tasks of a factory are as follows:

  1. 1.

Compute the expectation value by running an executor function at a given noise
level, and record the result;

  2. 2.

Determine the next noise level at which the expectation value should be
computed;

  3. 3.

Perform classical inference using the history of noise levels and expectation
values to compute the zero-noise extrapolated value.

The structure of a Factory is designed to account for adaptive fitting
techniques in which the next noise level depends on the history of previous
noise levels and expectation values. In Mitiq, (adaptive) fitting techniques
in zero-noise extrapolation are represented by specific factory objects. All
built-in factories, summarized in Table 1, can be imported from the
mitiq.zne.inference module.

Class | Extrapolation Method
---|---
LinearFactory | Extrapolation with a linear fit.
RichardsonFactory | Richardson extrapolation.
PolyFactory | Extrapolation with a polynomial fit.
ExpFactory | Extrapolation with an exponential fit.
PolyExpFactory | Similar to ExpFactory but the exponent
| can be a non-linear polynomial.
AdaExpFactory | Similar to ExpFactory but the noise
| scale factors are adaptively chosen.
Table 1: Factories that can be imported from mitiq.zne.inference to perform
different extrapolation methods. More information is available in the Mitiq
documentation and an analysis of the different extrapolation methods can be
found in Ref. Giurgica-Tiron  _et al._ (2020).

####  IV.2.1 Using factories in execute_with_zne to perform different
extrapolation methods

We now show examples of performing zero-noise extrapolation with fitting
techniques defined by factories in Table 1. As mentioned in Sec. II.2, this is
done by providing a factory as an optional argument to execute_with_zne. To
instantiate a non-adaptive factory, we input the noise scale factors we want
to compute the expectation values at, as shown below for the LinearFactory.

⬇

1from mitiq.zne.inference import LinearFactory

2

3linear_factory = LinearFactory(

4 scale_factors=[1.0, 2.0, 3.0],

5)

Codeblock 12: Initializing a factory object.

Here the scale_factors define the noise levels at which to compute expectation
values during zero-noise extrapolation. This factory can now be used as an
argument in execute_with_zne as follows. As in Sec. II.2, the circuit is the
quantum program which prepares a state of interest and the executor is a
function which executes the circuit and returns the expectation value of an
observable.

⬇

6from mitiq.zne import execute_with_zne

7

8zne_value = execute_with_zne(

9 circuit,

10 executor,

11 factory=linear_factory

12)

Codeblock 13: Using a factory object as an optional argument of
mitiq.zne.execute_with_zne.

Instead of the default Richardson extrapolation at noise scale factors $1,2$
and $3$, this call to execute_with_zne will perform linear extrapolation at
the specified noise scale factors. As mentioned in Sec. IV.1, different noise
scaling methods can also be used with the optional argument scale_noise.

Most extrapolation techniques implemented in Mitiq are static (i.e., non-
adaptive) and can be instantiated in a similar manner as the LinearFactory.
For example, to use a second-order polynomial fit, we use a PolyFactory object
as follows.

⬇

1from mitiq.zne import execute_with_zne

2from mitiq.zne.inference import PolyFactory

3

4zne_value = execute_with_zne(

5 circuit,

6 executor,

7 factory=PolyFactory(

8 scale_factors=[1.0, 2.0, 3.0], order=2

9 )

10)

Codeblock 14: Instantiating a second-order PolyFactory.

Other static factories follow similar patterns but may have additional
arguments in their constructors. For example, ExpFactory can take in a value
for the horizontal asymptote of the exponential fit. For full details, see the
Mitiq documentation.

Last, we show an example of an adaptive fitting technique defined by the
AdaExpFactory. To use this method (introduced and described in Ref. Giurgica-
Tiron  _et al._ (2020)), we can do the following:

⬇

1from mitiq.zne import execute_with_zne

2from mitiq.zne.inference import AdaExpFactory

3

4zne_value = execute_with_zne(

5 circuit,

6 executor,

7 factory=AdaExpFactory(

8 scale_factor=2.0, steps=5

9 )

10)

Codeblock 15: Using execute_with_zne with an adaptive fitting technique.

Instead of a list of scale factors, here we provide the initial scale factor
and the rest are determined adaptively. The number of scale factors determined
is equal to the argument steps. Additional arguments which can be passed into
the AdaExpFactory are described in the Mitiq documentation.

####  IV.2.2 Using custom fitting techniques

A custom fitting technique can be used in Mitiq by defining a new factory
class which inherits from the abstract class mitiq.zne.inference.Factory (for
general techniques) or BatchedFactory (for static techniques). To get noise
scale factors and expectation values, the methods Factory.get_scale_factors()
and Factory.get_expectation_values() can be used.

Below, we define a static factory which performs a second-order polynomial fit
and forces the expectation value to be in the interval $[-1,1]$.

⬇

1import numpy as np

2from mitiq.zne.inference import BatchedFactory

3

4class MyFactory(BatchedFactory):

5 def reduce(self) -> float:

6 # Get scale factors and exp values

7 scale_factors = self.get_scale_factors()

8 exp_vals = self.get_expectation_values()

9

10 # Define the custom fit here!

11 coeffs = np.polyfit(

12 scale_factors, exp_vals, deg=2

13 )

14 zne_value = coeffs[-1]

15

16 # Return the ZNE value

17 return np.clip(zne_value, -1.0, 1.0)

Codeblock 16: Defining a custom fitting technique by creating a new factory
object.

This factory can now be used as an argument in execute_with_zne to use the
custom fitting technique. Other fitting techniques can be defined in a similar
manner as the code block above.

###  IV.3 Executor examples

For concreteness, we now include explicit examples of executor functions which
were introduced in Sec. II.2. As mentioned, an executor always accepts a
quantum program, sometimes accepts other arguments, and always returns an
expectation value as a float.

Our first executor is the one used in creating Fig. 2(a). This executor runs a
two-qubit circuit on an IBMQ quantum processor and returns the probability of
the ground state.

⬇

1import qiskit

2

3provider = qiskit.IBMQ.load_account()

4

5def executor(

6 circuit: qiskit.QuantumCircuit,

7 backend_name: str = "ibmq_london",

8 shots: int = 1024

9) -> float:

10 # Execute the circuit

11 job = qiskit.execute(

12 experiments=circuit,

13 backend=provider.get_backend(backend_name),

14 optimization_level=0,

15 shots=shots

16 )

17

18 # Get the measurement data

19 counts = job.result().get_counts()

20

21 # Return the observable

22 return counts["00"] / shots

Codeblock 17: Defining an executor to run on IBMQ and return the probability
of the ground state for a two-qubit circuit. Line 2 requires a valid IBMQ
account with saved credentials. We assume that the input circuit contains
terminal measurements on both qubits.

We also include the same executor function as above but this time running on
Rigetti Aspen-8 and used in creating Fig. 2(b). Note that this executor
requires additional steps compared to the same executor in Qiskit — namely the
declaration of classical memory and the addition of measurement operations, as
Rigetti QCS handles classical memory different than other platforms.
Additionally, it is important to note the use of basic_compile from Mitiq
which preserves folded gates when mapping to the native gate set of Aspen-8.

⬇

1import pyquil

2from mitiq.mitiq_pyquil.compiler import basic_compile

3

4aspen8 = pyquil.get_qc("Aspen-8", as_qvm=False)

5

6def executor(

7 program: pyquil.Program,

8 active_reset: bool = True,

9 shots: int = 1024

10) -> float:

11 prog = Program()

12

13 # Force qubits into the ground state

14 if active_reset:

15 prog += pyquil.gates.RESET()

16

17 # Add the original program

18 prog += program.copy()

19

20 # Get list of qubits used in the program

21 qubits = prog.get_qubits()

22

23 # Add classical memory declaration

24 ro = prog.declare("ro", "BIT", len(qubits))

25

26 # Add measurement operations

27 for idx, q in enumerate(qubits):

28 prog += MEASURE(q, ro[idx])

29

30 # Add number of shots

31 prog.wrap_in_numshots_loop(shots)

32

33 # Compile the program, keeping folded gates

34 prog = basic_compile(prog)

35

36 # Convert to an executable and run

37 executable = aspen8.compiler. native_quil_to_executable(prog)

38 results = aspen8.run(executable)

39

40 # Return the observable

41 all_zeros = [sum(b) == 0 for b in results]

42 return sum(all_zeros) / shots

Codeblock 18: Defining an executor to run on Rigetti Aspen-8 and return the
probability of the ground state. Line 3 requires a Rigetti Quantum Cloud
Services (QCS) Karalekas  _et al._ (2020) account and reservation. We assume
that the input program has no measurements, resets, or classical memory
declarations.

In these examples, we see how the executor function abstracts away details
about running on a back-end. This abstraction makes Mitiq compatible with
multiple quantum processors using the same interface.

The executor function does not have to use a real quantum processor but
instead can use a classical simulator. In this case, the executor is also
responsible for adding noise to the circuit. The manner in which noise is
added depends on the quantum programming library being used. We show below an
example of an executor which adds depolarizing noise to a Cirq circuit and
uses density matrix simulation. This executor inputs an arbitrary observable
defined by a cirq.PauliString and returns its expectation value by sampling.

⬇

1import cirq

2

3dsim = cirq.DensityMatrixSimulator()

4

5def executor(

6 circ: Circuit,

7 obs: cirq.PauliString,

8 noise: float = 0.01,

9 shots: int = 1024

10) -> float:

11 # Add depolarizing noise to the circuit

12 noisy = circ.with_noise(

13 cirq.depolarize(p=noise)

14 )

15

16 # Do the sampling

17 psum = cirq.PauliSumCollector(

18 noisy,

19 obs,

20 samples_per_term=shots

21 )

22 psum.collect(sampler=dsim)

23

24 # Return the expectation value

25 return psum.estimated_energy()

Codeblock 19: Cirq executor function based on a density matrix simulation with
depolarizing noise and sampling. The observable is defined via
cirq.PauliString.

Other noise models can be easily substituted into this executor by changing
the channel in Line 13 from cirq.depolarize to a different channel, e.g.
cirq.amplitude_damp. Executors using classical simulators in other quantum
programming languages (e.g., Qiskit or pyQuil) can be defined in an analogous
way, although each handles noise in different manners.

Finally, we note that executor functions provided to execute_with_zne must
have only a single argument: the quantum program. The examples above include
additional arguments, and it is often convenient to write executors this way.
To make an executor with multiple arguments a function of one argument, we can
use functools.partial as shown below.

⬇

1from functools import partial

2

3def executor(qprogram, arg1, arg2) -> float:

4 ...

5

6new_executor = partial(

7 executor,

8 arg1=arg1value,

9 arg2=arg2value

10)

Codeblock 20: Converting a multi-argument executor to a single-argument
executor to use with execute_with_zne. The functools library is a built-in
Python library.

The new_executor is now a function of a single argument (the quantum program)
and can be used directly with mitiq.zne.execute_with_zne.

##  V Additional library information

In this section we provide technical details and meta-information about the
Mitiq library.

###  V.1 Alternative ways to use zero-noise extrapolation

Here we show two alternative methods for performing zero-noise extrapolation
in Mitiq. Depending on context, these may provide simpler usage than the
execute_with_zne function.

The first method is mitigate_executor which inputs the executor and the same
optional arguments as execute_with_zne except the quantum program. This
function returns a new executor which implements zero-noise extrapolation when
it is called with a quantum program, as shown below.

⬇

1from mitiq.zne import mitigate_executor

2

3mitigated_executor = mitigate_executor(

4 executor,

5 scale_noise=<noise scaling method>,

6 factory=<inference method>

7)

8

9zne_value = mitigated_executor(circuit)

Codeblock 21: Modifying an executor using the function mitigate_executor. The
new mitigated_executor performs zero-noise extrapolation when called on a
quantum program.

The second method is to decorate the executor with mitiq.zne.zne_decorator
such that it automatically performs zero-noise extrapolation when called.

⬇

1from mitiq import QPROGRAM

2from mitiq.zne import zne_decorator

3

4@zne_decorator(

5 factory=<inference method>,

6 scale_noise=<noise scaling method>

7)

8def executor(circuit: QPROGRAM) -> float:

9 ...

10

11zne_value = executor(circuit)

Codeblock 22: Decorating an executor using zne_decorator so that zero-noise
extrapolation is implemented when the executor is called on a quantum program

Again the zne_decorator takes the same optional arguments as execute_with_zne.
If no optional arguments are used, the decorator should still be called with
parentheses, i.e. @zne_decorator().

###  V.2 Mitiq documentation

Mitiq’s documentation is hosted online at https://mitiq.readthedocs.io and
includes a User’s Guide and an API glossary. The User’s Guide contains more
information on topics covered in this manuscript and additional information on
topics not covered here, for example more examples of executor functions and
an advanced usage guide for factory objects. The API glossary is self-
generated from the docstrings (formatted comments to code objects) and
contains information about public functions and classes defined in Mitiq.

###  V.3 Contribution guidelines

We welcome contributions to Mitiq from the larger community of quantum
software developers. Contributions can come in the form of feedback about the
library, feature requests, bug fixes, or pull requests. Feedback and feature
requests can be done by opening an issue on the Mitiq GitHub repository. Bug
fixes and other pull requests can be done by forking the Mitiq source code,
making changes, then opening a pull request to the Mitiq GitHub repository.
Pull requests are peer-reviewed by core developers to provide feedback and/or
request changes. Contributors are expected to uphold Mitiq development
practices including style guidelines and unit tests. More details can be found
in the Contribution guidelines documentation.

##  VI Discussion

Now that we have described error mitigation techniques in Mitiq and how to use
them, we discuss limitations of these techniques as well as the relation
between zero-noise extrapolation and additional strategies.

###  VI.1 Limitations of zero-noise extrapolation

Zero-noise extrapolation is a useful error mitigation technique but it is not
without limitations. First and foremost, the zero-noise estimate is
extrapolated, meaning that performance guarantees are quite difficult in
general. If a reasonable estimate of how increasing the noise affects the
observable (e.g., the blue curves in Fig. 2) is known, then ZNE can produce
good zero-noise estimates. This is the case for simple noise models such as
depolarizing noise, but noise in actual quantum systems is more complicated
and can produce different behavior than expected, e.g. Fig 2(b). In this case
the performance of ZNE is tied to the performance of the underlying hardware.
If expectation values do not produce a smooth curve as noise is increased, the
zero-noise estimate may be poor and certain inference techniques may fail. In
particular, one has to take into account that any initial error in the
measured expectation values will propagate to the zero-noise extrapolation
value. This fact can significantly amplify the final estimation uncertainty.
In practice, this implies that the evaluation of a mitigated expectation value
requires more measurement shots with respect to the unmitigated one.

Additionally, zero-noise extrapolation cannot increase the performance of
arbitrary circuits. If the circuit is large enough such that the expectation
of the observable is almost constant as noise is increased (e.g., if the state
is maximally mixed), then extrapolation will of course not help the zero-noise
estimate. The regime in which ZNE is applicable thus depends on the
performance of the underlying hardware as well as the circuit. A detailed
description of when zero-noise extrapolation is effective, and how effective
it is, is the subject of ongoing research.

###  VI.2 Relation to other error mitigation techniques

Zero-noise extrapolation is one of several methods for quantum error
mitigation. It was first proposed in Temme  _et al._ (2017); Li and Benjamin
(2017) and first demonstrated experimentally in Kandala  _et al._ (2019).
References Giurgica-Tiron  _et al._ (2020); Cai (2020) have extended the noise
scaling and extrapolation techniques. Additionally, these references and this
paper show experimental demonstrations of zero-noise extrapolation and how it
can improve the results of noisy quantum computations.

The purposeful randomization of gates is another approach to quantum error
mitigation. Specific techniques include compiling the quantum circuit with
twirling gates Wallman and Emerson (2016), expressing noiseless gates in a
basis of noisy gates as in probabilistic error cancellation Temme  _et al._
(2017), and a hybrid proposal improving the scaling of the technique with
circuit depth and other resources Endo  _et al._ (2018). Such techniques have
been investigated experimentally in trapped ions Zhang  _et al._ (2020) and
superconducting qubits Sun  _et al._ (2020) (implementing gate set
tomography).

Subspace expansion refers to another set of error mitigation techniques. In
Ref. McClean  _et al._ (2017), a hybrid quantum-classical hierarchy was
introduced, while in Ref. Bonet-Monroig  _et al._ (2018), symmetry
verification was introduced. It has been demonstrated with a stabilizer-like
method McArdle  _et al._ (2019), exploiting molecular symmetries McClean  _et
al._ (2020), and with an experiment on a superconducting circuit device
Sagastizabal  _et al._ (2019). Other error mitigation techniques include
approximating error-correcting codes in quantum channels Cafaro and van Loock
(2014), and have been extended to improve quantum sensing Otten and Gray
(2019), metrology Zhou and Jiang (2020), and reduce errors in analog quantum
simulation Sun  _et al._ (2020).

###  VI.3 Relation to quantum error correction

Quantum error mitigation is connected to quantum error correction and quantum
optimal control, two fields of study that also aim at reducing the impact of
errors in quantum information processing in quantum computers. While these are
fluid boundaries, it can be useful to point out some differences among these
two well-established fields and the emerging field of quantum error
mitigation.

Quantum error correction creates logical qubits out of multiple error-prone
physical qubits. After applying logical operations which correspond to the
physical operations we want to perform in our circuit, ancilla qubits are
measured to diagnose which (if any) errors occurred. Depending on the outcome
of these “syndrome measurements,” correction operations are performed to
remove the errors (if any) that occurred. If the error rate lies below a
certain threshold, errors can be actively removed. We can thus say that the
goal of error correction is to detect and exactly correct errors, while the
goal of error mitigation is to lessen the effect of errors.

The drawback of quantum error correction techniques is that they require a
large overhead in terms of additional physical qubits needed to create logical
qubits. Current quantum computing devices have been able to demonstrate some
components of quantum error correction with a very small number of qubits Gong
_et al._ (2019); Schindler  _et al._ (2011). Indeed, some techniques for
quantum error mitigation emerged as more practical quantum error correction
solutions Knill (2005).

###  VI.4 Relation to quantum optimal control

Optimal control theory encompasses a versatile set of techniques that can be
applied to many scenarios in quantum technology Brif  _et al._ (2010). It is
generally based on a feedback loop between an agent and a target system. A key
difference between some quantum error mitigation techniques and quantum
optimal control is that the former can be implemented in some instances with
post-processing techniques, while the latter relies on an active feedback
loop. An example of a specific application of optimal control to quantum
dynamics that can be seen as a quantum error mitigation technique is dynamical
decoupling Santos and Viola (2005); Viola and Knill (2005); Pokharel  _et al._
(2018). This technique employs fast control pulses to effectively decouple a
system from its environment, with techniques pioneered in the nuclear magnetic
resonance community Viola  _et al._ (1999). Quantum optimal control techniques
are being integrated in the quantum computing software as a means for and
noise characterization and error mitigation Ball  _et al._ (2020).

###  VI.5 Relation to the theory of open quantum systems

More in general, quantum computing devices can be studied in the framework of
open quantum systems Carmichael (1999, 2007); Breuer and Petruccione (2007),
that is, systems that exchange energy and information with the surrounding
environment. On one hand, the qubit-environment exchange can be controlled,
and this feature is actually fundamental to extract information and process
it. On the other hand, when this interaction is not controlled — and at the
fundamental level it cannot be completely suppressed — noise eventually kicks
in, thus introducing errors that are disruptive for the fidelity of the
information-processing protocols.

Indeed, issues arise in quantum computation due to the fact that quantum
computers are devices that are embedded in an environment and interact with
it. This means that stored information can be corrupted or that desired
programs are not necessarily faithfully executed during a computation.

Errors occur for several reasons in quantum computers, and the microscopic
description at the physical level can vary broadly, depending on the quantum
computing platform that is used as well as the computing architecture. For
example, superconducting-circuit-based quantum computers have chips that are
prone to cross-talk noise Murali  _et al._ (2020), while qubits encoded in
trapped ions need to be shuttled with electromagnetic pulses, and solid-state
artificial atoms, including quantum dots, are heavily affected by
inhomogeneous broadening Buluta  _et al._ (2011).

##  VII Conclusion

We have introduced a fully open-source library for quantum error mitigation
using zero-noise extrapolation. Our library can interface with multiple
quantum programming libraries — in particular Cirq, Qiskit, and pyQuil — and
arbitrary quantum processors (real or simulated) available to the user. In
this paper, we have demonstrated improved quantum computation using zero-noise
extrapolation on two benchmarks. We then discussed the library in detail,
demonstrating through code examples the noise scaling methods and inference
techniques in the zero-noise extrapolation module. After mentioning additional
software information including support and contribution guidelines, we
discussed how the error mitigation techniques in our library relate to other
error mitigation techniques as well as quantum error correction, quantum
optimal control, and the theory of open quantum systems.

In future work, we plan to incorporate additional error mitigation techniques
into the library and to expand the set of benchmarks to better understand when
quantum error mitigation is beneficial. Work can also be done to improve the
zero-noise extrapolation module, for example by implementing different noise-
scaling methods or inference techniques. One candidate noise-scaling method is
pulse stretching which will be possible when pulse-level access to quantum
hardware becomes available through more cloud services Alexander  _et al._
(2020). A high-level road map for future development which includes more
information on these ideas as well as other ideas can be found on the Mitiq
Wiki.

## Acknowledgements

This material is based upon work supported by the U.S. Department of Energy,
Office of Science, Office of Advanced Scientific Computing Research,
Accelerated Research in Quantum Computing under Award Number de-sc0020266 and
by IBM under Sponsored Research Agreement No. W1975810. RL acknowledges
support from a NASA Space Technology Graduate Research Opportunities Award. We
thank IBM and Rigetti for providing access to their quantum computers. The
views expressed in this paper are those of the authors and do not reflect
those of IBM or Rigetti.

## References

  * Temme  _et al._ (2017) K. Temme, S. Bravyi, and J. M. Gambetta,  _Error mitigation for short-depth quantum circuits,_Physical Review Letters 119 (2017), 10.1103/physrevlett.119.180509.
  * Li and Benjamin (2017) Y. Li and S. C. Benjamin,  _Efficient variational quantum simulator incorporating active error minimization,_Phys. Rev. X 7, 021050 (2017).
  * Endo  _et al._ (2018) S. Endo, S. C. Benjamin, and Y. Li,  _Practical quantum error mitigation for near-future applications,_ Physical Review X 8, 031027 (2018).
  * Santos and Viola (2005) L. F. Santos and L. Viola,  _Dynamical control of qubit coherence: Random versus deterministic schemes,_ Physical Review A 72, 062303 (2005).
  * Viola and Knill (2005) L. Viola and E. Knill,  _Random decoupling schemes for quantum dynamical control and error suppression,_ Physical review letters 94, 060502 (2005).
  * Pokharel  _et al._ (2018) B. Pokharel, N. Anand, B. Fortman, and D. A. Lidar,  _Demonstration of fidelity improvement using dynamical decoupling with superconducting qubits,_ Physical Review Letters 121, 220502 (2018).
  * Wallman and Emerson (2016) J. J. Wallman and J. Emerson,  _Noise tailoring for scalable quantum computation via randomized compiling,_ Physical Review A 94, 052325 (2016).
  * McClean  _et al._ (2020) J. R. McClean, Z. Jiang, N. C. Rubin, R. Babbush, and H. Neven,  _Decoding quantum errors with subspace expansions,_Nature Communications 11 (2020), 10.1038/s41467-020-14341-w.
  * Kandala  _et al._ (2019) A. Kandala, K. Temme, A. D. Córcoles, A. Mezzacapo, J. M. Chow, and J. M. Gambetta,  _Error mitigation extends the computational reach of a noisy quantum processor,_Nature 567, 491 (2019).
  * Giurgica-Tiron  _et al._ (2020) T. Giurgica-Tiron, Y. Hindy, R. LaRose, A. Mari, and W. J. Zeng,  _Digital zero noise extrapolation for quantum error mitigation,_ arXiv preprint arXiv:2005.10921 (2020).
  * Urbanek  _et al._ (2019) M. Urbanek, B. Nachman, and W. A. de Jong,  _Quantum error detection improves accuracy of chemical calculations on a quantum computer,_arXiv:1910.00129 [physics, physics:quant-ph] (2019), arXiv: 1910.00129.
  * (12) C. Vuillot,  _Is error detection helpful on ibm 5q chips?_Quantum Information and Computation 18, 10.26421/QIC18.11-12, arXiv: 1705.08957.
  * Quantum  _et al._ (2020) G. A. Quantum _et al._ ,  _Hartree-Fock on a superconducting qubit quantum computer,_ Science 369, 1084 (2020).
  * Ho and Bacon (2018) A. Ho and D. Bacon,  _Announcing Cirq: An open-source framework for NISQ algorithms,_ (2018).
  * Abraham  _et al._ (2019) H. Abraham _et al._ , Qiskit: An open-source framework for quantum computing,  (2019).
  * Smith  _et al._ (2016) R. S. Smith, M. J. Curtis, and W. J. Zeng, A practical quantum instruction set architecture, (2016), arXiv:1608.03355 [quant-ph] .
  * Karalekas  _et al._ (2020) P. J. Karalekas, N. A. Tezak, E. C. Peterson, C. A. Ryan, M. P. da Silva, and R. S. Smith,  _A quantum-classical cloud platform optimized for variational hybrid algorithms,_Quantum Science and Technology 5, 024003 (2020).
  * Virtanen  _et al._ (2020) P. Virtanen _et al._ ,  _SciPy 1.0: fundamental algorithms for scientific computing in Python,_Nature Methods 17, 261 (2020).
  * O’Malley  _et al._ (2016) P. J. J. O’Malley, R. Babbush, I. D. Kivlichan, J. Romero, J. R. McClean, R. Barends, J. Kelly, P. Roushan, A. Tranter, N. Ding, and et al.,  _Scalable quantum simulation of molecular energies,_Physical Review X 6 (2016), 10.1103/PhysRevX.6.031007, arXiv: 1512.06860.
  * Cai (2020) Z. Cai,  _Multi-exponential error extrapolation and combining error mitigation techniques for nisq applications,_ arXiv preprint arXiv:2007.01265 (2020).
  * Zhang  _et al._ (2020) S. Zhang, Y. Lu, K. Zhang, W. Chen, Y. Li, J.-N. Zhang, and K. Kim,  _Error-mitigated quantum gates exceeding physical fidelities in a trapped-ion system,_Nature Communications 11 (2020), 10.1038/s41467-020-14376-z.
  * Sun  _et al._ (2020) J. Sun, X. Yuan, T. Tsunoda, V. Vedral, S. C. Bejamin, and S. Endo, Practical quantum error mitigation for analog quantum simulation, (2020), arXiv:2001.04891 [quant-ph] .
  * McClean  _et al._ (2017) J. R. McClean, M. E. Kimchi-Schwartz, J. Carter, and W. A. de Jong,  _Hybrid quantum-classical hierarchy for mitigation of decoherence and determination of excited states,_Phys. Rev. A 95, 042308 (2017).
  * Bonet-Monroig  _et al._ (2018) X. Bonet-Monroig, R. Sagastizabal, M. Singh, and T. E. O’Brien,  _Low-cost error mitigation by symmetry verification,_Phys. Rev. A 98, 062339 (2018).
  * McArdle  _et al._ (2019) S. McArdle, X. Yuan, and S. Benjamin,  _Error-mitigated digital quantum simulation,_Phys. Rev. Lett. 122, 180501 (2019).
  * Sagastizabal  _et al._ (2019) R. Sagastizabal, X. Bonet-Monroig, M. Singh, M. A. Rol, C. C. Bultink, X. Fu, C. H. Price, V. P. Ostroukh, N. Muthusubramanian, A. Bruno, M. Beekman, N. Haider, T. E. O’Brien, and L. DiCarlo,  _Experimental error mitigation via symmetry verification in a variational quantum eigensolver,_Phys. Rev. A 100, 010302 (2019).
  * Cafaro and van Loock (2014) C. Cafaro and P. van Loock,  _Approximate quantum error correction for generalized amplitude-damping errors,_Phys. Rev. A 89, 022316 (2014).
  * Otten and Gray (2019) M. Otten and S. K. Gray,  _Recovering noise-free quantum observables,_Phys. Rev. A 99, 012338 (2019).
  * Zhou and Jiang (2020) S. Zhou and L. Jiang,  _Optimal approximate quantum error correction for quantum metrology,_Phys. Rev. Research 2, 013235 (2020).
  * Gong  _et al._ (2019) M. Gong, X. Yuan, S. Wang, Y. Wu, Y. Zhao, C. Zha, S. Li, Z. Zhang, Q. Zhao, Y. Liu, and et al.,  _Experimental verification of five-qubit quantum error correction with superconducting qubits,_arXiv:1907.04507 [quant-ph] (2019), arXiv: 1907.04507.
  * Schindler  _et al._ (2011) P. Schindler, J. T. Barreiro, T. Monz, V. Nebendahl, D. Nigg, M. Chwalla, M. Hennrich, and R. Blatt,  _Experimental repetitive quantum error correction,_Science 332, 1059–1061 (2011).
  * Knill (2005) E. Knill,  _Quantum computing with realistically noisy devices,_Nature 434, 39–44 (2005).
  * Brif  _et al._ (2010) C. Brif, R. Chakrabarti, and H. Rabitz,  _Control of quantum phenomena: past, present and future,_New Journal of Physics 12, 075008 (2010).
  * Viola  _et al._ (1999) L. Viola, E. Knill, and S. Lloyd,  _Dynamical decoupling of open quantum systems,_Physical Review Letters 82, 2417–2421 (1999).
  * Ball  _et al._ (2020) H. Ball, M. J. Biercuk, A. Carvalho, R. Chakravorty, J. Chen, L. A. de Castro, S. Gore, D. Hover, M. Hush, P. J. Liebermann, _et al._ ,  _Software tools for quantum control: Improving quantum computer performance through noise and error suppression,_ arXiv preprint arXiv:2001.04060 (2020).
  * Carmichael (1999) H. J. Carmichael,  _Statistical Methods in Quantum Optics 1: Master Equations and Fokker-Planck Equations_ (Springer-Verlag, 1999).
  * Carmichael (2007) H. Carmichael,  _Statistical Methods in Quantum Optics 2: Non-Classical Fields_ (Springer Berlin Heidelberg, 2007).
  * Breuer and Petruccione (2007) H. Breuer and F. Petruccione,  _The Theory of Open Quantum Systems_ (OUP Oxford, 2007).
  * Murali  _et al._ (2020) P. Murali, D. C. Mckay, M. Martonosi, and A. Javadi-Abhari,  _Software mitigation of crosstalk on noisy intermediate-scale quantum computers,_Proceedings of the Twenty-Fifth International Conference on Architectural Support for Programming Languages and Operating Systems (2020), 10.1145/3373376.3378477.
  * Buluta  _et al._ (2011) I. Buluta, S. Ashhab, and F. Nori,  _Natural and artificial atoms for quantum computation,_Reports on Progress in Physics 74, 104401 (2011).
  * Alexander  _et al._ (2020) T. A. Alexander, N. Kanazawa, D. J. Egger, L. Capelluto, C. J. Wood, A. Javadi-Abhari, and D. McKay,  _Qiskit-Pulse: programming quantum computers through the cloud with pulses,_Quantum Sci. and Tech. (2020), 10.1088/2058-9565/aba404.