Error-Mitigated Digital Quantum Simulation

Variational algorithms may enable classically intractable simulations on near-future quantum computers. However, their potential is limited by hardware errors. It is therefore crucial to develop efficient ways to mitigate these errors. Here, we propose a stabilizerlike method which enables the detection of up to 60% – 80% of depolarizing errors. Our method is suitable for near-term quantum hardware. Simulations show that our method can significantly benefit calculations subject to both stochastic and correlated noise, especially when combined with existing error mitigation techniques.

Unlike their classical counterparts, quantum computers can efficiently simulate large quantum systems [1][2][3].For example, using a quantum computer, we can efficiently find the ground states of systems such as the Fermi-Hubbard model or molecules [4].Accurately determining the ground states of quantum systems is a first step towards developing new materials [5], better catalysts [6] and more effective medicines [7].On first inspection, transformative simulations seem tantalisingly close, requiring only around 100 logical qubits [6].However, the required gate depth, on the order of 10 12 [8][9][10], necessitates at least one million physical qubits for error correction (based on current error rates) [6,11], which is many years beyond our current capabilities.
In contrast, hybrid algorithms, such as the variational quantum eigensolver (VQE) [12][13][14], may not require error correction [15].These algorithms exchange the long gate sequences described above for a polynomial number of short circuits, which dramatically reduces the coherence time required.While previous small experimental demonstrations of the VQE have shown it to be resilient to systematic errors [16], larger experiments have shown that noise can corrupt results [17,18].This is perhaps unsurprising; depending on the problem tackled, errors can add or remove particles, changing the system being simulated, and increasing the number of repititions needed to obtain a precise result [19].
While error correction is needed to fully suppress these errors, this requires considerable additional resources [20].Alternatively, error rates can be lowered by improving the hardware directly.However, this is an enormous challenge; decades of research has reduced error rates to 0.1 %, but this has not been improved in several years [21][22][23].While efforts to improve error rates continue worldwide, software based methods to effectively reduce error rates are clearly invaluable.
To date, several methods for mitigating errors in nearterm quantum hardware have been proposed: the linear [24,25] and exponential [26] extrapolation methods, the quasi-probability method [25,26] and the quantum subspace expansion (QSE) [27].The linear extrapolation method and QSE have recently been experimentally demonstrated [28,29], and were successful in accurately finding the ground states of small molecules in the presence of noise.However, these schemes are generally limited to low error rates, where the number of errors expected in the circuit is on the order of unity.
Motivated by this limitation, we have developed a new scheme for error mitigation.Our method uses stabiliser checks on a suitably constructed trial state to filter errors.It can be used in isolation to improve the accuracy of calculations, or can be used to extend the range of applicability of previous error mitigation techniques.We numerically demonstrate our method in an electronic structure calculation on the hydrogen molecule.Our method is low cost, and so can be immediately incorporated into experiments.
Conventional VQE.-We can use the VQE to find the ground state energy of physical Hamiltonians (see Supplementary Materials).In molecular simulations, we seek to arrange N electrons among M spin-orbitals, such that the energy of the system is minimised.Here, we use the Jordan-Wigner (JW) mapping, where each qubit represents an electron spin-orbital, the occupation number of which is stored in the |0 or |1 state of the qubit (unoccupied or occupied, respectively).For example, we can write a state describing the hydrogen molecule (H 2 ) as (see Supplementary Materials) where α, β, γ, δ are complex coefficients.The Hamiltonian can be written as a linear combination of products of Pauli operators, H = i g i ĥi , where g i is a scalar coefficient determining the strength of the term.An example of a typical term is ĥi = X 0 Y 1 Y 2 X 3 .
The VQE, as proposed in Ref. [12], augments a small quantum processor with a powerful classical computer.The quantum computer is used for classically intractable state preparation, and energy measurement.The state preparation circuit consists of a number of parametrised gates.The circuit used is known as the ansatz, denoted by U ( θ).This circuit produces a trial state, |ψ( θ) .The values of the parameters and the energy of the state they create are input into a classical optimisation algorithm, which seeks the ground state.The energy is calculated by summing the expectation values of each term in the Hamiltonian.To obtain each expectation value, we repeatedly perform the circuit, measure the state produced, and reinitialise.
Stabiliser-VQE.-In variational simulations, it is often beneficial to initialise the register in a mean-field state, and use a particle-number and spin conserving ansatz [30,31].This produces states with the correct number of: electrons, N , spin-up electrons, N ↑ , and spindown electrons, N ↓ .We refer to these states as 'physical' states.These physical states are eigenvectors of the electron number, spin-up number, and spin-down number operators.As these quantities are conserved, their relevant parity operators are also conserved; PN |ψ = P N |ψ = (−1) N |ψ and PN ↑/↓ |ψ = P N ↑/↓ |ψ = (−1) N ↑/↓ |ψ .In analogy with error correcting codes, the states generated by the ansatz are said to be stabilised by these three parity operators [32].
There are some ansatze, such as those suggested in Ref. [31] which are constructed from individual gates which conserve particle number and spin.If a single bit-flip error occurs, it will create or destroy an electron, radically changing the state.For other number and spin conserving ansatze, like the unitary coupled cluster (UCC) ansatz (which, in its canonical form [33], is constructed from individual gates which do not necessarily conserve particle number), a single error can propagate and degrade the final state even further.A key concern for the VQE is preserving particle number, as states with electron number far from the true value appear to have a larger energy variance than those with smaller particle number errors [19].We present below a method of detecting and removing some of these damaging errors, while still retaining the low qubit resources and gate count of the VQE.
In order to detect errors, we introduce an ancilla qubit, and use it to perform measurements of the conserved quantities.When deriving error detection rates, we make the following assumptions: 1. Errors are symmetric and depolarising.2. The error rate is low, such that only one gate malfunctions.3. The ansatz circuit is built from individual gates which conserve particle number and spin.4. Single qubit gate error rates are negligible compared to two qubit gate error rates.
While our method is still applicable under higher noise rates, different noise models, and using other number conserving ansatze, calculating an analytic bound becomes more difficult without these assumptions.
The most simple stabiliser measurement checks the total electron number parity.This procedure is shown A circuit to check the particle number parity of a physical trial state.The ancilla should be measured in | 1 2 (1 − (−1) N ) .If errors occur, and the measured value of the ancilla is not correct, the measurement of the Hamiltonian term ĥi on the register is not performed, and the circuit is reinitialised.The register is initialised in a mean-field state.
in Fig. 1, and enables the detection of any error which changes the electron number parity by one.Under the assumptions described above, we are able to detect and remove 53 % of error events (8/15 errors in the depolarising noise model, as described in the Supplementary Materials).In the Supplementary Materials we present an alternative circuit for this parity check, which can reduce the impact of qubit readout errors.The qubit readout error rate is currently around 1 % for superconducting qubits [34].This alternative circuit also makes it possible to combine our method with existing variational algorithms for real [24] and imaginary [35] time evolution.
To increase the proportion of errors detected, we can perform the circuit shown in Fig. 2 which measures both the spin-up parity and spin-down parity.This enables us to detect additional two qubit bit flip errors that we were unable to detect using the single parity check above.This means that we can effectively filter out 66 % of errors (10/15 two qubit gate errors in the depolarising noise model, as shown in the Supplementary Materials).
A circuit to measure the spin parities.We compute the spin-up parity onto the ancilla, and measure it.We then reset the ancilla to |0 , and measure the spin-down parity.
We can also measure the electron number and spin numbers directly, using an iterative procedure.We first write the electron number in binary.We then use the circuit in Fig. 3 to measure the first bit in N , by setting m = 1.We denote the bit value measured as N 1 .We then repeat the circuit in Fig. 3 to measure the second bit in N , by setting m = 2, and using our measurement of N 1 in the rotation ω 2 .In general, we can measure the m th bit of N using the circuit in Fig. 3, constructing ω m using our measurements of the m − 1 preceeding bits in N .When no errors have occured, the ancilla is in the state If N m = 0 we measure the ancilla in |+ , while if N m = 1 we measure the ancilla in |− .A worked example for N = 3 is given in the Supplementary Materials.We can measure the spin numbers using a similar procedure.
The circuit which measures the m th bit of the electron number, Nm.The Rm gates are given by diag(1, e πi/2 m−1 ).The gate ωm is given by diag(1, e −dec(N m−1 ...N 1 )πi/2 m−1 ), where dec(Nm−1 . . .N1) is the decimal representation of the binary string Nm−1 . . .N1.We define ω1 as the identity matrix.Measurement of the ancilla is in the X basis.
The exact fraction of errors that can be detected will depend on the trial state produced by the ansatz, but has a maximum value of 80 % (see Supplementary Materials).
A total of M log 2 (N ) control gates are required to measure the electron number, or both spin numbers.
While our method can filter a fraction of the possible errors, the results will not be completely noise free.Consequently, we can combine our technique with other methods of error mitigation to further improve accuracy.The most simple approach is to use the detection method to filter out errors, and then use the extrapolation technique to obtain highly accurate results.
Hardware implementation.-Wenow consider how to implement our technique in current leading architectures; specifically trapped ion and superconducting systems.The circuit structure required is similar to that of a stabiliser evaluation for a topological code, which has been investigated for both platforms [36,37].As can be seen from Fig. 1, the optimal implementation requires nonlocal gates.Trapped ion systems have the capability to perform gates between non-adjacent ions [38].As such, these non-local parity checks do not present any particular difficulty.Moreover, modular architectures are feasible designs for trapped ion systems [39,40].Such architectures are network-like and could be constructed with the connectivity required for our circuits.As the coherence times of trapped ion qubits are considerably longer than their readout times [41], it is possible to carry out the checks using a single ancilla that is repeatedly measured and reinitialised.
In contrast, superconducting qubits typically have more limited connectivity, that may be nearestneighbour.With such an architecture, we can implement our particle number check by using O(M ) SWAP gates to move the ancilla along the qubit register.It is possible to realise the parity checks with a shorter circuit, which was discussed in Ref. [42], and which we reproduce in the Supplementary Materials.In contrast, the number of gates required for a general UCC ansatz is O(M 3 ) [43].For physical systems of interest, requiring M = 50 − 100 qubits, the gate count will be dominated by the ansatz circuit.Consequently, we expect the additional gates to have little impact on the detection rates derived above.For superconducting qubits, the measurement time can be of a comparable order of magnitude to the coherence time [44].As such, it may be preferable to use multiple ancilla qubits, rather than to repeatedly reinitialise a single ancilla.As superconducting systems currently possess the largest number of qubits, we do not anticipate this small overhead (two qubits for spin number parity, log 2 N for spin number) being a problem.
Results.-In this section we test our method's efficacy at reducing the impact of errors in a VQE calculation.We consider the most simple model of molecular hydrogen, which consists of two electrons distributed in four spin-orbitals.We used a spin-conserving UCC ansatz applied to the Hartree-Fock state for H 2 .We did not consider the parameter update step of the VQE, which enabled us to examine the effect of errors without consideration of a classical optimisation algorithm [19].Numerical simulations were performed using the Quantum Exact Simulation Toolkit (QuEST) [45], and simulation code can be found at Ref. [46].Our aim was to measure the energy to within 'chemical accuracy' (1.6 mHartree), which enables the prediction of reaction rates to within an order of magnitude at room temperature.
We used a symmetric depolarising noise model in all calculations, and assumed that the two qubit gate error rate was 10 times larger than the single qubit gate error rate.To detect errors, we performed error-prone checks of both the spin-up and spin-down parity numbers, using the circuit shown in the Supplementary Materials.This circuit has nearest-neighbour connectivity, and so lower bounds the efficacy of our method.We designed our simulations to mimic the actions of an experimentalist; the expectation value of each term in the Hamiltonian was found by repeating the circuit and measurement procedure many times.The number of measurements used is discussed in the Supplementary Materials.
Initially, we considered energy measurements on a trial state that contained all four possible vectors, as described by Eq. ( 1).We measured the energy of the state prepared by the ansatz under the following conditions: We compare these results to the true energy extracted in the limit of infinite measurements and no gate errors.The results are shown in Fig. 4, using two qubit gate error rates ranging from 0.1 % to 2 %.There were 92 single qubit gates and 56 two qubit gates in the UCC ansatz circuit -which we can approximate as 65 two qubit gates.The parity checks contributed an additional 8 error-prone two qubit gates.We see from Fig. 4 that the error detection method alone improves the accuracy of our energy measurements.While the detection method itself is less effective than linear extrapolation, a greater benefit can be obtained by combining the two methods.Moreover, the accuracy obtained does not worsen significantly as the error rate increases, unlike the detection and extrapolation methods on their own.We observe from the inset plot that the fraction of detected errors falls approximately linearly with increasing error rate.When the error rate is small we detect around 53 % of errors.If we assume that we can only detect errors which occur during the ansatz circuit (due to the use of nearest-neighbour gates for the parity check) then our detection probability is given by the probability of an error happening in the ansatz circuit (65/73), multiplied by the probability of detection (10/15), which is roughly 59 %.We attribute the deviation of our result from this value to the use of a UCC ansatz, which enables errors to propagate.At higher error rates, multiple errors are able to occur in the circuit, which reduces the fraction of errors that we can detect to close to one third.
We also used our method to reduce the effect of errors when calculating the dissociation curve of H 2 .We compare the true energy values with: noisy measurements without error mitigation, noisy measurements with extrapolation, and noisy measurements with detection and extrapolation.The two qubit gate error rate was 0.1 %, which has been achieved in a controlled setting [22,23], and should be targetable in near-future quantum computers.While previous experimental VQE calculations on H 2 have achieved accurate results with higher error rates [16-18, 28, 29], these experiments used fewer gates (and often fewer qubits) -obtained using simplifications that are applicable to H 2 , but not to larger molecules.We chose to use the non-optimised circuits for H 2 to ensure that our simulations were representative of general quantum chemistry problems.We see from Fig. 5 that energy measurements are improved by combining error detection and extrapolation, which is once again more effective than using extrapolation alone.The inset plot shows that our method can obtain chemically accurate energies, even when the results would otherwise be corrupted by depolarising noise.Compared to the unmitigated results, the deviation from the true value is reduced by a median factor of 106 (with a range of 71 to 869, and a mean of 246) by combining the error mitigation techniques.Compared to the extrapolated results, the deviation from the true value is reduced by a median factor of 4.5 (with a range of 0.8 to 38.6, and a mean of 10.6) by combining the two mitigation methods.As energies are exponentiated when calculating reaction rates [33], this improvement will be magnified when performing calculations of interest.
Discussion.-We have introduced a method to mitigate errors in near-term digital quantum simulations, which requires minimal additional resources.Our technique can be used to detect errors which change the particle number parity, spin number parity, particle number, or spin number, depending on the variant used.
Our method can improve the accuracy of variational calculations, especially when combined with the extrapolation method of error mitigation.We simulated a VQE calculation of the hydrogen molecule, and found that the deviation from the true result is reduced by two orders of magnitude (median) using the spin number parity variant of our technique.Our simulations were performed using nearest-neighbour connectivity, showing the practicality of our method.As such, it can immediately benefit digital quantum simulations.
Recent work has shown surpassing classical simulation techniques with non-error-corrected quantum computers will likely require at least 10 4 gates [43,47,48].However, it is difficult to foresee two-qubit-gate error rates below 0.01 % -at which point, we would expect an error to occur in every circuit, on average.Error mitigation techniques, such as those presented herein, may enable us to extract meaningful results from these simulations, providing a practical use for near-term quantum hardware.
While our method can detect a large proportion of errors, additional mechanisms will be required to provide error resilience for long circuits on non-error corrected machines.One possibility is to combine our method with a two qubit phase-error detection code.Alternatively, one could utilise other invariant quantities.It was noted in Ref. [49] that the Hamiltonians of small molecules contain several symmetries.Evolution under a Hamiltonian variational ansatz should conserve these quantities, enabling us design additional stabiliser checks.We can use the VQE to find the ground state energy of a physical Hamiltonian.Following most of the previous work on near-term quantum simulation, we use the second quantised formalism.In this section, we focus primarily on the simulation of molecules, although the procedure is similar for lattice based models such as the Fermi-Hubbard model.We project the Hamiltonian onto a finite number of basis wavefunctions, {φ p }, which approximate spinorbitals.Electrons are excited into, or de-excited out of, these orbitals by fermionic creation (a † p ) or annihilation (a p ) operators, respectively.These operators obey fermionic anti-commutation relations, which enforce the antisymmetry of the wavefunction, a consequence of the Pauli exclusion principle.In the second quantised representation, the electronic Hamiltonian is written as with where x is a spatial and spin coordinate.
This fermionic Hamiltonian can be mapped to a qubit Hamiltonian by employing an encoding method.The two most common methods are the Jordan-Wigner (JW) and Bravyi-Kitaev (BK) mappings.In this work, we use the JW encoding, as it was found in Ref. [19] that the BK mapping was more susceptible to errors than JW mapped states.In the JW encoding, we store the occupation number of an orbital in the |0 or |1 state of a qubit (unoccupied or occupied, respectively).The mapping between the fermionic creation and annihilation operators and qubit gates is given by [50] The X and Y operators change the occupation number of the target orbital, while the string of Z operators enforces electron exchange antisymmetry.The JW mapped Hamiltonian of a molecule can be written as a linear combination of products of Pauli operators, where g j are coefficients, σ j i represents one of I, X, Y , or Z, i denotes which qubit the operator acts on, and j denotes which term in the Hamiltonian we apply.For example, As each term in the fermionic Hamiltonian contains an even number of creation and annihilation operators, each term in the qubit Hamiltonian will contain an even number of X or Y operators, and thus will conserve particle number parity.

ERROR DETECTION RATES
When deriving error detection rates, we make the following assumptions: 1.The errors are symmetric and depolarising.
2. The error rate is low, such that only one gate malfunctions in the circuit.
3. The ansatz circuit is built from individual gates which conserve particle number and spin [31].4. Single qubit gate error rates are negligible compared to two qubit gate error rates.
While our method is still applicable under higher noise rates, different noise models, and using other number conserving ansatze (such as the unitary coupled cluster ansatz used in our numerical simulations), an analytic bound on the error detection rate becomes more difficult without these assumptions.

Total electron number parity check
By performing a single parity check of the total electron number, we are able to detect 53 % of errors under the above assumptions.In the symmetric depolarising noise model the following errors are equally likely following a two qubit gate between qubits i and j: We can see that all of the errors in the top row change the electron number parity of a state vector.As a result, using a single parity check, we can detect 8/15 ≈ 53 % of these errors.This is true both if the error occurs during the ansatz circuit (we can detect of the 15 possible errors on two of the register qubits) or during the parity check gate sequence (we can detect X r X a , X r Y a , Y r X a , Y r Y a , Z r X a , Z r Y a , I r X a , I r Y a , where r and a denote register and ancilla qubits, respectively).

Spin-up and spin-down parity check
Using the spin-up and spin-down parity checks, we can detect additional errors beyond the 8/15 detectable using the electron number parity measurement.We will be able to detect certain two qubit errors, which change the value of either spin-parity.However, we will not be able to detect all two qubit bit-flip errors.
There are which occur on one orbital of each spin.There are M/2 1 = M/2 ways of distributing an error amongst half of the orbitals.As a result, there are M 2 4 errors we can detect.For a 2 spin-orbital system, we can detect 2 2 /4 (2×1)/2 = 100 % of double bit-flip errors.For a 4 spin-orbital system, this reduces to 66 % of double bit-flip errors.
When M is large, we can detect M 2 /4 M(M−1)/2 ≈ M 2 /4 M 2 /2 = 1 2 of double bit-flip errors.As there are four possible types of double bit-flip errors, and we can detect half of the occurences of each of them, this effectively increases the number of error events we can detect by 2/15, to 10/15 ≈ 66 %.
The above calculation holds when the error occurs during the ansatz circuit.If the error happens during the error detection procedure, the situation is more complicated.We can detect around 66 % of errors by performing the total electron number parity check first, then the spin-up and then the spin-down parity checks.First assume that the error happens during the first parity check.Using the total parity check, we can detect 8/15 errors that occur (we can detect X r X a , X r Y a , Y r X a , Y r Y a , Z r X a , Z r Y a , I r X a , I r Y a , where r and a denote register and ancilla qubits, respectively).Using the spin-up parity check, we are able to detect any of X r I a , X r Z a , Y r I a , Y r Z a that happen to one of the spin-up register qubits.The same is true for errors on the spin-down register qubits.As a result, we can detect all X r I a , X r Z a , Y r I a , Y r Z a errors resulting from the first parity check, in addition to those described above.This is 12/15 of the errors in the depolarising noise model.If the error occurs during either of the other two parity checks, we are only able to detect the 8/15 errors listed above.However, as the total electron number parity check requires twice as many gates as either of the spin-up or spin-down parity checks, the error is equally like to occur in the first parity check as in either of the other checks.As such, on average we can detect 10/15 ≈ 66 % of errors, even if they occur in the error checking process.Alternatively, given that the ansatz circuit will contain many more two qubit gates than the parity check circuits, we can just use the spin-up and spin-down parity checks, and assume that it is far more likely that the error will occur in the ansatz circuit.

Electron number check
We provide a worked example for the case of a system with N = 3 electrons in M = 6 orbitals.We first apply the circuit shown in Fig. 6 After this circuit, if no errors have occured, the ancilla is in the state The circuit which measures the 1 st bit of the electron number, N1.The R1 gates are given by diag(1, e πi ).Measurement of the ancilla is in the X basis.
Measuring the ancilla in the X basis informs us that the first bit in N is 1.We then apply the circuit shown in Fig. 7.
The ω 2 gate is given by diag(1, e −dec(N1)πi/2 ) = diag(1, e −πi/2 ).The state of the ancilla is This informs us that the second bit in N is also 1.As a result, we know the number of electrons in the state is 3.If a different value were measured, this would inform us that an error has occured, and therefore that the result should be discarded. |x0 The circuit which measures the 2 nd bit of the electron number, N2.The R2 gates are given by diag(1, e πi/2 ).The ω2 gate is given by diag(1, e −dec(N 1 )πi/2 ), where dec(N1) is the decimal value of the first bit of N .Measurement of the ancilla is in the X basis.
It is only possible to naively estimate the maximum error detection rate using the particle number checks, for reasons which are discussed in more detail below.We can initially perform the parity measurements described above to detect 66 % of errors, under the assumptions listed at the beginning of this section.We then make the assumption that the wavefunction consists of only one Slater determinant.We also assume that the error occurs during the ansatz circuit, and not during the number measurement procedure.
We are unable to detect any two qubit bit-flip error which acts on one occupied orbital and one unoccupied orbital of the same spin, as this mimics an excitation operator in the UCC ansatz.If we consider the spin-up electron number, then the number of possible two qubit bit flip errors which act on the occupied spin-up orbitals is N/2 2 .The number of possible two qubit bit flip errors which act on the unoccupied spin-up orbitals is M/2−N/2 2 .The total number of possible two qubit errors (where both errors happen on the spin-up orbitals) is M/2 2 .As such, the detection rate is In the limit that M → ∞ and M >> N , all errors occur on the unoccupied orbitals, and so change the electron number and spin numbers.As such, we are able to detect all two qubit bit flip errors.This means we are able to detect up to 12/15 = 80 % of single gate errors in the depolarising noise model (although this is unattainable in practice).
However, this only applies to a single Slater determinant, while the output of our ansatz will likely be a superposition of multiple determinants.The reason for this approximation is that double bit-flip errors may change the electron and spin numbers of certain determinants, while leaving others unchanged.For example, consider the state which has an electron number of 3, a spin up number of 2, and a spin down number of 1 (the rightmost 3 orbitals are spin-up, the leftmost 3 orbitals are spin-down).If this state undergoes a double bit flip error given by X 0 X 1 , the state becomes This new state has the correct spin up and spin down parities, so the error is undetectable using parity checks.Moreover, we see that while the first Slater determinant in the wavefunction has an incorrect particle number, the second still has the correct particle number.If we apply the electron number measuring scheme described above, we will still measure 1 for the first bit in the electron number.However, when measuring the second bit, there is a 50 % chance we measure 1 (ancilla in |− ), and a 50 % chance we measure 0 (ancilla in |+ ).If we measure 0, we conclude that an error has occured, and correctly discard the state.However, if we measure 1, we conclude that the electron number is correct, and no error has occured.As a result, we collapse the wavefunction into the state and measure the energy of this state, which may be far in energy from the state which the ansatz intended to produce.
As such, the true rate of accepting uncorrupted states is below the 80 % maximum discussed above, but impractical to calculate analytically.

Non-violation of the variational principle
In this section, we show that the measured energy still obeys the variational principle after the filtering process described above, such that energy values below the true ground state energy cannot be measured.We can prove this by considering the Hamiltonian produced after mapping to qubits.The physical states that our ansatz generates correspond to a small region of the full Hilbert space.Errors may take the state produced outside of this region.Under a general noise channel, the density matrix for the system is given by where p i is the probability of the register being in state |ψ i .If we apply our error detection procedure, we can filter out certain states, such as those with incorrect particle number parities.This results in a new density matrix, The energy of the system is given by where g denotes the ground state of the system.Because the states |ψ i are not the ground state, As the probabilities, p ′ i are between 0 and 1, and sum to unity, it is therefore true that where equality only holds when the filtering procedure is 100 % effective, and the system is in the ground state.Consequently, the variational principle is not violated by our filtering procedure.

ALTERNATIVE STABILISER-VQE CIRCUIT
Here we provide more detail on the alternative circuit mentioned in the main text, which can be used to reduce noise due to readout errors.We first show that the circuit given by Fig. 8 [51,52] gives the desired outcome for the VQE; ψ| h j |ψ .Stepping through the circuit, we find that: 8.The alternative method of performing a single measurement of term hj in the Hamiltonian.The ansatz circuit U ( θ) creates a physical state; |ψ = |ψ( θ) = U ( θ) | 0 .The controlled-hj gate is easy to realise in practice, as hj is a product of Pauli terms on different qubits, so it can be implemented as a sequence of controlled Pauli gates.
Measuring the ancilla in the computational basis gives the same result as the conventional VQE circuit, as required.The circuit has obtained this result by performing measurement of a single qubit each time, which we will show reduces noise due to readout errors when compared with the normal direct measurement VQE protocol.
We can also use this circuit to extract parity information about the qubits 'for free'.When the circuit and measurement are performed, the ancilla will either be measured in the |0 a or the |1 a state.The register is correspondingly in either which we write as |φ ± R .
In the Jordan-Wigner encoding, the Pauli terms in the Hamiltonian, h j , contain an even number of X and Y operators, and thus conserve electron number parity.Denoting the parity operator by P , we find that P |ψ = (−1) N |ψ and P h j |ψ = (−1) N h j |ψ , where N is the number of electrons in the molecule.As a result, the register state is an eigenstate of the parity operator, and so we can measure this stabiliser quantity, as shown in Fig. 9.If a single bit-flip error has occured, this will change the measured parity.If P = (−1) N , we can discard the h j measurement result.
We perform a parity measurement on the register after the ancilla has been measured in order to detect errors.
In the limit of small error rates, we consider that at most a single error happens.We assume here that no gate errors occur in the circuit, but a single readout error occurs.Using the circuit in Fig. 9, the probability that the error happens on the ancilla qubit is 1/M where M is the total number of qubits.If the error occurs on the ancilla qubit, its value will be corrupted.In contrast, the parity measurement will yield the correct result.This means we will not filter the corrupted result, reducing the accuracy of our expectation value measurement.In the other (M − 1)/M cases, the readout error occurs on one of the register qubits.This causes us to incorrectly assert that the state |ψ is not a physical state, and therefore wrongly filter it out.However, our measured expectation value is not degraded much by this.When the number of qubits is large, the readout errors are much more likely to occur on the register qubits, and so we are still able to obtain an accurate expectation value.
In contrast, when considering the circuit shown in Fig. 1 in the main text, we find that the opposite is true.If only a single readout error occurs, it is much more likely to occur on the register qubits than on the ancilla.As a result, we are likely to accept a corrupted state, producing a less accurate expectation value.While this sounds like a significant disadvantage, we note that the reality is less clear cut.Readout error rates are currently at around 1 % [34] for superconducting qubits, higher than the lowest two qubit gate error rates.However, there are typically far more two qubit gates in the circuit than qubits to be measured, and so we expect gate errors to dominate.Moreover, this circuit variant is only capable of checking the total electron parity, and not the spin-up or down parities.
We can also apply this circuit to variational algorithms which simulate real [24] and imaginary [35] time evolution, as well as quantum gradient finding [33].These algorithms use a circuit similar to the one shown in Fig. 8 to probe the derivative of an ansatz state with respect to one of the parameters.They leave the register in the state where |ψ( θ) is the ansatz state, k ± is a normalisation constant, h j is a Hamiltonian term, N is a normalisation constant for the derivative state vector, and θ = 0, π depending on the whether the simulation is of real time, imaginary time, or gradient finding.If an ansatz is used which constructs physical trial states, then the state |ψ( θ) has fixed particle number and spin.As discussed above, the Hamiltonian operators h j are particle number parity conserving.Consequently, we only require that | ∂ψ( θ) ∂θi has a conserved particle number parity.This is the case for both UCC and Hamiltonian variational ansatze.Consequently, the qubit register is left in a state which has a fixed particle number parity, in the absence of errors.The particle number parity of the register qubits can then be checked, to detect possible errors.This error detection can be considered 'free', as no additional ancilla qubits or circuit repititions are required, beyond what is needed for the quantum gradient finding circuit itself.

SIMULATION DETAILS UCC ansatz and the hydrogen molecule
When solving the electronic structure problem for the hydrogen molecule in a minimal basis, we construct four molecular orbitals, where A and B denote which of the two protons the 1s orbital is centred on.We can write a Jordan-Wigner (JW) mapped state vector as where f i = 1 if spin orbital i is occupied, and f i = 0 if spin orbital i is unoccupied.Using the JW encoding, the 4 qubit Hamiltonian for H 2 , given by We obtained the numerical values of h i using OpenFermion [53].The HF state for H 2 is given by The most general state for H 2 (with the same spin and electron number as the HF state) is given by We can construct such a state using the unitary coupled cluster (UCC) ansatz, considering single and double excitations above the HF state (UCCSD).The UCCSD operator is given by where and occ are occupied orbitals, virt are initially unoccupied orbitals in the HF state, and t iα and t ijαβ are variational parameters to be optimised.For H 2 , the UCCSD operator takes the form Splitting this operator up using Trotterization (with a single Trotter step) and using the JW encoding, we find that We can apply this operator using the circuit shown in Fig. 10 and Fig. 11, generated using the circuit constructions in Ref. [54].
The parity check circuit used in our error-mitigated simulation of the Hydrogen molecule is shown in Fig. 12.We restricted ourselves to a linear nearest-neighbour connectivity, in order to lower bound the efficacy of our method.The electron spin number parity checks could be implemented by using a series of SWAP gates to move the ancilla qubits along the register, such that they are next to every register qubit once.This can be achieved in depth O(M ).Instead, it is more efficient to use the procedure shown in Fig. 12, which effectively 'passes' the parity information along the register to the ancilla, before uncomputing the procedure to ensure reversibility.This circuit has already been suggested for efficient stabiliser checking in Ref. [42].

Number of measurements and error analysis
Our numerical simulations were designed to mimic the actions of an experimentalist; the expectation value of each term in the Hamiltonian was found by repeating the circuit and measurement procedure many times.
The number of measurements required was set by the desired precision, we which chose to be one quarter of chemical accuracy (0.4 mHartree).Measurements were distributed optimally among the different Hamiltonian terms [14,33], such that the number of measurements for each term was proportional to its strength.The standard error in each measurement is then given as follows.
The standard error in the mean is given by [55] where N is the number of measurements performed, and σ is the standard deviation of the result.The standard deviation of a measurement of one of the Pauli strings in the Hamiltonian, ĥj , is given by The standard error in the energy measurement is then upper bounded by hj where N i is the number of measurements used for each term in the Hamiltonian, and g i is the coefficient of term i in the Hamiltonian.We distribute our measurements optimally [14,33], setting where g max is the largest coefficient in the Hamiltonian, and k is the number of measurements allocated to the largest term in the Hamiltonian.We substitute this expression into Eq.35, Solving for k, and substituting back into Eq.36 provides an expression for the number of measurements required per term, as a function of the standard error The total number of measurements is then When extrapolation is performed, the standard error is increased by a factor that is dependant on the 'stretchfactor', λ, used in the extrapolation.When performing extrapolation, we used the same total number of samples for each expectation value, which were divided equally between two points for a linear extrapolation.The extrapolated value is given by As such, the standard error was increased by a factor of ω = 2(λ 2 + 1) (λ − 1) .
The stretch factor used in our simulations depended on the error rate, ǫ, as FIG. 10.The first half of the complete circuit used in our simulations to implement the UCCSD operator for H2.The Rx( π 2 ) and H gates rotate the basis such that the exponentiated operator applied to the corresponding qubit is either Y or X, respectively.
FIG. 11.The second half of the complete used in our simulations to implement the UCCSD operator for H2.The Rx( π 2 ) and H gates rotate the basis such that the exponentiated operator applied to the corresponding qubit is either Y or X, respectively.

FIG. 4 .
FIG. 4. Comparing methods of mitigating errors in simulations of H2.The detection rates shown in the inset were obtained from the numerical simulations.The true energy value was −1.1227 Hartree.The error bars upper bound the standard error in the result.

FIG. 5 .
FIG. 5. Comparing methods of mitigating errors in simulations of H2.The 2 qubit gate error was 0.1 %.The inset shows the residual from the true value.The dashed line in the inset marks chemical accuracy (±1.6 mHartree).The error bars upper bound the standard error in the result.