Method for creating machine learning model with noise, machine learning framework and related device
A hybrid quantum-classical framework for creating noise-inclusive machine learning models addresses computational errors in quantum virtual machines, ensuring simulation accuracy and model portability by isolating noise adjustments to the quantum layer.
Patent Information
- Application Number
- CN202111680566.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-12-30
AI Technical Summary
How to create a noise-containing machine learning model so that the results simulated on a quantum virtual machine are closer to the results calculated on a real quantum computer, and solve the inevitable calculation error problem when the quantum machine learning model is run.
Create quantum programs that consider the influence of noise by creating a quantum program based on the quantum computing programming library within the machine learning framework, encapsulate the interface of the noisy quantum computing layer, and call classic modules to create a machine learning model of the noisy quantum computing layer, which is applied to a machine learning framework including quantum modules and classic modules.
The results simulated on the quantum virtual machine are realized to be closer to the calculation results of the real quantum computer, and the model is easy to transplant and copy, improving ease of use.
Smart Images

Figure CN116415685B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of quantum computing, and particularly relates to a method for creating a noisy machine learning model, a machine learning framework, and related devices. Background Art
[0002] Classical machine learning, especially deep learning, has revolutionized many subfields of artificial intelligence and achieved great success. In recent years, with the advent of the information age, deep learning has developed rapidly. The rapid growth of electronic data volume has led to a large increase in the training data of deep learning models. At the same time, the rapid development of the computing power of electronic computers, especially the emergence of a series of new electronic computing devices represented by graphics processing units (GPUs), has made the large-scale training of deep learning models a reality. Therefore, deep learning has far exceeded the previous traditional algorithms and has been widely applied in many fields. The performance of deep learning in fields such as digital image classification, handwritten character recognition, and video analysis has reached or exceeded that of humans.
[0003] With the rapid development of quantum computing, based on quantum mechanics, quantum machine learning that combines quantum computing with classical machine learning has also begun to develop rapidly. Quantum machine learning utilizes the efficiency of quantum computers far exceeding that of classical computers and combines with the rapidly developing machine learning algorithms in the big data era to further improve the processing ability of big data.
[0004] However, due to the physical characteristics of qubits themselves, when a quantum machine learning model runs on a real quantum computer, there are inevitable computational errors. Therefore, when a quantum machine learning model runs on a quantum virtual machine, noise needs to be added to make the obtained results closer to the results calculated on a real quantum computer. Then how to create a noisy machine learning model is a technical problem that needs to be solved. Summary of the Invention
[0005] The object of the present invention is to provide a method for creating a noisy machine learning model, a machine learning model framework, and related devices, aiming to create a noisy machine learning model so that the results simulated by the machine learning model on a quantum virtual machine are closer to the results calculated on a real quantum computer.
[0006] An embodiment of the present invention provides a method for creating a noisy machine learning model, which is applied to an electronic device including a quantum module and a classical module in a machine learning framework. The quantum module includes a noisy quantum program encapsulation unit. The method includes:
[0007] Create a quantum program considering the influence of noise based on the quantum computing programming library included in the machine learning framework;
[0008] Use the quantum program as a parameter of the encapsulated noisy quantum computing layer interface and pass it into the noisy quantum computing layer interface;
[0009] Call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and call the classical module to create a machine learning model including the noisy quantum computing layer.
[0010] Optionally, creating a quantum program considering noise effects based on the quantum computing programming library included in the machine learning framework includes:
[0011] Apply for a noisy quantum virtual machine based on the quantum computing programming library included in the machine learning framework and set the noise of the quantum circuit running on the noisy virtual machine;
[0012] Apply for qubits and create quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine;
[0013] Package the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering noise effects.
[0014] Optionally, the noise includes at least one of the following: logic gate noise, quantum state reset noise of qubits, measurement noise of qubits, read noise of qubits.
[0015] Optionally, the noise is logic gate noise, and setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0016] Use the specified quantum logic gate type, noise model type, and parameters required for the noise model type as parameters of the logic gate noise interface and pass them into the logic gate noise interface;
[0017] Set the logic gate noise of the quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on all qubits in the quantum circuit.
[0018] Optionally, the noise is logic gate noise, and setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0019] Use the specified qubit, quantum logic gate type, noise model type, and parameters required for the noise model type as parameters of the logic gate noise interface and pass them into the logic gate noise interface;
[0020] Set the logical gate noise of the quantum circuit running on the noisy virtual machine through the logical gate noise interface, and the logical gate noise takes effect on the specified qubits in the quantum circuit.
[0021] Optionally, the noise is the quantum state reset noise of the qubit. The setting of the noise of the quantum circuit running on the noisy virtual machine includes:
[0022] Take the probabilities of resetting the quantum state of the qubits in the quantum circuit to |0> and resetting to |1> as the parameters of the reset noise interface, and pass them into the reset noise interface;
[0023] Set the quantum state reset noise of the qubits of the quantum circuit running on the noisy virtual machine through the reset noise interface.
[0024] Optionally, the noise is the measurement noise of the qubit. The setting of the noise of the quantum circuit running on the noisy virtual machine includes:
[0025] Take the specified noise model type and the parameters required by the noise model type as the parameters of the measurement noise interface, and pass them into the measurement noise interface;
[0026] Set the measurement noise of the qubits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
[0027] Optionally, the noise is the read noise of the qubit. The setting of the noise of the quantum circuit running on the noisy virtual machine includes:
[0028] Take the probability that |0> is read as |0> and the probability of being read as |1>, the probability that |1> is read as |0> and the probability of being read as |1> as the parameters of the read noise interface, and pass them into the read noise interface;
[0029] Set the read noise of the qubits of the quantum circuit running on the noisy virtual machine through the read noise interface.
[0030] Another embodiment of the present invention provides a device for creating a noisy machine learning model, which is applied to an electronic device including a machine learning framework of a quantum module and a classical module. The quantum module includes a noisy quantum program encapsulation unit. The device includes:
[0031] A program creation unit for creating a quantum program considering the influence of noise based on the quantum computing programming library included in the machine learning framework;
[0032] An interface determination unit, configured to use the quantum program as a parameter of a noisy quantum computing layer interface encapsulated, and input it into the noisy quantum computing layer interface;
[0033] A creation unit, configured to call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and call the classical module to create a machine learning model including the noisy quantum computing layer.
[0034] Optionally, in terms of creating a quantum program considering noise effects based on a quantum computing programming library included in the machine learning framework, the program creation unit is specifically configured to:
[0035] Apply for a noisy quantum virtual machine based on a quantum computing programming library included in the machine learning framework, and set the noise of a quantum circuit running on the noisy virtual machine;
[0036] Apply for quantum bits and create quantum logic gates acting on the quantum bits to obtain a quantum circuit running on the noisy virtual machine;
[0037] Encapsulate the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering noise effects.
[0038] Optionally, the noise includes at least one of the following: logic gate noise, quantum state reset noise of quantum bits, measurement noise of quantum bits, and read noise of quantum bits.
[0039] Optionally, the noise is logic gate noise. In terms of setting the noise of a quantum circuit running on the noisy virtual machine, the program creation unit is specifically configured to:
[0040] Use the specified quantum logic gate type, noise model type, and parameters required by the noise model type as parameters of a logic gate noise interface, and input them into the logic gate noise interface;
[0041] Set the logic gate noise of a quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on all quantum bits in the quantum circuit.
[0042] Optionally, the noise is logic gate noise. In terms of setting the noise of a quantum circuit running on the noisy virtual machine, the program creation unit is specifically configured to:
[0043] Use the specified quantum bit, quantum logic gate type, noise model type, and parameters required by the noise model type as parameters of a logic gate noise interface, and input them into the logic gate noise interface;
[0044] Set the logical gate noise of the quantum circuit running on the noisy virtual machine through the logical gate noise interface, and the logical gate noise takes effect on the specified qubits in the quantum circuit.
[0045] Optionally, when the noise is the quantum state reset noise of a qubit, in terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit is specifically configured to:
[0046] Use the probabilities of resetting the quantum state of the qubits in the quantum circuit to |0> and resetting to |1> as the parameters of the reset noise interface, and pass them into the reset noise interface;
[0047] Set the quantum state reset noise of the qubits of the quantum circuit running on the noisy virtual machine through the reset noise interface.
[0048] Optionally, when the noise is the measurement noise of a qubit, in terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit is specifically configured to:
[0049] Use the specified noise model type and the parameters required by the noise model type as the parameters of the measurement noise interface, and pass them into the measurement noise interface;
[0050] Set the measurement noise of the qubits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
[0051] Optionally, when the noise is the read noise of a qubit, in terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit is specifically configured to:
[0052] Use the probabilities that |0> is read as |0> and read as |1>, and the probabilities that |1> is read as |0> and read as |1> as the parameters of the read noise interface, and pass them into the read noise interface;
[0053] Set the read noise of the qubits of the quantum circuit running on the noisy virtual machine through the read noise interface.
[0054] Another embodiment of the present invention provides a machine learning framework, which includes a quantum module and a classical module. The quantum module includes a noisy quantum program encapsulation unit configured to create a noisy quantum computing layer through an encapsulated noisy quantum computing layer interface. The noisy quantum computing layer interface is used to provide a quantum program that takes into account the influence of noise created based on the quantum computing programming library included in the machine learning framework. The classical module is configured to create a machine learning model including the noisy quantum computing layer.
[0055] Another embodiment of the present invention provides a storage medium, in which a computer program is stored, and the computer program is configured to execute the method described in any one of the above when running.
[0056] Another embodiment of the present invention provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the method described in any one of the above.
[0057] Compared with the prior art, the present invention creates a quantum program considering noise effects by using a quantum computing programming library included in a machine learning framework; then uses the quantum program as a parameter of an encapsulated noisy quantum computing layer interface and passes it into the noisy quantum computing layer interface; finally, calls a noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and calls a classical module to create a machine learning model including the noisy quantum computing layer. By calling the noisy quantum program encapsulation unit, the present invention realizes the creation of a noisy machine learning model. Since this machine learning model contains noise, the results simulated on a quantum virtual machine are closer to the results calculated on a real quantum computer; in addition, by creating a noisy quantum computing layer through this noisy quantum computing layer interface, when simulating different real quantum computers, it is only necessary to change the parameter of this noisy quantum computing layer interface - the quantum program considering noise effects, without changing other parts of the machine learning model, making this noisy machine learning model easy to transplant and replicate, and further improving the usability of this noisy machine learning model. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a hardware structure block diagram of a computer terminal for a method of creating a noisy machine learning model provided by an embodiment of the present invention;
[0059] Figure 2 It is a schematic flowchart of a method of creating a noisy machine learning model provided by an embodiment of the present invention;
[0060] Figure 3 It is a schematic structural diagram of a device for creating a noisy machine learning model provided by an embodiment of the present invention;
[0061] Figure 4 It is a schematic structural diagram of a machine learning framework provided by an embodiment of the present invention;
[0062] Figure 5 It is a schematic structural diagram of another machine learning framework provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0063] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0064] The embodiments of the present invention first provide a method for creating a machine learning model with noise, which can be applied to electronic devices, such as computer terminals, specifically, ordinary computers, quantum computers, etc.
[0065] The following takes the operation on a computer terminal as an example to describe it in detail. Figure 1 It is a hardware structure block diagram of a computer terminal for a method of creating a machine learning model with noise provided by an embodiment of the present invention. As Figure 1 shown, the computer terminal may include one or more ( Figure 1 only one is shown in Figure 1 figures) processors 102 (the processors 102 may include, but are not limited to, processing devices such as microprocessor MCUs or programmable logic devices FPGAs) and a memory 104 for storing the method of creating a machine learning model with noise. Optionally, the above computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only illustrative and does not limit the structure of the above computer terminal. For example, the computer terminal may further include more or fewer components than Figure 1 shown in
[0066] The memory 104 can be used to store software programs and modules of application software, such as program instructions / modules corresponding to the method of creating a machine learning model with noise in the embodiments of the present invention. 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 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories may be connected to the computer terminal through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0067] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned 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.
[0068] It should be noted that a real quantum computer has a hybrid structure, which includes two major parts: one is a classical computer, responsible for performing classical calculations and controls; the other is a quantum device, responsible for running quantum programs to achieve quantum computing. A quantum program is a series of instruction sequences written in a quantum language such as the QRunes language that can run on a quantum computer, which supports operations on quantum logic gates and ultimately realizes quantum computing. Specifically, a quantum program is a series of instruction sequences that operate on quantum logic gates in a certain time sequence.
[0069] In practical applications, due to the limitation of the development of quantum device hardware, quantum computing simulation is usually required to verify quantum algorithms, quantum applications, etc. Quantum computing simulation is a process of simulating the operation of a quantum program corresponding to a specific problem by means of a virtual architecture (i.e., a quantum virtual machine) built with the resources of a general-purpose computer. Usually, a quantum program corresponding to a specific problem needs to be constructed. The quantum program referred to in the embodiments of the present invention is a program written in a classical language that represents qubits and their evolution, where qubits, quantum logic gates, etc. related to quantum computing are all represented by corresponding classical codes.
[0070] As an embodiment of a quantum program, a quantum circuit, also known as a quantum logic circuit, is the most commonly used general quantum computing model, which represents a circuit for operating on qubits under an abstract concept. Its components include qubits, a circuit (timeline), and various quantum logic gates. Finally, the result often needs to be read out through a quantum measurement operation.
[0071] Different from a traditional circuit that is connected by metal wires to transmit voltage signals or current signals, in a quantum circuit, the circuit can be regarded as being connected by time, that is, the state of a qubit evolves naturally over time. During this process, according to the instructions of the Hamiltonian operator, it is not until it encounters a logic gate that it is operated on.
[0072] A quantum program as a whole corresponds to a total quantum circuit. The quantum program in the present invention refers to this total quantum circuit. Among them, 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 on the qubits in the quantum circuit, a register for storing measurement results, and a control flow node (jump instruction). A quantum circuit can include dozens, hundreds, or even thousands of quantum logic gate operations. The execution process of a quantum program is a 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.
[0073] 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. The purpose of controlling a circuit can be achieved through the combination of logic gates. Similarly, the way to process qubits is a quantum logic gate. Using quantum logic gates can evolve quantum states. Quantum logic gates are the basis for constructing quantum circuits. Quantum logic gates include single-bit quantum logic gates, such as Hadamard gate (H gate, Hadamard gate), Pauli-X gate (X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, etc.; 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, and unitary matrices are not only in matrix form but also a kind of operation and transformation. Generally, the action of a quantum logic gate on a quantum state is calculated by left multiplying the matrix corresponding to the quantum state right vector by the unitary matrix.
[0074] See Figure 2 , Figure 2 is a schematic flowchart of a method for creating a noisy machine learning model provided by an embodiment of the present invention, which is applied to an electronic device including a machine learning framework with a quantum module and a classical module. The quantum module includes a noisy quantum program encapsulation unit. The method includes:
[0075] Step 201: Create a quantum program considering the influence of noise based on the quantum computing programming library included in the machine learning framework;
[0076] Step 202: Use the quantum program as a parameter of the encapsulated noisy quantum computing layer interface and pass it into the noisy quantum computing layer interface;
[0077] Step 203: Call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface;
[0078] Step 204: Call the classical module to create a machine learning model including the noisy quantum computing layer.
[0079] Among them, the quantum computing programming libraries included in the machine learning framework can be, for example, Qpanda, Qsikit, Cirq, Forest, Q#, qbsolv, Blackbird, etc., which are not limited here.
[0080] Among them, quantum computing is a new computing mode that controls quantum information units according to the laws of quantum mechanics for computing. By leveraging two quantum phenomena called superposition and entanglement, it can process multiple states of information simultaneously. The quantum computing layer is a program module containing quantum circuits, which can be used to implement the quantum computing corresponding to the quantum circuits. By encapsulating the quantum circuits according to certain standards, the quantum computing layer is convenient for use when creating and training machine learning models. For the part of the machine learning model implemented by quantum computing, it can all be understood as the corresponding quantum computing layer.
[0081] Among them, classical computing is a traditional computing mode that controls classical information units according to the laws of classical physics for computing. It works through a binary system, that is, information is stored using 1 or 0 and does not understand anything other than 0 or 1. The classical computing layer corresponds to the quantum computing layer, and it can be encapsulating the created classical computing programs according to certain standards, making the classical computing layer convenient for use when creating and training machine learning models.
[0082] Among them, an interface is a declaration of a series of methods and a collection of some method characteristics. An interface only has the characteristics of methods without the implementation of methods. Therefore, these methods can be implemented by different classes in different places, and these implementations can have different behaviors. The interface of the noisy quantum computing layer is the declaration of a series of methods corresponding to the noisy quantum computing layer. The specific form can be, for example, NoiseQuantumLayer(). The interface of the noisy quantum computing layer is used to provide a quantum program considering the influence of noise created based on the quantum computing programming libraries included in the machine learning framework; the other interfaces mentioned below can also refer to the explanation here and will not be elaborated.
[0083] Specifically, the machine learning framework further includes a data structure module. The calling of the classical module to create a machine learning model including the noisy quantum computing layer includes:
[0084] Calling the classical module to construct the classical computing layer and calling the data structure module to construct the forward propagation relationship between the classical computing layer and the noisy quantum computing layer;
[0085] Calling the classical module to encapsulate the classical computing layer, the noisy quantum computing layer, and the forward propagation relationship between the classical computing layer and the noisy quantum computing layer to obtain a machine learning model.
[0086] Among them, the forward propagation is to use the output of the previous calculation layer as the input of the next calculation layer and calculate the output of the next calculation layer until there is no next calculation layer. The calculation layer can be the above-mentioned classical calculation layer or the above-mentioned quantum calculation layer.
[0087] Furthermore, the classical module further includes an abstract class sub-module. Invoking the classical module encapsulates the classical calculation layer, the noisy quantum calculation layer, and the forward propagation relationship between the classical calculation layer and the noisy quantum calculation layer to obtain a machine learning model, including:
[0088] Invoking the abstract class sub-module to initialize and encapsulate the noisy quantum calculation layer and the classical calculation layer based on the initialization function to obtain the initialized and encapsulated noisy quantum calculation layer and classical calculation layer;
[0089] Invoking the abstract class sub-module to encapsulate the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship;
[0090] Invoking the abstract class sub-module to encapsulate the initialized and encapsulated noisy quantum calculation layer and classical calculation layer, and the encapsulated forward propagation relationship based on the module class to obtain a machine learning model.
[0091] Among them, the initialization function is _init_(), and the forward propagation function is forward().
[0092] Based on the initialization function to initialize and encapsulate the noisy quantum calculation layer and the classical calculation layer to obtain the initialized and encapsulated noisy quantum calculation layer and classical calculation layer, it can be as follows:
[0093] def _init_(self):
[0094] super(Net, self)._init_()
[0095] self.conv1 = Conv2D(a)
[0096] self.maxpool = Maxpool2D(b)
[0097] self.conv2 = Conv2D(c)
[0098] self.maxpool2 = Maxpool2D(d)
[0099] self.fc1 = Linear(e)
[0100] self.fc2 = Linear(f)
[0101] self.hybrid = NoiseQuantumLayer(g)
[0102] self.fc3 = Linear(h)
[0103] Encapsulate the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship, then it can be as follows:
[0104] def forward(self, x):
[0105] x = self.conv1(x)
[0106] x = self.maxpool1(x)
[0107] x = self.conv2(x)
[0108] x = maxpool2(x)
[0109] x = self.fc1(x)
[0110] x = self.fc2(x)
[0111] x = self.hybrid(x)
[0112] x = self.fc3(x)
[0113] return x
[0114] Encapsulate the initialized and encapsulated noisy quantum computing layer and classical computing layer, as well as the encapsulated forward propagation relationship based on the module class to obtain a machine learning model, then it can be as follows:
[0115] class Net(Module):
[0116] def _init_(self):
[0117] super(Net, self)._init_()
[0118] self.conv1 = Conv2D(a)
[0119] self.maxpool = Maxpool2D(b)
[0120] self.conv2 = Conv2D(c)
[0121] self.maxpool2 = Maxpool2D(d)
[0122] self.fc1 = Linear(e)
[0123] self.fc2 = Linear(f)
[0124] self.hybrid = NoiseQuantumLayer(g)
[0125] self.fc3 = Linear(h)
[0126] def forward(self, x):
[0127] x = self.conv1(x)
[0128] x = self.maxpool1(x)
[0129] x = self.conv2(x)
[0130] x = maxpool2(x)
[0131] x = self.fc1(x)
[0132] x = self.fc2(x)
[0133] x = self.hybrid(x)
[0134] x = self.fc3(x)
[0135] return x
[0136] Compared with the prior art, the present invention creates a quantum program considering the influence of noise by means of a quantum computing programming library included in a machine learning framework; then takes the quantum program as a parameter of an encapsulated noisy quantum computing layer interface and passes it into the noisy quantum computing layer interface; finally, calls a noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and calls a classical module to create a machine learning model including the noisy quantum computing layer. By calling the noisy quantum program encapsulation unit, the present invention realizes the creation of a noisy machine learning model. Since this machine learning model contains noise, the results simulated on a quantum virtual machine are closer to the results calculated on a real quantum computer; in addition, by creating a noisy quantum computing layer through this noisy quantum computing layer interface, when different real quantum computers are simulated, it is only necessary to change the parameter of this noisy quantum computing layer interface - the quantum program considering the influence of noise, without changing other parts of the machine learning model, making this noisy machine learning model easy to transplant and replicate, and further improving the usability of this noisy machine learning model.
[0137] In an embodiment provided by the present invention, creating a quantum program considering noise effects based on the quantum computing programming library included in the machine learning framework includes:
[0138] Applying for a noisy quantum virtual machine based on the quantum computing programming library included in the machine learning framework, and setting the noise of the quantum circuit running on the noisy virtual machine;
[0139] Applying for qubits and creating quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine;
[0140] Encapsulating the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering noise effects.
[0141] Among them, the noise includes at least one of the following: logic gate noise, quantum state reset noise of qubits, measurement noise of qubits, read noise of qubits.
[0142] Among them, the noise model types of logic gate noise at least include the following: relaxation process noise model of qubits, dephasing process noise model of qubits, decoherence noise model, depolarizing noise model, bit flip noise model, bit phase flip noise model, phase damping noise model.
[0143] In the quantum computing programming library included in the machine learning framework, the relaxation process noise model of qubits can be represented by DAMPING_KRAUS_OPERATOR, the dephasing process noise model of qubits can be represented by DEPHASING_KRAUS_OPERATOR, the decoherence noise model can be represented by DECOHERENCE_KRAUS_OPERATOR, the depolarizing noise model can be represented by DEPOLARIZING_KRAUS_OPERATOR, the bit flip noise model can be represented by BITFLIP_KRAUS_OPERATOR, the bit phase flip noise model can be represented by BIT_PHASE_FLIP_OPRATOR, and the phase damping noise model can be represented by PHASE_DAMPING_OPRATOR.
[0144] Among them, the kraus operator and representation method of the relaxation process noise model of qubits are as follows:
[0145]
[0146] Among them, the kraus operator and representation method of the dephasing process noise model of qubits are as follows:
[0147]
[0148] Among them, the decoherence noise model is a combination of the above two noise models, and their relationship is as follows:
[0149]
[0150] K1 = K 1damping K 1dephasing , K2 = K 1damping K 2dephasing
[0151] K3 = K 2damping K 1dephasing , K4 = K 2damping K 2dephasing
[0152] Among them, the Kraus operators and representation methods of the depolarizing noise model are as follows:
[0153]
[0154]
[0155] Among them, the Kraus operators and representation methods of the bit-flip noise model are as follows:
[0156]
[0157] Among them, the Kraus operators and representation methods of the bit-phase-flip noise model are as follows:
[0158]
[0159] Among them, the Kraus operators and representation methods of the phase-damping noise model are as follows:
[0160]
[0161] In the above various noise model types, K1, K2, K3, and K4 are Kraus operators, p is the parameter required for this noise model type, and X, Y, Z, and I are the matrices corresponding to their quantum logic gates.
[0162] Specifically, the application for a noisy quantum virtual machine can be implemented through NoiseQVM qvm. After applying for a noisy quantum virtual machine, it can also be initialized, and the initialization can be achieved through the initialization function qvm.init(). Setting the noise of the quantum circuit running on the noisy virtual machine can be realized through the interface set_moise_model(). Applying for qubits can be achieved through the interface qvm.qAllocMany(). If needed, classical bits can also be applied through the interface qvm.cAllocMany(). Finally, encapsulating the noisy quantum virtual machine, the noise model, and the quantum circuit can be achieved through the function main(). The above specific method is one of them, and it can also be implemented through other functions, interfaces, and classes, which will not be exemplified here.
[0163] In an embodiment provided by the present invention, the noise is gate noise. Setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0164] Taking the specified quantum gate type, noise model type, and the parameters required for the noise model type as the parameters of the gate noise interface, and passing them into the gate noise interface;
[0165] Setting the gate noise of the quantum circuit running on the noisy virtual machine through the gate noise interface, and the gate noise takes effect on all qubits in the quantum circuit.
[0166] In an embodiment provided by the present invention, the noise is gate noise. Setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0167] Taking the specified qubit, quantum gate type, noise model type, and the parameters required for the noise model type as the parameters of the gate noise interface, and passing them into the gate noise interface;
[0168] Setting the gate noise of the quantum circuit running on the noisy virtual machine through the gate noise interface, and the gate noise takes effect on the specified qubits in the quantum circuit.
[0169] Among them, the specified quantum gate type can be, for example, the H gate, X gate, Y gate, RX gate, etc. The noise model type is such as the relaxation process noise model of the qubit, the dephasing process noise model of the qubit, the decoherence noise model, the depolarization noise model, the bit flip noise model, the bit phase flip noise model, the phase damping noise model, etc. The parameters required for the noise model type are p or other parameters.
[0170] Among them, the logical gate noise interface can be, for example, qvm.set_noise_model(); for example, qvm.set_noise_model(NoiseModel.BITFLIP_KRAUS_OPERATOR, GateType.PAULI_X_GATE, 0.1) only specifies that the quantum logical gate type is the Pauli X gate, the noise model type is the bit flip noise model, and the parameter p required for the noise model type is 0.1. The quantum bit is not specified, so the logical gate noise takes effect on all quantum bits in the quantum circuit. For example, qvm.set_noise_model(NoiseModel.BITFLIP_KRAUS_OPERATOR, GateType.PAULI_X_GATE, 0.1, [q[0], q[1]]) specifies that the quantum logical gate type is the Pauli X gate, the noise model type is the bit flip noise model, the parameter p required for the noise model type is 0.1, and also specifies the quantum bits q[0] and q[1]. Then the logical gate noise only takes effect on q[0] and q[1] in the quantum circuit.
[0171] In an embodiment provided by the present invention, the noise is the measurement noise of a quantum bit. The method for setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0172] Taking the specified noise model type and the parameters required for the noise model type as the parameters of the measurement noise interface, and passing them into the measurement noise interface;
[0173] Setting the measurement noise of the quantum bits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
[0174] It should be noted that the measurement noise setting method is similar to the above-mentioned logical gate noise setting method, except that the quantum logical gate type does not need to be specified, and its measurement noise interface can be qvm.set_measure_error().
[0175] In an embodiment provided by the present invention, the noise is the quantum state reset noise of a quantum bit. The method for setting the noise of the quantum circuit running on the noisy virtual machine includes:
[0176] Taking the probability of resetting the quantum state of the quantum bits in the quantum circuit to |0> and the probability of resetting to |1> as the parameters of the reset noise interface, and passing them into the reset noise interface;
[0177] Setting the quantum state reset noise of the quantum bits of the quantum circuit running on the noisy virtual machine through the reset noise interface.
[0178] For example, there is the following code:
[0179] p0 = 0.9
[0180] p1 = 0.05
[0181] qvm.set_reset_error(p0, p1)
[0182] It means that the probability p0 of resetting the quantum state of the qubit in the quantum circuit to |0> and the probability p1 of resetting it to |1> are set to 0.9 and 0.05 respectively. The probabilities of not being reset to |0> and being reset to |1> are 1 - p0 - p1 = 0.05. Then, p0 and p1 are passed as parameters of the reset noise interface qvm.set_reset_error() into this interface. Through the reset noise interface qvm.set_reset_error(p0, p1), the reset noise of the quantum state of the qubit in the quantum circuit running on the noisy virtual machine can be set.
[0183] In an embodiment provided by the present invention, the noise is the readout noise of the qubit. The setting of the noise of the quantum circuit running on the noisy virtual machine includes:
[0184] Taking the probability of |0> being read as |0> and the probability of being read as |1>, and the probability of |1> being read as |0> and the probability of being read as |1> as the parameters of the readout noise interface, and passing them into the readout noise interface;
[0185] Setting the readout noise of the qubit in the quantum circuit running on the noisy virtual machine through the readout noise interface.
[0186] For example, there is the following code:
[0187] double f0 = 0.9
[0188] double f1 = 0.85
[0189] qvm.set_readout_error([[f0, 1 - f0], [1 - f1, f1]], [q[0]])
[0190] It is stated that the probability f0 of reading |0> as |0> and the probability 1 - f0 of reading it as |1> are set to 0.9 and 0.1 respectively; the probability f1 of reading |1> as |0> and the probability 1 - f1 of reading it as |1> are set to 0.85 and 0.15 respectively. Then, f0, 1 - f0, f1, and 1 - f1 are passed as parameters to the readout noise interface set_readout_error(). By using this readout noise interface qvm.set_readout_error([[f0,1 - f0],[1 - f1,f1]],[q[0]]), the readout noise of the qubits in the quantum circuit running on this noisy virtual machine can be set.
[0191] See Figure 3 , Figure 3 FIG. is a schematic structural diagram of a noisy machine learning model creation device provided by an embodiment of the present invention, which is applied to an electronic device including a quantum module and a classical module in a machine learning framework. The quantum module includes a noisy quantum program encapsulation unit. The device 30 includes:
[0192] A program creation unit 301, configured to create a quantum program considering noise effects based on a quantum computing programming library included in the machine learning framework;
[0193] An interface determination unit 302, configured to use the quantum program as a parameter of an encapsulated noisy quantum computing layer interface and pass it into the noisy quantum computing layer interface;
[0194] A creation unit 303, configured to call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and call the classical module to create a machine learning model including the noisy quantum computing layer.
[0195] Optionally, in terms of creating a quantum program considering noise effects based on the quantum computing programming library included in the machine learning framework, the program creation unit 301 is specifically configured to:
[0196] Apply for a noisy quantum virtual machine based on the quantum computing programming library included in the machine learning framework, and set the noise of the quantum circuit running on the noisy virtual machine;
[0197] Apply for qubits and create quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine;
[0198] Encapsulate the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering noise effects.
[0199] Optionally, the noise includes at least one of the following: logic gate noise, quantum state reset noise of qubits, measurement noise of qubits, and readout noise of qubits.
[0200] Optionally, the noise is logic gate noise. In terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit 301 is specifically configured to:
[0201] Use the specified quantum logic gate type, noise model type, and parameters required for the noise model type as the parameters of the logic gate noise interface, and pass them into the logic gate noise interface;
[0202] Set the logic gate noise of the quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on all qubits in the quantum circuit.
[0203] Optionally, the noise is logic gate noise. In terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit 301 is specifically configured to:
[0204] Use the specified qubit, quantum logic gate type, noise model type, and parameters required for the noise model type as the parameters of the logic gate noise interface, and pass them into the logic gate noise interface;
[0205] Set the logic gate noise of the quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on the specified qubits in the quantum circuit.
[0206] Optionally, when the noise is the quantum state reset noise of qubits, in terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit 301 is specifically configured to:
[0207] Use the probabilities of resetting the quantum state of the qubits in the quantum circuit to |0> and resetting to |1> as the parameters of the reset noise interface, and pass them into the reset noise interface;
[0208] Set the quantum state reset noise of the qubits in the quantum circuit running on the noisy virtual machine through the reset noise interface.
[0209] Optionally, when the noise is the measurement noise of qubits, in terms of setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit 301 is specifically configured to:
[0210] Use the specified noise model type and the parameters required for the noise model type as the parameters of the measurement noise interface, and pass them into the measurement noise interface;
[0211] Set the measurement noise of the qubits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
[0212] Optionally, in terms of the noise being the readout noise of the qubits and setting the noise of the quantum circuit running on the noisy virtual machine, the program creation unit 301 is specifically configured to:
[0213] Take the probability that |0> is read as |0> and the probability that it is read as |1>, the probability that |1> is read as |0>, and the probability that it is read as |1> as the parameters of the readout noise interface, and pass them into the readout noise interface;
[0214] Set the readout noise of the qubits of the quantum circuit running on the noisy virtual machine through the readout noise interface.
[0215] Compared with the prior art, the present invention creates a quantum program considering the influence of noise through a quantum computing programming library included in a machine learning framework; then takes the quantum program as the parameter of a noisy quantum computing layer interface that has been encapsulated, and passes it into the noisy quantum computing layer interface; finally, calls the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and calls the classical module to create a machine learning model including the noisy quantum computing layer. The present invention realizes the creation of a noisy machine learning model by calling the noisy quantum program encapsulation unit. Since this machine learning model contains noise, the results simulated on the quantum virtual machine are closer to the results calculated on a real quantum computer; in addition, by creating a noisy quantum computing layer through this noisy quantum computing layer interface, when simulating different real quantum computers, it is only necessary to change the parameter of this noisy quantum computing layer interface - the quantum program considering the influence of noise, without changing other parts of the machine learning model, making this noisy machine learning model easy to transplant and replicate, and further improving the usability of this noisy machine learning model.
[0216] See Figure 4 , Figure 4 As shown in the structural schematic diagram of a machine learning framework provided by an embodiment of the present invention, the machine learning framework 40 includes a quantum module 410 and a classical module 420. The quantum module 410 includes a noisy quantum program encapsulation unit 401, which is configured to create a noisy quantum computing layer through a noisy quantum computing layer interface that has been encapsulated. The noisy quantum computing layer interface is used to provide a quantum program considering the influence of noise created based on the quantum computing programming library included in the machine learning framework; the classical module 420 is configured to create a machine learning model including the noisy quantum computing layer.
[0217] Optionally, seeFigure 5 , Figure 5 It is a schematic structural diagram of another machine learning framework provided by an embodiment of the present invention. The machine learning framework 40 further includes a quantum computing programming library 430, which is configured to apply for a noisy quantum virtual machine and set the noise of a quantum circuit running on the noisy virtual machine;
[0218] Apply for qubits and create quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine;
[0219] Package the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering the influence of noise.
[0220] Optionally, the noise includes at least one of the following: logic gate noise, quantum state reset noise of qubits, measurement noise of qubits, and read noise of qubits.
[0221] Optionally, the noise is logic gate noise. The quantum computing programming library 430 is configured to use the specified quantum logic gate type, noise model type, and parameters required for the noise model type as the parameters of the logic gate noise interface and pass them into the logic gate noise interface;
[0222] Set the logic gate noise of the quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on all qubits in the quantum circuit.
[0223] Optionally, the noise is logic gate noise. The quantum computing programming library 430 is configured to use the specified qubit, quantum logic gate type, noise model type, and parameters required for the noise model type as the parameters of the logic gate noise interface and pass them into the logic gate noise interface;
[0224] Set the logic gate noise of the quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on the specified qubits in the quantum circuit.
[0225] Optionally, the noise is the quantum state reset noise of qubits. The quantum computing programming library 430 is configured to use the probability of resetting the quantum state of the qubits in the quantum circuit to |0> and the probability of resetting to |1> as the parameters of the reset noise interface and pass them into the reset noise interface;
[0226] Set the quantum state reset noise of the qubits of the quantum circuit running on the noisy virtual machine through the reset noise interface.
[0227] Optionally, the noise is the measurement noise of qubits, and the quantum computing programming library 430 is configured to use the specified noise model type and the parameters required by the noise model type as the parameters of the measurement noise interface and input them into the measurement noise interface;
[0228] Set the measurement noise of the qubits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
[0229] An embodiment of the present invention also provides a storage medium in which a computer program is stored. Specifically, the computer program is set to execute the steps in the method embodiment in any one of the above when running.
[0230] Specifically, in this embodiment, the above storage medium can be set to store a computer program for performing the following steps:
[0231] Create a quantum program considering the influence of noise based on the quantum computing programming library included in the machine learning framework;
[0232] Use the quantum program as the parameter of the encapsulated noisy quantum computing layer interface and input it into the noisy quantum computing layer interface;
[0233] Call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and call the classical module to create a machine learning model including the noisy quantum computing layer.
[0234] Specifically, in this embodiment, the above storage medium may include, but is not limited to, various media that can store computer programs such as USB flash drives, read-only memories (ROM), random access memories (RAM), mobile hard disks, magnetic disks, or optical discs.
[0235] Another embodiment of the present invention also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is set to run the computer program to execute the steps in the method embodiment in any one of the above.
[0236] Specifically, the above electronic device may further include a transmission device and an input / output device. The transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0237] Specifically, in this embodiment, the above processor can be set to execute the following steps through a computer program:
[0238] Create a quantum program considering the influence of noise based on the quantum computing programming library included in the machine learning framework;
[0239] Use the quantum program as a parameter of the encapsulated noisy quantum computing layer interface and pass it into the noisy quantum computing layer interface;
[0240] Call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and call the classical module to create a machine learning model including the noisy quantum computing layer.
[0241] The structure, features and effects of the present invention have been described in detail based on the embodiments shown in the drawings. The above are only the preferred embodiments 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 equivalent embodiments modified into equivalent changes, should still be within the protection scope of the present invention as long as they do not exceed the spirit covered by the description and the drawings.
Claims
1. A method for creating a machine learning model with noise, characterized in that, An electronic device applied to a machine learning framework including a quantum module and a classical module, the quantum module including a noisy quantum program encapsulation unit, the method including: Creating a quantum program considering noise effects based on a quantum computing programming library included in the machine learning framework; Using the quantum program as a parameter of an encapsulated noisy quantum computing layer interface and passing it into the noisy quantum computing layer interface; Invoking the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and invoking the classical module to create a machine learning model including the noisy quantum computing layer; Wherein, creating a quantum program considering noise effects based on a quantum computing programming library included in the machine learning framework includes: Applying for a noisy quantum virtual machine based on a quantum computing programming library included in the machine learning framework and setting the noise of a quantum circuit running on the noisy virtual machine; Applying for qubits and creating quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine; Encapsulating the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering noise effects.
2. The method according to claim 1, wherein The noise includes at least one of the following: logic gate noise, quantum state reset noise of qubits, measurement noise of qubits, read noise of qubits.
3. The method according to claim 2, wherein When the noise is logic gate noise, setting the noise of a quantum circuit running on the noisy virtual machine includes: Using the specified quantum logic gate type, noise model type, and parameters required for the noise model type as parameters of a logic gate noise interface and passing them into the logic gate noise interface; Setting the logic gate noise of a quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on all qubits in the quantum circuit.
4. The method according to claim 2, wherein When the noise is logic gate noise, setting the noise of a quantum circuit running on the noisy virtual machine includes: Using the specified qubit, quantum logic gate type, noise model type, and parameters required for the noise model type as parameters of a logic gate noise interface and passing them into the logic gate noise interface; Setting the logic gate noise of a quantum circuit running on the noisy virtual machine through the logic gate noise interface, and the logic gate noise takes effect on the specified qubits in the quantum circuit.
5. The method according to claim 2, wherein When the noise is quantum state reset noise of qubits, setting the noise of a quantum circuit running on the noisy virtual machine includes: Using the probability of resetting the quantum state of qubits in the quantum circuit to |0> and the probability of resetting to |1> as parameters of a reset noise interface and passing them into the reset noise interface; Setting the quantum state reset noise of qubits in a quantum circuit running on the noisy virtual machine through the reset noise interface.
6. The method according to claim 2, wherein When the noise is measurement noise of qubits, setting the noise of a quantum circuit running on the noisy virtual machine includes: Use the specified noise model type and the parameters required by the noise model type as the parameters of the measurement noise interface, and input them into the measurement noise interface; Set the measurement noise of the qubits of the quantum circuit running on the noisy virtual machine through the measurement noise interface.
7. The method according to claim 2, characterized in that The noise is the readout noise of the qubits. Setting the noise of the quantum circuit running on the noisy virtual machine includes: Use the probability that |0> is read as |0> and the probability that it is read as |1>, and the probability that |1> is read as |0> and the probability that it is read as |1> as the parameters of the readout noise interface, and input them into the readout noise interface; Set the readout noise of the qubits of the quantum circuit running on the noisy virtual machine through the readout noise interface.
8. A machine learning framework, characterized in that, The machine learning framework includes a quantum module and a classical module. The quantum module includes a noisy quantum program encapsulation unit configured to create a noisy quantum computing layer through the encapsulated noisy quantum computing layer interface. The noisy quantum computing layer interface is used to provide a quantum program that takes into account the influence of noise created based on the quantum computing programming library included in the machine learning framework. The classical module is configured to create a machine learning model including the noisy quantum computing layer. Among them, creating a quantum program that takes into account the influence of noise based on the quantum computing programming library included in the machine learning framework includes: Apply for a noisy quantum virtual machine based on the quantum computing programming library included in the machine learning framework, and set the noise of the quantum circuit running on the noisy virtual machine; Apply for qubits and create quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine; Package the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program that takes into account the influence of noise.
9. A device for creating a machine learning model with noise, characterized in that, An electronic device applied to a machine learning framework including a quantum module and a classical module. The quantum module includes a noisy quantum program encapsulation unit. The device includes: A program creation unit for creating a quantum program that takes into account the influence of noise based on the quantum computing programming library included in the machine learning framework. Among them, creating a quantum program that takes into account the influence of noise based on the quantum computing programming library included in the machine learning framework includes: applying for a noisy quantum virtual machine based on the quantum computing programming library included in the machine learning framework, and setting the noise of the quantum circuit running on the noisy virtual machine; applying for qubits and creating quantum logic gates acting on the qubits to obtain a quantum circuit running on the noisy virtual machine; packaging the noisy quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program that takes into account the influence of noise; An interface determination unit for using the quantum program as the parameter of the encapsulated noisy quantum computing layer interface and inputting it into the noisy quantum computing layer interface; A creation unit for calling the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and calling the classical module to create a machine learning model including the noisy quantum computing layer.
10. A storage medium, characterized in that, A computer program is stored in the storage medium, wherein the computer program is configured to execute the method described in any one of claims 1 to 7 when running.
11. 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 execute the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Quantum state preparation method and device
CN112232513A
Bias correction in deep learning systems
US20200311525A1