Parameter-containing quantum circuit training method and related device

By computing the training set in parallel on multiple real quantum computers and performing random loss operations on quantum logic gates, the problems of slow training speed and overfitting are solved, and efficient quantum line training and generalization capabilities are achieved.

CN119151000AActive Publication Date: 2024-12-17ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411184169.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-17
Estimated Expiration
2044-08-27

AI Technical Summary

Technical Problem

When training large-scale quantum machine learning models, real quantum computers in the prior art run slow and are prone to overfitting problems.

Method used

By splitting the training set into multiple sub-data sets for parallel computing on multiple real quantum computers, and performing random loss operations on the second part of the quantum logic gate to update parameters, parallel training and overfitting based on real quantum computers is realized. prevention.

Benefits of technology

It reduces the model training time, speeds up the execution speed of quantum circuits, reduces the burden on a single quantum computer, and improves the generalization ability of the model, avoiding overfitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119151000A_ABST
    Figure CN119151000A_ABST
Patent Text Reader

Abstract

The invention discloses a parameter-containing quantum circuit training method and a related device. The method comprises the following steps: constructing a parameter-containing quantum circuit; obtaining a training set, splitting data of the training set into a plurality of sub-data sets, and distributing the plurality of sub-data sets to at least two real quantum computers; data values of the sub-data sets are coded to the first part of quantum logic gates to serve as fixed parameters; initializing trainable parameters of the second part of quantum logic gates, wherein loss operation is randomly performed on at least one second part of quantum logic gate; running the parameter-containing quantum circuit to obtain an output quantum state; and judging whether the output quantum state meets a preset requirement, if not, updating the trainable parameters to meet the preset requirement, and obtaining a trained parameter-containing quantum circuit. Compared with the prior art, the method has the advantages that the execution burden of a single quantum computer is relieved, the execution speed of the parameter-containing quantum circuit is increased, and meanwhile, the overfitting phenomenon occurring in the training process is prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of quantum computing technology, and in particular to a training method for parameter-containing quantum circuits and related devices. Background Art

[0002] Training large-scale quantum machine learning models can achieve better results on a variety of tasks, such as improving the accuracy of image classification tasks. However, as the size of the parameters increases, the number of executions of the required quantum circuits increases, and running the relevant implementation on a single real quantum computer may cause the problem of slower running speed, and may also cause overfitting problems during training. Summary of the invention

[0003] The purpose of the present invention is to provide a training method and related device for a parameter-containing quantum circuit to solve the technical problems in the prior art. It can realize parallel computing based on a real quantum computer, reduce the running time of related experiments, and prevent overfitting.

[0004] In a first aspect, the present invention provides a training method for parameter-containing quantum circuits based on multiple real quantum computers, the method comprising:

[0005] Constructing a parameter-containing quantum circuit, wherein the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters;

[0006] Obtaining a training set, determining whether the training set satisfies a splitting condition, and if so, splitting the data of the training set into multiple sub-data sets, and assigning the multiple sub-data sets to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit;

[0007] encoding the data value of the sub-data set into the first part of quantum logic gates as the fixed parameters;

[0008] Initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0;

[0009] Running the parameter-containing quantum circuit to obtain an output quantum state;

[0010] Determine whether the output quantum state meets the preset requirements. If not, update the trainable parameters to meet the preset requirements and obtain the trained parameter-containing quantum circuit.

[0011] In the above-mentioned training method for parameter-containing quantum circuits based on multiple real quantum computers, preferably, the step of judging whether the training set satisfies the splitting condition comprises:

[0012] Determine whether the amount of data in the training set exceeds a preset threshold, wherein the threshold is determined according to the number of quantum bits in the parameter-containing quantum circuit.

[0013] In the above-mentioned training method for parameter-containing quantum circuits based on multiple real quantum computers, preferably, the randomly performing a loss operation on at least one of the second part quantum logic gates comprises:

[0014] Obtaining a first probability, where the first probability is a probability that a certain quantum bit in the parameter-containing quantum circuit is selected;

[0015] Obtaining a second probability, where the second probability is a probability that a second part of the quantum logic gates in the parameter-containing quantum circuit is selected;

[0016] The probability that a certain second-part quantum logic gate acting on a certain quantum bit is selected to perform a loss operation is the product of the first probability and the second probability.

[0017] A training method for parameterized quantum circuits based on multiple real quantum computers as described above, wherein preferably, the first probability and the second probability are both preset values, the first probabilities possessed by different quantum bits are different or the same as each other, and the second probabilities possessed by different second-part quantum logic gates are different or the same as each other.

[0018] In the above-mentioned training method for parameter-containing quantum circuits based on multiple real quantum computers, preferably, the randomly performing a loss operation on at least one of the second part quantum logic gates comprises:

[0019] A random number is generated, where the random number is used to generate a random third probability, where the third probability is a probability that a certain second part quantum logic gate is subjected to a loss operation.

[0020] In the above-mentioned training method for parameter-containing quantum circuits based on multiple real quantum computers, preferably, the randomly performing a loss operation on at least one of the second part quantum logic gates comprises:

[0021] A certain second part of quantum logic gates is designated to perform a fixed loss operation, and the second part of quantum logic gates that are fixed to perform a fixed loss operation are then designated to participate in training.

[0022] In the above-mentioned training method for parameter-containing quantum circuits based on multiple real quantum computers, preferably, the randomly performing a loss operation on at least one of the second part quantum logic gates comprises:

[0023] By combining several possible lists of loss operations, the combination method can be designed using a fixed combination method or by random generation. When using the random generation method, the generated combinations are recorded, and repeated lists are no longer involved in training. Then, training is performed in sequence through grid traversal, and finally the expected combination is output.

[0024] In a second aspect, the present invention provides a training device containing a parameterized subcircuit, comprising:

[0025] A parameter-containing quantum circuit construction module, used to construct a parameter-containing quantum circuit, wherein the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters;

[0026] A splitting module is used to determine whether the training set meets the splitting condition. If so, the data of the training set is split into multiple sub-data sets, and the multiple sub-data sets are assigned to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit;

[0027] An encoding module, used for encoding the data value of the sub-data set into the first part of quantum logic gates as the fixed parameter;

[0028] an initialization module, initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0;

[0029] A computing module, used to run the parameter-containing quantum circuit to obtain an output quantum state;

[0030] The adjustment module is used to determine whether the output quantum state meets the preset requirements. If not, the trainable parameters are updated to meet the preset requirements and obtain the trained parameter-containing quantum circuit.

[0031] In a third aspect, the present invention provides a storage medium storing a computer program, wherein the computer program is configured to implement the aforementioned method when run.

[0032] In a fourth aspect, the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the aforementioned method.

[0033] Compared with the prior art, the present invention reduces the overall training time of the model by splitting the training set into multiple sub-data sets for parallel calculation on multiple real quantum computers, thereby realizing the training of the model under a large data set, reducing the execution burden of a single quantum computer, and speeding up the execution of parameter-containing quantum circuits. At the same time, the overfitting phenomenon that occurs during the training process is prevented by randomly losing the second part of the quantum logic gate in the operation part. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 is a network block diagram of a quantum circuit construction system provided by an embodiment of the present invention;

[0035] Figure 2 is a flow chart of a parameter-containing subcircuit training method provided by an embodiment of the present invention;

[0036] Figure 3 A schematic diagram of a parameter-containing subcircuit provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of the structure of a parameterized subcircuit training device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, but should not be construed as limiting the present invention.

[0039] [Structure of the quantum circuit construction system]

[0040] Figure 1 1 is a network block diagram of a quantum circuit construction system provided in an embodiment of the present application. The quantum circuit construction system may include a network 110, a server 120, a wireless device 130, a client 140, a storage unit 150, a classical processing system 160, a quantum processing system 170, and may also include additional memories, classical processors, quantum processors, and other devices not shown.

[0041] The network 110 is a medium for providing communication links between various devices and computers connected together in the quantum circuit construction system, including but not limited to the Internet, corporate intranet, local area network, mobile communication network and their combination. The connection method can be wired, wireless communication links or optical fiber cables.

[0042] The server 120 and the client 140 are conventional data processing systems that may contain data and applications or software tools that perform conventional computing processes. The client 140 may be a personal computer or a network computer, so the data may also be provided by the server 120. The wireless device 130 may be a smart phone, a tablet, a laptop, a smart wearable device, etc. The storage unit 150 may include a database 151, which may be configured to store data such as quantum bit parameters, quantum logic gate parameters, quantum circuits, quantum programs, etc.

[0043] The classical processing system 160 (quantum processing system 170) may include a classical processor 161 (quantum processor 171) for processing classical data (quantum data) and a memory 163 (memory 172) for storing classical data (quantum data). The classical data (quantum data) may be a boot file, an operating system image, and an application 162 (application 173). The application 162 (application 173) may be used to implement a quantum algorithm compiled according to the quantum circuit construction method provided in an embodiment of the present application.

[0044] Any data or information stored or generated in the classical processing system 160 (quantum processing system 170) can also be configured to be stored or generated in another classical (quantum) processing system in a similar manner, and any application program executed by it can also be configured to be executed in another classical (quantum) processing system in a similar manner.

[0045] It should be noted that a true quantum computer is a hybrid structure, which includes at least Figure 1 There are two major parts in it: the classical processing system 160, which is responsible for performing classical calculations and control; and the quantum processing system 170, which is responsible for running quantum programs and thus realizing quantum calculations.

[0046] The classical processing system 160 and the quantum processing system 170 may be integrated into one device or distributed in two different devices. For example, the first device including the classical processing system 160 runs a classical computer operating system, on which quantum application development tools and services are provided, as well as storage and network services required for quantum applications. Users develop quantum applications through the quantum application development tools and services thereon, and send quantum programs to the second device including the quantum processing system 170 through the network services thereon. The second device runs a quantum computer operating system, parses the code of the quantum program through the quantum computer operating system, and compiles it into instructions that can be recognized and executed by the quantum computer measurement and control system. The quantum processor 170 implements the quantum algorithm corresponding to the quantum program according to the instructions.

[0047] In the classic processing system 160 based on silicon chips, the unit of the classic processor 161 is a CMOS tube. This computing unit is not limited by time and coherence, that is, this computing unit is not limited by the length of use and is available at any time. In addition, in the silicon chip, the number of such computing units is also sufficient. At present, the number of computing units in a classic processor is tens of thousands. The number of computing units is sufficient and the computing logic that can be selected by the CMOS tube is fixed, for example: AND logic. When calculating with the help of CMOS tubes, a large number of CMOS tubes are combined with limited logic functions to achieve the calculation effect.

[0048] Unlike this logic unit in the classical processing system 160, the basic computing unit of the quantum processor 171 in the quantum processing system 170 is a quantum bit, and the input of the quantum bit is limited by coherence and coherence time, that is, the quantum bit is limited by the use time and is not available at any time. Making full use of the quantum bit within the available use time of the quantum bit is a key problem in quantum computing. In addition, the number of quantum bits in a quantum computer is one of the representative indicators of the performance of a quantum computer. Each quantum bit realizes the computing function through the logical function configured on demand. In view of the limited number of quantum bits, the logical functions in the field of quantum computing are diverse, such as: Hadamard gate (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, CR gate, CR gate, iSWAP gate, Toffoli gate, etc. In quantum computing, it is necessary to use limited quantum bits combined with a variety of logical functions to achieve the computing effect.

[0049] Based on these differences, the design of the logical function on the quantum bit (including the design of whether the quantum bit is used and the design of the efficiency of each quantum bit) is the key to improving the computing performance of quantum computers, and requires special design. The above-mentioned design for quantum bits is a technical problem that ordinary computing devices do not need to consider or face.

[0050]

Parameterized subcircuit training method

[0051] Reference Figure 2 As shown, the present invention provides a parameter-containing subcircuit training method, comprising the following steps:

[0052] S101: constructing a parameter-containing quantum circuit, wherein the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters.

[0053] The number of corresponding quantum bits in the parameter-containing quantum circuit can be predetermined and can be determined based on the number of quantum bits supported by the quantum device. It is generally less than or equal to the number of quantum bits supported. When the number of quantum bits supported by the quantum device is relatively large, the number of quantum bits required for preparation can be selected depending on the situation.

[0054] In the embodiment provided by the present invention, the parameter-containing quantum circuit includes a quantum state encoding unit, an evolution unit and a measurement unit. The quantum state encoding unit is used to encode data into the corresponding quantum bit; the evolution unit is used to associate the quantum state information of the quantum bit and evolve to obtain the output quantum state; the measurement unit is used to perform measurement operations on the quantum bit.

[0055] In a feasible implementation, the quantum logic gates in the quantum state encoding unit are set as the first part of quantum logic gates, and the quantum logic gates in the evolution unit are set as the second part of quantum logic gates.

[0056] Step S102: Obtain a training set, and determine whether the training set meets the splitting condition. If so, split the data of the training set into multiple sub-data sets, and distribute the multiple sub-data sets to at least two real quantum computers. Each real quantum computer runs the same parameter-containing quantum circuit. The real quantum computer has a quantum chip. The quantum bits in the quantum chip are used to constitute the parameter-containing quantum circuit. By splitting the training set into multiple sub-data sets and distributing them to multiple real quantum computers for parallel computing, the multiple real quantum computers do not interfere with each other, that is, there is no shared quantum bit resource between the two, and the parallel computing of multiple sub-data sets is realized, which can reduce the execution burden of a single real quantum computer, speed up the execution of the circuit, and reduce the overall training time of the model, thereby realizing the training of the model under a large data set. The number of real quantum computers is set to n. The original time required for training a training set is T, and now the time required for running is reduced to T / n.

[0057] In one feasible implementation, the number of real quantum computers participating in parallel computing is equal to the number of sub-datasets, and each real quantum computer is assigned a sub-dataset, so as to achieve maximum resource utilization and high execution efficiency. In another feasible implementation, the number of real quantum computers participating in parallel computing is less than the number of sub-datasets, and the sub-datasets can be allocated according to the number of real quantum computers according to the preset grouping processing rules. The sub-datasets can be divided into multiple groups, and each real quantum computer is assigned a group of sub-datasets. The number of sub-datasets in different groups of sub-datasets can be the same or different, and is not limited here. For example, if the number of real quantum computers participating in parallel computing is two, the sub-datasets are divided into two groups. When the number of sub-datasets is an even number, the number of sub-datasets in the two groups of sub-datasets is the same. When the number of sub-datasets is an odd number, the number of sub-datasets in one group of sub-datasets is one more than the number of sub-datasets in the other group of sub-datasets.

[0058] In the embodiment provided by the present invention, the condition for splitting the training set is to determine whether the amount of data in the training set exceeds a preset threshold, wherein the threshold is determined according to the number of quantum bits in the parameter-containing quantum circuit. When the amount of data in the training set exceeds the number of quantum bits in the parameter-containing quantum circuit, the data in the training set is split according to the splitting rule into multiple sub-data sets. If the amount of data in the training set does not exceed the number of quantum bits in the parameter-containing quantum circuit, the training set can be trained on a single real quantum computer without splitting.

[0059] Preferably, the maximum threshold value can be set to the number of qubits of the quantum chip of the real quantum computer, so that the hardware resources of the real quantum computer can be fully utilized to improve the operation efficiency. The quantum computing task to be executed is split according to the ratio between the number of data in the training set and the number of qubits in the quantum chip. The number of sub-data sets obtained is directly related to the ratio. When the ratio is an integer, the number of sub-data sets obtained by splitting is the ratio number, and the number of data in each sub-data set is equal to the number of qubits; when the ratio is a non-integer, that is, the ratio has an integer part and a decimal part, then the number of sub-data sets obtained by splitting is the integer part of the ratio plus 1. At this time, only one sub-data set has less data than the number of qubits in the quantum chip, and the number of data in the remaining sub-data sets is equal to the number of qubits in the quantum chip. Splitting the training set based on this splitting rule can make the real quantum computer have the maximum resource utilization and high execution efficiency.

[0060] It should be noted that the splitting rules can also be set according to actual application requirements, and are not specifically limited here. It is sufficient to ensure that each sub-data set formed by splitting the training set based on the preset splitting rules can be successfully executed by the quantum circuit.

[0061] In addition, a label can be added to each sub-dataset so that each sub-dataset has a unique label code, and all sub-datasets can be combined according to the label code to form a training set, thereby facilitating the distinction of each sub-dataset and facilitating the grouping of each sub-dataset according to the preset processing rules.

[0062] For example, each sub-dataset in the sub-dataset group belonging to the same real quantum computer is labeled in a sequentially numbered manner, and the label code of each sub-dataset can be a sequential number. Then, all sub-datasets can be trained in sequence according to the order of the sequential numbers.

[0063] In practical applications, the setting of the grouping processing rules for the sub-data sets needs to be compatible with the compilation rules of the label codes, and as long as it can be ensured that the overall result of the compilation processing of each sub-data set according to the processing rules set based on the label codes is consistent with the result of the compilation processing of the quantum computing tasks to be executed before the segmentation, therefore, in the embodiments of the present application, the setting of the grouping processing rules and the label codes is not specifically limited, and can be set according to the actual application needs. For example, each sub-data set can be trained and processed in sequence based on the order of the label codes.

[0064] Furthermore, in order to facilitate accurate identification of multiple real quantum computers, a unique ID can be assigned to each real quantum computer, and multiple sub-data sets of the sub-data set group within the real quantum computer all use the ID of the real quantum computer. The ID can be set according to actual application needs and is not specifically limited here.

[0065] Step S103: Encode the data value of the sub-data set into the first part of the quantum logic gate as a fixed parameter.

[0066] In the embodiment provided by the present invention, a coding unit is used to establish a connection between the data of a sub-data set and a parameter-containing quantum circuit, and the data of the sub-data set is used as a fixed parameter of the first part of the quantum logic gate to perform angle coding or amplitude coding, so that the quantum circuit contains relevant information of the data.

[0067] In a feasible implementation, the encoding unit includes a plurality of first quantum rotating gate units, each of which corresponds to a quantum bit. Optionally, each data of the sub-data set is used as a rotation control parameter of the corresponding first quantum rotating gate unit. The rotation control parameter is a fixed parameter and does not participate in training and the loss operation mentioned later.

[0068] The first quantum rotating gate unit is a single-qubit rotating gate, including one or more of an RX gate, an RY gate, and an RZ gate. After the first quantum rotating gate unit is operated, only the amplitude of the quantum state changes.

[0069] In a feasible implementation mode, referring to Figure 3 As shown, the first quantum rotation gate unit includes an RZ gate, an RX gate and an RZ gate arranged in sequence along the action sequence, and the rotation control parameters of the RX gate and the RZ gate are adjusted separately according to the data of the sub-data set.

[0070] Step S104: Initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0.

[0071] The second part of quantum logic gates is located in the evolution unit. In the embodiment provided by the present invention, a combination of rotation and entanglement gates are applied to the quantum bits after encoding to obtain the output quantum state.

[0072] In a feasible implementation, the evolution unit includes CR gates and second quantum rotation gate units arranged in sequence along the action sequence, each CR gate and each second quantum rotation gate unit corresponds to a quantum bit, and except for the CR gate acting on the lowest-order quantum bit, the control bit of the CR gate is the low-order quantum bit adjacent to the quantum bit being acted on, and the control bit of the CR gate of the lowest-order quantum bit is the highest-order quantum bit.

[0073] The second quantum rotating gate unit is a single-qubit rotating gate. The second quantum rotating gate unit includes one or more of the RX gate, the RY gate and the RZ gate. After performing the single-qubit rotating gate operation, only the amplitude of the quantum state changes. The CR gate is used to construct the entanglement relationship between the quantum bits to form multi-qubit entanglement.

[0074] The rotation control parameters of the second quantum rotary gate unit are not fixed in advance, they need to be updated during the training optimization process, and the rotation control parameters of the second quantum rotary gate unit are based on the following: first initialize a set of parameters (i.e., trainable parameters), then build a quantum circuit according to the initialization angle, use the evolution unit to evolve the output quantum state, use the measurement unit to perform measurement operations on the output quantum state, and consider the expected value of each quantum bit through the measurement based on the calculation. If the expectation is not met, update the rotation parameters of the second quantum rotary gate unit.

[0075] In the embodiment provided by the present invention, in order to prevent overfitting in the training of a real quantum computer, during the parameter initialization step, a loss operation is randomly performed on at least one second part of the quantum logic gates, and the trainable parameters of the second part of the quantum logic gates after the loss operation are set to 0. Setting the trainable parameters to 0 is equivalent to calculating a unit matrix during calculation, which is equivalent to the second part of the quantum logic gate not working, which helps to reduce the fluctuation of model parameters, thereby reducing the overfitting phenomenon in the training of a real quantum computer, allowing the state of the quantum bit to change randomly during the training process, which can increase the diversity of data, avoid excessive dependence of the model on specific parameters, and increase the generalization ability of the model.

[0076] In a first feasible implementation manner, in step S104, randomly performing a loss operation on at least one second part of quantum logic gates includes:

[0077] A first probability is obtained, where the first probability is the probability that a certain quantum bit in the parameter-containing quantum circuit is selected; a second probability is obtained, where the second probability is the probability that a certain second-part quantum logic gate in the parameter-containing quantum circuit is selected; and the first probability is multiplied by the second probability to obtain the probability that a certain second-part quantum logic gate acting on a certain quantum bit is selected for a loss operation.

[0078] The first probability and the second probability are both preset values ​​set manually. The first probability and the second probability are equivalent to hyperparameters, which are parameters input manually and can be adjusted manually according to the final experimental results. The first probabilities of different quantum bits may be different or the same, and the second probabilities of different second-part quantum logic gates may be different or the same.

[0079] Take the example of a parameter-containing quantum circuit with four quantum bits, where the first probabilities of different quantum bits are different from each other, and the second probabilities of different second-part quantum logic gates are the same as each other:

[0080] For example, if the first probabilities on the four quantum bits are [0.2, 0.3, 0.1, 0.2], and the second probability of the second part of the quantum logic gate is set to 0.5, then the probability of the second part of the quantum logic gate on different quantum bits performing loss operations is [0.1, 0.15, 0.05, 0.1].

[0081] Take the example of a parameter-containing quantum circuit with four quantum bits, where the first probabilities of different quantum bits are different from each other, and the second probabilities of different second-part quantum logic gates are also different from each other:

[0082] If the first probabilities on the four quantum bits are as follows [0.2, 0.3, 0.1, 0.2], and the second probability of a second part of the quantum logic gate on different quantum bits is [0.5, 0.3, 0.1, 0.2], then the probability of a second part of the quantum logic gate on different quantum bits performing a loss operation is [0.1, 0.09, 0.01, 0.04].

[0083] In a second feasible implementation, in step S104, a loss operation is randomly performed on at least one second-part quantum logic gate, including: generating a random number, the random number is used to generate a random third probability, the third probability is the probability that a second-part quantum logic gate is subjected to a loss operation, after the test is completed, the results are screened according to set indicators, and finally the third probability corresponding to the result that best meets the set indicators is selected to participate in the real quantum computer training.

[0084] In a third feasible implementation, in step S104, randomly performing a loss operation on at least one second part quantum logic gate includes: specifying a second part quantum logic gate to be fixedly subjected to a loss operation, and then the second part quantum logic gate that is fixedly subjected to the loss operation participates in the training.

[0085] In a fourth feasible implementation, a loss operation is randomly performed on at least one second part quantum logic gate, including: by combining several possible lists for performing the loss operation, the combination method can be designed using a fixed combination method, or it can be performed by a random generation method. When using the random generation method, the generated combination is recorded, and repeated lists are no longer involved in training. Then, training is performed in sequence by grid traversal, and finally the expected combination method is output.

[0086] Step S105: Run the parameter-containing quantum circuit to obtain the output quantum state.

[0087] Step S106: Determine whether the output quantum state meets the preset requirements, wherein a measurement unit is used to perform a measurement operation on the output quantum state, and the expected value of each quantum bit is considered through measurement based on calculation. If the expectation is not met, the trainable parameters are updated. In updating the trainable parameters, the loss operation is also randomly performed on each second part quantum logic gate again to meet the preset requirements until the expected value meets the expectation, and a trained parameter-containing quantum circuit is obtained. After training, the average of the updated trainable parameters on each real quantum computer is taken as the parameters for forwarding on all real quantum computers in a new round.

[0088] In a feasible implementation, the parameter-containing quantum circuit is applied to the training process of the deep neural network model, and the parameter-containing quantum circuit is judged whether it has been trained based on the loss function. When the loss function meets the calculation termination condition, the trained parameter-containing quantum circuit will be obtained.

[0089] Preferably, it is possible to determine whether the value of the loss function is less than or equal to the ground state energy obtained by classical calculation, or to determine whether the difference between the current loss function value and the previously obtained loss function value meets a preset accuracy, or other methods are possible.

[0090] Taking the example of judging whether the difference between the current loss function value and the previously obtained loss function value meets the preset accuracy, first judge whether the difference between the current loss function value and the previous loss function value is within the preset range; if not, execute the update of the trainable parameters and re-perform the evolution process of the parameter-containing quantum circuit. As the parameter-containing quantum circuit is trained, the value of the loss function will become smaller and smaller, that is, the difference between the current loss function value and the previous loss function value will also become smaller and smaller, until the value of the loss function approaches the ground state energy. The difference between the current loss function value and the previous loss function value is within the preset range, indicating that the value of the loss function is approximately equal to the ground state energy, and the parameter-containing quantum circuit is now trained. The preset range mentioned here can be determined by the accuracy that the training wants to achieve.

[0091] [Structure of parameter-containing subcircuit training device]

[0092] See also Figure 4 As shown, the parameter-containing subcircuit training device includes:

[0093] A parameterized quantum circuit construction module is used to construct a parameterized quantum circuit, wherein the parameterized quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters.

[0094] The splitting module is used to determine whether the training set meets the splitting conditions. If so, the data of the training set is split into multiple sub-data sets, and the multiple sub-data sets are assigned to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit.

[0095] The encoding module is used to encode the data value of the sub-data set into the first part of the quantum logic gate as a fixed parameter.

[0096] An initialization module is used to initialize the trainable parameters of the second part of the quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of the quantum logic gates, and the trainable parameters of the second part of the quantum logic gates after the loss operation are set to 0.

[0097] The computing module is used to run the parameter-containing quantum circuit to obtain the output quantum state.

[0098] The adjustment module is used to determine whether the output quantum state meets the preset requirements. If not, the trainable parameters are updated to meet the preset requirements and obtain a trained parameter-containing quantum circuit.

[0099]

Storage medium structure

[0100] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to implement the steps of any of the above method embodiments when running.

[0101] Specifically, in this embodiment, the above storage medium may be configured to store a computer program for implementing the following steps:

[0102] Step S101: construct a parameter-containing quantum circuit, the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters.

[0103] Step S102: Obtain a training set and determine whether the training set meets the splitting condition. If so, split the data of the training set into multiple sub-data sets, and distribute the multiple sub-data sets to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit.

[0104] Step S103: Encode the data value of the sub-data set into the first part of the quantum logic gate as a fixed parameter.

[0105] Step S104: Initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0.

[0106] Step S105: Run the parameter-containing quantum circuit to obtain the output quantum state.

[0107] Step S106: determine whether the output quantum state meets the preset requirements. If not, update the trainable parameters to meet the preset requirements and obtain a trained parameter-containing quantum circuit.

[0108]

Structure of electronic devices

[0109] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to implement the steps in any one of the above method embodiments.

[0110] Specifically, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0111] Specifically, in this embodiment, the processor may be configured to implement the following steps through a computer program:

[0112] Step S101: construct a parameter-containing quantum circuit, the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters.

[0113] Step S102: Obtain a training set and determine whether the training set meets the splitting condition. If so, split the data of the training set into multiple sub-data sets, and distribute the multiple sub-data sets to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit.

[0114] Step S103: Encode the data value of the sub-data set into the first part of the quantum logic gate as a fixed parameter.

[0115] Step S104: Initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0.

[0116] Step S105: Run the parameter-containing quantum circuit to obtain the output quantum state.

[0117] Step S106: determine whether the output quantum state meets the preset requirements. If not, update the trainable parameters to meet the preset requirements and obtain a trained parameter-containing quantum circuit.

[0118] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the drawings. Any changes made according to the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the protection scope of the present invention.

Claims

1. A training method for parameterized quantum circuits based on multiple real quantum computers, Features: The method comprises: Constructing a parameter-containing quantum circuit, wherein the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters; Obtaining a training set, determining whether the training set satisfies a splitting condition, and if so, splitting the data of the training set into multiple sub-data sets, and assigning the multiple sub-data sets to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit; encoding the data value of the sub-data set into the first part of quantum logic gates as the fixed parameters; Initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0; Running the parameter-containing quantum circuit to obtain an output quantum state; Determine whether the output quantum state meets the preset requirements. If not, update the trainable parameters to meet the preset requirements and obtain the trained parameter-containing quantum circuit.

2. The method according to claim 1, Features: The determining whether the training set satisfies the splitting condition comprises: Determine whether the amount of data in the training set exceeds a preset threshold, wherein the threshold is determined according to the number of quantum bits in the parameter-containing quantum circuit.

3. The method according to claim 1, Features: The randomly performing a loss operation on at least one of the second part of quantum logic gates comprises: Obtaining a first probability, where the first probability is a probability that a certain quantum bit in the parameter-containing quantum circuit is selected; Obtaining a second probability, where the second probability is a probability that a second part of the quantum logic gates in the parameter-containing quantum circuit is selected; The probability that a certain second-part quantum logic gate acting on a certain quantum bit is selected to perform a loss operation is the product of the first probability and the second probability.

4. The method according to claim 3, Features: The first probability and the second probability are both preset values, the first probabilities possessed by different quantum bits may be different from or the same as each other, and the second probabilities possessed by different second-part quantum logic gates may be different from or the same as each other.

5. The method according to claim 1, Features: The randomly performing a loss operation on at least one of the second part of quantum logic gates comprises: A random number is generated, where the random number is used to generate a random third probability, where the third probability is a probability that a certain second part quantum logic gate is subjected to a loss operation.

6. The method according to claim 1, Features: The randomly performing a loss operation on at least one of the second part of quantum logic gates comprises: A certain second part of quantum logic gates is designated to perform a fixed loss operation, and the second part of quantum logic gates that are fixed to perform a fixed loss operation are then designated to participate in training.

7. The method according to claim 1, Features: The randomly performing a loss operation on at least one of the second part of quantum logic gates comprises: By combining several possible lists of loss operations, the combination method can be designed using a fixed combination method or by random generation. When using the random generation method, the generated combinations are recorded, and repeated lists are no longer involved in training. Then, training is performed in sequence through grid traversal, and finally the expected combination is output.

8. A training device containing a parameterized subcircuit, It is characterized in that include: A parameter-containing quantum circuit construction module, used to construct a parameter-containing quantum circuit, wherein the parameter-containing quantum circuit includes a plurality of first-part quantum logic gates and a plurality of second-part quantum logic gates, wherein the parameters of the first-part quantum logic gates are fixed parameters, and the parameters of the second-part quantum logic gates are trainable parameters; A splitting module is used to determine whether the training set meets the splitting condition. If so, the data of the training set is split into multiple sub-data sets, and the multiple sub-data sets are assigned to at least two real quantum computers, each of which runs the same parameter-containing quantum circuit; An encoding module, used for encoding the data value of the sub-data set into the first part of quantum logic gates as the fixed parameter; an initialization module, initializing the trainable parameters of the second part of quantum logic gates, wherein a loss operation is randomly performed on at least one of the second part of quantum logic gates, and the trainable parameters of the second part of quantum logic gates after the loss operation are set to 0; A computing module, used to run the parameter-containing quantum circuit to obtain an output quantum state; The adjustment module is used to determine whether the output quantum state meets the preset requirements. If not, the trainable parameters are updated to meet the preset requirements and obtain the trained parameter-containing quantum circuit.

9. A storage medium, It is characterized in that The storage medium stores a computer program, wherein the computer program is configured to implement the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, It is characterized in that A computer program is stored in the memory, and the processor is configured to run the computer program to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Quantum neural network

    CN110692067A

  • Method and device for constructing quantum logic gate, computer storage medium and terminal

    CN113283606A

  • Data classification method based on machine learning framework and related equipment

    CN114358317A

  • Method for estimating real output of quantum circuit based on quantum support vector machine

    CN114943341A

  • Data prediction method based on quantum recurrent neural network and related equipment

    CN116167407A