Platform tailored co-design of gate-based quantum simulation

The utility of near-term quantum computers and simulators is likely to rely upon software-hardware co-design, with error-aware algorithms and protocols optimized for the platforms they are run on. Here, we show how knowledge of noise in a system can be exploited to improve the design of gate-based quantum simulation algorithms. We concretely demonstrate this co-design in the context of a trapped ion quantum simulation of the dynamics of a Heisenberg spin model. Specifically, we derive a theoretical noise model describing unitary gate errors due to heating of the ions' collective motion, finding that the temporal correlations in the noise induce an optimal gate depth. We then illustrate how tailored feedforward control can be used to mitigate unitary gate errors and improve the simulation outcome. Our results provide a practical guide to the co-design of gate-based quantum simulation algorithms.


I. INTRODUCTION
Large-scale fault-tolerant quantum computers have the potential to catalyze progress in physics and material science, chemistry and drug development, as well as optimization and machine learning [1,2].In the nearterm, noisy intermediate-scale quantum (NISQ) technology may still demonstrate a quantum advantage over classical computers for certain tasks.The first useful task of NISQ computers likely to demonstrate a quantum advantage is the simulation of quantum dynamics [1,3,4].Digital quantum simulation, accomplished by discretizing the dynamics into several gates, is a flexible approach with controllable error that can improve our understanding of spin systems [5,6], quantum chemistry [7,8], biochemistry [9], and high energy physics [10,11].A common challenge in all such gate-based quantum simulation is to optimize the quantum circuit implementing the algorithm for a particular NISQ platform.Specifically, the discretization error in the algorithm is reduced by increasing the number of gates, while hardware noise in the system causing decoherence leads to error that typically worsens as the number of gates increases.To achieve the best performance of the algorithm, we must therefore determine both the optimal number of gates and the optimal parameters for these gates in order to account for noise.The focus of this work is to provide insight into these questions which lie at the heart of softwarehardware co-design of gate-based quantum simulation.
More generally, understanding the principles of codesign and error-mitigation is essential to realize the potential of quantum computers, as hardware noise usually wipes out the effects responsible for quantum advantages [12].Even fault-tolerant quantum computers of the future will rely on the characterization and mitigation of noise.The existence of a fault tolerance threshold is only rigorously defined when errors are assumed to be independent; this Markovian idealization is only true FIG. 1. Chain of trapped ions collectively moving at frequency ω0 in the x direction.Ions explore different parts of the beam waist of lasers (yellow) that apply unitary gates, thus accumulating an incorrect phase.
when spatial and temporal correlations in the noise die off quickly [13][14][15].The magnitude of independent errors, in turn, affects the resource cost of the system, with noisier systems requiring a larger overhead of physical qubits per logical qubit.For near-term noisy, intermediatescale platforms, characterizing the noise in a system is even more critical.Practical applications will require the co-design of protocols optimized to different hardwares.Indeed, understanding the nature of noise in a system can enable tailored quantum-control and error mitigation that improves desired performance metrics [16,17].In some cases, noise can even be exploited as a feature of the system to simulate the dynamics of complicated many-body models [18].
The three categories of error in quantum computations and simulations are measurement errors, incoherent errors, and coherent errors.The first, measurement error, arises as quantum observables have inherent uncertainty and hence their expectation value can only be determined with a certainty set by the number of measurement samples.The second, incoherent error, arises from coupling between the qubits and their environment, with these interactions causing the internal state of the qubit to change.The last, coherent error, occurs when a desired unitary transformation of the system imparts an angle different than intended.These unitary errors are the focus of this work and arise due to limitations of the platform's analog control hardware or the dynamics of the physical qubits [19].Over the course of a quantum computation or simulation, such unitary errors accumulate and dephase the system state, killing the coherent effects responsible for a quantum advantage and degrading the fidelity of any simulation.In trapped ions, for example, one dominant source of decoherence is the ions' collective motion, which is thermally excited due to electric field fluctuations from trap electrodes.While the internal qubit states of the ions are not directly affected by this motion, any quantum gate applied via individually addressed lasers imparts an erroneous phase to the qubit states, as depicted in Fig. 1.We can understand the source of this noise as the phonon mode associated with the center of mass of the chain having an energy that undergoes diffusion due to heating from electric field fluctuations.This slow diffusion of the phonon in energy space causes the unitary error to be non-Markovian, with correlations arising between gates applied at different times during an experiment.
In this work, we demonstrate how to exploit knowledge of the noise underlying a system to optimize gate-based quantum simulations.To provide an example, we do so in the context of simulating the dynamics of a Heisenberg spin model in a system of trapped ions.We first introduce the quantum simulation task and associated gate-based algorithm.Then, we derive a theoretical noise model describing unitary errors from thermal ion motion in trapped ion systems and provide a protocol to experimentally extract the latent variable underlying the model.We discuss how temporal correlations in the noise induce an optimal gate depth of the quantum simulation circuit.These correlations cause the error in the simulation arising from motional noise to accumulate as the gate depth is increased, while the Trotter error associated with discretization of the time-evolution decreases as the gate depth is increased.The competition of these two errors induces an optimal gate depth.
Next, we provide a platform-independent framework for optimal feedforward control of unitary gate errors, which involves applying gates with angles that are modified to compensate for the predicted noise in the system.We illustrate the utility of feedforward control in the trapped ion implementation of simulating the Heisenberg Hamiltonian, showing that feedforward control partially mitigates both discretization error and decoherence error in the simulation output.
Our work provides three results that are generally applicable to the co-design of gate-based quantum algorithms beyond the discussed simulation task: (i) the understanding that non-Markovian correlations are the root cause of decoherence and the subsequent limitation on gate depth in any platform where unitary errors are the dominant noise, (ii) a method to optimally leverage noise characterization to mitigate unitary gate errors via feedforward control, and (iii) an accurate model of unitary gate errors arising from thermally-excited ion motion in trapped ion systems.

II. HAMILTONIAN SIMULATION
Simulating the quantum dynamics of a system is a natural application of digital quantum computers and analog quantum simulators, and is likely to be the first problem of practical interest where a quantum advantage over classical computers is demonstrated on near-term quantum platforms [3].The goal is to simulate the timeevolution, Û (t) = exp −i Ĥt/ℏ , of a system whose dynamics are generated by a Hamiltonian Ĥ.Here, we focus on the Heisenberg Hamiltonian, which is a paradigmatic spin model that describes the magnetic properties of many insulating crystals [20], appears in the study of thermalization in quantum systems [21][22][23], and describes the essential physics underlying nuclear magnetic resonance (NMR) spectroscopy [9].Many near-term quantum algorithms and simulations focus on the task of estimating the expectation value of some observable after time-evolution, with the value of such observables often being less susceptible to noise than the full system state [24].In this vein, we benchmark the quality of gate-based quantum simulation of Eq. (1) with the spectrum simulation task discussed in Ref. [9] and experimentally demonstrated in Ref. [25].This algorithm uses time-evolution under the Heisenberg Hamiltonian, Eq. (1), to compute the NMR spectrum where = Tr e i Ĥt Ŝz tot e −i Ĥt Ŝz tot ρ 0 is the total magnetization response function and ρ 0 is the initial state of the spin system.For typical NMR experiments, it is a good approximation to assume that the system starts in an infinite temperature state , where Î is the identity operator.
Letting |z j ⟩ be the eigenstates of Ŝz tot corresponding to eigenvalues m j , the response function is computed as where |z j (t)⟩ = e −i Ĥt |z j ⟩ and N s is the number of spins in the system.The quantum algorithm is thus preparation of the desired computational basis states {|z j ⟩}, Hamiltonian simulation of Ĥ through implementation of the time-evolution operator Û (t) = e −i Ĥt , and projective measurements in the computational basis.These measurements yield the response function, S (t), whose Fourier transform gives the desired spectrum, A (ω).We implement this time-evolution using a first-order Trotter decomposition into gates commonly used in trapped ion platforms.Specifically, we split the total time-evolution into r Trotter steps yielding Û (t) = Û (∆t) where ∆t = t r .The unitary Û (∆t) = e −i Ĥ∆t is then approximated with the Suzuki-Trotter product formula where ⟨ij⟩ corresponds to all unique pairs of spins as J ij = J ji in the Hamiltonian.Furthermore, we only include pairs of spins where J ij ̸ = 0.The total timeevolution is then given by Û1 (t) = Û1 (∆t) , and angles ϕ i = 2h i ∆t, the quantum circuit for time evolution is given by where we apply gates from right to left.The Trotter decomposition, Eq. ( 7), is expressed in terms of the Molmer-Sorensen gates, Û xx (ϕ ij ), and single qubit rotations that are commonly used in trapped ion computations.
Assuming that enough measurements are made during a computation to ignore measurement errors in the expection values, ⟨z j (t) | Ŝz tot |z j (t)⟩, the computed spectrum will still include discretization errors from Trotterization and unitary gate errors from the ion motion described in Sec.III.The feedforward control discussed in Sec.V can help mitigate the latter.Figure 2 shows an example spectrum (black), the same spectrum with both Trotter and unitary noise (orange), and the noisy spectrum with feedforward control (green).

III. TRAPPED ION NOISE MODEL
Trapped ions have emerged as a leading platform for quantum computation and simulation due to their long FIG. 2. Example spectrum without noise (black), with Trotter error and unitary noise (orange), and noise with feedforward control (green) for a system of four spins evolving under the Heisenberg Hamiltonian, Eq. ( 1).The phonon heating rate is taken to be c2 = 0.02 ms −1 and the noisy spectra are averaged over 40 runs.The uncorrected noisy spectrum is computed using 200 gates and the corrected noisy spectrum is computed using 500 gates, which are the gate depths for which each spectrum is closest to the noiseless spectrum, as quantified by the Hellinger distance between the spectra.
coherence times, identical nature, and negligible idle errors [12,26].The ions in these systems crystallize into a chain after being tightly confined in two directions via an oscillating electric field.Entanglement between the qubits is generated by a laser-induced interaction between states that is mediated by the collective motion of ions.Usually, the motional modes along the tightly confined transverse direction are used for these operations as they are less sensitive to electric field fluctuations arising from the electrodes generating the trap.These fluctuations do, however, excite the weakly confined longitudinal modes of the chain.The deviation of the ions from their lattice positions causes them to experience erroneous intensities from the individually addressed laser beams used to implement different operations.As the longitudinal motion of the ions heats up, these errors build into a dominant form of noise that limits the operational time window of the system [26].Here, we develop a noise model for errors arising from this longitudinal heating, ignoring other possible sources of error in trapped ion systems that may be more prevalent in different operational regimes of the device.
We first characterize the gate error in the system due to longitudinal movement of the ions in the x-direction, depicted in Fig. 1.The individually addressed singleand two-qubit gates in trapped ion systems are enacted by shining a narrowly focused laser on a single or pair of ion lattice sites respectively.The gates take the form Û (ϕ) = exp −iϕ Â , where Â is either a single spin oper-ator, Ŝα j , acting on a site j, or the bilinear, Ŝx i Ŝx j , acting on a pair of sites.These gates form a sufficient set for universal quantum computation.The phase of the gate is ϕ = Ωt g , where t g is the duration of the laser pulse, and Ω is the Rabi frequency set by the electric field amplitude of the laser.This amplitude typically has a Gaussian spread in the longitudinal direction which carries over to the Rabi frequency: Ω (x) = Ω 0 exp −x 2 /(2σ 2 ) where Ω 0 represents the maximum beam intensity and σ characterizes the beam width.The collective motion of the ions in the longitudinal direction can be decomposed in terms of normal modes with frequencies ω m .During application of a gate, these motional oscillations cause the ions to feel a position-dependent Rabi frequency that is less than the desired Ω 0 .Our goal is to derive the distribution of the erroneous phase ϕ that is applied when inputting an angle ϕ in = Ω 0 t g .In general, this distribution will evolve in time as the longitudinal phonon modes are heated, leading to larger amplitude oscillations.We therefore also seek to determine how the erroneous Rabi frequency, and therefore the phases ϕ(t) and ϕ(t ′ ), are correlated at different times.Temporal correlations over a sufficiently long timescale can limit the fidelity of computations in the system, even after feedforward optimization of individual gates.
Electric field fluctuations from electrodes trapping the ions are primarily responsible for heating the longitudinal phonons [27].The lowest frequency phonon mode, characterized by ions oscillating in phase at frequency ω 0 , typically dominates the gate error as the field fluctuations are roughly uniform over the chain [26].The gate application time, t g , is usually much longer than the timescale set by ω 0 so we can assume that the effective Rabi frequency, Ω(t), that an ion feels during a gate initiated at time t only depends on the average position of the ion: where x(t) = 1 tg t+tg t ds ⟨x(s)⟩ and x is the position operator of the ion.Letting p be the canonically conjugate ion momentum operator, we define the usual bosonic creation and annihilation operators â † = (x − ip) / √ 2 and â = (x + ip) / √ 2. The average ion position only depends on the average energy of the harmonic motion: x 2 (t) = ℏ ⟨n(t)⟩ / (mω 0 ) where m is the mass of the ion and n = â † â is the occupation number.
We must describe the dynamics of the ions' harmonic motion in order to compute the distribution and correlations of the Rabi frequencies, and by extension the phases of the unitary gate.Letting the state of the system be ρ (t), we can model the dynamics with the Lindblad master equation where the first term represents the coherent harmonic oscillation of the ions, the second term represents an increase in the oscillation amplitude at rate γ + , and the third term represents a decrease in the oscillation amplitude at rate γ − .These latter two terms describe the incoherent dynamics of the ions resulting from background electric field fluctuations.Assuming that this background field exists in a thermal state at temperature T , the ions' oscillation amplitude changes at rates γ + = γN (ω 0 , T ) and γ − = γ (N (ω 0 , T ) + 1), where N (ω 0 , T ) = 1/ e ℏω0/k B T − 1 is the Bose-Einstein distribution of the electric field occupation.We assume that the background electric field is at infinite temperature so both these rates are equal and redefine γ such that γ + = γ − = γ.Given that the relevant phonon frequencies are of the order of a few hundreds of kHz, this approximation is satisfied down to very low temperatures [27].We also assume that the laser pulse enacting the gate does not affect the ions' motional state; in this sense, it is a weak measurement rather than a strong measurement which would collapse the ions' motion into a particular eigenstate of the occupation n.
In trapped ion experiments, it is possible to cool the chain close to its motional ground state during preparation of the system.We therefore assume that the initial motional state of the system is the phonon vacuum ρ (t 0 ) = |0⟩ ⟨0|.Dynamics under Eq.( 9) will then evolve the system into a harmonically oscillating coherent state undergoing a diffusive random walk in its amplitude.It therefore makes sense to describe the system state in terms of its Glauber-Sudarshan P-function representation: where {|α⟩} are coherent states that form a basis for the system.The dynamics of the system is then captured by a Fokker-Planck equation for the P-function, P (α, α * , t), The Green's function of the Fokker-Planck equation, expressed in the rotating frame of the phonon mode with frequency ω 0 , is which can be interpreted as the probability to find the ions in state |α ′ ⟩ at time t ′ given that they were in state |α⟩ at time t.To compute the full state of the system one simply has to involve this kernel with the initial Pfunction.For systems that have not been fully cooled down and maintain a non-zero thermal occupation of phonons, the initial state will be Gaussian.At present, it suffices to consider the T = 0 limit in which case the P-function is simply P (α, α * ) = δ(α)δ(α * ).This Green's function can be used to compute the probability distribution and correlations of observables expressed in the coherent state basis.Letting ϕ (τ ) = Ω (τ ) t g be the angle imparted by a unitary gate applied at time τ in the experiment, when the phonon mode is in state |α (τ )⟩, the Rabi phase of the qubit will advance by an angle where a osc = ℏ/(mω 0 ) and a laser = √ 2σ are the characteristic length scales of the harmonic oscillator and Gaussian laser respectively.The probability distribution of the angle can then be computed as where we have defined the heating rate constant and the Heaviside step function, Θ (ϕ in − ϕ), encodes the fact that the time-averaged Rabi frequency felt by the ion cannot be more than spending all its time at the center of the laser where its intensity is strongest.The distribution of angles, Eq. ( 14), is the noise model we need for feedforward control.Note that it only depends on a single latent variable, λ = c 2 τ , representing the amount of diffusion the ions' motion has undergone.
We can gain insight into the angle distribution by examining the average and typical angles that are applied by the gate, We see that at late experimental times compared to the rate c 2 such that λ → ∞, both the average and typical angles go to zero.Physically, the amplitude of the ions' oscillation becomes so large that the ion never spends time inside the laser beam and hence its internal qubit state is not changed.While the average angle algebraically decays to zero at late times, the typical angle becomes very small as τ crosses 1/c 2 , thus showing that c 2 sets the timescale where we can coherently manipulate the qubits in an experiment.We can further understand the effects of noise on a quantum computation or simulation by examining the correlation between two gates applied at a time ∆ τ apart, Taking the limit at late times, we have lim which shows that c 2 also sets the temporal correlation length between different gates.Given that the gate application time, t g , is small compared to typical values of c 2 in trapped ion experiments, the unitary gate errors will be temporally correlated.As a limiting case, we can examine how the noisy gate angles are distributed at short times when the ions are very close to the center of the laser beam.By simultaneously taking the limits ϕ → ϕ in and c 2 τ → 0 in Eq. ( 14), we get the short time distribution This expression can equivalently be derived by Taylor expanding Eq. ( 13) as ϕ (τ ) = ϕ in 1 − ( aosc a laser ) 2 |α (τ )| 2 and computing the probability distribution of gate angles using the Green's function given in Eq. ( 12).The exponential distribution of gate angles described in Eq. ( 20), valid at short times, is in agreement with the ion noise model discussed in Ref. [26].
We now give a protocol to experimentally extract the value of c 2 which characterizes the noise in a particular trapped ion set-up.Prepare a system of two qubits in the computational basis state |↓↓⟩, wait a time τ , and apply a gate Ûxx (ϕ) = exp −iϕ Ŝx i Ŝx j with an input angle ϕ in .Then, do a projective measurement in the computational basis state to extract the return probability of the system being in the |↓↓⟩ state.If there was no noise in the system, this probability would be for all τ .With unitary gate error due to the ions' motion, the probability becomes ), (22) where 1 F 2 is the generalized hypergeometric function.This average return probability is directly related to the moment generating function of Eq. ( 14).Measuring Eq. ( 22) for different input angles, ϕ in , and wait times, τ , yield curves that can be used to fit the value c 2 .We give examples of these curves in Fig. 3(a).In Fig. 3(b), we show how the return probability can differentiate between the noise model derived here and and typical phase damping.The latter leads to a return probability characterized by an exponentially decaying oscillations with a constant phase shift dependent on the input angle.Armed with knowledge of the noise model, Eq (14), and a method to experimentally determine the latent variable, c 2 , we now illustrate how non-Markovian correlations in the noise induce an optimal gate depth when implementing a quantum algorithm.

IV. OPTIMAL GATE DEPTH
We can gain insight into how non-Markovian correlations amongst gates induce an optimal gate depth in a quantum algorithm by first considering a single oneor two-qubit gate Û (ϕ tot ) = exp −iϕ tot Â of the form discussed in Sec III.Let us discretize this gate into r Trotter steps: Û (ϕ tot ) = Û (ϕ) r where ϕ = ϕ tot /r and Û (ϕ) = exp −iϕ Â .The expected angle applied by the total sequence Û (ϕ tot ) is where E ϕ [ϕ] is the average angle applied by Û (ϕ).If the unitary gate errors in the system were modeled as Markovian, and therefore uncorrelated, the variance in the total angle would be where Var (ϕ) is the variance in the angle applied by Û (ϕ).Regardless of the source of unitary error, this variance of each discretized gate will typically be proportional to E ϕ [ϕ] 2 .Letting the constant of proportionality be β, defined through Var (ϕ) = βE ϕ [ϕ] 2 , the noise-tosignal ratio of the total gate sequence becomes: As an example, if we take the noise model developed in Sec.III and ignore temporal correlations, we have β = (c 2 τ ) 2 /(1 + 2c 2 τ ).This constant β is computed by assuming that each gate angle is independent and identically distributed according to Eq. ( 14).We see that η → 0 as r → ∞, implying that discretizing the total intended gate, Û (ϕ tot ), into a large number of steps eliminates the unitary error in the system, thus illustrating that unitary gate errors in experiments cannot be fully described using a Markovian noise model.Correlations between the unitary gate errors are responsible for decoherence observed in experiments, with an optimal gate depth being set by the timescale upon which this decoherence becomes too large.
To demonstrate how this optimal gate depth manifests in practice, we turn to the Hamiltonian simulation task described in Sec.II.The computed spectrum will have errors both due to discretization via the Trotter decomposition, Eq. ( 7), and unitary gate noise due to heating of the ions' motion as described in Sec.III.Trotter error decreases as the number of gates in the circuit is increased, while unitary errors accumulate as the number of gates is increased.Therefore, there is an optimal gate count balancing Trotter error and accumulated unitary error.We can quantify the error in the computation use two different metrics.The first is to compute the average fidelity where Û (t) = e −i Ĥt , with Ĥ given by Eq. ( 1), is the desired time evolution operator and Û1 (t) is the noisy Trotterized evolution we implement in the quantum circuit, given by Eq (7), with noisy gate angles.Given that computation of a spectrum requires implementing time-evolution for a series of different times in order to generate samples of S(t), given by Eq. ( 5), we can define the time-integrated fidelity where T is the last sampled time.The optimal gate depth is then determined by the largest value of F int .This metric is not biased towards any particular choice of observable.
Alternatively, we can quantify the error in the spectrum by computing the Hellinger distance between a noiseless spectrum, A i (ω), generated by the perfect time evolution operator, Û (t) = e −i Ĥt , and a noisy spectrum, A j (ω), generated by a noisy Trotterized evolution, Û1 (t) .At the optimal gate depth, the Trotterized spectrum will have the most overlap with the true noiseless spectrum according to the Hellinger distance.This metric is biased towards the computation of the spectrum.
The optimal gate depth with the corresponding average fidelity and Hellinger distance for an example noisy computation is shown in Fig. 6 and Fig. 7 respectively, and we discuss these results in the next section.The total amount of error in the noisy computation can be reduced by appropriately modifying the angles of the gates comprising the quantum simulation circuit, Eq. ( 7), a method known as feedforward control.We develop a systematic, platform-independent protocol to determine the modified gate angles in the next section.We then illustrate the benefits of the feedforward control in the context of the Hamiltonian simulation task by showing improvements in the fidelity and Hellinger distance for an example Hamiltonian of the form in Eq. ( 1).

V. FEEDFORWARD CONTROL
A quantum computation or simulation involves applying a unitary operation Û to a system of qubits.Often, this unitary transformation is a composite of several single-and two-qubit unitary gates Û (ϕ) = exp −iϕ Â , with Â typically linear or bilinear in spin-1/2 operators, Ŝα j = σα j /2.A unitary error in the system manifests  as application of Û (ϕ) when we intend to apply Û (ϕ p ).We usually do not have deterministic knowledge of the value of the incorrect angle, ϕ, and therefore describe it with a probability distribution p ϕ ϕ; ϕ in , ⃗ λ , where ⃗ λ is a vector of latent variables characterizing the physical noise underlying the system and ϕ in is the angle we input when applying the gate.If the gate was noiseless, we would have p ϕ ϕ; ϕ in , ⃗ λ = δ (ϕ − ϕ in ) and would input ϕ in = ϕ p , where ϕ p is the desired output gate angle.The idea of feedforward control is to appropriately adjust the input gate angles of the computation to reduce the error accumulated from incorrect gate angles.
Formally, let the total unitary describing the actual computation be Û = M m=1 Ûm ϕ (m) , where Ûm ϕ (m) = exp −iϕ (m)  Âm .The desired computa- . As the output angles are probabilistic, a particular manifestation of the output computation Û depends on the joint probability distribution p ⃗ ϕ ⃗ ϕ; ⃗ ϕ in , ⃗ λ , where ⃗ ϕ in and ⃗ ϕ are the m different input and output angles respectively.The goal of feedforward control is to pick the optimal input angles, ⃗ ϕ * in , such that the computation Û is close to Ûp on average.In general, ⃗ ϕ * in will depend on both the set of desired output angles, ⃗ ϕ p , and the latent noise variables, ⃗ λ.Optimizing over the entire computation, however, can be challenging as it requires knowledge of the full joint distribution, p ⃗ ϕ , which is generally non-trivial to compute, even for the model presented in Sec.III.Additionally, even if possible, such an optimization may not generalize well to other computations represented by different gate sequences.We therefore focus on optimizing each individual unitary gate independently of the others, which amounts to neglecting correlations between unitary gate errors and assuming that they are independent and identically distributed according to the marginal distribution, p ϕ .Mathematically, this amounts to the factorization of the joint distribution: . Temporal correlations in the physical noise underlying the system lead to correlations in the angles ⃗ ϕ that are not captured by such a factorization.Feedforward optimization of individual gates can therefore only partially mitigate the error in the overall computation.Ignoring the non-Markovian effects discussed in Sec.IV implies that the feedforward control is best applied at sufficiently shallow gate depths; when circuit discretization becomes comparable to temporal correlations of noise, the feedforward correction will be inaccurate.The advantage of ignoring error correlations, however, is that the correction can be easily applied to any computation, Û , as it done at the level of individual gates.
The error due to applying a gate Û (ϕ) when we desire to apply Û (ϕ p ) can be quantified by the gate fidelity which describes the expected fidelity of an n-qubit gate for a random state drawn uniformly from the n-qubit state space [28].For example, let us consider a unitary gate corresponding to Â = Ŝα i Ŝα j describing an interaction between two qubits i and j.The fidelity then takes the simple form F (ϕ, ϕ p ) = cos 2 ((ϕ − ϕ p )/4).The figure of merit we want to optimize with feedforward control is the average fidelity over all possible wrong angles ϕ, The optimal input angle is then Calculation of this optimal feedforward angle requires knowledge of the control landscape defined by the dependence of the figure of merit, Eq. (30), on the input angle ϕ in and desired output angle ϕ p .This landscape can either be numerically mapped out with experimental measurements, or analytically computed after developing a theoretical description of the noise underlying the system.
As an example of the latter approach, the distribution p ϕ ϕ; ϕ in , ⃗ λ for the trapped ion noise discussed in Sec III is given by Eq. ( 14).The ion noise is parameterized by a single latent variable, λ = c 2 τ , which can be experimentally extracted by measuring the return probability Eq. (22).The figure of merit for feedforward control, Eq. (30), in this case can be analytically computed: The optimal input angle, ϕ * in (ϕ p , c 2 τ ), for the trapped ion noise is the angle which satisfies the condition where we recall that F (ϕ, ϕ p ) = cos ((ϕ − ϕ p )/4) is the fidelity of a gate imparting angle ϕ when we desire to apply ϕ p .We implement feedforward control by taking each desired output gate angle, ϕ ij , of the Û xx gates in Eq. (7) as ϕ p at the experimental time τ that the gate is applied.The optimality condition, Eq. ( 33), is then solved numerically for each such gate and the angle ϕ * in is input into the noisy gate rather than ϕ ij .We show the optimal input angle, Fig 4(a), and average gate fidelity, Fig 4(b), for a range of desired output angles ϕ p .First, we note that the optimal feedforward angle, ϕ * in , always yields a better average fidelity than inputting ϕ p .We see that for small output angles, there is always a finite optimal input angle.For sufficiently large output angles, however, the optimal input angle is ϕ * in = 0, meaning we do not apply the gate.These angles are such that doing nothing leads to a better fidelity than any non-zero gate we apply.Furthermore, for times τ > 1/c 2 , meaning that the ions' collective motion has undergone a considerable amount of diffusion, there is an intermediate range of angles where the optimal thing to do is apply a maximally strong laser pulse to make ϕ * in as large as possible.In this case, the gate essentially applies a random phase to the state and yields an average fidelity of 1/2.
To benchmark the utility of the feedforward control, we implement with Hamiltonian simulation task of Sec II using optimal input angles computed from Eq. (33).In Fig. 5,we plot an example of the time-dependent fidelity, Eq. ( 26), for different heating rate and gate counts with and without feedforward control.We see that for low gate counts such as computations with 100 gates, the drop in fidelity comes almost fully from Trotter error without heating noise having much of an effect.For larger gate counts, heating noise becomes the dominant cause of the drop in fidelity.While the fidelity for the zero heating case gets continuously better with increased gate count, finite heating causes computations with sufficiently large gate counts to decrease the overall fidelity.
Feedforward control can improve the situation in two different ways, which can be seen by comparing, for example, the 300 gate and 700 gate curves.The first effect is to improve the total fidelity over all time values, as quantified by the improvement in F int , Eq.( 27), depicted in Fig. 6.This improvement indicate that the computation of Û1 (t) is closer on average to the desired computation Û (t) for all values of t, with the feedforward correction bringing the fidelity of a computation closer to the upper bound set by the Trotter error.The second effect is that for computations with large gate counts, the fidelity for samples at late times, corresponding to large values of t, is improved more significantly than for short time samples.This improvement causes the fidelity to have a more shallow decay, and creates windows of time samples where it may be more advantageous to use circuits with different gate counts.For example, in Fig. 5(c), a computation with 300 gates is advantageous for samples with c 2 t ≲ 3, while a computation with 700 gates is advantageous for samples with c 2 t ≳ 3. The significance of this result is that a particular observables of interest may have information that is more concentrated in a particular time window.For example, the resolution between peak of the spectrum, Eq. ( 2), comes from samples at late times.Therefore, the optimal gate count determined by the accuracy of the spectrum may be larger than the optimal gate count determined by the integrated fidelity.Indeed, this is what is seen when comparing Fig. 6 and Fig. 7.
In Fig. 7(a) and (b), we show the optimal gate count and associated Hellinger distance of spectra computed both with and without the feedforward correction.We see that the accuracy of the optimal noisy spectrum is significantly improved.An example spectrum for a system with heating rate c 2 = 0.02 ms −1 is depicted in Fig. 2 Hellinger distance between the average Hamiltonian's noisy spectrum and the target spectrum with and without feedforward correction.(b) Spectrum comparison.We take the average Hamiltonians found at the initial and last iterations of the noisy inference protocol and simulate what its spectrum would be if there was no noise.The fact that the last spectrum is significantly closer to the target spectrum compared to the initial spectrum gives a visual indication of the improvement in the underlying Hamiltonian during the inference protocol.The phonon heating rate is taken to be c2 = 0.02 ms −1 and the noisy spectra are computed with 500 gates and averaged over 10 runs.
decoherence error from the motion of the ions and indirectly reduces the Trotter error by increasing the optimal gate count.Therefore, by effectively increasing the optimal gate depth of the circuit, feedforward control can be used to partially mitigate both discretization error and accumulated unitary gate error in the system.

VI. DISCUSSION & CONCLUSION
This improvement in the quality of the Hamiltonian simulation can be helpful for practical applications, such as the NMR spectrum inference task discussed in Ref. [9].In that work, a hybrid quantum-classical algorithm is used to infer the parameters of a Hamiltonian, Eq. ( 1), that models the system of nuclear spins which produce a given experimental NMR spectrum.The premise of the algorithm is to iteratively simulate the spectrum corresponding to different Hamiltonian parameters on quantum hardware and guess parameters that are closer to the target experimental spectrum using classical optimization techniques.After a sufficient number of iterations, the learned Hamiltonian parameters can be used to gain insight into the chemical structure of the sample that produced the given NMR spectrum.In Fig. 8, we demonstrate the benefit of feedforward correction in this inference algorithm.Figure 8(a) shows the Hellinger distance between the average noisy Trotterized spectrum and a given target spectrum at each iteration of the protocol.We see that the feedforward correction allows the algorithm to converge faster, as the increased resolution in the simulated spectra allows the classical optimization to more easily guess better Hamiltonian parameters.In Fig. 8(b), we take the Hamiltonian parameters for the initial and last iterations of the noisy protocol with feedforward correction and compute the corresponding spectra without noise to compare how well the learned parameters correspond to the true parameters underlying the given target spectrum.We see that even though the quantum simulation is noisy, we are still able to iteratively infer the Hamiltonian parameters underlying the target spectrum.
We have shown how to tailor gate-based quantum simulation algorithms for particular hardware platforms.Specifically, we demonstrate how knowledge of hardware noise leading to unitary gate errors can be exploited to implement feedforward control to improve the simulation outcome.The ion noise model we derive applies to an array of computations and simulations performed in trapped ions.Feedforward control, albeit being unable to correct for temporal correlations in the noise, can be used to partially mitigate errors in these applications.A similar approach may ameliorate errors other than the leading order rotation error captured by our noise model, but would require the development of noise models accurately describing such errors.
In addition to feedforward control, it may be possible to incorporate feedback control to mitigate the motional noise.For example, the motional state of an an ancilla ion can be periodically measured.Such a strong mea-surement, or relatedly mid-circuit cooling, would restart the ions' diffusion process, effectively reducing the time τ over which the system undergoes diffusion.Knowledge of the motional state can then be used to generate feedforward corrections until they are recalibrated by the next measurement.
Other common quantum platforms such as superconducting qubits and Rydberg atoms also suffer from unitary gate errors.The physical mechanisms underlying these errors, however, is quite different from that of trapped ions and understanding the structure of the optimal feedforward correction in these systems may provide insight into which quantum algorithms and simulations are best suited to different platforms.

FIG. 3 .
FIG. 3. Return probability predictions for experimental protocol to extract c2.(a) Curves for different wait times, τ , as a function of input angle ϕin.(b) Difference between derived noise model and phase damping.

FIG. 4 .
FIG. 4. Optimal feedforward control characterization.(a) Optimal input angle.(b) Average gate fidelity.The black dashed line depicts the fidelity if no gate is applied and the dotted lines represent the fidelity if the desired output angle, ϕp, is directly taken as the input to the gate.

FIG. 5 .
FIG. 5. Time dependent fidelity of noisy Trotterized time evolution for a system of four spins evolving under the Heisenberg Hamiltonian, Eq. (1).Solid curves include both heating noise and Trotter error, while the dotted curves include only Trotter error and are given as a noiseless reference.(a) c2 = 0.005 ms −1 and no feedforward correction.(b) c2 = 0.02 ms −1 and no feedforward correction.(c) c2 = 0.005 ms −1 with feedforward correction.(d) c2 = 0.02 ms −1 with feedforward correction.The noisy computations are averaged over 40 runs.

FIG. 6 .FIG. 7 .
FIG.6.Optimal fidelity resulting from balancing Trotter and decoherence errors for a system of four spins evolving under the Heisenberg Hamiltonian, Eq. (1).The heating rate c2 is given in units of ms −1 .(a) Optimal gate count.(b) Integrated fidelity.The noisy computations are averaged over 10 runs.
. The feedforward control both directly mitigates FIG. 8. Simulation of NMR inference algorithm with motional noise and Trotter error for a system of four spins.At each update step of the protocol, noisy spectra computed from a set of sample Hamiltonians are used to calculate the next update step (a)