A quantum program compilation method, apparatus and electronic device
By converting quantum programs into logic gates that support multiple platforms and optimizing quantum circuitry and noise, the problems of low efficiency and high noise in existing tools are solved, achieving efficient compilation and optimization for multiple platforms.
Patent Information
- Application Number
- CN202111258004.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2041-10-27
AI Technical Summary
Existing quantum compilers are platform-specific, resulting in low efficiency, high development costs, and quantum programs suffer from high depth and high noise.
The multi-control-bit quantum logic gates in the quantum program to be optimized are converted into target logic gates, the quantum circuits are optimized, the logic gates with high noise are replaced, and a suitable compilation method is selected to achieve multi-platform support.
It enables efficient compilation of quantum programs on multiple quantum platforms, reduces program depth and noise, and improves algorithm execution efficiency and accuracy.
Smart Images

Figure CN113934431B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a quantum program compilation method, apparatus, and electronic device. Background Technology
[0002] A compiler is a computer program that translates computer code written in one programming language into another. Compilation tools primarily convert source code from a high-level language into a low-level language to create executable programs.
[0003] Compared to ordinary computer programs, quantum programs are far more complex and require significantly more computing resources. Existing quantum compilers are typically developed for specific platforms. Therefore, applying quantum programs to multiple platforms necessitates using corresponding compilers for each platform, resulting in low efficiency and high development costs. Furthermore, existing compilers suffer from issues such as high quantum circuit depth and high noise levels. Summary of the Invention
[0004] In view of this, embodiments of the present invention disclose a quantum program compilation method, apparatus and electronic device, which solves the problem of high depth and noise in quantum programs in the prior art, and also achieves the goal of being oriented towards multiple quantum platforms.
[0005] This invention discloses a quantum program compilation method, comprising:
[0006] The multi-control-bit quantum logic gate in the quantum program to be optimized is converted into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate that matches the target quantum platform, and the target quantum platform includes multiple quantum platforms;
[0007] The quantum circuitry in the first quantum program is optimized to obtain the second quantum program;
[0008] The first logic gate in the second quantum program that does not meet the preset noise requirements is replaced with the second target logic gate to obtain the third quantum program;
[0009] A target compilation method matching the target quantum platform is determined from a variety of preset compilation methods, and the third quantum program is compiled using the target compilation method.
[0010] Optionally, converting the multi-control-bit quantum logic gate in the quantum program to be optimized into the first target logic gate includes:
[0011] The dual gates in the quantum program to be optimized are converted into a first combination of single gates, CNOT gates, and CU gates;
[0012] The multi-control gates in the quantum program to be optimized are converted into a second combination of single gates, CNOT gates, and CU gates;
[0013] Convert the CU gate into a combination of a single gate and a CNOT gate;
[0014] Convert the single door into a first combination of U3 door and CZ door;
[0015] The CNOT gate is converted into a second combination of a U3 gate and a CZ gate.
[0016] Optionally, optimizing the quantum circuitry in the first quantum program includes:
[0017] Detect whether there is a first quantum circuit in the first quantum program that does not meet the preset depth requirements;
[0018] Identify a target quantum circuit that matches the first quantum circuit;
[0019] Replace the first quantum circuit with the target quantum circuit.
[0020] Optionally, optimizing the quantum circuitry in the first quantum program includes:
[0021] Traverse the quantum circuits in the first quantum program to detect whether there are consecutive single gates or consecutive rotating gates;
[0022] If a series of consecutive single gates are detected, and the series of single gates meet a preset cancellation condition, then the series of single gates in the first quantum program are deleted.
[0023] If a series of revolving doors are detected and the series of revolving doors meet a preset merging condition, the series of revolving doors are merged into a target revolving door that matches the series of revolving doors.
[0024] Optionally, replacing the first logic gate in the second quantum program that does not meet the preset noise requirement with the second target logic gate includes:
[0025] Traverse the second quantum program to detect whether there is a first logic gate that does not meet the noise requirements;
[0026] A second target logic gate that matches the first logic gate is determined from the preset replacement rules;
[0027] Replace the first logic gate with the second target logic gate.
[0028] This invention discloses a quantum program compilation apparatus, comprising:
[0029] A conversion unit is used to convert a multi-control-bit quantum logic gate in the quantum program to be optimized into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate that matches a target quantum platform, and the target quantum platform includes multiple quantum platforms;
[0030] An optimization unit is used to optimize the quantum circuits in the first quantum program to obtain a second quantum program;
[0031] The replacement unit is used to replace the first logic gate in the second quantum program that does not meet the preset noise requirements with the second target logic gate to obtain the third quantum program;
[0032] The determining unit is used to determine a target compilation method that matches the target quantum platform from a variety of preset compilation methods, and to compile the third quantum program using the target compilation method.
[0033] Optionally, the conversion unit includes:
[0034] The first conversion subunit is used to convert the dual gates in the quantum program to be optimized into a first combination of single gates, CNOT gates, and CU gates;
[0035] The second conversion subunit is used to convert the multi-control gates in the quantum program to be optimized into a second combination of single gates, CNOT gates, and CU gates.
[0036] The third conversion subunit is used to convert the CU gate into a combination of a single gate and a CNOT gate;
[0037] The fourth conversion subunit is used to convert the single gate into a first combination of a U3 gate and a CZ gate;
[0038] The fifth conversion subunit is used to convert the CNOT gate into a second combination of a U3 gate and a CZ gate.
[0039] Optionally, the optimization unit includes:
[0040] The detection subunit is used to detect whether there is a first quantum circuit in the first quantum program that does not meet the preset depth requirements;
[0041] A determination subunit is used to determine a target quantum circuit that matches the first quantum circuit;
[0042] The first replacement subunit is used to replace the first quantum circuit with the target quantum circuit.
[0043] Optionally, the optimization unit includes:
[0044] The first traversal subunit is used to traverse the quantum circuits in the first quantum program and detect whether there are consecutive single gates or consecutive rotating gates.
[0045] The deletion sub-unit is used to delete consecutive single gates in the first quantum program if consecutive single gates are detected and the consecutive single gates meet a preset cancellation condition.
[0046] The merging subunit is used to merge consecutive revolving doors into a target revolving door that matches the consecutive revolving doors if consecutive revolving doors are detected and the consecutive revolving doors meet preset merging conditions.
[0047] This invention discloses an electronic device, comprising:
[0048] Memory and processor;
[0049] The memory is used to store programs, and the processor executes the quantum program compilation method described above when executing the programs in the memory.
[0050] This invention discloses a quantum program compilation method, apparatus, and electronic device. The method includes: converting multi-control-bit quantum logic gates in a quantum program to be optimized into first target logic gates to obtain a first quantum program; the first target logic gate is a logic gate matched with a target quantum platform, and the target quantum platform includes multiple quantum platforms; optimizing the quantum circuits in the first quantum program to obtain a second quantum program; replacing the first logic gates in the second quantum program that do not meet preset noise requirements with the second target logic gates to obtain a third quantum program; determining a target compilation method matched with the target quantum platform from a preset set of multiple compilation methods, and compiling the third quantum program using the target compilation method. Thus, by converting the quantum program into logic gates supported by multiple quantum platforms, a foundation is laid for compiling programs supported by multiple different quantum platforms. Furthermore, multiple compilation methods are pre-set, allowing selection of the desired compilation method, achieving the goal of supporting multiple quantum platforms, and optimizing the quantum program by reducing its depth and noise. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0052] Figure 1A flowchart illustrating a quantum program compilation method disclosed in an embodiment of the present invention is shown;
[0053] Figure 2 A schematic diagram of the structure of a quantum program compilation device provided in an embodiment of the present invention is shown;
[0054] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention is shown;
[0055] Figure 4 A schematic diagram of controlling the U-gate is shown. Detailed Implementation
[0056] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] Example 1
[0058] refer to Figure 1 The diagram illustrates a flowchart of a quantum program compilation method disclosed in an embodiment of the present invention. In this embodiment, the method includes:
[0059] S101: Convert the multi-control bit quantum logic gate in the quantum program to be optimized into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate that matches the target quantum platform, and the target quantum platform includes multiple quantum platforms;
[0060] In this embodiment, the quantum program uses multi-control bit quantum logic gates that are not supported by the quantum platform. In order to be applicable to the quantum platform, it needs to be converted into logic gates that the quantum platform can support. Different quantum platforms support different logic gates. In order for the quantum program to support multiple quantum platforms, it can be converted into different logic gates supported by different quantum platforms.
[0061] Optionally, to obtain support from different quantum platforms, in this embodiment, the multi-control bit quantum gate can be converted using the following method:
[0062] The two gates in the quantum program to be optimized are converted into a first combination of a single gate, a CNOT (Controlled-NOT) gate, and a CU gate;
[0063] The multi-control gates in the quantum program to be optimized are converted into a second combination of single gates, CNOT gates, and CU gates;
[0064] Convert the CU gate into a combination of a single gate and a CNOT gate;
[0065] Convert the single door into a first combination of U3 door and CZ door;
[0066] The CNOT gate is converted into a second combination of a U3 gate and a CZ gate.
[0067] Wherein, the CZ gate is the controlled-Z gate, and its corresponding matrix representation is:
[0068]
[0069] Among them, the CU gate is the control U gate, for example Figure 4 A schematic diagram of controlling the U-gate is shown.
[0070] The definition matrix of the U3 gate is as follows:
[0071] For example, a U3 gate is represented as:
[0072] In the U3 gate, the definable parameter is θ. λ.
[0073] In this embodiment, the quantum program to be optimized may contain some dual-gate and multi-controllable gates that are not supported by the quantum platform. The dual-gate and multi-controllable gates are converted into corresponding combinations of single-gate, CNOT gate, and CU gate. After conversion, the quantum program will contain single-gate, CNOT gate, and CU gate. To adapt to various different quantum platforms, CU gates also need to be converted into combinations of single-gate and CNOT gates, single gates into combinations of U3 gates and CZ gates, and CNOT gates into combinations of U3 gates and CZ gates. In one implementation, the first quantum logic gate can be represented as a U3 gate and a CZ gate, and multi-controllable bit quantum logic gates (dual-gate or multi-controllable gates) can be converted into U3 gates and CZ gates.
[0074] In this embodiment, the first combination of converting a dual-gate to a single-gate, a CNOT (Controlled-NOT) gate, and a CU gate, and the second combination of a single-gate, a CNOT gate, and a CU gate can be different. Similarly, the first combination of a U3 gate and a CZ gate and the second combination of a U3 gate and a CZ gate can also be different. S102: Optimize the quantum circuitry in the first quantum program to obtain the second quantum program;
[0075] Currently, quantum programs generally suffer from the problem of deep quantum circuitry. Existing compilation tools are unable to eliminate this problem, resulting in low execution efficiency of quantum algorithms and significant overhead in quantum simulation experiments or actual operation.
[0076] To address the aforementioned issues, the quantum circuitry in the quantum program was optimized in this embodiment.
[0077] The first quantum program is obtained by transforming the logic gates of the quantum program to be optimized. The optimization of the quantum circuits in the first quantum program includes the following two implementation methods:
[0078] Implementation Method 1:
[0079] Detect whether there is a first quantum circuit in the first quantum program that does not meet the preset depth requirements;
[0080] Identify a target quantum circuit that matches the first quantum circuit;
[0081] Replace the first quantum circuit with the target quantum circuit.
[0082] In this embodiment, a replacement rule base is pre-set, which stores the correspondence between the first quantum circuit to be replaced and the target quantum circuit. The first quantum circuit is a quantum circuit with higher depth, and the target quantum circuit is a quantum circuit with lower depth.
[0083] Those that do not meet the preset depth requirements can be understood as having a higher depth. Specifically, the degree of depth can be determined according to specific needs, and the preset depth requirements can also be confirmed according to specific needs.
[0084] Implementation Method Two:
[0085] Traverse the quantum circuits in the first quantum program to detect whether there are consecutive single gates or consecutive rotating gates;
[0086] If a series of consecutive single gates are detected, and the series of single gates meet a preset cancellation condition, then the series of single gates in the first quantum program are deleted.
[0087] If a series of revolving doors are detected and the series of revolving doors meet a preset merging condition, the series of revolving doors are merged into a target revolving door that matches the series of revolving doors.
[0088] In this embodiment, after the execution of consecutive single gates in the quantum program, it may represent a no-operation, that is, the result before the execution of consecutive single gates is the same as the result after the execution of consecutive single gates. In order to avoid invalid operations, in this embodiment, single gates that meet the preset cancellation conditions are deleted.
[0089] In this embodiment, the functions implemented by multiple rotating gates in the quantum program may be the same as the functions of a single rotating gate. Therefore, in order to save resources and improve efficiency, multiple consecutive rotating gates can be replaced with a single rotating gate. In a preset rule base, a correspondence between multiple consecutive rotating gates and their corresponding target rotating gates is pre-set. When consecutive rotating gates are detected, the corresponding target rotating gate is found from the preset rule base, and the consecutive rotating gates are replaced by the target rotating gate.
[0090] In this embodiment, only one of the above-mentioned implementation methods 1 and 2 can be executed, or both can be executed. When both implementation method 1 and implementation method 2 need to be executed, the execution order of implementation method 1 and implementation method 2 is not limited. Implementation method 1 can be executed first, and then implementation method 2 can be executed. In this case, the first quantum program in implementation method 2 is obtained after implementation method 1. Alternatively, implementation method 2 can be executed first, and then implementation method 1 can be executed. In this case, the first quantum program in implementation method 1 is obtained after implementation method 2.
[0091] S103: Replace the first logic gate in the second quantum program that does not meet the preset noise requirements with the second target logic gate to obtain the third quantum program;
[0092] In this embodiment, the current quantum program contains some logic gates with high noise levels, which reduces the execution accuracy of the algorithm. To improve the execution accuracy of the algorithm, this embodiment optimizes the quantum program and reduces the noise in the quantum program.
[0093] In this embodiment, by replacing the noisy logic gates in the quantum program with lower-noise target logic gates, the noise of the quantum program is reduced. In one implementation, S103 includes:
[0094] Traverse the second quantum program to detect whether there is a first logic gate that does not meet the noise requirements;
[0095] A second target logic gate that matches the first logic gate is determined from the preset replacement rules;
[0096] Replace the first logic gate with the second target logic gate.
[0097] In this embodiment, noise requirements are preset, and those that do not meet the noise requirements are considered to have high noise levels. A replacement rule base is also preset, which stores the correspondence between the first logic gate and the second target logic gate that do not meet the noise requirements.
[0098] S104: Determine a target compilation method that matches the target quantum platform from a variety of preset compilation methods, and compile the third quantum program using the target compilation method.
[0099] In this embodiment, in order to support different target quantum platforms, multiple compilation methods are set up. When compiling a quantum program, you only need to select the corresponding quantum compilation method.
[0100] In this embodiment, a correspondence between the target quantum platform and the compilation method is pre-set. Before compiling the quantum program, the target compilation method corresponding to the target quantum platform is determined, and the third quantum program is compiled using the target compilation method.
[0101] Optional compilation methods include: QASM-oriented code compilation methods and the compilation methods of Quil, a quantum instruction language developed by Rigetti, and the compilation methods of QRunes quantum instruction set launched by Origin Quantum. However, it should be noted that the preset compilation methods include, but are not limited to, QASM-oriented code compilation methods and QuinTengIR-oriented code compilation methods.
[0102] The QASM-oriented compilation method receives a third quantum program and outputs OpenQASM quantum assembly code. OpenQASM is one of the most widely used quantum computing assembly languages, similar to LIVMIR in classical computing. The multi-objective quantum code generation module allows the compilation of hybrid quantum programs written in high-level quantum programming languages into OpenQASM quantum assembly, supporting a wider range of quantum machines.
[0103] This invention discloses a quantum program compilation method, comprising: converting multi-control-bit quantum logic gates in a quantum program to be optimized into first target logic gates to obtain a first quantum program; the first target logic gates are logic gates matched with a target quantum platform, the target quantum platform including multiple quantum platforms; optimizing the quantum circuits in the first quantum program to obtain a second quantum program; replacing the first logic gates in the second quantum program that do not meet preset noise requirements with the second target logic gates to obtain a third quantum program; determining a target compilation method matched with the target quantum platform from a preset set of multiple compilation methods, and compiling the third quantum program using the target compilation method. Thus, by converting the quantum program into logic gates supported by multiple quantum platforms, a foundation is laid for compiling programs supported by multiple different quantum platforms. Furthermore, multiple compilation methods are pre-set, allowing selection of the desired compilation method, achieving the goal of supporting multiple quantum platforms, and optimizing the quantum program by reducing its depth and noise.
[0104] Example 2
[0105] refer to Figure 2 The diagram illustrates a structural schematic of a quantum program compilation device provided in an embodiment of the present invention. In this embodiment, the device includes:
[0106] The conversion unit 201 is used to convert the multi-control bit quantum logic gate in the quantum program to be optimized into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate that matches the target quantum platform, and the target quantum platform includes multiple quantum platforms;
[0107] Optimization unit 202 is used to optimize the quantum circuits in the first quantum program to obtain a second quantum program;
[0108] Replacement unit 203 is used to replace the first logic gate in the second quantum program that does not meet the preset noise requirements with the second target logic gate to obtain the third quantum program;
[0109] The determining unit 204 is used to determine a target compilation method that matches the target quantum platform from a variety of preset compilation methods, and to compile the third quantum program using the target compilation method.
[0110] Optionally, the conversion unit includes:
[0111] The first conversion subunit is used to convert the dual gates in the quantum program to be optimized into a first combination of single gates, CNOT gates, and CU gates;
[0112] The second conversion subunit is used to convert the multi-control gate in the quantum program to be optimized into a second combination of single gate, CNOT gate and CU gate;
[0113] The third conversion subunit is used to convert the CU gate into a combination of a single gate and a CNOT gate;
[0114] The fourth conversion subunit is used to convert the single gate into a first combination of a U3 gate and a CZ gate;
[0115] The fifth conversion subunit is used to convert the CNOT gate into a second combination of a U3 gate and a CZ gate.
[0116] Optionally, the optimization unit includes:
[0117] The detection subunit is used to detect whether there is a first quantum circuit in the first quantum program that does not meet the preset depth requirements;
[0118] A determination subunit is used to determine a target quantum circuit that matches the first quantum circuit;
[0119] The first replacement subunit is used to replace the first quantum circuit with the target quantum circuit.
[0120] Optionally, the optimization unit includes:
[0121] The first traversal subunit is used to traverse the quantum circuits in the first quantum program and detect whether there are consecutive single gates or consecutive rotating gates.
[0122] The deletion sub-unit is used to delete consecutive single gates in the first quantum program if consecutive single gates are detected and the consecutive single gates meet a preset cancellation condition.
[0123] The merging subunit is used to merge consecutive revolving doors into a target revolving door that matches the consecutive revolving doors if consecutive revolving doors are detected and the consecutive revolving doors meet preset merging conditions.
[0124] Optionally, the replacement unit includes:
[0125] The second traversal subunit is used to traverse the second quantum program and detect whether there is a first logic gate that does not meet the noise requirements.
[0126] A sub-unit is determined to identify a second target logic gate that matches the first logic gate from a preset replacement rule.
[0127] The second replacement subunit is used to replace the first logic gate with the second target logic gate.
[0128] The apparatus of this embodiment converts multi-control-bit quantum logic gates in a quantum program to be optimized into first target logic gates to obtain a first quantum program. The first target logic gate is a logic gate matched with a target quantum platform, which includes multiple quantum platforms. The quantum circuits in the first quantum program are optimized to obtain a second quantum program. The first logic gates in the second quantum program that do not meet preset noise requirements are replaced with the second target logic gates to obtain a third quantum program. A target compilation method matching the target quantum platform is determined from a preset set of multiple compilation methods, and the third quantum program is compiled using the target compilation method. Thus, by converting the quantum program into logic gates supported by multiple quantum platforms, a foundation is laid for compiling programs supported by multiple different quantum platforms. Furthermore, multiple compilation methods are pre-set, allowing selection of the desired compilation method, achieving the goal of supporting multiple quantum platforms. Additionally, the quantum program is optimized, reducing its depth and noise.
[0129] Example 3
[0130] refer to Figure 3The diagram illustrates a structural schematic of an electronic device according to an embodiment of the present invention. In this embodiment, the electronic device includes:
[0131] Memory 301 and processor 302;
[0132] The memory 301 is used to store programs, and the processor 302 executes a quantum program compilation method as described below when executing the programs in the memory.
[0133] The multi-control-bit quantum logic gate in the quantum program to be optimized is converted into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate that matches the target quantum platform, and the target quantum platform includes multiple quantum platforms;
[0134] The quantum circuitry in the first quantum program is optimized to obtain the second quantum program;
[0135] The first logic gate in the second quantum program that does not meet the preset noise requirements is replaced with the second target logic gate to obtain the third quantum program;
[0136] A target compilation method matching the target quantum platform is determined from a variety of preset compilation methods, and the third quantum program is compiled using the target compilation method.
[0137] Optionally, converting the multi-control-bit quantum logic gate in the quantum program to be optimized into the first target logic gate includes:
[0138] The dual gates in the quantum program to be optimized are converted into a first combination of single gates, CNOT gates, and CU gates;
[0139] The multi-control gates in the quantum program to be optimized are converted into a second combination of single gates, CNOT gates, and CU gates;
[0140] Convert the CU gate into a combination of a single gate and a CNOT gate;
[0141] Convert the single door into a first combination of U3 door and CZ door;
[0142] The CNOT gate is converted into a second combination of a U3 gate and a CZ gate.
[0143] Optionally, optimizing the quantum circuitry in the first quantum program includes:
[0144] Detect whether there is a first quantum circuit in the first quantum program that does not meet the preset depth requirements;
[0145] Identify a target quantum circuit that matches the first quantum circuit;
[0146] Replace the first quantum circuit with the target quantum circuit.
[0147] Optionally, optimizing the quantum circuitry in the first quantum program includes:
[0148] Traverse the quantum circuits in the first quantum program to detect whether there are consecutive single gates or consecutive rotating gates;
[0149] If a series of consecutive single gates are detected, and the series of single gates meet a preset cancellation condition, then the series of single gates in the first quantum program are deleted.
[0150] If a series of revolving doors are detected and the series of revolving doors meet a preset merging condition, the series of revolving doors are merged into a target revolving door that matches the series of revolving doors.
[0151] Optionally, replacing the first logic gate in the second quantum program that does not meet the preset noise requirement with the second target logic gate includes:
[0152] Traverse the second quantum program to detect whether there is a first logic gate that does not meet the noise requirements;
[0153] A second target logic gate that matches the first logic gate is determined from the preset replacement rules;
[0154] Replace the first logic gate with the second target logic gate.
[0155] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0156] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for quantum program compilation, characterized by, The method comprises the following steps: Converting a multi-control-bit quantum logic gate in a quantum program to be optimized into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate matched with a target quantum platform, and the target quantum platform comprises a plurality of quantum platforms; Optimizing a quantum circuit in the first quantum program to obtain a second quantum program; Replacing a first logic gate that does not meet a preset noise requirement in the second quantum program with a second target logic gate to obtain a third quantum program; Determining a target compiling method matched with the target quantum platform from a plurality of preset compiling methods, and compiling the third quantum program through the target compiling method; The optimization of the quantum circuit in the first quantum program comprises the following steps: Detecting whether a first quantum circuit that does not meet a preset depth requirement exists in the first quantum program; Determining a target quantum circuit matched with the first quantum circuit; Replacing the first quantum circuit with the target quantum circuit; Or, the optimization of the quantum circuit in the first quantum program comprises the following steps: Traversing the quantum circuit in the first quantum program to detect whether there exists a continuous single gate or a continuous rotation gate; If a continuous single gate is detected, and the continuous single gate meets a preset cancellation condition, deleting the continuous single gate in the first quantum program; If a continuous rotation gate is detected, and the continuous rotation gate meets a preset merging condition, merging the continuous rotation gate into a target rotation gate matched with the continuous rotation gate.
2. The method of claim 1, wherein, The conversion of the multi-control-bit quantum logic gate in the quantum program to be optimized into the first target logic gate comprises the following steps: Converting a double gate in the quantum program to be optimized into a first combination of a single gate, a CNOT gate and a CU gate; Converting a multi-control gate in the quantum program to be optimized into a second combination of a single gate, a CNOT gate and a CU gate; Converting the CU gate into a combination of a single gate and a CNOT gate; Converting the single gate into a first combination of a U3 gate and a CZ gate; Converting the CNOT gate into a second combination of a U3 gate and a CZ gate.
3. The method of claim 1, wherein, The replacement of the first logic gate that does not meet the preset noise requirement in the second quantum program with the second target logic gate comprises the following steps: Traversing the second quantum program to detect whether there exists a first logic gate that does not meet a noise requirement; Determining a second target logic gate matched with the first logic gate from a preset replacement rule; Replacing the first logic gate with the second target logic gate.
4. A quantum program compilation apparatus, comprising: The method comprises the following steps: A conversion unit is configured to convert a multi-control-bit quantum logic gate in a quantum program to be optimized into a first target logic gate to obtain a first quantum program; the first target logic gate is a logic gate matched with a target quantum platform, and the target quantum platform comprises a plurality of quantum platforms; An optimization unit is configured to optimize a quantum circuit in the first quantum program to obtain a second quantum program; A replacement unit is configured to replace a first logic gate that does not meet a preset noise requirement in the second quantum program with a second target logic gate to obtain a third quantum program. The determining unit is configured to determine a target compiling method matched with the target quantum platform from a plurality of preset compiling methods, and compile the third quantum program by using the target compiling method. The optimization unit comprises: The detecting subunit is configured to detect whether a first quantum circuit that does not meet a preset depth requirement exists in the first quantum program. The determining subunit is configured to determine a target quantum circuit matched with the first quantum circuit. The first replacing subunit is configured to replace the first quantum circuit with the target quantum circuit. Or, the optimization unit comprises: The first traversing subunit is configured to traverse quantum circuits in the first quantum program to detect whether a continuous single gate or a continuous rotation gate exists. The deleting subunit is configured to delete the continuous single gate in the first quantum program if the continuous single gate is detected and meets a preset cancellation condition. The merging subunit is configured to merge the continuous rotation gate into a target rotation gate matched with the continuous rotation gate if the continuous rotation gate is detected and meets a preset merging condition.
5. The apparatus of claim 4, wherein, The converting unit comprises: The first converting subunit is configured to convert a double gate in the quantum program to be optimized into a first combination of a single gate, a CNOT gate and a CU gate. The second converting subunit is configured to convert a multi-control gate in the quantum program to be optimized into a second combination of a single gate, a CNOT gate and a CU gate. The third converting subunit is configured to convert the CU gate into a combination of a single gate and a CNOT gate. The fourth converting subunit is configured to convert the single gate into a first combination of a U3 gate and a CZ gate. The fifth converting subunit is configured to convert the CNOT gate into a second combination of a U3 gate and a CZ gate.
6. An electronic device, comprising: The memory and the processor are included. The memory is configured to store a program, and the processor is configured to execute the program in the memory to execute the quantum program compiling method in any one of claims 1-3.
Citation Information
Patent Citations
Approximate gate and supercontrolled unitary gate decompositions for two-qubit operations
US10474960B1
Quantum circuits with reduced t gate count
WO2019050555A1