/quantum-barren-plateaus

Avoiding Barren Plateaus in Variational Quantum Circuits

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

Avoiding Barren Plateaus in Variational Quantum Circuits

A project by Felipe Quinteros (UdeC, Chile), Mariana Navarro (ICFO, Spain), Jorge Gidi (UdeC, Chile), and Luciano Pereira (IFF-CSIC, Spain) for the Open Hackathon in the Qhack 2023.

Variational quantum algorithms have the potential to solve real-world practical problems with quantum computers in the near term [1]. They are hybrid quantum-classical algorithms that optimize an objective function encoded on a hamiltonian over a parametric quantum circuit. This objective function is efficiently evaluated in a quantum computer, while a classical computer is used to drive the optimization. The variational algorithms find applications in areas such as chemistry and finance.

In order to reach real-word applications with variational algorithms, we have to overcome a big issue: the barren plateau phenomenon [2,3]. This consists of the lack of convergence due to the vanishing of the cost function gradient. Pictorially, we can think that the landscape of the objective function is too flat, as shown in the figure, so any optimization method stuck.

This problem can appear due to the following reasons:

1.- The cost function is global, i.e., involves measurements in many qubits [2]. For example, consider the $n$-qubits Hamiltonian

$$H = I^{\otimes n}-|0^{\otimes n}\rangle\langle 0^{\otimes n}|.\qquad (1)$$ This Hamiltonian require a measurement over $|0^{\otimes n}\rangle$, wich involve all the $n$ qubits. Thereby, the sample of shots $N_{shots}$ used to evaluate $H$ has to split into $2^n$ outputs. In the case $N_{shots}<2^n$, which always happens for large $n$, the number of shots is not enough large to perform a precise evaluation of $H$, so that its gradient vanish and the barren plateau appears. This occurs independently of the shape and the depth of the variational circuit.

In [2] the authors recommend avoiding this kind of Hamiltonian in the early iterations of the algorithm and instead employ a local hamiltonian $$H_L = I^{\otimes n}-\frac{1}{n}\sum_{j=1}^n I_{1}\otimes\cdots\otimes I_{j+1}\otimes|0_j\rangle\langle 0_j|\otimes I_{j-1}\otimes\cdots\otimes I_{n}.$$ Each term of this hamiltonian involves a single-qubits measurement, so that can be accurately evaluated with a small $N_{shots}$. The authors demonstrate that this kind of Hamiltonian can be used to train variational circuits with depth $\log(n)$.

2.- The parametric quantum circuit is too expressive, that is equivalent to saying that the parametric circuit approximates a 2-design [3]. When this condition is fulfilled the average gradient of the cost functions is null and its variance decay exponentially. $$\mathbb{E}( \nabla \langle H\rangle )=0, \qquad {\rm Var}( \nabla \langle H\rangle ) \sim \frac{1}{2^n}.$$ Almost any variational circuit composed of layers of local gates intercalated with layers of entangling gates satisfies this condition. Reducing the expressibility of variational circuits is a way to avoid barren plateaus, as is suggested in [4].

3.- The initial condition for the optimization is too far from the solution, which happens extremely often when is taken randomly. Having good initial conditions increase the probability to start the optimization with a non-zero gradient so that the protocol can converge to the optimum. For example, in [5] is proposed to classically pre-train the variational circuit with tensor networks to have a good initial condition for the quantum optimization.

4.- The problem of a lifetime: the noise [6]. The impact of the noise can be reduced by hardware-efficient circuits and local measurements.

In this project, we develop a Qiskit module that includes several proposals to reduce the impact of barren plateaus in variational quantum algorithms. We also provide an early implementation on Pennylane. For more details visit the introductory notebook or each individual tutorial notebook.

[1] Noisy intermediate-scale quantum algorithms, Rev. Mod. Phys. 94, 015004 (2002).

[2] Cost function dependent barren plateaus in shallow parametrized quantum circuits, Nat Commun 12, 1791 (2021).

[3] Barren plateaus in quantum neural network training landscapes, Nat Commun 9, 4812 (2018).

[4] Mitigating barren plateaus of variational quantum eigensolvers, arXiv:2205.13539v2 (2022).

[5] Matrix product state pre-training for quantum machine learning, Quantum Sci. Technol. 7, 035014 (2022).

[6] Noise-induced barren plateaus in variational quantum algorithms, Nat Commun 12, 6961 (2021).

Tutorials:

1.- Introduction to QuBaP

2.- Avoiding Cost-function induced Barren Plateaus

3.- State Efficient Ansatz

4.- Classical Pretraining

5.- Combining the methods

6.- Early implementation on Pennylane

Install via pip as

pip install git+https://github.com/jgidi/quantum-barren-plateaus

or, equivalently,

python -m pip install git+https://github.com/jgidi/quantum-barren-plateaus