A method and apparatus for preparing a quantum state
By encoding target data into qubits using specified quantum logic gates, the problem of the limited number of controllable qubits in quantum computers is solved, enabling efficient quantum algorithm simulation and sparse data processing, and expanding the applications of quantum computing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
- Filing Date
- 2022-03-22
- Publication Date
- 2026-05-12
AI Technical Summary
In the current technology, the number of qubits that can be controlled by quantum computers is limited due to the development of quantum chip hardware, which makes it difficult to simulate quantum algorithms, resulting in large quantum circuit depths, high computational costs, and difficulty in effectively running complex quantum algorithms.
By acquiring specific elements and their positions in the target data, and using designated quantum logic gates such as the Pauli-X gate, the controlled NOT gate, the U3 quantum logic gate, and the Tooffoli quantum logic gate, the position information of the specific elements is encoded into qubits, and the amplitude value of the final quantum state is output, corresponding one-to-one with the target data elements.
This invention enables efficient simulation of quantum algorithms on classical computers, reduces computational costs, is applicable to quantum state encoding of sparse data, and expands the research and application of quantum computing.
Smart Images

Figure CN116822643B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quantum computing technology, specifically a method and apparatus for preparing quantum states. Background Technology
[0002] Quantum computers utilize the superposition property of quantum mechanics, theoretically offering exponential speedups in certain situations. For example, cracking an RSA key would take hundreds of years on a classical computer, but executing a quantum algorithm on a quantum computer would only take a few hours. However, current quantum computers are limited by the finite number of controllable qubits resulting from advancements in quantum chip hardware, thus limiting their computational power and preventing the widespread execution of quantum algorithms.
[0003] In the simulation and implementation of quantum algorithms, it is usually necessary to construct the quantum algorithm using various quantum logic gates. For example, in solving scientific computing problems, it is necessary to encode the relevant information of the target data into the quantum states of qubits. However, when constructing quantum circuits to achieve this requirement using various quantum logic gates, the number of quantum logic gates required is enormous, and the depth of the constructed quantum circuits is quite deep, which seriously hinders the research of quantum computing. This is a problem that urgently needs to be solved. Summary of the Invention
[0004] The purpose of this invention is to provide a method and apparatus for preparing quantum states to overcome the shortcomings of the prior art. It can use several specified quantum logic gates to encode specific element information and position information in target data into qubits for the preparation of quantum states, thereby solving the simulation problem of quantum computing.
[0005] One embodiment of this application provides a method for preparing a quantum state, the method comprising:
[0006] Acquire specific elements from the target data, along with the location information corresponding to those specific elements and a set of qubits;
[0007] For each specific element and its corresponding position information, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information of the specific element into the qubit, and outputs a final quantum state containing the encoded qubit, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0008] Optionally, the target data includes sparse data.
[0009] Optionally, the specific element includes: a non-zero element.
[0010] Optionally, obtaining specific elements from the target data includes:
[0011] Obtain the non-zero elements in the target data and determine whether the sum of the squares of the non-zero elements is 1;
[0012] If not, the non-zero elements are normalized to obtain the non-zero elements whose sum of squares is 1.
[0013] Optionally, the position information corresponding to the specific element includes: the index information of the non-zero element represented by a binary string in the sparse data.
[0014] Optionally, the specified quantum logic gates include: Pauli-X gates, controlled NOT gates, U3 quantum logic gates, and Tofoli quantum logic gates.
[0015] Optionally, the final quantum state of the qubit includes:
[0016] The final quantum state of the qubit is determined by the following formula.
[0017]
[0018] Where M is the number of non-zero elements, and x k p is the amplitude value of the final quantum state. k p is the index of the non-zero element in the binary string representation of the sparse data. k ∈{0,1} n , where n is the number of qubits in a set.
[0019] Another embodiment of this application provides a quantum state preparation apparatus, the apparatus comprising:
[0020] The acquisition module is used to acquire a specific element in the target data, the position information corresponding to the specific element, and a set of qubits;
[0021] The encoding module is used to perform a quantum state evolution operation using a specified quantum logic gate for each specific element and the position information corresponding to the specific element, so as to encode the position information corresponding to the specific element into the qubit, and output the final quantum state containing the encoded qubit, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0022] Optionally, the acquisition module includes:
[0023] The judgment unit is used to obtain the non-zero elements in the target data and determine whether the sum of squares of the non-zero elements is 1;
[0024] A normalization unit is used to normalize the non-zero elements if not otherwise, to obtain the non-zero elements whose sum of squares is 1.
[0025] Another embodiment of this application provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.
[0026] Another embodiment of this application 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 method described in any of the preceding claims.
[0027] Compared with existing technologies, this application first obtains specific elements and their corresponding position information and a set of qubits from the target data. For each specific element and its corresponding position information, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information of the specific element into the qubit. The final quantum state containing the encoded qubit is then output, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data. It can use several specified quantum logic gates to encode the specific element information and position information in the target data into the qubit for quantum state preparation, thus solving the simulation problem of quantum computing. Attached Figure Description
[0028] Figure 1 This is a hardware structure block diagram of a computer terminal for a quantum state preparation method provided in an embodiment of the present invention;
[0029] Figure 2 This is a schematic flowchart of a method for preparing a quantum state provided in an embodiment of the present invention;
[0030] Figure 3 A schematic diagram of a quantum circuit provided for an embodiment of the present invention;
[0031] Figure 4 This is a schematic diagram of the structure of a quantum state preparation device provided in an embodiment of the present invention. Detailed Implementation
[0032] 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.
[0033] The present invention first provides a method for preparing a quantum state, which can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
[0034] The following detailed explanation uses a computer terminal as an example. Figure 1 This is a hardware structure block diagram of a computer terminal for a quantum state preparation method provided in an embodiment of the present invention. (See diagram below.) Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0035] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / modules corresponding to a method for preparing a quantum state in this embodiment of the application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0036] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0037] It's important to note that a true quantum computer has a hybrid structure, comprising two main parts: a classical computer responsible for performing classical computations and control, and a quantum device responsible for running quantum programs to achieve quantum computation. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can run on a quantum computer, supporting operations on quantum logic gates and ultimately enabling quantum computing. Specifically, a quantum program is a sequence of instructions that operates on quantum logic gates according to a specific timing order.
[0038] In practical applications, due to limitations in the development of quantum device hardware, quantum computing simulations are often required to verify quantum algorithms, quantum applications, and so on. Quantum computing simulation is the process of simulating the execution of a quantum program corresponding to a specific problem using a virtual architecture (i.e., a quantum virtual machine) built with the resources of a regular computer. Typically, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program referred to in this embodiment of the invention is a program written in a classical language that represents qubits and their evolution, wherein qubits, quantum logic gates, etc., related to quantum computing all have corresponding classical code representations.
[0039] Quantum circuits, also known as quantum logic circuits, are a common manifestation of quantum programming and are the most widely used general-purpose quantum computing model. They represent circuits that operate on qubits under an abstract concept. They consist of qubits, circuits (timelines), and various quantum logic gates. Finally, the results are often read out through quantum measurement operations.
[0040] Unlike traditional circuits that use metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as being connected by time. That is, the state of a quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
[0041] A quantum program corresponds to a single quantum circuit. The quantum program described in this invention refers to this single quantum circuit, where the total number of qubits in the single quantum circuit is the same as the total number of qubits in the quantum program. This can be understood as follows: a quantum program can consist of a quantum circuit, measurement operations on the qubits within the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A single quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution of a quantum program is the process of executing all the quantum logic gates in a specific timing order. It should be noted that the timing order refers to the chronological sequence in which individual quantum logic gates are executed.
[0042] It's important to note that in classical computing, the most basic unit is the bit, and the most fundamental control mode is the logic gate. Circuit control can be achieved through combinations of logic gates. Similarly, the way to process qubits is through quantum logic gates. Quantum logic gates enable the evolution of quantum states and are the foundation of quantum circuits. Quantum logic gates include single-qubit gates, 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, etc.; and multi-qubit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, Tofoli gates, etc. Quantum logic gates are generally represented using unitary matrices, which are not only matrix forms but also operations and transformations. The effect of a quantum logic gate on a quantum state is generally calculated by left-multiplying the unitary matrix by the matrix corresponding to the right vector of the quantum state.
[0043] As those skilled in the art will understand, in classical computers, the basic unit of information is the bit, which has two states: 0 and 1. The most common physical implementation uses high and low voltage levels to represent these states. In quantum computing, the basic unit of information is the qubit, which also has two states: 0 and 1, denoted as |0> and |1>. However, it can exist in a superposition of these two states, which can be represented as... Here, a and b are complex numbers representing the amplitudes (probability amplitudes) of the |0> and |1> states, respectively, which is not present in classical bits. After measurement, the state of a quantum bit collapses to a definite state (eigenstate, here |0> and |1>), where the probability of collapsing to |0> is |a|. 2 The probability of collapsing to |1> is |b|. 2 , |a| 2 +|b| 2 =1, |> is the Dirac notation.
[0044] A quantum state refers to the state of a qubit (or quantum bit). Its eigenstates are represented in binary form in quantum algorithms (or quantum programs). For example, a set of qubits q0, q1, and q2, representing the 0th, 1st, and 2nd qubits respectively, ordered from most significant bit to least significant bit as q2q1q0, has a quantum state of 2q1q ... 3 A quantum state is a superposition of 8 eigenstates. The 8 eigenstates (definite states) are: |000>, |001>, |010>, |011>, |100>, |101>, |110>, and |111>. Each eigenstate corresponds to a qubit. For example, in the |000> state, 000 corresponds to q2q1q0 from the highest to the lowest bit. In short, a quantum state is a superposition of eigenstates. When the probability amplitude of other states is 0, the state is in one of the definite eigenstates.
[0045] Currently, existing quantum circuit construction methods often only utilize existing single-quantum logic gates, dual-quantum logic gates, etc., which typically presents the following problems: First, for quantum circuits with complex functions, the number of qubits required is very large, consuming enormous memory space and taking a very long time when simulating using classical computers. Furthermore, some complex algorithms are difficult to implement using quantum circuits. Second, current encoding techniques prepare the basic states from classical data, mainly by loading each data point into a superposition quantum state one by one. The computational cost is related to the data size and the number of qubits, and the exponential cost of algorithms related to the number of qubits and the input mode is too high. Moreover, these methods can only be used to generate quantum states with a small number of qubits, and require a large number of CNOT gates, making them unsuitable for NISQ devices.
[0046] Based on this, this application proposes an algorithm for encoding sparse data into quantum circuits with a computational cost of O(MlogM+nM), which is used to construct quantum circuits by classical computers.
[0047] See Figure 2 , Figure 2 A flowchart illustrating a method for preparing a quantum state according to an embodiment of the present invention may include the following steps:
[0048] S201: Obtain a specific element in the target data, the position information corresponding to the specific element, and a set of qubits.
[0049] Specifically, users can input preset target data and obtain specific elements within the target data, their corresponding position information, and a set of qubits representing qubits. The number of qubits can be set by the user according to the size of the preset target data. With sufficient computing resources, a large number of qubits can also be set to meet the qubit requirements in most cases.
[0050] Target data can be determined through, but is not limited to, the following methods, where users can input the data information they want to encode on a computer terminal. Preferably, the target data can be sparse data, and specific elements in the target data can be non-zero elements. Sparse data refers to data in which the vast majority of values are missing or zero. In modern society, with the explosive growth of information, the amount of data has also exploded, and the forms of data are becoming increasingly diverse. In the field of data mining, we often face massive amounts of complex data, among which sparse data, a special form of data, is attracting increasing attention. Sparse data is not useless data; it is simply data with incomplete information, which needs to be mined and utilized through appropriate methods.
[0051] However, in some cases, the sparsity of the data can reach half or even higher, which makes traditional encoding methods, such as quantum circuits constructed by quantum state encoding using RY quantum logic gates, very complex, costly to simulate, and difficult to effectively simulate using NISQ devices. Therefore, traditional quantum state encoding methods are not suitable for processing such data.
[0052] The positional information corresponding to a specific element may include: the index information of the non-zero element represented by a binary string in sparse data.
[0053] For example, for a set of target sparse data Representing the index using binary strings is as follows: Therefore, the binary string representation of the indices of the three non-zero elements is:
[0054] Among these, obtaining specific elements from the target data includes:
[0055] Step 1: Obtain the non-zero elements in the target data and determine whether the sum of the squares of the non-zero elements is 1.
[0056] For example, for a set of target sparse data The sum of squares of its non-zero elements is 1, so no further processing is needed; for another set of target sparse data {1,0,2,0,3,4,0,5,0,0,0,0}, the sum of squares of its non-zero elements is not 1, so the following steps need to be performed.
[0057] Step 2: If not, normalize the non-zero elements to obtain the non-zero elements whose sum of squares is 1.
[0058] Specifically, normalization involves processing the target data and limiting it to a preset value. For example, it normalizes the values of the target data elements so that the sum of the squares of all elements is 1. The purpose is to facilitate subsequent data processing and, secondly, to improve efficiency during data encoding.
[0059] For example, for another set of target sparse data {1,0,2,0,3,4,0,5,0,0,0,0}, it can be seen that the sum of the squares of the five non-zero elements in this sparse data is not 1. Therefore, the values of the elements in the sparse data need to be normalized. The processed target sparse data is as follows:
[0060] S202: For each specific element and the position information corresponding to the specific element, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information corresponding to the specific element into the qubit, and a final quantum state containing the encoded qubit is output, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0061] Specifically, the idea of encoding quantum circuits is to use a recursive method to implement them with a series of specified quantum logic gates, specifically a series of Pauli-X gates, controlled NOT gates (CNOT gates), U3 quantum logic gates, and Tooffoli quantum logic gates to prepare data onto the corresponding quantum states.
[0062] The principle formula for the technical solution in this application is as follows:
[0063]
[0064] Where M is the number of non-zero elements, and x k p represents the amplitude value of the final quantum state. k Let p be the index of the binary string representation of a non-zero element in sparse data. k ∈{0,1} n , where n is the number of qubits in a set.
[0065] Among them, the preferred quantum logic gate used is the Pauli X gate, whose matrix form is as follows:
[0066]
[0067] The Pauli-X gate operates on a qubit, which is equivalent to the classical NOT gate. In Bloch spherical representation, it will rotate the target qubit 180° around the x-axis. If the qubit is |1> before the operation, it will be changed to |0> after the Pauli-X gate operation, and vice versa.
[0068] The other specified quantum logic gate used is preferably a controlled NOT gate (CNOT gate), whose matrix form is as follows:
[0069]
[0070] A control-NOT gate operates on two qubits: a controlled qubit and a target qubit. The target qubit only undergoes a NOT operation if the controlled qubit is |1>; otherwise, it remains unchanged. In practice, CNOT gates are commonly used to handle entanglement between two qubits, and because they are control-NOT gates, the logic state of the controlled qubit can be controlled.
[0071] The preferred quantum logic gate used is the U3 quantum logic gate, whose matrix form is as follows:
[0072]
[0073] The specific implementation of the U3 gate is shown below:
[0074]
[0075] Where, γ k Let γ be the iteration variable and its initial value be 1, satisfying γ k =γ k-1 -|x k-1 | 2 , 1≤k≤M-1, x k The amplitude value of the final quantum state can be either a real number or a complex number, and is not limited here.
[0076] The last specified quantum logic gate used is preferably the Tooffoli quantum logic gate. The Tooffoli gate (controlled-controlled-not (CCNOT) gate) is a quantum logic gate that operates on three qubits. It is a general reversible logic gate, meaning that any reversible circuit can be constructed using a Tooffoli gate. It has three inputs and three outputs. The third target qubit is only processed similarly to a classical NOT gate when two controlled qubits are |1>. Otherwise, no operation is performed.
[0077] For example, for the above set of target sparse data Each non-zero element and its corresponding binary index information, i.e.: The evolution of quantum states is performed using Pauli-X gates, controlled NOT gates, U3 quantum logic gates, and Tooffoli quantum logic gates, respectively, to encode the binary subscript position information corresponding to non-zero elements into qubits, and output the final quantum state containing the encoded qubits. The specific evolution process is as follows:
[0078] First, a set of 6 qubits is obtained and numbered from high to low as q[5]q[4]q[3]q[2]q[1]q[0], and its initial state is set to |0>|0>|0>|0>|0>|0>|0>. Then, using Pauli-X gates, controlled NOT gates, U3 quantum logic gates and Tooffoli quantum logic gates, the following structures are constructed: Figure 3 The quantum circuit shown performs the quantum state evolution operation, measures and outputs the final quantum state of a specified qubit, for example, outputs the final quantum state of the specified qubit q5q4q3, where the amplitude value of the final quantum state corresponds one-to-one with the element value of the non-zero element mentioned above.
[0079] It should be noted that, in order to visually demonstrate the controlled state of a specified quantum logic gate, the solid brown dots in the illustrations of this application represent 1 control, indicating that when the quantum state of the qubit is 1, the corresponding quantum logic gate will be executed, and the lines between the dots represent controlled state.
[0080] Specifically, according to Figure 3 The quantum circuit shown performs quantum state evolution operations according to the time sequence. The initial quantum state |0>|0>|0>|0>|0>|0> passes through the Pauli-X gate on the q[0] qubit, and the initial quantum state evolves into |0>|0>|0>|0>|0>|0)|1); after passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[3], the quantum state evolves into |0>|0>|1>|0>|0>|1>; after passing through a controlled U3 quantum logic gate with a controlled qubit of q[3] and a target qubit of q[0], the evolved quantum state is obtained as After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[3], the quantum state evolves into After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[4], the quantum state evolves into After passing through a controlled U3 quantum logic gate with controlled qubits q[4] and target qubits q[0], the quantum state evolves into After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[4], the quantum state evolves into After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[3], the quantum state evolves into After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[4], the quantum state evolves into After passing through a CNOT quantum logic gate with a controlled qubit of q[0] and a target qubit of q[5], the quantum state evolves into After passing through a Tooffoli quantum logic gate with one controlled qubit q[4], another controlled qubit q[5], and a target qubit q[2], the quantum state evolves into After passing through a Tooffoli quantum logic gate with one controlled qubit q[2], another controlled qubit q[3], and a target qubit q[1], the quantum state evolves into After passing through a controlled U3 quantum logic gate with controlled qubits q[1] and target qubits q[0], the quantum state evolves into... After passing through a Tooffoli quantum logic gate with one controlled qubit q[2], another controlled qubit q[3], and a target qubit q[1], the quantum state evolves into Finally, after passing through a Tooffoli quantum logic gate with one controlled qubit q[4], another controlled qubit q[5], and a target qubit q[2], the resulting evolved quantum state is:
[0081] It can be seen that for the target data before encoding and the final quantum state obtained through evolution The amplitude of the final quantum state obtained by the evolution of the zero element in the target data is zero, so it is omitted and not shown; the amplitude value of the final quantum state obtained by the evolution of the non-zero element in the target data corresponds one-to-one with the element value of the non-zero element in the target data.
[0082] It should be noted that the angle on the U3 gate can be determined based on the iteration variable and the non-zero element value to be encoded.
[0083] By specifying quantum logic gates to encode relevant information of target data into quantum states, classical data structures are linked to the states of qubits in the quantum field, which can be used for quantum computing simulations, further expanding research on quantum algorithms and quantum computers.
[0084] As can be seen, this application first obtains specific elements and their corresponding position information and a set of qubits from the target data. For each specific element and its corresponding position information, it uses a specified quantum logic gate to perform a quantum state evolution operation to encode the position information of the specific element into the qubit, and outputs a final quantum state containing the encoded qubit. The amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data. It can use several specified quantum logic gates to encode the specific element information and position information in the target data into the qubit for quantum state preparation, thus solving the simulation problem of quantum computing.
[0085] See Figure 4 , Figure 4 This is a schematic diagram of the structure of a quantum state preparation device provided in an embodiment of the present invention. Figure 2 The process shown can include:
[0086] Acquisition module 401 is used to acquire a specific element in the target data, the position information corresponding to the specific element, and a set of qubits;
[0087] The encoding module 402 is used to perform a quantum state evolution operation using a specified quantum logic gate for each specific element and the position information corresponding to the specific element, so as to encode the position information corresponding to the specific element into the qubit, and output the final quantum state containing the encoded qubit, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0088] Specifically, the acquisition module includes:
[0089] The judgment unit is used to obtain the non-zero elements in the target data and determine whether the sum of squares of the non-zero elements is 1;
[0090] A normalization unit is used to normalize the non-zero elements if not otherwise, to obtain the non-zero elements whose sum of squares is 1.
[0091] Compared with existing technologies, this application first obtains specific elements and their corresponding position information and a set of qubits from the target data. For each specific element and its corresponding position information, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information of the specific element into the qubit. The final quantum state containing the encoded qubit is then output, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data. It can use several specified quantum logic gates to encode the specific element information and position information in the target data into the qubit for quantum state preparation, thus solving the simulation problem of quantum computing.
[0092] Embodiments of the present invention also include a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0093] Specifically, in this embodiment, the storage medium can be configured to store a computer program for performing the following steps:
[0094] S201: Obtain a specific element in the target data, along with the position information corresponding to the specific element and a set of qubits;
[0095] S202: For each specific element and the position information corresponding to the specific element, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information corresponding to the specific element into the qubit, and a final quantum state containing the encoded qubit is output, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0096] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0097] Embodiments of the present invention also include 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 perform the steps in any of the above method embodiments.
[0098] 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.
[0099] Specifically, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0100] S201: Obtain a specific element in the target data, along with the position information corresponding to the specific element and a set of qubits;
[0101] S202: For each specific element and the position information corresponding to the specific element, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information corresponding to the specific element into the qubit, and a final quantum state containing the encoded qubit is output, wherein the amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data.
[0102] 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 preparing a quantum state, characterized in that, The method includes: Acquire specific elements in target data, along with the position information corresponding to those specific elements and a set of qubits, wherein the target data includes sparse data and the specific elements include non-zero elements; For each specific element and its corresponding position information, a quantum state evolution operation is performed using a specified quantum logic gate to encode the position information of the specific element into the qubit, outputting the final quantum state containing the encoded qubit. The position information of the specific element is the index information of the non-zero element represented by a binary string in the sparse data. The specified quantum logic gates include: Pauli X-gate, controlled NOT gate, U3 quantum logic gate, and Toffoli quantum logic gate. The amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data. The final quantum state of the qubit is determined by a formula. It is confirmed that the The number of the non-zero elements, the The amplitude value of the final quantum state, the The location information corresponding to the specific element and The The number of qubits in a set.
2. The method according to claim 1, characterized in that, The acquisition of specific elements from the target data includes: Obtain the non-zero elements in the target data and determine whether the sum of the squares of the non-zero elements is 1; If not, the non-zero elements are normalized to obtain the non-zero elements whose sum of squares is 1.
3. A device for preparing a quantum state, characterized in that, The device includes: An acquisition module is used to acquire specific elements in target data, the position information corresponding to the specific elements, and a set of qubits, wherein the target data includes sparse data, and the specific elements include non-zero elements; An encoding module is used to perform a quantum state evolution operation using a specified quantum logic gate for each specific element and its corresponding position information, thereby encoding the position information of the specific element into the qubit and outputting the final quantum state containing the encoded qubit. The position information of the specific element is the index information of the non-zero element represented by a binary string in the sparse data. The specified quantum logic gates include: Pauli X-gate, controlled NOT gate, U3 quantum logic gate, and Tofoli quantum logic gate. The amplitude value of the final quantum state corresponds one-to-one with the element value of the specific element in the target data. The final quantum state of the qubit is determined by a formula. It is confirmed that the The number of the non-zero elements, the The amplitude value of the final quantum state, the The index of the non-zero element in the sparse data is the binary string representation of the element. The The number of qubits in a set.
4. 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 2 when it is run.
5. 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 2.