Methodology for replacing indirect measurements with direct measurements

In quantum computing, the indirect measurement of unitary operators such as the Hadamard test plays a significant role in many algorithms. However, in certain cases, the indirect measurement can be reduced to the direct measurement, where a quantum state is destructively measured. Here we investigate in what cases such a replacement is possible and develop a general methodology for trading an indirect measurement with sequential direct measurements. The results can be applied to construct quantum circuits to evaluate the analytical gradient, metric tensor, Hessian, and even higher order derivatives of a parametrized quantum state. Also, we propose a new method to measure the out-of-time-order correlator based on the presented protocol. Our protocols can reduce the depth of the quantum circuit significantly by making the controlled operation unnecessary and hence are suitable for quantum-classical hybrid algorithms on near-term quantum computers.

Introduction -The output from quantum computation is measured in two ways; indirect and direct measurement of observables.In the former, the measured quantum state is not completely destructed, whereas, in the latter, the state collapses to the basis on which we perform the measurement.The simplest and important protocol for the indirect method is the Hadamard test (Fig. 1).In the Hadamard test, we add an ancillary qubit and apply a controlled unitary gate, a unitary U to a target quantum state |ψ conditioned on the ancilla being |0 or |1 to measure expectation value of ψ|U |ψ as the Z expectation value of the ancilla.This measurement allows us to reuse the state (I ± U ) |ψ / √ 2 after the measurement, which is the property exploited in algorithms like iterative phase estimation [1,2].
Such indirect approaches can achieve the precision of in O(1/ ) time.However, the implementation of the controlled-U gate can be a hard task especially for socalled noisy intermediate scale quantum (NISQ) [3] devices.In fact, direct measurements can be satiable when only an expectation value of an observable is required.A famous example is estimation of energy expectation values in the variational quantum eigensolver (VQE) [4], which is one of the most promising applications of NISQ devices.The time required to achieve the precision of is O(1/ 2 ) in this approach, which is in contrast with the indirect approach [5,6].
Another example, which replaces the indirect approach with the direct one, is the destructive swap test [7].It is a direct version of the swap test [8] which measures the overlap | ψ|ϕ | 2 between two quantum states |ψ and |ϕ .After a while from the first proposal [7], it has been rediscovered by machine learning approach [9], and now it is utilized for applications of NISQ devices [10][11][12].Ref. [13]  with U |ψ , and also extended the protocol to measure the quantity | ψ|P |ϕ | 2 , where P is a qubit-permutation operator, which can be employed to estimate nonlinear functionals of a quantum state ρ such as Tr(ρ n ) [14], with a low-depth circuit.
Furthermore, methods for estimating gradient employed in variational quantum algorithms (VQA) also illustrate the correspondence between those two approaches for certain cases.VQAs such as the VQE employ a parametrized quantum circuit U (θ) and classical optimizer, which minimizes a cost function L(θ) by iteratively tuning the circuit parameter θ.The cost is usually computed from expectation values of observables, therefore, the gradient of them can be a key ingredient for the optimization.We can estimate the gradient in two ways.Indirect and direct schemes have been proposed in Ref. [15] and Refs.[16,17], respectively.The indirect method uses two different quantum circuit to estimate one element of the gradient.
These examples motivate us to further develop the methodology for replacing the indirect measurement with the direct measurement.In this work, we describe the general protocol for such replacement.The protocols for the Hadamard test involving a single controlled gate are given as Result 1 and 2. Result 1 is a generalization of the method used in VQE, and Result 2 is a generalization of the destructive swap test which applies to general local unitary gates.Finally, as Result 3, we describe a method to replace the Hadamard test involving multiple controlled gates.It is a generalization of the method to estimate the gradient of observables with direct measurement, that is, we employ multiple quantum circuits to estimate the output of the Hadamard test.The replacement can significantly reduce the depth of a quantum circuit and the accumulating effect of noise to the measured quantity.Based on above results, we propose new methods to estimate higher order gradient including the metric tensor of variational quantum state |ψ(θ) and Hessian of an observable.Specifically, the metric tensor is a key quantity in variational quantum simulations [18,19].Finally, we present a new protocol to measure multipoint correlator like out-of-time-order correlators (OTOC), which is an important quantity in a quantum many-body system as a possible measure of quantum chaos [20][21][22][23].
Hadamard test with one controlled gate -Let us first consider the case where the unitary U in Fig. 1 is given by an exponential U (θ) = e −iθG of an Hermitian operator G such that G 2 = I.In this case, Z of the ancilla in the Hadamard test becomes ψ|U |ψ = cos θ 2 − i sin θ 2 ψ|G|ψ .Hence the measurement of ψ|G|ψ , which is just the expectation value of G, suffices to replace the Hadamard test.We can evaluate it efficiently if G can be decomposed as G = P ∈P a P P , where a P ∈ R and P = {I, X, Y, Z} ⊗n , with the polynomial number of terms with respect to the number of qubits.More generally, the same applies if the gate U itself can be decomposed into the sum of Pauli products consisting of the polynomial number of terms, which naturally include the previous case.Therefore we have the following.
Result 1: If the gate U can be decomposed into the sum of Pauli products with the polynomial number of terms with respect to the number of qubits, the output of Fig. 1, ψ|U |ψ , can be estimated with direct measurement by evaluating each Pauli terms.
A prototypical example of the above result is the replacement of the phase estimation with direct measurements in the VQE.The tradeoff of the protocol above is the time required to achieve the precision of .It scales as O(1/ 2 ) in the direct approach and O(1/ ) in the indirect approach, i.e., the phase estimation.
Next, we describe another method for the case where the quantum gate U is sufficiently local.It is the generalization of the destructive swap test [7].We say U is k-local if U can be decomposed into a tensor product of unitary matrices as U = q U q and each U q acts on at most k-qubit.With this definition, the result can be stated as follows.
Result 2: Let k be an integer such that k = O(poly(log n)), where n is the number of qubits.For This result follows from the following reasons.By the definition of k-local unitary matrix, U can be decomposed into U = Q q=1 U q .Let the number of qubits on which U q acts and eigenvalues of U q be k q and {exp (iφ q,m )} 2 kq −1 m=0 , respectively, where φ q,m ∈ [0, 2π].We denote the computational basis of each subsystem by |m q using integer m q = 0, • • • , 2 kq − 1.In this setting, U q is a 2 kq × 2 kq matrix.Classical computation can diagonalize each U q and obtain a unitary matrix V q such that U q = V † q D q V q , where D q = 2 kq −1 m=0 e iφq,m |m q m q |, in polynomial time to n by the assumption k = O(poly(log n)).Then, ( Therefore, we can estimate ψ| U |ψ by evaluating the probability of getting the result Q q=1 |m q from the measurement of Q q=1 V q |ψ in the computational basis.More concretely, let the j-th measurement result be m (j) q and the total number of measurement be N .Then ψ| U |ψ is estimated by ψ| U |ψ ∼ q exp iφ q,m (j) q scales as o(1/ √ N ) from the central limit theorem.Since the number of gates to implement V q can scale as O(k 2 q 2 kq poly(log(k 2 q 2 kq ))) in general [24], the overall time for this protocol is O(k 2 2 k poly(log(k 2 2 k ))/ 2 ) with classical preprocessing for the diagonalization of each V q in time O(poly(log n)).
Hadamard test with multiple controlled gates -Now we describe how to reduce an Hadamard test with multiple controlled gates to circuits without an ancilla qubit.The protocol given below is for the Hadamard test with two controlled gates (Fig. 2 (a)).It is straightforward to generalize the method to the case of more than two controlled gates.In the case of Fig. 2 (a), the measured The first term of the right hand side of the above formula is merely an expectation value of U with respect to the state W |ψ , therefore, if U satisfies one of the conditions mentioned in Results 1 and 2, we can evaluate it efficiently.Even if it does not, the protocol which uses destructive swap test to measure | ψ|U |ψ | 2 [13] can be utilized to estimate it using a quantum computer with 2n qubit.For the second term, we present a method involving a projective measurement of G, which we denote by M G .When G is a Pauli product, i.e.G ∈ {I, X, Y, Z} ⊗n , M G can be performed by first transferring G to a single qubit Z and then performing a measurement on the qubit nondestructively, for example with the dispersive readout of a superconducting qubit.This protocol of M G can, in principle, be generalized to G such that the degeneracy of its eigenvalue ±1 is equivalent although such a circuit can be exponentially hard to construct.On the other hand, for G which does not satisfy the above condition, M G requires an ancilla qubit due to the impossibility of transferring G to a single qubit Z.To estimate ψ|W † U W G|ψ , we use the following four quantities for its estimation, where p(M G = ±1) is probability of getting the result 2 (b) and (c) show the quantum circuit to estimate them.With these, ψ|W † U W G|ψ can be estimated by, Note that when U is Hermitian, the first two terms corresponds to the real part, and the rest corresponds to the imaginary part of ψ|W † U W G|ψ .Therefore, we have the following.Result 3: Let W , U and G be unitary matrices.Suppose U satisfies a condition of Results 1 and 2, and G 2 = I.It is possible to estimate the output of the circuit in Fig. 2 (a), ψ|W † U W e −iθ1G/2 |ψ , by using four quantum circuits in Fig. 2  We can extend the strategy of the methods described in the above sections to evaluate the output from the Hadamard test in the case where it has more than two controlled gates.By the construction of this method, the number of terms that we need to measure grows exponentially to the number of controlled gates, while in practice a few controlled gates are enough as seen later.Advantage -Now let us discuss the possible merits of our protocols.Result 1, 2 and 3 can provide a drastic reduction of depth of a quantum circuit.The reduction is due to the fact that it is generally a hard task to make a controlled-U gate for a given U .For example, a Toffoli gate, which is a controlled-CNOT gate, requires at least six CNOT gates for its construction [25].Along with the depth reduction, the disuse of an ancilla qubit is a nice advantage for qubit-limited, near-term quantum computers.Result 3 has the same advantages as the above three, apart from the reduction of the effect of noise.In the Hadamard tests of the type described in Fig. 2 (a), the ancilla qubit has to tolerate dephasing error during the gate W .In contrast, the ancilla qubit used in the protocol of Result 3 does not have to endure the noise; it is measured projectively at M G .Applications -As the first application, we describe the direct measurement of derivatives of a parametrized quantum state.In VQAs such as the VQE [4], we employ a parametrized quantum circuit U (θ) and an input state |ψ in on an n-qubit quantum computer, and optimize the circuit parameter θ with respect to an expectation value A(θ) = ψ in |U † (θ)AU (θ)|ψ in of an observable A. Let us consider the case where the parametrized quantum circuit is constructed as and each unitary U j (θ j ) is generated by a Pauli product P j ∈ {I, X, Y, Z} ⊗n ; U j (θ j ) = exp (−iθ j P j /2).We denote U k (θ k ) • • • U j (θ 1 ) by U k:j .In VQAs, we consider A which can be decomposed into a sum of Pauli products, and therefore, without loss of generality, we assume A ∈ {I, X, Y, Z} ⊗n .
In Fig. 3 (a), we show a quantum circuit to evaluate the analytic gradient of an expectation value of an observable A as presented in Ref. [15].The circuit of Fig. 3 (b) measures an equivalent quantity, and this circuit is equivalent to that one in Fig. 2 (a) when we replace e −iθG/2 with P j , U with A. Since we assumed A is a Pauli product, it satisfies the condition in Result 1.Therefore, Result 3 can be employed to measure the gradient.Note that the gradient of A is which only involves the last two terms of Eq. ( 6), and hence we do not need to evaluate the circuit in Fig. 3 (b).This method can easily be extended to evaluate the Hessian.
The metric tensor g jk = ∂ ψ(θ)| ∂θj ∂|ψ(θ) ∂θj of a variational quantum state |ψ(θ) = U (θ) |ψ in can be measured in the same manner.This quantity is the key for executing variational quantum simulations.Specifically, the imaginary and the real part of g jk are employed for the simulation of real [18] and imaginary time [19] evolutions, respectively.A quantum circuit for its evaluation from Refs.[18,19] is shown as Fig. 4 (a).The explicit expression for g jk , when k > j, can be written as: Figure 4 (a) shows the quantum circuit for the indirect measurement of g jk .Again, by Result 3, This circuit can be replaced with the ones in Fig. 4 (b) and (c).An explicit expression is: Figure 4 (a) differs from Fig. 2 (a) with two additional X gates on the ancilla.The consequence of this is the sign flip in the imaginary part (compare Eq. ( 10) and ( 6)).Next, we propose a new method to estimate the OTOC on quantum computers.The OTOC F (t) at time t is defined with two non-commuting operator A and B and a system Hamiltonian H as F (t) = B † (t)A † B(t)A , where B(t) = e iHt Be −iHt .It is an important quantity in quantum many-body physics measuring how chaotic a given quantum system is [20][21][22][23].Ref. [26] has proposed the circuit to evaluate F (t) as shown in Fig. 5.If we assume A 2 = I, the circuits in Fig. 2 (b) and (c) and Eq. ( 6) can be applied directly, with the sign flip of the imaginary part as the consequence of the X gates performed on the ancilla qubit.More concretely, to evaluate F (t), we replace W in Eq. ( 6) with U † (t)BU (t), U and G with A. This method can readily be extended to the measurement of higher order correlators.Conclusion -We provided general protocols to replace the indirect measurement, especially, the Hadamard test, with the direct measurement.The proposed methods to replace the Hadamard test provides means to evaluate analytical gradient, metric tensor, Hessian, and even higher order derivatives with direct measurement for parameter tuning in variational quantum algorithms.It can also be applied for the estimation of OTOC.The presented protocols can significantly reduce the depth of a quantum circuit, and consequently, are important subroutines for quantum algorithms, especially for those of NISQ devices.
KM thanks METI and IPA for its support through MITOU Target program.KF is supported by KAK-ENHI No.16H02211, JST PRESTO JPMJPR1668, JST ERATO JPMJER1601, and JST CREST JPMJCR1673.This work is supported by MEXT, Q-LEAP.
any k-local quantum gate U , it is possible to estimate ψ| U |ψ up to the precision in time O(k 2 2 k / 2 ) without the use of the Hadamard test, with classical preprocessing of time O(poly(log n)).

FIG. 2 .
FIG. 2. (a) Hadamard test with two controlled gates.In the figure, W is an arbitrary quantum gate.(b), (c) Quantum circuits to estimate the output of (a) with direct measurement.MG is the projective measurement of G

FIG. 3 .
FIG. 3. Quantum circuit for the estimation of ∂ A(θ) ∂θ j .(a) Circuit with an ancillary qubit from [15].Zanc is the Pauli Z acting only on the ancillary qubit.The output of the circuit, ZancA j , corresponds to the gradient as ZancA = − ∂ A(θ) ∂θ j .(b) Quantum circuit which has equivalent output as (a); ZancA j = Zanc j .