Quantum circuit construction method and apparatus, and quantum computer operating system
By determining the set of isomorphic subgraphs of a quantum program and their costs, quantum circuits are constructed, solving the problem of multiple path selection in quantum computing and improving the efficiency and accuracy 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
- 2021-04-21
- Publication Date
- 2026-07-03
AI Technical Summary
In quantum computing, since different quantum computing platforms and chips support different sets of quantum logic gates, how to select one path from multiple paths to construct a quantum circuit is a technical problem that needs to be solved.
By determining the set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program, and constructing quantum circuits based on the fixed cost and exchange cost of the isomorphic subgraphs, the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the transformation between the quantum logic gates corresponding to the isomorphic subgraphs.
This technology enables the selection of an optimal path from multiple paths for constructing quantum circuits, thereby improving the efficiency and accuracy of quantum computing.
Smart Images

Figure CN115310612B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of quantum computing technology, and in particular to a method, apparatus and operating system for constructing quantum circuits and a quantum computer. Background Technology
[0002] Quantum logic circuits, also known as quantum circuits, are commonly used quantum computing models in the field of quantum computing. They represent, in an abstract sense, the circuitry that operates on qubits (qubits), and are a collection of various quantum logic gates. In quantum computing, simulation primarily involves processing quantum state vectors through the operation matrices of quantum logic gates within a quantum program to obtain the final state after processing. Quantum algorithms, described by quantum circuit models, are methods for manipulating quantum computers to process input states and output specific measurements. Because quantum computers offer significantly higher efficiency in processing mathematical problems compared to conventional computers when running quantum algorithms, they have become a key technology under research.
[0003] In the practical implementation of quantum computing, different quantum computing platforms include different quantum chips, and different quantum computing chips support different sets of quantum logic gates. Therefore, it is necessary to convert quantum programs into quantum circuits supported by the current quantum chips. However, multiple paths may exist during the conversion process, resulting in more than one quantum circuit. Therefore, how to select one path from multiple paths to construct the quantum circuit is a technical problem that needs to be solved. Summary of the Invention
[0004] This application provides a quantum circuit construction method, apparatus, and quantum computer operating system for selecting one path from multiple paths to construct a quantum circuit.
[0005] In a first aspect, embodiments of this application provide a method for constructing quantum circuits, the method comprising:
[0006] The set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program is determined. The N largest subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the quantum chip in the electronic device based on the N largest subgraphs. N is an integer greater than or equal to 1.
[0007] Determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and construct a quantum circuit based on the fixed cost and the exchange cost; the sum of the fixed cost and the exchange cost of the quantum circuit is minimized.
[0008] The fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraph, and the exchange cost is determined based on the SWAP gates required for the conversion between the quantum logic gates corresponding to the isomorphic subgraph.
[0009] Optionally, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the determination of the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and the construction of quantum circuits based on the fixed cost and the exchange cost, includes:
[0010] Determine the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets to obtain N fixed cost sets, and the N fixed cost sets correspond one-to-one with the N isomorphic subgraph sets;
[0011] Determine the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets among the N isomorphic subgraph sets, resulting in N-1 sets of exchange costs, each set of exchange costs including k. i ·k i+1 Exchange cost;
[0012] Based on the N fixed cost sets and the N-1 exchange cost sets, determine Individual consumption costs;
[0013] Based on the above Constructing quantum circuits incurs significant costs.
[0014] Optionally, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the determination of the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and the construction of quantum circuits based on the fixed cost and the exchange cost, includes:
[0015] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0016] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0017] Determine the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set, and obtain k. i There are k0 sets of exchange costs;
[0018] Based on the first fixed cost set, the second fixed cost set, and k i The set of exchange costs determines k i There are k0 sets of consumption costs;
[0019] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k. i The minimum consumption cost, namely k i The minimum consumption cost and k in the second isomorphic subgraph set i a second isomorphism Figure 1 One-to-one correspondence;
[0020] k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph;
[0021] k i The set consisting of a new first isomorphic subgraph is determined as the new first isomorphic subgraph set;
[0022] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0023] When i = N-1, based on the obtained k N-1 Constructing quantum circuits at minimal cost.
[0024] Optionally, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the determination of the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and the construction of quantum circuits based on the fixed cost and the exchange cost, includes:
[0025] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0026] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0027] Determine the exchange costs between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set, resulting in k0 sets of exchange costs, each set containing k... i Exchange cost;
[0028] Based on the first fixed cost set, the second fixed cost set, and the k0 exchange cost sets, k0 consumption cost sets are determined, each consumption cost set including k i Individual consumption costs;
[0029] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k0 minimum consumption costs. These k0 minimum consumption costs are then compared with the k0 first isomorphic subgraphs in the first isomorphic subgraph set. Figure 1 One-to-one correspondence;
[0030] Each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph is combined to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs;
[0031] The set of the k0 new first isomorphic subgraphs is defined as the new first isomorphic subgraph set;
[0032] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0033] When i = N-1, construct quantum circuits based on the obtained k0 minimum cost values.
[0034] Optionally, the fixed cost and the exchange cost are determined based on fidelity.
[0035] Optionally, the fixed cost and the exchange cost are determined based on the number of CZ gates.
[0036] Secondly, embodiments of this application provide a quantum circuit construction apparatus, the apparatus comprising:
[0037] A determining unit is used to determine the set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program, wherein the N largest subgraphs are determined based on the directed acyclic graph of the quantum program, and N is an integer greater than or equal to 1;
[0038] A construction unit is used to determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and to construct quantum circuits based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
[0039] Thirdly, embodiments of this application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the steps of the method described in the first aspect of embodiments of this application.
[0040] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the method described in the first aspect of embodiments of this application.
[0041] Fifthly, embodiments of this application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to perform some or all of the steps described in the method described in the first aspect of embodiments of this application. The computer program product may be a software installation package.
[0042] In a sixth aspect, embodiments of this application provide a quantum computer operating system, wherein the quantum computer operating system implements the construction of the quantum circuit according to some or all of the steps described in the method described in the first aspect of embodiments of this application.
[0043] As can be seen in this embodiment, firstly, a set of N isomorphic subgraphs corresponding to the N maximal subgraphs of the quantum program is determined, and these N maximal subgraphs are determined based on the directed acyclic graph of the quantum program. Then, the fixed cost of each isomorphic subgraph in the set of N isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent set of isomorphic subgraphs are determined, and a quantum circuit is constructed based on the fixed cost and the exchange cost. The fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the transformation between the quantum logic gates corresponding to the isomorphic subgraphs. By constructing a quantum circuit based on the fixed cost and the exchange cost, it is possible to select one path from multiple paths for constructing the quantum circuit.
[0044] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A hardware structure block diagram of a computer terminal for a quantum circuit construction method provided in an embodiment of this application;
[0047] Figure 2A A flowchart illustrating a quantum circuit construction method provided in an embodiment of this application;
[0048] Figure 2B A schematic diagram of a quantum circuit structure provided in an embodiment of this application;
[0049] Figure 2C for Figure 2B A schematic diagram of the first directed acyclic graph corresponding to the quantum circuit shown;
[0050] Figure 2D For based on Figure 2C A schematic diagram of the first subgraph determined by the first node in the first directed acyclic graph.
[0051] Figure 2E for Figure 2C A schematic diagram of the second directed acyclic graph obtained after deleting the first node;
[0052] Figure 2F Based on the second node Figure 2D A schematic diagram of the second subgraph obtained by extending the above;
[0053] Figure 2G for Figure 2E A schematic diagram of the third directed acyclic graph obtained after deleting the second node;
[0054] Figure 2H Based on the new second node Figure 2F A schematic diagram of the second subgraph obtained by extending the above;
[0055] Figure 2I for Figure 2G A schematic diagram of the new first directed acyclic graph obtained after deleting the new second node;
[0056] Figure 2J For based on Figure 2I A schematic diagram of the first subgraph determined by the first node in the first directed acyclic graph.
[0057] Figure 2K for Figure 2J A schematic diagram of the second directed acyclic graph obtained after deleting the first node;
[0058] Figure 2L Based on the second node Figure 2J A schematic diagram of the second subgraph obtained by extending the above;
[0059] Figure 2M for Figure 2K A schematic diagram of the third directed acyclic graph obtained after deleting the second node;
[0060] Figure 2N For based on Figure 2M A schematic diagram of the first subgraph determined by the first node in the third directed acyclic graph;
[0061] Figure 2O A schematic diagram of a first directed acyclic graph including a single quantum logic gate, provided for an embodiment of this application;
[0062] Figure 2P For based on Figure 2O A schematic diagram of the resulting first directed acyclic graph;
[0063] Figure 2Q A topological diagram of a physical quantum bit in an electronic device provided in an embodiment of this application;
[0064] Figure 2R A schematic diagram of an isomorphic subgraph provided in an embodiment of this application;
[0065] Figure 3 A flowchart illustrating another quantum circuit construction method provided in this application embodiment;
[0066] Figure 4AA flowchart illustrating another quantum circuit construction method provided in this application embodiment;
[0067] Figure 4B A schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application;
[0068] Figure 5A A flowchart illustrating another quantum circuit construction method provided in this application embodiment;
[0069] Figure 5B A schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application;
[0070] Figure 5C A schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application;
[0071] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0072] Figure 7 This is a schematic diagram of a quantum circuit construction device provided in an embodiment of this application. Detailed Implementation
[0073] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0074] The following sections will provide detailed explanations.
[0075] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0076] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0077] This application first provides a quantum circuit construction method, which can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
[0078] 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 circuit construction method provided in an embodiment of this application. (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 information based on the quantum circuit construction method 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.
[0079] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / modules corresponding to the quantum circuit construction method in this embodiment. 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.
[0080] 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.
[0081] 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.
[0082] In practical applications, due to limitations in the development of quantum device hardware, quantum computing simulations are typically 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 conventional computer. Typically, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program referred to in the embodiments of this application 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.
[0083] Quantum circuits, also known as quantum logic circuits, are a manifestation of quantum programming and are the most commonly 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.
[0084] 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.
[0085] 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.
[0086] 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. Generally, the effect of a quantum logic gate on a quantum state is calculated by left-multiplying the unitary matrix by the matrix corresponding to the right vector of the quantum state.
[0087] See Figure 2A , Figure 2A This is a flowchart illustrating a quantum circuit construction method provided in an embodiment of this application. The method includes:
[0088] Step 201: Determine the set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program. The N largest subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the quantum chip in the electronic device based on the N largest subgraphs. N is an integer greater than or equal to 1.
[0089] Step 202: Determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and construct a quantum circuit based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
[0090] The N largest subgraphs are arranged in the order they were obtained to form a sequence of largest subgraphs.
[0091] Among them, the isomorphic subgraph is the bit relationship graph on the quantum chip obtained by mapping the topological structure of the quantum chip in the electronic device based on the maximum subgraph. For example, assuming the maximum subgraph is “q[0]—q[1]”, and the topological structure of the quantum chip in the electronic device is linear “Q[0]—Q[1]—Q[2]—Q[3]”, then “q[0]—q[1]” can be mapped to “Q[0]—Q[1]”, or to “Q[1]—Q[2]”, or to “Q[2]—Q[3]”. Then the isomorphic subgraphs of the maximum subgraph “q[0]—q[1]” are: “Q[0]—Q[1]”, “Q[1]—Q[2]”, and “Q[2]—Q[3]”.
[0092] As can be seen in this embodiment, firstly, a set of N isomorphic subgraphs corresponding to the N maximal subgraphs of the quantum program is determined, and these N maximal subgraphs are determined based on the directed acyclic graph of the quantum program. Then, the fixed cost of each isomorphic subgraph in the set of N isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent set of isomorphic subgraphs are determined, and a quantum circuit is constructed based on the fixed cost and the exchange cost. The fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the transformation between the quantum logic gates corresponding to the isomorphic subgraphs. By constructing a quantum circuit based on the fixed cost and the exchange cost, it is possible to select one path from multiple paths for constructing the quantum circuit.
[0093] Furthermore, before determining the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, the method further includes:
[0094] Constructing the first directed acyclic graph of a quantum program;
[0095] Traverse the first directed acyclic graph to obtain the sequence of maximum subgraphs, the sequence of maximum subgraphs includes N maximum subgraphs, where N is an integer greater than or equal to 1;
[0096] Determine the isomorphic subgraphs of the N maximum subgraphs in the topological structure to obtain a set of N isomorphic subgraphs. The topological structure is used to represent physical qubits in an electronic device and the connections between physical qubits. The set of N isomorphic subgraphs and the N maximum subgraphs are related. Figure 1 One-to-one correspondence.
[0097] The connection relationship indicates that two quantum logic gates can act on two physical qubits.
[0098] As can be seen, in the embodiments of this application, a first directed acyclic graph of the quantum program is first constructed, then the first directed acyclic graph is traversed to obtain a sequence of maximum subgraphs including N maximum subgraphs, and finally the isomorphic subgraphs of the N maximum subgraphs in the topological structure are determined to obtain a set of N isomorphic subgraphs. Thus, a quantum circuit can be constructed based on the obtained set of N maximum subgraphs, and the quantum program is transformed into a quantum circuit supported by the current quantum chip, thereby realizing the construction of the quantum circuit.
[0099] Furthermore, in constructing the first directed acyclic graph of the quantum program, the following is included:
[0100] Obtain the quantum logic gates in the quantum program;
[0101] A first directed acyclic graph is constructed based on the quantum logic gate. The first directed acyclic graph includes nodes and directed edges. Each node includes two points and one edge. The two points represent the two logical qubits corresponding to the quantum logic gate, and the edge represents the connection relationship of the quantum logic gate acting on the two logical qubits. The directed edge represents the dependency relationship of the quantum logic gate according to the quantum state evolution time sequence of the logical qubits.
[0102] Furthermore, the quantum logic gates include multiple quantum logic gates; in constructing the first directed acyclic graph based on the quantum logic gates, the following are included:
[0103] The multiple quantum logic gates are converted into single quantum logic gates and two quantum logic gates;
[0104] The single quantum logic gate is deleted, and a first directed acyclic graph is constructed based on the two quantum logic gates.
[0105] It should be noted that if the quantum program includes single-quantum logic gates, two-quantum logic gates, and multiple-quantum logic gates, then the multiple-quantum logic gates are first converted into single-quantum logic gates and two-quantum logic gates. Then, the single-quantum logic gates obtained after the conversion, along with the single-quantum logic gates already present in the original quantum program, are deleted. Finally, a first directed acyclic graph is constructed based on the two-quantum logic gates obtained after the conversion and the two-quantum logic gates already present in the original quantum program. The presence of single-quantum logic gates in the first directed acyclic graph does not affect the construction of the maximum subgraph; the maximum subgraph obtained from the first directed acyclic graph with single-quantum logic gates is the same as the maximum subgraph obtained from the first directed acyclic graph without single-quantum logic gates. Therefore, for simplicity, single-quantum logic gates are deleted here. In the subsequent construction of the maximum subgraph sequence, graphical examples will be used to illustrate that the maximum subgraph sequences obtained from both methods are the same; this will not be elaborated further here.
[0106] Furthermore, in constructing the first directed acyclic graph based on the quantum logic gate, the method includes:
[0107] If the quantum logic gates include multiple consecutive two-quantum logic gates, and the multiple consecutive two-quantum logic gates operate on two logic qubits that have the same function, then a first directed acyclic graph is constructed based on any one of the multiple consecutive two-quantum logic gates.
[0108] Here, "multiple" refers to two or more.
[0109] For example, if a quantum program includes two CZs (q[0], q[1]) that are temporally adjacent, then these two CZs (q[0], q[1]) are multiple consecutive quantum logic gates operating on the same two logical qubits. If there are other quantum logic gates between the two CZs (q[0], q[1]), then these two are not multiple consecutive quantum logic gates operating on the same two logical qubits. For multiple consecutive quantum logic gates operating on the same two logical qubits, the largest subgraph generated by constructing a first directed acyclic graph based on any one of them, or based on multiple of them, is the same. Similarly, for simplicity, here we only construct the first directed acyclic graph based on one of them.
[0110] Furthermore, the method also includes:
[0111] If the quantum logic gates include multiple consecutive two-quantum logic gates, and the multiple consecutive two-quantum logic gates operate on two different logic qubits, then a first directed acyclic graph is constructed sequentially based on the multiple consecutive two-quantum logic gates.
[0112] For example, a quantum program consists of two consecutive CZs. If the qubits operated by the two CZs are different, then the two are two logical qubits operated by two consecutive quantum logic gates but with different functions. When constructing the first directed acyclic graph, it is necessary to build it based on the two.
[0113] It should also be noted that if the quantum program includes a conjugate transposed quantum circuit, the transposed conjugate quantum circuit needs to be transformed before the first directed acyclic graph is constructed based on the transformed quantum circuit. If the quantum program contains a measurement operation, the processing method for the measurement operation is the same as that for a single quantum logic gate: delete the measurement operation or the single quantum logic gate, record the information of the measurement operation or the single quantum logic gate, and then construct the first directed acyclic graph based on the two quantum logic gates.
[0114] Further, the specific implementation method for constructing the first directed acyclic graph based on two quantum logic gates is as follows:
[0115] Obtain the logical qubit information on which the two quantum logic gates act;
[0116] Based on the logical qubit information, sequentially execute the two quantum logic gates, and determine the adjacent relationship between the currently executed two quantum logic gates and the next two quantum logic gates to be executed;
[0117] Construct the nodes corresponding to the two quantum logic gates. The nodes include two points and one edge. The two points are used to represent the two logical qubits corresponding to the two quantum logic gates, and the one edge is used to represent the quantum logic gate acting on the two logical qubits;
[0118] Based on the adjacent relationship, construct the directed edges between the nodes. The directed edges are used to represent the dependency relationship of the two quantum logic gates according to the quantum state evolution timing of the logical qubits; <00??396>Obtain the first directed acyclic graph based on the nodes and the directed edges.
[0120] For example, assume the quantum subroutine is CZ(q[0], q[1]) << CZ(q[0], q[2]) << CZ(q[0], q[3]) << CZ(q[1], q[2]) << CZ(q[1], q[3]) << CZ(q[2], q[3]). The quantum circuit corresponding to this quantum program is as Figure 2B shown, Figure 2B which is a schematic structural diagram of a quantum circuit provided by an embodiment of the present application. According to the above embodiment, the first directed acyclic graph of this quantum circuit can be constructed, as shown in Figure 2C, Figure 2C which is Figure 2B a schematic diagram of the first directed acyclic graph corresponding to the quantum circuit shown. The first directed acyclic graph includes 6 nodes and 8 directed edges.
[0121] Further, in terms of traversing the first directed acyclic graph to obtain the maximum subgraph sequence, it includes:
[0122] Determine the first node in the first directed acyclic graph, and the in-degree of the first node is 0;
[0123] Generate the first subgraph based on the first node;
[0124] Delete the first node to obtain the second directed acyclic graph;
[0125] Determine whether there is a second node in the second directed acyclic graph, and the in-degree of the second node is 0;
[0126] If the second node does not exist in the second directed acyclic graph, then the first subgraph is determined as the largest subgraph;
[0127] Arrange the largest subgraphs in the order of their generation to obtain the sequence of largest subgraphs.
[0128] In-degree is an important concept in graph theory algorithms. It usually refers to the sum of the number of times a vertex in a directed graph is the endpoint of an edge in the graph.
[0129] As can be seen, in this embodiment, the first node with an in-degree of 0 in the first directed acyclic graph is first determined, and a first subgraph is generated based on the first node; then, the first node is deleted to obtain a second directed acyclic graph, and it is determined whether a second node with an in-degree of 0 exists in the second directed acyclic graph; if no second node exists in the second directed acyclic graph, the first subgraph is determined as the maximum subgraph, and the maximum subgraphs are arranged in the order of generation to obtain the maximum subgraph sequence. This embodiment provides a method for determining the maximum subgraph sequence from the perspective of graph theory, and achieves the determination of the maximum subgraph sequence when no second node exists in the second directed acyclic graph.
[0130] Furthermore, the method also includes:
[0131] If the second node exists in the second directed acyclic graph, the priority of the second node is determined. The second node consists of two points and one edge. The two points represent two logical qubits in the quantum program, and the edge represents a quantum logic gate acting on the two logical qubits. The priority of the second node is determined based on the two points, one edge, and the first subgraph.
[0132] Based on the priority of the second node and the second node, generate the maximum subgraph.
[0133] For example, such as Figure 2C As shown, for a node corresponding to CZ(q[0], q[1]), there are two points and one edge: the point corresponding to q[0] and the point corresponding to q[1], and the edge between the point corresponding to q[0] and the point corresponding to q[1]. The point corresponding to q[0] represents the logical qubit q[0], the point corresponding to q[1] represents the logical qubit q[1], and the edge between the point corresponding to q[0] and the point corresponding to q[1] represents the CZ gate connection relationship acting on the logical qubit q[0] and the logical qubit q[1].
[0134] As can be seen from the embodiments of this application, if a second node exists in the second directed acyclic graph, the priority of the second node is determined, and a maximum subgraph is generated based on the priority of the second node and the second node. The embodiments of this application provide a method for determining a maximum subgraph sequence, which determines the maximum subgraph sequence from a graph theory perspective. When a second node exists in the second directed acyclic graph, a maximum subgraph is generated based on the priority of the second node and the second node, thereby realizing the determination of the maximum subgraph sequence.
[0135] Furthermore, in generating the maximum subgraph based on the priority of the second node and the second node, the following are included:
[0136] If the priority of the second node is the first priority, then based on the second node, the first subgraph is expanded into a second subgraph, and the second subgraph is used as the new first subgraph;
[0137] Delete the second node to obtain the third directed acyclic graph;
[0138] The third directed acyclic graph is used as the new second directed acyclic graph, and then the step of determining whether a second node exists in the second directed acyclic graph is performed.
[0139] Furthermore, the specific implementation of expanding the first subgraph into the second subgraph is as follows: if one of the two points exists in the first subgraph and the edge does not exist, then one of the two existing points is used as a vertex to form an edge, the other point is obtained, the line connecting the two points is used as the edge, and the expanded first subgraph is used as the second subgraph.
[0140] As can be seen in this embodiment, if the priority of the second node is the first priority, the first subgraph is expanded into a second subgraph based on the second node, and the second subgraph is used as the new first subgraph; then the second node is deleted to obtain a third directed acyclic graph; the third directed acyclic graph is used as the new second directed acyclic graph, and then the step of determining whether a second node exists in the second directed acyclic graph is executed. This embodiment provides a method for determining the maximum subgraph. When the priority of the second node is the first priority, the first subgraph is expanded until the first subgraph cannot be expanded, and the result is the maximum subgraph, thereby realizing the determination of the maximum subgraph.
[0141] Furthermore, the method also includes:
[0142] If the priority of the second node is the second priority, then the second node is used as the new first node, and then the step of generating a first subgraph based on the first node is executed, where the first priority is greater than the second priority.
[0143] Furthermore, before using the second node as the new first node, the method further includes:
[0144] Delete the second node with the highest priority, and determine the new first subgraph as the largest subgraph.
[0145] It should be noted that if a second node is included, there are two possibilities: one is that the subgraph can be expanded based on the second node, resulting in a larger subgraph than before; the other is that the subgraph cannot be expanded based on the second node, in which case the current subgraph is the largest subgraph. The first case always has a higher priority than the second case; otherwise, the resulting subgraph would not be the largest subgraph.
[0146] As can be seen, in this embodiment, if the priority of the second node is the second priority, then the second node is used as the new first node, and then the step of generating a first subgraph based on the first node is executed. This embodiment provides a method for determining the maximum subgraph. When the priority of the second node is the second priority, that is, the first subgraph cannot be expanded, it is the maximum subgraph. Therefore, the obtained first subgraph is determined as the maximum subgraph, and then the second node is used as the new first node to start searching for other maximum subgraphs again, thereby realizing the determination of the maximum subgraph.
[0147] Further, the first priority includes a first sub-priority and a second sub-priority, and the second priority includes a third sub-priority and a fourth sub-priority; in determining the priority of the second node, the following are included:
[0148] If the two points and the edge do not exist in the first subgraph, then the priority of the second node is determined as the fourth sub-priority.
[0149] If the first subgraph contains the two points and does not contain the edge, then the priority of the second node is determined as the third sub-priority.
[0150] If one of the two points exists in the first subgraph and the edge does not exist, then the priority of the second node is determined as the second sub-priority.
[0151] If the two points and the edge exist in the first subgraph, then the priority of the second node is determined as the first sub-priority.
[0152] The priorities, from highest to lowest, are: first sub-priority, second sub-priority, third sub-priority, and fourth sub-priority.
[0153] It should be noted that the case where the maximum subgraph cannot be expanded includes two sub-cases: one is that the first subgraph does not contain two vertices and one edge, and the other is that the first subgraph contains two vertices and no edge. If we consider two vertices and one edge as feature points, the first sub-case includes 0 feature points, and the second sub-case includes 2 feature points. If we determine the priority based on the number of feature points, the priority of the first sub-case is lower than that of the second sub-case, that is, the fourth sub-priority is lower than the third sub-priority.
[0154] Similarly, the cases that can expand the maximum subgraph include two sub-cases: one where the first subgraph contains one of two vertices and no edge; and the other where the first subgraph contains two vertices and one edge. If we consider the two vertices and one edge as feature points, the first sub-case includes 1 feature point, and the second sub-case includes 3. If we determine the priority based on the number of feature points, the priority of the first sub-case is lower than that of the second sub-case; that is, the second sub-priority is lower than the first sub-priority.
[0155] The above embodiments have explained the basis for determining the first priority (i.e., the first sub-priority and the second sub-priority) and the second priority (i.e., the third sub-priority and the fourth sub-priority), that is, the third sub-priority is less than the second sub-priority, which will not be elaborated here. Therefore, the priorities from largest to smallest can be determined as: first sub-priority, second sub-priority, third sub-priority, and fourth sub-priority.
[0156] As can be seen in this embodiment, if the first subgraph does not contain two points and one edge, the priority of the second node is determined to be the fourth sub-priority; if the first subgraph contains two points and no edge, the priority of the second node is determined to be the third sub-priority; if the first subgraph contains one of the two points and no edge, the priority of the second node is determined to be the second sub-priority; if the first subgraph contains two points and one edge, the priority of the second node is determined to be the first sub-priority; the priorities from largest to smallest are: first sub-priority, second sub-priority, third sub-priority, and fourth sub-priority. This embodiment provides a method for determining the priority of a second node, using the two points and one edge included in the second node as feature points, and determining the priority based on the number of these feature points, thus realizing the determination of the second priority.
[0157] The following is a specific application scenario of the method for determining the maximum subgraph sequence provided in the embodiments of this application.
[0158] For example, assume that the quantum subroutine is CZ(q[0], q[1]) << CZ(q[0], q[2]) << CZ(q[0], q[3]) << CZ(q[1], q[2]) << CZ(q[1], q[3]) << CZ(q[2], q[3]). The first directed acyclic graph corresponding to the quantum program is Figure 2C as shown. According to Figure 2C the first directed acyclic graph shown, the steps to determine the maximum subgraph sequence are as follows: Since the in-degree of the node corresponding to CZ(q[0], q[1]) is 0, the first node in the first directed acyclic graph can be determined as the node corresponding to CZ(q[0], q[1]). Take the two points included in the first node (the point corresponding to q[0] and the point corresponding to q[1]) as the two endpoints in the first subgraph, and take the edge included in the first node as the edge in the first subgraph to obtain the first subgraph, as Figure 2D shown, Figure 2D which is Figure 2C a schematic diagram of the first subgraph determined based on the first node in the first directed acyclic graph shown. Delete the first node to obtain the second directed acyclic graph, as Figure 2E shown, Figure 2E which is Figure 2C a schematic diagram of the second directed acyclic graph obtained after deleting the first node. Then determine whether there is a second node in the second directed acyclic graph. The in-degree of the node corresponding to CZ(q[0], q[2]) in the second directed acyclic graph is 0. Therefore, the node corresponding to CZ(q[0], q[2]) is the second node. This second node includes two points: the point corresponding to q[0] and the point corresponding to q[2], and an edge between them. The point corresponding to q[0] exists in the first subgraph. Determine the priority of this second node as the second sub-priority; use the point corresponding to q[0] as an edge to expand the first subgraph into the second subgraph, as Figure 2F shown, Figure 2F which is Figure 2D a schematic diagram of the second subgraph expanded based on the second node. Then take the above second subgraph as the new first subgraph, delete the second node, and obtain the third directed acyclic graph, as Figure 2G shown, Figure 2G which is Figure 2EA schematic diagram of the third directed acyclic graph obtained after deleting the second node. The third directed acyclic graph is used as the new second directed acyclic graph, and then it is determined whether there is a second node in the new second directed acyclic graph. Since the in-degree of the node corresponding to CZ(q[0], q[3]) and the in-degree of the node corresponding to CZ(q[1], q[2]) are both 0, there are 2 second nodes here. Determine the priority of the node corresponding to CZ(q[0], q[3]) and the priority of the node corresponding to CZ(q[1], q[2]). One point in the node corresponding to CZ(q[0], q[3]) is in the new first subgraph, and its priority is the second sub-priority; the two points in the node corresponding to CZ(q[1], q[2]) are both in the new first subgraph, but the edge between the two points is not in the new first subgraph, so its priority is the fourth sub-priority. The second sub-priority is greater than the fourth sub-priority, so the node corresponding to the second sub-priority is executed first. Using the point corresponding to q[0] as the edge, the new first subgraph is expanded into the second subgraph, such as Figure 2H As shown, Figure 2H This is a schematic diagram of the second subgraph obtained by expanding on Figure 2F based on the new second node. Then, the node corresponding to CZ(q[1], q[2]) is executed. Since the priority of this node is the fourth sub-priority, the new first subgraph obtained above is determined as the largest subgraph.
[0159] Delete the nodes corresponding to CZ(q[0], q[3]) to obtain a new first directed acyclic graph, such as Figure 2I As shown, Figure 2I for Figure 2G A schematic diagram of the new first directed acyclic graph obtained after deleting the new second node. The node corresponding to CZ(q[1], q[2]) is taken as the new first node. The two points included in the first node (the point corresponding to q[1] and the point corresponding to q[2]) are taken as the two endpoints of the first subgraph, and the edges included in the first node are taken as the edges of the first subgraph to obtain the first subgraph, as shown below. Figure 2J As shown, Figure 2J For based on Figure 2I The diagram shows the first subgraph determined by the first node in the first directed acyclic graph. Deleting the nodes corresponding to the first node CZ(q[1], q[2]) yields the second directed acyclic graph, as shown below. Figure 2K As shown, Figure 2K for Figure 2JSchematic diagram of the second directed acyclic graph obtained after deleting the first node. Then, it is determined whether there is a second node in the second directed acyclic graph. The in-degree of the node corresponding to CZ(q[1], q[3]) in the second directed acyclic graph is 0. Therefore, the node corresponding to CZ(q[1], q[3]) is the second node. This second node includes 2 points: the point corresponding to q[1] and the point corresponding to q[3], and an edge between them. There is a point corresponding to q[1] in the first subgraph. The priority of this second node is determined as the second sub-priority; using the point corresponding to q[1] as an edge, the first subgraph is expanded into a second subgraph, as Figure 2L shown, Figure 2L is the schematic diagram of the second subgraph obtained by expanding based on the second node in Figure 2J . Then, the above second subgraph is used as the new first subgraph, and the node corresponding to the second node CZ(q[1], q[3]) is deleted to obtain a third directed acyclic graph, as Figure 2M shown, Figure 2M is Figure 2K the schematic diagram of the third directed acyclic graph obtained after deleting the second node. The third directed acyclic graph is used as the new second directed acyclic graph, and then it is determined whether there is a second node in this new second directed acyclic graph. Since the in-degree of the node corresponding to CZ(q[2], q[3]) is 0, the node corresponding to CZ(q[2], q[3]) is the second node. Both of the two points in the node corresponding to CZ(q[2], q[3]) are in the new first subgraph but the edge between the two points is not in the new first subgraph. Therefore, its priority is the fourth sub-priority. The new first subgraph obtained above is determined as the maximum subgraph.
[0160] The node corresponding to CZ(q[2], q[3]) is used as the new first node. The first node includes two points (the point corresponding to q[2] and the point corresponding to q[3]) as the two end points in the first subgraph, and the edge included in the first node is used as the edge of the first subgraph to obtain the first subgraph, as Figure 2N shown, Figure 2N is Figure 2M the schematic diagram of the first subgraph determined based on the first node in the third directed acyclic graph shown. After deleting the node corresponding to CZ(q[2], q[3]), the obtained second directed acyclic graph is empty. There is no second node in the second directed acyclic graph, and the first subgraph is determined as the maximum subgraph.
[0161] In summary, three maximum subgraphs can be obtained: the maximum subgraph composed of CZ(q[0], q[1]) << CZ(q[0], q[2]) << CZ(q[0], q[3]) (as Figure 2H shown); the maximum subgraph composed of CZ(q[1], q[2]) << CZ(q[1], q[3]) (as Figure 2L(as shown); the maximum subgraph formed by CZ(q[2], q[3]) (such as Figure 2N (as shown). Arrange the three subgraphs in the order obtained to get the maximum subgraph sequence.
[0162] It should be noted that if there are single-qubit logic gates in the quantum program, its maximum subgraph sequence is the same as the maximum subgraph sequence obtained in the above embodiments. Assume the quantum subprogram is H(q[0]) << CZ(q[0], q[1]) << CZ(q[0], q[2]) << H(q[3]) << CZ(q[0], q[3]) << CZ(q[1], q[2]) << CZ (q[1], q[3]) << CZ(q[2], q[3]). As Figure 2O (as shown), Figure 2O is a schematic diagram of a first directed acyclic graph including single-qubit logic gates provided by an embodiment of the present application. For the node corresponding to H[0], it only includes one point (the point corresponding to q[0]), so the first subgraph obtained is a single point. Expand at this point and execute the node corresponding to CZ(q[0], q[1]), and the above first subgraph can be expanded to Figure 2D , and the subsequent steps are the same, and the 0th maximum subgraph ( Figure 2H ) can be obtained. Delete the node corresponding to CZ(q[0], q[3]) to get a new first directed acyclic graph, as Figure 2P (as shown), Figure 2P is a schematic diagram of the new first directed acyclic graph obtained based on Figure 2O . In the first directed acyclic graph, the in-degrees of the nodes corresponding to CZ(q[1], q[2]) and H(q[3]) are both 0, and the two nodes are the start of constructing the new first subgraph. The first subgraph does not include the points or edges included in both of them, so their priorities are the same. It is possible to construct the first subgraph based on the node corresponding to CZ(q[1], q[2]) first or construct the first subgraph based on the node corresponding to H(q[3]) first, and the points included in the node corresponding to H(q[3]) can all be incorporated into the 1st maximum subgraph ( Figure 2L ). The subsequent steps are the same, and the 2nd maximum subgraph ( Figure 2N ) can be obtained.
[0163] Specifically, in terms of constructing a quantum circuit based on the set of N isomorphic subgraphs, it includes:
[0164] Determine the fixed cost of each isomorphic subgraph in the set of N isomorphic subgraphs and the exchange cost between pairwise isomorphic subgraphs in any adjacent set of isomorphic subgraphs, and construct a quantum circuit based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for transformation between the quantum logic gates corresponding to the isomorphic subgraphs.
[0165] For example, assume the quantum subroutine is CZ(q[0], q[1]) << CZ(q[0], q[2]) << CZ(q[0], q[3]) << CZ(q[1], q[2]) << CZ(q[1], q[3]) << CZ(q[2], q[3]). Three maximum subgraphs can be obtained: the maximum subgraph composed of CZ(q[0], q[1]) << CZ(q[0], q[2]) << CZ(q[0], q[3]) (as Figure 2H shown); the maximum subgraph composed of CZ(q[1], q[2]) << CZ(q[1], q[3]) (as Figure 2L shown); the maximum subgraph composed of CZ(q[2], q[3]) (as Figure 2N shown).
[0166] As Figure 2Q shown, Figure 2Q is the topological structure diagram of physical qubits in an electronic device provided by an embodiment of the present application. The electronic device includes 8 physical qubits, namely Q[0], Q[1], Q[2], Q[3], Q[4], Q[5], Q[6], Q[7]. Among them, Q[o] is connected to Q[1] and Q[4], Q[5] is connected to Q[1], Q[4] and Q[6], Q[2] is connected to Q[1], Q[6] and Q[3], and Q[7] is connected to Q[3] and Q[6].
[0167] Map the 0th maximum subgraph ( Figure 2H ) in Figure 2Q , and 24 first isomorphic subgraphs can be obtained. These 24 first isomorphic subgraphs form the 0th set of isomorphic subgraphs; map the 1st maximum subgraph (Figure 2L) in Figure 2Q , and 32 second isomorphic subgraphs can be obtained. These 32 second isomorphic subgraphs form the 1st set of isomorphic subgraphs; map the 2nd maximum subgraph ( Figure 2L ) in Figure 2Q , and 20 third isomorphic subgraphs can be obtained. These 20 third isomorphic subgraphs form the 2nd set of isomorphic subgraphs, as Figure 2R shown, Figure 2RThis is a schematic diagram of an isomorphic subgraph provided in an embodiment of this application. The specific forms of each first isomorphic subgraph, each second isomorphic subgraph, and each third isomorphic subgraph are not listed in detail here.
[0168] By determining the fixed cost of each isomorphic subgraph in the three sets of isomorphic subgraphs, we obtain a first fixed cost set, a second fixed cost set, and a third fixed cost set. The first fixed cost set includes 24 first fixed costs, the second fixed cost set includes 32 second fixed costs, and the third fixed cost set includes 20 third fixed costs. By determining the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets, we obtain 24 × 32 first exchange costs between the 0th isomorphic subgraph set and the 1st isomorphic subgraph set, and 32 × 20 second exchange costs between the 1st isomorphic subgraph set and the 2nd isomorphic subgraph set. A quantum circuit is constructed based on these 24 first fixed costs, 32 second fixed costs, 20 third fixed costs, 24 × 32 first exchange costs, and 32 × 20 second exchange costs.
[0169] As can be seen, in this embodiment, the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs are first determined, and a quantum circuit is constructed based on the fixed cost and the exchange cost. The fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the conversion between the quantum logic gates corresponding to the isomorphic subgraphs. This embodiment provides a method for constructing quantum circuits, which constructs quantum circuits by using the fixed cost of isomorphic subgraphs and the exchange cost between isomorphic subgraphs, thus realizing the construction of quantum circuits.
[0170] See Figure 3 , Figure 3 A flowchart illustrating another quantum circuit construction method provided in this application embodiment. The method includes:
[0171] Step 301: Determine the set of N isomorphic subgraphs corresponding to the N maximum subgraphs of the quantum program. The N maximum subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the N maximum subgraphs to the quantum chip in the electronic device. N is an integer greater than or equal to 1. The N maximum subgraphs constitute a maximum subgraph sequence. The set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are 3 isomorphic subgraphs, and the sequence of the largest subgraphs is numbered from 0 to N-1.
[0172] Step 302: Determine the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets to obtain N fixed cost sets, and the N fixed cost sets correspond one-to-one with the N isomorphic subgraph sets.
[0173] Step 303: Determine the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets among the N isomorphic subgraph sets, obtaining N-1 exchange cost sets, each of which includes k i ·k i+1 Exchange cost.
[0174] Step 304: Determine based on the N fixed cost sets and the N-1 exchange cost sets Each consumption cost.
[0175] Step 305: Based on the above Constructing quantum circuits incurs significant costs.
[0176] For example, such as Figure 2Q As shown, the 0th isomorphic subgraph set includes 24 first isomorphic subgraphs, each corresponding to a fixed cost, and the first fixed cost set includes 24 first fixed costs; the 1st isomorphic subgraph set includes 32 second isomorphic subgraphs, each corresponding to a fixed cost, and the second fixed cost set includes 32 second fixed costs; the 2nd isomorphic subgraph set includes 20 third isomorphic subgraphs, each corresponding to a fixed cost, and the third fixed cost set includes 20 third fixed costs; there are 24 × 32 first exchange costs between the 0th isomorphic subgraph set and the 1st isomorphic subgraph set, and 32 × 20 second exchange costs between the 1st isomorphic subgraph set and the 2nd isomorphic subgraph set.
[0177] like Figure 2Q As shown, a 24×32×20 graph can be constructed based on the 0th isomorphic subgraph set, the 1st isomorphic subgraph set, and the 2nd isomorphic subgraph set. There are several quantum circuits, each with a corresponding cost. Each cost is determined based on a first fixed cost, a second fixed cost, a third fixed cost, a first exchange cost, and a second exchange cost. The quantum circuit with the lowest cost can be selected for construction.
[0178] As can be seen, in this embodiment, the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs is determined, resulting in N sets of fixed costs, each corresponding one-to-one with one of the N sets of isomorphic subgraphs; the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs in the N sets of isomorphic subgraphs is determined, resulting in N-1 sets of exchange costs, each set including k i·k i+1 Each exchange cost is determined based on N sets of fixed costs and N-1 sets of exchange costs. Individual consumption cost; based on This application provides a method for constructing quantum circuits by calculating the cost of all quantum circuits and then selecting the quantum circuit with the lowest cost for construction. The quantum circuit constructed in this application has the lowest cost and the highest fidelity, resulting in the highest quality quantum circuit.
[0179] The quantum circuit construction method provided in the above-mentioned application embodiments can find the quantum circuit with the lowest cost. However, its computational and storage requirements are enormous. Therefore, this application provides another method for constructing quantum circuits. For details, please refer to the following embodiments.
[0180] See Figure 4A , Figure 4A This is a flowchart illustrating another quantum circuit construction method provided in an embodiment of this application. The method includes:
[0181] Step 401: Determine the set of N isomorphic subgraphs corresponding to the N maximum subgraphs of the quantum program. The N maximum subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the N maximum subgraphs to the quantum chip in the electronic device. N is an integer greater than or equal to 1. The N maximum subgraphs constitute a maximum subgraph sequence. The set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are 3 isomorphic subgraphs, and the sequence of the largest subgraphs is numbered from 0 to N-1.
[0182] Step 402: Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0183] Step 403: Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph.
[0184] Step 404: Determine the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set, and obtain k. i There are k sets of exchange costs, each set containing k0 exchange costs.
[0185] Step 405: Based on the first fixed cost set, the second fixed cost set, and the k i The set of exchange costs determines k i There are k0 sets of consumption costs.
[0186] Step 406: Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k. i The minimum consumption cost, k i The minimum consumption cost and k in the second isomorphic subgraph set i a second isomorphism Figure 1 One-to-one correspondence.
[0187] Step 407: Place the k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph.
[0188] Step 408: Place the k i The set of new first isomorphic subgraphs is determined as the new set of first isomorphic subgraphs.
[0189] Step 409: Determine if i is equal to N-1;
[0190] If not, proceed to step 410;
[0191] If so, proceed to step 411.
[0192] Step 410: Let i = i + 1, and execute step 402, where the initial value of i is 1.
[0193] Step 411: Based on the obtained k N-1 Constructing quantum circuits at minimal cost.
[0194] Furthermore, the first fixed cost of the new first isomorphic subgraph is determined based on the first fixed cost of its corresponding previous first isomorphic subgraph, the second fixed cost of its previous second isomorphic subgraph, and the exchange cost between the previous first isomorphic subgraph and the previous second isomorphic subgraph.
[0195] For example, such as Figure 4B As shown, Figure 4BThis is a schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application. The first fixed cost of each first isomorphic subgraph in the 0th isomorphic subgraph set is determined, resulting in a first fixed cost set. This first fixed cost set includes 24 first fixed costs, namely first fixed cost 0, first fixed cost 1, ..., first fixed cost 23. The second fixed cost of each second isomorphic subgraph in the 1st isomorphic subgraph set is determined, resulting in a second fixed cost set. This second fixed cost set includes 32 second fixed costs, namely second fixed cost 0, second fixed cost 1, ..., second fixed cost 31.
[0196] Determine the second isomorphic subgraph 0, the second isomorphic subgraph Figure 1 ...The exchange costs between the second isomorphic subgraph 31 and the first isomorphic subgraph 0 can be used to obtain the exchange cost set 0, which includes exchange cost 00, exchange cost 10, exchange cost 20...exchange cost 310; determine the second isomorphic subgraph 0, the second isomorphic subgraph... Figure 1 ...The second isomorphism, graph 31, and the first isomorphism Figure 1 The exchange costs can be used to obtain exchange cost set 1, which includes exchange cost 01, exchange cost 11, exchange cost 21, ..., exchange cost 311, ... until the second isomorphic subgraph 0 is determined. Figure 1 The exchange costs between the second isomorphic subgraph 31 and the first isomorphic subgraph 23 can be used to obtain the exchange cost set 23, which includes exchange cost 023, exchange cost 123, exchange cost 223, ..., exchange cost 3123.
[0197] The consumption cost 00 of the first isomorphic subgraph 0 and the second isomorphic subgraph 0 is determined based on the exchange cost 00, the first fixed cost 0, and the second fixed cost 0; the first isomorphic subgraph 0 and the second isomorphic subgraph 0... Figure 1 The consumption cost 10 is determined based on the exchange cost 10, the first fixed cost 0, the second fixed cost 1, ... The consumption cost 310 of the first isomorphic subgraph 0 and the second isomorphic subgraph 31 is determined based on the exchange cost 310, the first fixed cost 0, the second fixed cost 31; Consumption cost 00, consumption cost 10, ... consumption cost 310 constitute the consumption cost set 0;
[0198] First isomorphism Figure 1 The consumption cost 01 of the second isomorphic subgraph 0 is determined based on the exchange cost 01, the first fixed cost 1, and the second fixed cost 0; the first isomorphic subgraph Figure 1 With the second isomorphism Figure 1 The consumption cost 11 is determined based on the exchange cost 11, the first fixed cost 1, the second fixed cost 1, ... the first isomorphism. Figure 1The consumption cost 311 of the second isomorphic subgraph 31 is determined based on the exchange cost 311, the first fixed cost 1, and the second fixed cost 31; consumption cost 01, consumption cost 11, ..., consumption cost 311 constitute the consumption cost set 1;
[0199] ···
[0200] The consumption cost 023 of the first isomorphic subgraph 23 and the second isomorphic subgraph 0 is determined based on the exchange cost 023, the first fixed cost 23, and the second fixed cost 0; the first isomorphic subgraph 23 and the second isomorphic subgraph 0 Figure 1 The consumption cost 123 is determined based on the exchange cost 123, the first fixed cost 23, the second fixed cost 1, ... The consumption cost 3123 of the first isomorphic subgraph 23 and the second isomorphic subgraph 31 is determined based on the exchange cost 3123, the first fixed cost 23, the second fixed cost 31; Consumption cost 023, consumption cost 123, ... Consumption cost 3123 constitute the consumption cost set 23.
[0201] Determine the minimum consumption cost in consumption cost set 0, determine the minimum consumption cost in consumption cost set 1, ... determine the minimum consumption cost in consumption cost set 23, and obtain 24 minimum consumption costs.
[0202] Combine the first isomorphic subgraph 0 with its corresponding second isomorphic subgraph to form a new first isomorphic subgraph 0. Figure 1 Together with its corresponding second isomorphic subgraph, a new first isomorphic subgraph is formed. Figure 1 ...Form a new first isomorphic subgraph 23 by combining the first isomorphic subgraph 23 with its corresponding second isomorphic subgraph; the new first isomorphic subgraph 0, the new first isomorphic subgraph... Figure 1 ...The new first isomorphic subgraph 23 constitutes a new set of first isomorphic subgraphs.
[0203] Determine the first fixed cost of each first isomorphic subgraph in the new set of isomorphic subgraphs to obtain the first fixed cost set, which includes 24 first fixed costs, namely first fixed cost 0', first fixed cost 1', ..., first fixed cost 23'; determine the second fixed cost of each second isomorphic subgraph in the second set of isomorphic subgraphs (here the third isomorphic subgraph is the new second isomorphic subgraph) to obtain the second fixed cost set, which includes 32 second fixed costs, namely second fixed cost 0', second fixed cost 1', ..., second fixed cost 31'.
[0204] Determine the second isomorphic subgraph 0', the second isomorphic subgraph Figure 1The exchange costs between the second isomorphic subgraph 31' and the first isomorphic subgraph 0' can be used to obtain the exchange cost set 0', which includes exchange cost 00', exchange cost 10', exchange cost 20', ..., exchange cost 310'; the exchange costs of the second isomorphic subgraph 0' and the first isomorphic subgraph 0' can be determined. Figure 1 '...Second isomorphic graph 31' and the first isomorphic graph Figure 1 The exchange costs can be used to obtain the exchange cost set 1', which includes exchange cost 01', exchange cost 11', exchange cost 21', ..., exchange cost 311', ... until the second isomorphic subgraph 0' is determined. Figure 1 The exchange costs between the second isomorphic subgraph 31 and the first isomorphic subgraph 23' can be used to obtain the exchange cost set 23', which includes exchange cost 023', exchange cost 123', exchange cost 223', ..., exchange cost 3123'.
[0205] The consumption cost 00' of the first isomorphic subgraph 0' and the second isomorphic subgraph 0' is determined based on the exchange cost 00', the first fixed cost 0', and the second fixed cost 0'; the first isomorphic subgraph 0' and the second isomorphic subgraph 0' Figure 1 The consumption cost 10' is determined based on the exchange cost 10', the first fixed cost 0', and the second fixed cost 1'... The consumption cost 310' of the first isomorphic subgraph 0' and the second isomorphic subgraph 31' is determined based on the exchange cost 310', the first fixed cost 0', and the second fixed cost 31'; Consumption cost 00', consumption cost 10'... consumption cost 310' constitute the consumption cost set 0';
[0206] First isomorphism Figure 1 The consumption cost 01' of the second isomorphic subgraph 0' is determined based on the exchange cost 01', the first fixed cost 1', and the second fixed cost 0'; the first isomorphic subgraph Figure 1 'with the second isomorphism Figure 1 The consumption cost 11' is determined based on the exchange cost 11', the first fixed cost 1', the second fixed cost 1', ... the first isomorphism. Figure 1 The consumption cost 311' of the second isomorphic subgraph 31' is determined based on the exchange cost 311', the first fixed cost 1', and the second fixed cost 31'; consumption cost 01', consumption cost 11', ..., consumption cost 311' constitute the consumption cost set 1';
[0207] ···
[0208] The consumption cost 023' of the first isomorphic subgraph 23' and the second isomorphic subgraph 0' is determined based on the exchange cost 023', the first fixed cost 23', and the second fixed cost 0'; the first isomorphic subgraph 23' and the second isomorphic subgraph 0' Figure 1 The consumption cost 123' is determined based on the exchange cost 123', the first fixed cost 23', and the second fixed cost 1'. The consumption cost 3123' of the first isomorphic subgraph 23' and the second isomorphic subgraph 31' is determined based on the exchange cost 3123', the first fixed cost 23', and the second fixed cost 31'. Consumption cost 023', consumption cost 123', ..., consumption cost 3123' constitute the consumption cost set 23'.
[0209] Determine the minimum consumption cost in consumption cost set 0', the minimum consumption cost in consumption cost set 1', and so on, until the minimum consumption cost in consumption cost set 23', resulting in 24 minimum consumption costs. Determine the 24 quantum circuits corresponding to these 24 minimum consumption costs. Quantum circuit 0 consists of a first isomorphic subgraph 0, its corresponding second isomorphic subgraph, and its corresponding third isomorphic subgraph; quantum circuit 1 consists of the first isomorphic subgraph... Figure 1 The quantum circuit 23 is composed of the first isomorphic subgraph 23, its corresponding second isomorphic subgraph, its corresponding third isomorphic subgraph, and so on. The quantum circuit with the lowest cost is selected.
[0210] As can be seen, in this embodiment, the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set is determined to obtain a first fixed cost set, and the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph; the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set is determined to obtain a second fixed cost set, and the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph; the exchange cost between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set is determined to obtain k0 exchange cost sets, each exchange cost set including k i There are k0 exchange costs; based on the first fixed cost set, the second fixed cost set, and the k0 exchange cost sets, a k0 consumption cost set is determined, the consumption cost set includes k... i Each set of consumption costs is used to determine the minimum consumption cost, resulting in k0 minimum consumption costs. These k0 minimum consumption costs are then compared with the k0 first isomorphic subgraphs in the first isomorphic subgraph set. Figure 1One-to-one correspondence; combine each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs; determine the set of the k0 new first isomorphic subgraphs as a new set of first isomorphic subgraphs; let i = i + 1, and perform the steps to determine the first fixed cost of each first isomorphic subgraph in the set of first isomorphic subgraphs, resulting in a first fixed cost set, with the initial value of i being 1; when i = N - 1, construct a quantum circuit based on the obtained k0 minimum consumption costs.
[0211] This application provides another method for constructing quantum circuits. By traversing the sequence of maximum subgraphs, it matches from beginning to end to find k0 cost values. The number of cost values is equal to the number of isomorphic subgraphs corresponding to the 0th maximum subgraph. Based on these k0 cost values, it determines one isomorphic subgraph corresponding to each maximum subgraph, and then uses this isomorphic subgraph to construct the quantum circuit. In this application, every two adjacent sets of isomorphic subgraphs are filtered, and each time only the optimal isomorphic subgraph with the same number of isomorphic subgraphs as the 0th maximum subgraph is obtained. This significantly reduces computational and storage requirements while enabling the construction of quantum circuits.
[0212] The quantum circuit construction method provided in the above-mentioned embodiment can find the quantum circuit with minimal computational cost; however, its computational and storage requirements are enormous. While the quantum circuit construction method provided in the other embodiment reduces computational and storage requirements, it may overlook the optimal quantum circuit. Therefore, this application provides another method for constructing quantum circuits, the details of which are described in the following embodiments.
[0213] See Figure 5A , Figure 5A This is a flowchart illustrating another quantum circuit construction method provided in an embodiment of this application. The method includes:
[0214] Step 501: Determine the set of N isomorphic subgraphs corresponding to the N maximum subgraphs of the quantum program. The N maximum subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the N maximum subgraphs to the quantum chip in the electronic device. N is an integer greater than or equal to 1. The N maximum subgraphs constitute a maximum subgraph sequence. The set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are 3 isomorphic subgraphs, and the sequence of the largest subgraphs is numbered from 0 to N-1.
[0215] Step 502: Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0216] Step 503: Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph.
[0217] Step 504: Determine the exchange cost between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set, resulting in k0 sets of exchange costs, each set including k... i Exchange cost.
[0218] Step 505: Determine k0 sets of consumption costs based on the first set of fixed costs, the second set of fixed costs, and the k0 sets of exchange costs, where each set of consumption costs includes k i Each consumption cost.
[0219] Step 506: Determine the minimum consumption cost in each of the aforementioned consumption cost sets, obtaining k0 minimum consumption costs. These k0 minimum consumption costs are then compared with the k0 first isomorphic subgraphs in the first isomorphic subgraph set. Figure 1 One-to-one correspondence.
[0220] Step 507: Combine each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs.
[0221] Step 508: Determine the set of the k0 new first isomorphic subgraphs as the new first isomorphic subgraph set.
[0222] Step 509: Determine whether i is equal to N-1, where the initial value of i is 1;
[0223] If not, proceed to step 510;
[0224] If so, proceed to step 511.
[0225] Step 510: Let i = i + 1, and execute step 502.
[0226] Step 511: Construct quantum circuits based on the obtained k0 minimum cost values.
[0227] For example, such as Figure 5B As shown, Figure 5BThis is a schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application. The first fixed cost of each first isomorphic subgraph in the 0th isomorphic subgraph set is determined, resulting in a first fixed cost set. This first fixed cost set includes 24 first fixed costs, namely first fixed cost 0, first fixed cost 1, ..., first fixed cost 23. The second fixed cost of each second isomorphic subgraph in the 1st isomorphic subgraph set is determined, resulting in a second fixed cost set. This second fixed cost set includes 32 second fixed costs, namely second fixed cost 0, second fixed cost 1, ..., second fixed cost 31.
[0228] Determine the first isomorphic subgraph 0, the first isomorphic subgraph Figure 1 ...The exchange costs between the first isomorphic subgraph 23 and the second isomorphic subgraph 0 can be used to obtain the exchange cost set 0, which includes exchange cost 00, exchange cost 01, exchange cost 02...exchange cost 023; determine the first isomorphic subgraph 0, the first isomorphic subgraph... Figure 1 ...First isomorphism Graph 23 and second isomorphism Figure 1 The exchange costs can be used to obtain exchange cost set 1, which includes exchange cost 10, exchange cost 11, exchange cost 12, ..., exchange cost 123; ... until the first isomorphic subgraph 0 is determined. Figure 1 The exchange costs of the first isomorphic subgraph 23 and the second isomorphic subgraph 31 can be used to obtain the exchange cost set 31, which includes exchange costs 310, 311, 312, ..., 3123.
[0229] The cost 00 of the first isomorphic subgraph 0 and the second isomorphic subgraph 0 is determined based on the exchange cost 00, the first fixed cost 0, and the second fixed cost 0; the first isomorphic subgraph 0 Figure 1 The consumption cost 01 of the second isomorphic subgraph 0 is determined based on the exchange cost 01, the first fixed cost 1, and the second fixed cost 0, ... The consumption cost 023 of the first isomorphic subgraph 23 and the second isomorphic subgraph 0 is determined based on the exchange cost 023, the first fixed cost 23, and the second fixed cost 0; Consumption cost 00, consumption cost 01, ... consumption cost 023 constitute the consumption cost set 0;
[0230] First isomorphic graph 0 and second isomorphic graph Figure 1 The consumption cost 10 is determined based on the exchange cost 10, the first fixed cost 0, and the second fixed cost 1; the first isomorphic component Figure 1 With the second isomorphism Figure 1 The consumption cost 11 is determined based on the exchange cost 11, the first fixed cost 1, the second fixed cost 1, ... the first isomorphic subgraph 23 and the second isomorphic subgraph Figure 1Consumption cost 123 is determined based on exchange cost 123, first fixed cost 23, and second fixed cost 1; consumption cost 10, consumption cost 11, ..., consumption cost 123 constitute consumption cost set 1;
[0231] ···
[0232] The consumption cost 310 of the first isomorphic subgraph 0 and the second isomorphic subgraph 31 is determined based on the exchange cost 310, the first fixed cost 0, and the second fixed cost 31; the first isomorphic subgraph 0 and the second isomorphic subgraph 31 are determined based on the exchange cost 310, the first fixed cost 0, and the second fixed cost 31. Figure 1 The consumption cost 311 of the second isomorphic subgraph 31 is determined based on the exchange cost 311, the first fixed cost 1, and the second fixed cost 31... The consumption cost 3123 of the first isomorphic subgraph 23 and the second isomorphic subgraph 31 is determined based on the exchange cost 3123, the first fixed cost 23, and the second fixed cost 31; the consumption costs 310, 311... and 3123 constitute the consumption cost set 31.
[0233] Determine the minimum consumption cost in consumption cost set 0, determine the minimum consumption cost in consumption cost set 1, ... determine the minimum consumption cost in consumption cost set 31, and obtain 32 minimum consumption costs.
[0234] Combine the second isomorphic subgraph 0 with its corresponding first isomorphic subgraph to form a new first isomorphic subgraph 0, and then combine the second isomorphic subgraph with its corresponding first isomorphic subgraph. Figure 1 Together with its corresponding first isomorphic subgraph, a new first isomorphic subgraph is formed. Figure 1 ...The second isomorphic subgraph 31 and its corresponding first isomorphic subgraph form a new first isomorphic subgraph 31; the new first isomorphic subgraph 0, the new first isomorphic subgraph... Figure 1 ...The new first isomorphic subgraph 31 constitutes a new set of first isomorphic subgraphs.
[0235] Determine the first fixed cost of each first isomorphic subgraph in the new set of isomorphic subgraphs to obtain the first fixed cost set, which includes 32 first fixed costs, namely first fixed cost 0', first fixed cost 1', ..., first fixed cost 31'; determine the second fixed cost of each second isomorphic subgraph in the second set of isomorphic subgraphs (here the third isomorphic subgraph is the new second isomorphic subgraph) to obtain the second fixed cost set, which includes 20 second fixed costs, namely second fixed cost 0', second fixed cost 1', ..., second fixed cost 19'.
[0236] Determine the first isomorphic subgraph 0', the first isomorphic subgraph Figure 1The exchange costs of the first isomorphic subgraph 31' and the second isomorphic subgraph 0' can be used to obtain the exchange cost set 0', which includes exchange cost 00', exchange cost 10', exchange cost 20', ..., exchange cost 310'; the first isomorphic subgraph 0' and the second isomorphic subgraph 0' are determined. Figure 1 '...First isomorphism graph 31' and the second isomorphism Figure 1 The exchange cost of ' can be used to obtain the exchange cost set 1', which includes exchange cost 01', exchange cost 11', exchange cost 21', ..., exchange cost 311', ... until the first isomorphic subgraph 0' is determined. Figure 1 The exchange costs of the first isomorphic subgraph 31' and the second isomorphic subgraph 19' can be used to obtain the exchange cost set 19', which includes exchange cost 019', exchange cost 119', exchange cost 219', ..., exchange cost 3119'.
[0237] The consumption cost 00' of the first isomorphic subgraph 0' and the second isomorphic subgraph 0' is determined based on the exchange cost 00', the first fixed cost 0', and the second fixed cost 0'; the first isomorphic subgraph 0' Figure 1 The consumption cost 01' of the second isomorphic subgraph 0' is determined based on the exchange cost 01', the first fixed cost 1', and the second fixed cost 0'... The consumption cost 031' of the first isomorphic subgraph 31' and the second isomorphic subgraph 0' is determined based on the exchange cost 031', the first fixed cost 31', and the second fixed cost 0'; Consumption cost 00', consumption cost 01'... consumption cost 031' constitute the consumption cost set 0';
[0238] First isomorphic graph 0' and second isomorphic graph Figure 1 The consumption cost 10 is determined based on the exchange cost 10', the first fixed cost 0', and the second fixed cost 1'; the first isomorphic component Figure 1 'with the second isomorphism Figure 1 The consumption cost 11' is determined based on the exchange cost 11', the first fixed cost 1', the second fixed cost 1', ... the first isomorphic subgraph 31' and the second isomorphic subgraph 31'. Figure 1 The consumption cost 131 is determined based on the exchange cost 131', the first fixed cost 31', and the second fixed cost 1'; the consumption costs 10', 11', ..., 131' constitute the consumption cost set 1';
[0239] ···
[0240] The cost 310' of the first isomorphic subgraph 0' and the second isomorphic subgraph 31' is determined based on the exchange cost 310', the first fixed cost 0', and the second fixed cost 31'; the first isomorphic subgraph 0' and the second isomorphic subgraph 31' are consumed based on the exchange cost 310', the first fixed cost 0', and the second fixed cost 31'. Figure 1 The consumption cost 311' of the second isomorphic subgraph 31' is determined based on the exchange cost 311', the first fixed cost 1', and the second fixed cost 31'... The consumption cost 1931' of the first isomorphic subgraph 31' and the second isomorphic subgraph 19' is determined based on the exchange cost 1931', the first fixed cost 31', and the second fixed cost 19'; the consumption cost 310', consumption cost 311'... consumption cost 3119' constitutes the consumption cost set 19'.
[0241] Determine the minimum consumption cost in consumption cost set 0', the minimum consumption cost in consumption cost set 1', and so on, until the minimum consumption cost in consumption cost set 19' is determined, resulting in 20 minimum consumption costs. Then, determine the 20 quantum circuits corresponding to these 20 minimum consumption costs. Quantum circuit 0 consists of the third isomorphic subgraph 0, its corresponding second isomorphic subgraph, and its corresponding first isomorphic subgraph; quantum circuit 1 consists of the third isomorphic subgraph... Figure 1 The quantum circuit 19 is composed of the third isomorphic subgraph 19, its corresponding second isomorphic subgraph, and its corresponding first isomorphic subgraph. The quantum circuit with the lowest cost is selected.
[0242] As can be seen, in this embodiment, the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set is determined to obtain the first fixed cost set, and the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph; the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set is determined to obtain the second fixed cost set, and the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph; the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set is determined to obtain k. i There are k sets of exchange costs, each set containing k0 exchange costs; based on a first fixed cost set, a second fixed cost set, and k... i The set of exchange costs determines k i There are k0 sets of consumption costs; determine the minimum consumption cost in each set, and obtain k. i The minimum consumption cost, k i The minimum consumption cost and k in the second isomorphic subgraph set i a second isomorphism Figure 1 One-to-one correspondence; k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph; k iThe set consisting of a new set of first isomorphic subgraphs is determined as the new set of first isomorphic subgraphs; let i = i + 1, and perform the steps to determine the first fixed cost of each first isomorphic subgraph in the set of first isomorphic subgraphs, to obtain the set of first fixed costs, with the initial value of i being 1; when i = N - 1, based on the obtained k N-1 Constructing quantum circuits at minimal cost.
[0243] This application provides another method for constructing quantum circuits, which involves traversing the maximum subgraph sequence from back to front to find k. N-1 Each cost is equal to the number of isomorphic subgraphs corresponding to the (N-1)th largest subgraph. Based on this k... N-1 The cost is used to determine a corresponding isomorphic subgraph for each maximum subgraph, and then a quantum circuit is constructed using this isomorphic subgraph. In this embodiment, a selection process is performed for every two adjacent sets of isomorphic subgraphs, and each time only the optimal isomorphic subgraph with the same number of isomorphic subgraphs as the next maximum subgraph is obtained. This greatly reduces the computational and storage requirements while still being able to construct the optimal quantum circuit.
[0244] In the following embodiment, a specific example is given to illustrate the difference between constructing a quantum circuit by traversing from front to back and constructing a quantum circuit by traversing from back to front.
[0245] like Figure 5C As shown, Figure 5C This is a schematic diagram illustrating the matching between isomorphic subgraphs provided in an embodiment of this application. The 0th set of isomorphic subgraphs includes the first isomorphic subgraph 0 and the first isomorphic subgraph... Figure 1 The first set of isomorphic subgraphs includes the second isomorphic subgraph 0 and the second isomorphic subgraph 0. Figure 1 The second set of isomorphic subgraphs includes the third isomorphic subgraph 0 and the third isomorphic subgraph 0. Figure 1 ; First isomorphic subgraph 0, first isomorphic subgraph Figure 1 Second isomorphic subgraph 0, second isomorphic subgraph Figure 1 The third isomorphic graph 0 and the third isomorphic graph Figure 1 The fidelity of the graph itself is 1. The fidelity between the first isomorphic subgraph 0 and the second isomorphic subgraph 0 is 0.9. Figure 1 The fidelity between them is 0.85, and the first isomorphism Figure 1 The fidelity between the first isomorphism and the second isomorphic graph 0 is 0.9. Figure 1 With the second isomorphism Figure 1 The fidelity between the second and third isomorphic subgraphs is 0.85, and the fidelity between the second and third isomorphic subgraphs is 0.9. Figure 1The fidelity between them is 0.8, and the second isomorphism Figure 1 The fidelity with the third isomorphic graph 0 is 1, and the second isomorphic graph... Figure 1 With the second isomorphism Figure 1 The fidelity between them is 0.7.
[0246] Constructing the quantum circuit by traversing from front to back: The cost of the first isomorphic subgraph 0 and the second isomorphic subgraph 0 is 0.1 (1 - 1 × 0.9 × 1). Figure 1 The consumption cost is 0.15 (1-1×0.85×1). Selecting the one with the lowest consumption cost yields a new first isomorphic subgraph 0, which is composed of the first isomorphic subgraph 0 and the second isomorphic subgraph 0. Figure 1 The cost of the second isomorphic subgraph 0 is 0.1 (1 - 1 × 0.9 × 1), and the first isomorphic subgraph... Figure 1 With the second isomorphism Figure 1 The consumption cost is 0.15 (1-1×0.85×1). Selecting the one with the lowest consumption cost yields the new first isomorphic component, Graph 1. Figure 1 By the first isomorphism Figure 1 It forms a second isomorphic subgraph 0; the cost of the new first isomorphic subgraph 0 and the third isomorphic subgraph 0 is 0.19 (1 - 1 × 0.9 × 1 × 0.9 × 1). Figure 1 The consumption cost is 0.28 (1 - 1 × 0.9 × 1 × 0.8 × 1). Selecting the one with the lowest consumption cost yields a new first isomorphic subgraph 0. This new first isomorphic subgraph 0 is composed of the first isomorphic subgraph 0, the second isomorphic subgraph 0, and the third isomorphic subgraph 0. Figure 1 The cost of the third isomorphic subgraph 0 is 0.19 (1 - 1 × 0.9 × 1 × 0.9 × 1), and the cost of the new first isomorphic subgraph is 0.19 (1 - 1 × 0.9 × 1 × 0.9 × 1). Figure 1 With the third isomorphism Figure 1 The consumption cost is 0.28 (1 - 1 × 0.9 × 1 × 0.8 × 1). The one with the lowest consumption cost is selected to obtain the new first isomorphic unit. Figure 1 The new first isomorphism Figure 1 By the first isomorphism Figure 1 It consists of the second isomorphic subgraph 0 and the third isomorphic subgraph 0; finally, it is composed of the new first isomorphic subgraph 0 and the new first isomorphic subgraph 0. Figure 1 The quantum circuit is constructed by selecting the isomorphic subgraph with the lowest cost. Since the cost of both is 0.19, the quantum circuit can be constructed based on the first isomorphic subgraph 0, the second isomorphic subgraph 0, and the third isomorphic subgraph 0, or it can be constructed based on the first isomorphic subgraph 0. Figure 1 The second isomorphic subgraph 0 and the third isomorphic subgraph 0 are used to construct quantum circuits.
[0247] Constructing the quantum circuit by traversing from back to front: The cost of the second isomorphic subgraph 0 and the first isomorphic subgraph 0 is 0.1 (1 - 1 × 0.9 × 1). Figure 1 The consumption cost is 0.1 (1-1×0.9×1). Selecting the one with the lowest consumption cost yields the new first isomorphic subgraph 0. Since both have the same consumption cost, the new first isomorphic subgraph 0 can be composed of the first isomorphic subgraph 0 and the second isomorphic subgraph 0, or it can be composed of the first isomorphic subgraph 0. Figure 1 It is formed with the second isomorphic graph 0; the second isomorphic graph Figure 1 The cost of the first isomorphic subgraph 0 is 0.15 (1 - 1 × 0.85 × 1), and the cost of the second isomorphic subgraph is... Figure 1 With the second isomorphism Figure 1 The consumption cost is 0.15(1-1×0.85×1). Selecting the one with the lowest consumption cost yields the new first isomorphic component, Graph 1. Since both have the same consumption cost, the new first isomorphic component... Figure 1 It can be made by the first isomorphism Figure 1 It can be formed by the second isomorphic subgraph 0, or by the first isomorphic subgraph. Figure 1 With the second isomorphism Figure 1 The cost of the new first isomorphic subgraph 0 and the third isomorphic subgraph 0 is 0.19 (1 - 1 × 0.9 × 1 × 0.9 × 1). Figure 1 The consumption cost is 0.28 (1 - 1 × 0.9 × 1 × 0.8 × 1). The one with the lowest consumption cost is selected to obtain a new first isomorphic subgraph 0. The new first isomorphic subgraph 0 is composed of the first isomorphic subgraph 0, the second isomorphic subgraph 0, and the third isomorphic subgraph 0. Alternatively, the new first isomorphic subgraph 0 is composed of the first isomorphic subgraph 0... Figure 1 It consists of the second isomorphic subgraph 0 and the third isomorphic subgraph 0; the new first isomorphic subgraph Figure 1 The cost of the third isomorphic graph 0 is 0.15 (1 - 1 × 0.85 × 1 × 1 × 1), and the cost of the new first isomorphic graph is 0.15 (1 - 1 × 0.85 × 1 × 1 × 1). Figure 1 With the third isomorphism Figure 1 The consumption cost is 0.405 (1 - 1 × 0.85 × 1 × 0.7 × 1). The one with the lowest consumption cost is selected to obtain the new first isomorphic unit. Figure 1 The new first isomorphism Figure 1 It can be composed of the first isomorphic subgraph 0, the second isomorphic subgraph Figure 1 It can be composed of the third isomorphic subgraph 0, or it can be composed of the first isomorphic subgraph. Figure 1 Second isomorphism Figure 1 The third isomorphic subgraph 0 is formed; finally, the new first isomorphic subgraph 0 and the new first isomorphic subgraph 0 are formed. Figure 1 The quantum circuit is constructed by selecting the isomorphic graph with the lowest consumption cost, resulting in a new first isomorphic graph. Figure 1 The minimum cost is 0.85, therefore it can be based on the first isomorphic subgraph 0 and the second isomorphic subgraph 0. Figure 1 Quantum circuits can be constructed using the third isomorphic graph 0, or they can be based on the first isomorphic graph. Figure 1 Second isomorphism Figure 1 The third isomorphic subgraph 0 is used to construct quantum circuits.
[0248] It can be seen that constructing a quantum circuit by traversing from front to back yields results based on the first isomorphic subgraph 0, the second isomorphic subgraph 0, and the third isomorphic subgraph 0, or based on the first isomorphic subgraph 0. Figure 1 Construct quantum circuits using the first isomorphic subgraph 0 and the second isomorphic subgraph 0; traverse from front to back to construct quantum circuits, the result of which is based on the first isomorphic subgraph 0 and the second isomorphic subgraph 0. Figure 1 The third isomorphic graph 0 can be used to construct quantum circuits, or based on the first isomorphic graph. Figure 1 Second isomorphism Figure 1 The two methods construct quantum circuits using the third isomorphic subgraph 0. The results obtained are different; the total cost of the former is 0.19, while the total cost of the latter is 0.15. Clearly, the latter is superior to the former, indicating that the former did not find the optimal method for constructing quantum circuits.
[0249] It should be noted that in the above three embodiments for constructing quantum circuits, the maximum subgraph, the maximum subgraph sequence, the isomorphic subgraph, the set of isomorphic subgraphs, the first fixed cost set, the second fixed cost set, and the consumption cost set are all numbered starting from 0. They can also be numbered starting from 1 or from any other number or letter. Examples will not be provided here.
[0250] Furthermore, the fixed costs and the exchange costs are determined based on fidelity.
[0251] Furthermore, the fixed cost and the exchange cost are determined based on the number of CZ gates.
[0252] It should be noted that the fidelity of any two quantum logic gate is equivalent to the fidelity of at least one CZ gate.
[0253] Each isomorphic subgraph corresponds to a maximal subgraph, each maximal subgraph is determined based on at least one two-quantum logic gate, and the fixed cost of each isomorphic subgraph is determined based on the product of the fidelities corresponding to at least one two-quantum logic gate.
[0254] For example, the largest child Figure 2H The corresponding quantum logic gates are CZ(q[0], q[1]), CZ(q[0], q[2]), and CZ(q[0], q[3]); the largest quantum gate is CZ(q[0], q[3]). Figure 2LThe corresponding quantum logic gates are CZ(q[1], q[2]) and CZ(q[1], q[3]). The largest quantum... Figure 2H and the largest child Figure 2L Mapped to Figure 2Q In, the largest sub Figure 2H The mapping relationships are as follows: q[1]—>Q[0], q[0]—>Q[1], q[3]—>Q[2], q[2]—>Q[5], the largest sub Figure 2L The mapping relationships are as follows: q[3]—>Q[2], q[1]—>Q[1], q[2]—>Q[5].
[0255] Determining fixed costs and exchange costs based on fidelity:
[0256] The fidelity of the analog signal corresponding to the CZ gate acting on Q[0] and Q[1] is F. 01 The fidelity of the analog signal corresponding to the CZ gate acting on Q[1] and Q[2] is F. 12 The fidelity of the analog signal corresponding to the CZ gate acting on Q[1] and Q[5] is F. 15 The largest child Figure 2H The fixed cost is 1-F 01 ·F 12 ·F 15 When executing CZ(q[1], q[2]) and CZ(q[1], q[3]), the mapping relationship of q[1] needs to be transformed from Q[0] to Q[1], and the maximum sub-matrix... Figure 2L The fixed cost is 1-F 12 ·F 15 To transform the mapping relationship of q[1] from Q[0] to Q[1], a quantum logic gate SWAP(q[0], q[1]) needs to be introduced. SWAP(q[0], q[1]) = CZ(q[0], q[1])CZ(q[0], q[1])CZ(q[0], q[1]). Therefore, the largest quantum... Figure 2H With the largest child Figure 2L The exchange cost is 1-F 01 3 The total cost is 1-F. 01 ·F 12 ·F 15 ·F 12 ·F 15 ·F 01 3 .
[0257] Determining fixed and exchange costs based on the number of CZ gates: Maximum sub-gate Figure 2H The fixed cost is 3 CZ gates, with the largest sub-gate... Figure 2L The fixed cost is 2 CZ gates, with the largest sub-gate... Figure 2H With the largest child Figure 2L The exchange cost is 3 CZ gates, and the total consumption cost is 8 CZ gates.
[0258] With the above Figure 1 , Figure 2A , Figure 3 , Figure 4A and Figure 5A The embodiments shown are consistent; please refer to Figure 6. Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 6 As shown, the electronic device includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the following steps:
[0259] The set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program is determined. The N largest subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the quantum chip in the electronic device based on the N largest subgraphs. N is an integer greater than or equal to 1.
[0260] Determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and construct a quantum circuit based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
[0261] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the procedure includes instructions specifically for performing the following steps in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost:
[0262] Determine the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets to obtain N fixed cost sets, and the N fixed cost sets correspond one-to-one with the N isomorphic subgraph sets;
[0263] Determine the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets among the N isomorphic subgraph sets, resulting in N-1 sets of exchange costs, each set of exchange costs including k. i ·k i+1 Exchange cost;
[0264] Based on the N fixed cost sets and the N-1 exchange cost sets, determine Individual consumption costs;
[0265] Based on the above Constructing quantum circuits incurs significant costs.
[0266] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the procedure includes instructions specifically for performing the following steps in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost:
[0267] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0268] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0269] Determine the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set, and obtain k. i There are k0 sets of exchange costs;
[0270] Based on the first fixed cost set, the second fixed cost set, and k i The set of exchange costs determines k i There are k0 sets of consumption costs;
[0271] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k. i The minimum consumption cost, namely k i The minimum consumption cost and k in the second isomorphic subgraph seti a second isomorphism Figure 1 One-to-one correspondence;
[0272] k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph;
[0273] k i The set consisting of a new first isomorphic subgraph is determined as the new first isomorphic subgraph set;
[0274] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0275] When i = N-1, based on the obtained k N-1 Constructing quantum circuits at minimal cost.
[0276] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; the procedure includes instructions specifically for performing the following steps in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost:
[0277] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0278] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0279] Determine the exchange costs between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set, resulting in k0 sets of exchange costs, each set containing k... i Exchange cost;
[0280] Based on the first fixed cost set, the second fixed cost set, and the k0 exchange cost sets, k0 consumption cost sets are determined, each consumption cost set including ki Individual consumption costs;
[0281] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k0 minimum consumption costs. These k0 minimum consumption costs are then compared with the k0 first isomorphic subgraphs in the first isomorphic subgraph set. Figure 1 One-to-one correspondence;
[0282] Each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph is combined to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs;
[0283] The set of the k0 new first isomorphic subgraphs is defined as the new first isomorphic subgraph set;
[0284] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0285] When i = N-1, construct quantum circuits based on the obtained k0 minimum cost values.
[0286] In one embodiment of this application, the fixed cost and the exchange cost are determined based on fidelity.
[0287] In one embodiment of this application, the fixed cost and the exchange cost are determined based on the number of CZ gates.
[0288] It should be noted that the specific implementation process of this embodiment can be found in the specific implementation process described in the above method embodiments, and will not be described again here.
[0289] This application embodiment can divide an electronic device into functional units according to the method example described above. For example, each function can be divided into its own functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0290] The following are embodiments of the apparatus described in this application. These embodiments are used to execute the methods implemented in the embodiments of the method described in this application. Please refer to... Figure 7 , Figure 7 This is a schematic diagram of a quantum circuit construction device provided in an embodiment of this application. The device includes:
[0291] The determining unit 701 is used to determine the set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program, wherein the N largest subgraphs are determined based on the directed acyclic graph of the quantum program, and N is an integer greater than or equal to 1;
[0292] The construction unit 702 is used to determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and to construct quantum circuits based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
[0293] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost, the construction unit 702 is specifically used for:
[0294] Determine the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets to obtain N fixed cost sets, and the N fixed cost sets correspond one-to-one with the N isomorphic subgraph sets;
[0295] Determine the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets among the N isomorphic subgraph sets, resulting in N-1 sets of exchange costs, each set of exchange costs including k. i ·k i+1 Exchange cost;
[0296] Based on the N fixed cost sets and the N-1 exchange cost sets, determine Individual consumption costs;
[0297] Based on the above Constructing quantum circuits incurs significant costs.
[0298] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. iThere are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost, the construction unit 702 is specifically used for:
[0299] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0300] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0301] Determine the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set, and obtain k. i There are k0 sets of exchange costs;
[0302] Based on the first fixed cost set, the second fixed cost set, and k i The set of exchange costs determines k i There are k0 sets of consumption costs;
[0303] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k. i The minimum consumption cost, namely k i The minimum consumption cost and k in the second isomorphic subgraph set i a second isomorphism Figure 1 One-to-one correspondence;
[0304] k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph;
[0305] k i The set consisting of a new first isomorphic subgraph is determined as the new first isomorphic subgraph set;
[0306] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0307] When i = N-1, based on the obtained k N-1 Constructing quantum circuits at minimal cost.
[0308] In one embodiment of this application, the N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, the largest subgraph sequence being numbered from 0 to N-1; in determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and in constructing quantum circuits based on the fixed cost and the exchange cost, the construction unit 702 is specifically used for:
[0309] Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph.
[0310] Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set, where the second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph;
[0311] Determine the exchange costs between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set, resulting in k0 sets of exchange costs, each set containing k... i Exchange cost;
[0312] Based on the first fixed cost set, the second fixed cost set, and the k0 exchange cost sets, k0 consumption cost sets are determined, each consumption cost set including k i Individual consumption costs;
[0313] Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k0 minimum consumption costs. These k0 minimum consumption costs are then compared with the k0 first isomorphic subgraphs in the first isomorphic subgraph set. Figure 1 One-to-one correspondence;
[0314] Each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph is combined to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs;
[0315] The set of the k0 new first isomorphic subgraphs is defined as the new first isomorphic subgraph set;
[0316] Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1;
[0317] When i = N-1, construct quantum circuits based on the obtained k0 minimum cost values.
[0318] In one embodiment of this application, the fixed cost and the exchange cost are determined based on fidelity.
[0319] In one embodiment of this application, the fixed cost and the exchange cost are determined based on the number of CZ gates.
[0320] It should be noted that the determining unit 501 and the building unit 502 can be implemented by a processor.
[0321] This application also provides a computer-readable storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments, wherein the computer includes an electronic device.
[0322] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the computer may include an electronic device.
[0323] This application also provides a quantum computer operating system, which implements the construction of the quantum circuit according to some or all of the steps of any of the methods described in the above method embodiments.
[0324] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0325] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0326] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0327] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0328] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0329] If the integrated units described above are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0330] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0331] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for constructing quantum circuits, characterized in that, The method includes: The set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program is determined. The N largest subgraphs are determined based on the directed acyclic graph of the quantum program. The set of N isomorphic subgraphs is a bit relationship graph on the quantum chip obtained by mapping the topology of the quantum chip in the electronic device based on the N largest subgraphs. N is an integer greater than or equal to 1. Determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and construct a quantum circuit based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
2. The method according to claim 1, characterized in that, The N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, where the largest subgraph sequence is numbered from 0 to N-1; determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and constructing a quantum circuit based on the fixed cost and the exchange cost, includes: Determine the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets to obtain N fixed cost sets, and the N fixed cost sets correspond one-to-one with the N isomorphic subgraph sets; Determine the exchange cost between any pairwise isomorphic subgraphs in any adjacent isomorphic subgraph sets among the N isomorphic subgraph sets, resulting in N-1 sets of exchange costs, each set of exchange costs including k. i ·k i+1 Exchange cost; Based on the N fixed cost sets and the N-1 exchange cost sets, determine Individual consumption costs; Based on the above Constructing quantum circuits incurs significant costs.
3. The method according to claim 1, characterized in that, The N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, where the largest subgraph sequence is numbered from 0 to N-1; determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and constructing a quantum circuit based on the fixed cost and the exchange cost, includes: Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph. Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set. The second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph; i is greater than or equal to 1 and i is less than or equal to N-1. Determine the exchange cost between all first isomorphic subgraphs in the first isomorphic subgraph set and each second isomorphic subgraph in the second isomorphic subgraph set, and obtain k. i There are k0 sets of exchange costs; Based on the first fixed cost set, the second fixed cost set, and k i The set of exchange costs determines k i There are k0 sets of consumption costs; Determine the minimum consumption cost in each of the aforementioned consumption cost sets to obtain k. i The minimum consumption cost, k i The minimum consumption cost and k in the second isomorphic subgraph set i Each of the second isomorphic subgraphs corresponds one-to-one; k i Each second isomorphic subgraph in the first isomorphic subgraph and its corresponding first isomorphic subgraph together form a new first isomorphic subgraph, resulting in k. i A new first isomorphic subgraph; k i The set consisting of a new first isomorphic subgraph is determined as the new first isomorphic subgraph set; Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1; When i = N-1, based on the obtained k N-1 Constructing quantum circuits at minimal cost.
4. The method according to claim 1, characterized in that, The N maximum subgraphs constitute a maximum subgraph sequence, and the set of isomorphic subgraphs corresponding to the i-th maximum subgraph in the maximum subgraph sequence includes k. i There are N isomorphic subgraphs, where the largest subgraph sequence is numbered from 0 to N-1; determining the fixed cost of each isomorphic subgraph in the N isomorphic subgraph sets and the exchange cost between any two isomorphic subgraphs in any adjacent isomorphic subgraph sets, and constructing a quantum circuit based on the fixed cost and the exchange cost, includes: Determine the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, where the first isomorphic subgraph set is the isomorphic subgraph set corresponding to the 0th largest subgraph. Determine the second fixed cost of each second isomorphic subgraph in the second isomorphic subgraph set to obtain the second fixed cost set. The second isomorphic subgraph set is the isomorphic subgraph set corresponding to the i-th largest subgraph; i is greater than or equal to 1 and i is less than or equal to N-1. Determine the exchange costs between all second isomorphic subgraphs in the second isomorphic subgraph set and each first isomorphic subgraph in the first isomorphic subgraph set, resulting in k0 sets of exchange costs, each set containing k... i Exchange cost; Based on the first fixed cost set, the second fixed cost set, and the k0 exchange cost sets, k0 consumption cost sets are determined, each consumption cost set including k i Individual consumption costs; Determine the minimum consumption cost in each set of consumption costs to obtain k0 minimum consumption costs, and the k0 minimum consumption costs correspond one-to-one with the k0 first isomorphic subgraphs in the first set of isomorphic subgraphs; Each of the k0 first isomorphic subgraphs and its corresponding second isomorphic subgraph is combined to form a new first isomorphic subgraph, resulting in k0 new first isomorphic subgraphs; The set of the k0 new first isomorphic subgraphs is defined as the new first isomorphic subgraph set; Let i = i + 1, and perform the step of determining the first fixed cost of each first isomorphic subgraph in the first isomorphic subgraph set to obtain the first fixed cost set, wherein the initial value of i is 1; When i=N-1, construct quantum circuits based on the obtained k0 minimum cost values.
5. The method according to any one of claims 1-4, characterized in that, The fixed costs and the exchange costs are determined based on fidelity.
6. The method according to any one of claims 1-4, characterized in that, The fixed cost and the exchange cost are determined based on the number of CZ gates.
7. A quantum circuit construction device, characterized in that, The device includes: A determining unit is used to determine the set of N isomorphic subgraphs corresponding to the N largest subgraphs of the quantum program, wherein the N largest subgraphs are determined based on the directed acyclic graph of the quantum program, and N is an integer greater than or equal to 1; A construction unit is used to determine the fixed cost of each isomorphic subgraph in the N sets of isomorphic subgraphs and the exchange cost between any two isomorphic subgraphs in any adjacent sets of isomorphic subgraphs, and to construct quantum circuits based on the fixed cost and the exchange cost; the fixed cost is determined based on the quantum logic gates corresponding to the isomorphic subgraphs, and the exchange cost is determined based on the SWAP gates required for the conversion between the quantum logic gates corresponding to the isomorphic subgraphs.
8. An electronic device, characterized in that, The method includes a processor, a memory, a communication interface, and one or more programs, said programs being stored in the memory and configured to be executed by the processor, said programs including instructions for performing the steps of the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the method of any one of claims 1-6.
10. A quantum computer operating system, characterized in that, The quantum computer operating system implements the construction of the quantum circuit according to any one of claims 1-6.