An amplitude-encoding quantum circuit construction method and related apparatus
By using cascaded angle encoding and variable quantum state compression, classical data is encoded into quantum superposition states, solving the decoherence problem caused by amplitude encoding and enabling the representation of large-sized images on a quantum computer.
Patent Information
- Application Number
- CN202411202020.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-08-29
AI Technical Summary
In existing technologies, amplitude encoding can easily lead to decoherence problems on real quantum computers, making it impossible to represent large-sized images on current quantum computers.
By cascading angle encoding and variable quantum state compression, classical data is progressively encoded into quantum superposition states. Variational encoders are used to simulate amplitude encoding, reducing line depth and alleviating decoherence problems.
It enables the representation of large-sized images on current quantum computers, reduces circuit depth, and alleviates the decoherence problem caused by amplitude encoding.
Smart Images

Figure CN119250211B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum computing fundamentals, and in particular to a method and apparatus for constructing amplitude-encoded quantum circuits. Background Technology
[0002] Due to the superposition property of qubits, N qubits can store 2^N qubits. N Using qubits for information storage and representation, instead of classical bits, would significantly save storage space and computing power. Images, as a method of information representation, are intuitive and rich in content; however, massive amounts of image data require enormous storage and computing power, and storage based on classical bits is insufficient to cope with the current surge in image data. Qubits hold promise for solving the storage and computational bottlenecks faced by massive image data. Amplitude encoding can encode pixel values into the amplitude of quantum states, exponentially reducing storage space. However, amplitude encoding often requires a large number of multi-bit control gates, and the decomposition of multi-bit control gates generates a large number of single-bit control gates, greatly increasing circuit depth and making decoherence prone to occur during actual operation. Therefore, on current quantum computers, amplitude encoding can often only represent smaller images, and cannot represent larger images. Summary of the Invention
[0003] The purpose of this invention is to provide a method and related apparatus for constructing quantum circuits with amplitude encoding, so as to solve the technical problems in the prior art. It can solve the problem that amplitude encoding is prone to decoherence on real quantum computers, and realize the representation of large-size images on quantum computers at the present stage.
[0004] In a first aspect, the present invention provides a method for constructing amplitude-encoded quantum circuits, the method comprising:
[0005] Obtain a data value group, wherein the data value group contains multiple data values;
[0006] A first quantum circuit is constructed, comprising a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates consisting of multiple first quantum rotation gates acting sequentially on the first quantum bit and variational encoders acting simultaneously on the first and second quantum bits. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0007] In the amplitude-encoded quantum circuit construction method described above, preferably, the variational encoder includes a plurality of CNOT gates and a plurality of second quantum rotation gates arranged sequentially along the action time sequence. The CNOT gates act on adjacent qubits of the first qubit and the second qubits. The control qubit of the CNOT gate is the higher-order qubit adjacent to the qubit it acts on. The second quantum rotation gates act on each of the first qubit and the second qubit.
[0008] In the amplitude-encoded quantum circuit construction method described above, preferably, the first quantum rotation gate includes one or more of a first RX gate, a first RY gate, and a first RZ gate, and the second quantum rotation gate includes one or more of a second RX gate, a second RY gate, and a second RZ gate.
[0009] In the amplitude-encoded quantum circuit construction method described above, preferably, the first quantum circuit further includes a third quantum bit that encodes a plurality of the data values by amplitude encoding, wherein the number of the third quantum bit is the same as that of the second quantum bit.
[0010] The amplitude-encoded quantum circuit construction method described above, preferably, further includes:
[0011] The quantum states of the second and third qubits are compared using a SWAP test quantum circuit.
[0012] In the amplitude-encoded quantum circuit construction method described above, preferably, the SWAP test quantum circuit includes a fourth qubit, a second qubit, a third qubit with corresponding weights, an H gate acting sequentially, a plurality of controlled SWAP gates, an H gate, and a measurement gate; wherein: the H gate and the measurement gate act on the fourth qubit, and the plurality of controlled SWAP gates act sequentially on the third qubit at different weight positions and the second qubit with corresponding weights of the third qubit, with the fourth qubit as the control qubit.
[0013] The amplitude-encoded quantum circuit construction method described above, preferably, further includes:
[0014] Construct training and testing datasets, set the batch size, and each batch includes at least one data value group. Send multiple data value groups from the same batch into the first quantum circuit one by one to calculate the loss value, and each data value group generates a loss value.
[0015] The average loss value for a batch is obtained by summing multiple loss values within a batch.
[0016] The gradient value of each second quantum rotating gate is calculated by backpropagation based on the average loss value. The rotation control parameters of the second quantum rotating gate are updated based on this gradient value, thus completing the training of a batch.
[0017] The aforementioned process is repeated iteratively until the loss value is lower than the set threshold or the set number of iterations is reached, at which point the training process is complete and the parameter weights in the variational encoder are determined.
[0018] In a second aspect, the present invention provides a quantum circuit construction apparatus, the apparatus comprising:
[0019] The acquisition module is used to acquire a data value group, wherein the data value group contains multiple data values;
[0020] The first quantum circuit construction module is used to construct a first quantum circuit including a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that act sequentially on the first quantum bit and a variational encoder that acts simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by means of angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0021] Thirdly, the present invention provides a storage medium storing a computer program, wherein the computer program is configured to execute the aforementioned method at runtime.
[0022] Thirdly, 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 perform the aforementioned method.
[0023] Compared with existing technologies, this invention encodes classical data into quantum superposition states step by step through cascaded angle encoding and variable quantum state compression. It uses a variational encoder to simulate amplitude encoding, reducing the line depth and thus alleviating the problem of decoherence that amplitude encoding easily leads to on real quantum computers. This enables the representation of large-sized images on current quantum computers. Attached Figure Description
[0024] Figure 1 This is a network block diagram of a quantum circuit construction system provided in an embodiment of this application;
[0025] Figure 2 This is a flowchart of a quantum circuit construction method with amplitude encoding provided in an embodiment of this application;
[0026] Figure 3 This is a schematic diagram of cascaded angle encoding in the quantum circuit construction method provided in the embodiments of this application;
[0027] Figure 4 This is a schematic diagram of a variational encoder provided in an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of the angle tree when the quantum circuit amplitude is encoded with four data values, as provided in the embodiments of this application;
[0029] Figure 6 This is a schematic diagram of a quantum circuit with four data values encoded by the quantum circuit amplitude, as provided in the embodiments of this application.
[0030] Figure 7 This is a schematic diagram of the SWAP test quantum circuit in the quantum circuit construction method provided in the embodiments of this application;
[0031] Figure 8 A flowchart illustrating the parameter training method for a variational encoder provided in this application embodiment;
[0032] Figure 9 This is a schematic diagram of a quantum circuit construction device provided in an embodiment of this application. Detailed Implementation
[0033] 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.
[0034] [Structure of a quantum circuit construction system]
[0035] 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.
[0036] 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.
[0037] 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.
[0038] 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.
[0039] 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.
[0040] 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.
[0041] 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.
[0042] 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.
[0043] 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, CR gates, iSWAP gates, Tooffoli gates, etc., quantum computing requires combining a limited number of qubits with diverse logic function combinations to achieve computational effects.
[0044] 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.
[0045] Amplitude-encoded quantum circuit construction method
[0046] like Figure 2 As shown, this invention provides an amplitude-encoded quantum circuit construction method for encoding classical data into a quantum superposition state. The method includes:
[0047] Step S101: Obtain a data value group. The data value group contains multiple data values. In the embodiment provided by the present invention, the data values are derived from the pixel values of the pixels. The set of pixel values of all pixels in an image is the data value group. Of course, the pixel values of all pixels in an image can also be split into two or more parts, and the set of pixel values of each part is a data value group. This is not limited here.
[0048] Step S102: Refer to Figure 3 As shown, a first quantum circuit including a first quantum bit and a second quantum bit is constructed. The number of the first quantum bit and the second quantum bit can be determined as needed and is not limited here. The first quantum circuit includes a combination of logic gates consisting of multiple first quantum rotation gates acting sequentially on the first quantum bit and variational encoders acting simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain the input quantum state by angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0049] Multiple data values are sequentially encoded into the quantum state of the first quantum bit by angle encoding, thereby establishing a connection between the data values in the data value group and the first quantum circuit, so that the first quantum bit contains relevant information about the data values. In the embodiments provided in this application, the pixel value information of the image pixels is linked to the first quantum bit, so that the first quantum bit contains the pixel value information of each pixel.
[0050] In one feasible implementation, a first qubit is set to one, and multiple data values are encoded onto the first qubit in a linear order. Before each data value is encoded, the first qubit is restored to its ground state. There are many ways to reset the first qubit to its ground state, such as by measurement and then returning it to the ground state.
[0051] Following the action sequence, after a data value is encoded into the quantum state of the first qubit, the quantum state information is associated with the variational encoder and the quantum state information on the first qubit is compressed into the second qubit. Then the first qubit is restored to the ground state, and the next data value is encoded, until the quantum state information of all data values is compressed into the second qubit.
[0052] Based on the amplitude encoding quantum circuit construction method provided in the above embodiments, classical data is gradually encoded into quantum superposition states through cascaded angle encoding and variable quantum state compression. Variational encoders are used to simulate amplitude encoding to reduce circuit depth, thereby alleviating the problem of decoherence that amplitude encoding easily leads to on real quantum computers, and realizing the representation of large-size images on current quantum computers.
[0053] In the embodiments provided by this invention, each variational encoder corresponds to a first quantum rotating door setup, as shown in the reference. Figure 4 As shown, the variational encoder includes multiple variational modules set sequentially along the action time sequence. The variational modules are repeated multiple times to increase the depth of evolution, thereby increasing the number of parameters, enhancing the expressive power of the model, capturing complex features, and improving the entanglement of quantum states.
[0054] Each variational module includes multiple CNOT gates and multiple second quantum rotation gates. The CNOT gates are positioned before the second quantum rotation gates. There are multiple second qubits, with the first qubit located at the higher position among all second qubits. The CNOT gates act on adjacent qubits in the first and second qubits. The control qubit of the CNOT gate is the higher-position qubit adjacent to the qubit it acts on. The CNOT gate is a two-qubit controlled NOT gate. The CNOT gates are used to construct entanglement relationships between qubits, forming multi-qubit entanglement. The second quantum rotation gates act on each of the first and second qubits.
[0055] In one feasible implementation, the first quantum rotation gate is a single-qubit rotation gate, including one or more of a first RX gate, a first RY gate, and a first RZ gate. After executing the first quantum rotation gate operation, only the amplitude of the quantum state changes. The data value is used as the rotation control parameter of the first quantum rotation gate. Preferably, the first quantum rotation gate is a first RY gate, and the rotation control parameter of the first RY gate is set to a value of... x is the data value to be encoded by the first quantum bit.
[0056] The second quantum rotation gate is also a single-qubit rotation gate. The second quantum rotation gate includes one or more of the second RX gate, the second RY gate, and the second RZ gate. Preferably, the second quantum rotation gate is the second RY gate. The rotation control parameters of the second quantum rotation gate are not fixed in advance and need to be updated in the subsequent training and optimization process.
[0057] Furthermore, the amplitude-encoded quantum circuit construction method also includes the following steps:
[0058] Step S103: Encode multiple data values into the quantum state of the third qubit using amplitude encoding.
[0059] In the process of constructing the first quantum circuit in step S102, the first quantum circuit also includes a third quantum bit that encodes multiple data values by means of amplitude encoding, wherein the number of the third quantum bit is the same as that of the second quantum bit.
[0060] The amplitude encoding process in step S103 includes two stages. The first stage is to preprocess multiple data values to obtain target data that meets the requirements of amplitude encoding. For example, normalization and zero-padding are performed on multiple data values in the data value group to obtain target data. The second stage is to construct the angle tree corresponding to the target data based on the target data, encode the nodes on the angle tree corresponding to the target data into the component quantum circuits, combine the quantum states in the quantum circuits, and output the input quantum state of the encoded quantum circuits.
[0061] Specifically, amplitude encoding requires the input data to be normalized in order to encode the data value group onto the amplitude of the quantum state. It also requires that the number of data values within the data value group be N = 2. n If the number of data values does not exceed 2 n In the form of , zero-padding is required to increase the number of elements. Therefore, multiple data values within the data group need to be preprocessed to obtain 2. n There are n target data, where n is a positive integer, to satisfy the encoding conditions of amplitude coding.
[0062] By performing preprocessing such as normalization and zero-padding on multiple data values within a data value group, the encoding conditions of amplitude coding can be met, which helps to ensure effective amplitude coding in the subsequent process.
[0063] After normalizing multiple data values, we obtain 2. n After obtaining the target data, based on 2 n Constructing an angle tree corresponding to the target data, in one feasible implementation, uses a top-down encoding method to encode the data values onto the third qubit. The bottom layer of the angle tree contains 2... n The first node and 2 n Each target data point corresponds to a parent node, and every two adjacent first nodes have a parent node.
[0064] In one feasible implementation, firstly RGB image Flattened dimensional vector Then to dimensional vector Normalization operation is performed to obtain , making The sum of the squares of is equal to 1, as shown in Formula 1;
[0065]
[0066] Next, amplitude encoding is used for encoding. dimensional vector As shown in Formula 2:
[0067]
[0068] in, This represents the superposition quantum state after encoding. Indicates the first A quantum state, Indicates the first The amplitude of a quantum state.
[0069] Reference Figure 5 as well as Figure 6 For example, let's take a data value group with 4 data values as an example. The 4 data values are denoted as follows: , , and This corresponds to the four first nodes at the bottom level of the angle tree. Each of these four first nodes has two second nodes above it, and each second node has two first nodes as child nodes. The two second nodes then have one root node above them. The value in the root node box is set to... The values in the boxes of the two second nodes are respectively as well as , The corresponding values in the first node's box are respectively and , The corresponding values in the first node's box are respectively and .
[0070] Correspondingly, there are two third qubits: a low-order qubit and a high-order qubit. Four data values are encoded onto these two third qubits. Specifically, following the activation sequence, a third RY gate is activated on the high-order qubit, and two controlled RY gates are activated on the low-order and high-order qubits respectively. The controlled RY gates use the RY gate as the target gate, and their application depends on the state of one or more control qubits. In this embodiment, the control qubit of the controlled RY gate is the high-order qubit, and the target gate is located on the low-order qubit. When the RY gate is used as a controlled gate, the state of the control qubit determines whether the effect of the RY gate is applied to the target qubit. If the control qubit is in the |1> state, the RY gate will be applied; if the control qubit is in the |0> state, the target qubit remains unchanged.
[0071] Specifically, by rotating the higher-order qubits by the first angle along the y-axis, we obtain RY( Rotating the lower-order qubits by a second angle along the y-axis yields RY ( Rotating the lower-order qubits by a third angle along the y-axis yields RY ( ).
[0072] Furthermore, the amplitude-encoded quantum circuit construction method also includes the following steps:
[0073] Step S104: Use SWAP to test the quantum circuit to compare the quantum states of the second and third qubits.
[0074] In the embodiments provided by this invention, the similarity (fidelity) of the quantum states of the second and third qubits output by the quantum circuit is used to measure the difference between them. By calculating the loss value between them, the parameters of the variational encoder are updated and optimized by backpropagation based on the loss value. When the loss value is lower than a set threshold or reaches a set number of iterations, the training of the variational encoder is completed, and the parameter weights in the variational encoder are determined.
[0075] In one feasible implementation, refer to Figure 7 As shown, the SWAP test quantum circuit includes a fourth qubit, a second qubit, a third qubit with corresponding weights, H gates acting sequentially, multiple controlled SWAP gates, H gates, and measurement gates; wherein: the H gates and measurement gates act on the fourth qubit, and the multiple controlled SWAP gates use the fourth qubit as the control qubit and act sequentially on the third qubit at different weight positions and the second qubit with the corresponding weights of the third qubit.
[0076] In a SWAP test quantum circuit, a fourth qubit is configured. The fidelity of the quantum states of the second and third qubits is obtained by measuring the fourth qubit, and this fidelity is used as the loss value. This testing method only requires measuring one fourth qubit at a time, eliminating the need to measure multiple qubits, thus saving quantum resources.
[0077] By running the first quantum circuit Next, the fourth qubit is measured, and the quantum state is statistically analyzed. quantity Formula 3 is the loss function. The smaller the value of S, the closer the quantum state is to the quantum state, that is, the more successful the quantum state simulation is.
[0078]
[0079] Reference Figure 8 As shown, in the embodiments provided by the present invention, the parameter training method of the variational encoder includes:
[0080] Step S1041: Construct training and testing datasets, set the batch size, and ensure that each batch includes at least one data value group. Feed multiple data value groups from the same batch into the first quantum circuit one by one to calculate the loss value, generating one loss value for each data value group. ;
[0081] Step S1042: Summing multiple loss values within a batch yields the average loss value for that batch. The calculation formula is shown in Formula 4;
[0082]
[0083] Step S1043: Backpropagation is performed based on the average loss value to calculate the gradient value of each second quantum rotating gate. The gradient value is then fed into the Adam optimizer, which is used to update the rotation control parameters of the second quantum rotating gate, thus completing a batch of training.
[0084] Step S1044: Iterate through the above process until the loss value is lower than the set threshold or the set number of iterations is reached, then complete the training process, determine the parameter weights in the variational encoder, and obtain the desired variational encoder.
[0085] [Structure of a quantum circuit construction device]
[0086] See Figure 9 As shown, the quantum circuit construction device includes:
[0087] The acquisition module is used to acquire a data value group, which contains multiple data values.
[0088] The first quantum circuit construction module is used to construct a first quantum circuit including a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that act sequentially on the first quantum bit and a variational encoder that acts simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by means of angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0089] Furthermore, the quantum circuit building module is also used to construct the third qubit, and the first quantum circuit also includes the third qubit that encodes multiple data values through amplitude encoding.
[0090] Furthermore, the quantum circuit construction device also includes a SWAP test quantum circuit construction module for constructing a SWAP test quantum circuit and using the SWAP test quantum circuit to compare the quantum states of the second and third qubits.
[0091] The SWAP test quantum circuit includes a fourth qubit, a second qubit, a third qubit with corresponding weights, H gates acting sequentially, multiple controlled SWAP gates, H gates, and measurement gates; wherein: the H gates and measurement gates act on the fourth qubit, and the multiple controlled SWAP gates use the fourth qubit as the control qubit and act sequentially on the third qubit at different weight positions and the second qubit with the corresponding weights of the third qubit.
[0092] [Structure of storage media]
[0093] 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.
[0094] Specifically, in this embodiment, the storage medium can be configured to store a computer program for implementing the following steps:
[0095] S101: Get a data value group, which contains multiple data values.
[0096] S102: Construct a first quantum circuit including a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that act sequentially on the first quantum bit and a variational encoder that acts simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0097] S103: Encodes multiple data values into the quantum state of the third qubit using amplitude encoding.
[0098] S104: Use SWAP to test the quantum circuit to compare the quantum states of the second and third qubits.
[0099] Structure of electronic devices
[0100] 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.
[0101] 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.
[0102] Specifically, in this embodiment, the processor described above can be configured to implement the following steps via a computer program:
[0103] S101: Get a data value group, which contains multiple data values.
[0104] S102: Construct a first quantum circuit including a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that act sequentially on the first quantum bit and a variational encoder that acts simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by angle encoding when the first quantum bit is in the ground state. Each variational encoder is used to compress the input quantum state in the corresponding logic gate combination to the second quantum bit.
[0105] S103: Encodes multiple data values into the quantum state of the third qubit using amplitude encoding.
[0106] S104: Use SWAP to test the quantum circuit to compare the quantum states of the second and third qubits.
[0107] 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 method for constructing amplitude-encoded quantum circuits, characterized in that: The method includes: Obtain a data value group, wherein the data value group contains multiple data values; A first quantum circuit is constructed, comprising a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that sequentially act on the first quantum bit and a variational encoder that simultaneously acts on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by means of angle encoding when the first quantum bit is in the ground state. Each variational encoder corresponds to a first quantum rotation gate setting and is used to compress the corresponding input quantum state to the second quantum bit.
2. The method according to claim 1, characterized in that: The variational encoder includes multiple CNOT gates and multiple second quantum rotation gates arranged sequentially along the operating time sequence. The CNOT gates operate on adjacent qubits of the first qubit and the second qubit. The control qubit of the CNOT gate is the higher-order qubit adjacent to the qubit it operates on. The second quantum rotation gates operate on each of the first qubit and the second qubit.
3. The method according to claim 2, characterized in that: The first quantum rotation gate includes one or more of a first RX gate, a first RY gate, and a first RZ gate, and the second quantum rotation gate includes one or more of a second RX gate, a second RY gate, and a second RZ gate.
4. The method according to claim 2, characterized in that: The first quantum circuit also includes a third quantum bit that encodes multiple data values using amplitude encoding, wherein the number of the third quantum bit is the same as the number of the second quantum bit.
5. The method according to claim 4, characterized in that: The method further includes: The quantum states of the second and third qubits are compared using a SWAP test quantum circuit.
6. The method according to claim 5, characterized in that, The SWAP test quantum circuit includes a fourth qubit, a second qubit, a third qubit with corresponding weights, an H gate acting sequentially, multiple controlled SWAP gates, H gates, and a measurement gate; wherein: the H gate and the measurement gate act on the fourth qubit, and the multiple controlled SWAP gates act on the third qubit at different weight positions and the second qubit with corresponding weights of the third qubit, with the fourth qubit as the control qubit.
7. The method according to claim 6, characterized in that, The method further includes: Construct training and testing datasets, set batch size, each batch includes at least one data value group, send multiple data value groups from the same batch into the first quantum circuit one by one to calculate loss value, each data value group generates a loss value, the loss value is the fidelity of obtaining the quantum state of the second and third qubits by measuring the fourth qubit; The average loss value for a batch is obtained by summing multiple loss values within a batch. The gradient value of each second quantum rotating gate is calculated by backpropagation based on the average loss value. The rotation control parameters of the second quantum rotating gate are updated based on this gradient value, thus completing the training of a batch. The aforementioned process is repeated iteratively until the loss value is lower than the set threshold or the set number of iterations is reached, at which point the training process is complete and the parameter weights in the variational encoder are determined.
8. A quantum circuit construction device, characterized in that, The device includes: The acquisition module is used to acquire a data value group, wherein the data value group contains multiple data values; The first quantum circuit construction module is used to construct a first quantum circuit including a first quantum bit and a second quantum bit. The first quantum circuit includes a combination of logic gates that act sequentially on the first quantum bit and a variational encoder that acts simultaneously on the first quantum bit and the second quantum bit. Each first quantum rotation gate is used to encode a data value to obtain an input quantum state by means of angle encoding when the first quantum bit is in the ground state. Each variational encoder corresponds to a first quantum rotation gate setting and is used to compress the corresponding input quantum state to the second quantum bit.
9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 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 perform the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Classification method based on machine learning framework and related device
CN114358318A
Multi-classification method and device based on variable component calculation
CN116756663A