Measuring Trotter error and its application to precision-guaranteed Hamiltonian simulations
Abstract
Trotterization is the most common and convenient approximation method for Hamiltonian simulations on digital quantum computers, but estimating its error accurately is computationally difficult for large quantum systems. Here, we develop a method for measuring the Trotter error without ancillary qubits on quantum circuits by combining the th- and th-order () Trotterizations rather than consulting with mathematical error bounds. Using this method, we make Trotterization precision-guaranteed, developing an algorithm named Trotter, in which the Trotter error at each time step is within an error tolerance preset for our purpose. Trotter is applicable to both time-independent and -dependent Hamiltonians, and it adaptively chooses almost the largest stepsize , which keeps quantum circuits shallowest, within the error tolerance. Benchmarking it in a quantum spin chain, we find the adaptively chosen to be about ten times larger than that inferred from known upper bounds of Trotter errors.
I Introduction
The rapid development of quantum devices in recent years has led researchers to find useful applications with significant quantum advantage [Harrow2017, Cao2019, Cerezo2021]. On top of the eigenvalue problems [Aspuru-Guzik2005, Lloyd1996, Whitfield2011, Higgott2019, Jones2019, Kirby2021], quantum many-body dynamics, or Hamiltonian simulation [Babbush2015, Low2017, Campbell2019, An2021, An2022, Childs2022], is one of the most promising candidates because quantum computers could overcome the exponential complexity that classical computers face [Lloyd1996], enabling us to address intriguing dynamical phenomena like nonequilibrium phases of matter [Swingle2016, Zhang2017, Landsman2019, Joshi2022] and to implement fundamental quantum algorithms like phase estimation [Kitaev1995]. Among several algorithms for the Hamiltonian simulation, Trotterization [Trotter1959, Hatano2005] is and will be used most commonly in the current noisy intermediate-scale quantum (NISQ [Preskill2018]) era and the coming early fault-tolerant quantum computing (FTQC) era because it does not demand additional ancillary qubits or largely controlled quantum gates. Indeed, quantum advantage in Trotterized dynamics simulation has been reported using a 127-qubit NISQ computer only recently [Kim2023].
One major and presumably inevitable issue of Trotterization is the trade-off relation between the simulation accuracy and the circuit depth (see, however, Refs. [Barison2021, Mansuroglu2023] for variational approaches). The -th order Trotterization accompanies an error of during a single time step , which decreases when is taken shorter. In the meantime, the number of steps to reach a final time increases, meaning a deeper quantum circuit. To suppress the gate depth, it is desirable to choose the largest possible stepsize , i.e., the shallowest circuit, within our error tolerance preset for our purposes.
However, it is difficult to find the optimal stepsize because the Trotter error is complex in generic many-body systems. According to the previous studies on the Trotter error, its upper bounds [Kivlichan2020, Childs2021] and typical values [Zhao2021] are available. If we choose so that the upper bound is below our tolerance , the precision is guaranteed, but tends to be too small, as we will see below. On the other hand, if we choose based on the typical values, can be larger, but the precision guarantee is lost. Recently, Zhao et al. [Zhao2022] proposed an approach where is chosen adaptively in each time step based on the energy expectation value and variance. Yet, the precision guarantee of this method is still elusive, and the applicability is limited to time-independent Hamiltonians 111After the submission of our work, Zhao et al. [Zhao2023] publicized their adaptive-stepsize Trotterization generalized to time-dependent Hamiltonians..
In this paper, we develop a method to measure the Trotter error on quantum circuits by combining Trotterization formulas at different orders, and . Since measured, the estimated error is significantly more accurate than known upper bounds for it and thus allows us to accurately choose the largest possible stepsize so that the error does not exceed our tolerance . Using this method, we make Trotterization precision-guaranteed, in which almost the largest is adaptively chosen within a preset error tolerance (see Fig. 1 for its structure). We name this algorithm Trotter in analogy to RFK45 (Runge-Kutta-Fehlberg) for classical simulations, where the fourth- and fifth-order methods are combined. We benchmark Trotter24 in a quantum spin chain under time-independent and -dependent Hamiltonians, finding that the adaptively chosen is about ten times larger than that inferred from the upper bound of Trotter errors.
![Refer to caption](https://cdn.statically.io/img/arxiv.org/x1.png)
II Measuring Trotter error
In this section, we present a way to measure a Trotter error on quantum circuits without ancillary qubits when a quantum state is evolved by an -th order Trotterization for a small time step . A key idea is making use of a higher-order -th Trotterization to approximate the unknown exact solution accurately enough.
II.1 Extracting Trotter error using different orders
For simplicity, we first consider a time-independent Hamiltonian consisting of two parts,
(1) |
where and do not necessarily commute with each other. Generalization to more noncommuting parts is straightforward, and we will generalize the arguments to time-dependent ones later in Sec. LABEL:sec:tdep. We assume that the quantum state at time is known to be and consider evolving it by a small time step ,
(2) |
Trotterization approximately decomposes into quantum-gate-friendly parts consisting of either and . We take an -th order Trotterization . For example, can be the Lie-Trotter formula for or its symmetrized form for . In general, approximates up to the order of and satisfies
(3) |
where is an anti-Hermitian error operator. These relations imply
(4) |
meaning that approximates the exact one-step evolution within an error of .
To quantify the error arising in the one step, we adopt the square root of the infidelity
(5) |
We can also use other quantities depending on our purposes and make parallel arguments. For example, when we are interested in the expectation value of an observable , we care about the error in it,
(6) |
In either case, calculating or is difficult because we do not know the exactly evolved state .
We remark that both and are , but showing is less obvious. To show this, we note that the leading term of is pure-imaginary as shown in Appendix LABEL:app:error, and its leading-order contribution of is given by
(7) |
where is Hermitian. Equation (II.1) dictates that is the variance of the “observable” , giving a way to estimate using and the explicit form of . Indeed this is a possible way of measuring , but it requires, for generic many-body Hamiltonians, measuring numerous Hermitian operators involved in consisting of doubly nested commutators between and . Hence, in the following subsection, we will also discuss another way to estimate with less sampling costs.
Our idea of estimating the errors is the following: In calculating and in the leading order, we can safely replace the exact by a higher-order approximant for . Replacing by in and , we obtain the following key analytical results (see Appendix LABEL:app:error for derivation): For the fidelity error,
(8) | ||||
(9) |
and, for the observable error,
(10) | ||||
(11) |
Given that and , these results mean that () coincides with () in the leading order since . If , the above equations hold true, but contributions are nonnegligible, and do not give good estimates for .
Unlike and , and consist of and and are thereby implementable in quantum circuits. In other words, we can estimate the deviation from the exact solution induced by without knowing the solution when supplemented with the fourth-order Trotterization and neglect higher-order corrections. We will discuss in more detail how to measure and in Sec. II.2.
We emphasize that and are the actual Trotter error specific to the current state . This contrasts the upper-bound arguments on the operator difference [Kivlichan2020, Childs2021]. Such upper bounds apply to arbitrary states and are thus always larger than or equal to the error occurring at a specific state . The fact that and are state-dependent enables us to choose more accurately so that the error is below our tolerance, as we will see in detail below.
We highlight two sets of of particular interest in practical use. The first choice is the minimum pair , for which the Trotterizations and involve the minimum possible exponentials, i.e., the gate complexity in the quantum circuit. For noisy circuits, such lowest-order Trotterizations are commonly used to avoid gate errors as much as possible. The second choice is the pair of minimum even numbers , which can be useful when we can use more gates to achieve higher accuracy. Changing from 1 to 2 increases the number of exponentials in from 2 to 3, by which the Trotter error or becomes one-order smaller. In this case, using rather than could be beneficial. To see this, let us compare Ruth’s third-order formula [Ruth1983, Hatano2005],
(12) |
and the fourth-order Forest-Ruth-Suzuki (FRS) formula [Forest1990, Suzuki1990]
(13) |
where . Here we note that the FRS formula involves only one extra exponential but is one-order more accurate than Ruth’s third-order formula. Since estimates one-order more accurately at the expense of an extra exponential, it can be worth using for .
II.2 Quantum circuit implementations
In Sec. II.1 we derived two expressions, Eqs. (II.1) and (8), for estimating the fidelity error and one (10) for the observable error . We are assuming a quantum advantage regime, where the number of qubits is so large that cannot be stored in classical computer memory but is realized on a quantum circuit. In such a regime, all the expressions for and cannot be evaluated with classical linear algebraic computations, and we need to develop ways to evaluate them on quantum circuits.
First, let us consider how to measure the leading-order contribution in Eq. (II.1) of the fidelity error , assuming that is realized on a quantum circuit accurately enough. For concreteness we focus on the first-order Trotterization , for which and . Since and are Hermitian, one can evaluate the expectation values for them based on samplings (we will discuss the sampling cost below).
Although this method is useful for small quantum systems, it becomes quadratically costly for larger systems. To see this we consider a Hamiltonian with and are linear combinations of distinct local Pauli strings. Thanks to the commutator scaling [Childs2021], consists of distinct Pauli strings, and its expectation values are evaluated by estimating the expectation values of each Pauli string. Notably, the translation symmetries can reduce the number of combinations of measurements for expectation value estimations, even down to . However, is no more a commutator and involves Pauli strings. In most cases symmetries cannot reduce the number of measured operators to be subextensive, and the sampling cost tends to be extensive. This extensive sampling cost also appears in the energy variance estimation in Ref. [Zhao2022, Zhao2023]. Thus Eq. (II.1) tends to be useful only in small quantum systems.
In contrast, in Eq. (8) avoids measuring numerous distinct Pauli strings. To show this we write as . Here denotes the initialized state, is an initial state preparation unitary, and is some Trotterized unitary propagation from time 0 to . We assume and have appropriate circuit realizations. With these notations can be obtained by
(14) | ||||
(15) |
Our assumptions tell us that has a circuit realization, so can be interpreted by the probability of finding after being evolved by the circuit (see also the middle panel of Fig. 1). Note that is a kind of the Lochmidt echo [Wisniacki2012]. A challenge is that becomes exponentially small when the system size increases, so this procedure makes practical sense only in small systems. This issue is not technical but intrinsic in the fidelity error because it is the most stringent quantifier among many-body wave function errors.
The observable error is more useful for extensive quantum systems. Typically we are interested in local Pauli strings or their linear combinations of . The expectation value of each Pauli string can be estimated by measuring the wave function in its eigenbasis. Unlike fidelity, the expectation value does not decay exponentially with the system size. Also, symmetries, such as the translation one, can reduce the number of measured strings to possibly . When one is only interested in local observables, using is the cheapest option to guarantee precision.
In each method, the Trotter error estimation is based on sampling, and the statistical error can be a bottleneck to achieve high accuracy. The statistical error in general scales as , with denoting the number of samples (or shots). For the error estimation to be successful, this error should be smaller enough than the error, or , so must hold true. When we use as an estimator, the estimation error is determined by the larger of and (see Eqs. (8) and (10)). So, one cannot make the error estimation infinitely accurate by increasing when the available number of shots is limited finitely. Rather, would hold for a reasonably chosen set of , , and . In Section LABEL:sec:finiteShots, we will benchmark our way to estimate for in an example spin system and show that it works with for .
III Precision-guaranteed Trotterization
In the previous section, we developed the methods to evaluate Trotter errors on quantum circuits. Given that the Trotter error is known, one can make Trotterization precision-guaranteed: In each time step, one can make sure that the Trotter error is within a preset accuracy target . In this section we develop such an algorithm consisting of error measurements and step size optimization, as illustrated in Fig. 1 (The figure is for the fidelity version, but it works, in parallel, for the observable version.).
Our algorithm uses either and as the Trotter error estimator, and we name it Trotter. For concreteness we set and describe Trotter24 since the generalization to other is straightforward (we may use Trotter and Trotter interchangeably). In current NISQ devices, could be more realistic. Since the argument goes in parallel, we first focus on the fidelity error and will address the observable error later in this section.
Our overall task is to simulate the time evolution according to the Hamiltonian from the initial time to the final time , starting from an initial state . We set an error tolerance for the fidelity error in each time step. Initially, we have no a priori information about the appropriate time step, so take a reasonably small trial stepsize , say, with being a typical energy scale of . One could also choose so small that never gives larger error than our tolerance , as guaranteed by a mathematical bound (see Eq. (LABEL:eq:dt_bound) and Appendix LABEL:sec:errorbound for detail). One can also use this to know the upper bound, in advance, for the required quantum resources for the calculation, although they tend to be too pessimistic, as we will see below.
For the trial taken in either way, we implement and and calculate using a quantum circuit. Basically, we aim the stepsize to be so small that
(16) |
If this is true, we accept our trial and evolve our state as . If instead, our trial is too large and we need a smaller . In choosing appropriately, we invoke the leading-order scaling relation for some unknown independent of . We can use this relation to estimate by since we measured . For , we expect , which we wish is smaller than . Thus, the condition leads to as an optimal choice within our error tolerance. For a safety margin, we introduce a constant () and set as an updated trial . We repeat this update procedure until gets smaller than and accept the latest to evolve our state as .
Next, we move on to the second step, using a time step . In choosing this, we again use the latest obtained at the end of the previous time step. Since , we can expect the error scaling coefficient to be almost the same in the present and previous steps. Therefore, like in the updated trials within the previous time step, we have as a good candidate for the optimal stepsize in the present time step. We note that here is what was measured in the previous step, and we have not made any measurements in the present step yet. Using this as a trial stepsize, we implement and and calculate using a quantum circuit. Depending on whether is less or greater than , we accept or update like in the previous step.
The following iteration is straightforward and repeated until the accumulated evolution time exceeds the final time . We summarize a pseudocode for the algorithm in Algorithm III.
Fidelity-based Trotter24
Input: Initial and final times, and , an initial state , a Hamiltonian , an error tolerance , an initial stepsize , a safety constant (), an oracle function that calculates .
Output: An ordered list of unitaries that approximates within the error tolerance for each time step.
Let us make a parallel argument for the observable error instead of the fidelity error . At each time step, we measure and judge if the condition
(17) |
is met. This is an analog of Eq. (16), and we introduced the operator norm as a reference scale and put the subscript on the tolerance as to avoid confusion. The iteration scheme is parallel to the fidelity case.We summarize a pseudocode for the observable-based algorithm in Algorithm III.
{algorithm}Observable-based Trotter24