Quantum circuit optimization
By identifying and replacing quantum circuit gate modes and optimizing quantum circuits using the low-quantum cost mode in the template library, the quantum circuit programming and optimization problems in the existing technology are solved, and the quantum computing performance and economic improvements are achieved.
Patent Information
- Application Number
- CN202080016172.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2019-02-21
- Filing Date
- 2020-02-21
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2040-02-21
AI Technical Summary
The prior art is difficult to efficiently program and optimize quantum circuits to take full advantage of quantum computers, and there are performance losses caused by the number of quantum gates and circuit depth.
By identifying and replacing quantum circuit gate patterns, optimizing quantum circuits using low quantum cost patterns in pre-generated template libraries, reducing quantum costs and circuit depth, and using mapping and replacement techniques to convert abstract circuits into lower cost physical representations.
It realizes efficient optimization of quantum circuits, reduces quantum cost and circuit depth, improves the performance and economy of quantum computing, and enhances the utilization of the advantages of quantum computers.
Smart Images

Figure CN113614728B_ABST
Abstract
Description
Technical Field
[0001] Embodiments described herein generally relate to optimizing quantum circuits built by classical processes. Background Art
[0002] A quantum computer is a computing system that uses quantum mechanical phenomena such as superposition and entanglement to process data. Unlike digital computers, where data is encoded as binary digits (bits) that are in one of two definite states ("0" or "1"), quantum computing requires that data be encoded into quantum bits (hereafter referred to as "qubits"), where a single qubit can represent "1", "0", or any quantum superposition of the two qubit states. In general, a quantum computer with N qubits can be in up to 2 states at the same time. N That is, a pair of qubits can be in any quantum superposition of four states, and three qubits can be in any superposition of eight states.
[0003] Large-scale quantum computers can solve certain problems much faster than digital computers (also referred to herein as "classical computers"). In the operation of a quantum computer, a calculation can be initialized by setting the quantum bits in a controlled initial state. By manipulating these quantum bits, a predetermined sequence of quantum logic gates is implemented, which represents the solution to the problem to be solved, which is called a quantum algorithm. Quantum algorithms, such as Shor's algorithm, Simon's algorithm, etc., can run more efficiently than any possible classical algorithm.
[0004] Given the inherent advantages of quantum computers in solving certain problems, the challenge is to program quantum computers to exploit their advantages in an efficient and economical way. Summary of the invention
[0005] In an example embodiment, a method of optimizing a quantum circuit includes: identifying a set of quantum circuit gates intended to perform a function; finding a quantum circuit gate template from a template library that also performs the function; and replacing the identified set of quantum circuit gates with the quantum circuit gate template.
[0006] In another example embodiment, a computer readable medium stores instructions that, when executed, cause a digital computing processor to receive a portion of a quantum circuit; identify, from within the received portion of the quantum circuit, a quantum gate pattern that matches a portion of a pattern from a pre-generated template library; search the template library for a quantum gate replacement pattern; determine that a quantum cost of the quantum gate replacement pattern is lower than a quantum cost of the identified quantum gate pattern; and replace the identified quantum gate pattern with the quantum gate replacement pattern.
[0007] In yet another embodiment, an optimizer includes: a quantum circuit analyzer to identify a quantum gate pattern that matches at least a portion of a pattern from a pre-generated template library; the template library to: execute an algorithm to search for a quantum gate replacement pattern, identify the quantum gate replacement pattern to replace the identified quantum gate pattern when a quantum cost of the quantum gate replacement pattern is determined to be less than a quantum cost of the identified quantum gate pattern, and replace the identified quantum gate pattern with the quantum gate replacement pattern.
[0008] The foregoing is merely illustrative and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features will become apparent by reference to the drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In the following detailed description, embodiments are described by way of example only, since various changes and modifications will become apparent to those skilled in the art from the following detailed description. The use of the same reference numerals in different drawings indicates similar or identical items.
[0010] Figure 1 A quantum circuit diagram representing an example embodiment of a template having multiple elements as described herein is shown.
[0011] Figure 2A A quantum circuit diagram representing an example embodiment of an input circuit having multiple elements as described herein is shown.
[0012] Figure 2B A circuit diagram representing an optimized circuit obtained by template-based optimization is shown in accordance with at least some embodiments described herein.
[0013] Figure 3 shows a block diagram representing an example classical computing system for optimizing quantum circuits arranged in accordance with at least some embodiments described herein;
[0014] Figure 4 showing a block diagram representing an example classical computing system optimizer arranged in accordance with at least some embodiments described herein;
[0015] Figure 5 shows an example process flow for optimizing quantum circuits in a classical computing environment, arranged in accordance with at least some embodiments described herein;
[0016] Figure 6 An illustrative computing device is shown in which any of the processes and sub-processes for optimizing quantum circuits may be implemented as executable instructions stored on a computer-readable medium.
[0017] Figure 7is an illustration of the mapping of qubits from template to circuit.
[0018] Figure 8 It is a diagram of gate pattern matching.
[0019] Fig. 9 is a diagram illustrating an example search library.
[0020] Fig.10 is a diagram illustrating an example search implementation. DETAILED DESCRIPTION
[0021] In the following detailed description, reference is made to the accompanying drawings that form a part of the specification. In the accompanying drawings, similar symbols generally identify similar components, unless otherwise specified in the text. In addition, unless otherwise indicated, the description of each consecutive figure may refer to features from one or more previous figures to provide a clearer background and more substantial explanation of the current exemplary embodiment. However, the example embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other implementations may be utilized and other changes may be made without departing from the spirit and scope of the subject matter presented herein. It is readily understood that the aspects of the invention generally described herein and illustrated in the drawings may be arranged, replaced, combined, separated, and designed in a variety of different configurations, all of which are expressly contemplated herein.
[0022] Means embodied in one or more of systems, apparatuses, applications, programs, and methods are described herein whereby quantum circuits are simplified through algorithmic synthesis of quantum gate templates using, for example, map-and-replace techniques.
[0023] In this specification, in addition to their accepted meanings, the following terms may be used:
[0024] "Classical computing", "classical program", "digital computing", "digital program" or their variants may refer to the calculation / processing of data that has been converted into binary numbers. Classical computing processors may include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), tensor processing units (TPUs), application specific integrated circuits (ASICs), field programmable gate arrays, etc. and their unbound permutations. Non-limiting examples thereof may include classical optimization functions that can be parallelized and run on multi-core classical computers; classical computers with GPUs for performing parallel computing, etc.
[0025] "Quantum computing" or variations thereof may refer to computation / processing of data that has been encoded as quantum bits. Quantum computing utilizes quantum bits to perform computations to produce results much faster than classical computing, or to make problems that are intractable in classical computing tractable. The embodiments described herein certainly contemplate implementation in even faster and more efficient quantum computing systems as the technology develops.
[0026] An "environment" may refer to a computing environment in which components exist that, when executing a program, can utilize, for example, utilities such as libraries, other programs, other hardware, etc. Thus, in this document, reference may be made to a classical computing environment, a quantum computing environment, etc.
[0027] A "quantum gate" may refer to a controlled interaction that manipulates the state and / or phase of a qubit in a quantum computing system, thereby changing the information content of the system.
[0028] A "quantum circuit" can refer to a sequence of quantum gate operations acting on a set of qubits. The name historically comes from quantum algorithms being expressed as a sequence of quantum logic gates, similar to classical logic gates in traditional circuit design.
[0029] Quantum information processing (QIP) algorithms can be represented using quantum circuits. Abstract gate operations have been used in the design and construction of QIP algorithms, which, when implemented at the physical level, must be compiled into a set of hardware-specific operations that manipulate the states of qubits. In this context, logic gates can refer to abstract, design-oriented operations, while physical gates can refer to hardware-specific implementations.
[0030] In general, there may be multiple (non-unique) expressions of algorithmic functions in logic gates. For a given quantum circuit, there may be other logical representations that express the same function within the global phase factor. Although these circuits may be mathematically equivalent to each other for the purpose of quantum computing, their respective performance characteristics may be different when implemented in actual hardware. That is, although there may be multiple equivalent circuits that cause the same computational state evolution, some actual representations may work better than others when mapped to physical gates.
[0031] "Quantum cost" may refer to the expected performance penalty of a logic circuit that is mapped and executed as physical gates; thus, a logical representation of a quantum circuit that is considered to have lower performance is considered to have a higher quantum cost.
[0032] Thus, the optimizer embodiments disclosed and described herein reduce the expected cost by manipulating one or more circuit representations. The apparatus, components, systems, methods, and programs described herein relate to a classical computing optimizer that converts an abstract circuit into a logically identical representation that has a lower quantum cost and is therefore more suitable for quantum processing.
[0033] The process of mapping logic gates to physical gates can be called a compiler step or compilation. The process of selecting a preferred (i.e., lowest cost) logic representation can be called optimization. The quantum cost of each logic gate sequence can depend on the method of the compilation step. Therefore, when considering the optimization of logic circuits, a consistent compilation process and therefore a consistent definition of the quantum cost function can be used for optimization.
[0034] According to example embodiments described herein, quantum computing may include performing an iterative process by which one or more quantum circuits may be written in a classical computing environment for execution in a quantum computing environment. Non-limiting examples of such classical computing environments that may be used include desktop computers, laptop computers, mobile devices, virtual reality environments, and the like. Quantum circuits may be submitted to a quantum computing device via a network (e.g., the Internet), where the one or more quantum circuits may be queued with other quantum circuits, similar to batch processing of, for example, a mainframe computing device. The queued quantum circuits may be executed sequentially.
[0035] As explained above, a QIP algorithm can be represented in various ways by different quantum circuits that describe the same function. In theory, a quantum computer that can execute these different circuit representations of the same algorithm in the absence of errors, decoherence, noise, etc. faithfully produces the same results. However, in practice, physical quantum computing systems may be more error-prone in one representation relative to another, resulting in different results with varying degrees of consistency with the ideal result. Therefore, a compiler that uses logic gates to design an arbitrary quantum program and submits it for execution on a quantum computer can benefit from cost reduction by first converting the logic circuits into a lower-cost representation.
[0036] Thus, embodiments described herein may include finding a sublist of gates, i.e., patterns, in a main circuit whose operation can be improved by replacing the pattern with a set of gates that achieve better physical results (i.e., have reduced quantum cost, but whose logical functionality is otherwise equivalent). These search and replace patterns are expressions of previously generated template identities, i.e., templates.
[0037] As referenced herein, a template can be viewed as a list of gates that have no net effect on the state of a quantum system in an ideal system; that is, an identity operation, e.g., two NOT gates in series are equivalent to a negation operation. A template can also be viewed as a list of gates that form an identity within a global phase. Non-trivial templates with many gates spanning multiple qubits can be pre-generated and used to reduce an input circuit to the same circuit with fewer gates and / or to a computationally more efficient or cost-effective circuit solution. A template is typically defined as a ring of gates because when the unitary operator U 1 U 2 ...U N The product of is evaluated to identity, where U n , n=1,2,...N represents the nth operator, and any cyclic permutation of the product is also an identity.
[0038] Figure 1 A quantum circuit diagram 100 is shown, which represents an example of a template having multiple elements as described herein. CNOT gates 110, 120, 130, 140, and 150 are represented by symbols The symbol represents a NOT gate connected to a solid circle representing a control. The embodiments and implementations described and described herein are not limited in number. Figure 1 shown.
[0039] Template 100 evaluates to an identity operation. That is, Figure 1 In a non-limiting example embodiment, CNOT gates 110, 120, and 130 may be replaced with the inverse of the remainder of the circuit including CNOT gates 140 and 150. This is a direct extension of the functionality of the identity operation, since the product of two operators as an identity implies that one operator is the inverse of the other.
[0040] The example template 100 can be used to reduce the number of CNOT gates in any input quantum circuit having a quantum gate pattern matching the first three CNOT gate patterns 110, 120, and 130 by one, effectively replacing the gate pattern with the inverse of the subcircuit including CNOT gates 140 and 150. The more patterns that appear in the input quantum circuit, the more the number of quantum gates is reduced by applying the template-based quantum circuit optimization described and described herein. The number of quantum gates can be considered an example of quantum cost.
[0041] The need for classical computational efficiency of template-based optimization is essential because the input quantum circuit may potentially include many known gate patterns and need to be managed in a timely manner. In order to efficiently identify known patterns, a directed acyclic graph (DAG) representation of the quantum circuit can be generated to expose the gate connection pattern along the selected qubit wire.
[0042] To identify subcircuits in the input circuit that match a given template circuit, two mappings are performed, namely, qubit mapping and gate mapping. Qubit mapping consists of matching qubit labels between the input circuit and the template circuit. Gate mapping consists of matching the type and order of quantum gates defined on the DAG representation of the circuit between the input circuit and the template circuit. When these two mappings are completed, identification can be made and template-based optimization can be applied.
[0043] As an example of identification, and to contextualize the above-described embodiments and implementations, an example diagram is depicted and described below, specifically as follows: Figure 7 and Figure 8 shown.
[0044] Figure 7 and Figure 8 Examples generally involve scanning of an input circuit, identifying matches with stored templates, and replacing the identified patterns with the stored templates to reduce quantum cost.
[0045] The matching can be implemented as a DAG search that builds candidate mappings from template qubits to circuit qubits. To match the template pattern to the gates of the input circuit, a non-deterministic finite automaton (NFA) can evaluate the gate mapping before substitution. An NFA based on regular expression matching can be used to compute the gate mapping.
[0046] Figure 2A A quantum circuit diagram 200a is shown, which represents an example of an input circuit having multiple elements including CNOT gates 210a, 240a, 260a, 270a, where R z (a) Single-qubit z-rotation gate (R) corresponding to angle a z (a) 220a), H represents Hadamard Gate (H 230a), Corresponding to the single-qubit NOT gate 250a.
[0047] In a non-limiting example, in order to identify a subcircuit in circuit 200a that matches the example template 100, CNOT gate 240a can be considered a seed gate. According to the selection of the seed gate in this example, the qubit mapping reads as the first and second qubits in template 100 are mapped to the second and third qubits in the example input circuit 200a, respectively. Along the third qubit line from the top in circuit 200a to which the qubit line is applied as the target of CNOT gate 240a, a DAG search is performed from seed gate 240a to the right, and the next qubit of NOT gate 250a is encountered. Using the commutation rule, it can be determined that CNOT gate 240a is commutated with NOT gate 250a. Therefore, according to the example template 100, although NOT gate 250a is not part of the pattern to be identified, the identification process is not terminated because it has been determined that the non-matching gate 250a can be commuted, so that there is a chance that seed gate 240a can still be used to form template pattern 100. The DAG search is continued along the same third qubit line in circuit 200a, CNOT gates 260a and 270a are found that match expected pattern 100, while successfully mapping (i.e., qubit mapping) the third and last qubit in template 100 to the fourth and last qubit in circuit 200a, and the identification process can be terminated because gates 240a, 260a, and 270a match most of expected template 100 according to the qubit mapping and gate mapping (3).
[0048] The recognition process may be performed on one template at a time or on multiple templates in parallel. According to at least some example embodiments, the recognition process may be implemented as a DAG search that establishes candidate mappings from template circuits to input circuits (or vice versa). That is, the recognition process may also be implemented by applying a mapping from an input circuit to a known set of templates.
[0049] Figure 2B A circuit diagram 200b is shown, which represents an optimized circuit obtained by applying a template-based optimization using template 100 relative to the above-identified pattern in circuit 200a. The identified pattern of gates 240a, 260a, and 270a can be replaced by a circuit of lower cost containing gates 220b and 260b. This is equivalent to reducing the number of CNOT gates from 3 to 2. Because CNOT gate 220b acts on the second and fourth quantum bit lines of circuit 200b, it can be commutated by any gate that does not act on the second and fourth quantum bit lines of circuit 200b. Gates 230b, 240b, and 250b are single qubit gates that can be applied to the third quantum bit line of circuit 200b. Therefore, CNOT gate 220b can be set anywhere between CNOT gate 210b and CNOT gate 260b.
[0050] Another quantum cost metric that can be used is quantum circuit depth. Note that circuit execution time is an important consideration in quantum computing performance because the accumulation of certain errors such as timing, laser amplitude and phase errors, systematic errors such as field drift and heating, and the possibility of complete state decoherence all increase over time. Therefore, in addition to the sum of the quantum costs of each gate, a second heuristic for circuit performance can include significantly reducing or even minimizing the circuit execution time. Although the actual execution time may depend on hardware-level parameters, the circuit depth (which can be viewed as the longest connection path from the beginning to the end of the circuit) can be used to estimate the execution time.
[0051] Circuit depth can be calculated by determining the longest path in a DAG representation of the circuit, where length is considered to be the number of gates encountered on each path, the sum of quantum costs along the path, or some other constructed value. Entanglement gates can induce qubit connections between each pair of entangled qubits, i.e., vertical lines between qubits in the circuit diagram; but in the case of a fully connected topology available, some qubits can be entangled in parallel, rather than in the order commonly used in current quantum algorithm design. Forward commutation of one or more pairs of gates and merging them into a single parallel operation with one or more pairs of gates can reduce circuit depth. Such an operation can be represented as, for example, a template with two or more regular entangled gates, followed by a parallel version. As another example, the template-based optimization described above of the output optimization circuit 210b performed on circuit 210a shows that entanglement gates 210b and 220b can be implemented in parallel. The two-qubit circuit depth of the pre-optimized circuit 210a is 4, which can be compared with the post-optimized circuit depth of 2 of the post-optimized circuit 210b, thereby reducing the circuit depth from 4 to 2. Therefore, the solutions described herein, both explicitly and implicitly, can be applied to circuit depth reduction via parallel gates.
[0052] Because template-based optimization can change the topology of qubit connections, it can, for example, be used in tandem with a quantum circuit optimizer that maintains the connection topology to facilitate further circuit optimization in terms of quantum cost, including both the number of gates and circuit depth, when the underlying target quantum hardware that is to implement the optimized circuit is capable of natively implementing the newly introduced connections. That is, the optimization described and narrated herein can be applied in a pipeline that combines quantum circuit compilation and additional quantum circuit optimization methods. Multiple iterations between different quantum circuit optimizers (including template-based optimizers) can be performed until, for example, no further optimization of quantum cost can be achieved, thereby outputting an optimized circuit for a given optimization strategy.
[0053] The all-to-all connection of trapped ions allows efficient implementation of quantum circuits that include or can be transformed to include parallel gates. Parallel gates are a generalization of two-qubit quantum entanglement gates. Standard entanglement gates, such as the Molmer-Sorensen or "MS" gate, can operate on a pair of qubits to create an inseparable superposition of multi-qubit states. This operation is used in quantum algorithms to explore complex problem areas that are not feasible in classical computing.
[0054] Parallel gates can act on multiple pairs simultaneously, rather than a single pair. One challenge associated with implementing entanglement gates in parallel is to operate on the qubit of interest while leaving all other pairs unaffected. Performing entanglement in parallel can be at most a constant multiple of the single-pair performance cost. Therefore, parallel gates provide a second optimizer function that reduces the cumulative quantum resource requirements of circuit execution. Furthermore, the all-to-all connectivity of trapped-ion quantum computers allows entanglement gates to be implemented simultaneously between multiple arbitrary pairs.
[0055] In this case, for example Figure 2A and Figure 2B The quantum cost reduction described and described in the method for generating the template library is shown in FIG. An example implementation of the generator using breadth-first search (BFS) is shown in FIG. Fig. 9 and Fig.10 shown.
[0056] like Fig. 9 and Fig.10 As shown in , BFS for template library generation can be performed by selecting the number of qubits on which the template is to be generated. For a selected number of qubits, a set of possible gates is created, which are selected for template library generation. The selected gates for template library generation are called naked gates, and BFS first considers each naked gate of the first child, where the root of the tree is empty. The library generation then checks each complete branch defined according to the branch from the root to the leaf to determine whether any complete branch (that is, the product of all naked gates that appear sequentially along the branch in the path of the complete branch) leads to identity. If the branch of interest is not evaluated as identical, the search continues along the branch. If the branch of interest is evaluated as identical, the search is terminated at the branch, and the product of the naked gate corresponding to the branch is recorded as a template in the template library. When all branches at a given level have been checked, if there are still unterminated branches, the next child branch will be added to these branches. Once there are no more branches available for further search and all branches are used for the generation of the template library, BFS terminates.
[0057] In one example, the above BFS method can be optimized to reduce the runtime cost of BFS. For example, when adding children, template-based optimization can be applied to all complete branches that have templates stored in the template library at BFS time. If any branch allows template-based optimization, such as T, then the branch can be eliminated from the search because such a branch represents a suboptimal template. That is, if the search is continued along this branch, the branch will result in a suboptimal template of the form U 1 U 2 U 3 ...U m U m+1 ...U m+M U m+M+1 ...U N template, where U m+1 …U m+M is the identified template T, so in the application of template-based optimization of the input quantum circuit, by first considering the template U m+1 ...U m+M , then consider the template U 1 U 2 U 3 ...U m U m+M+1 ...U N Shorter optimal template U 1 U 2 U 3 …U m U m+M+1 …U N , the suboptimal template can be replaced. This greatly reduces the computational overhead in BFS.
[0058] BFS can be repeated any number of times to search for templates for any number of qubits. To aid searches for larger numbers of qubits, previous search trees for smaller numbers of qubits can be saved in memory, and all newly discovered templates can therefore be used as part of the template library, which helps reduce the computational overhead of subsequent searches. Thus, while the search space can be represented as a tree that grows exponentially in template length for a given number of qubits and a fixed number of bare gates, many growing search paths can be found to be equivalent to previously searched templates. Thus, checks against previously discovered templates can reduce the problem size to a more manageable size. The loop can terminate after a predetermined amount of time or iterations.
[0059] Figure 3A block diagram is shown that represents an example classical computing system 300 that can be used to optimize quantum circuits, arranged in accordance with at least some embodiments described herein. As shown, the configuration 300 includes at least a program source 305, a program 307, and a digital processor 310. The digital processor 310 may include at least a preprocessor 315, a compiler 320 including a quantum circuit optimizer 325, and an operating system 330. In accordance with at least some embodiments described herein, a library 410A may be associated with the quantum circuit optimizer 325.
[0060] Source 305 may refer to one of a plurality of servers that may be hosted on a cloud-based infrastructure, through which program 307 may be received from a user or user entity on a network. Source 305 may be further configured to receive and / or store partial or complete results of execution of program 307, and also return such results to the user or user entity via the network. Furthermore, source 305 may be implemented by a single or multiple machines, and program 307 may be transmitted via a single or multiple connections or channels.
[0061] Program 307 may refer to one or more programs received from a user or user entity via source 305. Program 307 may include at least one or more quantum circuits written or programmed in a classical environment for execution in a quantum computing environment. Individual programs in program 307 may be written or programmed partially or completely in any quantum computing language, include only quantum circuits, or include quantum circuits combined with classical computing functions. Unless the context requires otherwise, the description will continue with reference to a single embodiment of program 307, but embodiments and implementations including multiple programs are not excluded.
[0062] Digital processor 310 may refer to one or more embodiments of a classical computing environment, which may be or include a classical computer, a processing device, and / or even an individual processor on which program 307 is assembled, managed, and / or executed. Digital processor 310 may refer to a high performance computing (HPC) environment, which includes at least a CPU and a GPU, which resides on, for example, a video card, embedded on a motherboard, or on a CPU die. According to embodiments described herein, optimization of quantum circuits may be performed entirely on the CPU, or partially on the CPU and GPU. Alternative embodiments may be performed in an evolutionary HPC component equivalent to that described herein.
[0063] Preprocessor 315 may refer to a program designed, programmed, or otherwise configured to modify input data to conform to the input requirements of another program. According to embodiments described herein, the input to preprocessor 315 includes at least a portion of program 307, which may include one or more quantum circuits. The output may be referred to as a preprocessed form of the input data, i.e., program 307, which may be used or executed by other programs on digital processor 310. According to embodiments described herein, preprocessor 315 may preprocess or otherwise translate source code from which program 307 is written in preparation for compilation.
[0064] Compiler 320 may refer to an optimizing compiler designed, programmed, or otherwise configured to render at least a portion of program 307 suitable for execution in a quantum environment. As is known in the art, a compiler may perform operations that facilitate efficient design and correct conversion of source inputs to target outputs. Therefore, compiler 320 may be designed, programmed, or otherwise configured to minimize or maximize some properties of program 307, i.e., reduce quantum cost. To this end, compiler 320 includes or is associated with quantum circuit optimizer 325, which uses an algorithm to implement quantum circuit optimization, which may convert one or more quantum circuits included in program 307 into corresponding quantum circuits that are functionally equivalent but have a lower quantum cost.
[0065] The quantum circuit optimizer 325 may be designed, programmed, or otherwise configured to identify a quantum circuit gate pattern in the program 307 that is intended to perform a function, search the template library 410A for a quantum circuit gate template that also performs the function at a lower quantum cost, and replace the identified set of quantum circuit gates with the quantum circuit gate template.
[0066] According to at least some embodiments, quantum circuit optimizer 325 may map template patterns stored in library 410A to one or more identified quantum gate patterns in program 307. As referenced herein, pattern matching may include both qubit mapping and gate mapping. If a non-commutating gate is encountered during the pattern recognition process, the process may terminate and the next template may be mapped to the input circuit corresponding to program 307. The program described by quantum circuit optimizer 325 may perform mapping from pattern qubits to circuit qubits and mapping of pattern gates to circuit gates, both of which may be used to identify a given pattern function from within a sub-region of a circuit.
[0067] When a circuit modification algorithm is implemented, it can be determined which gates are commutated. Typically, specific rules for gate commutation can be recorded, including commutation rules for gates that are commutated with a set of gates. However, rather than hard-coding commutation rules (which may be the default in some embodiments), commutation relationships can be defined in a dictionary type structure and can be modified offline, thereby facilitating fast lookup, arbitrary online or offline modification, and simplicity of use from multiple software packages.
[0068] According to at least one embodiment, quantum circuit optimizer 325 may be designed, programmed, or otherwise configured to receive at least a portion of program 307, identify a quantum gate pattern programmed to perform a quantum function therein, search a library for a quantum gate replacement template also programmed to perform the quantum function, determine whether a quantum cost of the quantum gate replacement template is lower than a quantum cost of the identified quantum gate pattern, and if the determination is positive, replace the identified quantum gate pattern with the quantum gate replacement template.
[0069] Operating system (OS) 330 may be designed, programmed, or otherwise configured to control classical computing software and hardware components. Thus, in accordance with at least some embodiments of quantum circuit optimization, OS 330 may receive optimizer 307, schedule and / or sequence processing for its functions, including assigning functions to job queues for eventual execution on the QPU, and initiate their execution.
[0070] The solution described explicitly and implicitly in this paper includes an automated process for reducing quantum costs by running quantum algorithms through an optimizer that can produce equivalent circuits that, when implemented, have a lower chance of decoherence in the quantum computation state, for example.
[0071] Figure 4 An example configuration of a quantum circuit optimizer 325 that can be used to implement quantum circuit optimization, arranged in accordance with at least some embodiments described herein, is shown. As shown, the quantum circuit optimizer 325 is included in or associated with the optimizing compiler 320; and the quantum circuit optimizer 325 includes at least a receiver 405, a library generator 410, a cost arbitrator 415, a functional arbitrator 420, a library manager 425, and a replacement manager 430. Although shown as discrete components, it is contemplated within the scope of the disclosed subject matter that various components may be divided into additional components, combined into fewer components, or eliminated entirely. Those skilled in the art will appreciate that each function and / or operation of a component may be implemented individually and / or collectively by a wide range of hardware, software, firmware, or any combination thereof.
[0072] Receiver 405 may be designed, configured, or otherwise programmed to receive program 107, which includes one or more quantum circuits written or programmed in a classical environment for execution in a quantum computing environment.
[0073] Library generator 410 may be designed, configured, or otherwise programmed to generate library 410A using a BFS approach. Library generator 410 may insert the constructed permutations into a tree where the root node is a bare gate type. New first level nodes are instances of different bare gates, thus increasing the width of the tree. Library generator 410 may also repeat this process for any number of qubits, and saving templates found in a smaller number of qubit instances in memory may benefit a larger number of qubit instances.
[0074] Cost arbiter 415 may be designed, configured or otherwise programmed to utilize an algorithm to determine the quantum cost of templates stored in library 410A and patterns identified in program 307. As referenced herein, quantum cost may involve a custom dictionary implementation of the efficiency and resource cost of gates and arbitrary gate sequences. Gate costs may be stored as key-value pairs accessible in constant time, for example via hashing, but such implementation is not limiting. Costs may be assigned to gates and / or gate sequences using a custom scoring scale, with larger numbers indicating cost. Thus, according to at least one example implementation, a single gate may have a relatively low cost, but a CNOT / two-qubit gate may have a higher cost associated with it. The quantum cost of a gate or gate sequence may be dynamically or offline adjusted based on experimental results or actual experience. Constant time lookup prevents performance loss when replacement manager 425 is to replace an identified gate pattern from program 307 with a template from library 410A.
[0075] According to at least some embodiments, cost arbitrator 415 can determine the quantum cost of each template in library 410A when the template is generated or stored. Cost arbitrator 415 can then also determine the quantum cost of each pattern in program 307 when identified by a functional arbitrator, as described below.
[0076] Function arbiter 420 may be designed, configured, or otherwise programmed to perform a pattern search within received program 307 and perform a trial mapping of one or more templates into program 307, i.e., one or more target circuits. The search or mapping may be performed for one function at a time or for multiple functions in parallel. Furthermore, the search or mapping may depend in part on a search of a directed acyclic graph (i.e., DAG, a representation of a quantum circuit) that establishes candidate mappings from template qubits to circuit qubits.
[0077] Librarian 425 may be designed, configured, or otherwise programmed to search library 410A to determine whether there is stored therein a template that is functionally equivalent to the pattern identified by functional arbiter 420 in received program 307; that is, to determine whether the qubits of the template stored in library 410A can be mapped to the qubits of at least one quantum circuit corresponding to program 307, such that the gates of the template can be mapped to the gates of program 307. If the determination is positive, quantum circuit optimizer 325 implements a fast technique for pattern matching the stored template with a subset of the gates corresponding to program 307 via, for example, a non-deterministic finite automaton (i.e., NFA). Template-based optimization may be applied to reduce the quantum cost of the input quantum circuit.
[0078] According to at least one embodiment, library manager 425 can search for templates in library 410A so that a pattern identified within program 307 can be replaced by a lower cost sequence. The pattern is only recognizable if certain gate commutators are applied using an efficient implementation for storing, reading, and evaluating gate commutation relations as described herein. Commutation relations can be defined in an abstract data structure, such as a dictionary or prefix tree, and can be modified offline, thereby facilitating fast lookup, arbitrary online or offline modification, and simplicity of use from multiple software packages, rather than hard-coding gate commutation rules.
[0079] Substitution manager 430 may be designed, configured, or otherwise programmed to facilitate topological variation via templates by, for example, modifying the topology of program 307. For example, a quantum SWAP gate (which swaps the states of two qubits) may be implemented as a logical qubit redistribution on a trapped ion system in a substantially economical manner, since the SWAP gate may comprise three CNOT gates in an exemplary embodiment. Logical redistribution / remapping, which may be readily used for a trapped ion system (which may utilize all-to-all connections), is low cost, since remapping in this system incurs zero quantum cost. Thus, when three CNOT gates acting as SWAP gates are identified in an input circuit during an optimized compilation, substitution manager 430 may remove the identified template and switch the qubits of the remaining gates in the input circuit.
[0080] Figure 5 It is shown that it can be used at least according to the above Figure 3 and Figure 4An example process flow 500 for implementing at least a portion of quantum circuit optimization is provided. As shown, the process flow 500 includes subprocesses performed by various components of a compiler 320 that may be included in the system 300. However, the process flow 500 is not limited to such components, as significant modifications may be made by reordering two or more of the subprocesses described herein, eliminating at least one of the subprocesses, adding additional subprocesses, replacing components, or even causing various components to assume subprocessing roles consistent with other components in the following description. The process flow 500 may include various operations, functions, or actions as shown in one or more of blocks 505A, 505B, 510, 515, 520, 525, and 530. These various operations, functions, or actions may, for example, correspond to software, program code, or program instructions that can be executed by a processor to cause the functions to be performed. Processing may begin at one or both of block 505A or block 505B.
[0081] At block 505A (Build Library), the library generator 410 may utilize the BFS tree to generate a template library 410A. As explained above, the library 410A may refer to or include a gate library that stores one or more lists of possible gates for use by at least a portion of the program 307.
[0082] Furthermore, at block 505A, the cost arbitrator 415 may determine the quantity sub-costs of the templates simultaneously or serially when the corresponding templates are generated or when the corresponding templates are stored in the library 410A. According to at least one example embodiment, the cost arbitrator 415 may utilize a custom scoring criterion to assign costs to gates and / or gate sequences when generating or storing the corresponding templates.
[0083] At block 505B (Receive Program), the receiver 405 may receive the program 307 from the source 305 .
[0084] Processing at blocks 505A and 505B may be performed in parallel or serially or out of a predetermined order, according to embodiments described herein. Processing may proceed to block 510 .
[0085] At block 510 (Identify Candidate Gates for Template-Pattern Matching), the functional arbitrator 420 may perform a pattern search within the received program 307 .
[0086] At block 515 (Search Template Library), function arbitrator 420 may perform a trial mapping of one or more templates stored in template library 410A into program 307. Pattern recognition may be performed on one template at a time or on multiple templates in parallel. According to at least some example embodiments, the search may be implemented as a DAG search that constructs candidate mappings from template qubits to circuit qubits. Processing may proceed to block 520.
[0087] At block 520 (Compare Quantum Costs), if the corresponding quantum costs have not yet been determined, the cost arbitrator 415 may utilize an algorithm to determine the quantum costs of one or more templates stored in the library 410A; and the cost arbitrator 415 may utilize the same algorithm to determine the quantum costs of the patterns identified in the procedure 307. That is, for each embodiment, a common algorithm may be utilized to determine the quantum costs of the templates and the patterns that the templates replace. Processing may proceed to decision block 525.
[0088] At decision block 525 (Save?), the cost arbitrator 415 may determine that the quantum cost of the quantum gate replacement pattern is lower than the quantum cost of the identified quantum gate pattern. Upon a negative determination, processing may return to block 510; upon an affirmative determination, processing may proceed to block 530.
[0089] At block 530 (REPLACE), the replacement manager 430 may modify the topology of the program 107 by replacing the identified quantum gate pattern with a quantum gate replacement pattern.
[0090] The solution depicted and described herein involves a fast technique for mapping templates to a target circuit included in program 307, and a fast technique for pattern matching a stored template to a subset of gates in the target circuit. That is, given a quantum circuit in program 307 and a template stored in library 410A, function arbiter 420 determines whether the qubits of the stored template can be mapped to the qubits of the quantum circuit. If the determination is positive, the corresponding template is mapped to the circuit. Multiple iterations may be performed to achieve cost reductions caused by new patterns that appear in the modified circuit.
[0091] The template patterns stored in library 410A can be mapped to the target circuit included in program 307 by stepping through the circuit and stopping at the first gate that matches the gate pattern. This produces a mapping from the pattern qubit to the target qubit. Other pattern qubits can be mapped by stepping along the DAG from the seed gate, first locating the gate that matches the next pattern gate and by controlling the gate connected to the seed bit. A similar procedure can be performed for the control bits. If a non-commutating gate is encountered, or not all qubits are mapped, the process can terminate and the mapping for the next template can be performed.
[0092] Figure 6Illustrative computing embodiments are shown, in which any process and subprocess of quantum hybrid computing can be implemented as computer-readable instructions stored on a computer-readable medium. The computer-readable instructions can be executed, for example, by a processor of a device as described herein, the processor having a network element and / or any other device corresponding thereto, particularly when applicable to the above-mentioned application programs and / or programs corresponding to the systems 300 and 400 for quantum hybrid computing.
[0093] In a very basic configuration, computing device 600 may typically include at least one or more processors 602 , a system memory 604 , one or more input components 606 , one or more output components 608 , a display component 610 , computer-readable media 612 , and a transceiver 614 .
[0094] The processor 602 may refer to, for example, a microprocessor, a microcontroller, a digital signal processor, or any combination thereof.
[0095] The memory 604 may refer to, for example, a volatile memory, a non-volatile memory, or any combination thereof. The memory 604 may store therein an operating system 30, application programs, and / or program data. In other words, the memory 604 may store executable instructions for implementing any of the above functions or operations, and therefore, the memory 604 may be considered as a computer-readable medium.
[0096] Input component 606 may refer to a built-in or communicatively coupled keyboard, touch screen, or telecommunication device. Alternatively, input component 606 may include a microphone configured to cooperate with a speech recognition program that may be stored in memory 604 to receive voice commands from a user of computing device 600. Furthermore, if input component 606 is not built-in to computing device 600, it may be communicatively coupled to computing device 600 via a short-range communication protocol including, but not limited to, radio frequency or Bluetooth.
[0097] Output component 608 may refer to a component or module built into or removable from computing device 600 that is configured to output commands and data to an external device.
[0098] Display component 610 may refer to, for example, a solid-state display that may have touch input capabilities. In other words, display component 610 may include the ability to share or replace input component 606 with input component 606.
[0099] The computer-readable medium 612 may refer to a detachable machine-readable medium configured to store one or more programs that embody any of the functions or operations described above. That is, the computer-readable medium 612 may be received into a drive component of the computing device 600 or otherwise connected to a drive component of the computing device 600, and the computer-readable medium 612 may store executable instructions for implementing any of the functions or operations described above. These instructions may be in addition to or independent of those instructions stored in the memory 604.
[0100] The transceiver 614 may refer to a network communication link of the computing device 400, which is configured as a wired network or a direct wired connection. Alternatively, the transceiver 614 may be configured as a wireless connection, such as radio frequency (RF), infrared, Bluetooth, and other wireless protocols.
[0101] As can be seen from the above, various embodiments of the present disclosure have been described herein for illustrative purposes, and various modifications may be made without departing from the scope and spirit of the present disclosure. Therefore, the various embodiments disclosed herein are not intended to be limiting, and the true scope and spirit are indicated by the appended claims.
Claims
1. A computer-implemented method for optimizing a quantum circuit, the method comprising: identifying a set of quantum circuit gates that perform a predetermined function of the quantum circuit to be optimized; searching a library of templates stored on a non-transitory computer readable medium to identify a quantum circuit gate template that performs the predetermined function and has a lower quantum cost than the identified set of quantum circuit gates based on an estimated execution time, the searching comprising performing qubit mapping and gate mapping to find a match, the gate mapping comprising: matching the types and order of the quantum circuit gates defined on a graphical representation of the quantum circuit between the quantum circuit and the quantum circuit gate template; replacing the identified set of quantum circuit gates with the identified quantum circuit gate template; as well as The program is compiled using the identified quantum circuit gate template into a set of hardware-specific operations that operate on the qubit states of the quantum circuit to be optimized.
2. The computer-implemented method of claim 1 , wherein the same algorithm is used to calculate the quantum cost of the identified quantum circuit gate and the quantum cost of the identified quantum circuit gate template. 3 . The computer-implemented method of claim 1 , wherein the templates in the template library are generated using parallel gates to modify circuit topology.
4. The computer-implemented method of claim 1, wherein the method is performed in a pipeline combining quantum circuit compilation and additional quantum optimization.
5. The computer-implemented method of claim 1, wherein the method is automatically performed upon receiving the quantum circuit. The computer-implemented method of claim 5 , wherein the method is performed in a serial manner. The computer-implemented method of claim 5 , wherein the method is performed in parallel.
8. A non-transitory computer readable medium storing executable instructions which, when executed, cause a digital computing processor to perform functions comprising: receiving quantum circuit; identifying, from within the received quantum circuit, a quantum gate pattern that matches at least a portion of at least one pattern from a pre-generated template library, the template library stored on a non-transitory computer-readable medium coupled to the digital computing processor; searching the template library for a quantum gate replacement pattern by performing quantum bit mapping and gate mapping to find a match, the gate mapping comprising: matching the type and order of quantum circuit gates defined on a graphical representation of the quantum circuit between the quantum circuit and the quantum gate replacement pattern; determining, based on the estimated execution time, that a quantum cost of the quantum gate replacement pattern is lower than a quantum cost of the identified quantum gate pattern; replacing the identified quantum gate pattern with the quantum gate replacement pattern; and The program is compiled into a set of hardware-specific operations using the quantum gate replacement pattern, which operate on the qubit states of the quantum circuit to be optimized.
9. The non-transitory computer readable medium of claim 8, wherein the quantum cost of the identified quantum gate pattern and the quantum cost of the quantum gate replacement pattern are efficiently accessible via an abstract data structure.
10. The non-transitory computer-readable medium of claim 9, wherein the quantum cost of the identified quantum gate pattern and the quantum cost of the quantum gate replacement pattern are assigned respective values according to a customizable cost function.
11. The non-transitory computer readable medium of claim 8, wherein the quantum gate replacement pattern comprises at least one quantum gate.
12. The non-transitory computer readable medium of claim 8, wherein the identified quantum gate pattern is identically replaced. 13 . The non-transitory computer-readable medium of claim 8 , wherein the searching of the template library is performed at least partially on a graphics processing unit (GPU) and at least partially on a central processing unit (CPU).
14. An optimizer for optimizing a quantum circuit, comprising: a quantum circuit analyzer configured to identify quantum gate patterns that match at least a portion of a pattern from a pre-generated template library; A template library stored on a non-transitory computer readable medium and configured to instruct a processor to: executing an algorithm to search for quantum gate replacement patterns; identifying the quantum gate replacement pattern to replace the identified quantum gate pattern so that the quantum cost of the quantum gate replacement pattern is less than the quantum cost of the identified quantum gate pattern, the identification of the quantum gate replacement pattern comprising performing qubit mapping and gate mapping to find a match between the quantum circuit and a template of quantum circuit gates, wherein the gate mapping comprises matching the types and order of the quantum circuit gates defined on a graphical representation of the quantum circuit; and replacing the identified quantum gate pattern with the quantum gate replacement pattern; as well as A compiler is configured to compile a program into a set of hardware-specific operations using the quantum gate replacement pattern, the hardware-specific operations operating on the qubit states of the quantum circuit to be optimized.
15. The optimizer of claim 14, wherein the template library stores abstract data structures representing the quantum cost of the identified quantum gate pattern and the quantum cost of the quantum gate replacement pattern, respectively.
16. The optimizer of claim 14, wherein the quantum cost of the identified quantum gate pattern and the quantum cost of the quantum gate replacement pattern are assigned respective values according to a customizable cost function.
17. The optimizer of claim 14, wherein specific characteristics of individual quantum gate patterns are modifiable.
18. The optimizer of claim 14, wherein the templates in the template library utilize parallel gate generation to modify circuit topology.
19. The optimizer of claim 14, wherein the templates in the template library are generated using parallel gates to reduce quantum circuit depth.
Citation Information
Patent Citations
Method for optimizing quantum circuit simulation
CN107977541A
Novel universal quantum gate and quantum circuit optimization method
CN108334952A
Processing method and device of a quantum circuit, storage medium and electronic device
CN109165741A
In-situ quantum error correction
US20180330265A1
