A parallel quantum eigensolver for quantum machine learning

Eigensolvers have a wide range of applications in machine learning. Quantum eigensolvers have been developed for achieving quantum speedup. Here, we propose a parallel quantum eigensolver (PQE) for solving a set of machine learning problems, which is based on quantum multi-resonant transitions that simultaneously trigger multiple energy transitions in the systems on demand. PQE has a polylogarithmic cost in problem size under certain circumstances and is hardware efficient, such that it is implementable in near-term quantum computers. As a verification, we utilize it to construct a collaborative filtering quantum recommendation system and implement an experiment of the movie recommendation tasks on a nuclear spin quantum processor. As a result, our recommendation system accurately suggests movies to the user that he/she might be interested in. We further demonstrate the applications of PQE in classification and image completion. In the future, our work will shed light on more applications in quantum machine learning.


Introduction
The past decade has witnessed the great successes of machine learning in many areas [1].However, with the end of Moore's law and the rapidly increasing demands for machine learning, it is necessary to develop new computing machines [2][3][4].Quantum computing is a potential candidate that has exceeded modern supercomputers in the specific tasks of random circuit sampling and boson sampling [5,6].Quantum machine learning (QML) implies that quantum computing may boost machine learning tasks using quantum devices [7][8][9][10][11].In QML, solving eigenproblems is often encountered in practical applications [12].
In this work, inspired by QRT, we construct quantum multi-resonant transitions and propose parallel quantum eigensolver (PQE) by designing its Hamiltonian dynamics.PQE directly solves a eigenproblem of the projective summation of a vector b in the partial eigenspace of the hermitian matrix A in the given weights, instead of individually solving each eigenvector.We develop PQE-based collaborative filtering QRS and QLS in the time complexity O(κdRploylogN/ϵ) with the condition number κ, dimension N and sparsity d, the number of non-degenerate eigenvalues R of matrix A, accuracy ε and some assumption.We implement a movie recommendation experiment on a four-qubit NMR quantum processor, where a 4 × 4 movie-scoring table (four users and four movies [44]) is considered.The experimental results show that the recommender can predict the scores on unwatched movies and accurately recommend movies to user that he/she might like.Finally, we numerically simulate the applications of PQE in data classification and image completion.

Parallel quantum eigensolver
Given a matrix A, an N-dimensional vector b, and a function f(λ j ) where λ j 's are partial or all eigenvalues {λ 1 , λ 2 , . .., λ R } of A, how to obtain the solution where R is the number of eigenvalues to be considered and v k is the eigenvector of A. It is the projective summation of b in the partial eigenspace of A according to the given weight f(λ k ).f(λ k ) depends on specific problems.For instance, QLS can be developed by . Hence, studying how to solve this eigenproblem will generate some QML applications.One direct idea is to use existing quantum eigensolvers [20,42,46,47] to individually solve each λ k and v k , and sum directly in equation ( 1), but it consumes lots of resources and cannot maintain the correct relative phase between individual |v k ⟩ [48,49].PQE can directly solve this eigenproblem without the need of diagonalization.It needs one probe qubit, an ancillary register with r = ⌈log 2 R⌉ qubits, and a working system with n = ⌈log 2 N⌉ qubits.It includes critical steps as follows, (a) Hamiltonian design.The (1 + r + n)-qubit Hamiltonian is constructed as ( c is the coupling parameter, I 2 is a 2 × 2 identity and σ x,y,z are the Pauli operators.The four parts of equation ( 2) describe the Hamiltonians of probe qubit, ancillary register, working system, and the interaction between them, respectively.H λ and S are diagonal matrices.H λ can trigger multi-resonant transitions by encoding the eigenvalues of resonant energy levels into the diagonal elements h k = 1 − λ k .The element s k in S controls the strength of the kth transition.Figure 1 After Hadamard gates are applied on the ancillary register, the final state α 1 and α ′ 10 are the factors in uninterested subspaces.2 (c) Measurements.We set t = 1 c and s k = arcsin f(λ k ) fmax with f max,min = max, min λ k |f(λ k )|.Then we measure the work system in the ancillary subspace of |1⟩|0⟩ ⊗r .The final result is It differs from equation ( 1) by a constant factor.Compared with quantum single-resonant transitions [42,50,51], we add an r-qubit register that encodes the eigenvalues, and we design the Hamiltonian H PQE and its dynamics in PQE, such that PQE can trigger multi-resonant transitions simultaneously.Thus, it can directly obtain equation ( 5) without diagonalizing the matrix A. Here, the main steps in the complexity analysis are briefly presented.First, the success probability of the measurement at the end of the quantum circuit can be easily calculated.It is, where b k = ⟨v k |b⟩.This probability can be increased to a constant by O(1/ √ P m ) times amplitude amplification [52].Second, the query complexity of implementing the evolution of a d-sparse Hamiltonian H is O(td||H|| max ) pre amplitude amplification.Third, if the error ε is defined as the distance between the PQE result x ′ PQE and the ideal result x, the magnitude of error introduced by the off-resonant effect is ϵ ∼ c/|λ j − λ k |.When the interval between the eigenvalues is Ω(1/polylogN), the total time complexity of PQE will be O(||H|| max κdRβ −0.5 polylogN/ϵ) with κ = f max /f min and β = ∑ R−1 k=0 b 2 k .Similar to the previous [14], we also assume that ||H|| max is bounded by some constant.We stress that the complexity of PQE depends on the specific problems, for example, β ∼ 1 and the final complexity will be O(κdRpolylogN/ϵ) in the QRS and QLS.More details can be found in supplement material [45].Next, we demonstrate its application in QRS [53].

Quantum recommendation system
In the various recommendation systems, collaborative filtering is the mainstream model which uses the similarity between users or items to recommend the target items to the users [54].The item-based collaborative filtering recommendation system, as an example, contains three steps shown in figure 2. First, collect the scoring table B with M users and N items.Second, compute the similarity between the ith and jth items by dot product sim(i, j) = B :i • B :j with column-normalized B. Here, singular value decomposition [52,55] is adopted to decompose B into a low-dimensional space and then compute the dot product matrix by sim V is the right singular matrix of B. Third, calculate the prediction of a new-user vector b on the jth item by The system will recommend the item with the highest score to the user.Similar procedure can be made for the user-based collaborative filtering recommendation system.Obviously, equation ( 6) is the solution of equation ( 1), so PQE can realize the item-based QRS by setting A = B † B and f(λ k ) = λ k .The unitary operator e −iB † Bt can be implemented by the method in [9].Besides, we can also set We feed H PQE and |b⟩ into PQE and execute it.In the ancillary subspace of |1⟩|0⟩ ⊗r , measuring the work system will output the result equation ( 6) by a constant factor.Considering that scores are positive values and only the probabilities of wave functions can be measured, we use an experiment-friendly definition as our result by ) are the diagonal elements of final density matrix ρ f in the ancillary space of |1⟩|0⟩ ⊗r .For ensemble quantum devices, like NMR Diag(ρ ) can be inferred by measuring the operators {I, σ z } ⊗n [56].For quantum devices with projective measurements such as superconducting circuits [57], W PQE is easily obtained on the computational basis of work qubits.Finally, we can recommend the item with the highest score to the new user.The user-based case can be similarly obtained using A = BB † and row-normalized B.

Experiments
As a verification, we implement a movie recommendation experiment on a four-qubit NMR Here, we consider a small-scale user-movie scoring table with four users and four movies that is selected from GroupLens [44], The four-qubit sample is unlabeled iodotrifluroethylene (C 2 F 3 I) molecule dissolved in d-chloroform, in which the half-spin nucleus (one 13 C and three 19 F) in the sample are used as the qubits.The structure and properties of the molecule are shown in figure 3(a), where one 13 C and three 19 F form a four-qubit all-to-all connected quantum processor. 13C has both the abilities of individual address and readout, while 19 F nucleus lack the individual readout.This problem can be overcome by transferring 19 F channel to 13 C channel using SWAP operation in experiments.Under weak coupling approximation, the internal Hamiltonian of this 4-qubit system is where ν j is the chemical shift and J jk is the J-coupling strength between jth and kth nuclei.The dynamic of the spins is controlled by designing the shaped radio-frequency pulses, which can be used to realize the evolution of quantum multi-resonant Hamiltonians.First, we implement QRT to search for the first two eigenvalues that are necessary for the subsequent procedure.It needs one probe qubit ( 13 C) and two work qubits (first two 19

F). The Hamiltonian is
Starting from |0⟩ ⊗3 , we first roughly locate the resonant positions by setting c = 0.1 and sweeping ω x from 1 to 3 with the step △ω x = 0.1 and then accurately find the eigenvalues by fixing c = 0.01 and sweeping ω x near resonance peaks.We optimize the shaped pulses by the gradient ascent pulse engineering technique [58,59] and implement U QRT = e −iHQRTτ with τ = 2/c for each pair of c and ω x .The width of the shaped pulses is 20 ms.The probability P |1⟩ of probe qubit is obtained by Second, we perform PQE with λ exp 1 and λ exp 2 .It needs one probe qubit ( 13 C), one register qubit ( 19 F 1 ) and two work qubits (the remaining 19 F).To prepare the initial state |b⟩, it usually needs some quantum devices for a general |b⟩ like quantum random access memory.Fortunately, the initial state |b⟩ is usually sparse enough in the QRS to be prepared from a product state through a few gates.In the item-based recommendation, we consider the recommendation task for two new users U-5 and U-6 with vectors |b⟩ U-5 ∝ [5, 0, 1, 0] T and |b⟩ U-6 ∝ [1, 0, 5, 0] T respectively.They have watched M-1 and M-3 but did not watch M-2 and M-4.The task is to predict their scores on M-2 and M-4 and recommend the movie to them.In the user-based case, we recommend one of two new movies M-5 and M-6 to the users.Their scoring vectors are |b⟩ M-5 ∝ [5, 0, 2, 0] T and |b⟩ M-6 ∝ [2, 0, 5, 0] T .U-1 and U-3 watched and scored new movies, but U-2 and U-4 have not watched them.The task is to predict the scores of U-2 and U-4 on new movies and recommend the movie to them.
As shown in figure 3(b), experiment includes three procedures.(i) Preparing the initial state.Single-qubit rotations are applied on 19  ) [45].Before the measurement, we also perform the amplitude amplification to increase the probability P |1⟩|0⟩ [45,60].It is also realized with a 20 ms shaped pulse.Finally, the movie with the highest score will be recommended to the user.Equation (6) shows that W will give information about similarities between movies or users when the input |b⟩ is a simple product state.Here, we also individually feed product states |b⟩ = |00⟩ and |b⟩ = |10⟩ into both item-based and user-based QRS experiments.Their results W PQE |00⟩ and W PQE |10⟩ respectively provide the similarities of M-1 and M-3 with the remaining movies (item-based) and the similarities of U-1 and U-3 with the remaining users (user-based).

Results
Figure 5 presents the experimental results of both item-based and user-based QRS.The results agree well with the numerical simulations, verifying the feasibility of the PQE.In the item-based QRS, the user U-5 has watched the movies M-1 and M-3 and rated the former with a higher score.For unwatched movies, the recommendation system rated M-2 higher than M-4.Thus, it will recommend M-2 to U-5.It is an accurate recommendation because both M-1 and M-2 are action movies [44].Therefore U-5 is likely to appreciate M-2.Experimental results also support this recommendation, of which M-2 has a higher similarity with M-1 than M-4.Based on a similar analysis, it will recommend M-4 to U-6.In the user-based QRS, U-1 and U-3 have watched M-5, but U-2 and U-4 did not watch it.The results show that U-2 will rate M-5 a higher score than U-4 after watching M-5.Thus M-5 will be recommended to U-2.It makes sense that U-1 rates M-5 highly because the taste between U-1 and U-2 is similar.Namely, they may both enjoy action movies.With the same logic, U-4 might prefer M-6 since U-3 rated M-6 highly.
The deviation between experimental and ideal diagonal elements is 1.56%, mainly from the imperfections of pulses and decoherence.The simulation shows that their contribution is approximately 1.49% [45].The accuracy of the found eigenvalues may affect the performance of PQE.In QRT experiments, the found eigenvalues have a deviation of 10 −3 from the real one, and c = 10 −2 in PQE.In such a setting, the final state of PQE has a fidelity of over 0.998 [45].

Other applications
Our work can be extended to solve other problems in machine learning, like classification and image completion, by setting different functions f in PQE.We simulate the application in data classification by using our method as a quantum linear solver and image completion by using our method to realize singular value threshold (SVT).
For data classification, given the training data with M points {(⃗ z j , y j )|⃗ z j ∈ R N , y j = ±1, j = 1, . .., M}, the support vector machine (SVM) classifies a new point⃗ z new into one of two classes.Here, y j = ±1 is the label of the points.The critical step of predicting sample classification is to solve the linear equation, K is the kernel matrix with the element K jk =⃗ z T j •⃗ z k .⃗ y = (y 1 , . . ., y M ) T and − → 1 = (1, . . ., 1) T .PQE solves the above equation by constructing the Hamiltonian of the composite system with one probe qubit, an r = ⌈log 2 R⌉-qubit register, and an n-qubit work system.The Hamiltonian is designed as equation ( 2) with the function form f(λ) = λ −1 .The system starts from the initial state Here, |b⟩ is the normalized vector of (0,⃗ y).The Hadamard gates are applied on the register after time dynamics with t = 1/c.Measuring the state of work qubits in the ancillary subspace of |1⟩|0⟩ ⊗r gives the result x work .The solution of equation ( 8) can be written as, ( η 0 ⃗ η Here, N is the normalized factor of (0,⃗ y) T .This solution can be further used to classify new data into one of two classes [45].Some classification results are placed in figure 6.
For image completion, SVT is one of the common methods in matrix completion.For a sampled matrix B ∈ R N×M , it has the singular value decomposition where ⃗ u k and ⃗ v k are left and right singular vectors corresponding to singular value Λ k .The task of SVT is to recover a new matrix B ′ with the eigenvalue threshold Λ τ , To solve this problem, we need to design a Hamiltonian, which is a little different from equation (2), Here, A = BB † .S and H Λ are the diagonal matrices with the elements s k = arcsin fτ (Λ k ) Λ k and h k = 1 − Λ 2 k , respectively.The other next steps are the same as QRS.The initial state denotes the input matrix B, and the completed matrix B ′ will be encoded in the final state.Figure 6 presents the simulated results, and more details can be found in supplemental information [45].

Discussion and conclusion
In this section, we first make some discussions related to QRT.The time complexity of QRT is O(RdlogN/δ) with the precision δ of eigenvalues [45].It is worth noting that QRT is not the only option to solve the eigenvalues.There are some quantum approaches here that can solve the eigenvalues, such as near-optimal ground state preparation using a method called block coding [61], but this approach seems to solve directly only for the ground state and requires more ancilla qubits.In this work, we propose a modified QRT and use it to find eigenvalues, as it requires only one ancilla qubit and can easily obtain several large eigenvalues, which is very friendly for our experiments.
We second discuss the complexity and error source of the PQE.There is still a small transition from Here, we assume that ∥H∥ max is bounded by some constant.Hence, the scaling behavior of PQE depends on the problem studied.PQE-based QRS and QLS has the complexity O(κdRpolylogN/ϵ).Meanwhile, PQE still works when the degenerate eigenvalues exist because resonant transitions are triggered according to eigenvalues instead of eigenstates [42].
We third make a comparison with the previous QRS and QLS.Different from previous QRS [13], our work is based on a collaborative filtering recommendation system rather than low-rank approximate matrix completion.Besides, it solves the eigenproblem using the PQE proposed in this paper rather than quantum phase estimation, which uses fewer qubits than the previous work.To our knowledge, the best collaborative filtering QRS before PQE has linear scaling in N [62].Thus, PQE for collaborative filtering QRS can reduce the complexity to polylogarithmic scaling in N when R = O(logN).Compared with the HHL method whose complexity is O(κ 2 d 2 logN/ϵ), PQE has linear scaling in κ and d, and it may achieve polynomial speedup when R = O(logN).For QLS, it can be solved by some works based on linear combinations of unitaries [18,63].They need to calculate O(log(κ/ϵ)κ/ϵ × κ log(κ/ϵ)) different overlaps with O(κ log(κ/ϵ)) evolution time, or compute a linear combination of so many unitary operators.In contrast to them, the number of ancilla qubits 1 + ⌈log 2 R⌉ is independent of κ and ϵ in PQE.At the same time, PQE does not require the measurement of many overlaps or summing over a lot of terms.
This letter focuses on solving eigenproblems in QML.We propose PQE that can solve the eigenproblems in parallel and further demonstrate the feasibility of PQE by constructing QRS and implementing the movie recommendation experiments.The first experimental realization of QRS benefits from the implementable dynamics and fewer qubit resource requirement.Our framework is friendly to quantum devices and it will pave the way towards more practical applications in QML.Here, we numerically simulate the applications in data classification (PQE is used as QLS) and image completion ( PQE is used to realize QSVT) [45].The images are accurately recovered even under the low sampling rate of 50%.Moreover, it is expected to develop quantum fidelity estimators without full state tomography [80,81] and the SWAP test [82], because the overlap ⟨v k |b⟩ is computable in PQE.It is also interesting to explore quantum chemistry simulations [83].

Figure 1 .
Figure 1.Quantum multi-resonant transitions.(a) Block structure of Hamiltonian HPQE.A ′ ′ j = A + 1/2 − λ j and I = I ⊗n 2 .(b) Energy levels of HPQE in the subspace of ancillary register.b i = ⟨v i |b⟩ and cs k is the transition strength from |0⟩|k⟩|v k ⟩ to |1⟩|k⟩|v k ⟩ when the resonance happens for each pair of |k⟩ and |v k ⟩.

Figure 2 .
Figure 2. PQE-based quantum recommendation process.(a) Left: the user may like the item based on the rating of the item by other users with similar tastes as the target user.Right: the user may like the item which has the high similarity with the other item given a high score by the user.(b) A new rating vector from the new user or on new item is encoded by |b⟩.The rating table is encoded by A. Center box is the subroutine for finding the eigenvalues {λ1, . .., λR} of A. If the eigenvalues are known in advance, it can be omitted.PQE routine inputs the user-vector |b⟩ and H to output the recommendation results |x⟩.

Figure 3 .
Figure 3. (a) Molecular properties and the Hamiltonian parameters of the 13 C-iodotrifluoroethylene (C2F3I).Top part: the encoding, controllability, readability, and coherent time T2 of Q1-Q4.Bottom part: the diagonal and off-diagonal elements give the chemical shifts ν i and the scalar coupling strengths J ij (in units of Hz), respectively.(b) NMR quantum circuit to realize quantum recommendation system via PQE.C1 and C2 are used as probe and register qubits.C3 and C4 are work qubits to encode |b⟩ and |x⟩.It starts from |0⟩ ⊗4 which is prepared via the initialization method.U1 and U2 are applied to prepare |0⟩|+⟩|b⟩ and realize the dynamics of H. Last, we measure the state of the work qubits in the ancillary subspace |10⟩.

Figure 4 .
Figure 4.The found eigenvalues via QRT.(a) The measured eigenvalues for A = B † B with column-normalized B. (b) The measured eigenvalues for A = BB † with row-normalized B. The resonant peaks appear when ωx is close to the eigenvalue λ i .After the rough resonance points are found, the delicate sweep with smaller c is performed.

Figure 4 2 =
presents the experimental results of sweeping ω x for A = B † B (item-based) and A = BB † (user-based).For A = B † B, there are two resonance peaks corresponding to two eigenvalues λ 1.650 (λ th 2 = 1.649) are estimated for A = BB † .The remaining smaller eigenvalues are outside the frequency range of the scan.

Figure 5 .
Figure 5.The results of the movie recommendation experiment.(a) The user-based QRS: W PQE for four users on the new movies M-5 and M-6.(b) The item-based QRS: W PQE for the users U-5 and U-6 on four movies.(c) The similarities between the different movies or users.The error bars come from 8 repeated experiments with different shaped pluses, and the bars are the numerical simulations.The similarities are displayed based on self-similarity.The light and dark bars represents watched and unwatched movies, respectively.
F 1 and19 F 2 to prepare the state |0⟩|+⟩|b⟩ from |0⟩ ⊗4 .The shaped pulses are used realize them in experiments.(ii) Realizing the evolution operators.The shaped pulse is optimized to implement the evolution e −iHPQE/c , similar to the above experiments.The last Hadamard gate on19 F 1 is decomposed into single-qubit rotations.Totally, we engineer the implementation of the quantum circuit with a 15 ms shaped pulse.(iii) Obtaining recommendation results.By using π/2 readout pulses and collecting the NMR signal spectrum, we measure the expectation values of {I, σ z } ⊗4 to infer the diagonal elements Diag(ρ|10⟩ f

Figure 6 .
Figure 6.The numerical simulations for the extended applications in SVM and image completion.(a) The insimilarity of the SVM solutions with ideal ones and an application example on the classification (Insert figure.Circle: training points.Triangular: test points.Lines: SVM hyperplane).(b) The recovered images via classical SVT and our method from the 50%-sampled images, respectively.