Variational optimization of parametrized quantum circuits is an integral component for many hybrid quantum-classical algorithms, which are arguably the most promising applications of Noisy Intermediate-Scale Quantum (NISQ) computers Preskill (2018). Applications include the Variational Quantum Eigensolver (VQE) Peruzzo et al. (2014), Quantum Approximate Optimization Algorithm (QAOA) Farhi et al. (2014)
and Quantum Neural Networks (QNNs)Farhi and Neven (2018); Huggins et al. (2018); Schuld et al. (2018).
All the above are examples of stochastic optimization problems whereby one minimizes the expected value of a random cost function over a set of variational parameters, using noisy estimates of the cost and/or its gradient. In the quantum setting these estimates are obtained by repeated measurements of some Hermitian observables for a quantum state which depends on the variational parameters.
A variety of optimization methods have been proposed in the variational quantum circuit literature for determining optimal variational parameters, including derivative-free (zeroth-order) methods such as Nelder-Mead, finite-differencing Guerreschi and Smelyanskiy (2017) or SPSA Spall et al. (1992). Recently the possibility of exploiting direct access to first-order gradient information has been explored. Indeed quantum circuits have been designed to estimate such gradients with minimal overhead compared to objective function evaluations Schuld et al. (2019).
One motivation for exploiting first-order gradients is theoretical: in the convex case, the expected error in the objective function using the best known zeroth-order stochastic optimization algorithm scales polynomially with the dimension
of the parameter space, whereas Stochastic Gradient Descent (SGD) converges independently of. Another motivation stems from the empirical success of stochastic gradient methods in training deep neural networks, which involve minimization of non-convex objective functions over high-dimensional parameter spaces.
The application of SGD to deep learning suffers from the caveat that successful optimization hinges on careful hyper-parameter tuning of the learning rate (step size) and other hyper-parameters such as Momentum. Indeed a vast literature has developed devoted to step size selection (see e.g.Jastrzebski et al. (2017)
). The difficulty of choosing a step size can be understood intuitively in the simple quadratic bowl approximation, where the optimal step size depends on the maximum eigenvalue of the Hessian, a quantity which is difficult to calculate in high dimensions. In practical applications the step size selection problem is overcome by using adaptive methods of stochastic optimization such as AdamKingma and Ba (2014) which have enjoyed wide adoption because of their ability to dynamically select a step size by maintaining a history of past gradients.
Independently of the improvements arising from historical averaging as in Momentum and Adam, it is natural to ask if the geometry of quantum states favors a particular optimization strategy. Indeed, it is well-known that the choice of optimization is intimately linked to the choice of geometry on the parameter space Neyshabur et al. (2015). In the most well-known case of vanilla gradient descent, the relevant geometry corresponds to the geometry as can be seen from the following exact rewriting of the iterative update rule
where is the loss as a function of the variational parameters and is the step size. Thus, vanilla gradient descent moves in the steepest descent direction with respect to the geometry.
In the deep learning literature, it has been argued that the geometry is poorly adapted to the space of weights of deep networks, due to their intrinsic parameter redundancy Neyshabur et al. (2015). The Natural Gradient Amari (1998), in contrast, moves in the steepest descent direction with respect to the Information Geometry. This natural gradient descent is advantageous compared to the vanilla gradient because it is invariant under arbitrary re-parametrizations Amari (1998) and moreover possesses an approximate invariance with respect to over-parametrizations Liang et al. (2017), which are typical for deep neural networks.
In a similar spirit, the quantum circuit literature has investigated the impact of geometry on dynamics of variational algorithms. In particular, it was shown that under the assumption of strong convexity, the geometry is sub-optimal in some situations compared to the geometry Harrow and Napp (2019). The intuitive argument put forth favoring the geometry is that some quantum state ansätze can be physically interpreted as a sequence of pulses of Hamiltonian evolution, starting from a fixed reference state. In this particular parametrization, each variational parameter can be interpreted as the duration of the corresponding pulse. This is not the only useful parametrization of quantum states, however, and it is thus desirable to find a descent direction which is not tied to any particular parametrization.
Ref. Harrow and Napp (2019) leaves open the problem of finding the relevant geometry for general-purpose variational quantum algorithms, and this paper seeks to fill that void. The contributions of this papers are as follows:
We point out that the demand of invariance with respect to arbitrary reparametrizations can be naturally fulfilled by introducing a Riemannian metric tensor on the space of quantum states, and that the implied descent direction is invariant with respect to reparametrizations by construction.
We note that the space of quantum states is naturally equipped with a Riemannian metric, which differs from and geometries explored previously. In fact, in the absence of noise, the space of quantum states is a complex projective space, which possesses a unique unitarily-invariant metric tensor called the Fubini-Study metric tensor. When restricted to the submanifold of quantum states defining the parametric family, the Fubini-Study metric tensor emerges as the real part of a more general geometric quantity called the Quantum Geometric Tensor (QGT).
We show that the resulting gradient descent algorithm is a direct quantum analogue of the Natural Gradient in the statistics literature, and reduces to it in a certain limit.
We present quantum circuit construction which computes a block-diagonal approximation to the Quantum Geometric Tensor and show that a simple diagonal preconditioning scheme outperforms vanilla gradient descent in terms of number of iterates required to achieve convergence
ii.1 Quantum Information Geometry
Consider the set of probability distributions onelements
; that is, the set of positive vectors, which are normalized in the 1-norm . The following function is easily shown to be metric on the probability simplex ,
where and denote the elementwise square root of the probability vectors in the probability simplex .
Now consider a parametric family of strictly positive probability distributions indexed by real parameters . It can be shown that the infinitesimal squared line element between two members of the parametric family is given by
where are the components of a (possibly degenerate) Riemannian metric called the Fisher Information Matrix. Letting denote the component of the probability vector corresponding to we have
Now consider a -dimensional complex Hilbert space . Given a vector which is normalized in the 2-norm , a pure quantum state is defined as the projection onto the one-dimensional subspace spanned by the unit vector . In direct analogy with the simplex, the following function is easily shown to be a metric on the space of pure states:
where are unit vectors. Letting denote a parametric family of unit vectors, the infinitesimal squared line element between two states defined by the parametric family is given by
where is the Fubini-Study metric tensor, which is defined in terms of the Quantum Geometric Tensor (see Wilczek and Shapere (1989) for a review),
Indeed if denotes an orthonormal basis for then one can easily verify that for the family of unit vectors defined by
we have .
Finally, although we have posed the discussion in finite-dimensions, all of the above concepts carry over to infinite-dimensional Hilbert spaces by replacing sums by integrals.
ii.2 Optimization problem
Consider a parametric family of unitary operators which are indexed by real parameters . Given a fixed reference unit vector and a Hermitian operator acting on , we consider the following optimization problem
where and . In particular, note that is normalized since is unitary. Global optimization of the nonconvex objective function is impractical, so we instead propose to search for local optima by iterating the following discrete-time dynamical system,
where is the symmetric matrix with component and we have introduced the following notation:
The first-order optimality condition corresponding to (10) is
which we solve using the pseudo-inverse as follows,
In the continuous-time limit corresponding to vanishing step size , the dynamics (10) is equivalent to imaginary-time evolution within the variational subspace according to the Hamiltonian , as reviewed in the supplementary material. In the Quantum Monte Carlo literature, the Stochastic Reconfiguration algorithm Sorella et al. (2007) has been developed which produces an estimate of (13) using classical Monte Carlo sampling from the Born probability distribution corresponding to .
ii.3 Parametric family
In a digital quantum computer the Hilbert space dimension
is exponential in the number of qubitsand the Hilbert space has a natural tensor product decomposition into two-dimensional factors . A parametric family of unitaries relevant to variational quantum algorithms consists of decompositions into products of non-commuting layers of unitaries. Specifically, assume that the variational parameter vector is of the form where denotes the direct sum (concatenation) and consider a unitary operator acting on qubits of the following form
where and are parametric and non-parametric unitary operators, respectively. The parametric family of states under consideration corresponds to the following subset of the unit sphere in Hilbert space:
For later convenience, we introduce the following notation for representing subcircuits between layers
so that, for example
where and . Moreover, we define the following convenience state for each layer :
ii.4 Quantum Circuit Representation of Quantum Geometric Tensor
Computing the Quantum Geometric Tensor corresponding to a parametrized quantum circuit of the form (14) is a challenging task. In this section we will show, nevertheless, that block-diagonal components of the tensor can be efficiently computed on a quantum computer, producing an approximation to the QGT of the following block-diagonal form:
Consider the th layer of the circuit parametrized by and let and denote the partial derivative operators acting with respect to any pair of components of (not necessarily distinct). For each layer there exist Hermitian generator matrices and such that,
where for simplicity we have dropped the layer index from the Hermitian generator , despite the fact that the generators can vary between layers. The commutativity of the partial derivative operators combined with unitarity of implies that .
Similarly, we have
It follows from unitarity of the subcircuit and Hermiticity of the generator that
Similarly, the so-called Berry connection is given by
Combining these expressions we obtain the following form for the th block of the QGT,
The operator is Hermitian since and thus the block-diagonal approximation of the QGT coincides with the block-diagonal approximation of the Fubini-Study metric tensor,
The preceding calculation demonstrates the following key facts:
The th block of the Fubini-Study metric tensor can be evaluated in terms of quantum expectation values of Hermitian observables.
The states defining the quantum expectation values are prepared by subcircuits of the full quantum circuit and are thus experimentally realizable.
Having identified the states for which the quantum expectation values are to be evaluated, we now turn to characterizing the Hermitian observables defining the quantum measurement.
For simplicity of exposition we focus on one of the most common parametric families encountered in the literature, which consists of tensor products of single-qubit Pauli rotations,
The rotation gates are given by
where , and denotes the Pauli matrix which acts on qubit of layer . The expressive power of this class of circuits was recently investigated in Du et al. (2018). In this case the generators are easily shown to be
where . These operators evidently satisfy . Since as a result of the Pauli algebra, it follows that the th block of the QGT requires the evaluation of the quantum expectation value where belongs to the following set of operators
Furthermore, since every operator in commutes, this implies that the number of state preparations is reduced from the naive counting to just a single measurement.
Iii Numerical Experiments
In order to validate the choice of geometry, numerical experiments were conducted to compare the Quantum Natural Gradient approach against vanilla gradient descent and the Adam optimizer. These experiments were performed with the open-source quantum machine learning software library PennyLaneBergholm et al. (2018); Schuld et al. (2019). New functionality was added for efficiently computing the block-diagonal and diagonal approximations of the Fubini-Study metric tensor for arbitrary -qubit parametrized quantum circuits on quantum hardware.
This process involves the following steps:
Represent the circuit as a directed acyclic graph (DAG). This allows the parametrized layer structure to be programmatically extracted. Gates which have no dependence on each other (e.g., because they act on different wires) can be grouped together into the same layer.
Determine observables. For each layer consisting of parameters, the generators for each parametrized gate are determined, and a subcircuit preparing constructed.
Calculate the th block of the Fubini-Study metric tensor.
Entire block: The unitary operation which rotates into the shared eigenbasis of is calculated and applied to the subcircuit, and all qubits measured in the Pauli-Z basis. Classical post-processing is performed to determine , , and for all , and subsequently .
: The varianceis computed for all , and subsequently the diagonal approximation to the block-diagonal, .
Thus, to evaluate the block-diagonal approximation of the Fubini-Study metric tensor on quantum hardware, a single quantum evaluation is performed for each layer in the parametrized quantum circuit. Finally, a Quantum Natural Gradient optimizer was implemented in PennyLane. This optimizer computes the pseudo-inverse of the block-diagonal metric tensor at each optimization step ( quantum evaluations), as well as the analytic gradient of the objective function via the parameter shift rule ( quantum evaluations), and updates the parameter values via Eq. (13). As a result, each optimization step requires quantum evaluations.
For numerical verification, we considered the circuit of Peruzzo et al. (2014), which consists of an initial fixed layer of gates acting on qubits, followed by layers of parametrized Pauli rotations interwoven with 1D ladders of controlled-Z gates, and target Hermitian observable chosen to be the same two-Pauli operator acting on the first and second qubit which has a ground state energy of . Starting from the same random initialization of Ref. Peruzzo et al. (2014), we optimize the parametrized Pauli rotation gates using vanilla gradient descent, the Adam optimzer, and the Quantum Natural Gradient optimizer, with both the block-diagonal and diagonal approximations. The results are shown in Fig. 1 for qubits, layers, and with the optimization performed using 8192 samples per expectation value. In all cases the vanilla gradient descent fails to find the minimum of the objective function, while the Quantum Natural Gradient descent finds the minimum in a small number of iterations, in both block-diagonal and strictly diagonal approximation. In addition, we present a comparison with the Adam optimizer which is a non-local averaging method. In this particular circuit, Adam is capable of finding the minimum but requires a larger number of iterations than the Quantum Natural Gradient. Furthermore, the improvement afforded by the Quantum Natural Gradient optimizer appears more significant with increasing qubit number. Note that for , we do not include the block-diagonal approximation, due to the increased classical overhead associated with numerically computing the shared eigenbasis for each parametrized layer. However, this overhead can likely be negated by implementing the techniques of Crawford et al. (2019) and Gokhale et al. (2019).
To investigate the effects of variable circuit depth, the numerical experiment was repeated with qubits, and parametric quantum circuits with layers. The results are shown in Fig. 2, highlighting that the Quantum Natural Gradient optimizer retains its advantage with increasing circuit depth.
It is instructive to compare our proposal with existing preconditioning schemes such as Adam. Unlike Adam, which involves some kind of historical averaging, the preconditioning matrix suggested by quantum information geometry does not depend on the specific choice of loss function (Hermitian observable). It is instead a reflection of the local geometry of the quantum state space. In view of these differences it is natural to expect that the benefits provided by the Quantum Natural Gradient are complementary to those of existing stochastic optimization methods such as Adam. It is therefore of interest to perform a detailed ablative study combining these methods, which we leave to future work.
Finally, this paper only considered the relevant geometry for idealized systems described by pure quantum states. In near-term noisy devices it may be of interest to study the relevant geometry for density matrices. The most promising candidate is the Bures metric, which possesses a number of desirable features. In particular, it is the only monotone metric which reduces to both the Fubini-Study metric for pure states and the Fisher information matrix for classical mixtures Petz (1998).
Appendix A Supplementary Material
In this appendix we employ the Einstein summation convention where summation over repeated indices is implied.
a.1 Real and imaginary parts of Quantum Geometric Tensor
Partially differentiating both sides of the normalization condition with respect to gives
Partially differentiating again with respect to gives
Consider the wavefunction in a neighborhood of . Taylor expanding in the displacement vector we obtain,
Taking the inner product with gives
It follows that the fidelity between and is given to quadratic order in the displacement by,
It follows that the infinitesimal squared distance is given by,
It follows that the metric tensor is given by the real part of the QGT,
For completeness, the imaginary part of the QGT is given by
where is the Berry connection,
a.2 Relationship with imaginary-time evolution
Consider the imaginary-time evolution operator generated by the Hermitian operator where . Let denote the projector onto the one-dimensional subspace spanned by the unit vector and let . Then the projected imaginary-time evolution is defined by,
where we used the normalization of . We have
So Taylor expanding to quadratic order in the displacement gives,
Expanding the exponential in and neglecting cubic-order terms in the multi-variable Taylor expansion in and ,
where and we have used . In the limit
we obtain the following system of ordinary differential equations,
a.3 Relationship with classical Fisher information
Let be an orthonormal basis for and suppose is a parametric family of probability distributions on the finite set . Define the following parametric family of quantum states
Then by the chain rule
Thus the Berry connection for this family of states vanishes
where we used the orthonormality of the basis . The QGT is thus given by
- Preskill (2018) J. Preskill, Quantum 2, 79 (2018).
- Peruzzo et al. (2014) A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L. O’Brien, Nature Communications 5, 4213 (2014).
- Farhi et al. (2014) E. Farhi, J. Goldstone, and S. Gutmann, arXiv preprint arXiv:1411.4028 (2014).
- Farhi and Neven (2018) E. Farhi and H. Neven, arXiv preprint arXiv:1802.06002 (2018).
- Huggins et al. (2018) W. J. Huggins, P. Patil, B. Mitchell, K. B. Whaley, and M. Stoudenmire, Quantum Science and Technology 4, 024001 (2018).
- Schuld et al. (2018) M. Schuld, A. Bocharov, K. Svore, and N. Wiebe, arXiv preprint arXiv:1804.00633 (2018).
- Guerreschi and Smelyanskiy (2017) G. G. Guerreschi and M. Smelyanskiy, arXiv preprint arXiv:1701.01450 (2017).
- Spall et al. (1992) J. C. Spall et al., IEEE Transactions on Automatic Control 37, 332 (1992).
- Schuld et al. (2019) M. Schuld, V. Bergholm, C. Gogolin, J. Izaac, and N. Killoran, Physical Review A 99, 032331 (2019).
- Jastrzebski et al. (2017) S. Jastrzebski, Z. Kenton, D. Arpit, N. Ballas, A. Fischer, Y. Bengio, and A. Storkey, arXiv preprint arXiv:1711.04623 (2017).
- Kingma and Ba (2014) D. P. Kingma and J. Ba, arXiv preprint arXiv:1412.6980 (2014).
- Neyshabur et al. (2015) B. Neyshabur, R. R. Salakhutdinov, and N. Srebro, in Advances in Neural Information Processing Systems (2015) pp. 2422–2430.
- Amari (1998) S.-I. Amari, Neural Computation 10, 251 (1998).
- Liang et al. (2017) T. Liang, T. Poggio, A. Rakhlin, and J. Stokes, arXiv preprint arXiv:1711.01530 (2017).
- Harrow and Napp (2019) A. Harrow and J. Napp, arXiv preprint arXiv:1901.05374 (2019).
- Wilczek and Shapere (1989) F. Wilczek and A. Shapere, Geometric Phases In Physics. Series: Advanced Series in Mathematical Physics, ISBN: 978-9971-5-0621-6. WORLD SCIENTIFIC, Edited by F Wilczek and A Shapere, vol. 5 5 (1989).
- Sorella et al. (2007) S. Sorella, M. Casula, and D. Rocca, The Journal of Chemical Physics 127, 014105 (2007).
- Du et al. (2018) Y. Du, M.-H. Hsieh, T. Liu, and D. Tao, arXiv preprint arXiv:1810.11922 (2018).
- Bergholm et al. (2018) V. Bergholm, J. Izaac, M. Schuld, C. Gogolin, and N. Killoran, arXiv preprint arXiv:1811.04968 (2018).
- Crawford et al. (2019) O. Crawford, B. van Straaten, D. Wang, T. Parks, E. Campbell, and S. Brierley, arXiv preprint arXiv:1908.06942 (2019).
- Gokhale et al. (2019) P. Gokhale, O. Angiuli, Y. Ding, K. Gui, T. Tomesh, M. Suchara, M. Martonosi, and F. T. Chong, arXiv preprint arXiv:1907.13623 (2019).
- Petz (1998) D. Petz, in Quantum Probability Communications: Volume X (World Scientific, 1998) pp. 135–157.