CN117313883A - Quantum circuit processing method and device and electronic equipment - Google Patents

Quantum circuit processing method and device and electronic equipment Download PDF

Info

Publication number
CN117313883A
CN117313883A CN202311268026.XA CN202311268026A CN117313883A CN 117313883 A CN117313883 A CN 117313883A CN 202311268026 A CN202311268026 A CN 202311268026A CN 117313883 A CN117313883 A CN 117313883A
Authority
CN
China
Prior art keywords
quantum
list
circuit
quantum circuit
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311268026.XA
Other languages
Chinese (zh)
Inventor
方堃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311268026.XA priority Critical patent/CN117313883A/en
Publication of CN117313883A publication Critical patent/CN117313883A/en
Pending legal-status Critical Current

Links

Abstract

The disclosure provides a quantum circuit processing method, a quantum circuit processing device and electronic equipment, relates to the technical field of quantum computing, and particularly relates to the technical field of quantum circuits. The specific implementation scheme is as follows: acquiring a first instruction list of a first quantum circuit comprising N quantum bits, wherein the first quantum circuit is a quantum circuit with a star structure or a sub-circuit of the quantum circuit with the star structure, and in the star structure, a double-quantum bit gate acts between each first quantum bit and a target quantum bit according to the sequence of the quantum bits from small to large; based on the first instruction list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of the second quantum circuit; equivalent compilation includes: adding a first reset operation instruction after the first measurement operation instruction in the first instruction list; each target operating instruction in the first instruction list is remapped to the qubit of the qubit i, and the target operating instruction acts on the qubit i+1.

Description

Quantum circuit processing method and device and electronic equipment
Technical Field
The disclosure relates to the technical field of quantum computing, in particular to the technical field of quantum circuits, and specifically relates to a quantum circuit processing method, a quantum circuit processing device and electronic equipment.
Background
The quantum computing provides a brand new and very promising information processing mode by utilizing the specific operation rule in the quantum world. Quantum algorithms can offer advantages over classical algorithms over a number of specific problems. For example, large integers can be efficiently decomposed using the schiff (shell) algorithm, and data search can be performed faster using the Grover (Grover) algorithm. With the development of quantum theory, new quantum algorithms are continuously proposed, and how to efficiently simulate the algorithms or run the algorithms on real quantum hardware is always an important problem.
Classical simulation or true operation of quantum algorithms is mainly limited by the number of qubits. In classical simulation, since the length of the column vector describing the quantum state grows exponentially with the corresponding number of bits (e.g., the length of the column vector of an n-bit quantum state is 2 n ) Classical computers have difficulty simulating large-scale quantum algorithms. The existing quantum circuit simulation mode can support an algorithm for simulating tens of quantum bits at most under the limitation of the memory and the processor capacity of a computer.
Currently, a heuristic algorithm is generally adopted to perform equivalent compiling on a quantum circuit, so as to obtain a dynamic quantum circuit equivalent to the quantum circuit.
Disclosure of Invention
The disclosure provides a quantum circuit processing method, a quantum circuit processing device and electronic equipment.
According to a first aspect of the present disclosure, there is provided a quantum circuit processing method, comprising:
obtaining a first instruction list of a first quantum circuit comprising N quantum bits, the first quantum circuit being: the quantum circuit comprises a star-shaped structure quantum circuit or a sub-circuit of the star-shaped structure quantum circuit, wherein N quantum bits in the star-shaped structure quantum circuit are sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1 of the quantum bit, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence from small to large of the quantum bit, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the star-shaped structure quantum circuit, and N is an integer larger than 2;
based on the first instruction list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit;
Wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
According to a second aspect of the present disclosure, there is provided a quantum circuit processing apparatus comprising:
an acquisition module, configured to acquire a first instruction list of a first quantum circuit including N quantum bits, the first quantum circuit being: the quantum circuit comprises a star-shaped structure quantum circuit or a sub-circuit of the star-shaped structure quantum circuit, wherein N quantum bits in the star-shaped structure quantum circuit are sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1 of the quantum bit, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence from small to large of the quantum bit, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the star-shaped structure quantum circuit, and N is an integer larger than 2;
The equivalent compiling module is used for carrying out equivalent compiling on the first quantum circuit based on the first instruction list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit;
wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform any one of the methods of the first aspect.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform any of the methods of the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements any of the methods of the first aspect.
According to the technology disclosed by the invention, the problem that classical simulation and true operation of the quantum circuit with the star structure and the sub-circuit of the quantum circuit with the star structure are difficult in the related technology is solved, the quantum circuit with the star structure and the optimal compiling of the sub-circuit of the quantum circuit with the star structure can be realized, so that the width of the compiled quantum circuit can be minimized, namely, the quantum circuit with the star structure or the sub-circuit of the quantum circuit with the star structure can be compiled into a dynamic quantum circuit with the minimum number of required quantum bits equivalent to the quantum circuit with the star structure, and therefore, the classical simulation and true operation of the quantum circuit with the star structure and the sub-circuit of the quantum circuit with the star structure can be simplified.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a flow diagram of a quantum circuit processing method according to a first embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an exemplary static quantum circuit;
FIG. 3 is a schematic diagram of another example static quantum circuit structure;
FIG. 4 is a schematic diagram of a compiled dynamic quantum circuit of the quantum circuit of FIG. 3;
FIG. 5 is a schematic diagram of an exemplary star-structured quantum circuit;
FIG. 6 is a schematic diagram of a quantum circuit of another example star configuration;
FIG. 7 is a schematic diagram of a sub-circuit of an exemplary star-structured quantum circuit;
FIG. 8 is a schematic diagram of a compiled dynamic quantum circuit of the quantum circuit of FIG. 6;
fig. 9 is a schematic structural view of a quantum circuit processing apparatus according to a second embodiment of the present disclosure;
fig. 10 is a schematic block diagram of an example electronic device used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
First embodiment
As shown in fig. 1, the present disclosure provides a quantum circuit processing method, including the steps of:
step S101: obtaining a first instruction list of a first quantum circuit comprising N quantum bits, the first quantum circuit being: the quantum circuit of the star structure or the sub-circuit of the quantum circuit of the star structure, N quantum bits in the quantum circuit of the star structure are sequentially arranged according to the quantum bit of the quantum bit 0 to the quantum bit of the quantum bit N-1, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence of the quantum bit from small to large, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except for the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the quantum circuit of the star structure, and N is an integer larger than 2.
In this embodiment, the quantum circuit processing method relates to the technical field of quantum computing, in particular to the technical field of quantum circuits, and can be widely applied to quantum circuits with star structures, and classical simulation and true operation scenes of sub-circuits of the quantum circuits with the star structures. The quantum circuit processing method of the embodiment of the present disclosure may be performed by the quantum circuit processing apparatus of the embodiment of the present disclosure. The quantum circuit processing apparatus of the embodiments of the present disclosure may be configured in any electronic device to perform the quantum circuit processing method of the embodiments of the present disclosure.
Currently, the mainstream quantum computing implementation is based on a quantum circuit model, that is, a series of quantum gates act on the quantum bits to complete the evolution of the quantum state, and quantum measurement is performed at the end of the circuit to obtain a computing result. The quantum circuits currently in common use in the industry are static quantum circuits, i.e. quantum circuits that contain measurement operations only at the ends of the circuit.
With the recent rapid development of hardware (mainly the significant increase of the coherence time of qubits and the realization of high-fidelity intermediate state measurement and reset operations), dynamic quantum circuits including intermediate measurement and reset operations have been increasingly receiving attention from the industry. Due to the introduction of intermediate measurement of the circuit, the dynamic quantum circuit can effectively combine quantum computation with real-time classical computation and communication within the coherence time of the quantum bit. This feature greatly increases the variety of computational tasks that can be accomplished by quantum circuit models. For example, with intermediate measurements of dynamic quantum circuits, a feed-forward operation may be implemented in the circuit operation, i.e. deciding what quantum gate to act next based on the results obtained from the intermediate measurements, or discarding the current calculation results to restart the calculation task. Such functionality is very important in quantum error correction and fault tolerant quantum computing. It is therefore expected that dynamic quantum circuits will become an important component of various quantum algorithms and quantum applications in the future.
Since the qubits in the dynamic quantum circuit can be reset and used continuously in the subsequent calculation process, the dynamic quantum circuit can effectively reduce the number of the qubits required for the calculation task without any influence on the calculation capability in theory compared with the static quantum circuit under the condition of running the same quantum algorithm. For example, the Berstein-Vazirani algorithm, which requires n qubits in static circuits, can be implemented with only 2 qubits in dynamic quantum circuits.
The existing quantum circuit simulation mode can support an algorithm for simulating tens of quantum bits at most under the limitation of the memory and the processor capacity of a computer. For example, notebooks can simulate around 20-30 qubits, and large supercomputers and clusters can simulate up to around 30-40 qubits. On the true machine operation, the problem of scalability of the current quantum chip is not solved, so that the number of quantum bits which can be provided by a quantum computer is very limited. Quantum circuit optimization is therefore a fundamental problem in the field of quantum computing.
The quantum circuit optimization is to equivalently compile a given quantum circuit into a dynamic quantum circuit by a certain technical means so as to reduce the number of quantum bits, thus reducing the requirements of classical simulation and true operation of the quantum circuit and accelerating the research of quantum algorithm and the landing of quantum calculation in an actual scene.
In this embodiment, the quantum circuit of the star structure or the sub-circuit of the quantum circuit of the star structure is compiled, so that the original quantum circuit can be greatly simplified in terms of the number of quantum bits. On one hand, the scale of the classical simulation of the quantum algorithm can be further improved, the verification capability of a classical computer on the quantum algorithm is enhanced, on the other hand, the bit number requirement of the quantum algorithm on the true machine operation can be reduced, and the defect of expandability of the current quantum chip is overcome. The quantum circuits of the star structure, and the sub-circuits of the quantum circuits of the star structure are important in the use scenarios of quantum algorithms such as Deutsch-Jozsa algorithm and Bernstein-Vazirani algorithm, etc.
The quantum circuit model is described in detail below.
Currently, quantum computing implementations can be based on quantum circuit models, i.e., the evolution of the quantum states is accomplished by acting a series of quantum gates on the qubits, and quantum measurements are made at the ends of the circuit to obtain the computation results. The quantum circuit diagram may represent the overall process of quantum circuit model computation.
Fig. 2 is a schematic diagram of an exemplary quantum circuit, and as shown in fig. 2, a qubit system may be represented by a horizontal line, where qubits of a qubit are numbered sequentially from top to bottom, where the qubit is often numbered from zero.
The time evolution direction in the quantum circuit diagram is from left to right, the leftmost end is an initial quantum state, wherein each quantum bit is initialized to be a zero state, and then different quantum gate operations are sequentially applied to the initial state to complete the evolution of the quantum state. Meanwhile, quantum measurement can be carried out on some qubits, and measurement results are obtained.
If one quantum circuit does not include operations such as reset and intermediate quantum measurement, and all measurement operations are located at the extreme end of the quantum circuit, such a quantum circuit is referred to as a static quantum circuit, and the quantum circuit shown in fig. 2 is referred to as a static quantum circuit.
The operations in a quantum circuit diagram may generally be represented in order of action by an ordered list of instructions, each element of the list representing an instruction for an operation.
Each quantum state preparation (or initialization) operation is represented as an instruction [ Reset, qubit, none ] containing four elements. For example, [ Reset,2, none ] means initializing the qubit of qubit 2 to a zero state.
Each single bit quantum gate (e.g., H, X, Y, Z, S, T, rx, ry, rz, etc.) is represented as an operation instruction [ name, qubit, parameter, condition ], where name is the name of the quantum gate, qubit is the qubit that the quantum gate acts on, parameter is the parameter of the quantum gate (default to None if no parameter is present), which indicates which qubit measurement the operation of the quantum gate is controlled by (default to None in standard quantum circuits). For example, [ Rx,2, pi, none ] represents acting an Rx rotation gate on the qubit on qubit 2, with a rotation angle pi.
Each two-bit quantum gate (e.g., control not gate CNOT, SWAP gate) is represented as an instruction containing four elements. Wherein name is the name of the quantum gate, qubit is a list of control bits and controlled bits, parameter is the parameter of the quantum gate (if no parameter is default to None), and condition parameter in the standard quantum circuit is default to None. For example, [ SWAP, [1,2], none ] represents the action of a SWAP gate between qubits 1 and 2; [ CNOT, [1,3], none ] represents a control NOT acting on qubit 1 and qubit 3, where qubit 1 is the control bit and qubit 3 is the control bit.
More generally, each multiple-quantum bit gate (e.g., CCX gate) is represented as an instruction containing four elements [ name, qubit, parameter, condition ]. Where name is the name of the quantum gate, qubit is a list of qubits acted on by the multiple quantum bit gate, parameter is a parameter of the quantum gate (no if there is no parameter), and condition indicates which qubit measurement the quantum gate operation is controlled by (None if there is no parameter).
The measurement under each computation is represented as an instruction containing four elements [ measure, qubit, none ]. For example, [ measure,2, none ] represents a measurement based on the calculation of qubit 2.
According to the instruction representation rules as above, the static quantum circuit in fig. 2 can be represented as an ordered list of instructions as follows: static_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ Reset,2, none ], [ H,0, none ], [ H,1, none ], [ H,2, none ], [ CNOT, [0,1], none ], [ SWAP, [1,2], none, none ], [ Rx,0, α, none ], [ Ry,1, β, none ], [ Rz,2, γ, none ], [ Measure,0, none, none ], [ Measure,1, none, none ], [ Measure,2, none, none ] ].
In some application scenarios, it may be allowed to measure some qubits in the middle of the quantum circuit and reset them to the |0> state after the measurement results for continued use by subsequent computations. And a quantum circuit that includes a circuit intermediate measurement and a reset operation is called a dynamic quantum circuit.
The static quantum circuit can be compiled into the dynamic quantum circuit through quantum circuit optimization, for example, the static quantum circuit shown in fig. 3 can be equivalently compiled into the dynamic quantum circuit shown in fig. 4, and compared with the original static quantum circuit, the number of quantum bits of the dynamic quantum circuit is reduced by one, but the operation effects of the two quantum circuits are equivalent.
The instruction list of the original static quantum circuit is as follows: static_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ Reset,2, none ], [ H,0, none ], [ H,1, none ], [ H,2, none ], [ CNOT, [0,1], none, none ], [ CNOT, [1,2], none, none ], [ Measure,0, none, none ], [ Measure,1, none, none ], [ Measure,2, none, none ] ]. The compiled instruction list of the dynamic quantum circuit is as follows: dynamic_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ H,0, none ], [ H,1, none ], [ CNOT, [0,1], none ], [ Measure ], 0, none ], [ Reset,0, none ], [ H,0, none ], [ CNOT, [1,0], none, none ], [ Measure,0, none ], [ Measure,1, none ] ].
The aim of this embodiment is to compile a given static quantum circuit into its equivalent dynamic quantum circuit and to minimize the number of qubits required for the compiled quantum circuit.
In step S101, the first quantum circuit may be a static quantum circuit, and the first quantum circuit is a quantum circuit with a star structure or a sub-circuit of a quantum circuit with a star structure. The quantum circuit of the star structure is a quantum circuit widely used in quantum algorithms such as Deutsch-Jozsa algorithm and Bernstein-Vazirani algorithm.
The connectivity of the quantum circuit with the star structure is provided with a unified public quantum bit, namely a target quantum bit, such as the quantum bit of the quantum bit N-1, namely the last quantum bit, and all other quantum bits respectively act with a double-quantum bit gate between the target quantum bit and the quantum bit according to the sequence from the small quantum bit to the large quantum bit, and the corresponding topological structure is a star structure, which is called as a star structure. The double-qubit gate can be a CNOT gate, a SWAP gate, or other double-qubit gates.
Fig. 5 is a schematic structural diagram of an exemplary star-shaped quantum circuit, and as shown in fig. 5, the star-shaped quantum circuit includes 4 qubits, the last qubit is taken as a target qubit, and a qubit of qubit 0, a qubit of qubit 1 and a qubit of qubit 2 sequentially act as a double-qubit gate with a qubit of qubit 3.
The first instruction list of the first quantum circuit stored in advance may be acquired, the first instruction list of the first quantum circuit input by the user may be acquired, or the first instruction list of the first quantum circuit may be acquired based on the instruction list of the third quantum circuit equivalent to the first quantum circuit, which is not particularly limited herein.
The instruction list for the quantum circuit in fig. 5 is: static_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ Reset,2, none ], [ Reset,3, none ], [ CNOT, [0,3], none ], [ CNOT, [1,3], none ], [ CNOT, [2,3], none ], [ Measure,0, none ], [ Measure,1, none ], [ Measure,2, none ], [ Measure,3, none ].
In addition, in the case that the first quantum circuit is a sub-circuit of a quantum circuit having a star structure, the first instruction list of the first quantum circuit may be determined based on an instruction list of a quantum circuit having a star structure, which is an ordered subset of the quantum circuit having a star structure, that is, a part of the operation instruction is deleted from the instruction list of the quantum circuit having a star structure, to obtain the first instruction list.
Step S102: based on the first instruction list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit; wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
In this step, the second quantum circuit may be a dynamic quantum circuit.
When equivalent compiling is carried out, the first measurement operation instructions in the first instruction list can be sequentially obtained, and for each first measurement operation instruction, based on the qubit i acted by the first measurement operation instruction, a first reset operation instruction on the qubit i is added after the first measurement operation instruction, and each target operation instruction in the first instruction list is remapped to the qubit of the qubit i. The first measurement operation instruction is a measurement operation instruction acting on the qubit 0, the qubit 1 … and the qubit N-3, respectively.
If N is 3, the first measurement operation instruction is a measurement operation instruction acting on qubit 0. That is, at the time of equivalent compilation, a reset operation instruction on the qubit 0 is added after a measurement operation instruction on the qubit 0, and a target operation instruction acting on the qubit 1 in the first instruction list is remapped and mapped onto the qubit of the qubit 0, so that a second instruction list of a second quantum circuit equivalent to the first quantum circuit is obtained.
If N is 4, the first measurement operation instruction is a measurement operation instruction acting on qubit 0 and qubit 1, respectively. That is, during equivalent compiling, firstly, for the measurement operation instruction on the qubit 0, after the measurement operation instruction on the qubit 0, a reset operation instruction on the qubit 0 is added, and the target operation instruction acting on the qubit 1 in the first instruction list is remapped, and mapped to the qubit of the qubit 0. Then, for the measurement operation instruction on the qubit 1, adding a reset operation instruction on the qubit 1 after the measurement operation instruction on the qubit 1, remapping the target operation instruction acting on the qubit 2 in the first instruction list, and mapping the target operation instruction to the qubit of the qubit 1, thereby obtaining a second instruction list of a second quantum circuit equivalent to the first quantum circuit.
In this way, after the operation instruction of the quantum measurement operation is equivalently compiled, the operation instruction of the reset operation can be added after the operation instruction of the quantum measurement operation, and the register unit allocated to the quantum bit i can be recovered through the reset operation instruction so as to be used for the quantum bit of the quantum bit i+1 continuously, so that the quantum bit number of the second quantum circuit obtained by compiling is reduced.
In an alternative embodiment, the equivalent compiling of the first quantum circuit may be directly performed based on the first instruction list, that is, the first measurement operation instruction and the target operation instruction are respectively obtained through traversing the first instruction list, and the equivalent compiling of the first quantum circuit is performed. In another alternative embodiment, a directed acyclic graph may be constructed based on the first instruction list, and equivalent compilation of the first quantum circuit is performed based on the directed acyclic graph.
In the related art, a heuristic algorithm is generally adopted to compile a quantum circuit, so that the optimality of circuit compilation cannot be ensured, if an optimal compiling scheme is given through mathematical modeling of circuit compilation, however, the algorithm complexity increases exponentially with the number of quantum bits, and the compiling efficiency of a larger-scale circuit is very low. In this embodiment, for the structural specificity of the quantum circuit with a star structure, the qubit of the qubit i may be reset after being measured, and all the operation instructions acting on the qubit of the qubit i+1 are remapped to the qubit of the qubit i for execution, where the rule is obtained by proof of theory based on the circuit structure.
In terms of time complexity, the embodiment does not need to construct a complex mathematical model, so that the compiling process is simple, the running time can linearly increase along with N, and the compiling is very efficient. In the compiling effect, the compiled dynamic quantum circuit only needs 2 quantum bits. It can be theoretically proven that the compiling scheme in this embodiment is the optimal compiling scheme, that is, it is impossible to have a compiling scheme such that the compiled circuit width is less than 2. In this way, the embodiment provides an optimal compiling mode of the quantum circuit with the star structure and the sub-circuit of the quantum circuit with the star structure, which can be directly applied to corresponding scenes without complex calculation and optimization.
And the quantum computer based on different architecture designs can provide different quantum bit numbers and different realization capacities of various operations. Through equivalent compiling, the running scheme of the quantum circuit on a real quantum computer can be more flexible, and the dynamic quantum circuit and the static quantum circuit can be flexibly selected according to actual hardware conditions. For example, for a superconducting quantum computer with shorter coherence time but easy expansion of the number of quantum bits, it is more suitable for running a static quantum circuit with larger width and smaller depth; for a quantum computer based on an ion trap architecture, which has longer coherence time but relatively poorer expansibility, the quantum computer is more suitable for running a dynamic quantum circuit with smaller width and larger depth.
Optionally, the first quantum circuit further includes at least one single-quantum bit gate, where the single-quantum bit gate is located at any position of the first quantum circuit.
The equivalent compiling process in this embodiment is irrelevant to the information such as the number, the type, the specific execution position and the like of the single-quantum bit gates, and therefore, the first quantum circuit in this embodiment may further include the single-quantum bit gates under the condition that the first quantum circuit is guaranteed to be of a star-shaped structure or is a sub-circuit of the quantum circuit of the star-shaped structure.
Fig. 6 is a schematic diagram of a quantum circuit of another example star structure, and as shown in fig. 6, a single qubit gate may be added at any position of the quantum circuit shown in fig. 5, or a CNOT gate may be replaced with another double qubit gate. The quantum circuit is a star-structured quantum circuit as long as the double-quantum bit gate of the quantum circuit satisfies the star-structured structure.
For the star-structured quantum circuit shown in fig. 6, the instruction list is static_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ Reset,2, none ], [ Reset,3, none ], [ H,0, none ], [ S,1, none ], [ T,2, none ], [ H,3, none ], [ CNOT, [0,3], none, none ], [ Z,1, none, none ], [ CNOT, [1,3], none, none ], [ CNOT, [2,3], none, none ], [ Rx,0,0.5, none ], [ Rz,1,0.1, none ], [ Measure,0, none ], [ Measure,1, none, none ], [ Measure,2, none, none ], [ Measure,3, none, none ] ].
Fig. 7 is a schematic diagram of a sub-circuit of an exemplary star-structured quantum circuit, as shown in fig. 7, which is a quantum circuit obtained by deleting a part of the operation instruction of the double-quantum bit gate on the basis of fig. 6.
Thus, the application range of the original quantum circuit processed by the quantum circuit can be enlarged.
Optionally, the step S102 specifically includes:
determining a first directed acyclic graph based on the first instruction list, wherein the first directed acyclic graph comprises nodes corresponding to operation instructions in the first instruction list and first directed edges, and the first directed edges are used for representing time sequence relations among different operation instructions in the first instruction list;
adding a second directed edge in the first directed acyclic graph to obtain a directed edge list formed by the second directed acyclic graph and the second directed edge, wherein the second directed edge comprises a directed edge from an output node corresponding to the first measurement operation instruction to an input node corresponding to a second reset operation instruction, and the second reset operation instruction is a reset operation instruction acting on the qubit i+1;
and based on the second directed acyclic graph and the directed edge list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit.
In an alternative embodiment, the first instruction list may be traversed in order of instruction arrangement from left to right, and the first directed acyclic graph may be constructed by looking up nearest-neighbor operation instructions where the acted qubits intersect with the qubits acted by the operation instruction currently traversed.
In another optional embodiment, optionally, the determining, based on the first instruction list, a first directed acyclic graph includes:
traversing the first instruction list according to the arrangement sequence of the operation instructions;
taking the currently traversed operation instruction as a node, and adding an operation instruction corresponding node positioned at the tail of the target list to a first directed edge of the currently traversed operation instruction corresponding node under the condition that the target list is not an empty list; the target list is a list corresponding to the qubit acted by the currently traversed operation instruction;
and adding the currently traversed operation instruction to the tail end of the target list, and obtaining the first directed acyclic graph under the condition that the first instruction list is traversed.
That is, the preamble operation instruction of the operation instruction currently traversed is stored by constructing N target lists of N quantum bits in one-to-one correspondence. And acquiring a target list corresponding to the qubit based on the qubit acted by the currently traversed operation instruction, wherein the qubit acted by the operation instruction in the target list has an intersection with the qubit acted by the currently traversed operation instruction. And selecting the operation instruction nearest to the target list, namely the operation instruction at the tail in the target list, so as to construct a first directed edge. Thus, the construction process of the first directed acyclic graph can be simplified, and efficient construction of the first directed acyclic graph can be realized.
Further, a second directed edge is added in the first directed acyclic graph to obtain a directed edge list formed by the second directed acyclic graph and the second directed edge, wherein the second directed edge comprises the directed edge from the output node corresponding to the first measurement operation instruction to the input node corresponding to the second reset operation instruction, and the second reset operation instruction is a reset operation instruction acting on the qubit i+1. For example, if N is 3, the second directed edge is the directed edge from the output node corresponding to the measurement operation command acting on qubit 0 to the input node corresponding to the reset operation command acting on qubit 1. For another example, if N is 4, the second directed edge includes: the measurement operation instruction acting on qubit 0 corresponds to the directed edge of the output node to the reset operation instruction acting on qubit 1 corresponds to the input node, and the measurement operation instruction acting on qubit 1 corresponds to the directed edge of the output node to the reset operation instruction acting on qubit 2 corresponds to the input node.
And then, based on the second directed acyclic graph and the directed edge list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit. Optionally, the performing equivalent compiling on the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit, including:
Obtaining the topological order of the operation instructions corresponding to the second directed acyclic graph to obtain a third instruction list;
and remapping each target operation instruction corresponding to the qubit acted by the input node of the second directed edge in the third instruction list to the qubit acted by the output node of the second directed edge aiming at each second directed edge in the directed edge list to obtain the second instruction list.
The optimal compilation process of the first quantum circuit is as follows:
input: a first instruction list circuit_list of the first quantum circuit, a circuit width N (N > 2);
and (3) outputting: a second list of instructions for the compiled dynamic quantum circuit.
Step 1: initializing an empty directed acyclic graph;
step 2: initializing a target list causellists with the length of N, wherein each element is an empty list;
step 3: looping around the circuit_list, assuming that the currently looped element is an instrucition:
step 3.1: taking out a qubit value in an instruction, circulating, setting a circulated element as q, taking the instruction as a node, and adding the node into a directed acyclic graph; searching the last element of the target list causel_list [ q ], and recording as a preinstruction; if the preinstruction is not a null element, adding a first directed edge to the directed acyclic graph, from the preinstruction to the instruction; add instruction to the last of list causellists q;
Step 4: initializing an empty list add_edges (i.e., a directed edge list);
step 5: for the variable i e {0, & gtis, N-3) cycle:
step 5.1: adding a second directed edge to the directed acyclic graph, pointing from a measurement operation instruction acting on qubit i to a reset operation instruction acting on qubit i+1, while adding the directed edge to the add_edges list;
step 6: obtaining topological ordering of all circuit instructions according to the directed acyclic graph digraph, and recording the topological ordering in a circuit_list;
step 7: cycling the add_edges list, and setting the variable of the current cycle as edge:
step 7.1: let the presuppression and posinstruction represent the output node and input node of the directed edge respectively;
step 7.2: the quantum bits under the action of the two operation instructions of the preinstruction and the postinstruction are respectively a prequbit and a postqubit; circularly traversing the circuit_list list, and updating all target operation instructions acting on the quantum bit postqubit to act on the quantum bit prequbit;
step 8: the circuit_list is returned as output.
In this way, an equivalent compilation of the quantum circuits of the star structure and the sub-circuits of the quantum circuits of the star structure can be achieved by means of directed acyclic graphs, the implementation process being very simple.
For the quantum circuit in fig. 6, the dynamic quantum circuit obtained by compiling the scheme in this embodiment is shown in fig. 8, and the corresponding circuit instruction list is: dynamic_circuit= [ [ Reset,0, none ], [ Reset,1, none ], [ H,0, none ], [ H,1, none ], [ CNOT, [0,1], none ], [ Rx,0,0.5, none ], [ Mecure, 0, none ], [ Reset,0, none ], [ S,0, none ], [ Z,0, none ], [ CNOT, [0,1], none ], [ Rz,0,0.1, none ], [ Measure,0, none ], [ Reset,0, none ], [ T,0, none ], [ CNOT, [0,1], none ], [ Measure,0, none ], [ Measure,1, none ] ]. The quantum bit number of the dynamic quantum circuit is 2, and the method is an optimal compiling scheme.
Optionally, in the case where the first quantum circuit is a quantum circuit with a star structure, the step S101 specifically includes:
adding a reset operation instruction of each qubit in the first quantum circuit to a circuit list;
determining a first qubit of the target qubit, and adding an operation instruction of each double-qubit gate between the qubits of other qubits except the first qubit in the first quantum circuit and the target qubit to a circuit list according to the sequence of the qubits from small to large;
And adding a quantum measurement operation instruction of each quantum bit in the first quantum circuit to a circuit list to obtain the first instruction list.
A specific acquisition procedure of a circuit instruction list of a quantum circuit of a star structure containing N quantum bits is as follows. The target qubit may be a qubit of the qubit N-1, i.e., the last qubit in the quantum circuit.
Input: quantum circuit width N;
and (3) outputting: instruction list of quantum circuits in star configuration.
Step 1: initializing an empty list circuit_list;
step 2: for the variable i e {0,1, · ·, N-1) cycle:
step 2.1: adding a Reset operation instruction [ Reset, i, none ] to the end of the list circuit_list;
step 3: for the variable i e {0,1, · ·, N-2) cycle:
step 3.1: adding an operation instruction of the double-quantum bit gate, such as [ CNOT, [ i, N-1], none ] to the end of the list circuit_list;
step 4: for the variable i e {0,1, · ·, N-1) cycle:
step 4.1: adding a circuit instruction [ Measure, i, none ] to the end of the list circuit_list;
step 5: the circuit_list is returned as output.
Thus, the first instruction list of the quantum circuit with the star structure can be obtained by inputting the structure information of the quantum circuit with the star structure, and the process is simple.
In the case that the first quantum circuit is a quantum circuit with a star structure, optionally, before step S101, the method further includes:
performing displacement mapping on a third quantum circuit comprising N quantum bits, so that the N quantum bits in the third quantum circuit are orderly arranged according to the quantum bits from the quantum bit 0 to the quantum bit N-1;
and determining that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after the replacement mapping is a quantum circuit with a star structure.
For the third quantum circuit which is not the standard quantum circuit, the third quantum circuit can be converted into the standard quantum circuit, and if the standard quantum circuit obtained after conversion is a quantum circuit with a star structure, the third quantum circuit is equivalent to the first quantum circuit. In the standard quantum circuit, N quantum bits are sequentially arranged according to the quantum bit of the quantum bit 0 to the quantum bit of the quantum bit N-1.
Thus, the application range of the original quantum circuit processed by the quantum circuit can be enlarged.
Optionally, in the case where the third quantum circuit after the substitution mapping is a quantum circuit with a star structure, the step S101 specifically includes:
Acquiring a fourth instruction list of the third quantum circuit;
replacing a first number list of N quantum bits in the third quantum circuit to obtain a second number list, wherein the second number list is sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1;
and transforming the qubit acted by the operation instruction in the fourth instruction list based on the mapping relation between the first number list and the second number list to obtain the first instruction list.
The first number list of N quantum bits in the third quantum circuit may be permuted based on a permutation matrix, to obtain a second number list, where the permutation matrix may be input or preset by a user. Then, based on the mapping relationship between the first numbering list and the second numbering list, for example, the qubit 2 in the third quantum circuit is mapped to the qubit 0 in the first quantum circuit, the qubit acted by the operation instruction in the fourth instruction list is transformed, for example, the operation instruction acted on the qubit 2 in the fourth instruction list is remapped to the qubit 0, so as to obtain the first instruction list of the first quantum circuit.
In this way, the acquisition of the instruction list of the first quantum circuit can be realized based on the instruction list of the third quantum circuit equivalent to the first quantum circuit.
Second embodiment
As shown in fig. 9, the present disclosure provides a quantum circuit processing apparatus 900, comprising:
an obtaining module 901, configured to obtain a first instruction list of a first quantum circuit including N quantum bits, where the first quantum circuit is: the quantum circuit comprises a star-shaped structure quantum circuit or a sub-circuit of the star-shaped structure quantum circuit, wherein N quantum bits in the star-shaped structure quantum circuit are sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1 of the quantum bit, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence from small to large of the quantum bit, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the star-shaped structure quantum circuit, and N is an integer larger than 2;
The equivalent compiling module 902 is configured to perform equivalent compiling on the first quantum circuit based on the first instruction list, to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit;
wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
Optionally, the equivalent compiling module 902 includes:
the determining unit is used for determining a first directed acyclic graph based on the first instruction list, wherein the first directed acyclic graph comprises nodes corresponding to operation instructions in the first instruction list and first directed edges, and the first directed edges are used for representing time sequence relations among different operation instructions in the first instruction list;
The adding unit is used for adding a second directed edge in the first directed acyclic graph to obtain a directed edge list formed by the second directed acyclic graph and the second directed edge, wherein the second directed edge comprises the directed edge from the output node corresponding to the first measurement operation instruction to the input node corresponding to the second reset operation instruction, and the second reset operation instruction is a reset operation instruction acting on the qubit i+1;
and the equivalent compiling unit is used for carrying out equivalent compiling on the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit.
Optionally, the determining unit is specifically configured to:
traversing the first instruction list according to the arrangement sequence of the operation instructions;
taking the currently traversed operation instruction as a node, and adding an operation instruction corresponding node positioned at the tail of the target list to a first directed edge of the currently traversed operation instruction corresponding node under the condition that the target list is not an empty list; the target list is a list corresponding to the qubit acted by the currently traversed operation instruction;
And adding the currently traversed operation instruction to the tail end of the target list, and obtaining the first directed acyclic graph under the condition that the first instruction list is traversed.
Optionally, the equivalent compiling unit is specifically configured to:
obtaining the topological order of the operation instructions corresponding to the second directed acyclic graph to obtain a third instruction list;
and remapping each target operation instruction corresponding to the qubit acted by the input node of the second directed edge in the third instruction list to the qubit acted by the output node of the second directed edge aiming at each second directed edge in the directed edge list to obtain the second instruction list.
Optionally, in the case where the first quantum circuit is a quantum circuit with a star structure, the acquiring module 901 is specifically configured to:
adding a reset operation instruction of each qubit in the first quantum circuit to a circuit list;
determining a first qubit of the target qubit, and adding an operation instruction of each double-qubit gate between the qubits of other qubits except the first qubit in the first quantum circuit and the target qubit to a circuit list according to the sequence of the qubits from small to large;
And adding a quantum measurement operation instruction of each quantum bit in the first quantum circuit to a circuit list to obtain the first instruction list.
Optionally, the apparatus further includes:
the permutation mapping module is used for permutation mapping of a third quantum circuit comprising N quantum bits so as to orderly arrange the N quantum bits in the third quantum circuit according to the quantum bits from the quantum bit 0 to the quantum bit N-1;
and the determining module is used for determining that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after the substitution mapping is a quantum circuit with a star structure.
Optionally, in the case where the third quantum circuit after the substitution mapping is a quantum circuit with a star structure, the obtaining module 901 is specifically configured to:
acquiring a fourth instruction list of the third quantum circuit;
replacing a first number list of N quantum bits in the third quantum circuit to obtain a second number list, wherein the second number list is sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1;
and transforming the qubit acted by the operation instruction in the fourth instruction list based on the mapping relation between the first number list and the second number list to obtain the first instruction list.
Optionally, the first quantum circuit further includes at least one single-quantum bit gate, where the single-quantum bit gate is located at any position of the first quantum circuit.
The quantum circuit processing apparatus 900 provided in the present disclosure can implement each process implemented by the quantum circuit processing method embodiment, and can achieve the same beneficial effects, so that repetition is avoided, and no further description is provided herein.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
FIG. 10 illustrates a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 10, the apparatus 1000 includes a computing unit 1001 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
Various components in device 1000 are connected to I/O interface 1005, including: an input unit 1006 such as a keyboard, a mouse, and the like; an output unit 1007 such as various types of displays, speakers, and the like; a storage unit 1008 such as a magnetic disk, an optical disk, or the like; and communication unit 1009 such as a network card, modem, wireless communication transceiver, etc. Communication unit 1009 allows device 1000 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks.
The computing unit 1001 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 1001 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the respective methods and processes described above, for example, a quantum circuit processing method. For example, in some embodiments, the quantum circuit processing method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 1000 via ROM 1002 and/or communication unit 1009. When a computer program is loaded into RAM 1003 and executed by computing unit 1001, one or more steps of the quantum circuit processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform the quantum circuit processing method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (19)

1. A quantum circuit processing method, comprising:
obtaining a first instruction list of a first quantum circuit comprising N quantum bits, the first quantum circuit being: the quantum circuit comprises a star-shaped structure quantum circuit or a sub-circuit of the star-shaped structure quantum circuit, wherein N quantum bits in the star-shaped structure quantum circuit are sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1 of the quantum bit, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence from small to large of the quantum bit, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the star-shaped structure quantum circuit, and N is an integer larger than 2;
Based on the first instruction list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit;
wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
2. The method of claim 1, wherein the equivalently compiling the first quantum circuit based on the first instruction list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit comprises:
determining a first directed acyclic graph based on the first instruction list, wherein the first directed acyclic graph comprises nodes corresponding to operation instructions in the first instruction list and first directed edges, and the first directed edges are used for representing time sequence relations among different operation instructions in the first instruction list;
Adding a second directed edge in the first directed acyclic graph to obtain a directed edge list formed by the second directed acyclic graph and the second directed edge, wherein the second directed edge comprises a directed edge from an output node corresponding to the first measurement operation instruction to an input node corresponding to a second reset operation instruction, and the second reset operation instruction is a reset operation instruction acting on the qubit i+1;
and based on the second directed acyclic graph and the directed edge list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit.
3. The method of claim 2, wherein the determining a first directed acyclic graph based on the first list of instructions comprises:
traversing the first instruction list according to the arrangement sequence of the operation instructions;
taking the currently traversed operation instruction as a node, and adding an operation instruction corresponding node positioned at the tail of the target list to a first directed edge of the currently traversed operation instruction corresponding node under the condition that the target list is not an empty list; the target list is a list corresponding to the qubit acted by the currently traversed operation instruction;
And adding the currently traversed operation instruction to the tail end of the target list, and obtaining the first directed acyclic graph under the condition that the first instruction list is traversed.
4. The method of claim 2, wherein the equivalently compiling the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit comprises:
obtaining the topological order of the operation instructions corresponding to the second directed acyclic graph to obtain a third instruction list;
and remapping each target operation instruction corresponding to the qubit acted by the input node of the second directed edge in the third instruction list to the qubit acted by the output node of the second directed edge aiming at each second directed edge in the directed edge list to obtain the second instruction list.
5. The method of claim 1, wherein, in the case where the first quantum circuit is a quantum circuit of a star structure, the obtaining the first instruction list of the first quantum circuit including N quantum bits comprises:
adding a reset operation instruction of each qubit in the first quantum circuit to a circuit list;
Determining a first qubit of the target qubit, and adding an operation instruction of each double-qubit gate between the qubits of other qubits except the first qubit in the first quantum circuit and the target qubit to a circuit list according to the sequence of the qubits from small to large;
and adding a quantum measurement operation instruction of each quantum bit in the first quantum circuit to a circuit list to obtain the first instruction list.
6. The method of claim 1, prior to the fetching of the first instruction list of the first quantum circuit comprising N quantum bits, further comprising:
performing displacement mapping on a third quantum circuit comprising N quantum bits, so that the N quantum bits in the third quantum circuit are orderly arranged according to the quantum bits from the quantum bit 0 to the quantum bit N-1;
and determining that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after the replacement mapping is a quantum circuit with a star structure.
7. The method of claim 6, wherein, in the case where the third quantum circuit after permutation mapping is a quantum circuit of a star structure, the obtaining the first instruction list of the first quantum circuit including N quantum bits includes:
Acquiring a fourth instruction list of the third quantum circuit;
replacing a first number list of N quantum bits in the third quantum circuit to obtain a second number list, wherein the second number list is sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1;
and transforming the qubit acted by the operation instruction in the fourth instruction list based on the mapping relation between the first number list and the second number list to obtain the first instruction list.
8. The method of claim 1, wherein the first quantum circuit further comprises at least one single-qubit gate therein, the single-qubit gate being located anywhere in the first quantum circuit.
9. A quantum circuit processing apparatus comprising:
an acquisition module, configured to acquire a first instruction list of a first quantum circuit including N quantum bits, the first quantum circuit being: the quantum circuit comprises a star-shaped structure quantum circuit or a sub-circuit of the star-shaped structure quantum circuit, wherein N quantum bits in the star-shaped structure quantum circuit are sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1 of the quantum bit, a double-quantum bit gate acts between each first quantum bit and a target quantum bit respectively according to the sequence from small to large of the quantum bit, the target quantum bit is any quantum bit among the N quantum bits, the first quantum bit is other quantum bits except the target quantum bit in the N quantum bits, the sub-circuit is a quantum circuit obtained by deleting part of operation instructions from an instruction list of the star-shaped structure quantum circuit, and N is an integer larger than 2;
The equivalent compiling module is used for carrying out equivalent compiling on the first quantum circuit based on the first instruction list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit;
wherein the number of qubits of the second quantum circuit is smaller than the number of qubits of the first quantum circuit, the equivalent compilation comprising: adding a first reset operation instruction after a first measurement operation instruction in the first instruction list; and remapping each target operation instruction in the first instruction list to a qubit of a qubit i, wherein the first measurement operation instruction and the first reset operation instruction both act on the qubit i, the target operation instruction acts on a qubit i+1, and the value range of i is [0, N-3].
10. The apparatus of claim 9, wherein the equivalent compiling module comprises:
the determining unit is used for determining a first directed acyclic graph based on the first instruction list, wherein the first directed acyclic graph comprises nodes corresponding to operation instructions in the first instruction list and first directed edges, and the first directed edges are used for representing time sequence relations among different operation instructions in the first instruction list;
The adding unit is used for adding a second directed edge in the first directed acyclic graph to obtain a directed edge list formed by the second directed acyclic graph and the second directed edge, wherein the second directed edge comprises the directed edge from the output node corresponding to the first measurement operation instruction to the input node corresponding to the second reset operation instruction, and the second reset operation instruction is a reset operation instruction acting on the qubit i+1;
and the equivalent compiling unit is used for carrying out equivalent compiling on the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second instruction list of a second quantum circuit equivalent to the first quantum circuit.
11. The apparatus according to claim 10, wherein the determining unit is specifically configured to:
traversing the first instruction list according to the arrangement sequence of the operation instructions;
taking the currently traversed operation instruction as a node, and adding an operation instruction corresponding node positioned at the tail of the target list to a first directed edge of the currently traversed operation instruction corresponding node under the condition that the target list is not an empty list; the target list is a list corresponding to the qubit acted by the currently traversed operation instruction;
And adding the currently traversed operation instruction to the tail end of the target list, and obtaining the first directed acyclic graph under the condition that the first instruction list is traversed.
12. The apparatus of claim 10, wherein the equivalent compiling unit is specifically configured to:
obtaining the topological order of the operation instructions corresponding to the second directed acyclic graph to obtain a third instruction list;
and remapping each target operation instruction corresponding to the qubit acted by the input node of the second directed edge in the third instruction list to the qubit acted by the output node of the second directed edge aiming at each second directed edge in the directed edge list to obtain the second instruction list.
13. The apparatus of claim 9, wherein, in the case that the first quantum circuit is a quantum circuit of a star structure, the obtaining module is specifically configured to:
adding a reset operation instruction of each qubit in the first quantum circuit to a circuit list;
determining a first qubit of the target qubit, and adding an operation instruction of each double-qubit gate between the qubits of other qubits except the first qubit in the first quantum circuit and the target qubit to a circuit list according to the sequence of the qubits from small to large;
And adding a quantum measurement operation instruction of each quantum bit in the first quantum circuit to a circuit list to obtain the first instruction list.
14. The apparatus of claim 9, further comprising:
the permutation mapping module is used for permutation mapping of a third quantum circuit comprising N quantum bits so as to orderly arrange the N quantum bits in the third quantum circuit according to the quantum bits from the quantum bit 0 to the quantum bit N-1;
and the determining module is used for determining that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after the substitution mapping is a quantum circuit with a star structure.
15. The apparatus of claim 14, wherein, in the case where the third quantum circuit after the permutation mapping is a quantum circuit of a star structure, the obtaining module is specifically configured to:
acquiring a fourth instruction list of the third quantum circuit;
replacing a first number list of N quantum bits in the third quantum circuit to obtain a second number list, wherein the second number list is sequentially arranged according to quantum bits from quantum bit 0 to quantum bit N-1;
And transforming the qubit acted by the operation instruction in the fourth instruction list based on the mapping relation between the first number list and the second number list to obtain the first instruction list.
16. The apparatus of claim 9, wherein the first quantum circuit further comprises at least one single-qubit gate therein, the single-qubit gate being located anywhere in the first quantum circuit.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-8.
19. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-8.
CN202311268026.XA 2023-09-27 2023-09-27 Quantum circuit processing method and device and electronic equipment Pending CN117313883A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311268026.XA CN117313883A (en) 2023-09-27 2023-09-27 Quantum circuit processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311268026.XA CN117313883A (en) 2023-09-27 2023-09-27 Quantum circuit processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN117313883A true CN117313883A (en) 2023-12-29

Family

ID=89249428

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311268026.XA Pending CN117313883A (en) 2023-09-27 2023-09-27 Quantum circuit processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN117313883A (en)

Similar Documents

Publication Publication Date Title
CN109858628B (en) Method, apparatus, device and computer readable storage medium for compiling quantum circuit
WO2020151129A1 (en) Quantum machine learning framework construction method and apparatus, and quantum computer and computer storage medium
US20210201198A1 (en) Method, electronic device, and storage medium for generating node representations in heterogeneous graph
CN110825375B (en) Quantum program conversion method and device, storage medium and electronic device
CN114970865B (en) Quantum circuit processing method and device on quantum chip and electronic equipment
CN113190719B (en) Node grouping method and device and electronic equipment
CN114037082A (en) Quantum computing task processing method and system and computer equipment
CN115860128A (en) Quantum circuit operation method and device and electronic equipment
CN113646784A (en) Information processing device, information processing system, information processing method, storage medium, and program
CN116151381B (en) Quantum circuit processing method and device and electronic equipment
CN114580645A (en) Simulation method, device and equipment for random quantum measurement and storage medium
CN116151384B (en) Quantum circuit processing method and device and electronic equipment
CN116167446B (en) Quantum computing processing method and device and electronic equipment
CN117313883A (en) Quantum circuit processing method and device and electronic equipment
JP7341965B2 (en) Calculation device, calculation method and program
CN117313877A (en) Quantum circuit processing method and device and electronic equipment
CN117313879A (en) Quantum circuit processing method and device and electronic equipment
CN117313882A (en) Quantum circuit processing method and device and electronic equipment
CN117313878A (en) Quantum circuit processing method and device and electronic equipment
CN117313884A (en) Quantum circuit processing method and device and electronic equipment
CN116227607B (en) Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN116187458B (en) Quantum circuit processing method and device and electronic equipment
CN116579435B (en) Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN116611527B (en) Quantum circuit processing method and device and electronic equipment
CN117313881A (en) Quantum circuit classification method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination