A variational quantum linear solver method, apparatus and medium for a subspace
By constructing variable quantum circuits and Krylov subspaces, and combining them with the generalized minimum residual method, we have achieved efficient solving of linear problems on ordinary computers, thus solving the problem of excessive complexity and computation in existing technologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
- Filing Date
- 2022-05-07
- Publication Date
- 2026-07-03
Smart Images

Figure CN117056646B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quantum computing technology, and in particular to a method, apparatus and medium for solving variable quantum linear problems in subspace. Background Technology
[0002] A quantum computer is a physical device that performs high-speed mathematical and logical operations, stores and processes quantum information in accordance with the laws of quantum mechanics. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Because of its ability to process mathematical problems more efficiently than ordinary computers—for example, reducing the time to crack RSA keys from hundreds of years to hours—quantum computers have become a key technology under research.
[0003] Quantum computing simulation is a simulation program that uses numerical computation and computer science to simulate computations that follow the laws of quantum mechanics. As a simulation program, it uses the high-speed computing power of computers to characterize the spacetime evolution of quantum states based on the fundamental laws of quantum bits in quantum mechanics.
[0004] Solving systems of linear equations is central to many scientific and engineering problems, and the classic algorithms for solving such problems are collectively known as linear system algorithms. In recent years, a significant achievement in quantum computing has been quantum linear system algorithms, the most famous of which is the HHL algorithm proposed by Harrow, Hassidim, and Lloyd in 2009. However, as the dimension of the input matrix increases, the time complexity of solving linear problems also increases, potentially requiring megabytes or even gigabytes of data for the solution process. This excessive demand on computational resources prevents it from being used to simulate and solve real-world physical problems on ordinary computers. Summary of the Invention
[0005] The purpose of this invention is to provide a method, apparatus, and medium for solving variational quantum linear problems in subspaces, in order to overcome the shortcomings of the prior art. It can reduce the complexity and computational load of solving linear problems.
[0006] One embodiment of this application provides a variational quantum linear solution method for subspaces, the method comprising:
[0007] Identify the system of linear equations to be solved;
[0008] A variable quantum circuit and a Krylov subspace are constructed. Using the generalized minimum residual method and the variable quantum circuit, an approximate solution to the linear equation system to be solved is calculated in the subspace.
[0009] Optionally, determining the system of linear equations to be solved includes:
[0010] Determine the linear equation system Ax = b to be solved and the initial residual r0, where A is a coefficient matrix, b is a vector, and the initial residual r0 is calculated based on the initial solution x0, satisfying r0 = b - Ax0.
[0011] Optionally, the construction of the variable quantum circuit and Krylov subspace, and the calculation of the approximate solution of the linear equation system to be solved in the subspace using the generalized minimum residual method and the variable quantum circuit, includes:
[0012] Construct an m-order Krylov subspace K corresponding to the coefficient matrix A and vector b. m Orthogonal basis set V m and Hessenberg matrix H m+1,m ;
[0013] For the Hessenberg matrix H m+1,m Perform QR decomposition;
[0014] A variable quantum circuit is constructed and used to process the QR decomposition results to obtain the linear equation system to be solved in the Krylov subspace K. m The median value y within m ;
[0015] According to the intermediate value y m To obtain an approximate solution x of the linear equation system to be solved. m , where x m =x0+V m y m .
[0016] Optionally, the Hessenberg matrix H... m+1,m Perform QR decomposition, including:
[0017] The Hessenberg matrix H m+1,m Decomposed into Among them, Q m+1 R is an orthogonal matrix. m+1,m It is an upper triangular matrix.
[0018] Optionally, the method further includes:
[0019] Construct a loss function based on the approximate solution and determine whether the value of the loss function meets the preset precision.
[0020] If so, the approximate solution is taken as the target solution of the linear equation system to be solved; otherwise, the variational parameters are updated, the approximate solution of the linear equation system corresponding to the updated variational parameters is obtained, and the steps of constructing the variational quantum circuit and Krylov subspace, and calculating the approximate solution of the linear equation system to be solved in the subspace using the generalized minimum residual method and the variational quantum circuit are continued until an approximate solution that satisfies the loss function with a preset accuracy is obtained, which is taken as the target solution of the linear equation system to be solved.
[0021] Optionally, the construction of a variable quantum circuit and the processing of the QR decomposition results using the variable quantum circuit yield the linear equations to be solved in the Krylov subspace K. m The median value y within m ,include:
[0022] A first sub-quantum circuit and a second sub-quantum circuit are constructed respectively to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace K. m The median value y within m The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function;
[0023] Enter R m The values of the residual vector β are used to measure the variable quantum circuit, thereby obtaining the linear equations to be solved in the Krylov subspace K. m The median value y within m The final quantum state, where R m R is an upper triangular matrix m+1,m For the first m rows, β = ||r0||2q1(1:m), where q1(1:m) represents the orthogonal matrix Q. m+1 The vector consisting of the first m elements of the first column, β and R m y m Satisfying the relation: β = R m y m ;
[0024] Based on the final quantum state, the linear equations to be solved are determined to be in the Krylov subspace K. m The median value y within m .
[0025] Optionally, the loss function is:
[0026]
[0027] Among them, the For the loss function, the Here, I is the variational parameter, and I is the identity matrix. and U is a parametric quantum logic gate.
[0028] Another embodiment of this application provides a variational quantum linear solver for subspaces, the apparatus comprising:
[0029] The determination module is used to determine the system of linear equations to be solved.
[0030] The module is used to construct the variable quantum circuit and the Krylov subspace. Using the generalized minimum residual method and the variable quantum circuit, the approximate solution of the linear equation system to be solved is calculated in the subspace.
[0031] Optionally, the determining module includes:
[0032] A determining unit is used to determine the linear equation system Ax = b to be solved and the initial residual r0, wherein A is a coefficient matrix, b is a vector, and the initial residual r0 is calculated based on the initial solution x0, satisfying r0 = b - Ax0.
[0033] Optionally, the building module includes:
[0034] The first construction unit is used to construct the m-order Krylov subspace K corresponding to the coefficient matrix A and the vector b. m Orthogonal basis set V m and Hessenberg matrix H m+1,m ;
[0035] Decomposition unit, used for the Hessenberg matrix H m+1,m Perform QR decomposition;
[0036] The second construction unit is used to construct a variable quantum circuit and process the QR decomposition results using the variable quantum circuit to obtain the linear equation system to be solved in the Krylov subspace K. m The median value y within m ;
[0037] The acquisition unit is used to obtain the intermediate value y. m To obtain an approximate solution x of the linear equation system to be solved. m , where x m =x0+V m y m .
[0038] Optionally, the decomposition unit includes:
[0039] Decomposition subunits are used to decompose the Hessenberg matrix H. m+1,m Decomposed into Among them, Q m+1 R is an orthogonal matrix. m+1,m It is an upper triangular matrix.
[0040] Optionally, the device further includes:
[0041] The judgment module is used to construct a loss function based on the approximate solution and determine whether the value of the loss function meets the preset precision.
[0042] The update module is used to, if yes, take the approximate solution as the target solution of the linear equation system to be solved; otherwise, update the variational parameters, obtain the approximate solution of the linear equation system corresponding to the updated variational parameters, and continue to execute the steps of constructing the variational quantum circuit and Krylov subspace, and using the generalized minimum residual method and variational quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace, until an approximate solution that satisfies the loss function value with a preset accuracy is obtained, which is then taken as the target solution of the linear equation system to be solved.
[0043] Optionally, the second building unit includes:
[0044] Constructing sub-units, used to construct a first sub-quantum circuit and a second sub-quantum circuit respectively, to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace K. m The median value y within m The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function;
[0045] Measurement subunit, used for input R m The values of the residual vector β are used to measure the variable quantum circuit, thereby obtaining the linear equations to be solved in the Krylov subspace K. m The median value y within m The final quantum state, where R m R is an upper triangular matrix m+1,m For the first m rows, β = ||r0||2q1(1:m), where q1(1:m) represents the orthogonal matrix Q. m+1 The vector consisting of the first m elements of the first column, β and R m y m Satisfying the relation: β = R m y m ;
[0046] Determine the subunit, used to determine the linear equations to be solved in the Krylov subspace K based on the final quantum state. m The median value y within m .
[0047] Another embodiment of this application provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.
[0048] Another embodiment of this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in any of the preceding claims.
[0049] Compared with existing technologies, this invention first determines the system of linear equations to be solved, then constructs a variable quantum circuit and a Krylov subspace, and uses the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the system of linear equations in the subspace. It can reduce the complexity and computational cost of solving linear problems by using the generalized minimum residual method and the variable quantum circuit, thus filling the gap in related technologies. Attached Figure Description
[0050] Figure 1 A hardware structure block diagram of a computer terminal for a variational quantum linear solution method for subspaces provided in an embodiment of the present invention;
[0051] Figure 2 A flowchart illustrating a variational quantum linear solution method for subspaces provided in an embodiment of the present invention;
[0052] Figure 3 A schematic diagram of a first sub-quantum circuit provided in an embodiment of the present invention;
[0053] Figure 4 A schematic diagram of a second sub-quantum circuit provided in an embodiment of the present invention;
[0054] Figure 5 This is a schematic diagram of a variational quantum linear solver for subspaces provided in an embodiment of the present invention. Detailed Implementation
[0055] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0056] The present invention first provides a variational quantum linear solution method for subspaces, which can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
[0057] The following detailed explanation uses a computer terminal as an example. Figure 1This is a hardware structure block diagram of a computer terminal for a variational quantum linear solution method for subspaces, provided as an embodiment of the present invention. (See diagram below.) Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0058] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / modules corresponding to the variational quantum linear solution method for subspaces in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0059] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0060] It's important to note that a true quantum computer has a hybrid structure, comprising two main parts: a classical computer responsible for performing classical computations and control, and a quantum device responsible for running quantum programs to achieve quantum computation. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can run on a quantum computer, supporting operations on quantum logic gates and ultimately enabling quantum computing. Specifically, a quantum program is a sequence of instructions that operates on quantum logic gates according to a specific timing order.
[0061] In practical applications, due to limitations in the development of quantum device hardware, quantum computing simulations are often required to verify quantum algorithms, quantum applications, and so on. Quantum computing simulation is the process of simulating the execution of a quantum program corresponding to a specific problem using a virtual architecture (i.e., a quantum virtual machine) built with the resources of a regular computer. Typically, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program referred to in this embodiment of the invention is a program written in a classical language that represents qubits and their evolution, wherein qubits, quantum logic gates, etc., related to quantum computing all have corresponding classical code representations.
[0062] Quantum circuits, also known as quantum logic circuits, are a common manifestation of quantum programming and are the most widely used general-purpose quantum computing model. They represent circuits that operate on qubits under an abstract concept. They consist of qubits, circuits (timelines), and various quantum logic gates. Finally, the results are often read out through quantum measurement operations.
[0063] Unlike traditional circuits that use metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as being connected by time. That is, the state of a quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
[0064] A quantum program corresponds to a single quantum circuit. The quantum program described in this invention refers to this single quantum circuit, where the total number of qubits in the single quantum circuit is the same as the total number of qubits in the quantum program. This can be understood as follows: a quantum program can consist of a quantum circuit, measurement operations on the qubits within the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A single quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution of a quantum program is the process of executing all the quantum logic gates in a specific timing order. It should be noted that the timing order refers to the chronological sequence in which individual quantum logic gates are executed.
[0065] It's important to note that in classical computing, the most basic unit is the bit, and the most fundamental control mode is the logic gate. Circuit control can be achieved through combinations of logic gates. Similarly, the way to process qubits is through quantum logic gates. Quantum logic gates enable the evolution of quantum states and are the foundation of quantum circuits. Quantum logic gates include single-qubit gates, such as Hadamard gates (H-gates), Pauli-X gates (X-gates), Pauli-Y gates (Y-gates), Pauli-Z gates (Z-gates), RX gates, RY gates, RZ gates, etc.; and multi-qubit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, Tofoli gates, etc. Quantum logic gates are generally represented using unitary matrices, which are not only matrix forms but also operations and transformations. The effect of a quantum logic gate on a quantum state is generally calculated by left-multiplying the unitary matrix by the matrix corresponding to the right vector of the quantum state.
[0066] A quantum state, or the logical state of a qubit, is represented in binary in quantum algorithms (or quantum programs). For example, a set of qubits q0, q1, and q2 represents the 0th, 1st, and 2nd qubits, ordered from most significant bit to least significant bit as q2q1q0. The quantum state corresponding to this set of qubits is a superposition of the eigenstates corresponding to this set of qubits. There are a total of 2^(1 / 2) eigenstates corresponding to this set of qubits, that is, 8 eigenstates (definite states): |000>, |001>, |010>, |011>, |100>, |101>, |110>, and |111>. Each bit in each eigenstate corresponds to the qubit. For example, in the state |000>, 000 corresponds to q2q1q0 from most significant bit to least significant bit. |> is the Dirac notation.
[0067] To illustrate the logic state of a single qubit. It may be in a superposition of the states |0>, |1>, |0>, and |1> (an uncertain state), which can be specifically represented as: Where c and d are complex numbers representing the quantum state amplitude (probability amplitude), and the square of the amplitude modulus |c| 2 and |d| 2 Let |c| represent the probabilities of the |0> state and the |1> state, respectively. 2 +|d| 2 =1. In short, a quantum state is a superposition of eigenstates. When the probability of other eigenstates is 0, it is in a uniquely determined eigenstate.
[0068] See Figure 2 , Figure 2 A flowchart illustrating a variational quantum linear solution method for subspaces provided in this embodiment of the invention may include the following steps:
[0069] S201: Determine the system of linear equations to be solved.
[0070] Specifically, determining the system of linear equations to be solved can include:
[0071] Determine the linear equation system Ax = b to be solved and the initial residual r0, where A is a coefficient matrix, b is a vector, and the initial residual r0 is calculated based on the initial solution x0, satisfying r0 = b - Ax0.
[0072] In applied mathematics and scientific and engineering computing, many problems can be described by linear equations. For example, the discretization of electromagnetic field differential equations by numerical algorithms such as the finite element method transforms them into solving matrix equations. Other examples include solving the Navier-Stokes equations in fluid mechanics and lattice gauge theory in quantum chromodynamics (QCD).
[0073] A linear system is a mathematical model that uses linear operators and simultaneously satisfies superposition and homogeneity (also known as homogeneity). Currently, linear systems are central to many scientific and engineering fields. For the linear system Ax = b to be solved, we obtain the element information and dimension of the coefficient matrix A and the vector b. The coefficient matrix is one of many types of matrices; simply put, it's used to calculate the solution to a system of equations by assembling the coefficients of the system. Coefficient matrices are often used to represent mathematical relationships between items. In mathematical statistics, the residual is the difference between the actual value and the estimated value (fitted value). The residual contains important information about the basic assumptions of the system model. The initial residual r0 of the linear system Ax = b to be solved can be calculated based on the preset initial solution x0, satisfying r0 = b - Ax0.
[0074] It should be noted that for solving high-dimensional linear equations, preprocessing can generally be performed first, such as by constructing sparse approximation matrices for linear system preprocessing, to reduce the dimensionality of the linear equations to be solved.
[0075] S202: Construct a variable quantum circuit and a Krylov subspace, and use the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace.
[0076] The Generalized Minimum Residual Method (GMRES) is one of the most commonly used algorithms today, and it is a classic subspace-based solution method for linear problems. The computational complexity of GMRES mainly consists of matrix-vector multiplication and vector orthogonalization. Therefore, further reducing its computational complexity has always been a challenging task.
[0077] Specifically, constructing variable quantum circuits and Krylov subspaces, and using the generalized minimum residual method and variable quantum circuits, can calculate approximate solutions to the linear equations to be solved within the subspace. This may include:
[0078] S2021: Construct an m-order Krylov subspace K corresponding to the coefficient matrix A and vector b. m Orthogonal basis set V m and Hessenberg matrix H m+1,m .
[0079] Specifically, based on the Arnoldi algorithm, the coefficient matrix A, and the vector b, an m-order Krylov subspace K can be constructed. m Orthogonal basis set V m and Hessenberg matrix H m+1,m .
[0080] Among them, we can define:
[0081] K m =span{r0, Ar0, A 2 r0,…,A m-1 r0}
[0082] Let A be the m-order Krylov subspace of coefficient matrix A and vector b. By definition, Krylov subspaces are nested, i.e., K1∈K2∈…∈K m Clearly, the orthogonal basis set of the subspace {V1, V2, ..., V} is... m} is also nested. The core idea of GMRES is to transform the exact solution of the linear system to be solved into finding the "optimal solution" in a certain subspace, when the solution x m Constrained in subspace K m Within the time frame, it is obvious that x m It can be made by K m base V m Linear representation. Based on the nested property mentioned above, we have Ax m ∈K m+1 When x m In K m When Ax changes, m In a higher-order subspace K m+1 The internal changes accordingly. Because r m =r0-Ax m Therefore r m The magnitude and direction also change. In order for the "optimal solution" to approximate the exact solution, r is required to... m The modulus should be as small as possible; therefore, the mathematical form of the generalized minimum residual method can be described as: finding x m ∈K m , making r m ⊥AK m Therefore, it can be seen that in the GMRES method, the solution space is K. m The constraint space of the solution is AK.m .
[0083] The m-th order Krylov subspace K is solved using the Arnoldi algorithm based on Gram-Schmidt orthogonalization. m Orthogonal basis set V m For subspace K m Approximate solution x within m , can be made by K m orthogonal basis set V m Linear representation, we have:
[0084] x m =x0+V m y m
[0085] Orthogonality condition r0-Ax m ⊥AK m ,have to:
[0086]
[0087] Among them, the orthogonal basis set V m It has the following properties:
[0088]
[0089]
[0090] Among them, h m+1,m =(w m v m+1 ), w m =Av m e m = [0, 0, 0, ..., 1] T H m+1,m The matrix formed during the execution of the Arnoldi algorithm records the projection information from the original space to the subspace, and its matrix form is as follows:
[0091]
[0092] Combining the properties of orthogonal basis sets mentioned above, GMRES (Generalized Minimum Residual) directly uses r... m Starting with the condition of minimizing the modulus, the optimal criterion can be described as finding X. m ∈K m Solve for min||r0-Ax m ||2.
[0093] S022: For the Hessenberg matrix H m+1,mPerform QR decomposition.
[0094] Specifically, for the Hessenberg matrix H m+1,m Performing QR decomposition may include: decomposing the Hessenberg matrix H... m+1,m Decomposed into Among them, Q m+1 R is an orthogonal matrix. m+1,m It is an upper triangular matrix.
[0095] Among them, the QR decomposition method is currently the most efficient and widely used method for finding all eigenvalues of a general matrix. The general matrix is first transformed into a Hessenberg matrix through orthogonal similarity transformation, and then the QR method is applied to find the eigenvalues and eigenvectors. It decomposes the matrix into an orthogonal matrix Q and an upper triangular matrix R, hence the name QR decomposition method, which is related to the general notation Q of this orthogonal matrix.
[0096] S2023: Construct a variable quantum circuit and use the variable quantum circuit to process the QR decomposition results to obtain the linear equation system to be solved in the Krylov subspace K. m The median value y within m .
[0097] Specifically, a variable quantum circuit is constructed and used to process the QR decomposition results to obtain the linear equation system to be solved in the Krylov subspace K. m The median value y within m It can include:
[0098] Step 1: Construct a first sub-quantum circuit and a second sub-quantum circuit respectively to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace K. m The median value y within m The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function.
[0099] Step 2: Enter R m The values of the residual vector β are used to measure the variable quantum circuit, thereby obtaining the linear equations to be solved in the Krylov subspace K. m The median value y within m The final quantum state, where R m R is an upper triangular matrix m+1,m For the first m rows, β = ||r0||2q1(1:m), where q1(1:m) represents the orthogonal matrix Q. m+1 The vector consisting of the first m elements of the first column, β and R m y mSatisfying the relation: β = R m y m .
[0100] Step 3: Based on the final quantum state, determine the Krylov subspace K of the system of linear equations to be solved. m The median value y within m .
[0101] For details, see Figure 3 , Figure 3 This is a schematic diagram of a first sub-quantum circuit provided in an embodiment of the present invention. The first sub-quantum circuit can be a HEA (Hardware Efficient Ansatz) circuit, wherein each layer of the HEA circuit is composed of parametric quantum logic gates (e.g., RY quantum logic gates) and CNOT quantum logic gates. The black dots in the diagram and... The icon represents a CNOT quantum logic gate, with the black dot on the control bit of the CNOT quantum logic gate. On the target qubit of the CNOT quantum logic gate, the variational parameter is expressed as the rotation angle. The vector is composed of a single-quantum rotation connection layer and a global entanglement layer. As the number of layers increases, the expressive power of the circuit continuously improves, but it also increases the training difficulty of the circuit. The number of qubits and layers of the circuit proposed in the figure can be determined by the dimension of the linear equation system to be solved. With sufficient computing resources, the circuit can be proposed with a sufficient number of qubits and a sufficient number of layers in the HEA to ensure the solution accuracy.
[0102] Before measuring the variable component quantum circuit, R can be input to the variable component quantum circuit. m The value of the residual vector β, because based on the above description, has r0-Ax m =r0-AV m y m =V m+1 (β-Hm+1, mym, since the column vectors of Vm+1 are orthogonal, therefore:
[0103] ||r0-Ax m ||2=||V m+1 (β-H m+1,m y m )||2=||β-H m+1,m y m ||2
[0104] Therefore, in the GMRES method, the problem is transformed into a least squares problem. When m is not very large, QR decomposition is used to solve the above least squares problem. From: For H m+1,m The QR decomposition, where Qm+1 R is an orthogonal matrix. m+1,m Since it is an upper triangular matrix, we have:
[0105]
[0106] Among them, R m For R m+1,m The first m rows, therefore y m This can be obtained by solving the following system of upper triangular equations:
[0107] β=R m y m
[0108] Where β=||r0||2q1(1:m), q1(1:m) represents the orthogonal matrix Q m+1 The vector consisting of the first m elements of the first column, q1 is Q m+1 The first column.
[0109] The final linear system to be solved in GMRES is:
[0110] β=R m y m
[0111] S2024: Based on the intermediate value y m Obtain the linear equation system to be solved in the Krylov subspace K. m Approximate solution x within m , where x m =x0+V m y m .
[0112] Specifically, this includes the system of linear equations to be solved in the Krylov subspace K. m The median value y within m The final quantum state is represented by the quantum state trial wave function of variational fitting, with the intermediate value y. m That is, the ground state of the Hamiltonian as described below.
[0113] Determine the linear equation system to be solved in the Krylov subspace K. m The median value y within m It can include:
[0114] a. Obtain the pre-constructed Hamiltonian.
[0115] b. Based on the linear equations to be solved in the Krylov subspace K m The median value y within m The final quantum state determines the expected value corresponding to the Hamiltonian.
[0116] c. Determine the Krylov subspace K of the linear equation system to be solved based on the expected value. m The median value y within m .
[0117] Specifically, after the aforementioned variable quantum circuit, the final state is obtained. To read quantum state information, a pre-constructed Hamiltonian can be used. Measuring the final state yields the solution to the linear equations in the Krylov subspace K. m The middle value within The key to this process is the pre-constructed Hamiltonian. Expected value The system of linear equations to be solved is located in the Krylov subspace K. m The median value y within m Therefore, the linear system Ax = b to be solved exists in the subspace K. m An approximate solution can then be obtained.
[0118] It should be noted that the above steps, which combine variational quantum circuits and the GMRES algorithm, obtain an approximate solution to the linear equations to be solved in the subspace. However, the accuracy of this approximate solution is not good, and it is necessary to further utilize the idea of iteration to solve for the target solution in order to improve the computational accuracy.
[0119] Specifically, a loss function is constructed based on the approximate solution, and it is determined whether the value of the loss function meets the preset precision. If yes, the approximate solution is used as the target solution of the linear equation system to be solved. Otherwise, the variational parameters are updated, and the approximate solution of the linear equation system corresponding to the updated variational parameters is obtained. The steps of constructing the variational quantum circuit and Krylov subspace, and using the generalized minimum residual method and variational quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace are continued until an approximate solution that satisfies the preset precision of the loss function is obtained, which is then used as the target solution of the linear equation system to be solved.
[0120] The loss function is:
[0121]
[0122] The For the loss function, the Here, I is the variational parameter, and I is the identity matrix. and U is a parametric quantum logic gate.
[0123]
[0124] In the partial derivative form of the loss function described above, it can be divided into three terms, namely: the first partial derivative term. Second partial derivative term and the third partial derivative term These three items can be measured separately through the second sub-quantum circuit, specifically:
[0125]
[0126]
[0127]
[0128] And because:
[0129]
[0130] For the purpose of measuring the second quantum circuit, Rewrite it in the following form:
[0131]
[0132] in, It is a unitary matrix.
[0133] See Figure 4 , Figure 4 This is a schematic diagram of a second sub-quantum circuit provided in an embodiment of the present invention. The specific second sub-quantum circuit mainly consists of three circuits shown in Figures (a), (b), and (c), which are used for the first partial derivative term, respectively. Second partial derivative term and the third partial derivative term The measurement is shown in the figure, where H represents the H quantum logic gate, S represents the S quantum logic gate, and U0, U0, ..., U i+1 U L This indicates the proposed U-gate. Denotes a unitary matrix, σ s Let σ' be a unitary matrix. s U represents a unitary matrix. b Let X represent the unitary matrix formed by encoding |b>, and let X represent the Pauli X gate.
[0134] To determine whether the value of the loss function meets the precision requirement, specifically:
[0135] Based on the approximate solution of the linear equation to be solved, the target solution of the system of linear equations to be solved is then obtained, mainly by using a pre-selected measurement operator. When applied to the final quantum state, the Krylov subspace K of the system of linear equations to be solved can be obtained at the current step. m The median value y within mThis process involves obtaining an approximate solution, substituting the approximate solution from the current step into the loss function, and then determining whether the value of the loss function meets the required precision. The precision can be set by the user according to their computational needs, for example, 10. -6 Or 0.
[0136] If the value of the loss function constructed based on the approximate solution in the current step meets the preset accuracy, then the approximate solution obtained is exactly the target solution of the linear equation system to be solved; otherwise, the variational parameters in the variational quantum circuit are updated by optimizing the algorithm.
[0137] For example, using the traditional optimization method—gradient descent—the variational parameters are updated using the following formula.
[0138]
[0139] Where k is an integer not less than 1, and α is the learning rate. Let θ be the gradient of the loss function with respect to θ.
[0140] Then, the updated variational parameters are passed to the variational quantum circuit, and the evolution and measurement steps described above are continued. The approximate solution is updated and the loss function is solved by iterating the variational parameters until a predicted solution with the required accuracy to satisfy the loss function is obtained, which is then used as the target solution for the linear equation system to be solved.
[0141] As can be seen, this application combines the GMRES algorithm and variable quantum circuits in the solution method of linear systems, thereby significantly improving the solution of linear systems and enabling the simulation of real physical problems on a quantum virtual machine on a regular PC.
[0142] Compared with existing technologies, this invention first determines the system of linear equations to be solved, then constructs a variable quantum circuit and a Krylov subspace, and uses the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the system of linear equations in the subspace. It can reduce the complexity and computational cost of solving linear problems by using the generalized minimum residual method and the variable quantum circuit, thus filling the gap in related technologies.
[0143] See Figure 5 , Figure 5 This is a schematic diagram of a variational quantum linear solver for subspaces provided in an embodiment of the present invention. Figure 2 The process shown can include:
[0144] Module 501 is used to determine the system of linear equations to be solved.
[0145] Module 502 is used to construct the variable quantum circuit and the Krylov subspace, and to calculate the approximate solution of the linear system of equations to be solved in the subspace using the generalized minimum residual method and the variable quantum circuit.
[0146] Specifically, the determining module includes:
[0147] A determining unit is used to determine the linear equation system Ax = b to be solved and the initial residual r0, wherein A is a coefficient matrix, b is a vector, and the initial residual r0 is calculated based on the initial solution x0, satisfying r0 = b - Ax0.
[0148] Specifically, the building module includes:
[0149] The first construction unit is used to construct the m-order Krylov subspace K corresponding to the coefficient matrix A and the vector b. m Orthogonal basis set V m and Hessenberg matrix H m+1,m ;
[0150] Decomposition unit, used for the Hessenberg matrix H m+1,m Perform QR decomposition;
[0151] The second construction unit is used to construct a variable quantum circuit and process the QR decomposition results using the variable quantum circuit to obtain the linear equation system to be solved in the Krylov subspace K. m The median value y within m ;
[0152] The acquisition unit is used to obtain the intermediate value y. m To obtain an approximate solution x of the linear equation system to be solved. m , where x m =x0+V m y m .
[0153] Specifically, the decomposition unit includes:
[0154] Decomposition subunits are used to decompose the Hessenberg matrix H. m+1,m Decomposed into Among them, Q m+1 R is an orthogonal matrix. m+1,m It is an upper triangular matrix.
[0155] Specifically, the device further includes:
[0156] The judgment module is used to construct a loss function based on the approximate solution and determine whether the value of the loss function meets the preset precision.
[0157] The update module is used to, if yes, take the approximate solution as the target solution of the linear equation system to be solved; otherwise, update the variational parameters, obtain the approximate solution of the linear equation system corresponding to the updated variational parameters, and continue to execute the steps of constructing the variational quantum circuit and Krylov subspace, and using the generalized minimum residual method and variational quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace, until an approximate solution that satisfies the loss function value with a preset accuracy is obtained, which is then taken as the target solution of the linear equation system to be solved.
[0158] Specifically, the second building unit includes:
[0159] Constructing sub-units, used to construct a first sub-quantum circuit and a second sub-quantum circuit respectively, to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace K. m The median value y within m The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function;
[0160] Measurement subunit, used for input R m The values of the residual vector β are used to measure the variable quantum circuit, thereby obtaining the linear equations to be solved in the Krylov subspace K. m The median value y within m The final quantum state, where R m R is an upper triangular matrix m+1,m For the first m rows, β = ||r0||2q1(1:m), where q1(1:m) represents the orthogonal matrix Q. m+1 The vector consisting of the first m elements of the first column, β and R m y m Satisfying the relation: β = R m y m ;
[0161] Determine the subunit, used to determine the linear equations to be solved in the Krylov subspace K based on the final quantum state. m The median value y within m .
[0162] Compared with existing technologies, this invention first determines the system of linear equations to be solved, then constructs a variable quantum circuit and a Krylov subspace, and uses the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the system of linear equations in the subspace. It can reduce the complexity and computational cost of solving linear problems by using the generalized minimum residual method and the variable quantum circuit, thus filling the gap in related technologies.
[0163] This invention also provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the method embodiments described above when running.
[0164] Specifically, in this embodiment, the storage medium can be configured to store a computer program for performing the following steps:
[0165] S201: Determine the system of linear equations to be solved;
[0166] S202: Construct a variable quantum circuit and a Krylov subspace, and use the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace.
[0167] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0168] This invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the method embodiments described above.
[0169] Specifically, the aforementioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the aforementioned processor, and the input / output device is connected to the aforementioned processor.
[0170] Specifically, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0171] S201: Determine the system of linear equations to be solved;
[0172] S202: Construct a variable quantum circuit and a Krylov subspace, and use the generalized minimum residual method and the variable quantum circuit to calculate the approximate solution of the linear equation system to be solved in the subspace.
[0173] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.
Claims
1. A variational quantum linear solution method for subspaces, characterized in that, The method includes: Determine the system of linear equations to be solved and initial residual , wherein For the coefficient matrix, the The initial residual is a vector. Based on the initial solution Calculate, satisfy ; A variable quantum circuit and a Krylov subspace are constructed. Using the generalized minimum residual method and the variable quantum circuit, approximate solutions to the linear equations to be solved are calculated within the subspace, including: Construct the corresponding coefficient matrix ,vector of Krylov subspace of order Standard orthogonal basis set and Hessenberg matrix ; For the Hessenberg matrix Perform QR decomposition; A first sub-quantum circuit and a second sub-quantum circuit are constructed respectively to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace. The middle value within The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function; enter and residual vector The value is measured and the variational quantum circuit is obtained to obtain the linear equations to be solved in the Krylov subspace. The middle value within The final quantum state, wherein, the It is an upper triangular matrix The former Okay, the above The Represents an orthogonal matrix The first column A vector consisting of n elements, the and , relation: ; Based on the final quantum state, the system of linear equations to be solved is determined in the Krylov subspace. The middle value within ; According to the intermediate value To obtain an approximate solution to the system of linear equations to be solved. , wherein .
2. The method according to claim 1, characterized in that, The Hessenberg matrix Perform QR decomposition, including: The Hessenberg matrix Decomposed into , wherein It is an orthogonal matrix, the It is an upper triangular matrix.
3. The method according to any one of claims 1 to 2, characterized in that, The method further includes: Construct a loss function based on the approximate solution and determine whether the value of the loss function meets the preset precision. If so, the approximate solution is taken as the target solution of the linear equation system to be solved; otherwise, the variational parameters are updated, the approximate solution of the linear equation system corresponding to the updated variational parameters is obtained, and the steps of constructing the variational quantum circuit and Krylov subspace, and calculating the approximate solution of the linear equation system to be solved in the subspace using the generalized minimum residual method and the variational quantum circuit are continued until an approximate solution that satisfies the loss function with a preset accuracy is obtained, which is taken as the target solution of the linear equation system to be solved.
4. The method according to claim 3, characterized in that, The loss function is: Among them, the For the loss function, the For variational parameters, the The identity matrix, the and The It is a parameterized quantum logic gate.
5. A variational quantum linear solver for subspaces, characterized in that, The device includes: The determination module is used to determine the system of linear equations to be solved. and initial residual , wherein For the coefficient matrix, the The initial residual is a vector. Based on the initial solution Calculate, satisfy ; The building module is used to construct the variational quantum circuit and the Krylov subspace. Using the generalized minimum residual method and the variational quantum circuit, it calculates approximate solutions to the linear equations to be solved within the subspace, including: Construct the corresponding coefficient matrix ,vector of Krylov subspace of order Standard orthogonal basis set and Hessenberg matrix ; For the Hessenberg matrix Perform QR decomposition; A first sub-quantum circuit and a second sub-quantum circuit are constructed respectively to form a variable quantum circuit, wherein the first sub-quantum circuit is used to form a system of linear equations to be solved in the Krylov subspace. The middle value within The second sub-quantum circuit is used to obtain the value of the loss function and / or the gradient of the loss function; enter and residual vector The value is measured and the variational quantum circuit is obtained to obtain the linear equations to be solved in the Krylov subspace. The middle value within The final quantum state, wherein, the It is an upper triangular matrix The former Okay, the above The Represents an orthogonal matrix The first column A vector consisting of n elements, the and , relation: ; Based on the final quantum state, the system of linear equations to be solved is determined in the Krylov subspace. The middle value within ; According to the intermediate value To obtain an approximate solution to the system of linear equations to be solved. , wherein .
6. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 4 when it is run.
7. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method described in any one of claims 1 to 4.