This application relates to quantum computing technologies, and in particular, to a quantum circuit optimization method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
A quantity of quantum gates in a quantum circuit correlates with runtime of quantum algorithms. For a purpose of continuing to improve computing efficiency, the quantum circuit may also be optimized to further reduce the runtime of the quantum algorithms.
However, there are a wide variety of constraints on a quantum circuit in a superconducting quantum device, for example, no constraints, constraints of a path, constraints of a tree, and constraints of a connected graph. As a result, if implementation of a circuit corresponding to an arbitrary unitary matrix is promoted based on an existing quantum circuit on which no constraints are imposed, a quantum circuit is poorly optimized.
Embodiments of this application provide a quantum circuit optimization method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product, to improve optimization of quantum circuits.
Technical solutions in the embodiments of this application are implemented as follows:
An embodiment of this application provides a quantum circuit optimization method performed by an electronic device. The method includes:
An embodiment of this application provides an electronic device, including:
An embodiment of this application provides a non-transitory computer-readable storage medium, storing executable instructions, the executable instructions implementing the quantum circuit optimization method provided in the embodiment of this application when being executed by a processor of an electronic device.
The embodiments of this application have the following beneficial effects: The electronic device first iteratively decomposes the to-be-processed unitary matrix that is obtained through transformation of the to-be-optimized quantum circuit, and then decomposes the qubit uniformly controlled gates that are obtained through decomposition, to obtain the qubit diagonal unitary matrices and the single-qubit gates. The to-be-optimized quantum circuit is of a complex structure. Therefore, without changing functions and while being constrained by the connected graph, the to-be-optimized quantum circuit cannot be optimized. However, a process of implementing a quantum circuit corresponding to a qubit diagonal unitary matrix is simple. Therefore, a problem of optimizing a quantum circuit is converted into a problem of implementing a quantum circuit corresponding to a qubit diagonal unitary matrix, efficiently implementing optimization of a quantum circuit. The electronic device then determines the matching quantum circuits for the qubit diagonal unitary matrices under the constraints of the connected graph, and finally integrates the matching quantum circuits and the single-qubit gates, to obtain the optimized quantum circuit. In this way, an optimal quantum circuit under the constraints of the connected graph is obtained, that is, an optimized quantum circuit that is faster to compute, improving optimization of the quantum circuit. As such, efficiency of quantum computing is improved by optimizing the quantum circuit.
To make objectives, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings. The described embodiments are not to be considered as a limitation on this application. All other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
In the following description, the term “some embodiments” is used and describes subsets of all possible embodiments, but it may be understood that “some embodiments” may be same subsets or different subsets of all the possible embodiments, and can be combined with each other in a case of no conflict.
In the following description, the used terms “first”, “second”, and “third” are merely intended to distinguish between similar objects rather than describe specific orders for intended objects. It may be understood that “first”, “second”, and “third” may be interchanged to form specific orders when they are allowed, so that the embodiments of this application described herein can be implemented in an order other than an order illustrated or described herein.
Unless otherwise defined, meanings of all technical and scientific terms used in this specification are the same as those usually understood by a person skilled in the art to which this application belongs. Terms used in this specification are merely intended to describe objectives of the embodiments of this application rather than limit this application.
Before the embodiments of this application are further described in detail, nouns and terms used in the embodiments of this application are described. The nouns and terms used in the embodiments of this application are interpreted as follows:
With a feature of quickly completing computing tasks, quantum computation can help solve some problems that are difficult to solve by classical computers. For example, for a problem of decomposing larger numbers, use of quantum computation can achieve an exponential increase in computing efficiency.
A quantity of quantum gates in a quantum circuit corresponds to runtime of quantum algorithms. Therefore, for a purpose of continuing to improve computing efficiency, the quantum circuit may also be optimized to further reduce the runtime of the quantum algorithms.
In the noisy intermediate-scale quantum era (NISQ era), implementation of two-qubit gates (for example, CNOT gates) in superconducting quantum devices is constrained. For example, a two-qubit gate is allowed to act only on specific qubit pairs. Such constraints are referred to as constraints of a graph in the embodiments of this application.
For example,
Because an arbitrary quantum circuit can be transformed into a unitary matrix, optimizing a size of a quantum circuit can be converted into a problem of implementing a quantum circuit corresponding to an arbitrary unitary matrix. Therefore, under constraints of a graph G=(V, E), a quantum state preparation circuit may be defined as follows: Given an arbitrary unitary matrix U=[uxy]x,y∈{0,1}2
In the foregoing, |ψrepresents a quantum state. The n-qubit circuit CUS includes single-qubit gates and CNOT gates, with positions of the CNOT gates constrained by G=(V, E). In other words, during design of a quantum circuit, only single-qubit gates and CNOT gates are allowed, and the CNOT gates are allowed to act only on two adjacent qubits.
For a problem of optimizing quantum circuits, by using related technologies, a quantum circuit corresponding to an arbitrary unitary matrix is implemented when no constraints are imposed on the circuit, and a quantum circuit addressing a special issue is implemented under constraints of a path; and then the quantum circuit on which no constraints are imposed is promoted to obtain an optimal quantum circuit. However, there are a wide variety of constraints on a quantum circuit in a superconducting quantum device, for example, no constraints, and constraints of a graph such as constraints of a path, constraints of a tree, and constraints of a connected graph. As a result, if implementation of a circuit corresponding to an arbitrary unitary matrix is promoted based on an existing quantum circuit on which no constraints are imposed, it is difficult to obtain an optimal quantum circuit in a progressive sense, and finally a quantum circuit is poorly optimized.
The embodiments of this application provide a quantum circuit optimization method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product, to improve optimization of quantum circuits. The following describes an exemplary application of an electronic device that is configured to optimize quantum circuits and that is provided in an embodiment of this application. The electronic device provided in the embodiment of this application may be implemented as various types of terminals or as servers. The following describes an exemplary application when the electronic device is implemented as a server.
The terminal 400 is configured to generate a to-be-optimized quantum circuit based on a problem to be solved, and transmit the to-be-optimized quantum circuit to the server 200.
The server 200 is configured to: transform the to-be-optimized quantum circuit into a to-be-processed unitary matrix, and decompose the to-be-processed unitary matrix iteratively, to obtain a first quantity of qubit uniformly controlled gates; decompose each qubit uniformly controlled gate into a second quantity of qubit diagonal unitary matrices and a third quantity of single-qubit gates; determine, under constraints of a connected graph, a matching quantum circuit corresponding to each qubit diagonal unitary matrix; integrate the second quantity of matching quantum circuits and the third quantity of single-qubit gates, to obtain a target quantum circuit of each qubit uniformly controlled gate; and connect the first quantity of target quantum circuits, to obtain an optimized quantum circuit corresponding to the to-be-optimized quantum circuit. In this way, a process of optimizing the quantum circuit is implemented.
The server 200 is further configured to apply the optimized quantum circuit to the quantum computing device 500 (for example, transmit the optimized quantum circuit to a quantum chip fabrication instrument for fabricating a quantum chip corresponding to the optimized quantum circuit, and configure a quantum computing device based on the quantum chip), to improve computing efficiency of the quantum computing device 500 by using the optimized quantum circuit.
In some embodiments, the server 200 may be a standalone physical server, or may be a server cluster or a distributed system including a plurality of physical servers, or may be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), big data, and artificial intelligence platforms. The terminal 400 may be a smartphone, a tablet computer, a notebook computer, a desktop computer, or the like, but is not limited thereto.
The processor 210 may be an integrated circuit chip with signal processing capabilities, for example, a general-purpose processor, a digital signal processor (DSP), another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor, any conventional processor, or the like.
The memory 250 may be a removable memory, a non-removable memory, or a combination of both. An exemplary hardware device includes a solid-state memory, a hard disk drive, a compact disc drive, and the like. The memory 250 includes one or more storage devices that are physically away from the processor 210.
The memory 250 includes a volatile memory or a nonvolatile memory, or may include both a volatile memory and a nonvolatile memory. The nonvolatile memory may be a read only memory (ROM). The volatile memory may be a random access memory (RAM). The memory 250 described in this embodiment of this application is intended to include any suitable type of memory.
In some embodiments, the memory 250 can store data to support a variety of operations. Examples of the data include a program, a module, a data structure, or a subset or superset thereof. The following provides an exemplary description.
An operating system 251 includes a system program that is configured to process various basic system services and perform hardware-related tasks, for example, a framework layer, a kernel library layer, or a driver layer, and is configured to implement various basic services and process hardware-based tasks.
A network communication module 252 is configured to reach another electronic device by using one or more (wired or wireless) network interfaces 220. Exemplary network interfaces 220 include Bluetooth, wireless fidelity (Wi-Fi), a universal serial bus (USB), and the like.
In some embodiments, a quantum circuit optimization apparatus provided in this embodiment of this application may be implemented in a form of software.
In some other embodiments, a quantum circuit optimization apparatus provided in this embodiment of this application may be implemented in a form of hardware. For example, the quantum circuit optimization apparatus provided in this embodiment of this application may be a processor in a form of a hardware decoding processor. The processor is programmed to perform the quantum circuit optimization method provided in the embodiment of this application. For example, the processor in the form of a hardware decoding processor may use one or more application specific integrated circuits (ASIC), DSPs, programmable logic devices (PLD), complex programmable logic devices (CPLD), field-programmable gate arrays (FPGA), or other electronic elements.
In some embodiments, a terminal or server may implement the quantum circuit optimization method provided in the embodiment of this application by running a computer program. For example, the computer program may be a native program or software module in an operating system; or may be a native application (APP), that is, a program that needs to be installed in an operating system to run, for example, a circuit optimization APP; or may be an applet, that is, a program that can run after being downloaded into a browser environment; or may be an applet that can be embedded in an arbitrary APP. In summary, the computer program may be an application, a module, or a plug-in in any form.
An embodiment of this application provides a quantum computing device, the quantum computing device including an optimized quantum circuit, and the optimized quantum circuit being implemented by using the quantum circuit optimization method provided in the embodiment of this application.
Before the quantum circuit optimization method provided in the embodiment of this application is described, basic symbols used in the embodiments of this application are first described as follows: [n] represents a set {1, 2, . . . , n}; 2 represents a binary field, and ⊕ represents addition in the binary field; for any x=(x1, . . . , xn)T, y=(y1, . . . , yn)T∈{0,1}n, an inner product
x, y
=⊕i=1n, where addition and multiplication are both defined in the binary field; 0n represents a vector that is of length n and has elements of all 0s, and 1n represents a vector that is of length n and has elements of all 1s; a set S is a set of numbers of qubits, |ψ
s indicates that a quantum state |ψ
includes the qubits in the set S, and if S={q}, |ψ
s is simply denoted as |ψ
q; and if the set S and a set T satisfy S⊆T, T−Sdef{a: a∈T, and a∉S} is defined.
The following describes the quantum circuit optimization method provided in the embodiment of this application with reference to the exemplary application and the implementation of the electronic device provided in the embodiments of this application and to the related basic symbols.
S101: Transform a to-be-optimized quantum circuit into a to-be-processed unitary matrix, and decompose the to-be-processed unitary matrix iteratively, to obtain a first quantity of qubit uniformly controlled gates.
This embodiment of this application is implemented in a scenario in which the to-be-optimized quantum circuit is optimized under constraints of a connected graph, to obtain, by optimizing the to-be-optimized quantum circuit, an optimized quantum circuit that can implement the same functions as the to-be-optimized quantum circuit but has fewer quantum gates (that is, less required computation time). Each quantum circuit has a corresponding unitary matrix. In this embodiment of this application, an electronic device first transforms a to-be-processed quantum circuit into a unitary matrix. The obtained unitary matrix is the to-be-processed unitary matrix. The to-be-optimized quantum circuit is of a complex structure. Therefore, without changing functions and while being constrained by the connected graph, it is difficult to optimize the to-be-optimized quantum circuit. However, a process of implementing a quantum circuit corresponding to a unitary matrix is simple. Therefore, in this embodiment of this application, optimizing a size of a quantum circuit is converted into a problem of implementing a quantum circuit corresponding to an arbitrary unitary matrix.
It may be understood that a quantity of qubits on which the to-be-optimized quantum circuit acts may be set based on an actual situation, for example, set to n (n is a positive integer). In this embodiment of this application, a process of optimizing the to-be-optimized quantum circuit is described by using an example in which the to-be-optimized quantum circuit acts on n qubits.
When the to-be-optimized quantum circuit acts on n qubits, the to-be-processed unitary matrix is an n-qubit unitary matrix. Therefore, a problem of optimizing the to-be-optimized quantum circuit is converted into implementing, under the constraints of the connected graph, a quantum circuit corresponding to the n-qubit unitary matrix.
A quantity of qubits corresponding to the qubit uniformly controlled gates that are obtained through iterative decomposition of the to-be-processed unitary matrix is the same as a quantity of qubits corresponding to the to-be-processed unitary matrix. In other words, when the to-be-processed unitary matrix is an n-qubit unitary matrix, the electronic device decomposes the n-qubit unitary matrix iteratively for n times. After each iterative decomposition is performed, one or more n-qubit uniformly controlled gates (UCG) and a qubit unitary matrix that needs to be further decomposed are obtained. The electronic device continues to decompose the obtained qubit unitary matrix and iterates in this way, until the first quantity of n-qubit uniformly controlled gates are obtained after n iterative decompositions are performed.
An effect of an n-qubit uniformly controlled gate is to apply different single-qubit gates to a target qubit under 2n-1 different controls. For example,
In some embodiments, the decomposing the to-be-processed unitary matrix iteratively in step S101 may be implemented by following the processing process below: letting i be a positive integer that increases sequentially, with 1≤i≤n and n being a quantity of qubits, and performing the following processing iteratively based on i: performing matrix decomposition on an initial unitary matrix of an ith iteration, to obtain a decomposition result of the ith iteration, an initial unitary matrix of the first iteration being the to-be-processed unitary matrix; extracting a qubit uniformly controlled gate of the ith iteration and generated unitary matrices of the ith iteration from the decomposition result of the ith iteration; and determining the generated unitary matrices of the ith iteration as initial unitary matrices of an (i+1)th iteration; and determining 2n-1 qubit uniformly controlled gates that are obtained after n iterations are performed, as the first quantity of qubit uniformly controlled gates.
i is a positive integer that increases sequentially, 1≤i≤n, and n is the quantity of qubits. An ith qubit in the qubit uniformly controlled gate of the ith iteration is a target qubit, and remaining n−1 qubits are all control qubits. Qubits corresponding to the generated unitary matrix of the ith iteration is one less than qubits corresponding to the initial unitary matrix of the ith iteration.
For example, when n qubits corresponding to an arbitrary n-qubit unitary matrix (that is, a to-be-processed unitary matrix) are denoted as {1, 2, . . . , n}, an electronic device may perform cosine-sine decomposition (that is, matrix decomposition) on the n-qubit unitary matrix. A decomposition result in the following form is obtained:
In the decomposition result, Vn-1,1, Vn-1,2, Vn-1,1′, Vn-1,2′∈2
2
, k∈[1,2n-1]} and {sin (θk):θk∈
, k∈[2n-1]}, respectively.
is an n-qubit uniformly controlled gate with a target qubit being the first qubit (that is, a qubit uniformly controlled gate of the first iteration), denoted as V1[n]-{1}. In this case, cosine-sine decomposition of the first iteration may be written as follows:
Vn-1,1, Vn-1,2, Vn-1,1′, Vn-1,2′ are (n−1)-qubit unitary matrices, and therefore can further undergo cosine-sine decomposition (that is, matrix decomposition). A decomposition result in the following form is obtained:
In the decomposition result, Vn-1,i∈2
2
2
, k∈[2n-2]} and {sin (θk):θk∈
, k∈[2n-2]}, and {cos (θ′k):θ′k∈
, k∈[2n-2]} and {sin (θ′k):θ′k∈
, k∈[2n-2]}, respectively. Therefore, the matrix U can be expanded into the following form:
The second matrix (that is,
and the sixth matrix (that is,
are n-qubit uniformly controlled gates V2[n]-{2} with a target qubit being the second qubit. The remaining matrices (that is, the generated unitary matrices of the second iteration) are diagonal matrices that need to further undergo cosine-sine decomposition (that is, initial unitary matrices of the third iteration).
Iterations are performed in this way until i is n. In this case, a final expansion of U can be obtained and is a result of a cumulative multiplication of 2n−1 n-qubit uniformly controlled gates. Therefore, U may be written as follows:
In the expression, ζ(i) is calculated by using a ruler function. The ruler function is defined as follows: ζ(n)=max{k:2kłn and 2k-1|n} (ł indicates that the former is not divisible by the latter, and | indicates that the former is divisible by the latter).
For example,
It can be learned from the foregoing content that to implement a quantum circuit that corresponds to the to-be-processed unitary matrix under the constraints of the connected graph, the electronic device only needs to implement circuits that are of the n-qubit uniformly controlled gates under the constraints of the connected graph.
S102: Decompose each qubit uniformly controlled gate into a second quantity of qubit diagonal unitary matrices and a third quantity of single-qubit gates.
An arbitrary diagonal matrix (a matrix in which elements above and below the principal diagonal are all 0s) in a qubit uniformly controlled gate can be decomposed into rotation gates Rz(θ), Hadamard gates H, phase gates S, and inverse phase gates S†. Therefore, an electronic device implements decomposition of the qubit uniformly controlled gate by decomposing each diagonal matrix, and obtains qubit diagonal unitary matrices and single-qubit gates. In addition, a quantum circuit of a single-qubit gate is known. Therefore, in this embodiment of this application, based on iterative decomposition of the to-be-processed unitary matrix and decomposition of the qubit uniformly controlled gates, a problem of implementing the circuit that corresponds to the to-be-processed unitary matrix is further converted into a problem of implementing a circuit that corresponds to a qubit diagonal unitary matrix (the diagonal unitary matrix is easier to implement than the unitary matrix).
With reference to formulas (1) to (3), the following specifically describes a process of decomposing a qubit uniformly controlled gate.
Each diagonal element of an arbitrary n-qubit uniformly controlled gate is a diagonal matrix, as shown in the formula (1):
In the formula, Vn represents the n-qubit uniformly controlled gate, and Uk represents a diagonal matrix, where k∈[2n-1].
An arbitrary diagonal matrix Uk can be decomposed in a way shown in the formula (2):
In the formula, Rz represents a rotation gate, S represents a phase gate, H represents a Hadamard gate, and S† represents an inverse phase gate.
In this case, the arbitrary n-qubit uniformly controlled gate can be decomposed into a form shown in the formula (3):
In the formula, n-1 represents an identity operator of n−1 qubits (
n-1 represents a (2n−1)×(2n−1)-dimensional identity matrix, and a (2n−1)×(2n−1)-dimensional operator can operate on n−1 qubits for implementation). A1, A2, A4, and A6 are all n-qubit diagonal unitary matrices. The Hadamard gates H, the phase gate S, and the inverse phase gate St are all single-qubit gates. A1 and A2 can be combined into an n-qubit diagonal unitary matrix. Therefore, for the arbitrary n-qubit uniformly controlled gate, an electronic device can obtain three (the second quantity) n-qubit diagonal unitary matrices (that is, A1·A2, A4, and A6) and four (the third quantity) single-qubit gates (that is, the Hadamard gate H and the phase gate S in A3, and the Hadamard gate H and the inverse phase gate St in A3) through decomposition.
For example,
In conclusion, with reference to the decomposing the n-qubit uniformly controlled gate into the n-qubit diagonal unitary matrices in S102, it can be learned that to obtain a target quantum circuit of the n-qubit uniformly controlled gate, and further obtain the quantum circuit that corresponds to the to-be-processed unitary matrix under the constraints of the connected graph, only matching quantum circuits corresponding to the n-qubit diagonal unitary matrices need to be implemented.
S103: Determine, under the constraints of the connected graph, a matching quantum circuit corresponding to each qubit diagonal unitary matrix.
In this embodiment of this application, the electronic device needs to implement, under the constraints of the connected graph, circuits corresponding to the qubit diagonal unitary matrices, and denotes the obtained circuits as the matching quantum circuits. The electronic device determines numbers of the n qubits based on the connected graph, determines qubit pairs based on the numbers, and recursively implements, by using two-qubit gates acting on the qubit pairs, the matching quantum circuits corresponding to the qubit diagonal unitary matrices.
Any two nodes included in a connected graph are connected, that is, any two nodes are connected by an edge. Nodes in a connected graph one-to-one correspond to qubits, that is, nodes in a connected graph represent qubits. Constraints of a connected graph mean that a two-qubit gate in a quantum circuit is allowed to act only on two qubits that are connected by an edge in a connected graph. For example,
Numbers obtained based on a connected graph have the following advantage: A distance between a qubit numbered k∈[n] ([n] represents a set of numbers of n qubits) and a qubit numbered n does not exceed n−k. Therefore, a size of a circuit of a two-qubit gate can be restricted when the circuit is implemented under constraints of a path, and a size of a matching quantum circuit is restricted accordingly.
The following describes a process of implementing, under the constraints of the connected graph, the matching quantum circuit corresponding to the qubit diagonal unitary matrix.
S1031: Determine, under the constraints of the connected graph, numbers respectively corresponding to the n qubits.
In some embodiments, step S1031 may be implemented by using the following solution 2: extracting a target tree from the connected graph; numbering each node in the target tree, to obtain a node number corresponding to each node; and determining the node number corresponding to each node as a number of a qubit corresponding to each node. The target tree is an arbitrary spanning tree in the connected graph, and each qubit corresponds to a node in the target tree.
For example, the electronic device extracts a spanning tree from the connected graph G=(V, E) arbitrarily and numbers the n qubits by using the spanning tree. In the spanning tree, nodes are all of the nodes in the connected graph G=(V, E), and edges are some of the edges in the connected graph G=(V, E), that is, V(G′)=V(G) and E(G′)⊆E(G). G′ represents the spanning tree, and satisfies that all the edges in the edge set E(G′) connect all the nodes without forming a loop.
In more detail, the numbering each node in the target tree, to obtain a node number corresponding to each node in the solution 2 may be implemented by performing the following steps: generating an initial number for each node in the target tree; and searching numbered nodes for a target node that matches a search criterion when the node numbered n−k+2 does not have a child node or does not have a child node that is numbered the initial number, and determining a node number of a leftmost child node of the target node as n−k+1; or determining a node number of a leftmost child node of a child node that is numbered the initial number as n−k+1, when the node numbered n−k+2 has the child node and the child node is numbered the initial number.
The search criterion is a node that is numbered a largest number and has a child node numbered the initial number, 3≤k≤n, the node numbered n is a root node of the target tree (that is, an nth node is the root node of the target tree), and the node numbered n−1 is a leftmost node of the root node (that is, an (n−1)th node is the leftmost node of the root node). In other words, the electronic device first accesses a root node of a spanning tree and numbers the root node n, and then accesses a leftmost child node of the root node and numbers the node n−1. The electronic device then continues to access nodes downward. When an accessed node number is n−k+2 (3≤k≤n), if the node n−k+2 does not have a leaf node or does not have a leaf node numbered 0 (0 is an initial number), the electronic device finds, in a node set {n−k+2, n−k+3, . . . , n} (that is, numbered nodes), a node that is numbered a largest number and has a child node numbered 0, accesses a leftmost node that is of the node and is numbered 0, and numbers the leftmost node n−k+1. If the node n−k+2 has a child node numbered 0, the electronic device accesses a leftmost child node that is of the child node and is numbered 0, and numbers the leftmost child node n−k+1.
For example,
In the foregoing numbering manner, the n qubits may be denoted as [n]. The numbering manner has the following advantage: A distance between a node numbered k∈[n] and a node numbered n does not exceed n−k, and a subgraph generated by {k, k+1, k+2, . . . , n} is a connected graph.
S1032: Extract a reference diagonal unitary matrix from the qubit diagonal unitary matrix based on the numbers of the n qubits. A target qubit of the reference diagonal unitary matrix is a qubit numbered n, and control qubits are qubits numbered 1, 2, . . . , and n−1.
S1033: Determine, based on the numbers of the n qubits, a reference quantum circuit corresponding to the reference diagonal unitary matrix.
Before the reference quantum circuit is determined for the reference diagonal unitary matrix (that is, Λn[n-1]), a definition of transformation of the reference diagonal unitary matrix Λn[n-1] in a standard basis is first described:
In the definition, |x represents the standard basis, and
represents a set of real numbers. For the set of real numbers, the following may be defined: {as:s∈{0,1}n−{0n}}:
For convenience, α0
S1033a: Generate a plurality of qubit sequences for the reference diagonal unitary matrix.
For example, when the reference diagonal unitary matrix is Λn[n-1], the electronic device constructs 2n-1 qubit sequences of length n−1: c1, c2, c3, . . . , c2
In some embodiments, the generating a plurality of qubit sequences for the reference diagonal unitary matrix may be implemented through the following processing: determining a to-be-flipped qubit of a jth qubit sequence, and flipping an element on the to-be-flipped qubit, to obtain a (j+1)th qubit sequence; and determining 2n-1 qubit sequences as the plurality of qubit sequences of the reference diagonal unitary matrix when a value of j reaches 2n-1.
2≤j≤2n-1, and the first qubit sequence is formed by arranging n−1 second elements. For example, when the second element is 0, the first qubit sequence is formed by arranging n−1 0s. The to-be-flipped qubit is obtained by subtracting a value of the ruler function for j from n.
In other words, the first qubit sequence c1=0n-1, and the qubit sequence cj is obtained by flipping an (n−ζ((j−1))th qubit in cj-1. It can be learned with reference to properties of the ruler function that c2
S1033b: Add a first element to the end of each qubit sequence to obtain a plurality of first qubit sequences, and add the second element to the end of each qubit sequence to obtain a plurality of second qubit sequences.
For example, the first element may be 1 and the second element may be 0. In this case, the electronic device expands each qubit sequence of length n−1 to two qubit sequences of length n. For example, when the plurality of qubit sequences are 00, 01, 10, and 11, respectively, the plurality of first qubit sequences may be 001, 011, 101, and 111, and the plurality of second qubit sequences may be 000, 010, 100, and 110.
S1033c: Determine, based on the numbers of the n qubits, a first quantum circuit corresponding to the reference diagonal unitary matrix, the first quantum circuit being configured to load phases corresponding to the plurality of first qubit sequences into the standard basis.
For example, when the first element is 1, the phases corresponding to the first qubit sequences are loaded into a quantum circuit corresponding to the standard basis, to obtain the first quantum circuit corresponding to the reference diagonal unitary matrix. With reference to the transformation of the reference diagonal unitary matrix Λn[n-1] in the standard basis and the set of real numbers defined above, in step S1033c, the electronic device implements a quantum circuit corresponding to a result of transformation
where c is a collective term for a plurality of qubit sequences, c1 is a collective term for first qubit sequences that are obtained by adding 1 to the end of each qubit sequence, and αc1 represents a set of real numbers that includes the first qubit sequences.
In more detail, S1033c may be implemented through the following processing: determining a matching CNOT gate of a jth first qubit sequence based on the numbers of the n qubits; constructing, based on a (j+1)th first qubit sequence, a matching R quantum gate that is applied after the matching CNOT gate of the jth first qubit sequence; connecting the 2n-1−1 matching CNOT gates and the 2n-1−1 matching R quantum gates alternately when j reaches 2n-1−1, to obtain a candidate sub-circuit; determining a supplementary R quantum gate and a supplementary CNOT gate, and connecting the supplementary R quantum gate and the supplementary CNOT gate, to obtain a supplementary sub-circuit; and determining the first quantum circuit based on the candidate sub-circuit and the supplementary sub-circuit. j is a positive integer that increases sequentially, and 1≤j≤2n-1−1.2n-1 is a quantity of the first qubit sequences.
A target qubit of a matching CNOT gate is the qubit numbered n, and a control qubit is a qubit numbered n−ζ(j). To be specific, the electronic device applies a CNOT gate to the qubit numbered n and the qubit numbered n−ζ(j) (ζ(j) is calculated based on the definition of the ruler function). The CNOT gate is configured to process a first qubit sequence. In other words, a number corresponding to a control qubit of the matching CNOT gate of the jth first qubit sequence is calculated based on n and j, and a target qubit is the qubit numbered n.
The supplementary R quantum gate is determined based on the first qubit sequence, a control qubit of the supplementary CNOT gate is a qubit numbered 1, and a target qubit of the supplementary CNOT gate is the qubit numbered n.
For example, a formula (2) is a formula representation of the first quantum circuit:
In the formula, αc1 represents the set of real numbers that includes the first qubit sequences, CNOTnn-ζ(j) represents a matching CNOT gate, R(αc
The formula (2) may be implemented by following the process below:
S1033d: Determine, based on the numbers of the n qubits, a second quantum circuit corresponding to the reference diagonal unitary matrix, the second quantum circuit being configured to load phases corresponding to the plurality of second qubit sequences into the standard basis.
In some embodiments, step S1033d may be implemented by using the following solution 1: determining a to-be-implemented diagonal unitary matrix corresponding to the reference diagonal unitary matrix, the to-be-implemented diagonal unitary matrix corresponding to n−1 qubits; decomposing the to-be-implemented diagonal unitary matrix by using a transformation circuit, to obtain a substitute diagonal unitary matrix, the transformation circuit being configured to substitute quantum states in a first qubit set corresponding to the to-be-implemented diagonal unitary matrix for quantum states in a second qubit set; determining, based on the numbers of the n qubits, a substitute quantum circuit corresponding to the substitute diagonal unitary matrix; and determining a connection result of the transformation circuit, the substitute quantum circuit, and an inverse transformation circuit corresponding to the transformation circuit as the second quantum circuit, the inverse transformation circuit being configured to substitute the quantum states in the second qubit set for the quantum states in the first qubit set (for example, the inverse transformation circuit transforms the qubits into initial positions, that is, original quantum states).
The following describes the solution 1 by using an example. When the second element is 0, the phases corresponding to the second qubit sequences are loaded into the quantum circuit corresponding to the standard basis, to obtain the second quantum circuit. With reference to the transformation of the reference diagonal unitary matrix Λn[n-1] in the standard basis and the set of real numbers defined above, the electronic device implements a quantum circuit corresponding to a result of
and determines the quantum circuit as the second quantum circuit, where c0 represents second qubit sequences that are obtained by adding 0 to the end of each qubit sequence, and αc0 represents a set of real numbers that includes the second qubit sequences.
Implementing
is actually implementing an (n−1)-qubit diagonal unitary matrix that corresponds to a qubit set [n−1] (a to-be-implemented diagonal unitary matrix Λn-1[n-2]), that is:
However, a graph generated based on the qubit set [n−1] (that is, a first qubit set) is not necessarily a connected graph, but a graph generated based on a qubit set [n]−{1} (that is, a second qubit set) is a connected graph. Therefore, for a purpose of implementing Λn-1[n-2], a transformation circuit that can substitute quantum states in the qubit set [n−1] corresponding to the to-be-implemented diagonal unitary matrix for quantum states in the qubit set [n]−{1} may be first determined in this embodiment of this application. To be specific, the transformation circuit is configured to substitute the quantum states in the first qubit set corresponding to the to-be-implemented diagonal unitary matrix for the quantum states in the second qubit set. For example, the qubit set [n−1] is a set of qubits numbered 1, 2, 3, . . . , and n−1. Respective quantum states of the qubits are represented by x1, x2
, . . . , and Xn-1
. In this case, a quantum state of a qubit numbered n is xn
. The qubit set [n]−{1} is a set of qubits numbered 2, 3, . . . , and n. In this case, a process of substitute the quantum states in the qubit set [n−1] for the quantum states in the qubit set [n]−{1} is as follows: The quantum states of the qubits numbered 2, 3, . . . , and n are replaced with x1
, x2
, . . . , and xn-1
, respectively. In this case, the quantum state of the qubit numbered n is xn-1
. Then, the to-be-implemented diagonal unitary matrix is decomposed in the following manner: Based on a unitary matrix corresponding to the transformation circuit and a unitary matrix corresponding to an inverse transformation circuit, the to-be-implemented diagonal unitary matrix is decomposed, to obtain Λn[n-1]-{1} that corresponds to the qubit set [n]−{1} (a substitute diagonal unitary matrix). Decomposition principles are as follows: Λn-1[n-2] and Λn[n-1]-{1} satisfy Y=PXP−1 (Y represents the to-be-implemented diagonal unitary matrix, P represents the unitary matrix corresponding to the transformation circuit, P−1 represents the unitary matrix corresponding to the inverse transformation circuit, and X represents the substitute diagonal unitary matrix). Therefore, after the transformation circuit is determined, the unitary matrix corresponding to the transformation circuit and the unitary matrix corresponding to the inverse transformation circuit are both known, and accordingly Λn[n-1]-{1} is obtained through matrix transformation (that is, by left-multiplying Y by P−1, right-multiplying Y by P, and decomposing Y). Then, a quantum circuit corresponding to Λn[n-1]-{1} (a substitute quantum circuit) is determined in the following manner: Because Λn[n-1]-{1} is constrained by the connected graph, the substitute diagonal unitary matrix Λn[n-1]-{1} may be decomposed based on the numbers of the n qubits. Then, quantum circuits corresponding to quantum gates that are finally obtained through decomposition are connected, to obtain the substitute quantum circuit. For example, Λn[n-1]-{1} is used as a new reference diagonal unitary matrix, and steps S1033a to S1033e are performed to obtain the substitute quantum circuit corresponding to Λn[n-1]-{1}. To be specific, step S1033a is performed to construct qubit sequences for Λn[n-1]-{1}; step S1033b is performed, to obtain first qubit sequences for Λn[n-1]-{1} by adding 0 to the end of each qubit sequence, and to obtain second qubit sequences for Λn[n-1]-{1} by adding 1 to the end of each qubit sequence; then a first quantum circuit corresponding to Λn[n-1]-{1} is determined in a manner similar to a process in S1033c; a second quantum circuit corresponding to Λn[n-1]-{1} is determined by using a method in step S1033d; and step S1033e is performed to determine the substitute quantum circuit corresponding to Λn[n-1]-{1}. After the quantum circuit corresponding to Λn[n-1]-{1} (the substitute quantum circuit) is determined, the transformation circuit and the inverse transformation circuit that corresponds to the transformation circuit are connected based on the substitute quantum circuit, to obtain a second quantum circuit.
S1033e: Determine, based on the first quantum circuit and the second quantum circuit, the reference quantum circuit corresponding to the reference diagonal unitary matrix.
The electronic device first applies the first quantum circuit to the n qubits and then applies the second quantum circuit also to the n qubits. The obtained overall circuit is the reference quantum circuit. In other words, the electronic device connects the first quantum circuit and the second quantum circuit, and obtains the reference quantum circuit.
For example,
S1034: Transform the reference quantum circuit by using a CNOT gate, to obtain a transformation quantum circuit corresponding to a remaining diagonal unitary matrix.
The remaining diagonal unitary matrix is a diagonal unitary matrix that is obtained after the reference diagonal unitary matrix is removed from the qubit diagonal unitary matrix.
S1035: Determine the reference quantum circuit corresponding to the reference diagonal unitary matrix and the transformation quantum circuit corresponding to the remaining diagonal unitary matrix as the matching quantum circuit corresponding to the qubit diagonal unitary matrix.
S104: Integrate the second quantity of matching quantum circuits and the third quantity of single-qubit gates, to obtain a target quantum circuit of each qubit uniformly controlled gate.
The single-qubit gates are known quantum circuits. After the electronic device obtains, by performing step S103, the matching quantum circuits that are constrained by the connected graph, step S104 may be implemented in the following manner: The matching quantum circuits and the single-qubit gates are connected in an order, to obtain the target quantum circuit of each qubit uniformly controlled gate. The order is a decomposition order of the qubit diagonal unitary matrices and the single-qubit gates that are obtained through decomposition of the qubit uniformly controlled gate, for example, an order in
For example, as shown in
S105: Connect the first quantity of target quantum circuits, to obtain an optimized quantum circuit.
Herein, after obtaining the first quantity of target quantum circuits by performing step S104, the electronic device connects the first quantity of target quantum circuits in an iterative decomposition order of the qubit uniformly controlled gates, to obtain the optimized quantum circuit (that is, an optimized quantum circuit corresponding to the to-be-optimized quantum circuit). The iterative decomposition order is an order of the qubit uniformly controlled gates that are obtained through iterative decomposition of the to-be-processed unitary matrix. It can be learned from the foregoing content that computation time required by the optimized quantum circuit is less than computation time required by the to-be-optimized quantum circuit.
In conclusion, this embodiment of this application is implemented in a scenario in which the to-be-optimized quantum circuit is optimized under the constraints of the connected graph, to obtain, by optimizing the to-be-optimized quantum circuit, an optimized quantum circuit that can implement the same functions as the to-be-optimized quantum circuit but has fewer quantum gates (that is, less required computation time). Each quantum circuit has a corresponding unitary matrix. In this embodiment of this application, the electronic device first transforms the to-be-processed quantum circuit into a unitary matrix. The obtained unitary matrix is the to-be-processed unitary matrix. The to-be-optimized quantum circuit is of a complex structure. Therefore, without changing functions and while being constrained by the connected graph, it is difficult to optimize the to-be-optimized quantum circuit. However, a process of implementing a quantum circuit corresponding to a unitary matrix is simple. Therefore, in this embodiment of this application, the electronic device first iteratively decomposes the to-be-processed unitary matrix that is obtained through transformation of the to-be-optimized quantum circuit, and then decomposes the qubit uniformly controlled gates that are obtained through decomposition, to obtain the qubit diagonal unitary matrices and the single-qubit gates, so as to recursively convert a problem of optimizing a quantum circuit into a problem of implementing a quantum circuit corresponding to a qubit diagonal unitary matrix. The electronic device then determines the matching quantum circuits for the qubit diagonal unitary matrices under the constraints of the connected graph, and finally integrates the matching quantum circuits and the single-qubit gates, to obtain the optimized quantum circuit. In this way, an optimal quantum circuit under the constraints of the connected graph is obtained, that is, an optimized quantum circuit that is faster to compute, improving optimization of the quantum circuit. In addition, when the obtained optimized quantum circuit is applied to a quantum computing device, a computing speed of the quantum computing device is increased, improving computing efficiency of the quantum computing device.
In conclusion, the following describes optimization effects of the quantum circuit optimization method provided in this embodiment of this application.
First, circuit implementation of a CNOT gate and a SWAP gate under constraints of a path is introduced:
The following analyzes a size of a circuit that is recursively implemented under constraints of a connected graph G and that corresponds to an n-qubit diagonal unitary matrix Λn[n-1]. It is assumed that S[n]-[k] represents a size of a circuit that corresponds to a diagonal unitary matrix and that acts on a qubit set [n]−[k], where [n]−[0]def[n] is defined. When a first quantum circuit is determined, it can be learned based on numbers of qubits in the connected graph that a distance between a control qubit n−ζ(j) and a target qubit n in a CNOTbn-ζ(j) does not exceed ζ(j) and with reference to implementation of a CNOT gate under constraints of a path, it can be learned that the CNOTnn-ζ(j) can be implemented by a circuit of a size O(ζ(j)). In addition, the ruler function has the following property: In a set {ζ(i):∀i∈[2n-1−1]}, an element k appears for 2n-1-k times. Therefore, a size of the first quantum circuit is:
During construction of a second quantum circuit, a size of the circuit that undergoes two substitutions is O((n−0)2)=O(n2). Therefore, S[n]-[0] satisfies the following recurrence relation:
In conclusion, the size of the circuit corresponding to the n-qubit diagonal unitary matrix under the constraints of the connected graph is O(2n), and therefore a size of a circuit of an n-qubit uniformly controlled gate is 3·O(2n)+4=O(2n). In addition, because 2n−1 n-qubit uniformly controlled gates are obtained after an n-qubit unitary matrix is decomposed, it can be learned that under the constraints of the connected graph, the n-qubit unitary matrix can be implemented by a circuit of a size O(2n)·(2n−1)=O(4n). Therefore, according to the quantum circuit optimization method provided in this embodiment of this application, an optimal quantum circuit in a progressive sense can be obtained, that is, an optimized quantum circuit that is faster to compute. In addition, when the optimized quantum circuit is applied to a quantum computing device, a computing speed of the quantum computing device can be increased, improving computing efficiency of the quantum computing device.
Besides, in this embodiment of this application, an arbitrary n-qubit uniformly controlled gate is implemented by a circuit of the size O(2n) under constraints of a connected graph, and a quantum state preparation circuit can be decomposed into n qubit uniformly controlled gates whose sizes are 1, 2, . . . , n, respectively. Therefore, in this embodiment of this application, a quantum state preparation circuit of a circuit size O(2n) under constraints of a connected graph can be implemented, and as such, the size of the quantum state preparation circuit under the constraints of the connected graph is also optimal.
The following continues to describe an exemplary structure of the quantum circuit optimization apparatus 255 provided in the embodiment of this application when the quantum circuit optimization apparatus 255 is implemented as software modules. In some embodiments, as shown in
a matrix decomposition module 2551, configured to: transform a to-be-optimized quantum circuit into a to-be-processed unitary matrix, and decompose the to-be-processed unitary matrix iteratively, to obtain a first quantity of qubit uniformly controlled gates; a controlled gate decomposition module 2552, configured to decompose each qubit uniformly controlled gate into a second quantity of qubit diagonal unitary matrices and a third quantity of single-qubit gates; a circuit implementation module 2553, configured to determine, under constraints of a connected graph, a matching quantum circuit corresponding to each qubit diagonal unitary matrix; and a connection and integration module 2554, configured to: integrate the second quantity of matching quantum circuits and the third quantity of single-qubit gates, to obtain a target quantum circuit of each qubit uniformly controlled gate, and connect the first quantity of target quantum circuits, to obtain an optimized quantum circuit.
In some embodiments, the matrix decomposition module 2551 is further configured to: perform the following processing for an ith iteration:
performing matrix decomposition on an initial unitary matrix of the ith iteration, to obtain a decomposition result of the ith iteration, an initial unitary matrix of the first iteration being the to-be-processed unitary matrix, i being a positive integer that increases sequentially, 1≤i≤n, and n being a quantity of qubits; extracting a qubit uniformly controlled gate of the ith iteration and generated unitary matrices of the ith iteration from the decomposition result of the ith iteration; and determining the generated unitary matrices of the ith iteration as initial unitary matrices of an (i+1)th iteration; and determine 2{circumflex over ( )}(n−1) qubit uniformly controlled gates that are obtained after n iterations are performed, as the first quantity of qubit uniformly controlled gates.
In some embodiments, the circuit implementation module 2553 is further configured to: determine, under the constraints of the connected graph, numbers respectively corresponding to the n qubits; extract a reference diagonal unitary matrix from the qubit diagonal unitary matrix based on the numbers of the n qubits, a target qubit of the reference diagonal unitary matrix being a qubit numbered n, and control qubits being qubits numbered 1, 2, . . . , and n−1; determine, based on the numbers of the n qubits, a reference quantum circuit corresponding to the reference diagonal unitary matrix; transform the reference quantum circuit by using a controlled-NOT (CNOT) gate, to obtain a transformation quantum circuit corresponding to a remaining diagonal unitary matrix, the remaining diagonal unitary matrix being a diagonal unitary matrix that is obtained after the reference diagonal unitary matrix is removed from the qubit diagonal unitary matrix; and determine the reference quantum circuit corresponding to the reference diagonal unitary matrix and the transformation quantum circuit corresponding to the remaining diagonal unitary matrix as the matching quantum circuit corresponding to the qubit diagonal unitary matrix.
In some embodiments, the circuit implementation module 2553 is further configured to: generate a plurality of qubit sequences for the reference diagonal unitary matrix; add a first element to the end of each qubit sequence to obtain a plurality of first qubit sequences, and add a second element to the end of each qubit sequence to obtain a plurality of second qubit sequences; determine, based on the numbers of the n qubits, a first quantum circuit corresponding to the reference diagonal unitary matrix, the first quantum circuit being configured to load phases corresponding to the plurality of first qubit sequences into a standard basis; determine, based on the numbers of the n qubits, a second quantum circuit corresponding to the reference diagonal unitary matrix, the second quantum circuit being configured to load phases corresponding to the plurality of second qubit sequences into the standard basis; and determine, based on the first quantum circuit and the second quantum circuit, the reference quantum circuit corresponding to the reference diagonal unitary matrix.
In some embodiments, the circuit implementation module 2553 is further configured to: determine a matching CNOT gate of a jth first qubit sequence based on the numbers of the n qubits, j being a positive integer that increases sequentially, and 1≤j≤2n-1−1; construct, based on a (j+1)th first qubit sequence, a matching R quantum gate that is applied after the matching CNOT gate of the jth first qubit sequence; connect the 2n-1−1 matching CNOT gates and the 2n-1−1 matching R quantum gates alternately when j reaches 2n-1−1, to obtain a candidate sub-circuit; determine a supplementary R quantum gate and a supplementary CNOT gate, and connect the supplementary R quantum gate and the supplementary CNOT gate, to obtain a supplementary sub-circuit; and determine the first quantum circuit based on the candidate sub-circuit and the supplementary sub-circuit.
In some embodiments, the supplementary R quantum gate is determined based on the first qubit sequence, a control qubit of the supplementary CNOT gate is a qubit numbered 1, and a target qubit of the supplementary CNOT gate is a qubit numbered n; and a number corresponding to a control qubit of the matching CNOT gate of the jth first qubit sequence is calculated based on n and j, and a target qubit of the matching CNOT gate of the jth first qubit sequence is the qubit numbered n.
In some embodiments, the circuit implementation module 2553 is further configured to: determine a to-be-implemented diagonal unitary matrix corresponding to the reference diagonal unitary matrix, the to-be-implemented diagonal unitary matrix corresponding to n−1 qubits; substitute quantum states in a first qubit set corresponding to the to-be-implemented diagonal unitary matrix for quantum states in a second qubit set by using a transformation circuit, and determine, as a substitute diagonal unitary matrix, the to-be-implemented diagonal unitary matrix that undergoes the substitution; determine, based on the numbers of the n qubits, a substitute quantum circuit corresponding to the substitute diagonal unitary matrix; and determine a connection result of the transformation circuit, the substitute quantum circuit, and an inverse transformation circuit corresponding to the transformation circuit as the second quantum circuit, the inverse transformation circuit being configured to substitute the quantum states in the second qubit set for the quantum states in the first qubit set.
In some embodiments, the circuit implementation module 2553 is further configured to: determine a to-be-flipped qubit of a jth qubit sequence, and flip an element on the to-be-flipped qubit, to obtain a (j+1)th qubit sequence, 2≤j≤2n-1, and the first qubit sequence being obtained by arranging n−1 second elements; and determine 2n-1 qubit sequences as the plurality of qubit sequences of the reference diagonal unitary matrix when a value of j reaches 2n-1.
In some embodiments, the circuit implementation module 2553 is further configured to: extract a target tree from the connected graph, the target tree being an arbitrary spanning tree in the connected graph, and each qubit corresponding to a node in the target tree; number each node in the target tree, to obtain a node number corresponding to each node; and determine the node number corresponding to each node as a number of a qubit corresponding to each node.
In some embodiments, the circuit implementation module 2553 is further configured to: generate an initial number for each node in the target tree; and search numbered nodes for a target node that matches a search criterion when the node numbered n−k+2 does not have a child node or does not have a child node that is numbered the initial number, and determine a node number of a leftmost child node of the target node as n−k+1, the search criterion being a node that is numbered a largest number and has a child node numbered the initial number, 3≤k≤n, the node numbered n being a root node of the target tree, and the node numbered n−1 being a leftmost node of the root node; or determine a node number of a leftmost child node of a child node that is numbered the initial number as n−k+1, when the node numbered n−k+2 has the child node and the child node is numbered the initial number.
An embodiment of this application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions. The computer instructions are stored in a computer-readable storage medium. A processor in an electronic device reads the computer instructions from the computer-readable storage medium. The processor executes the computer instructions, so that the electronic device performs the quantum circuit optimization method in the embodiment of this application.
An embodiment of this application provides a non-transitory computer-readable storage medium storing executable instructions. The computer-readable storage medium stores the executable instructions. When the executable instructions are executed by a processor, the processor is caused to perform the quantum circuit optimization method provided in the embodiment of this application, for example, the quantum circuit optimization method shown in
In some embodiments, the computer-readable storage medium may be a memory such as a FRAM, a ROM, a PROM, an EPROM, an EEPROM, a flash memory, a magnetic surface memory, a compact disc, or a CD-ROM, or may be a device including one or any combination of the foregoing memories.
In some embodiments, the executable instructions may be in a form of a program, software, a software module, a script, or code, and may be written in any form of programming language (including a compiled language or an interpreted language, or a declarative language or a procedural language). In addition, the executable instructions may be deployed in any form, including being deployed as a standalone program or as a module, a component, a subroutine, or another unit suitable for use in a computing environment.
For example, the executable instructions may be deployed to be executed on an electronic device, or on a plurality of electronic devices that are located in a place, or on a plurality of electronic devices that are distributed across a plurality of places and are connected to each other via a communication network.
In conclusion, in the embodiments of this application, the electronic device first iteratively decomposes the to-be-processed unitary matrix that is obtained through transformation of the to-be-optimized quantum circuit, and then decomposes the qubit uniformly controlled gates that are obtained through decomposition, to obtain the qubit diagonal unitary matrices and the single-qubit gates, so as to recursively convert a problem of optimizing a quantum circuit into a problem of implementing a quantum circuit corresponding to a qubit diagonal unitary matrix. The electronic device then determines the matching quantum circuits for the qubit diagonal unitary matrices under the constraints of the connected graph, and finally integrates the matching quantum circuits and the single-qubit gates, to obtain the optimized quantum circuit. In this way, an optimal quantum circuit under the constraints of the connected graph is obtained, that is, an optimized quantum circuit that is faster to compute, improving optimization of the quantum circuit. In addition, when the optimized quantum circuit is applied to a quantum computing device, a computing speed of the quantum computing device can be increased, that is, computing efficiency of the quantum computing device is improved. Therefore, a quantum state preparation circuit of a circuit size O(2n) under the constraints of the connected graph can be implemented, and as such, the size of the quantum state preparation circuit under the constraints of the connected graph is also optimal.
The foregoing descriptions are merely embodiments of this application and are not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, and the like made without departing from the spirit and scope of this application shall fall within the protection scope of this application.
Number | Date | Country | Kind |
---|---|---|---|
202210885994.4 | Jul 2022 | CN | national |
This application is a continuation application of PCT Patent Application No. PCT/CN2023/096212, entitled “QUANTUM CIRCUIT OPTIMIZATION METHOD AND APPARATUS, ELECTRONIC DEVICE, COMPUTER-READABLE STORAGE MEDIUM, AND COMPUTER PROGRAM PRODUCT” filed on May 25, 2023, which is based upon and claims priority to Chinese Patent Application No. 202210885994.4, entitled “QUANTUM CIRCUIT OPTIMIZATION METHOD AND APPARATUS, ELECTRONIC DEVICE, COMPUTER-READABLE STORAGE MEDIUM, AND COMPUTER PROGRAM PRODUCT” filed on Jul. 26, 2022, all of which is incorporated by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2023/096212 | May 2023 | WO |
Child | 18610133 | US |