Quantum linear solution method, device and medium based on generalized minimal residual
Through the quantum linear solution method based on generalized minimal residual quantum, combined with sparse approximation matrix and Krylov subspace, and combined with the quantum circuit of the HHL algorithm, the time complexity and calculation quantity of quantum linear system algorithms when solving high-dimensional linear problems are solved. High-quality problems can be solved efficiently on ordinary computers.
Patent Information
- Application Number
- CN202111275781.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2041-10-29
AI Technical Summary
When existing quantum linear system algorithms deal with high-dimensional linear problems, the time complexity and calculation amount are too high, resulting in the inability to effectively solve actual physical problems on ordinary computers.
Using a quantum linear solution method based on generalized minimal residual amount, by obtaining the linear system to be processed, a sparse approximation matrix and Krylov subspace are constructed, combined with the quantum circuit of the HHL algorithm, and the approximation solution is calculated based on the generalized minimal residual amount method to reduce time complexity degree and calculation amount.
It significantly reduces the time complexity and calculation amount of linear problems, speeds up the solution speed of quantum linear algorithms, reduces the use of hardware resources, and realizes large-scale linear problems solving on ordinary computers.
Smart Images

Figure CN116090571B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of quantum computing technology, and in particular to a quantum linear solution method, device and medium based on generalized minimal residual. Background Art
[0002] Quantum computers are physical devices that follow the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have become a key technology under research because they have the ability to process mathematical problems more efficiently than ordinary computers. For example, they can speed up the time to crack RSA keys from hundreds of years to a few hours.
[0003] Quantum computing simulation is a simulation that uses numerical calculations and computer science to simulate calculations that follow the laws of quantum mechanics. As a simulation program, it uses the basic laws of quantum bits in quantum mechanics and the high-speed computing power of computers to characterize the spatiotemporal evolution of quantum states.
[0004] Solving systems of linear equations is at the core of many scientific and engineering problems. The classical algorithms for solving such problems are collectively referred to as linear system algorithms. In recent years, a very important achievement in the field of quantum computing is the quantum linear system algorithm, of which the most famous 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 increases, resulting in the need to call megabytes or even gigabytes of data during the solution process. The demand for computing resources is too high, making it impossible to simulate and solve actual physical problems on ordinary computers. Summary of the invention
[0005] The purpose of the present invention is to provide a quantum linear solution method, device and medium based on generalized minimal residual to solve the deficiencies in the prior art. It can reduce the time complexity and calculation amount of solving linear problems, while reducing the occupation of hardware resources.
[0006] An embodiment of the present application provides a quantum linear solution method based on a generalized minimal residual, the method comprising:
[0007] Get the linear system Ax=b to be processed;
[0008] Constructing a sparse approximation matrix M for linear system preprocessing, and preprocessing the linear system to be processed;
[0009] Construct the m-order Krylov subspace K mThe quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0010] Optionally, obtaining the linear system to be processed Ax=b includes:
[0011] Obtain a linear system Ax=b to be processed and an initial residual b0, wherein A is a first matrix, b is a first vector, and the initial residual b0 is calculated according to a preset initial solution x0, satisfying b0=b-Ax0.
[0012] Optionally, constructing a sparse approximation matrix M for linear system preprocessing and preprocessing the linear system to be processed includes:
[0013] According to the first matrix A, a sparse approximation matrix M for linear system preprocessing is constructed, wherein the sparse approximation matrix M is A -1 The sparse approximation of and satisfies the preset sparse structure;
[0014] According to the sparse approximate matrix M, a second matrix A′ and a second vector b′ in the linear system are respectively obtained, wherein the second matrix A′=MA, and the second vector b′=Mb.
[0015] Optionally, the construction of the m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m ,include:
[0016] According to the Arnoldi algorithm, the second matrix A′ and the second vector b′, construct the m-order Krylov subspace K m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m ;
[0017] For the Hessenberg matrix H m+1,m Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm;
[0018] Using the quantum circuit corresponding to the HHL algorithm, the linear system to be processed is output in the Krylov subspace K m The middle value y m ;
[0019] According to the intermediate value y m, obtain the linear system to be processed in the Krylov subspace K m The approximate solution x m , where x m =x0+V m y m .
[0020] Optionally, the Hessenberg matrix H m+1,m Perform QR decomposition, including:
[0021] The Hessenberg matrix H m+1,m Decompose into Among them, Q m+1 is an orthogonal matrix, R m+1,m is an upper triangular matrix.
[0022] Optionally, the quantum circuit corresponding to the HHL algorithm is used to output the linear system to be processed in the Krylov subspace K m The middle value y m ,include:
[0023] Using the quantum circuit corresponding to the HHL algorithm, input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m , where R m is the upper triangular matrix R m+1,m The first m rows of , β = ‖b0‖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, β and R m ,y m Satisfy the relationship: β=R m y m .
[0024] Optionally, the quantum circuit corresponding to the HHL algorithm is used to input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Afterwards, the method further comprises:
[0025] Determine the intermediate value y m Can it satisfy ‖R m y m -β‖2<∈1, where ∈1 is the preset first precision;
[0026] If the intermediate value y m Not satisfied with ‖R m ym -β‖2<∈1, then get the updated residual vector β new And return to execute the quantum circuit corresponding to the HHL algorithm, input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Step, wherein the updated residual vector β new =β-R m y m .
[0027] Optionally, the method further includes:
[0028] If the intermediate value y m Satisfy ‖R m y m -β‖2<∈1, then the approximate solution x is determined m Can it satisfy ‖A′x m -b′‖2<∈2, where ∈2 is the preset second precision;
[0029] If the approximate solution x m Satisfies ‖A′x m -b′‖2<∈2, then determine the approximate solution x m That is, the linear system Ax=b to be processed in the Krylov subspace K m The target approximate solution is within .
[0030] Optionally, the method further includes:
[0031] If the approximate solution x m Does not satisfy ‖A′x m -b′‖2<∈2, then get the current residual b0-Ax m And return to execute the Arnoldi algorithm, the second matrix A' and the second vector b', to construct the m-order Krylov subspace K m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m The iterative calculation is continued until a target approximate solution satisfying a preset second accuracy is obtained.
[0032] Optionally, constructing a quantum circuit corresponding to the HHL algorithm includes:
[0033] A plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit are obtained, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to The b iis the i-th element of the first vector b, and N is the dimension of the first vector;
[0034] Determine a unitary matrix U corresponding to the first matrix A;
[0035] Construct a first sub-quantum circuit module for phase estimation, which is used to decompose the |b> in the eigenspace of the first matrix A into And convert the initial states of the first quantum bit and the second quantum bit |0>|b> into Among them, the |μ j > is the eigenvector of the first matrix A, the λ j is the eigenvalue of the first matrix A, the β j is the amplitude of the eigenvector of the first matrix A;
[0036] A second sub-quantum circuit module is constructed to perform a controlled rotation operation, which is used to convert |λ j >Using the auxiliary qubit as a control bit to rotate, we get Wherein, C is a normalization constant;
[0037] The third quantum circuit module for performing inverse phase estimation is constructed to convert |λ j >reset to |0〉;
[0038] A measurement operation module for the auxiliary quantum bit is constructed so that when the quantum state of the auxiliary quantum bit is measured to be |1>, the following is obtained: The |x′〉∝|x〉;
[0039] The first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module are sequentially combined to form a quantum circuit corresponding to the HHL algorithm.
[0040] Optionally, determining a unitary matrix U corresponding to the first matrix A includes:
[0041] If the first matrix A is a Hermite matrix, determine the corresponding unitary matrix U=e iAt ; Wherein, t is a constant;
[0042] If the first matrix A is a non-Hermite matrix, determine the corresponding Hermite matrix To determine the corresponding unitary matrix
[0043] Another embodiment of the present application provides a quantum linear solution device based on generalized minimal residual, the device comprising:
[0044] An acquisition module, used for acquiring a linear system Ax=b to be processed;
[0045] A construction module, used to construct a sparse approximation matrix M for linear system preprocessing, and preprocess the linear system to be processed;
[0046] Construction module, used to construct the m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0047] Optionally, the acquisition module includes:
[0048] The first acquisition unit is used to obtain the linear system Ax=b to be processed and the initial residual b0, wherein A is a first matrix, b is a first vector, and the initial residual b0 is calculated according to a preset initial solution x0, satisfying b0=b-Ax0.
[0049] Optionally, the building block includes:
[0050] A first construction unit is used to construct a sparse approximate matrix M for linear system preprocessing according to the first matrix A, wherein the sparse approximate matrix M is A -1 The sparse approximation of and satisfies the preset sparse structure;
[0051] The second acquisition unit is used to respectively acquire a second matrix A′ and a second vector b′ in the linear system according to the sparse approximate matrix M, wherein the second matrix A′=MA, and the second vector b′=Mb.
[0052] Optionally, the construction module includes:
[0053] A construction unit, used to construct an m-order Krylov subspace K according to the Arnoldi algorithm, the second matrix A′ and the second vector b′ m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m ;
[0054] The second building block is used to transform the Hessenberg matrix H m+1,m Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm;
[0055] An output unit is used to output the linear system to be processed in the Krylov subspace K using the quantum circuit corresponding to the HHL algorithm. m The middle value y m ;
[0056] The third acquisition unit is used to obtain the intermediate value y m , obtain the linear system to be processed in the Krylov subspace K m The approximate solution x m , where x m =x0+V m y m .
[0057] Optionally, the second building unit includes:
[0058] Decomposition subunit, used to convert the Hessenberg matrix H m+1,m Decompose into Among them, Q m+1 is an orthogonal matrix, R m+1,m is an upper triangular matrix.
[0059] Optionally, the output unit includes:
[0060] The output subunit is used to use the quantum circuit corresponding to the HHL algorithm to input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m , where R m is the upper triangular matrix R m+1,m The first m rows of , β = ‖b0‖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, β and R m ,y m Satisfy the relationship: β=R m y m .
[0061] Optionally, after the output subunit, the following is further included:
[0062] The first judgment subunit is used to judge the intermediate value y m Can it satisfy ‖R m y m -β‖2<∈1, where ∈1 is the preset first precision;
[0063] The first return subunit is used to return the intermediate value y m Not satisfied with ‖R m y m -β‖2<∈1, then get the updated residual vector β new And return to execute the quantum circuit corresponding to the HHL algorithm, input R mand the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Step, wherein the updated residual vector β new =β-R m y m .
[0064] Optionally, the device further comprises:
[0065] The second judgment subunit is used to determine if the intermediate value y m Satisfy ‖R m y m -β‖2<∈1, then the approximate solution x is determined m Can it satisfy ‖A′x m -b′‖2<∈2, where ∈2 is the preset second precision;
[0066] The first determination subunit is used to determine if the approximate solution x m Satisfies ‖A′x m -b′‖2<∈2, then determine the approximate solution x m That is, the linear system Ax=b to be processed in the Krylov subspace K m The target approximate solution is within .
[0067] Optionally, the device further comprises:
[0068] The second return subunit is used to return the approximate solution x m Does not satisfy ‖A′x m -b′‖2<∈2, then get the current residual b0-Ax m And return to execute the Arnoldi algorithm, the second matrix A' and the second vector b', to construct the m-order Krylov subspace K m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m The iterative calculation is continued until a target approximate solution satisfying a preset second accuracy is obtained.
[0069] Optionally, the second building unit includes:
[0070] An obtaining subunit is used to obtain a plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to The b i is the i-th element of the first vector b, and N is the dimension of the first vector;
[0071] A second determining subunit, used to determine a unitary matrix U corresponding to the first matrix A;
[0072] The first construction subunit is used to construct a first sub-quantum circuit module for phase estimation, and is used to decompose the |b> in the eigenspace of the first matrix A into And convert the initial states of the first quantum bit and the second quantum bit |0>|b> into Among them, the |μ j > is the eigenvector of the first matrix A, the λ j is the eigenvalue of the first matrix A, the β j is the amplitude of the eigenvector of the first matrix A;
[0073] The second construction subunit is used to construct a second sub-quantum circuit module for performing a controlled rotation operation, and is used to convert |λ j >Using the auxiliary qubit as a control bit to rotate, we get Wherein, C is a normalization constant;
[0074] The third construction subunit is used to construct a third sub-quantum circuit module for performing inverse phase estimation, and is used to convert |λ j >reset to |0>;
[0075] The fourth construction subunit is used to construct a measurement operation module for the auxiliary quantum bit, so that when the quantum state of the auxiliary quantum bit is measured to be |1>, the following is obtained: The |x′〉∝|x〉;
[0076] The composition subunit is used to sequentially combine the first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module to form a quantum circuit corresponding to the HHL algorithm.
[0077] Optionally, the second determining subunit includes:
[0078] The third determination subunit is used to determine the corresponding unitary matrix U=e if the first matrix A is a Hermite matrix iAt ; Wherein, t is a constant;
[0079] The fourth determination subunit is used to determine the corresponding Hermite matrix if the first matrix A is a non-Hermite matrix To determine the corresponding unitary matrix
[0080] Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute any of the above methods when running.
[0081] Yet another embodiment of the present 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 execute any of the methods described above.
[0082] Compared with the prior art, the present invention first obtains the linear system to be processed Ax=b, constructs a sparse approximate matrix M for linear system preprocessing, and preprocesses the linear system to be processed to construct an m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m It can reduce the time complexity and computational effort of solving linear problems, speed up the solution of quantum linear algorithms, and reduce the occupation of hardware resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 A hardware structure block diagram of a computer terminal for a quantum linear solution method based on a generalized minimal residual provided by an embodiment of the present invention;
[0084] Figure 2 A schematic flow chart of a quantum linear solution method based on a generalized minimal residual provided in an embodiment of the present invention;
[0085] Figure 3 A schematic diagram of a first sub-quantum circuit module corresponding to phase estimation provided in an embodiment of the present invention;
[0086] Figure 4 A schematic diagram of the total quantum circuit corresponding to the HHL algorithm provided in an embodiment of the present invention;
[0087] Figure 5 A schematic diagram of the structure of a quantum linear solution device based on a generalized minimal residual provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0088] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, but should not be construed as limiting the present invention.
[0089] The embodiment of the present invention first provides a quantum linear solution method based on a generalized minimal residual, which can be applied to electronic devices such as computer terminals, specifically ordinary computers, quantum computers, etc.
[0090] The following describes it in detail by taking running on a computer terminal as an example. Figure 1The hardware structure block diagram of a computer terminal of a quantum linear solution method based on a generalized minimal residual provided by an embodiment of the present invention. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the computer terminal may also include a transmission device 106 for communication functions and an input and output device 108. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0091] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / modules corresponding to the quantum linear solution method based on the generalized minimal residue in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above method. The memory 104 may include a high-speed random access memory, and may also include a 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 a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0092] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0093] It should be noted that a true quantum computer is a hybrid structure, which consists of two parts: one part is a classical computer, which is responsible for performing classical calculations and control; the other part is a quantum device, which is responsible for running quantum programs and thus realizing quantum computing. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can be run on a quantum computer, which supports quantum logic gate operations and ultimately realizes quantum computing. Specifically, a quantum program is a sequence of instructions that operate quantum logic gates in a certain sequence.
[0094] In practical applications, due to the limitations of the development of quantum device hardware, quantum computing simulation is usually required to verify quantum algorithms, quantum applications, etc. Quantum computing simulation is the process of simulating the operation of quantum programs corresponding to specific problems using a virtual architecture (i.e., quantum virtual machine) built with the resources of ordinary computers. Usually, it is necessary to build a quantum program corresponding to a specific problem. The quantum program referred to in the embodiment of the present invention is a program written in a classical language to characterize quantum bits and their evolution, in which quantum bits, quantum logic gates, etc. related to quantum computing are represented by corresponding classical codes.
[0095] Quantum circuits, as a manifestation of quantum programs, are also called quantum logic circuits. They are the most commonly used general quantum computing model. They represent circuits that operate on quantum bits in an abstract concept. They are composed of quantum bits, circuits (timelines), and various quantum logic gates. Finally, the results often need to be read out through quantum measurement operations.
[0096] Unlike traditional circuits that are connected by metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as connected by time, that is, the state of the quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated.
[0097] A quantum program as a whole corresponds to a total quantum circuit. The quantum program described in the present invention refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits in the quantum program. It can be understood that a quantum program can be composed of a quantum circuit, measurement operations on quantum bits in the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution process of a quantum program is the process of executing all quantum logic gates in a certain time sequence. It should be noted that the time sequence is the time order in which a single quantum logic gate is executed.
[0098] It should be noted that in classical computing, the most basic unit is the bit, and the most basic control mode is the logic gate, which can achieve the purpose of controlling the circuit through the combination of logic gates. Similarly, the way to process quantum bits is quantum logic gates. Using quantum logic gates, quantum states can evolve. Quantum logic gates are the basis of quantum circuits. Quantum logic gates include single-bit quantum logic gates, such as Hadamard gates (H gates, Hadamard gates), Pauli-X gates (X gates), Pauli-Y gates (Y gates), Pauli-Z gates (Z gates), RX gates, RY gates, RZ gates, etc.; multi-bit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, Toffoli gates, etc. Quantum logic gates are generally represented by unitary matrices, and unitary matrices are not only in matrix form, but also a kind of operation and transformation. The effect of general quantum logic gates on quantum states is calculated by multiplying the unitary matrix on the left by the matrix corresponding to the right vector of the quantum state.
[0099] The quantum state, that is, the logical state of the quantum bit, is represented by binary in the quantum algorithm (or quantum program). For example, a group of quantum bits is q0, q1, and q2, representing the 0th, 1st, and 2nd quantum bits, and is sorted from high to low as q2q1q0. The quantum state corresponding to this group of quantum bits is the superposition of the eigenstates corresponding to this group of quantum bits. The eigenstates corresponding to this group of quantum bits have 2 to the power of the total number of quantum bits, that is, 8 eigenstates (determined states): |000>, |001>, |010>, |011>, |100>, |101>, |110>, |111>, and the bit of each eigenstate corresponds to the quantum bit. For example, in the |000> state, 000 corresponds to q2q1q0 from high to low, and |> is the Dirac symbol.
[0100] Using a single qubit to illustrate, the logical state of a single qubit It may be in the |0> state, |1> state, or the superposition state of |0> state and |1> state (uncertain state), which can be specifically expressed as Where c and d are complex numbers representing the amplitude (probability amplitude) of the quantum state, and the square of the amplitude modulus |c| 2 and |d| 2 denote the probabilities of the |0> and |1> states, respectively, and |c| 2 +|d| 2 = 1. In short, the quantum state is a superposition state composed of various eigenstates. When the probability of other eigenstates is 0, it is in the only determined eigenstate.
[0101] See also Figure 2 , Figure 2 A schematic flow chart of a quantum linear solution method based on a generalized minimal residual provided in an embodiment of the present invention may include the following steps:
[0102] S201: Obtain a linear system Ax=b to be processed.
[0103] Specifically, the linear system Ax=b to be processed and the initial residual b0 can be obtained, wherein A is a first matrix, b is a first vector, and the initial residual b0 is calculated according to a preset initial solution x0, satisfying b0=b-Ax0.
[0104] In the field of applied mathematics and scientific engineering computing, the mathematical models of many problems can be described by linear equations. For example, the simulation calculation problem of target electromagnetic characteristics is transformed into the solution of matrix equations by discretizing electromagnetic field calculus equations through numerical algorithms such as moment method and finite element method. Another example is the solution of NS equations in fluid mechanics and lattice gauge theory in quantum chromodynamics (QCD).
[0105] A linear system is a mathematical model that refers to a system composed of linear operators and satisfies superposition and uniformity (also known as homogeneity). At present, linear systems are the core of many scientific and engineering fields. For the linear system Ax=b to be processed, the element information and dimension of the first matrix A and the first vector b are obtained respectively. The first matrix A can be a coefficient matrix. The coefficient matrix is one of the many types of matrices. Simply put, the coefficient matrix is to form a matrix of coefficients of the equation group to calculate the solution of the equation. The coefficient matrix is often used to represent the mathematical relationship of some items. When the coefficient matrix is asymmetric, the generalized minimum residual method (GMRES) is the most commonly used algorithm today. The computational complexity of GMRES mainly consists of two parts: matrix-vector product and vector orthogonalization. How to further reduce its computational complexity has always been a challenging task.
[0106] In mathematical statistics, residual refers to 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. For the linear system Ax=b to be processed, the initial residual b0 can be calculated based on the preset initial solution x0, satisfying b0=b-Ax0.
[0107] S202: construct a sparse approximation matrix M for linear system preprocessing, and preprocess the linear system to be processed.
[0108] Construct a sparse approximation matrix for linear system preprocessing, including:
[0109] S1: Based on the first matrix A, construct a sparse approximate matrix M for linear system preprocessing, wherein the sparse approximate matrix M is A -1 The sparse approximation of and satisfies the preset sparse structure.
[0110] Specifically, let N = {1, 2, 3, ..., n}, Represents the preset sparse structure. The sparse approximate inverse preprocessing technique aims to explicitly construct A -1 The sparse approximation is used to reduce the condition number of the matrix and reduce the difficulty and complexity of the solution. The most basic premise is that given the first matrix A, there exists A -1 A sparse approximation matrix M in some sense such that M ≈ A -1 , how to quickly capture A -1 The position information of the elements determines the sparse structure of M, which is the key to the success of the algorithm.
[0111] It should be noted that the sparse approximate inverse preprocessing technique for minimizing the F-norm is achieved by minimizing the residual matrix ‖AM-I‖ F To calculate A -1 A sparse approximation M of , where M satisfies a certain sparse structure (M is either given in advance or determined dynamically during the execution of the algorithm). According to the characteristics of the matrix F-norm, minimize ‖AM-I‖ F It can be transformed into solving n least squares problems independently, so it has natural parallel characteristics. However, for the general first matrix A, it is often difficult to predetermine a reasonable and effective sparse structure of M. -1 When there are few large elements in A, the prior structure may not be able to effectively capture their position information, or only when the prior structure is very dense can the same information as A be obtained at the cost of computation and storage. -1 M with a higher degree of approximation. In order to overcome the above difficulties, a strategy for dynamically determining the sparse structure of M can be proposed. This strategy often starts with a simple initial structure (such as the structure of the unit matrix or the structure of the sparse first matrix A, etc.), and then gradually expands or adaptively adjusts according to certain rules until the residual matrix satisfies a given accuracy ‖AM-I‖ with respect to a certain norm. F ≤ε, where ε represents a preset precision value, or the number of non-zero elements of M reaches a predetermined maximum value.
[0112] S2: According to the sparse approximate matrix M, respectively obtain a second matrix A′ and a second vector b′ in the linear system, wherein the second matrix A′=MA, and the second vector b′=Mb.
[0113] Specifically, according to the sparse approximate matrix M, a second matrix A′ and a second vector b′ with reduced condition number in the linear system are obtained respectively.
[0114] S203: Construct m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0115] First, according to the Arnoldi algorithm, the second matrix A′ and the second vector b′, the m-order Krylov subspace K is constructed. m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m .
[0116] Specifically, the generalized minimum residual method (GMRES) is a classic subspace-based solution method for linear problems. For the linear system Ax = b to be processed, given a preset initial solution x0, there is an initial residual b0 = b-Ax0, defined as:
[0117] K m =span{b0,Ab0,A 2 b0,…,A m-1 b0}
[0118] is the m-order Krylov subspace of the second matrix A′ and the second vector b′. From the definition, we can see that the Krylov subspace is nested, that is, K1∈K2∈…∈K m , it is clear that the orthogonal basis set of the subspace {V1,V2,…,V m The core idea of GMRES is to transform the exact solution of the linear system to be processed into finding the "optimal solution" in a subspace. m Constrained in subspace K m When x m Can be K m Base V m Linear representation. According to the above nested properties, Ax m ∈K m+1 , when x m In K m When Ax m In a higher order subspace K m+1 The internal changes accordingly. m = b0-Ax m , so b m The size and direction of b also change. In order to make the "optimal solution" close to the exact solution, b is required m The modulus of is as small as possible, so the mathematical form of the generalized minimum residual method can be described as: Find x m ∈K m , so that b m ⊥AK m , it can be seen that in the GMRES method, the solution space is K m , the solution constraint space is AK m .
[0119] The m-order Krylov subspace K is solved by using the Arnoldi algorithm based on Gram-Schmidt orthogonalization. m The standard orthogonal basis set V m , for the subspace K m The approximate solution x m , can be represented by K m The orthogonal basis set V m Linear representation:
[0120] x m =x0+V m y m
[0121] Orthogonality condition b0-Ax m ⊥AK m ,have to:
[0122]
[0123] Among them, the orthogonal basis set V m It has the following properties:
[0124]
[0125]
[0126] 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 It is a matrix composed of elements in the process of executing the Arnoldi algorithm, which records the projection information from the original space to the subspace. Its matrix form is as follows:
[0127]
[0128] Combining the properties of the above orthogonal basis set, GMRES (Generalized Minimum Residual) directly obtains the m Starting from the condition of minimum modulus length, the optimal criterion can be described as finding x m ∈K m , solve for min‖b0-Ax m ‖2.
[0129] Secondly, for the Hessenberg matrix H m+1,m Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm.
[0130] The QR decomposition method is currently the most effective and widely used method for finding all eigenvalues of a general matrix. The general matrix first undergoes an orthogonal similarity transformation to become a Hessenberg matrix, 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, so it is called the QR decomposition method, which is related to the universal symbol Q of this orthogonal matrix.
[0131] The Hessenberg matrix H m+1,m Decompose into Among them, Q m+1 is an orthogonal matrix, R m+1,m is an upper triangular matrix.
[0132] Based on the above description, we have b0-Ax m =b0-AV m y m =V m+1 (β-H m+1,m y m ), due to V m+1 The column vectors of are orthonormal, so:
[0133] ‖b0-Ax m ‖2=||V m+1 (β-H m+1,m y m )||2=||β-H m+1,m y m ||2
[0134] 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 least squares problem. By: H m+1,m QR decomposition, where Q m+1 is an orthogonal matrix, R m+1,m is an upper triangular matrix, so we have:
[0135]
[0136] Among them, R m For R m+1,m The first m rows of , so y m It can be obtained by solving the following upper triangular equations:
[0137] β=R m y m
[0138] Among them, β = ‖b0‖2q1(1:m), q1(1:m) represents the orthogonal matrix Q m+1 A vector consisting of the first m elements of the first column, q1 is Qm+1 The first column of .
[0139] The linear system to be processed in GMRES is:
[0140] β=R m y m
[0141] The linear system to be processed Ax=b in subspace K m The approximate solution within can be obtained. It can be seen that the biggest feature of using GMRES to solve linear problems is the "dimensionality reduction" effect. If the dimension of the first matrix is n, the dimension of the subspace that meets the accuracy requirement is m. Generally speaking, m is often significantly smaller than n.
[0142] Specifically, constructing the quantum circuit corresponding to the HHL algorithm includes the following steps:
[0143] Step 1: Obtain a plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to The b i is the i-th element of the first vector b, and N is the dimension of the first vector.
[0144] Specifically, the number of quantum bits to be obtained can be determined by the user according to demand, or a more sufficient number of quantum bits can be set to meet computing needs if computing resources are sufficient.
[0145] A plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit are obtained, which can be specifically represented by a quantum bit position. For example, if the initial quantum bit position is |0>, it means that the quantum state of the quantum bit is |0> state, and if it is |1>, it means that the initial quantum state is |1> state.
[0146] It should be noted that, for the convenience of subsequent distinction, the obtained quantum bits can be divided into auxiliary quantum bits, first quantum bits, and second quantum bits. The specific distinction names are not limited here, and the initial state of each quantum bit can be prepared by the existing amplitude coding method or quantum state coding method. Among them, the initial state of the auxiliary quantum bit and the first quantum bit is set to |0> state, and the initial state of the second quantum bit is set to For example, for the 4-dimensional first vector b = [b1, b2, b3, b4], that is, N = 4, the data of the first vector b is encoded into the quantum state amplitude, and we get:
[0147]
[0148] The data of the first vector b is loaded onto the quantum state amplitude of the two second quantum bits in the quantum circuit.
[0149] Step 2: Determine the unitary matrix U corresponding to the first matrix A.
[0150] Specifically, if the first matrix A is a unitary matrix, the first matrix A is directly determined as the corresponding unitary matrix U;
[0151] If the first matrix A is a Hermite matrix, the conversion from the Hermite matrix to the unitary matrix can be realized by Hamiltonian simulation, and the corresponding unitary matrix U=e iAt ; Where t is a constant, usually 2π;
[0152] If the first matrix A is a non-Hermite matrix, it is transformed by expanding the dimension to determine the corresponding Hermitian matrix To determine the corresponding unitary matrix At the same time, the first vector b is transformed into It can also be written as have to x m This is the solution of the above HHL algorithm.
[0153] Step 3: Construct a first sub-quantum circuit module for phase estimation, which is used to decompose the |b> in the eigenspace of the first matrix A into And convert the initial states of the first quantum bit and the second quantum bit |0>|b> into Among them, the |μ j > is the eigenvector of the first matrix A, the λ j is the eigenvalue of the first matrix A, the β j is the amplitude of the eigenvector of the first matrix A.
[0154] Specifically, a first sub-quantum circuit module for phase estimation is constructed to decompose the |b> in the eigenspace of the first matrix A into And transform the initial states of the first and second qubits |0>|b> into Those skilled in the art can understand that phase estimation is an important application of quantum Fourier transform (QFT), which is reflected in that it is the basis of many quantum algorithms.
[0155] like Figure 3 The first sub-quantum circuit module corresponding to the phase estimation provided in this embodiment is shown as a schematic diagram, including: an H gate operation module, a controlled U operator operation module and a quantum Fourier inverse transformation module (in the figure Module), where the U operator is the unitary matrix U corresponding to the first matrix A. After the first sub-quantum circuit module, the auxiliary quantum bit (corresponding to Figure 3 The quantum state of the top timeline) remains unchanged, and the first qubit (corresponding to Figure 3 The initial state of the timeline in the middle |0> is transformed into |λ j >, the second quantum bit (corresponding to Figure 3 The initial state of the bottom timeline) |b> decomposition
[0156] In fact, the output λ j is an estimated value, and the output accuracy of the phase estimation can be improved by increasing the number of the first quantum bits. In addition, in practical applications, an auxiliary quantum register, a first quantum register, and a second quantum register can be set to store the quantum states of the auxiliary quantum bit, the first quantum bit, and the second quantum bit, respectively.
[0157] Step 4: Construct a second sub-quantum circuit module for performing a controlled rotation operation to convert |λ j >Using the auxiliary qubit as a control bit to rotate, we get Wherein, C is a normalization constant.
[0158] Specifically, a second sub-quantum circuit module for performing a controlled rotation operation is constructed to convert |λ j >Using the auxiliary qubit as a control bit to rotate, we get The controlled rotation can also be called "extraction ratio" because after the phase estimation operation, the first quantum register will store a series of eigenvalues λ j (Specifically stored in the base state |λ j >), and the input state stored in the second quantum register, namely the initial state |b>, is decomposed in the eigenspace of the first matrix A, and then the λ in the ground state is rotated by a controlled rotation operation. j The value is extracted from the amplitude, and the quantum state of the auxiliary quantum bit |0> is converted to obtain The quantum state of each quantum bit passes through the second quantum circuit route Convert to In order to reduce resource usage, the auxiliary quantum bit can be set to 1 bit, and C is a constant, generally 1.
[0159] It should be noted that, yes, the quantum state |x>=A can be obtained in the second quantum register -1 |b> (more precisely, the close |x> quantum state), accompanied by a constant factor C. Later, amplitude amplification can be used to increase the probability of success, replacing the process of simply measuring and screening the results.
[0160] Step 5: Construct a third sub-quantum circuit module for performing inverse phase estimation to convert |λ j >Reset to |0>.
[0161] Specifically, those skilled in the art can understand that the inverse operation of phase estimation is the restoration process of the above phase estimation, or the transposed conjugate operation of phase estimation, the purpose of which is to convert |λ j >reset to |0>, specifically by resetting the quantum state Convert to the following:
[0162]
[0163] Step 6: Construct a measurement operation module for the auxiliary quantum bit so that when the quantum state of the auxiliary quantum bit is measured to be |1>, the following is obtained: The |x′>∝|x>.
[0164] Specifically, the quantum measurement operation is applied to the auxiliary qubit to measure the auxiliary qubit after the inverse operation of the phase estimation. After the measurement, the state of the auxiliary qubit collapses to a certain state, where the probability of collapsing to |0〉 is The probability of collapsing to |1〉 is When the quantum state of the auxiliary quantum bit is measured to be |1〉 and C=1, a definite quantum state can be obtained: |x′〉= It can be seen that The corresponding result of amplitude normalization. In practical applications, |x〉 can be obtained according to the application scenario required by the user, or |x′〉 can be directly used for subsequent scenario calculations.
[0165] Step 7: The first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module are sequentially combined into a quantum circuit corresponding to the HHL algorithm.
[0166] For details, see Figure 4 , Figure 4 According to the execution sequence of the first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module, a complete quantum circuit is sequentially formed, which is the total quantum circuit corresponding to the HHL algorithm.
[0167] Again, using the quantum circuit corresponding to the HHL algorithm, the linear system to be processed is output in the Krylov subspace K m The middle value y m , which may include:
[0168] Using the quantum circuit corresponding to the HHL algorithm, input Rm and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m , where R m is the upper triangular matrix R m+1,m The first m rows of , β = ‖b0‖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, β and R m ,y m Satisfy the relationship: β=R m y m .
[0169] Specifically, since the HHL algorithm has an exponential acceleration effect compared to the classical algorithm under certain conditions, it will be widely used in scenarios such as data processing, machine learning, numerical calculation, and fluid mechanics problem processing in the future.
[0170] In this embodiment, the HHL algorithm can be used to solve a problem of solving a linear equation, that is, input a first matrix A and a first vector b, and output a solution x that satisfies the linear equation and satisfies Ax=b, that is, x=A -1 b. Therefore, the first matrix A needs to satisfy the requirement of being a reversible matrix, and for the first vector b, due to the need to load the data of the first vector b into the quantum circuit as described below, the dimension of the first vector b needs to be expressible as a positive integer power of 2. If the dimension does not conform to the form of a positive integer power of 2, zeros are added to the elements of the first vector b until the form of a positive integer power of 2 is satisfied. Similarly, the element information of the first matrix A loaded into the quantum circuit also needs to conform to the form of a positive integer power of 2. If zero-padding is required, the principle and method are the same as the method of zero-padding the elements of the first vector b.
[0171] Using the quantum circuit corresponding to the HHL algorithm constructed above, input R m and the value of the residual vector β, the linear system to be processed can be output in the Krylov subspace K through measurement and other operations m The middle value y m .
[0172] Finally, according to the intermediate value y m , obtain the linear system to be processed in the Krylov subspace K m The approximate solution x m , where x m =x0+V m y m .
[0173] It should be noted that, using the quantum circuit corresponding to the HHL algorithm, input R mand the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Afterwards, the method further comprises:
[0174] Determine the intermediate value y m Can it satisfy ‖R m y m -β‖2<∈1, where ∈1 is the preset first precision.
[0175] Specifically, judge ‖R m y m -β‖2 can satisfy the first preset accuracy. Its main purpose is to determine the intermediate value y calculated by the above HHL algorithm. m Whether it meets the user's preset ∈1 accuracy requirements is convenient for further processing.
[0176] If the intermediate value y m Not satisfied with ‖R m y m -β‖2<∈1, then get the updated residual vector β new And return to execute the quantum circuit corresponding to the HHL algorithm, input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Step, wherein the updated residual vector β new =β-R m y m .
[0177] If the intermediate value y m Satisfy ‖R m y m -β‖2<∈1, then the approximate solution x is determined m Can it satisfy ‖A′x m -b′‖2<∈2, where ∈2 is the preset second precision.
[0178] Specifically, judge ‖A′x m The main purpose of checking whether the value of -b′‖2 can meet the second preset accuracy is to check whether the accuracy loss of the approximate solution obtained after dimensionality reduction calculation using GMRES is small enough to meet the user's preset accuracy requirements.
[0179] If the approximate solution x m Satisfies ‖A′x m -b′‖2<∈2, then determine the approximate solution x m That is, the linear system Ax=b to be processed in the Krylov subspace K mThe target approximate solution is within .
[0180] If the approximate solution x m Does not satisfy ‖A′x m -b′‖2<∈2, then get the current residual b0-Ax m And return to execute the Arnoldi algorithm, the second matrix A' and the second vector b', to construct the m-order Krylov subspace K m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m The iterative calculation is continued until a target approximate solution satisfying a preset second accuracy is obtained.
[0181] Specifically, when x m If the preset second precision is not met, the residual b0-Ax of the current step is obtained. m , update the second vector and continue the calculation as the input vector of the next iteration until the target approximate solution that meets the preset second accuracy is obtained.
[0182] It should be noted that the above iterative steps, in order to solve the problem of poor accuracy of the GMRES algorithm in low-dimensional subspace solutions, use the idea of iteration to solve the target approximate solution, thereby improving the calculation accuracy and stability.
[0183] It can be seen that this application combines the GMRES algorithm in the linear system solution method with the quantum HHL algorithm, thereby significantly improving the acceleration effect of the HHL algorithm, so that actual physical problems can be simulated on a quantum virtual machine on an ordinary PC. The time complexity of the HHL algorithm for solving linear problems is O(s 2 κ 2 logN), where N is the matrix dimension, κ is the matrix condition number, and s represents the matrix density. Obviously, the HHL algorithm can be accelerated in three ways: reducing the matrix dimension N to be solved; reducing the condition number κ of the matrix to be solved or increasing the sparsity of the matrix by reducing s. In the GMRES algorithm, the equations in the m-dimensional subspace are directly solved:
[0184] β-R m y m =0
[0185] The dimension m of the system of equations is often much smaller than the dimension of the original problem, thus achieving accelerated solution. This is one of the advantages of the GMRES-HHL algorithm, which retains the "dimensionality reduction" effect of the GMRES method. Note that the input matrix directly solved by GMRES is a low-dimensional matrix, which can be easily converted into a normalized double diagonal matrix because the Hessenberg matrix can significantly increase the sparsity of the coefficient matrix and reduce the matrix condition number to a certain extent. Also note that the matrix can be easily processed during the algorithm without introducing too much additional calculation. In addition, for the selection of nested subspaces in GMRES, there are:
[0186] K m =span{b0,Ab0,A 2 b0,…,A m-1 b0}
[0187] That is, in the process of constructing the subspace, by continuously applying the matrix A to the initial residual, the initial residual is continuously rotated and expanded in the space, so it can be understood as an artificial signal amplification process. Assuming that the problem is m-dimensional full rank, the initial residual can always be expressed by the m eigenvectors μ of the matrix A m Linear representation, as the matrix A continues to work, the eigenvector μ m According to its corresponding eigenvalue λ m The size of is constantly scaling. Obviously, as m gets larger, λ m The greater the influence weight of the eigenvector >1, the greater the influence weight of λ m The influence of eigenvectors < 1 is getting smaller and smaller, that is, A m-1 The direction of b0 tends to be more stable. When the condition number of matrix A is larger, this weak influence is more difficult to distinguish, so a basis with a very small modulus length is needed to construct this weak change. However, in the low-dimensional subspace, this influence is weakened, and the low-frequency information of the original matrix is not fully considered. Therefore, the low-dimensional matrix H m Not only is the dimension smaller than the original matrix A, but the condition number is also smaller than the original matrix A. This is the second advantage of the GMRES-HHL algorithm, that is, the condition number is automatically reduced in the low-dimensional space. In summary, compared with the direct HHL algorithm, the GMRES-HHL algorithm reduces the problem dimension, condition number, increases sparsity, and can better stimulate the acceleration performance of the HHL algorithm, thus making it possible to solve large-scale linear problems based on the HHL algorithm on ordinary PCs.
[0188] Compared with the prior art, the present invention first obtains the linear system to be processed Ax=b, constructs a sparse approximate matrix M for linear system preprocessing, and preprocesses the linear system to be processed to construct an m-order Krylov subspace K mThe quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m It can reduce the time complexity and computational effort of solving linear problems, speed up the solution of quantum linear algorithms, and reduce the occupation of hardware resources.
[0189] See also Figure 5 , Figure 5 A schematic diagram of a quantum linear solution device based on a generalized minimal residual provided by an embodiment of the present invention, and Figure 2 The process shown here corresponds to the following:
[0190] An acquisition module 501 is used to acquire a linear system Ax=b to be processed;
[0191] A construction module 502 is used to construct a sparse approximation matrix M for linear system preprocessing, and to preprocess the linear system to be processed;
[0192] Construction module 503, used to construct the m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0193] Specifically, the acquisition module includes:
[0194] The first acquisition unit is used to obtain the linear system Ax=b to be processed and the initial residual b0, wherein A is a first matrix, b is a first vector, and the initial residual b0 is calculated according to a preset initial solution x0, satisfying b0=b-Ax0.
[0195] Specifically, the building blocks include:
[0196] A first construction unit is used to construct a sparse approximate matrix M for linear system preprocessing according to the first matrix A, wherein the sparse approximate matrix M is A -1 The sparse approximation of and satisfies the preset sparse structure;
[0197] The second acquisition unit is used to respectively acquire a second matrix A′ and a second vector b′ in the linear system according to the sparse approximate matrix M, wherein the second matrix A′=MA, and the second vector b′=Mb.
[0198] Specifically, the construction module includes:
[0199] A construction unit, used to construct an m-order Krylov subspace K according to the Arnoldi algorithm, the second matrix A′ and the second vector b′ m The standard orthogonal basis set V m and the Hessenberg matrix H m+1,m ;
[0200] The second building block is used to transform the Hessenberg matrix H m+1,m Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm;
[0201] An output unit is used to output the linear system to be processed in the Krylov subspace K using the quantum circuit corresponding to the HHL algorithm. m The middle value y m ;
[0202] The third acquisition unit is used to obtain the intermediate value y m , obtain the linear system to be processed in the Krylov subspace K m The approximate solution x m , where x m =x0+V m y m .
[0203] Specifically, the second construction unit includes:
[0204] Decomposition subunit, used to convert the Hessenberg matrix H m+1,m Decompose into Among them, Q m+1 is an orthogonal matrix, R m+1,m is an upper triangular matrix.
[0205] Specifically, the output unit includes:
[0206] The output subunit is used to use the quantum circuit corresponding to the HHL algorithm to input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m , where R m is the upper triangular matrix R m+1,m The first m rows of , β = ‖b0‖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, β and R m ,y m Satisfy the relationship: β=R m y m .
[0207] Specifically, after the output subunit, it also includes:
[0208] The first judgment subunit is used to judge the intermediate value y m Can it satisfy ‖R m y m -β‖2<∈1, where ∈1 is the preset first precision;
[0209] The first return subunit is used to return the intermediate value y m Not satisfied with ‖R m y m -β‖2<∈1, then get the updated residual vector β new And return to execute the quantum circuit corresponding to the HHL algorithm, input R m and the value of the residual vector β, outputting the linear system to be processed in the Krylov subspace K m The middle value y m Step, wherein the updated residual vector β new =β-R m y m .
[0210] Specifically, the device further includes:
[0211] The second judgment subunit is used to determine if the intermediate value y m Satisfy ‖R m y m -β‖2<∈1, then the approximate solution x is determined m Can it satisfy ‖A′x m -b′‖2<∈2, where ∈2 is the preset second precision;
[0212] The first determination subunit is used to determine if the approximate solution x m Satisfies ‖A′x m -b′‖2<∈2, then determine the approximate solution x m That is, the linear system Ax=b to be processed in the Krylov subspace K m The target approximate solution is within .
[0213] Specifically, the device further includes:
[0214] The second return subunit is used to return the approximate solution x m Does not satisfy ‖A′x m -b′‖2<∈2, then get the current residual b0-Ax m And return to execute the Arnoldi algorithm, the second matrix A' and the second vector b', to construct the m-order Krylov subspace K m The standard orthogonal basis set Vm and the Hessenberg matrix H m+1,m The iterative calculation is continued until a target approximate solution satisfying a preset second accuracy is obtained.
[0215] Specifically, the second construction unit includes:
[0216] An obtaining subunit is used to obtain a plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to The b i is the i-th element of the first vector b, and N is the dimension of the first vector;
[0217] A second determining subunit, used to determine a unitary matrix U corresponding to the first matrix A;
[0218] The first construction subunit is used to construct a first sub-quantum circuit module for phase estimation, and is used to decompose the |b> in the eigenspace of the first matrix A into And convert the initial states of the first quantum bit and the second quantum bit |0>|b> into Among them, the |μ j > is the eigenvector of the first matrix A, the λ j is the eigenvalue of the first matrix A, the β j is the amplitude of the eigenvector of the first matrix A;
[0219] The second construction subunit is used to construct a second sub-quantum circuit module for performing a controlled rotation operation, and is used to convert |λ j 〉Using as the control bit to rotate the auxiliary qubit, we get Wherein, C is a normalization constant;
[0220] The third construction subunit is used to construct a third sub-quantum circuit module for performing inverse phase estimation, and is used to convert |λ j >reset to |0〉;
[0221] The fourth construction subunit is used to construct a measurement operation module for the auxiliary quantum bit, so that when the quantum state of the auxiliary quantum bit is measured to be |1>, the following is obtained: The |x′〉∝|x〉;
[0222] The composition subunit is used to sequentially combine the first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module to form a quantum circuit corresponding to the HHL algorithm.
[0223] Specifically, the second determining subunit includes:
[0224] The third determination subunit is used to determine the corresponding unitary matrix U=e if the first matrix A is a Hermite matrix iAt ; Wherein, t is a constant;
[0225] The fourth determination subunit is used to determine the corresponding Hermite matrix if the first matrix A is a non-Hermite matrix To determine the corresponding unitary matrix
[0226] Compared with the prior art, the present invention first obtains the linear system to be processed Ax=b, constructs a sparse approximate matrix M for linear system preprocessing, and preprocesses the linear system to be processed to construct an m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m It can reduce the time complexity and computational effort of solving linear problems, speed up the solution of quantum linear algorithms, and reduce the occupation of hardware resources.
[0227] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0228] Specifically, in this embodiment, the above storage medium may be configured to store a computer program for performing the following steps:
[0229] S201: Obtain a linear system to be processed Ax=b;
[0230] S202: constructing a sparse approximation matrix M for linear system preprocessing, and preprocessing the linear system to be processed;
[0231] S203: Construct m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0232] Specifically, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0233] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.
[0234] Specifically, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0235] Specifically, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0236] S201: Obtain a linear system to be processed Ax=b;
[0237] S202: constructing a sparse approximation matrix M for linear system preprocessing, and preprocessing the linear system to be processed;
[0238] S203: Construct m-order Krylov subspace K m The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace K based on the generalized minimal residual method. m The approximate solution x m .
[0239] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the drawings. Any changes made according to the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the protection scope of the present invention.
Claims
1. A quantum linear solution method based on generalized minimal residual, characterized in that: The method comprises: Get the linear system to be processed , including: Get the linear system to be processed and initial residual , wherein the is the first matrix, is the first vector, the initial residual According to the preset initial solution Calculate, satisfy ; Constructing sparse approximation matrices for linear system preconditioning , and preprocessing the linear system to be processed, including according to the first matrix , construct a sparse approximation matrix for linear system preprocessing , where the sparse approximation matrix for The sparse approximation and the preset sparse structure are satisfied. According to the sparse approximation matrix , respectively obtain the second matrix in the linear system , the second vector , where the second matrix , the second vector ; structure Krylov subspace The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace based on the generalized minimal residual method. The approximate solution in ,include: According to the Arnoldi algorithm, the second matrix and the second vector ,structure Krylov subspace Orthonormal basis set and the Hessenberg matrix ; For the Hessenberg matrix Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm, and transform the Hessenberg matrix Decompose into ,in, is an orthogonal matrix, is an upper triangular matrix; Using the quantum circuit corresponding to the HHL algorithm, the linear system to be processed is output in the Krylov subspace The median value within , using the quantum circuit corresponding to the HHL algorithm, input and the residual vector The value of the linear system to be processed is output in the Krylov subspace The median value within ,in, is an upper triangular matrix Before OK, , Represents an orthogonal matrix The first column A vector consisting of elements, and , relation: ; According to the intermediate value , obtain the linear system to be processed in the Krylov subspace The approximate solution in , wherein the ; The quantum circuit corresponding to the HHL algorithm is constructed, including: A plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit are obtained, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to , The first vector No. elements, the is the dimension of the first vector; Determine the first matrix The corresponding unitary matrix ; Constructing a first sub-quantum circuit module for phase estimation, In the first matrix The feature space is decomposed into , and the initial states of the first quantum bit and the second quantum bit Convert to , wherein the The first matrix The feature vector of The first matrix The characteristic value of The first matrix the amplitude of the eigenvector; A second sub-quantum circuit module is constructed to perform a controlled rotation operation. As the control bit, the auxiliary quantum bit is rotated to obtain , wherein the is the normalization constant; A third quantum circuit module is constructed to perform inverse phase estimation. Reset to ; Construct a quantum measurement operation module for the auxiliary quantum bit so that the quantum state of the auxiliary quantum bit measured is When , we get: , ; The first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module are sequentially combined to form a quantum circuit corresponding to the HHL algorithm.
2. The method according to claim 1, characterized in that The quantum circuit corresponding to the HHL algorithm is input and the residual vector The value of the linear system to be processed is output in the Krylov subspace The median value within Afterwards, the method further comprises: Determine the intermediate value Can it be satisfied ,in, To preset the first precision; If the intermediate value Dissatisfied , then get the updated residual vector And return to execute the quantum circuit corresponding to the HHL algorithm, input and the residual vector The value of the linear system to be processed is output in the Krylov subspace The median value within step, wherein the updated residual vector 3. The method according to claim 2, characterized in that The method further comprises: If the intermediate value satisfy , then determine the approximate solution Can it be satisfied ,in, To preset the second precision; If the approximate solution satisfy , then determine the approximate solution That is the linear system to be processed In Krylov subspace The target approximate solution is within .
4. The method according to claim 3, characterized in that The method further comprises: If the approximate solution Dissatisfied , then get the current residual And return to execute the Arnoldi algorithm, the second matrix and the second vector ,structure Krylov subspace Orthonormal basis set and the Hessenberg matrix The iterative calculation is continued until a target approximate solution satisfying a preset second accuracy is obtained.
5. The method according to claim 1, characterized in that The determining of the first matrix The corresponding unitary matrix ,include: If the first matrix For the Hermite matrix, determine the corresponding unitary matrix ; wherein said is a constant; If the first matrix For a non-Hermite matrix, determine the corresponding Hermite matrix , to determine the corresponding unitary matrix .
6. A quantum linear solver based on generalized minimal residual, characterized in that: The device comprises: Acquisition module, used to obtain the linear system to be processed , including: obtaining the linear system to be processed and initial residual , wherein the is the first matrix, is the first vector, the initial residual According to the preset initial solution Calculate, satisfy ; Building blocks for constructing sparse approximation matrices for preconditioning of linear systems , and preprocessing the linear system to be processed, including according to the first matrix , construct a sparse approximation matrix for linear system preprocessing , where the sparse approximation matrix for The sparse approximation and the preset sparse structure are satisfied. According to the sparse approximation matrix , respectively obtain the second matrix in the linear system , the second vector , where the second matrix , the second vector ; Construction module, used to construct Krylov subspace The quantum circuit corresponding to the HHL algorithm calculates the preprocessed linear system in the Krylov subspace based on the generalized minimal residual method. The approximate solution in ,include: According to the Arnoldi algorithm, the second matrix and the second vector ,structure Krylov subspace Orthonormal basis set and the Hessenberg matrix ; For the Hessenberg matrix Perform QR decomposition and construct the quantum circuit corresponding to the HHL algorithm, and transform the Hessenberg matrix Decompose into ,in, is an orthogonal matrix, is an upper triangular matrix; Using the quantum circuit corresponding to the HHL algorithm, the linear system to be processed is output in the Krylov subspace The median value within , using the quantum circuit corresponding to the HHL algorithm, input and the residual vector The value of the linear system to be processed is output in the Krylov subspace The median value within ,in, is an upper triangular matrix Before OK, , Represents an orthogonal matrix The first column A vector consisting of elements, and , relation: ; According to the intermediate value , obtain the linear system to be processed in the Krylov subspace The approximate solution in , wherein the ; The quantum circuit corresponding to the HHL algorithm is constructed, including: A plurality of quantum bits including an auxiliary quantum bit, a first quantum bit, and a second quantum bit are obtained, wherein the initial states of the auxiliary quantum bit and the first quantum bit are set to |0>, and the initial state of the second quantum bit is set to , The first vector No. elements, the is the dimension of the first vector; Determine the first matrix The corresponding unitary matrix ; Constructing a first sub-quantum circuit module for phase estimation, In the first matrix The feature space is decomposed into , and the initial states of the first quantum bit and the second quantum bit Convert to , wherein the The first matrix The feature vector of The first matrix The characteristic value of The first matrix the amplitude of the eigenvector; A second sub-quantum circuit module is constructed to perform a controlled rotation operation. As the control bit, the auxiliary quantum bit is rotated to obtain , wherein the is the normalization constant; A third quantum circuit module is constructed to perform inverse phase estimation. Reset to ; Construct a quantum measurement operation module for the auxiliary quantum bit so that the quantum state of the auxiliary quantum bit measured is When , we get: , ; The first sub-quantum circuit module, the second sub-quantum circuit module, the third sub-quantum circuit module and the quantum measurement operation module are sequentially combined into a quantum circuit corresponding to the HHL algorithm.
7. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 5 when executed.
8. An electronic device, comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and system for achieving GMRES algorithm
CN105045768A
Acoustic vibration model correction method based on energy sensitivity analysis
CN108875243A