A training method for a parametric quantum circuit and related apparatuses
By employing parallel computation on multiple real quantum computers and random loss operations, the problems of slow training speed and overfitting are solved, achieving more efficient quantum circuit training.
Patent Information
- Application Number
- CN202411184169.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-08-27
AI Technical Summary
Training large-scale quantum machine learning models on a single real quantum computer is slow and prone to overfitting.
The training set is split into multiple subsets and computed in parallel on multiple real quantum computers, and overfitting is prevented by randomly dropping parameters of the second part of the quantum logic gates in the operation section.
It reduces model training time, improves execution speed, and prevents overfitting.
Smart Images

Figure CN119151000B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum computing technology, and in particular to a training method and related apparatus for a parametric quantum circuit. Background Technology
[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. However, as the parameter scale increases, the number of times the required quantum circuits are executed also increases. Running the relevant implementation on a single real quantum computer may result in slow execution speed and may also lead to overfitting during training. Summary of the Invention
[0003] The purpose of this invention is to provide a training method and related apparatus for parametric quantum circuits to solve the technical problems in the prior art. It can realize parallel computing based on real quantum computers, reduce the running time of related experiments, and prevent overfitting.
[0004] In a first aspect, the present invention provides a training method for parametric quantum circuits based on multiple real quantum computers, the method comprising:
[0005] Construct a parametric quantum circuit, which includes multiple first-part quantum logic gates and multiple 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.
[0006] Obtain the training set, determine whether the training set meets the splitting condition, and if so, split the data of the training set into multiple subsets, and assign the multiple subsets to at least two real quantum computers, with each real quantum computer running the same parametric quantum circuit.
[0007] The data values of the sub-dataset are encoded onto the first part of the quantum logic gates as the fixed parameters;
[0008] Initialize the trainable parameters of the second part of the quantum logic gate, wherein at least one of the second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0;
[0009] Run the parametric quantum circuit to obtain the 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 parameterized quantum circuit.
[0011] The training method for parametric quantum circuits based on multiple real quantum computers, as described above, preferably includes determining whether the training set satisfies the splitting condition, comprising:
[0012] Determine whether the number of data in the training set exceeds a preset threshold, wherein the threshold is determined based on the number of qubits in the parametric quantum circuit.
[0013] The training method for parametric quantum circuits based on multiple real quantum computers, as described above, preferably includes the random loss operation on at least one of the second part quantum logic gates, comprising:
[0014] Obtain a first probability, which is the probability that a certain qubit in the parametric quantum circuit is selected;
[0015] Obtain a second probability, which is the probability that a certain second part of the quantum logic gate in the parametric quantum circuit is selected;
[0016] The probability that a certain second part of the quantum logic gate acting on a certain qubit is selected for a loss operation is the product of the first probability and the second probability.
[0017] In the training method of parametric quantum circuits based on multiple real quantum computers as described above, preferably, the first probability and the second probability are both preset values, the first probabilities of different qubits are different from each other or the same, and the second probabilities of different second part quantum logic gates are different from each other or the same.
[0018] The training method for parametric quantum circuits based on multiple real quantum computers, as described above, preferably includes the random loss operation on at least one of the second part quantum logic gates, comprising:
[0019] A random number is generated, which is used to generate a random third probability, which is the probability that a certain second part quantum logic gate is lost.
[0020] The training method for parametric quantum circuits based on multiple real quantum computers, as described above, preferably includes the random loss operation on at least one of the second part quantum logic gates, comprising:
[0021] A specific second part of the quantum logic gate is designated to be subject to a loss operation, and this second part of the quantum logic gate is then used in the training process.
[0022] The training method for parametric quantum circuits based on multiple real quantum computers, as described above, preferably includes the random loss operation on at least one of the second part quantum logic gates, comprising:
[0023] By combining several possible lists of loss operations, the combination method can be designed using a fixed combination method or by random generation. If the random generation method is used, the generated combination is recorded, and duplicate lists are not included in the training. Then, the training is performed sequentially by grid traversal, and finally the combination method that meets the expectations is output.
[0024] Secondly, the present invention provides a training device containing a parametric quantum circuit, comprising:
[0025] A parametric quantum circuit construction module is used to construct parametric quantum circuits, wherein the parametric quantum circuits include multiple first-part quantum logic gates and multiple 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] 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 subsets and the multiple subsets are assigned to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit.
[0027] The encoding module is used to encode the data values of the subset of data onto the first part of the quantum logic gate as the fixed parameters;
[0028] An initialization module initializes the trainable parameters of the second part of the quantum logic gate, wherein at least one of the second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0.
[0029] The computing module is used to run the parametric quantum circuit and obtain the output quantum state;
[0030] An adjustment module is used to determine whether the output quantum state meets preset requirements. If not, the trainable parameters are updated to meet the preset requirements, thereby obtaining the trained parameterized quantum circuit.
[0031] Thirdly, the present invention provides a storage medium storing a computer program, wherein the computer program is configured to implement the aforementioned method when running.
[0032] Fourthly, the present invention provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to implement the aforementioned method.
[0033] Compared with existing technologies, this invention reduces the overall training time of the model by splitting the training set into multiple subsets and performing parallel computation on multiple real quantum computers, thereby enabling model training on large datasets, reducing the burden on a single quantum computer, accelerating the execution speed of parametric quantum circuits, and preventing overfitting during training by randomly dropping the second part of the quantum logic gates in the operation section. Attached Figure Description
[0034] Figure 1 This is a network block diagram of a quantum circuit construction system provided in an embodiment of the present invention;
[0035] Figure 2 This is a flowchart of a parametric quantum circuit training method provided in an embodiment of the present invention;
[0036] Figure 3 A schematic diagram of a parametric quantum circuit provided in this application embodiment;
[0037] Figure 4 This is a schematic diagram of a parametric quantum circuit training device provided in an embodiment of the present invention. Detailed Implementation
[0038] 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.
[0039] [Structure of a quantum circuit construction system]
[0040] Figure 1 This is a network block diagram of a quantum circuit construction system provided in an embodiment of this 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 memory, a classical processor, a quantum processor, and other devices not shown.
[0041] Network 110 is a medium used to provide communication links between various devices and computers connected together within a quantum circuit construction system, including but not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The connection method can be wired, wireless communication links, or fiber optic cables.
[0042] Server 120 and client 140 are conventional data processing systems that may contain data and applications or software tools that perform conventional computational processes. Client 140 may be a personal computer or a network computer, so the data may also be provided by server 120. Wireless device 130 may be a smartphone, tablet, laptop, smart wearable device, etc. Storage unit 150 may include database 151, which can be configured to store data such as qubit parameters, quantum logic gate parameters, quantum circuits, and quantum programs.
[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 program 162 (application program 173). The application program 162 (application program 173) may be used to implement a quantum algorithm compiled according to the quantum circuit construction method provided in the embodiments of this 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 executed therein 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 has a hybrid structure, which includes at least... Figure 1 The system consists of two main parts: 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 computing.
[0046] The aforementioned classical processing system 160 and quantum processing system 170 can be integrated into a single device or distributed across two different devices. For example, the first device, including the classical processing system 160, runs a classical computer operating system that provides quantum application development tools and services, as well as the storage and network services required for quantum applications. Users develop quantum applications using the quantum application development tools and services on the second device and send the quantum program to the second device, including the quantum processing system 170, via the network services. The second device runs a quantum computer operating system, which parses the code of the quantum program and compiles it into instructions that can be recognized and executed by the quantum computer control system. The quantum processor 170 then implements the quantum algorithm corresponding to the quantum program based on these instructions.
[0047] In the classic silicon-based processing system 160, the units of the classic processor 161 are CMOS transistors. These computing units are not limited by time or coherence; that is, they are available at any time without time constraints. Furthermore, the number of these computing units in a silicon chip is sufficient; currently, a classic processor contains tens of thousands of computing units. The sufficient number of computing units and the fixed selectable computing logic of the CMOS transistors, such as AND logic, allow for computational efficiency through a combination of numerous CMOS transistors and limited logic functions.
[0048] Unlike the logic units in the classical processing system 160, the basic computational unit of the quantum processor 171 in the quantum processing system 170 is the qubit. The input of a qubit is limited by coherence and coherence time; that is, a qubit is limited by its available usage time and is not always readily available. Making full use of qubits within their available usage time is a key challenge in quantum computing. Furthermore, the number of qubits in a quantum computer is one of the representative indicators of its performance. Each qubit performs computational functions through on-demand configured logic functions. Given the limited number of qubits and the diverse logic functions available in quantum computing, such as Hadamard gates (H gates), Pauli-X gates (X gates), Pauli-Y gates (Y gates), Pauli-Z gates (Z gates), RX gates, RY gates, RZ gates, CR gates, iSWAP gates, Tofoli gates, etc., quantum computing requires combining a limited number of qubits with diverse combinations of logic functions to achieve computational effects.
[0049] Based on these differences, the design of logical functions applied to qubits (including the design of whether qubits are used and the design of the efficiency of each qubit's use) is crucial to improving the computational performance of quantum computers and requires specialized design. The aforementioned design considerations for qubits are technical issues that ordinary computing devices do not need to address.
[0050] [Quantum Circuit Training Method with Parametric Components]
[0051] Reference Figure 2 As shown, the present invention provides a method for training a parametric quantum circuit, comprising the following steps:
[0052] S101: Construct a parametric quantum circuit, which includes multiple first-part quantum logic gates and multiple 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.
[0053] The number of corresponding qubits in a parametric quantum circuit can be predetermined, depending on the number of qubits supported by the quantum device. Generally, it is less than or equal to the number of qubits supported. When the number of qubits supported by the quantum device is relatively large, the number of qubits required for preparation can be selected as appropriate.
[0054] In the embodiments provided by the present invention, the parametric 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 onto 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; and the measurement unit is used to perform measurement operations on the quantum bit.
[0055] In one feasible implementation, the quantum logic gates in the quantum state encoding unit are designated as the first part of the quantum logic gates, and the quantum logic gates in the evolution unit are designated as the second part of the quantum logic gates.
[0056] Step S102: Obtain the training set and determine whether the training set meets the splitting condition. If so, split the training set data into multiple subsets and assign these subsets to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit. The real quantum computers have quantum chips, and the qubits in the quantum chips are used to construct the parametric quantum circuits. By splitting the training set into multiple subsets and assigning them to multiple real quantum computers for parallel computation, the multiple real quantum computers do not interfere with each other, that is, there are no shared qubit resources between them. This achieves parallel computation of multiple subsets, which can reduce the burden on a single real quantum computer, speed up the execution of the circuit, and reduce the overall training time of the model, thereby enabling the training of the model under a large dataset. If the number of real quantum computers is set to n, and the original training time for one training set is T, then the current running time is reduced to T / n.
[0057] In one feasible implementation, the number of real quantum computers participating in parallel computing equals the number of subsets, with each real quantum computer assigned one subset, maximizing resource utilization and execution efficiency. In another feasible implementation, if the number of real quantum computers participating in parallel computing is less than the number of subsets, the subsets can be allocated according to a pre-defined grouping rule based on the number of real quantum computers. The subsets can be divided into multiple groups, with each real quantum computer assigned one group. The number of subsets in different groups can be the same or different, without limitation. For example, if there are two real quantum computers participating in parallel computing, the subsets are divided into two groups. When the number of subsets is even, both groups have the same number of subsets; when the number of subsets is odd, one group has one more subset than the other.
[0058] In the embodiments provided by the present invention, the condition for splitting the training set is to determine whether the number of data in the training set exceeds a preset threshold. The threshold is determined based on the number of qubits in the parametric quantum circuit. When the number of data in the training set exceeds the number of qubits in the parametric quantum circuit, the data in the training set is split into multiple subsets according to the splitting rules. If the number of data in the training set does not exceed the number of qubits in the parametric quantum circuit, then training can be performed on a single real quantum computer without splitting.
[0059] Preferably, the threshold can be set to the maximum number of qubits in the quantum chip of a real quantum computer. This fully utilizes the hardware resources of the real quantum computer to improve operating efficiency. The quantum computing task to be performed is split according to the ratio between the amount of data in the training set and the number of qubits in the quantum chip. The number of the resulting subsets is directly related to this ratio. When the ratio is an integer, the number of subsets is the ratio itself, and the number of data in each subset equals the number of qubits. When the ratio is not an integer (i.e., it has an integer part and a fractional part), the number of subsets is the integer part of the ratio plus 1. In this case, only one subset has a number of data less than the number of qubits in the quantum chip, while the remaining subsets have a number of data equal to the number of qubits in the quantum chip. Splitting the training set according to this rule allows the real quantum computer to achieve maximum resource utilization and high execution efficiency.
[0060] It should be noted that the splitting rules can be set according to actual application needs, and no specific limitations are made here. The key is to ensure that the subsets of the training set split according to the preset splitting rules can be successfully executed by the quantum circuit.
[0061] Alternatively, labels can be added to each subset of data, giving each subset a unique label code. All subsets can then be combined according to these label codes to form a training set. This facilitates the differentiation of the subsets and also makes it easier to perform grouping processing on each subset according to preset rules.
[0062] For example, if each subset of a dataset belonging to the same real quantum computer is labeled with sequential numbers, then the label code of each subset can be a sequential number. In this case, all subsets can be trained sequentially according to the order of their sequential numbers.
[0063] In practical applications, the rules for grouping and processing subsets need to be compatible with the rules for creating the label codes. Furthermore, as long as the overall result of compiling and processing each subset according to the label code-based rules remains consistent with the result of compiling and processing the quantum computing task before segmentation, this application does not impose specific limitations on the grouping and processing rules and the label codes. These rules can be set according to actual application needs. For example, the subsets can be trained sequentially based on the order of the label codes.
[0064] Furthermore, to facilitate accurate identification of multiple real quantum computers, each real quantum computer can be assigned a unique ID, and multiple subsets of datasets formed by subsets within a real quantum computer can all use that real quantum computer's ID. The ID can be set according to the actual application needs, and no specific limitation is made here.
[0065] Step S103: Encode the data values of the subset into the first part of the quantum logic gate as fixed parameters.
[0066] In the embodiments provided by the present invention, an encoding unit is used to establish a connection between the data of the subset and the parameterized quantum circuit, and the data of the subset is used as the fixed parameters of the first part of the quantum logic gate to perform angle encoding or amplitude encoding, so that the quantum circuit contains relevant information of the data.
[0067] In one feasible implementation, the encoding unit includes a plurality of first quantum rotation gate units, each of which corresponds to a qubit. Optionally, each data point of the subset is used as the rotation control parameter of the corresponding first quantum rotation gate unit. This rotation control parameter is a fixed parameter and is not involved in training or the loss operation mentioned later.
[0068] The first quantum rotation gate unit is a single-qubit rotation gate, including one or more of the RX gate, RY gate, and RZ gate. After performing the operation of the first quantum rotation gate unit, only the amplitude of the quantum state changes.
[0069] In one feasible implementation, refer to Figure 3 As shown, the first quantum rotation gate unit includes an RZ gate, an RX gate, and another RZ gate arranged sequentially along the action time sequence. The rotation control parameters of the RX gate and the RZ gate are adjusted individually according to the data of the subset dataset.
[0070] Step S104: Initialize the trainable parameters of the second part of the quantum logic gate, wherein at least one second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0.
[0071] The second part, the quantum logic gates, is located in the evolution unit. In the embodiment provided by this invention, after encoding, a combination of rotation and entanglement gates is applied to the qubits to obtain the output quantum state.
[0072] In one feasible implementation, the evolution unit includes CR gates and second quantum rotation gate units arranged sequentially along the action time sequence. Each CR gate and each second quantum rotation gate unit corresponds to a qubit. Except for the CR gate that acts on the least significant qubit, the control bit of the CR gate is the least significant qubit adjacent to the qubit it acts on, and the control bit of the CR gate of the least significant qubit is the most significant qubit.
[0073] The second quantum rotation gate unit is a single-qubit rotation gate, which includes one or more of the RX gate, RY gate and RZ gate. After performing the single-qubit rotation gate operation, only the amplitude of the quantum state changes. The CR gate is used to build the entanglement relationship between qubits, forming multi-qubit entanglement.
[0074] The rotation control parameters of the second quantum rotating gate unit are not fixed in advance; they need to be updated during the training and optimization process. The values of the rotation control parameters of the second quantum rotating gate unit are determined as follows: First, a set of parameters (i.e., training parameters) are initialized. Then, a quantum circuit is constructed based on the initial angle. The output quantum state is obtained by using the evolution unit. The measurement unit performs measurement operations on the output quantum state. The expected value of each qubit is considered by calculating the measurement based on the calculation. If the expected value is not met, the rotation parameters of the second quantum rotating gate unit are updated.
[0075] In the embodiments provided by this invention, to prevent overfitting during the training of a real quantum computer, at least one second-part quantum logic gate is randomly dropped during the parameter initialization step. After the drop operation, the trainable parameters of the second-part quantum logic gate are set to 0. Setting the trainable parameters to 0 is equivalent to calculating an identity matrix during computation, which means that the second-part quantum logic gate is not active. This helps to reduce the fluctuation of model parameters, thereby reducing overfitting during the training of a real quantum computer. Allowing the state of the qubit to change randomly during training 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, step S104 involves randomly performing a loss operation on at least one second-part quantum logic gate, including:
[0077] Obtain the first probability, which is the probability that a certain qubit in the parametric quantum circuit is selected; obtain the second probability, which is the probability that a certain second part of the quantum logic gate in the parametric quantum circuit is selected; multiply the first probability and the second probability to obtain the probability that a certain second part of the quantum logic gate acting on a certain qubit is selected for a loss operation.
[0078] The first probability and the second probability are both preset values set by humans. The first probability and the second probability are equivalent to hyperparameters, which are parameters that are manually input and can be adjusted according to the final experimental results. The first probabilities of different qubits may be different or the same, and the second probabilities of different second-part quantum logic gates may be different or the same.
[0079] Taking a parametric quantum circuit with four qubits as an example, where the first probabilities of different qubits differ from each other, while the second probabilities of different second-part quantum logic gates are the same, this will be explained as follows:
[0080] If the first probabilities on the four qubits are [0.2, 0.3, 0.1, 0.2] respectively, 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 qubits performing a loss operation is [0.1, 0.15, 0.05, 0.1].
[0081] Taking a parametric quantum circuit with four qubits as an example, where the first probabilities of different qubits differ from each other, and the second probabilities of different second-part quantum logic gates also differ from each other:
[0082] If the first probabilities on the four qubits are [0.2, 0.3, 0.1, 0.2], and the second probability of a certain second part quantum logic gate on different qubits is [0.5, 0.3, 0.1, 0.2], then the probability of a certain second part quantum logic gate on different qubits performing a loss operation is [0.1, 0.09, 0.01, 0.04].
[0083] In the second feasible implementation, in step S104, at least one second part quantum logic gate is randomly dropped, including: generating a random number, which is used to generate a random third probability, the third probability being the probability that a certain second part quantum logic gate is dropped; after the test, the results are filtered according to the set indicators, and finally the third probability that best matches the set indicators is selected to participate in the training of the real quantum computer.
[0084] In a third feasible implementation, in step S104, at least one second part quantum logic gate is randomly subjected to a loss operation, including: specifying a certain second part quantum logic gate to be fixed to be lost, and then participating in training.
[0085] In the fourth feasible implementation, a loss operation is randomly performed on at least one second part quantum logic gate, including: combining several possible lists of possible combinations for the loss operation. The combination method can be designed using a fixed combination method or can be generated randomly. If the random generation method is used, the generated combination is recorded, and duplicate lists are no longer included in the training. Then, the training is performed sequentially by grid traversal, and finally, the combination method that meets the expectation is output.
[0086] Step S105: Run the parametric quantum circuit to obtain the output quantum state.
[0087] Step S106: Determine whether the output quantum state meets the preset requirements. The measurement unit performs a measurement operation on the output quantum state. The expected value of each qubit is considered by calculating the measurement. If the expected value is not met, the trainable parameters are updated. In updating the trainable parameters, the loss operation is also randomly performed on each second part of the quantum logic gate to meet the preset requirements until the expected value meets the requirements. The trained parameterized quantum circuit is obtained. After training, the average value of the updated trainable parameters on each real quantum computer is used as the parameters for forward propagation on all real quantum computers in the new round.
[0088] In one feasible implementation, the parametric quantum circuit is applied to the training process of a deep neural network model. The training status of the parametric quantum circuit is determined based on the loss function. When the loss function meets the termination condition, the trained parametric quantum circuit is obtained.
[0089] Preferably, it can be determined whether the value of the loss function is less than or equal to the ground state energy obtained by classical calculation, or whether the difference between the current value of the loss function and the previously obtained value of the loss function meets the preset precision, or other methods can be used.
[0090] Taking the determination of whether the difference between the current loss function value and the previously obtained loss function value meets the preset accuracy as an example, firstly, it is determined whether the difference between the current loss function value and the previous loss function value is within the preset range. If not, the trainable parameters are updated, and the evolution process of the parametric quantum circuit is repeated. As the parametric 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. If the difference between the current loss function value and the previous loss function value is within the preset range, it means that the value of the loss function is approximately equal to the ground state energy, and at this point, the parametric quantum circuit is successfully trained. The preset range mentioned here can be determined by the desired accuracy to be achieved during training.
[0091] [Structure of the Quantum Circuit Training Device with Parametric Parameters]
[0092] See Figure 4 As shown, the parametric quantum circuit training device includes:
[0093] The parametric quantum circuit construction module is used to construct parametric quantum circuits. The parametric quantum circuit includes multiple first-part quantum logic gates and multiple second-part quantum logic gates. The parameters of the first-part quantum logic gates are fixed parameters, while 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 training set data is split into multiple subsets and distributed to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit.
[0095] The encoding module is used to encode the data values of the subset into the first part of the quantum logic gates as fixed parameters.
[0096] An initialization module initializes the trainable parameters of the second part of the quantum logic gates, wherein at least one second part of the quantum logic gates is randomly dropped, and the trainable parameters of the second part of the quantum logic gates after the drop operation are set to 0.
[0097] The computation module is used to run parametric quantum circuits and obtain the output quantum state.
[0098] The adjustment module is used to determine whether the output quantum state meets the preset requirements. If not, it updates the trainable parameters to meet the preset requirements and obtains a trained parameterized quantum circuit.
[0099] [Structure of storage media]
[0100] This invention also provides a storage medium storing a computer program, wherein the computer program is configured to implement the steps in any of the above method embodiments when running.
[0101] Specifically, in this embodiment, the storage medium can be configured to store a computer program for implementing the following steps:
[0102] Step S101: Construct a parametric quantum circuit, which includes multiple first-part quantum logic gates and multiple 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 the training set and determine whether the training set meets the splitting condition. If so, split the training set into multiple subsets and assign the subsets to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit.
[0104] Step S103: Encode the data values of the subset into the first part of the quantum logic gate as fixed parameters.
[0105] Step S104: Initialize the trainable parameters of the second part of the quantum logic gate, wherein at least one second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0.
[0106] Step S105: Run the parametric 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 the trained parameterized quantum circuit.
[0108] Structure of electronic devices
[0109] This invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to implement the steps in any of the above method embodiments.
[0110] Specifically, the aforementioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the aforementioned processor, and the input / output device is connected to the aforementioned processor.
[0111] Specifically, in this embodiment, the processor described above can be configured to implement the following steps via a computer program:
[0112] Step S101: Construct a parametric quantum circuit, which includes multiple first-part quantum logic gates and multiple 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 the training set and determine whether the training set meets the splitting condition. If so, split the training set into multiple subsets and assign the subsets to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit.
[0114] Step S103: Encode the data values of the subset into the first part of the quantum logic gate as fixed parameters.
[0115] Step S104: Initialize the trainable parameters of the second part of the quantum logic gate, wherein at least one second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0.
[0116] Step S105: Run the parametric 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 the trained parameterized quantum circuit.
[0118] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.
Claims
1. A training method for parametric quantum circuits based on multiple real quantum computers, characterized in that: The method includes: Construct a parametric quantum circuit, wherein the parametric quantum circuit includes a quantum state encoding unit and an evolution unit, wherein the quantum state encoding unit includes multiple first part quantum logic gates, and the evolution unit includes multiple 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; Obtain the training set, determine whether the training set meets the splitting condition, and if so, split the data of the training set into multiple subsets, and assign the multiple subsets to at least two real quantum computers, with each real quantum computer running the same parametric quantum circuit. The data values of the sub-dataset are encoded onto the first part of the quantum logic gates as the fixed parameters; Initialize the trainable parameters of the second part of the quantum logic gate, wherein at least one of the second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0; Run the parametric quantum circuit to obtain the 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 parameterized quantum circuit.
2. The method according to claim 1, characterized in that: The step of determining whether the training set meets the splitting condition includes: Determine whether the number of data in the training set exceeds a preset threshold, wherein the threshold is determined based on the number of qubits in the parametric quantum circuit.
3. The method according to claim 1, characterized in that: The random loss operation on at least one of the second part quantum logic gates includes: Obtain a first probability, which is the probability that a certain qubit in the parametric quantum circuit is selected; Obtain a second probability, which is the probability that a certain second part of the quantum logic gate in the parametric quantum circuit is selected; The probability that a certain second part of the quantum logic gate acting on a certain qubit is selected for a loss operation is the product of the first probability and the second probability.
4. The method according to claim 3, characterized in that: Both the first probability and the second probability are preset values. The first probabilities of different qubits may differ from or be the same to each other. The second probabilities of different second part quantum logic gates may differ from or be the same to each other.
5. The method according to claim 1, characterized in that: The random loss operation on at least one of the second part quantum logic gates includes: A random number is generated, which is used to generate a random third probability, which is the probability that a certain second part quantum logic gate is lost.
6. The method according to claim 1, characterized in that: The random loss operation on at least one of the second part quantum logic gates includes: A specific second part of the quantum logic gate is designated to be subject to a loss operation, and this second part of the quantum logic gate is then used in the training process.
7. The method according to claim 1, characterized in that: The random loss operation on at least one of the second part quantum logic gates includes: By combining several possible lists of loss operations, including using fixed combinations and random generation, the generated combinations are recorded and duplicate lists are not included in the training. Then, the training is performed sequentially by grid traversal, and finally the combination that meets the expectations is output.
8. A training device containing a parametric quantum circuit, characterized in that, include: A parametric quantum circuit construction module is used to construct parametric quantum circuits. The parametric quantum circuits include quantum state encoding units and evolution units. The quantum state encoding units include multiple first-part quantum logic gates, and the evolution units include multiple 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. 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 subsets and the multiple subsets are assigned to at least two real quantum computers. Each real quantum computer runs the same parametric quantum circuit. The encoding module is used to encode the data values of the subset of data onto the first part of the quantum logic gate as the fixed parameters; An initialization module initializes the trainable parameters of the second part of the quantum logic gate, wherein at least one of the second part of the quantum logic gate is randomly dropped, and the trainable parameters of the second part of the quantum logic gate after the drop operation are set to 0. The computing module is used to run the parametric quantum circuit and obtain the output quantum state; An adjustment module is used to determine whether the output quantum state meets preset requirements. If not, the trainable parameters are updated to meet the preset requirements, thereby obtaining the trained parameterized quantum circuit.
9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to implement the method described in any one of claims 1 to 7 when it is run.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Quantum neural network
CN110692067A
Data classification method based on machine learning framework and related equipment
CN114358317A