A quantum algorithm compilation method, system, electronic device and storage medium
By dividing the quantum compilation process into multiple compilation stages and determining extended implementations based on configuration files, the problem of insufficient versatility and scalability of quantum compilers is solved, and adaptability and compatibility to different quantum computing backends are achieved.
Patent Information
- Application Number
- CN202211279530.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-10-19
Smart Images

Figure CN115481745B
Abstract
Description
Technical Field
[0001] The present application relates to the field of quantum computing technology, and in particular to a compilation method, system, electronic device and storage medium for a quantum algorithm. Background Art
[0002] A quantum compiler, also known as a quantum computing compiler, is a special computer software used to convert quantum algorithms into quantum circuits that can actually be executed by quantum chips. Quantum compilers are important tools for quantum computers to implement quantum algorithms, and are also one of the key research and development directions of quantum computing-related companies, universities, and other research institutions. In related technologies, quantum compilers from various manufacturers are not compatible with each other, and the versatility and scalability of quantum compilers are poor.
[0003] Therefore, how to improve the versatility and scalability of quantum compilers is a technical problem that technicians in this field currently need to solve. Summary of the invention
[0004] The purpose of this application is to provide a quantum algorithm compilation method, system, electronic device and storage medium, which can improve the versatility and scalability of the quantum compiler.
[0005] In order to solve the above technical problems, the present application provides a method for compiling a quantum algorithm, which includes:
[0006] Determine, according to the configuration file, the extended implementations corresponding to the multiple extension points in the quantum compiler; wherein the quantum compilation process of the quantum compiler includes multiple compilation stages, the extension points are functional interfaces corresponding to the compilation stages, and the extension points include a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage;
[0007] receiving a quantum algorithm to be compiled;
[0008] The corresponding extension implementations are called in sequence according to the implementation order of the compilation stage to obtain the program described by the quantum computing backend instruction set.
[0009] Optionally, calling the corresponding extension implementations in sequence according to the implementation order of the compilation phase includes:
[0010] The extension implementations corresponding to the first extension point, the second extension point, and the third extension point are called in sequence.
[0011] Optionally, the operations performed when calling the extension implementation corresponding to the first extension point include:
[0012] The quantum algorithm is decomposed into quantum circuits including single-bit gates and two-bit gates.
[0013] Optionally, the operations performed when calling the extension implementation corresponding to the second extension point include:
[0014] The quantum circuits obtained in the quantum gate decomposition stage are arranged on the quantum bits at the back end, and auxiliary bits are added.
[0015] Optionally, the operations performed when calling the extension implementation corresponding to the third extension point include:
[0016] Convert the single-bit gates and two-bit gates into programs described by the quantum computing backend instruction set.
[0017] Optionally, a quantum algorithm preprocessing stage is further included before the quantum gate decomposition stage, and the extension point further includes a fourth extension point corresponding to the quantum algorithm preprocessing stage;
[0018] Correspondingly, the operations performed when calling the extension implementation corresponding to the fourth extension point include:
[0019] A preprocessing operation is performed on the quantum algorithm so as to process the preprocessed quantum algorithm in the quantum gate decomposition stage.
[0020] Optionally, a pre-compilation optimization stage is further included between the quantum gate decomposition stage and the quantum bit layout stage, and the extension point further includes a fifth extension point corresponding to the pre-compilation optimization stage;
[0021] Correspondingly, the operations performed when calling the extension implementation corresponding to the fifth extension point include:
[0022] A pre-compilation optimization operation is performed on the quantum circuit obtained in the quantum gate decomposition stage, so that the pre-compilation optimized quantum circuit can be processed in the quantum bit layout stage.
[0023] Optionally, after the quantum gate implementation stage, a post-compilation optimization stage is also included, and the extension point also includes a sixth extension point corresponding to the post-compilation optimization stage;
[0024] Correspondingly, the operations performed when calling the extension implementation corresponding to the sixth extension point include:
[0025] A post-compilation optimization operation is performed on the program described by the quantum computing back-end instruction set obtained in the quantum gate implementation stage.
[0026] Optionally, before calling the corresponding extension implementations in sequence according to the implementation order of the compilation phase, the method further includes:
[0027] The extension implementation is loaded dynamically or statically.
[0028] Optionally, the extension point further includes: a fourth extension point corresponding to the quantum algorithm preprocessing stage, the extension point further includes a fifth extension point corresponding to the pre-compilation optimization stage and a sixth extension point corresponding to the post-compilation optimization stage;
[0029] Accordingly, the corresponding extension implementations are called in sequence according to the implementation order of the compilation phase, including:
[0030] The extension implementations corresponding to the fourth extension point, the first extension point, the fifth extension point, the second extension point, the third extension point and the sixth extension point are called in sequence.
[0031] Optionally, calling the corresponding extension implementations in sequence according to the implementation order of the compilation phase includes:
[0032] Dividing all the compilation stages into N stage combinations; wherein one stage combination includes one or more compilation stages;
[0033] Deploy the extended implementation corresponding to the N stage combinations in N quantum compilation devices;
[0034] The corresponding extended implementations are called in sequence according to the implementation order of the compilation stage using the N quantum compilation devices.
[0035] The present application also provides a quantum algorithm compilation system, the system comprising:
[0036] An extended implementation determination module is used to determine the extended implementations corresponding to multiple extension points in the quantum compiler according to the configuration file; wherein the quantum compilation process of the quantum compiler includes multiple compilation stages, the extension points are functional interfaces corresponding to the compilation stages, and the extension points include a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage;
[0037] An algorithm receiving module, used to receive the quantum algorithm to be compiled;
[0038] A compiling and executing module is used to sequentially call the corresponding extension implementations according to the implementation order of the compiling stage to obtain a program described by the quantum computing backend instruction set.
[0039] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps of executing the compilation method of the above-mentioned quantum algorithm are implemented.
[0040] The present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor calls the computer program in the memory, the steps of executing the compilation method of the above-mentioned quantum algorithm are implemented.
[0041] The present application provides a compilation method for a quantum algorithm, comprising: determining, according to a configuration file, an extended implementation corresponding to a plurality of extension points in a quantum compiler; wherein the quantum compilation process of the quantum compiler comprises a plurality of compilation stages, the extension points are functional interfaces corresponding to the compilation stages, and the extension points comprise a first extension point corresponding to a quantum gate decomposition stage, a second extension point corresponding to a quantum bit layout stage, and a third extension point corresponding to a quantum gate implementation stage; receiving a quantum algorithm to be compiled, and sequentially calling the corresponding extended implementations in accordance with the implementation order of the compilation stages to obtain a program described by a quantum computing backend instruction set.
[0042] This application divides the quantum compilation process of the quantum compiler into multiple compilation stages, and sets the functional interface corresponding to each compilation stage as the extension point of the quantum compiler, which includes the first extension point corresponding to the quantum gate decomposition stage, the second extension point corresponding to the quantum bit layout stage, and the third extension point corresponding to the quantum gate implementation stage. During the compilation process of the quantum algorithm, this application determines the extension implementation corresponding to the multiple extension points of the quantum compiler according to the configuration file, and calls the corresponding extension implementation in sequence according to the implementation order of the compilation stage. In the above process, different extension implementations can be configured on the extension points of the quantum compiler, so that the quantum compiler can adapt to any quantum computing backend. It can be seen that this application can improve the versatility and scalability of the quantum compiler. The application also provides a compilation system, a storage medium and an electronic device for a quantum algorithm, which have the above-mentioned beneficial effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 A flowchart of a method for compiling a quantum algorithm provided in an embodiment of the present application;
[0045] Figure 2 A quantum compilation information flow diagram based on an extension mechanism provided in an embodiment of the present application;
[0046] Figure 3 A schematic diagram of an expansion mechanism provided in an embodiment of the present application;
[0047] Figure 4 A schematic diagram of the structure of a quantum compilation system based on an extension mechanism provided in an embodiment of the present application;
[0048] Figure 5 A schematic diagram of the first extension point deployment method provided in an embodiment of the present application;
[0049] Figure 6 A schematic diagram of a second extension point deployment method provided in an embodiment of the present application;
[0050] Figure 7 A schematic diagram of the structure of a quantum algorithm compilation system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0052] See below Figure 1 , Figure 1 A flowchart of a method for compiling a quantum algorithm provided in an embodiment of the present application.
[0053] Specific steps may include:
[0054] Step 1: Determine the extension implementation corresponding to multiple extension points in the quantum compiler according to the configuration file;
[0055] Among them, this embodiment can be applied to a quantum compilation device (i.e., a quantum computing compilation device), and can also be applied to a cluster constructed by multiple quantum compilation devices. A quantum compiler is a program that generates a program described by a quantum chip instruction set according to a quantum algorithm described in a high-level language; the above program can be used as the input of the back-end quantum measurement and control hardware or quantum computing simulator. The quantum compiler is used to generate a program described by the instruction set of a quantum chip or other quantum computing back-end according to a quantum algorithm described in a high-level language, as the input of a quantum computer or other quantum computing back-end. The input of the quantum compiler is a quantum algorithm described in a high-level language, such as a quantum algorithm designed for a specific problem described in a high-level programming language such as Python or C / C++, which can be mathematically abstracted as a combination of a series of unitary operators and Hermitian operators. The output of the quantum compiler is a program described using the instruction set of a quantum chip or other quantum computing back-end, which can be directly converted by the quantum computer into operations sent to the quantum computing hardware, or directly executed by other quantum computing back-ends.
[0056] Before this step, the quantum compilation process of the quantum compiler may be divided into multiple compilation stages, and corresponding extension points may be set for each compilation stage. The above extension points are functional interfaces corresponding to the compilation stages, and the extension points at least include: a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage.
[0057] Extension points are points in software or software frameworks that are specially set up for other developers to extend functionality. Extension implementation is a key mechanism in extensible projects, which can be used to add new functionality to the platform. Extension implementations cannot be created arbitrarily, but must be clearly declared in accordance with the specifications defined by the extension point so that the platform can recognize these extensions. Extension implementation is essentially the implementation of the extension point.
[0058] Each of the above extension points has its corresponding extension implementation. "Extension point" is a general descriptive term for the functional interface in an extensible system, and its meaning is equivalent to "service interface". Correspondingly, the meaning of "extension implementation" is equivalent to "service".
[0059] Step 2: Receive the quantum algorithm to be compiled;
[0060] This embodiment does not limit the execution order of step 1 and step 2. Step 1 may be executed first and then step 2, or step 2 may be executed first and then step 1, or step 1 and step 2 may be executed simultaneously. Further, after both step 1 and step 2 are executed, the related operations of step 3 below are executed.
[0061] Step 3: Call the corresponding extension implementations in sequence according to the implementation order of the compilation stage to obtain the program described by the quantum computing backend instruction set.
[0062] Among them, after receiving the quantum algorithm to be compiled, this step can call the corresponding extended implementation in sequence according to the implementation order of all the above compilation stages to obtain the program described by the quantum computing backend instruction set. The program described by the above quantum computing backend instruction set refers to: the program described by the instruction set of the quantum computing backend device.
[0063] As a feasible implementation method, in the quantum algorithm compilation process, the quantum gate decomposition stage is earlier than the quantum bit layout stage, and the quantum bit layout stage is earlier than the quantum gate implementation stage. Therefore, in this step, the extended implementation corresponding to the first extension point, the extended implementation corresponding to the second extension point, and the extended implementation corresponding to the third extension point can be called in sequence.
[0064] Before calling the corresponding extension implementation in sequence according to the implementation order of the compilation stage, the present embodiment can also load the extension implementation in a dynamic or static manner. Specifically, the corresponding relationship between each extension point and the extension implementation is pre-stored in a configuration file, and the configuration file can be formulated by the user. In this step, all extension implementations can be loaded statically, or the extension implementation to be called can be loaded dynamically according to the requirements in the configuration file.
[0065] This embodiment divides the quantum compilation process of the quantum compiler into multiple compilation stages, and sets the functional interface corresponding to each compilation stage as the extension point of the quantum compiler, which includes a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage. During the compilation process of the quantum algorithm, this embodiment determines the extended implementations corresponding to the multiple extension points of the quantum compiler according to the configuration file, and calls the corresponding extended implementations in sequence according to the implementation order of the compilation stage. In the above process, different extended implementations can be configured on the extension points of the quantum compiler, so that the quantum compiler can adapt to any quantum computing backend. It can be seen that this embodiment can improve the versatility and scalability of the quantum compiler.
[0066] As a feasible implementation mode, the operation performed when calling the extended implementation corresponding to the first extension point in the above embodiment includes: decomposing the quantum algorithm into quantum circuits including single-bit gates and two-bit gates. The operation performed when calling the extended implementation corresponding to the second extension point in the above embodiment includes: laying out the quantum circuits obtained in the quantum gate decomposition phase to the quantum bits of the backend, and adding auxiliary bits. The operation performed when calling the extended implementation corresponding to the third extension point in the above embodiment includes: converting the single-bit gates and two-bit gates into programs described by the quantum computing backend instruction set.
[0067] In the actual quantum algorithm compilation process, the compilation stage may also include any one or several stages of the quantum algorithm preprocessing stage, the pre-compilation optimization stage and the post-compilation optimization stage.
[0068] As a feasible implementation, a quantum algorithm preprocessing stage is also included before the quantum gate decomposition stage, and the extension point also includes a fourth extension point corresponding to the quantum algorithm preprocessing stage. Accordingly, the operation performed when calling the extension implementation corresponding to the fourth extension point includes: performing a preprocessing operation on the quantum algorithm so as to process the preprocessed quantum algorithm in the quantum gate decomposition stage. The above-mentioned preprocessing operation may include quantum circuit position conversion and / or adjusting the operation order of the quantum algorithm, etc.
[0069] As a feasible implementation, a pre-compilation optimization stage is also included between the quantum gate decomposition stage and the quantum bit layout stage, and the extension point also includes a fifth extension point corresponding to the pre-compilation optimization stage. Accordingly, the operation performed when calling the extension implementation corresponding to the fifth extension point includes: performing a pre-compilation optimization operation on the quantum circuit obtained in the quantum gate decomposition stage, so as to process the pre-compilation optimized quantum circuit in the quantum bit layout stage. The above-mentioned pre-compilation optimization operation includes: reducing the depth of the quantum circuit and / or reducing the number of two-bit gates, etc.
[0070] As a feasible implementation, a post-compilation optimization stage is further included after the quantum gate implementation stage, and the extension point further includes a sixth extension point corresponding to the post-compilation optimization stage. Accordingly, the operation performed when calling the extension implementation corresponding to the sixth extension point includes: performing a post-compilation optimization operation on the program described by the quantum computing backend instruction set obtained in the quantum gate implementation stage. The above-mentioned post-compilation optimization operation includes adjusting the parameters of the gate circuit.
[0071] On the basis of the above embodiment, if the extension point also includes a fourth extension point corresponding to the quantum algorithm preprocessing stage, the extension point also includes a fifth extension point corresponding to the pre-compilation optimization stage and a sixth extension point corresponding to the post-compilation optimization stage, a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage, then the process of sequentially calling the corresponding extension implementations in the implementation order of the compilation stage includes: sequentially calling the extension implementation corresponding to the fourth extension point, the extension implementation corresponding to the first extension point, the extension implementation corresponding to the fifth extension point, the extension implementation corresponding to the second extension point, the extension implementation corresponding to the third extension point, and the extension implementation corresponding to the sixth extension point.
[0072] As a feasible implementation mode, the above embodiment can call the corresponding extended implementation in the following manner: divide all the compilation stages into N stage combinations; wherein one stage combination includes one or more compilation stages; deploy the extended implementations corresponding to the N stage combinations in N quantum compilation devices; and use the N quantum compilation devices to call the corresponding extended implementations in sequence according to the implementation order of the compilation stages.
[0073] Let's take an example to illustrate the above process of using N quantum compilation devices to call the extension implementation:
[0074] Example 1: The compilation stage includes a quantum gate decomposition stage, a quantum bit layout stage, and a quantum gate implementation stage. The compilation stage is divided into a combination of three stages, that is, the extended implementation corresponding to the first extension point is deployed on the first quantum compilation device, the extended implementation corresponding to the second extension point is deployed on the second quantum compilation device, and the extended implementation corresponding to the third extension point is deployed on the third quantum compilation device, thereby controlling the first quantum compilation device, the second quantum compilation device, and the third quantum compilation device to successively call the corresponding extended implementations.
[0075] Example 2: The compilation stage includes a quantum gate decomposition stage, a quantum bit layout stage, and a quantum gate implementation stage. The compilation stage is divided into a combination of two stages, that is, the extended implementations corresponding to the first extension point and the second extension point are deployed on the first quantum compilation device, and the extended implementation corresponding to the third extension point is deployed on the second quantum compilation device, thereby controlling the first quantum compilation device and the second quantum compilation device to successively call the corresponding extended implementations.
[0076] Example 3: The compilation stage includes a quantum algorithm preprocessing stage, a quantum gate decomposition stage, a pre-compilation optimization stage, a quantum bit layout stage, a quantum gate implementation stage, and a post-compilation optimization stage. The compilation stage is divided into a combination of 6 stages, that is, the extended implementation corresponding to the first extension point is deployed on the first quantum compilation device, the extended implementation corresponding to the second extension point is deployed on the second quantum compilation device, the extended implementation corresponding to the third extension point is deployed on the third quantum compilation device, the extended implementation corresponding to the fourth extension point is deployed on the fourth quantum compilation device, the extended implementation corresponding to the fifth extension point is deployed on the fifth quantum compilation device, and the extended implementation corresponding to the sixth extension point is deployed on the sixth quantum compilation device, thereby controlling the fourth quantum compilation device, the first quantum compilation device, the fifth quantum compilation device, the second quantum compilation device, the third quantum compilation device, and the sixth quantum compilation device to successively call the corresponding extended implementations.
[0077] Example 4: The compilation stage includes a quantum algorithm preprocessing stage, a quantum gate decomposition stage, a pre-compilation optimization stage, a quantum bit layout stage, a quantum gate implementation stage, and a post-compilation optimization stage. The compilation stage is divided into a combination of three stages, namely, the extended implementations corresponding to the fourth extension point and the first extension point are deployed on the first quantum compilation device, the extended implementations corresponding to the fifth extension point and the second extension point are deployed on the second quantum compilation device, and the extended implementations corresponding to the third extension point and the sixth extension point are deployed on the third quantum compilation device, thereby controlling the first quantum compilation device, the second quantum compilation device, and the third quantum compilation device to successively call the corresponding extended implementations.
[0078] Example 5: The compilation stage includes a quantum algorithm preprocessing stage, a quantum gate decomposition stage, a pre-compilation optimization stage, a quantum bit layout stage, a quantum gate implementation stage and a post-compilation optimization stage. The compilation stage is divided into two stage combinations, that is, the extended implementations corresponding to the fourth extension point, the first extension point, and the fifth extension point are deployed on the first quantum compilation device, and the extended implementations corresponding to the second extension point, the third extension point, and the sixth extension point are deployed on the second quantum compilation device, thereby controlling the first quantum compilation device and the second quantum compilation device to successively call the corresponding extended implementations.
[0079] The process described in the above embodiment is explained below through an embodiment in actual application.
[0080] At present, the research on quantum compilers is mainly focused on optimization algorithms for quantum computers and quantum chips with specific architectures. However, the current quantum compilers are all single software or modules, which cannot be reused due to the incompatibility of various products. Although some quantum encoders borrow the front-end and back-end ideas of LLVM and decompose the compilation process into two stages, which brings certain reusability and compatibility, almost all front-end optimizations for the C++ compilation problems of classical computers targeted by LLVM are applicable to all types of back-ends, and the differences between different back-ends are often only in different instruction sets, which are much smaller than quantum computing. Therefore, this solution, which is divided into only two stages and each stage has no scalability, is not suitable for quantum compilation tasks. Although each quantum compilation algorithm is different, many optimization algorithms have certain versatility. If multiple optimization algorithms can be combined, better results may be achieved.
[0081] In view of the technical defects existing in the above-mentioned related technologies, the embodiments of this application consider the need to integrate multiple optimization algorithms and propose a quantum compilation architecture based on an extension mechanism, which decomposes the compilation process into multiple stages. Each stage is considered to be an extension point, and one or more extension implementations can be mounted. In this way, for different systems and products, quantum computing services or users can select the appropriate extension implementation combination through configuration, thereby greatly increasing the versatility and scalability of the quantum compiler.
[0082] The extension mechanism is to decompose a system into multiple compilation stages, abstract the functions of each compilation stage into an extension point, and add extension implementations for these extension points statically or dynamically in the system. When the system is running, the extension implementation required is called at each extension point according to the preset or user-given configuration information to complete the system function. The extension point is equivalent to the abstract interface of each sub-function of the system, and the extension implementation is the actual implementation module of these functions.
[0083] This embodiment decomposes the quantum compilation process into six compilation stages, each of which corresponds to an extension point, which are:
[0084] (1) The “Quantum Algorithm Preprocessing” extension point (i.e., the fourth extension point mentioned above) supports calling any number of extension implementations to optimize the input quantum algorithm by applying certain preprocessing algorithms;
[0085] (2) The “Quantum Gate Decomposition” extension point (i.e., the first extension point mentioned above) requires and can only call one extension implementation, which is used to decompose a quantum algorithm composed of arbitrary unitary operators and Hermitian operators into quantum circuits composed of single-bit and two-bit gates;
[0086] (3) The “pre-compile optimization” extension point (i.e., the fifth extension point mentioned above) supports calling any number of extension implementations to optimize the decomposed quantum circuit, such as reducing the depth of the quantum circuit or the number of two-bit gates.
[0087] (4) The “Qubit Layout” extension point (i.e., the second extension point mentioned above) needs to call and can only call one extension implementation to layout the quantum circuit onto the actual backend quantum bits;
[0088] (5) The “Quantum Gate Implementation” extension point (i.e., the third extension point mentioned above) requires calling and can only call one extension implementation to convert any single-bit and two-bit gates into gate operations that can be performed by the actual backend, that is, to use the backend instruction set to implement the description of the quantum circuit;
[0089] (6) The “Post-Compilation Optimization” extension point (i.e., the sixth extension point mentioned above) supports calling any number of extension implementations for the final optimization of the quantum circuit described using the backend instruction set.
[0090] Among the above six extension points, the "Quantum Gate Decomposition" extension point, the "Quantum Bit Layout" extension point and the "Quantum Gate Implementation" extension point are the operating skeletons of the quantum computing compilation system and are the compilation stages that must be implemented; in addition, the "Quantum Algorithm Preprocessing" extension point, the "Pre-compilation Optimization" extension point and the "Post-compilation Optimization" extension point correspond to the optimization compilation stage, and any number of extension implementations (including zero) can be configured, that is, the compilation process can ignore these compilation stages.
[0091] Among the above 6 extension points, the input and output data forms of the "Quantum Gate Decomposition" extension point, the "Quantum Bit Layout" extension point and the "Quantum Gate Implementation" extension point have changed. The "Quantum Gate Decomposition" extension point decomposes the quantum algorithm composed of any unitary operator and Hermitian operator into a quantum circuit composed of single-bit and double-bit gates; the "Quantum Bit Layout" extension point layouts the abstract quantum bits in the input quantum circuit to the actual back-end quantum bits, and adds necessary auxiliary bits as needed; the "Quantum Gate Implementation" extension point converts any single-bit and double-bit gates into a sequence of back-end instruction sets. In addition, the "Quantum Algorithm Preprocessing" extension point, the "Pre-Compile Optimization" extension point, and the "Post-Compile Optimization" extension point do not change the form of input and output data.
[0092] The normal operation process of the above-mentioned quantum computing compilation system is divided into the following operations: loading and identifying all possible extension implementations in static or dynamic form; determining the extension implementation that needs to be called for each extension point according to a preset or user-defined configuration file; after receiving the quantum algorithm to be compiled, calling the determined extension implementations in sequence according to the order of the extension points, and generating and outputting a program described by the quantum computing backend instruction set.
[0093] The above process can divide the compilation process consisting of the complete 6 compilation stages into 1 or more stages for deployment, with a minimum of 1 stage, that is, all 6 extension implementations are deployed in one device, and a maximum of 6 stages, that is, each compilation stage is deployed in a separate device.
[0094] See also Figure 2 , Figure 2 A quantum compilation information flow diagram based on an extension mechanism is provided in an embodiment of the present application, in which 101 represents the "quantum algorithm preprocessing" extension point, 102 represents the "quantum gate decomposition" extension point, 103 represents the "pre-compilation optimization" extension point, 104 represents the "quantum bit layout" extension point, 105 represents the "quantum gate implementation" extension point, 106 represents the "post-compilation optimization" extension point, 201 represents the initial quantum algorithm, 202 represents the pre-processed quantum algorithm, 203 represents a quantum circuit composed of any number of single-bit and / or double-bit quantum gates, 204 represents the quantum circuit after processing by the pre-compilation optimization algorithm, 205 represents the quantum circuit after completing the quantum bit layout, 206 represents the quantum circuit described using the quantum chip instruction set, and 207 represents the quantum circuit after processing by the post-compilation optimization algorithm. Figure 2As shown, the quantum computing compilation process of the present invention is decomposed into 6 serial extension points. The input high-level language describes the quantum algorithm, and sequentially passes through 6 links of "quantum algorithm preprocessing", "quantum gate decomposition", "pre-compilation optimization", "quantum bit layout", "quantum gate implementation" and "post-compilation optimization". It is first decomposed into quantum circuits composed of arbitrary single-bit gates and double-bit gates, and then laid out on the quantum bits of the quantum computing backend, and finally generates a program described by the quantum computing backend instruction set.
[0095] See also Figure 3 , Figure 3 This is a schematic diagram of an extension mechanism provided by an embodiment of the present application. In the diagram, Extends indicates that an extension point is extended. For the "quantum gate decomposition" extension point, the "quantum bit layout" extension point, and the "quantum gate implementation" extension point, there is one extension implementation. For the "quantum algorithm preprocessing" extension point, the "pre-compilation optimization" extension point, and the "post-compilation optimization" extension point, there can be 0, 1, or M extension implementations. Figure 2 As shown, the extension point is the interface definition of a certain function, and the extended implementation inherits the interface defined by the extension point to specifically implement the function.
[0096] See also Figure 4 , Figure 4 A schematic diagram of the structure of a quantum compilation system based on an extension mechanism provided in an embodiment of the present application. Figure 4 301 indicates the extended implementation of "quantum algorithm preprocessing", 302 indicates the extended implementation of "quantum gate decomposition", 303 indicates the extended implementation of "pre-compilation optimization", 304 indicates the extended implementation of "quantum bit layout", 305 indicates the extended implementation of "quantum gate implementation", 306 indicates the extended implementation of "post-compilation optimization", 401 indicates the configuration file of the quantum compilation system, and use indicates use. Figure 4 As shown, the quantum computing compilation system consists of a compilation pipeline consisting of 6 extension points, loaded and identified extension implementations, and preset or user-given system configurations.
[0097] See also Figure 5 and Figure 6 , Figure 5 This is a schematic diagram of the first extension point deployment method provided in the embodiment of the present application. Figure 6 This is a schematic diagram of the second extension point deployment method provided in the embodiment of the present application. Figure 5 In the deployment mode shown, the six extension points are deployed on a single quantum computing compilation device, 501 in the figure represents the quantum computing compilation device, and 502 represents the quantum computing backend device. Figure 6The deployment method shown is that the six extension points are divided into two stages. The "quantum algorithm preprocessing" extension point, the "quantum gate decomposition" extension point, and the "pre-compilation optimization" extension point are relatively independent of the specific quantum computing backend and have strong versatility. They are deployed on the quantum computing compilation device. The "quantum bit layout" extension point, the "quantum gate implementation" extension point, and the "post-compilation optimization" extension point are closely related to the specific quantum computing backend. They are dedicated links and are directly deployed on the quantum computing backend device. Of course, the extension point deployment method provided in this embodiment is not limited to Figure 5 and Figure 6 in the form of.
[0098] The above embodiment turns each link of the quantum computing compilation process into an open extension point, and any extension implementation that inherits the definition of these extension points can be loaded into the quantum computing compilation system described in this embodiment. This embodiment decomposes the quantum computing compilation process into six serial extension points, namely "quantum algorithm preprocessing", "quantum gate decomposition", "pre-compilation optimization", "quantum bit layout", "quantum gate implementation" and "post-compilation optimization", and standardizes the process of converting any quantum algorithm into a quantum computing back-end instruction set description program. The above-mentioned "quantum algorithm preprocessing" extension point, "pre-compilation optimization" extension point and "post-compilation optimization" extension point are three extension points for optimization, and any number of extension implementations can be loaded. Since the three extension points of "quantum algorithm preprocessing", "pre-compilation optimization" and "post-compilation optimization" allow the configuration of 0 extension implementations, a system that ignores one or more of these three extension points also belongs to the specific implementation of this embodiment.
[0099] This embodiment configures different extension implementations at the two extension points of "quantum bit layout" and "quantum gate implementation" so that the quantum computing compilation system described in this embodiment can adapt to any quantum computing backend. This embodiment allows the configuration of any number of extension implementations at the three extension points involving optimization, namely "quantum algorithm preprocessing", "pre-compilation optimization" and "post-compilation optimization", so that emerging optimization algorithms can be easily integrated into the quantum computing compilation process. New algorithms can be loaded into the system by only writing corresponding extension implementations without modifying any existing modules in the system.
[0100] See also Figure 7 , Figure 7 A schematic diagram of the structure of a quantum algorithm compilation system provided in an embodiment of the present application, the system may include:
[0101] An extended implementation determination module 701 is used to determine, according to a configuration file, extended implementations corresponding to a plurality of extended points in a quantum compiler; wherein the quantum compilation process of the quantum compiler includes a plurality of compilation stages, the extended points are functional interfaces corresponding to the compilation stages, and the extended points include a first extended point corresponding to a quantum gate decomposition stage, a second extended point corresponding to a quantum bit layout stage, and a third extended point corresponding to a quantum gate implementation stage;
[0102] An algorithm receiving module 702, used to receive a quantum algorithm to be compiled;
[0103] The compiling and executing module 703 is used to call the corresponding extended implementations in sequence according to the implementation order of the compiling stage to obtain the program described by the quantum computing backend instruction set.
[0104] This embodiment divides the quantum compilation process of the quantum compiler into multiple compilation stages, and sets the functional interface corresponding to each compilation stage as the extension point of the quantum compiler, which includes a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage. During the compilation process of the quantum algorithm, this embodiment determines the extended implementations corresponding to the multiple extension points of the quantum compiler according to the configuration file, and calls the corresponding extended implementations in sequence according to the implementation order of the compilation stage. In the above process, different extended implementations can be configured on the extension points of the quantum compiler, so that the quantum compiler can adapt to any quantum computing backend. It can be seen that this embodiment can improve the versatility and scalability of the quantum compiler.
[0105] Furthermore, the process in which the compile execution module 703 sequentially calls the corresponding extension implementations according to the implementation order of the compile stage includes: sequentially calling the extension implementations corresponding to the first extension point, the second extension point and the third extension point.
[0106] Furthermore, the operations performed by the compiling and executing module 703 when calling the extended implementation corresponding to the first extension point include: decomposing the quantum algorithm into quantum circuits including single-bit gates and two-bit gates.
[0107] Furthermore, the operations performed by the compiling and executing module 703 when calling the extended implementation corresponding to the second extension point include: laying out the quantum circuit obtained in the quantum gate decomposition stage to the quantum bits of the back end, and adding auxiliary bits.
[0108] Furthermore, the operations performed when the compiling and executing module 703 calls the extension implementation corresponding to the third extension point include: converting the single-bit gate and the two-bit gate into a program described by the quantum computing backend instruction set.
[0109] Furthermore, before the quantum gate decomposition stage, a quantum algorithm preprocessing stage is also included, and the extension point also includes a fourth extension point corresponding to the quantum algorithm preprocessing stage;
[0110] Correspondingly, the operations performed by the compiling and executing module 703 when calling the extended implementation corresponding to the fourth extension point include: performing a preprocessing operation on the quantum algorithm, so as to process the preprocessed quantum algorithm in the quantum gate decomposition stage.
[0111] Furthermore, a pre-compilation optimization stage is included between the quantum gate decomposition stage and the quantum bit layout stage, and the extension point further includes a fifth extension point corresponding to the pre-compilation optimization stage;
[0112] Correspondingly, the operations performed by the compile execution module 703 when calling the extension implementation corresponding to the fifth extension point include: performing a pre-compilation optimization operation on the quantum circuit obtained in the quantum gate decomposition stage, so as to process the pre-compilation optimized quantum circuit in the quantum bit layout stage.
[0113] Furthermore, after the quantum gate realization stage, a post-compilation optimization stage is also included, and the extension point also includes a sixth extension point corresponding to the post-compilation optimization stage;
[0114] Correspondingly, the operation performed by the compiling and executing module 703 when calling the extended implementation corresponding to the sixth extension point includes: performing a post-compilation optimization operation on the program described by the quantum computing backend instruction set obtained in the quantum gate implementation phase.
[0115] Furthermore, it also includes:
[0116] The loading module is used to load the extension implementation dynamically or statically before calling the corresponding extension implementation in sequence according to the implementation order of the compilation stage.
[0117] Furthermore, the extension points also include: a fourth extension point corresponding to the quantum algorithm preprocessing stage, the extension points also include a fifth extension point corresponding to the pre-compilation optimization stage and a sixth extension point corresponding to the post-compilation optimization stage;
[0118] Correspondingly, the compilation execution module 703 calls the corresponding extension implementation in sequence according to the implementation order of the compilation stage, including: calling the extension implementation corresponding to the fourth extension point, the first extension point, the fifth extension point, the second extension point, the third extension point and the sixth extension point in sequence.
[0119] Furthermore, the compilation execution module 703 sequentially calls the corresponding extended implementations according to the implementation order of the compilation stages, including: dividing all the compilation stages into N stage combinations; wherein one stage combination includes one or more compilation stages; deploying the extended implementations corresponding to the N stage combinations in N quantum compilation devices; and using the N quantum compilation devices to sequentially call the corresponding extended implementations according to the implementation order of the compilation stages.
[0120] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, which will not be repeated here.
[0121] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0122] The present application also provides an electronic device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the electronic device may also include various network interfaces, power supplies and other components.
[0123] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0124] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprising a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for compiling a quantum algorithm, characterized in that: include: Determine, according to the configuration file, the extended implementations corresponding to the multiple extension points in the quantum compiler; wherein the quantum compilation process of the quantum compiler includes multiple compilation stages, the extension points are functional interfaces corresponding to the compilation stages, and the extension points include a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage; receiving a quantum algorithm to be compiled; Calling the corresponding extension implementations in sequence according to the implementation order of the compilation stage to obtain a program described by the quantum computing backend instruction set; The operations performed when calling the extended implementation corresponding to the first extension point include: decomposing the quantum algorithm into quantum circuits including single-bit gates and two-bit gates; The operations performed when calling the extension implementation corresponding to the second extension point include: placing the quantum circuit obtained in the quantum gate decomposition stage to the quantum bits of the back end, and adding auxiliary bits; The operations performed when calling the extension implementation corresponding to the third extension point include: converting single-bit gates and two-bit gates into programs described by the quantum computing backend instruction set.
2. The method for compiling a quantum algorithm according to claim 1, characterized in that: The corresponding extension implementations are called in sequence according to the implementation order of the compilation phase, including: The extension implementations corresponding to the first extension point, the second extension point, and the third extension point are called in sequence.
3. The method for compiling a quantum algorithm according to claim 1, characterized in that: A quantum algorithm preprocessing stage is also included before the quantum gate decomposition stage, and the extension point also includes a fourth extension point corresponding to the quantum algorithm preprocessing stage; Correspondingly, the operations performed when calling the extension implementation corresponding to the fourth extension point include: A preprocessing operation is performed on the quantum algorithm so as to process the preprocessed quantum algorithm in the quantum gate decomposition stage.
4. The method for compiling a quantum algorithm according to claim 1, characterized in that: A pre-compilation optimization stage is further included between the quantum gate decomposition stage and the quantum bit layout stage, and the extension point further includes a fifth extension point corresponding to the pre-compilation optimization stage; Correspondingly, the operations performed when calling the extension implementation corresponding to the fifth extension point include: A pre-compilation optimization operation is performed on the quantum circuit obtained in the quantum gate decomposition stage, so that the pre-compilation optimized quantum circuit can be processed in the quantum bit layout stage.
5. The method for compiling a quantum algorithm according to claim 1, characterized in that: A post-compilation optimization stage is further included after the quantum gate implementation stage, and the extension point further includes a sixth extension point corresponding to the post-compilation optimization stage; Correspondingly, the operations performed when calling the extension implementation corresponding to the sixth extension point include: A post-compilation optimization operation is performed on the program described by the quantum computing back-end instruction set obtained in the quantum gate implementation stage.
6. The method for compiling a quantum algorithm according to claim 1, characterized in that: Before calling the corresponding extension implementations in sequence according to the implementation order of the compilation phase, the method further includes: The extension implementation is loaded dynamically or statically.
7. The method for compiling a quantum algorithm according to claim 1, characterized in that: The extension points also include: a fourth extension point corresponding to the quantum algorithm preprocessing stage, a fifth extension point corresponding to the pre-compilation optimization stage, and a sixth extension point corresponding to the post-compilation optimization stage; Accordingly, the corresponding extension implementations are called in sequence according to the implementation order of the compilation phase, including: calling the extension implementations corresponding to the fourth extension point, the first extension point, the fifth extension point, the second extension point, the third extension point and the sixth extension point in sequence; The operations performed when calling the extension implementation corresponding to the fourth extension point include: performing a preprocessing operation on the quantum algorithm so as to process the preprocessed quantum algorithm in the quantum gate decomposition stage; The operations performed when calling the extension implementation corresponding to the fifth extension point include: performing a pre-compilation optimization operation on the quantum circuit obtained in the quantum gate decomposition stage, so as to process the pre-compilation optimized quantum circuit in the quantum bit layout stage; The operation performed when calling the extension implementation corresponding to the sixth extension point includes: performing a post-compilation optimization operation on the program described by the quantum computing backend instruction set obtained in the quantum gate implementation phase.
8. The method for compiling a quantum algorithm according to any one of claims 1 to 7, characterized in that: The corresponding extension implementations are called in sequence according to the implementation order of the compilation phase, including: Dividing all the compilation stages into N stage combinations; wherein one stage combination includes one or more compilation stages; Deploy the extended implementation corresponding to the N stage combinations in N quantum compilation devices; The corresponding extended implementations are called in sequence according to the implementation order of the compilation stage using the N quantum compilation devices.
9. A compilation system for quantum algorithms, characterized in that: include: An extended implementation determination module is used to determine the extended implementations corresponding to multiple extension points in the quantum compiler according to the configuration file; wherein the quantum compilation process of the quantum compiler includes multiple compilation stages, the extension points are functional interfaces corresponding to the compilation stages, and the extension points include a first extension point corresponding to the quantum gate decomposition stage, a second extension point corresponding to the quantum bit layout stage, and a third extension point corresponding to the quantum gate implementation stage; An algorithm receiving module, used to receive the quantum algorithm to be compiled; A compiling and executing module, used to sequentially call the corresponding extension implementations according to the implementation order of the compiling stage to obtain a program described by the quantum computing backend instruction set; The operations performed by the compiling and executing module when calling the extension implementation corresponding to the first extension point include: decomposing the quantum algorithm into quantum circuits including single-bit gates and two-bit gates; The operations performed by the compiling and executing module when calling the extension implementation corresponding to the second extension point include: placing the quantum circuit obtained in the quantum gate decomposition stage to the quantum bits of the back end, and adding auxiliary bits; The operations performed by the compiling and executing module when calling the extension implementation corresponding to the third extension point include: converting single-bit gates and two-bit gates into programs described by the quantum computing backend instruction set.
10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the compiling method of the quantum algorithm as claimed in any one of claims 1 to 8 are implemented.
11. A storage medium, characterized in that: The storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the compilation method of the quantum algorithm as claimed in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Compiler and compiling method for extensible instruction set
CN111078290A
Extending A Development Environment
US20140189662A1
Adaptive compilation of quantum computing jobs
US20210012233A1
