Introduction to Quantum Simulation Algorithms
©️ Copyright 2023
Author:Shuo Zhou(周烁) 📨
To execute this document directly, please click the Connect button at the top of Bohrium Notebook Interface.
Quantum Computing is a computing model that is different from classical computing. In the 1970s and 1980s, with the development of quantum mechanics, the need to observe and simulate quantum systems was raised, and the idea of building "quantum computers" that follow the principles of quantum mechanics rather than those of classical physics was born.
Quantum Algorithm refers to algorithm that runs on a realistic model of quantum computing. Quantum algorithms often take advantage of the quantum superposition and entanglement properties of quantum computing to achieve speedups over classical algorithms for specific tasks. The most famous examples include the quantum algorithm for prime factorisation of large numbers proposed by Shor in 1994 [1], the quantum algorithm for unordered list search proposed by Grover in 1996 [2], and the quantum simulation algorithm introduced in this issue of the Notebook.
Quantum Simulation Algorithm dates back to 1982 [3], when Feynman, in his talk "Simulating Physics with Computers", suggested that it was inherently difficult to simulate the evolution of quantum systems using classical computers, and that using "quantum computers" to do so might be a viable path. In 1996, Seth Lloyd proposed the first explicit algorithm based on the Product Formula [4]. Since then, more quantum simulation algorithms have emerged, with applications ranging from quantum field theory to quantum chemistry and condensed matter physics.
Intuitively, we could classify quantum simulation problems into two catogories:
1. Hamiltonian Simulation
In quantum mechanics, time evolution of the wave function is governed by the Schrdinger equation, For independent of time, the solution is: Many natural Hamiltonians have the form of a sum of terms, common expamles include:
- A particle in a potential:
- A -local Heisenberg spin model:
For numerical example, we choose Heisenberg model on a lattice. Without loss of generality, we assume there is no external magnetic field (), and the interaction length equals unit ().
The Hamiltonian is , where , and are Pauli operators acting on the -th spin, where the summation is over all neighboring spin pairs. We decompose the Hamiltonian into tree interaction terms: , respectively represented by yellow, green, and red bonds.
In the following code, "np.kron" means tensor product between Pauli Matrices under the basis of spins.
1.1 Quantum Circuit: why we need to break Hamiltonian into local terms
In quantum computing, we generally utilize subsets consisting of few single or two-qubit gates to approximate any unitary operation.
You've probably heard some common gate elements such as Control-NOT, Rotation-Pauli, Hardamard and so on. On top of that, we can simulate tensor product of Pauli matrix. For instance, the following figure shows "unit" quantum circuit for implementing :
If we could analyse the relationship between original time-evolution operator and "unit" quantum circuit as the figure above, in principle we could simulate many natural Hamiltonians. In fact, there are following mathematical theorems in a nutshell:
1.2 Product Formula
1.2.1 Lie-Trotter Formula
In Lie algebra, for possibly noncommutative operator and , the product of their exponential does not behave that simply according to Baker–Campbell–Hausdorff formula: For Hamiltonian with local interactions, , only when for all j,k could we split the time-evolution operator as products: However, even in general cases where the term do not commute with each other, an enlightening idea is splitting time into segments, called Lie formula or Trotterization:
1.2.2 Trotter-Suzuki Formula
By Taylor's theorem we can calculate the error bounds by straightforward algebra: Generally, for Hamiltonian with terms, one could define recursively: Thus we have a very significant result called Trotter Suzuki formula [5], p-order expansion satisfies:
If we measure the Trotter Error by spectral norm, let's change the timestep and Trotter number, plot the error using 2-order Trotter-Suzuki formula. We could see that the cubic function fits the error very well, as the theory predicted.
1.3 qDRIFT Algorithm
Since the permutation of local terms in Trotter-Suzuki Formula is chosen arbitrarily. Without loss of generality, In 2018, Campbell imported randomness to seek possible improvement [6].
The slopes of the lines are all almost -1/2, which roughly verify the theory: qDRIFT_Error ~ .
What's worth mentioning, the qDRIFT algorithm is easy to be mistaken for randmom permutation Trotter-Suzuki algorithm [7], which simply averages the time-evolution quantum channel over all permutation of local Hamiltonians.
1.4 More About Efficient Simulation
We say can be effeciently simulated if for any , there is a quantum circuit consisting of poly gates such that .
Generally, the problem of simulating Hamiltonians is BQP-hard.
Up to now, mainstream algorithms for quantum simulation include:
- Product Formula [3]: the most straightforward approach first proposed.
- Randomized Product Formula [6, 7]: randomly permuting terms in product formula & the qDRIFT algorithm.
- Truncated Taylor Series [8]: an alternative approach that leverages LCU achieves complexity poly.
- Quantum Singnal Processing [9]: an approach based on qubitization and block-encoding with an optimal complexity tradeoff.
2. Variational Quantum Eigensolver
The variational quantum eigensolver (VQE) [10] is a method that uses a hybrid quantum-classical computational approach to find eigenvalues of a Hamiltonian.
2.1 Schematic of VQE
It starts with a reasonable assumption about the form of the target wave function. A trial wave function or ansatz is constructed with adjustable parameters, followed by the design of a quantum circuit capable of realizing this ansatz. The ansatz parameters are then variationally adjusted until the expectation value of the electronic Hamiltonian is minimized:
Here is a schematic of variational quantum eigensolver (VQE) that minimizes the energy of Fermionic Hamiltonian . It uses classical computing resources denoted by green color and quantum computing resources denoted by blue. A simulation starts by constructing wavefunction ansatz with a set of initial parameter. Then the quantum computer prepares the trial state by applying parameterized unitary on Hatree-Fock wavefunction, and at iteration , the energy of the Hamiltonian is computed by measuring every Hamiltonian term and adding them on a classical computer. Next, the clasical optimization algorithm updates the parameter and feedbacks to the quantum computer. Finally the quantum computer generates a new state and goes round.
We use TenCirChem from Tencent to implement Quantum Chemistry Computation: https://github.com/tencent-quantum-lab/TenCirChem
In the following code, h4 represents chain consisting of 4 H atoms, the UCCSD is a wavefunction ansatz for optimization, which is chemistry-inspired and represents a unitary version of the classical non-unitary CCSD method.
################################ Ansatz ############################### #qubits #params #excitations initial condition 8 11 18 RHF ############################### Circuit ############################### #qubits #gates #CNOT #multicontrol depth #FLOP 8 146 98 10 78 506688 ############################### Energy ################################ energy (Hartree) error (mH) correlation energy (%) HF -2.121387 46.173788 -0.000 MP2 -2.151794 15.766505 65.854 CCSD -2.167556 0.004979 99.989 UCCSD -2.167546 0.014384 99.969 FCI -2.167561 0.000000 100.000 ############################# Excitations ############################# excitation configuration parameter initial guess 0 (6, 4) 01100011 -6.291323e-03 0.000000 1 (2, 0) 00110110 -6.291323e-03 0.000000 2 (7, 4) 10100011 9.142024e-17 0.000000 3 (3, 0) 00111010 9.142024e-17 0.000000 4 (6, 5) 01010011 2.013444e-16 0.000000 5 (2, 1) 00110101 2.013444e-16 0.000000 6 (7, 5) 10010011 3.686593e-03 0.000000 7 (3, 1) 00111001 3.686593e-03 0.000000 8 (2, 6, 5, 1) 01010101 -1.399103e-01 -0.081208 9 (2, 6, 4, 0) 01100110 -5.239766e-02 -0.045444 10 (2, 7, 5, 0) 10010110 -5.250098e-02 -0.032406 11 (6, 3, 1, 4) 01101001 -5.250098e-02 -0.032406 12 (3, 7, 5, 1) 10011001 -2.991510e-02 -0.029495 13 (3, 7, 4, 0) 10101010 -3.308486e-02 -0.022896 14 (6, 7, 5, 4) 11000011 -2.457277e-02 -0.018145 15 (2, 3, 1, 0) 00111100 -2.457277e-02 -0.018145 16 (3, 6, 5, 0) 01011010 -2.856758e-02 -0.014261 17 (7, 2, 1, 4) 10100101 -2.856758e-02 -0.014261 ######################### Optimization Result ######################### e: -2.1675461600271344 fun: array(-2.16754616) hess_inv: <11x11 LbfgsInvHessProduct with dtype=float64> init_guess: [0.0, 0.0, 0.0, 0.0, -0.018145135788852563, -0.04544411015309671, -0.022896105235218407, -0.03240648017333939, -0.01426134438448682, -0.08120787303242095, -0.02949460893918542] jac: array([-1.37001897e-08, 6.68513448e-21, 1.11607575e-19, 1.18183576e-09, -1.78964662e-09, -6.83009106e-09, 3.43035067e-09, 7.86964607e-09, 1.11886073e-08, 4.56193371e-09, 1.70279067e-09]) message: 'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH' nfev: 13 nit: 11 njev: 13 opt_time: 0.02908802032470703 staging_time: 8.106231689453125e-06 status: 0 success: True x: array([-6.29132329e-03, 9.14202447e-17, 2.01344373e-16, 3.68659333e-03, -2.45727657e-02, -5.23976611e-02, -3.30848564e-02, -5.25009838e-02, -2.85675846e-02, -1.39910303e-01, -2.99150954e-02])
2.2 Quantum Circuit: trial state preparation
3. Reference
- Peter W. Shor, Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer, SIAM Journal on Computing 26 (1997), no. 5, 1484–1509, quant-ph/9508027, preliminary version in FOCS 1994.
- Lov K. Grover, Quantum mechanics helps in searching for a needle in a haystack, Physical Review Letters 79 (1997), no. 2, 325–328, quant-ph/9706033, preliminary version in STOC 1996.
- Richard P. Feynman, Simulating physics with computers, International Journal of Theoretical Physics 21 (1982), no. 6, 467-488.
- Seth Lloyd, Universal quantum simulators, Science 273 (1996), 1073-1078.
- Masuo Suzuki, Fractal decomposition of exponential operators with applications to many-body theories and Monte Carlo simulations, Physics Letter A (1990), 319-323.
- Earl Campbell, Random compiler for fast hamiltonian simulation, Physical Reivew Letters 123 (2019), no. 7, 070503, arXiv:1811.08017.
- Andrew M. Childs, Aaron Ostrander, and Yuan Su, Faster quantum simulation by randomization, Quantum 3 (2019), 182, arXiv:1805.08385.
- Dominic W. Berry, Andrew M. Childs, Richard Cleve, Robin Kothari, and Rolando D. Somma, Simulating hamiltonian dynamics with a truncated taylor series, Physical Review Letters 114 (2015), no. 9, 090502, arXiv:1412.4687.
- Guang Hao Low and Isaac L. Chuang, Optimal hamiltonian simulation by quantum signal processing, Physical Review Letters 118 (2017), no. 1, 010501, arXiv:1606.02685.
- Dmitry A. Fedorov, Bo Peng, Niranjan Govind, Yuri Alexeev, VQE method: a short survey and recent developments, Materials Theory 6 (2022), arXiv:2103.08505.