HHL Algorithm
HHL Algorithm
HHL is the basis of many more advanced algorithms and is important in various applications such as machine learning and modelling of quantum systems.
1. Linear System Problem and Overview of HHL Algorithm
A linear system problem (LSP) can be represented as the following
where is an Hermitian matrix and and are -dimensional vectors. For simplicity, it is assumed and are known and is the unknown to be solved, i.e.
The figure below shows the schematic of the HHL algorithm and the corresponding circuit. The HHL algorithm has 5 main components, namely state preparation, quantum phase estimation (QPE), ancilla bit rotation, inverse quantum phase estimation (IQPE), and measurement.
{:width="512px"}
The clock qubits are used to store the encoded eigenvalues of A and larger n results in higher accuracy when the encoding is not exact.
The matrix , which is a Hamiltonian, may be written as a linear combination of its eigenvectors, weighted by its eigenvalues, .
Since is diagonal in its eigenvector basis, its inverse is simply, . can be also expressed in the basis of , such that
Therefore, it can be encoded as,
by using the fact that . The goal of the HHL algorithm is to find the solution in this form and is stored in the b-register.
2. State Preparation
There are total qubits and they are initialized as
In the state preparation, in the b-register needs to be rotated to have the amplitudes correspond to the coefficients of . That is
The vector is represented in a column form on the left with coefficients which is also a valid representation of . On the right, the corresponding basis of the Hilbert space formed by the qubits is written explicitly. Therefore,
From now on, some of the subscripts of the kets will be omitted when there is no ambiguity. Since the state preparation depends on the actual value of , it will be discussed in more detail in the numerical example.
3. Phase Estimation
Quantum phase estimation (QPE) is also an eigenvalue estimation algorithm. QPE has three components, namely the superposition of the clock qubits through Hadamard gates, controlled rotation, and Inverse Quantum Fourier Transform (IQFT). Here we assume the readers are already familiar with IQFT and it will not be explained in detail. In the first step where a superposition of the clock qubits is created, Hadamard gates are applied to the clock qubits to obtain,
In the controlled rotation part, is applied to with the clock qubits as the control qubits (Figure 2). For simplicity, we begin by assuming that is an eigenvector of with eigenvalue . Therefore
When the control clock qubit is will not be affected. If the clock bit is will be applied to . This is equivalent to multiplying in front of the of the clock qubit. Therefore, after the controlled- operation, we have
In the IQFT part, only the clock qubits are affected. Note that in certain literature, this is called Quantum Fourier Transform (QFT).
Due to interference, only for satisfying the condition will have a finite amplitude of . Otherwise, the amplitude is due to destructive interference. By ignoring the states with zero amplitude, we may rewrite as
Therefore, in QPE, the clock qubits are used to represent the phase information of , which is , and the accuracy depends on the number of qubits, .In Hamiltonian encoding, is related to through
where is the evolution time for that Hamiltonian. is obviously also diagonal in eigenvector, , basis. If ,
By equating to in Eq. (11), we get and Eq. (14) becomes
Thus the eigenvalues of have been encoded in the clock qubits (basis encoding). However, in general, (Eq. 4), by using superposition,
are usually not integers. We will choose so that are integers. Therefore, the encoded values
can be different from
can be rewritten as
4. Controlled Rotation and Measurement of the Ancilla Qubit
The next step is to rotate the ancilla qubit, , based on the encoded eigenvalues in the c-register, such that
where is a constant. When the ancilla qubit is measured, the ancilla qubit wavefunction will collapse to either or . If it is , the result will be discarded and the computation will be repeated until the measurement is . Therefore, the final wavefunction of interest is
where the prefactor is due to normalization after measurement. Since is the probability of obtaining when the ancilla bit is measured, should be chosen to be as large as possible. Compared to Eq. (5), the result resembles the answer that we are looking for. However, it is entangled with the clock qubits, . This means that we cannot factorize the result into a tensor product of the c-register and b-register. Therefore, we need to uncompute the state to unentangle them.
The measurement can be and is usually performed after uncomputation. However, since the ancilla bit is not involved in any operations after the controlled rotation, measuring the ancilla bit before the uncomputation gives the same result. For simplicity in the derivation, it is thus performed before the uncomputation.
5. Uncomputation - Inverse QPE
Firstly, QFT is applied to the clock qubits.
$$\left\vert \Psi_{7}\right\rangle=\frac{1}{\sqrt{\sum_{j=0}^{2^{n_{-}-1}}\left\vert \frac{b_{\frac{b}{\lambda}} C_{1}}{\lambda_{1}}\right\vert ^{2}}} \sum_{j=0}^{2 m_{b}-1} \frac{b_{j} C}{\hat{\lambda}{j}}\left\vert u{j}\right\rangle Q F T\left\vert \hat{\lambda_{j}}\right\rangle\vert 1\rangle_{a}$$
Then inverse controlled-rotations of the b-register by the clock qubits are applied with . Similar to the forward process, when the control clock qubit is will not be affected. If the clock bit is will be applied to . This is equivalent to multiplying in front of the of the clock bit. Therefore,
Since we have set$$\bar{\lambda}{j}=N \lambda{j} t / 2 \pi$$, therefore, the two exponential terms cancel each other and
The clock qubits and the b-register are now unentangled and the b-register stores . By applying the Hadamard gate on the clock qubits, finally, we have
6. Example
For example, take ,
Then the problem can also be written as find such that
The eigenvectors of A are, respectively,
The eigenvalues of them are,
.
2 qubits are needed by encoding and as so that it maintains the ratio of e1/e0 = 2
it maintains the ratio of This means or in other words,
to achieve the encoding scheme since .
On outcome 1 when measuring the auxiliary qubit, the state is
A quick calculation shows that
Since is a 2-dimensional complex vector, it can be encoded using 1 qubit and, thus, .
We can use and to find what is x.
The solution to the LSP is found to be
whereby, the ratio of
.
Reference:
1. Nielsen, Michael A., and Isaac Chuang. "Quantum computation and quantum information." (2002): 558-559.
2. Asfaw, Abraham, et al. "Learn quantum computation using qiskit." Accessed: Oct 24 (2020): 2020.
3. Susskind, Leonard, and Art Friedman. Quantum mechanics: the theoretical minimum. Basic Books, 2014.
4. Morrell Jr, Hector Jose, and Hiu Yung Wong. "Step-by-Step HHL Algorithm Walkthrough to Enhance the Understanding of Critical Quantum Computing Concepts." arXiv preprint arXiv:2108.09004 (2021).
版权声明: 本文为 InfoQ 作者【Si Yuan】的原创文章。
原文链接:【http://xie.infoq.cn/article/bcaae7aa34f47e574efc90c7e】。未经作者许可,禁止转载。
评论