Method, apparatus and medium for solving linear systems using variational quantum circuits
By using distributed computing clusters and variable quantum circuit cutting technology, the problem of high resource requirements for solving linear systems in quantum computing simulations has been solved, achieving faster computing speeds and lower quantum circuit depths, thus promoting the expansion of quantum computing simulation applications.
Patent Information
- Application Number
- CN202210565232.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-05-23
AI Technical Summary
In existing quantum computing simulation applications, the time complexity of solving linear systems increases with the dimension of the input matrix, resulting in excessive computational resource requirements. This makes it impossible to effectively solve real-world physical problems on ordinary computers, thus limiting the development of quantum computing.
A distributed computing cluster and variable quantum circuits are used. Sub-quantum circuits are formed by cutting the circuits. Distributed processors are used for parallel processing. Each processor performs the measurement task of one sub-quantum circuit and the measurement results are combined to solve the linear system.
It improves computing speed, reduces the depth of quantum circuits, promotes the further development of quantum computing simulation applications, and reduces computational complexity.
Smart Images

Figure CN117151231B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of quantum computing, and particularly relates to a method and device for solving a linear system by using a variational quantum circuit and a medium. BACKGROUND
[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 a quantum algorithm, it is a quantum computer. The quantum computer has the ability to process mathematical problems more efficiently than ordinary computers, for example, it can accelerate the time for cracking RSA keys from hundreds of years to a few hours, so it has become a key technology under research.
[0003] Quantum computing simulation is a simulation calculation that simulates the laws of quantum mechanics with the aid of numerical calculation and computer science. As a simulation program, it uses the high-speed computing power of a computer to depict the space-time evolution of a quantum state in accordance with the basic laws of quantum bits of quantum mechanics.
[0004] Solving a linear system is the core of many scientific and engineering problems, and the classical algorithms for solving such problems are collectively referred to as linear system algorithms. In recent years, one of the most important achievements in the field of quantum computing is quantum linear system algorithms. However, as the dimension of the input matrix increases, the time complexity of solving linear problems will also increase, which may require the use of megabytes or even gigabytes of data during the solving process, resulting in high demand for computing resources. This makes it impossible to simulate and solve actual physical problems on ordinary computers, which to some extent limits the development of quantum computing. As a result, users are not strong in using quantum computing to solve linear systems, which affects the further development of quantum computing simulation applications. SUMMARY
[0005] The purpose of the present application is to provide a method and device for solving a linear system by using a variational quantum circuit and a medium to solve the problems in the prior art. It can provide support for the implementation of a variational quantum circuit for solving a linear system by using distributed technology, improve the computing speed and reduce the depth of the quantum circuit, and promote the further development of quantum computing simulation applications.
[0006] One embodiment of the present application provides a method for solving a linear system by using a variational quantum circuit, applied to a distributed computing cluster, wherein the distributed computing cluster comprises a master server and a plurality of distributed processors in communication connection with the master server, and the method comprises the following steps:
[0007] Obtaining each sub-quantum circuit formed by cutting a variational quantum circuit, wherein each sub-quantum circuit contains an approximate solution of a linear system to be solved;
[0008] The number of distributed processors to be invoked is determined based on the number of each sub-quantum circuit.
[0009] Upon receiving a call request for the distributed processor, the distributed processor to be called loads each sub-quantum circuit and measures each sub-quantum circuit through the distributed processor to be called to obtain measurement results. Each distributed processor is used to execute at least one computational task simultaneously, and each computational task corresponds one-to-one with a sub-quantum circuit containing an approximate solution to the linear system to be solved after being cut.
[0010] The measurement results of each of the distributed processors are merged and output, and the resulting distributed measurement results are used as an approximate solution to the linear system to be solved.
[0011] Optionally, before obtaining the individual sub-quantum circuits formed by cutting the variable quantum circuit, the method includes:
[0012] Construct a variable quantum circuit and obtain the directed graph corresponding to the variable quantum circuit. The vertices of the directed graph are used to represent the quantum logic gates in the variable quantum circuit, the edges of the directed graph are used to represent the association between the quantum logic gates, and the direction of the edges of the directed graph is used to represent the timing relationship of executing the quantum logic gates.
[0013] Based on the directed graph, the cutting position of the variable quantum circuit is determined, and the variable quantum circuit is cut based on the cutting position.
[0014] Optionally, the linear system to be solved includes:
[0015] The system of linear equations to be solved is Ax = b, where A is a coefficient matrix and b is a vector. The vector b is encoded to obtain |b>=U b |0>, where S is the number of unitary matrices in the decomposition of coefficient matrix A, and l s Let σ be the coefficient of the linear system to be solved. s U b It is a unitary matrix.
[0016] Optionally, the method further includes:
[0017] 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.
[0018] If yes, the approximate solution is taken as the target solution of the linear system to be solved, otherwise, the variational parameters in the variational quantum circuit are updated, an approximate solution of the linear system corresponding to the updated variational parameters is obtained, the step of combining and outputting the measurement results of each distributed processor to obtain the distributed measurement results as the approximate solution of the linear system to be solved is continuously performed until an approximate solution meeting the value of the loss function in accordance with the accuracy is obtained as the target solution of the linear system to be solved.
[0019] Optionally, the loading the respective sub-quantum circuits and measuring the respective sub-quantum circuits by the distributed processors respectively to obtain measurement results comprises:
[0020] The coefficient matrix A, the vector b and the preset accuracy of the linear system to be solved are input, the respective sub-quantum circuits after cutting are measured and the probability reconstruction is calculated by the distributed processors respectively, and the obtained results are taken as the value of the loss function.
[0021] Optionally, the combining and outputting the measurement results of each distributed processor to obtain the distributed measurement results as the approximate solution of the linear system to be solved comprises:
[0022] Optionally, the combining and outputting the measurement results of each distributed processor to obtain the distributed measurement results as the approximate solution of the linear system to be solved comprises:
[0023] The approximate solution of the linear system to be solved is determined according to the expected value.
[0024] Optionally, the loss function is:
[0025]
[0026] The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter. The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter. The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter. The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter. The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter. The loss function is L, the variational parameter is θ, the I is a unit matrix, the U is a parametric quantum logic gate, the A is a coefficient matrix of a linear system to be solved, the b is a vector of the linear system to be solved, the N is the number of the distributed processors, the M is the number of the sub-quantum circuits, the H is a Hamiltonian, the E is an expected value, and the θ is a variational parameter.
[0027] Another embodiment of the present application provides a device for solving a linear system by using a variational quantum circuit, the device comprising:
[0028] An obtaining module is configured to obtain respective sub-quantum circuits formed by cutting a variational quantum circuit, wherein the respective sub-quantum circuits contain an approximate solution of a linear system to be solved;
[0029] A determining module is configured to determine the number of distributed processors to be invoked according to the number of the respective sub-quantum circuits;
[0030] The measuring module is configured to load the sub-quantum circuits by using the called distributed processors after receiving the calling request for the distributed processors, and measure the sub-quantum circuits by using the called distributed processors respectively to obtain measurement results, wherein each distributed processor is configured to execute at least one computing task simultaneously, and the computing task corresponds to one sub-quantum circuit containing an approximate solution of the linear system to be solved.
[0031] The output module is configured to combine and output the measurement results of each distributed processor to obtain distributed measurement results as the approximate solution of the linear system to be solved.
[0032] Optionally, the apparatus further comprises:
[0033] The constructing module is configured to construct a variational quantum circuit and obtain a directed graph corresponding to the variational quantum circuit, wherein a vertex of the directed graph is configured to represent a quantum logic gate in the variational quantum circuit, an edge of the directed graph is configured to represent an association relationship between the quantum logic gates, and a direction of the edge of the directed graph is configured to represent a time sequence relationship of executing the quantum logic gates.
[0034] The cutting module is configured to determine a cutting position of the variational quantum circuit according to the directed graph, and cut the variational quantum circuit based on the cutting position.
[0035] Optionally, the apparatus further comprises:
[0036] The judging module is configured to construct a loss function according to the approximate solution, and judge whether a value of the loss function meets a preset accuracy.
[0037] The updating module is configured to, if yes, take the approximate solution as a target solution of the linear system to be solved, and otherwise, update a variational parameter in the variational quantum circuit, obtain an approximate solution of the linear system corresponding to the updated variational parameter, and continue to execute the step of combining and outputting the measurement results of each distributed processor to obtain distributed measurement results as the approximate solution of the linear system to be solved until an approximate solution meeting the value of the loss function meets the accuracy is obtained as the target solution of the linear system to be solved.
[0038] Optionally, the measuring module comprises:
[0039] The input unit is configured to input a coefficient matrix A of a linear system to be solved, a vector b, and the preset accuracy, measure and calculate the probability reconstruction of the sub-quantum circuits after cutting by using the distributed processors respectively, and obtain a result as the value of the loss function.
[0040] Optionally, the output module comprises:
[0041] a first determining unit, configured to determine a Hamiltonian constructed in advance, and determine an expected value corresponding to the Hamiltonian according to a measurement result of the distributed processor;
[0042] a second determining unit, configured to determine an approximate solution of the linear system to be solved according to the expected value.
[0043] One embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and the computer program is configured to execute any of the above methods when running.
[0044] One embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to execute any of the above methods.
[0045] Compared with the prior art, the present application first acquires each sub quantum circuit containing an approximate solution of the linear system to be solved in the variational quantum circuit after cutting, determines the number of distributed processors to be called according to the number of each sub quantum circuit, after receiving a calling request for the distributed processors, loads each sub quantum circuit by using the distributed processors to be called, and measures each sub quantum circuit by using the distributed processors respectively to obtain measurement results, wherein each distributed processor is used to execute at least one computing task simultaneously, the measurement results of each distributed processor are combined and output, and the obtained distributed measurement results are used as the approximate solution of the linear system to be solved, which can provide support for solving the linear system of the variational quantum circuit by using the distributed technology, improve the computing speed, reduce the depth of the quantum circuit, and promote the further development of quantum computing simulation application. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 A hardware structure block diagram of a computer terminal using the method for solving the linear system by using the variational quantum circuit is provided for the embodiments of the present application.
[0047] Figure 2 A flowchart of the method for solving the linear system by using the variational quantum circuit is provided for the embodiments of the present application.
[0048] Figure 3 A schematic diagram of a quantum circuit is provided for the embodiments of the present application.
[0049] Figure 4 A process schematic diagram of cutting a quantum circuit into sub quantum circuits is provided for the embodiments of the present application.
[0050] Figure 5A raw quantum circuit schematic diagram provided for an embodiment of the present application;
[0051] Figure 6 A two-sub quantum circuit schematic diagram after cutting of the raw quantum circuit provided for an embodiment of the present application;
[0052] Figure 7 A structure schematic diagram of a device for solving a linear system by using a variational quantum circuit provided for an embodiment of the present application. DETAILED DESCRIPTION
[0053] The embodiments described below with reference to the drawings are exemplary and are only used to explain the present application, and cannot be explained as a limitation of the present application.
[0054] The embodiment of the present application first provides a method for solving a linear system by using a variational quantum circuit, which can be applied to a distributed computing cluster.
[0055] The following will be described in detail by taking a distributed processor running on a computer terminal as an example. Figure 1 A hardware structure block diagram of a computer terminal for the method for solving a linear system by using a variational quantum circuit provided for an embodiment of the present application is shown in the figure. Figure 1 As shown in the figure, the computer terminal can include one or more (only one is shown in the figure) processors 102 (the processor 102 can 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, and optionally, the above computer terminal can further include a transmission device 106 for communication function and an input and output device 108. Figure 1 Those skilled in the art can understand that the structure shown in the figure is only schematic, and it does not limit the structure of the above computer terminal.For example, the computer terminal can further include more or less components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 Figure 1 Figure 1
[0056] The memory 104 can be used to store software programs of application software and modules, such as program instructions / modules corresponding to the method for solving a linear system by using a variational quantum circuit in the embodiments 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, implements the above method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include memories remotely arranged with respect to the processor 102, which can be connected to the computer terminal through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0057] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network can 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 (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
[0058] It should be noted that a real quantum computer is a hybrid structure, which includes two parts: one part is a classical computer responsible for performing classical computation and control; the other part is a quantum device responsible for running a quantum program to implement quantum computation. The quantum program is a sequence of instructions written in a quantum language such as QRunes language that can run on a quantum computer, which supports quantum logic gate operations and finally realizes quantum computation. Specifically, the quantum program is a sequence of instructions for operating quantum logic gates in a certain time sequence.
[0059] In practical applications, due to the limitation of the development of quantum device hardware, quantum computation simulation is usually needed to verify quantum algorithms, quantum applications, and the like. Quantum computation simulation is a process of simulating the running of a quantum program corresponding to a specific problem by means of a virtual architecture (i.e., a quantum virtual machine) built by using resources of an ordinary computer. Generally, a quantum program corresponding to a specific problem needs to be constructed. The quantum program referred to in the embodiments of the present application is a program written in a classical language representing quantum bits and their evolution, in which quantum bits, quantum logic gates, and the like related to quantum computation are represented by corresponding classical codes.
[0060] As a way of embodying quantum programs, quantum circuits, also called quantum logic circuits, are the most commonly used general quantum computing model, representing a circuit for operating on qubits in an abstract concept, which consists of qubits, circuits (time lines), and various quantum logic gates, and finally the results are often read out through quantum measurement operations.
[0061] Unlike traditional circuits, which are connected by metal wires to transmit voltage signals or current signals, in quantum circuits, the circuits can be seen as being connected by time, that is, the state of the qubits naturally evolves over time, and in this process, the qubits are operated on according to the instructions of the Hamiltonian operator until they encounter a logic gate.
[0062] A quantum program corresponds to a total quantum circuit as a whole, and the quantum program described in the present application refers to the total quantum circuit, wherein the total number of qubits in the total quantum circuit is the same as the total number of qubits of the quantum program. It can be understood that a quantum program can be composed of a quantum circuit, a measurement operation for the qubits in the quantum circuit, a register for storing the measurement results, and a control flow node (jump instruction), and a quantum circuit can contain tens, hundreds, or even thousands or tensof 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 refers to the time order in which individual quantum logic gates are executed.
[0063] It should be noted that in classical computing, the most basic unit is a bit, and the most basic control mode is a logic gate, which can be combined to achieve the purpose of controlling the circuit. Similarly, the way to handle qubits is quantum logic gates. Using quantum logic gates can make the quantum state evolve, and quantum logic gates are the basis of quantum circuits. Quantum logic gates include single-bit quantum logic gates such as Hadamard gate (H gate), Pauli-X gate (X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, etc., and multi-bit quantum logic gates such as CNOT gate, CR gate, iSWAP gate, Toffoli gate, etc. Quantum logic gates are generally represented by unitary matrices, which are not only matrix forms but also operations and transformations. The action of a general quantum logic gate on a quantum state is calculated by multiplying the left vector of the quantum state by the corresponding matrix of the unitary matrix on the right.
[0064] The logical state of a quantum state, i.e., a quantum bit, is represented in binary in a quantum algorithm (or quantum program), for example, a set of quantum bits q0, q1, q2 represents the 0th, 1st, and 2nd quantum bits, and the order from high to low is q2q1q0. The quantum state corresponding to the set of quantum bits is the superposition of the eigenstates corresponding to the set of quantum bits. The eigenstates corresponding to the set of quantum bits have 2n times the total number of quantum bits, i.e., 8 eigenstates (determined states): |000>, |001>, |010>, |011>, |100>, |101>, |110>, |111>. Each eigenstate corresponds to a bit and a quantum bit, such as |000> state, 000 corresponds to q2q1q0 from high to low, and |> is the Dirac symbol.
[0065] The logical state of a single quantum bit is described as follows: The logical state of a single quantum bit is described as follows: 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 represent the probabilities of |0> and |1> states, respectively. |c| 2 + |d| 2 = 1. In short, the quantum state is a superposition of eigenstates, and when the probability of other eigenstates is 0, it is in a unique eigenstate.
[0066] Nowadays, the idea of distributed computing has penetrated into our lives, and the explanation of "distributed computing" is generally described as a framework for numerical computation that uses processors or computers to solve pending computing tasks. Although these processors or computers are physically separate, they work closely together in a process of distributing work. In addition to high-performance supercomputers or computers used by researchers, small processors and desktop computers used by individuals can also be integrated. In short, distributed computing is a combination of task allocation and coordinated interaction, and its goal is to make task management as efficient as possible and find practical and flexible solutions. In distributed computing, computation begins with a special problem-solving strategy, and each part is handled by a computing unit, and a distributed application running on all processors in a computer network handles operation execution.
[0067] The present application introduces the above-mentioned idea of distributed computing into the use of variational quantum circuits to solve linear systems to calculate the target solution of the linear system, thereby reducing the computation time and optimizing the quantum circuit.
[0068] Referring to Figure 2 , Figure 2This is a flowchart illustrating a method for solving linear systems using variable quantum circuits, as provided in an embodiment of the present invention.
[0069] This embodiment provides an example of a method for solving linear systems using variational quantum circuits. The method is applied to a distributed computing cluster, which includes a master server and multiple distributed processors communicatively connected to the master server, comprising:
[0070] S201: Obtain each sub-quantum circuit formed by cutting the variable quantum circuit, wherein each sub-quantum circuit contains an approximate solution to the linear system to be solved.
[0071] Specifically, the linear system to be solved includes:
[0072] The system of linear equations to be solved is Ax = b, where A is a coefficient matrix and b is a vector. The vector b is encoded to obtain |b>=U b |0>, where S is the number of unitary matrices in the decomposition of coefficient matrix A, and l s Let σ be the coefficient of the linear system to be solved. s U b It is a unitary matrix.
[0073] Before measuring the segmented variable quantum circuit, information about a system of linear equations can be input into the variable quantum circuit. One such equation is a linear combination of S unitary matrices decomposed from matrix A, which facilitates encoding matrix A into the quantum circuit. Here, A can be represented as: Among them, l s Let σ be the coefficient of the linear combination. s The unitary matrix (unitary operator); another piece of information about the linear equation system input to the variable component quantum circuit is the unitary matrix U obtained by encoding the vector b. b unitary matrix U b To prepare a quantum state |b> proportional to the vector b, that is, after normalizing the vector b, encode it into the quantum circuit in the form |b> = U b |0>。 The solution to the linear equation system is expressed using the quantum state trial wave function of the variational hypothesis as:
[0074] It should be noted that the proposed architecture can be a HEA (Hardware Efficient Ansatz), where each layer of the HEA circuit consists of parametric quantum logic gates (e.g., RY quantum logic gates) and CNOT quantum logic gates, with the variational parameter represented by the rotation angle. Vector. It is composed of a connection layer of single quantum rotation and a global entanglement layer. As the number of layers increases, the expression capacity of the circuit is constantly improved, which also increases the difficulty of training the circuit. The number of quantum bits and the number of layers can be determined by the dimension of the linear equation system to be solved. In the case of sufficient computing resources, the solution accuracy can be guaranteed by using a sufficient number of quantum bits and layers of HEA.
[0075] Before obtaining each sub-quantum circuit formed by the variational quantum circuit cutting, the method can comprise:
[0076] Step 1: Construct a variational quantum circuit and obtain a directed graph corresponding to the variational quantum circuit, wherein the vertices of the directed graph are used to represent quantum logic gates in the variational quantum circuit, the edges of the directed graph are used to represent the association relationship between the quantum logic gates, and the direction of the edges of the directed graph is used to represent the time sequence relationship of executing the quantum logic gates.
[0077] Specifically, the vertices of the directed graph are used to represent at least quantum logic gates in the quantum circuit. Since the existence of single quantum logic gates does not affect the number of quantum bits used by the sub-quantum circuit, the single quantum logic gates can be deleted and the position information thereof can be recorded when drawing the directed graph of the quantum circuit. The single quantum logic gates are restored for execution after the cutting position of the sub-quantum circuit is obtained.
[0078] For example, as shown in a schematic diagram of a quantum circuit, Figure 3 as shown in the schematic diagram of the quantum circuit, Figure 3 the vertices of the directed graph include an edge and two points, the edge is used to represent a quantum logic gate, and the two points are used to represent two quantum bits acted on by the quantum logic gate.
[0079] Step 2: Determine the cutting position of the variational quantum circuit according to the directed graph, and cut the variational quantum circuit based on the cutting position.
[0080] Further, the vertices of the sub-directed graph of the directed graph can be determined by pre-configuring the number of vertices of the sub-directed graph, or can be determined by a greedy algorithm, or can be determined according to the computing resources of the computing device.
[0081] For example, the directed graph of the quantum circuit is obtained, the directed graph is more directly visualized than the quantum circuit, and the connection relationship between quantum logic gates in the quantum circuit is shown; secondly, the vertices of the sub-directed graph of the directed graph are determined, and the cutting position of the directed graph is determined based on the vertices of the sub-directed graph, the vertices of the sub-directed graph can be more conveniently and quickly determined by traversing and searching the connection relationship, and then the cutting position of the directed graph is determined by the vertices of the sub-directed graph; finally, the cutting point corresponding to the cutting position on the quantum circuit is determined, and the quantum circuit is cut based on the cutting position, so that the determination of the cutting position in the quantum circuit when the quantum circuit with more quantum bits is cut into a quantum circuit is realized.
[0082] As shown in the formula (1), the probability of the quantum circuit is calculated based on the cutting position of the quantum circuit. Figure 4 Figure 4 A process diagram for cutting a quantum circuit into a sub-quantum circuit is provided for an embodiment of the present application, it should be noted that since the circuit of the variational quantum circuit is relatively complex, the above only takes a simple quantum circuit as an example to explain the cutting process, including the conversion of the quantum circuit to the directed graph, the search for the cutting position, and the reconstruction of the calculation probability based on the cutting circuit, etc.
[0083] According to the circuit cutting theory, at the cutting position of the quantum circuit, if the cutting position is an observation, the measurement basis at this time is M i ∈{I,X,Y,Z},if the cutting position is an initial state, the initial state needs to be initialized to the following four initial states q i ∈{|0>,|1>,|+>,|i>},where |+> and |i> are superposition states, respectively: This is because for any 2X2 matrix A', there is:
[0084]
[0085] Among them, A′1=Tr(A′1I)[|0><0|+|1><1|], A′2=Tr(A′1Z)[|0><0|-|1><1|], A′3=Tr(A′1X)[2|+><+|-|0><0|-|1><1|], A′4=Tr(A′1Y)[2|i><i|-|0> <0|-|1><1|]. The operators in the above equations correspond to the operations performed on the qubit using the corresponding Pauli basis. Simultaneously, the eigenstates in the density matrix correspond to the initial state of the qubit. Since the projection measurement paths of the I and Z gates in the Pauli basis are consistent, only one measurement is needed. The following will provide a simple example of quantum circuit segmentation and a probabilistic reconstruction algorithm. The traditional method for probabilistic reconstruction of segmented quantum circuits involves measuring all qubits of the segmented sub-quantum circuits and reconstructing all results to obtain the computational result of the original quantum circuit. However, for the original quantum circuit described below, this method only requires measuring the computational result of one qubit, without needing to measure the entire circuit. Therefore, a computational method that measures only one qubit is proposed for this situation.
[0086] For example, see Figure 5 , Figure 5 This is a schematic diagram of a primitive quantum circuit provided in an embodiment of the present invention. The diagram shows a three-qubit quantum circuit. The black dots and ⊕ symbols represent CNOT quantum logic gates. The black dots are on the control bits of the CNOT quantum logic gates, and the ⊕ symbols are on the target bits. Measurement of the third qubit in this quantum circuit is required. When... Figure 5 When cutting the quantum circuit shown, the same circuit cutting method described above can be used to cut the quantum circuit into the following shapes: Figure 6 The two sub-quantum circuits (1) and (2) are shown. For the cut sub-quantum circuit (1), the first qubit needs to be measured. During the measurement, projection measurement is performed using the Pauli basis (I,X,Y) respectively. The calculation results of the cut sub-quantum circuit (1) are shown in Table 1:
[0087] Table 1: Calculation results of the segmented sub-quantum circuit (1)
[0088] Measurement base Probability P(0) Probability P(1) I 0.75 0.25 X 0.933013 0.0669873 Y 0.5 0.5
[0089] Meanwhile, for the segmented sub-quantum circuit (2), the first qubit needs to be initialized to |0>,|1>,|+>,|i> respectively before running the quantum circuit and measuring the second qubit. Therefore, the measurement results of the sub-quantum circuit can be obtained as shown in Table 2:
[0090] Table 2: Calculation results of the segmented sub-quantum circuit (2)
[0091] Initial state Probability P(0) Probability P(1) |0> 0.5 0.5 |1> 0.5 0.5 |+> 1.0 0.0 |i> 0.5 0.5
[0092] At this time, the following calculation formula can be used to reconstruct the probability value of the third quantum bit being 0 on the original quantum circuit, i.e.: Figure 5
[0093]
[0094]
[0095]
[0096] Substituting the data in the above table into the formula can obtain P1=(1.5, 0.5, 0.866026, 0) T , P2=(0.5, 0.5, 1, 0) T Therefore:
[0097]
[0098] Since the running result of the original quantum circuit is P(0)=0.933013, it is consistent with the calculation result after cutting.
[0099] It should be noted that the single-cutting-point formula can be extended to a multi-cutting-point formula, and the two-cutting-point example is used, i.e. for any 4X4 matrix:
[0100]
[0101] The above σ i is obtained by expanding the corresponding Pauli basis, and σ4 is used as an example, At this time, P1 has 16 items, i.e.:
[0102]
[0103] Correspondingly, P2 also has 16 items, i.e.:
[0104]
[0105] Finally, the calculation formula of P(0) of the measured quantum bit in the original quantum circuit can be obtained as:
[0106]
[0107] S202: Determine the number of distributed processors to be called according to the number of each sub quantum circuit.
[0108] For example, for the quantum circuit as shown inFigure 5 As shown in the original quantum circuit, the two sub-quantum circuits obtained after cutting generally require 2 distributed processors to be called. For a complex original quantum circuit, the sub-quantum circuits after cutting may have dozens or even hundreds, and the traditional method is very time-consuming in the measurement process and has no advantage. Therefore, the number of distributed processors to be called is determined by the number of sub-quantum circuits, and at this time, the idea of distributed computing can greatly reduce the circuit depth and reduce the calculation time, providing a new idea for calculating complex systems and reducing the difficulty of simulating variational quantum circuits on real quantum chips.
[0109] S203: After receiving the calling request for the distributed processor, load the sub-quantum circuits by using the distributed processor to be called, and measure the sub-quantum circuits by using the distributed processor to be called respectively to obtain measurement results, wherein each distributed processor is used to execute at least one computing task simultaneously, and the computing task corresponds to one sub-quantum circuit after cutting which contains an approximate solution of the linear system to be solved.
[0110] Specifically, loading the sub-quantum circuits and measuring the sub-quantum circuits by using the distributed processor to obtain measurement results can include:
[0111] Input the coefficient matrix A, vector b of the linear system to be solved, and the preset accuracy, measure and calculate the probability reconstruction of the sub-quantum circuits after cutting by using the distributed processor respectively, and the obtained result is used as the value of the loss function.
[0112] After receiving the calling request for the distributed processor to be called, each distributed processor loads at least one sub-quantum circuit after cutting which contains an approximate solution of the linear system to be solved, and measures the sub-quantum circuits by using the distributed processor to obtain measurement results.
[0113] S204: Merge and output the measurement results of each distributed processor to obtain distributed measurement results as an approximate solution of the linear system to be solved.
[0114] Specifically, merging and outputting the measurement results of each distributed processor to obtain distributed measurement results as an approximate solution of the linear system to be solved can include:
[0115] Determine a Hamiltonian constructed in advance, and determine an expected value corresponding to the Hamiltonian according to the measurement results of the distributed processor;
[0116] According to the expected value, an approximate solution of the linear system to be solved is determined.
[0117] Specifically, after the measurement results of each distributed processor are combined and output, the final state To read the quantum state information, a pre-constructed Hamiltonian can be used The final state is measured to obtain the approximate solution of the linear system The key to this process is the pre-constructed Hamiltonian The expected value The value of the loss function is determined as the approximate solution.
[0118] When the value of the loss function tends to 0, at this time is the solution of the linear system, which is converted into a classical vector representation It is worth noting that the quantum state output by the quantum circuit is normalized, because the vector b encoded into the quantum circuit is a normalized quantum state |b>. Assuming that the solution of the equation system obtained by the quantum circuit is the solution of the real linear system satisfies the proportional relationship:
[0119]
[0120] Substituting it into the linear system to be solved can obtain:
[0121]
[0122] By multiplying the left side of the above formula by the transpose of each respectively, we can obtain:
[0123]
[0124] The of the left term in the above formula is equal to the term in the measurement loss function, so by solving the coefficient η, the solution of the linear system can be finally obtained.
[0125] It should be noted that the above steps use a distributed method combined with a variational quantum circuit to solve the approximate solution of the linear system, but the accuracy of the approximate solution is not good enough, and the target solution needs to be further solved using the idea of iteration to improve the calculation accuracy.
[0126] According to the approximate solution, a loss function is constructed, and whether the value of the loss function meets the preset accuracy is determined.
[0127] The loss function is:
[0128]
[0129] The loss function is: is a loss function, the is a variational parameter, the I is a unit matrix, the and the U is a parametric quantum logic gate.
[0130]
[0131] In the partial derivative form of the loss function described above, it can be divided into three terms, that is, the first partial derivative term the second partial derivative term and the third partial derivative term The three terms can be obtained by measuring operations respectively, specifically:
[0132]
[0133]
[0134]
[0135] and since:
[0136]
[0137] In order to meet the measurement needs, the is rewritten in the following form:
[0138]
[0139] wherein, is a unitary matrix.
[0140] It should be noted that the quantum circuit for solving the value of the loss function can be solved by cutting the circuit and combining the method of distributed computing.
[0141] Wherein, it is judged whether the value of the loss function meets the accuracy, specifically:
[0142] According to the approximate solution of the linear system to be solved, the target solution of the linear system to be solved is further obtained, mainly by using the pre-selected Hamiltonian acting on the final quantum state, the approximate solution of the linear system to be solved at the current step can be obtained, and further it is judged whether the value of the loss function meets the accuracy, wherein the accuracy can be set by the user according to the calculation requirement, for example, taking 10 -6 or 0.
[0143] If yes, the approximate solution is taken as the target solution of the linear system to be solved, otherwise, the variational parameters in the variational quantum circuit are updated, the approximate solution of the linear system corresponding to the updated variational parameters is obtained, the step of merging and outputting the measurement results of each distributed processor is continued to be executed, and the obtained distributed measurement results are taken as the approximate solution of the linear system to be solved until the approximate solution satisfying the value of the loss function in accordance with the accuracy is obtained as the target solution of the linear system to be solved.
[0144] Specifically, if the value of the loss function of the current step constructed according to the approximate solution meets the preset accuracy, the obtained approximate solution is exactly the target solution of the linear system to be solved, otherwise, the variational parameters in the variational quantum circuit are updated through an optimization algorithm.
[0145] For example, the variational parameters are updated by using a traditional optimization method, i.e., a gradient descent method, through the following formula
[0146]
[0147] wherein k is an integer not less than 1, β is a learning rate, is the gradient of the loss function with respect to θ.
[0148] Then, the updated variational parameters are transmitted to the cut variational quantum circuit, and the evolution and measurement of the above step are continued to be executed, the approximate solution is updated by iteratively updating the variational parameters, and the loss function is solved until the predicted solution satisfying the value of the loss function in accordance with the accuracy is obtained as the target solution of the linear system to be solved.
[0149] It can be seen that the present application firstly obtains each sub-quantum circuit containing the approximate solution of the linear system to be solved in the cut variational quantum circuit, determines the number of distributed processors to be called according to the number of each sub-quantum circuit, receives the calling request for the distributed processor, loads each sub-quantum circuit by using the distributed processor to be called, and respectively measures each sub-quantum circuit by using the distributed processor to obtain the measurement result, wherein each distributed processor is used to simultaneously execute at least one computing task, and the measurement results of each distributed processor are merged and outputted to obtain the distributed measurement result as the approximate solution of the linear system to be solved, which can provide support for the implementation of the variational quantum circuit for solving the linear system by using the distributed technology, improve the calculation speed and reduce the depth of the quantum circuit, and promote the further development of quantum computing simulation application.
[0150] Referring to Figure 7 , Figure 7 The structure of a device for solving a linear system by using a variational quantum circuit provided by the embodiment of the present application is shown in the figure, and Figure 2The illustrated flow corresponds to the device comprising:
[0151] The acquisition module 701 is configured to acquire each sub quantum circuit formed by cutting the variational quantum circuit, wherein each sub quantum circuit contains an approximate solution of a linear system to be solved.
[0152] The determination module 702 is configured to determine the number of distributed processors to be invoked according to the number of each sub quantum circuit.
[0153] The measurement module 703 is configured to load each sub quantum circuit by using the distributed processors to be invoked after receiving the invocation request for the distributed processors, and measure each sub quantum circuit by using the distributed processors to be invoked respectively to obtain measurement results, wherein each distributed processor is configured to execute at least one computing task simultaneously, and the one computing task corresponds to one sub quantum circuit containing an approximate solution of a linear system to be solved after cutting.
[0154] The output module 704 is configured to merge and output the measurement results of each distributed processor to obtain distributed measurement results as an approximate solution of the linear system to be solved.
[0155] Specifically, the device further comprises:
[0156] The construction module is configured to construct a variational quantum circuit and acquire a directed graph corresponding to the variational quantum circuit, wherein a vertex of the directed graph is configured to represent a quantum logic gate in the variational quantum circuit, an edge of the directed graph is configured to represent an association relationship between the quantum logic gates, and a direction of the edge of the directed graph is configured to represent a time sequence relationship of executing the quantum logic gates.
[0157] The cutting module is configured to determine a cutting position of the variational quantum circuit according to the directed graph, and cut the variational quantum circuit based on the cutting position.
[0158] Specifically, the device further comprises:
[0159] The judgment module is configured to construct a loss function according to the approximate solution, and judge whether a value of the loss function meets a preset accuracy.
[0160] An updating module is configured to, if yes, take the approximate solution as a target solution of the linear system to be solved, or, if no, update a variational parameter in the variational quantum circuit, obtain an approximate solution of the linear system corresponding to the updated variational parameter, continue to perform the step of merging and outputting the measurement results of each distributed processor to obtain a distributed measurement result as the approximate solution of the linear system to be solved, until an approximate solution meeting a value of the loss function in accordance with the preset accuracy is obtained as the target solution of the linear system to be solved.
[0161] Specifically, the measurement module comprises:
[0162] An input unit is configured to input a coefficient matrix A of a linear system to be solved, a vector b, and the preset accuracy, and perform measurement and probability reconstruction on each sub-quantum circuit after cutting through the distributed processor to obtain a result as a value of the loss function.
[0163] Specifically, the output module comprises:
[0164] A first determining unit is configured to determine a Hamiltonian constructed in advance, and determine an expected value corresponding to the Hamiltonian according to the measurement result of the distributed processor.
[0165] A second determining unit is configured to determine an approximate solution of the linear system to be solved according to the expected value.
[0166] Compared with the prior art, the present application first obtains each sub-quantum circuit containing an approximate solution of a linear system to be solved in a cut variational quantum circuit, determines the number of distributed processors to be called according to the number of each sub-quantum circuit, loads each sub-quantum circuit by using the distributed processors to be called after receiving a calling request for the distributed processors, and performs measurement on each sub-quantum circuit by the distributed processors to obtain measurement results, wherein each distributed processor is configured to simultaneously execute at least one computing task, and the measurement results of each distributed processor are merged and output to obtain a distributed measurement result as an approximate solution of the linear system to be solved. The present application can provide support for solving a linear system of a variational quantum circuit by using distributed technology, improve the computing speed and reduce the depth of the quantum circuit, and promote the further development of quantum computing simulation applications.
[0167] The embodiment of the present application further provides a storage medium, wherein the storage medium stores a computer program, and the computer program is set to execute the steps in any one of the method embodiments.
[0168] Specifically, in the embodiment, the storage medium can be set to store a computer program for executing the following steps:
[0169] S201: obtaining each sub quantum circuit formed by variational quantum circuit cutting, wherein the each sub quantum circuit contains an approximate solution of a linear system to be solved;
[0170] S202: determining the number of distributed processors to be called according to the number of each sub quantum circuit;
[0171] S203: after receiving the calling request for the distributed processor, loading the each sub quantum circuit by using the distributed processor to be called, and measuring the each sub quantum circuit by using the distributed processor to be called respectively to obtain a measurement result, wherein each distributed processor is used to execute at least one computing task simultaneously, and the one computing task corresponds to one sub quantum circuit after cutting, which contains an approximate solution of a linear system to be solved;
[0172] S204: merging and outputting the measurement result of each distributed processor to obtain a distributed measurement result as an approximate solution of the linear system to be solved.
[0173] Specifically, in the embodiment, the storage medium can include but is not limited to a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk and various computer program storage media.
[0174] The embodiment of the application further provides an electronic device including 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 execute the steps in any one of the method embodiments.
[0175] Specifically, the electronic device can further include a transmission device and an input and output device, wherein the transmission device is connected with the processor, and the input and output device is connected with the processor.
[0176] Specifically, in the embodiment, the processor can be configured to execute the following steps through the computer program:
[0177] S201: obtaining each sub quantum circuit formed by variational quantum circuit cutting, wherein the each sub quantum circuit contains an approximate solution of a linear system to be solved;
[0178] S202: determining the number of distributed processors to be called according to the number of each sub quantum circuit;
[0179] S203: after receiving the calling request for the distributed processors, loading the respective sub-quantum circuits by using the distributed processors to be called, and measuring the respective sub-quantum circuits by using the distributed processors to be called respectively to obtain measurement results, wherein each distributed processor is configured to execute at least one computing task simultaneously, and the one computing task corresponds to one sub-quantum circuit containing an approximate solution of the linear system to be solved after being cut;
[0180] S204: merging and outputting the measurement results of each distributed processor to obtain distributed measurement results as the approximate solution of the linear system to be solved.
[0181] The above detailed description of the embodiments shown in the drawings explains the structure, features and effects of the present application. The above description is only the preferred embodiments of the present application, but the present application is not limited by the drawings. Any changes or modifications made in accordance with the concept of the present application, or equivalent embodiments with equivalent changes, are still within the scope of the present application.
Claims
1. A method for solving linear systems using variable quantum circuits, characterized in that, Applied to a distributed computing cluster, the distributed computing cluster including a master server and multiple distributed processors communicatively connected to the master server, the method includes: Obtaining sub-quantum circuits formed by cutting variable quantum circuits, wherein each sub-quantum circuit contains an approximate solution to a linear system to be solved, the linear system to be solved comprising: a system of linear equations to be solved. The For the coefficient matrix, the The coefficient matrix is a vector. The vector Encoding , wherein Coefficient matrix The number of unitary matrices in the decomposition, the The coefficients of the linear system to be solved are... , It is a unitary matrix; The number of distributed processors to be invoked is determined based on the number of each sub-quantum circuit. Upon receiving a call request for the distributed processor, the distributed processor to be called loads each sub-quantum circuit and measures each sub-quantum circuit through the distributed processor to be called to obtain measurement results. Each distributed processor is used to execute at least one computational task simultaneously, and each computational task corresponds one-to-one with a sub-quantum circuit containing an approximate solution to the linear system to be solved after being cut. The measurement results of each of the distributed processors are merged and output, and the resulting distributed measurement results are used as an approximate solution to the linear system to be solved. 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 so, the approximate solution is taken as the target solution of the linear system to be solved; otherwise, the variational parameters in the variational quantum circuit are updated, the approximate solution of the linear system corresponding to the updated variational parameters is obtained, and the step of merging and outputting the measurement results of each of the distributed processors and taking the obtained distributed measurement results as the approximate solution of the linear system to be solved is continued until an approximate solution that satisfies the accuracy of the loss function is obtained, which is taken as the target solution of the linear system to be solved.
2. The method according to claim 1, characterized in that, Before obtaining the individual sub-quantum circuits formed by cutting the variable quantum circuit, the method includes: Construct a variable quantum circuit and obtain the directed graph corresponding to the variable quantum circuit. The vertices of the directed graph are used to represent the quantum logic gates in the variable quantum circuit, the edges of the directed graph are used to represent the association between the quantum logic gates, and the direction of the edges of the directed graph is used to represent the timing relationship of executing the quantum logic gates. Based on the directed graph, the cutting position of the variable quantum circuit is determined, and the variable quantum circuit is cut based on the cutting position.
3. The method according to claim 1, characterized in that, The loading of each sub-quantum circuit and the measurement of each sub-quantum circuit by the distributed processor to obtain measurement results include: Input the coefficient matrix of the linear system to be solved ,vector The preset precision is used to measure and calculate the probability reconstruction of each sub-quantum circuit after the segmentation is completed by the distributed processor, and the result is used as the value of the loss function.
4. The method according to claim 3, characterized in that, The step of merging and outputting the measurement results of each of the distributed processors, and using the resulting distributed measurement results as an approximate solution to the linear system to be solved, includes: Determine the pre-constructed Hamiltonian, and determine the expected value corresponding to the Hamiltonian based on the measurement results of the distributed processor; The approximate solution to the linear system to be solved is determined based on the expected value.
5. The method according to claim 1, 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.
6. An apparatus for solving linear systems using variable quantum circuits, applied to a distributed computing cluster, the distributed computing cluster comprising a master server and multiple distributed processors communicatively connected to the master server, characterized in that, The device includes: The acquisition module is used to acquire each sub-quantum circuit formed by cutting a variable quantum circuit, wherein each sub-quantum circuit contains an approximate solution to a linear system to be solved, and the linear system to be solved includes: a system of linear equations to be solved. The For the coefficient matrix, the The coefficient matrix is a vector. The vector Encoding , wherein Coefficient matrix The number of unitary matrices in the decomposition, the The coefficients of the linear system to be solved are... , It is a unitary matrix; The determining module is used to determine the number of distributed processors to be invoked based on the number of each sub-quantum circuit; The measurement module is used to load each sub-quantum circuit using the called distributed processor after receiving a call request for the distributed processor, and to measure each sub-quantum circuit through the called distributed processor to obtain measurement results. Each distributed processor is used to execute at least one computation task at the same time, and each computation task corresponds one-to-one with a sub-quantum circuit containing an approximate solution to the linear system to be solved after being cut. The output module is used to merge and output the measurement results of each of the distributed processors, and the resulting distributed measurement results are used as an approximate solution to the linear system to be solved. The judgment module constructs a loss function based on the approximate solution and determines whether the value of the loss function meets the preset precision. If the update module is correct, the approximate solution is used as the target solution of the linear system to be solved. Otherwise, the variational parameters in the variational quantum circuit are updated, and the approximate solution of the linear system corresponding to the updated variational parameters is obtained. The step of merging and outputting the measurement results of each of the distributed processors and using the resulting distributed measurement results as the approximate solution of the linear system to be solved is continued until an approximate solution that satisfies the accuracy of the loss function is obtained, which is then used as the target solution of the linear system to be solved.
7. 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 5 when it is run.
8. 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 according to any one of claims 1 to 5.
Citation Information
Patent Citations
Computational fluid dynamics simulation method and device based on quantum algorithm, and equipment
CN114091363A
Method and device for processing quantum application problem based on quantum circuit
CN114418105A