Quantum algorithm compiling method, and compiler, quantum computer and computing device

Through the multi-level intermediate expression compiler framework and hierarchical processing technology, custom optimization of quantum algorithms is supported, and the problem of high development difficulty in the existing technology is solved, and the efficient compilation and execution of quantum algorithms is achieved.

WO2024244589A1PCT designated stage expired Publication Date: 2024-12-05HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/080646
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-31
Filing Date
2024-03-07
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

The existing quantum algorithm compilation methods do not support developers to add custom optimizations to quantum algorithms, which makes quantum algorithm development more difficult.

Method used

Using a multi-level intermediate expression compiler framework, the source code of the quantum algorithm is converted into intermediate expressions, and electromagnetic wave information is generated through layered processing, and quantum bits are bound to generate executable files of quantum chips, which supports developers to perform during the compilation process. Custom optimization.

Benefits of technology

It realizes custom optimization of quantum algorithms, improves development freedom, simplifies the compilation process of quantum algorithms, and improves the execution efficiency of quantum algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024080646_05122024_PF_FP_ABST
    Figure CN2024080646_05122024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are a quantum algorithm compiling method, and a compiler, a quantum computer and a computing device. In the quantum algorithm compiling method, before an executable file is generated, a multi-level intermediate expression compiler framework can be used for freely increasing intermediate expressions of various levels and realizing the characteristics of conversion of different intermediate expressions, a source code in which a quantum algorithm is recorded is converted into intermediate expressions under a first target compiler framework, and hierarchical processing is performed on the intermediate expressions, such that custom optimizations by developers in the quantum algorithm can be compiled in the form of the intermediate expressions, thereby achieving the purposes of jumping out of the language specification of the quantum algorithm and supporting the developers of the quantum algorithm to freely increase the custom optimizations as needed.
Need to check novelty before this filing date? Find Prior Art

Description

Compilation methods, compilers, quantum computers, and computing devices for quantum algorithms

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 31, 2023, with application number 202310639499.X and invention name “Compilation method, compiler, quantum computer and computing device for quantum algorithm”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments in this specification relate to the field of computer application technology, specifically, to quantum computing technology under the field of computer application technology, and more specifically, to a compilation method, compiler, quantum computer and computing device for a quantum algorithm. Background Art

[0003] Compilation refers to the process of translating program code written in a high-level computer language into binary machine language code that can be run by a computer. Using a compiler (also known as a compiler), a program written in a certain programming language can be translated into an equivalent program in another language.

[0004] In quantum computers, quantum chips also need to use a compiler to convert quantum algorithms into executable files before executing them. Conventional quantum algorithm compilation methods do not allow developers to add custom optimizations to quantum algorithms, making quantum algorithm development more difficult.

[0005] Summary of the Invention

[0006] Multiple embodiments in this specification provide a quantum algorithm compilation method, compiler, quantum computer, and computing device, achieving the purpose of supporting the addition of custom optimization to quantum algorithms.

[0007] In a first aspect, an embodiment of the present specification provides a method for compiling a quantum algorithm, comprising: converting source code recording a quantum algorithm into an intermediate expression under a first target compiler framework; the first target compiler framework includes a multi-level intermediate expression compiler framework; the intermediate expression is used to represent quantum gate operations in the quantum algorithm; hierarchical processing is performed on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to an electromagnetic wave used to control a quantum bit to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate expression to a quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit; based on the electromagnetic wave information, generating an executable file for a quantum chip, wherein the quantum chip includes a plurality of the quantum bits.

[0008] In a second aspect, an embodiment of the present specification provides a compiler, comprising: a first conversion module, configured to convert source code recording a quantum algorithm into an intermediate expression under a first target compiler framework; the first target compiler framework comprises a multi-level intermediate expression compiler framework; the intermediate expression is used to characterize quantum gate operations in the quantum algorithm; an expression processing module, configured to perform hierarchical processing on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to electromagnetic waves used to control quantum bits to implement the quantum gate operations; the hierarchical processing comprises hardware implementation processing; the hardware implementation processing comprises binding the intermediate expression to the quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit; a file generation module, configured to generate an executable file for a quantum chip based on the electromagnetic wave information, wherein the quantum chip comprises a plurality of the quantum bits.

[0009] In a third aspect, one embodiment of this specification provides a quantum computer, comprising: a quantum chip, a control system, and a compiler as described above; the compiler is connected to the control system, the control system is used to execute an executable file output by the compiler, and output electromagnetic waves to the quantum chip; the quantum chip is used to execute the quantum algorithm recorded in the executable file under the control of the electromagnetic wave.

[0010] In a fourth aspect, an embodiment of this specification provides a computing device, comprising: a processor and a memory; wherein the memory is connected to the processor, and the memory is used to store a computer program; the processor is used to implement a compilation method of a quantum algorithm as described in any one of the above items by running the computer program stored in the memory.

[0011] In a fifth aspect, an embodiment of this specification provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the compilation method of the quantum algorithm as described above is implemented.

[0012] In a sixth aspect, one embodiment of this specification provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; the processor of the computer device reads the computer instructions from the computer-readable storage medium, and when the processor executes the computer instructions, the steps of the above-mentioned quantum algorithm compilation method are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in this application and should not be construed as limiting the scope of this application.

[0014] FIG1 is a feasible application scenario of a quantum algorithm compilation method provided in one embodiment of this specification.

[0015] FIG2 is a schematic diagram of the architecture of a quantum computer to which a compilation method for a quantum algorithm provided in one embodiment of this specification may be applied.

[0016] FIG3 is a flow chart of a method for compiling a quantum algorithm provided in accordance with one embodiment of this specification.

[0017] FIG4 is a flow chart of another method for compiling a quantum algorithm provided in accordance with one embodiment of this specification.

[0018] FIG5 is a flow chart of another method for compiling a quantum algorithm provided in accordance with an embodiment of this specification.

[0019] FIG6 is a schematic diagram of the structure of a compiler provided in one embodiment of this specification.

[0020] FIG7 is a schematic diagram of the structure of a computing device provided in one embodiment of this specification. DETAILED DESCRIPTION

[0021] Unless otherwise defined, technical or scientific terms used in the embodiments of this specification should have the same ordinary meaning as those understood by persons of ordinary skill in the art to which this specification pertains. The terms "first," "second," and similar terms used in the embodiments of this specification do not denote any order, quantity, or importance, but are provided solely to avoid confusion between constituent elements.

[0022] Unless the context requires otherwise, throughout this specification, the term "plurality" means "at least two," and "including" is to be interpreted as open and inclusive, meaning "including, but not limited to." Throughout this specification, the terms "one embodiment," "some embodiments," "exemplary embodiments," "example," "specific example," or "some examples" are intended to indicate that a particular feature, structure, material, or characteristic associated with the embodiment or example is included in at least one embodiment or example of this specification. The schematic representations of these terms do not necessarily refer to the same embodiment or example.

[0023] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.

[0024] Overview

[0025] Quantum computers can perform computations much faster than traditional computers because they exploit the coherence of quantum states. Specifically, in traditional computers, information is stored and processed in the form of binary code, with each binary bit storing only a 0 or 1. In quantum computers, information is stored and processed in the form of quantum bits (qubits). Qubits can exist in a superposition of multiple states, enabling quantum computers to handle multiple computational tasks simultaneously, completing large numbers of computations in a short period of time. Furthermore, quantum computers possess properties such as quantum parallelism and quantum interference, which enable them to perform certain computational tasks much faster than traditional computers. For example, quantum computers can solve large-scale factorization problems in polynomial time, while traditional computers would require exponential time to complete the same task. This significant speed advantage makes quantum computers promising broad applications in science, engineering, and business in the future.

[0026] Given these advantages, quantum computers have become a key research and development focus for various computing vendors. Currently, when developing quantum algorithms for quantum computers, developers must rely on the quantum domain's DSL (Domain Specific Language). This limitation prevents developers from adding custom optimizations to quantum algorithms, significantly restricting their development.

[0027] To address this issue, the present invention has discovered through research that a multi-level intermediate representation compiler framework (MLIR) uses an intermediate representation (IR) to represent source code and target code. This allows developers' custom optimizations in quantum algorithms to be optimized and compiled in the form of intermediate representations during the compilation process, thereby bypassing the language specifications of quantum algorithms and enabling developers of quantum algorithms to freely add custom optimizations based on demand, thereby increasing the freedom of quantum algorithm development.

[0028] Based on the above concept, an embodiment of this specification provides a method for compiling a quantum algorithm. The following will exemplarily describe the method for compiling a quantum algorithm with reference to the accompanying drawings.

[0029] Scenario Example

[0030] Referring to Figure 1, Figure 1 shows a feasible application scenario of the compilation method of the quantum algorithm. In this application scenario, the developer develops a quantum algorithm that needs to be executed by a quantum chip. The quantum algorithm can be written based on the language specification of the quantum algorithm. Since the quantum algorithm is still based on the algorithm logic represented by characters, it cannot be directly executed by the quantum chip. Therefore, the quantum algorithm needs to be input into the compiler. The compiler compiles the quantum algorithm to obtain an executable file (Executable File). The executable file is input into the control system of the quantum chip to obtain an electromagnetic wave that controls the quantum chip to execute the quantum algorithm. The electromagnetic wave is input into the quantum chip, so that the quantum chip implements the quantum algorithm and finally obtains the output result of the quantum chip executing the quantum algorithm. In this process, the compiler can execute the compilation method of the quantum algorithm to compile the quantum algorithm.

[0031] The system architecture in which this quantum algorithm compilation method can be applied can be a quantum computer. As shown in Figure 2, the quantum computer 10 may include a control system 12, a quantum chip 13, and a compiler 11. Compiler 11 is used to execute the quantum algorithm compilation method, converting the quantum algorithm into an executable file for quantum chip 13. Control system 12 generates electromagnetic waves based on the executable file and transmits the waves to quantum chip 13. Under the control of the electromagnetic waves, the qubits in quantum chip 13 implement the quantum algorithm. Compiler 11 can be installed on a device with computing and communication capabilities, such as a desktop computer, tablet computer, laptop computer, smartphone, digital assistant, smart wearable device, shopping guide terminal, television, smart speaker, microphone, etc. Smart wearable devices include, but are not limited to, smart bracelets, smart watches, smart glasses, smart helmets, smart necklaces, etc. Control system 12 can be a device with computing capabilities and electromagnetic wave transmission capabilities. Quantum chip 13 may include multiple qubits, which can implement the corresponding quantum algorithm under the control of electromagnetic waves.

[0032] Example Method

[0033] One embodiment of this specification provides a method for compiling a quantum algorithm, as shown in FIG3 , including:

[0034] S301: Convert source code containing a quantum algorithm into an intermediate representation under a first target compiler framework; the first target compiler framework includes a multi-level intermediate representation compiler framework; the intermediate representation is used to represent quantum gate operations in the quantum algorithm.

[0035] In the multi-level intermediate representation compiler framework, an intermediate representation is an abstract representation between source code and the machine code (e.g., binary code) in an executable file. The intermediate representation supports optimization and transformation, and within the framework, executable files can be generated based on the intermediate representation. Thus, custom optimizations specified by quantum algorithm developers in the source code can be converted into an intermediate representation in step S301. In subsequent steps, these custom optimizations are compiled as intermediate representations, transcending the quantum algorithm's language specifications and allowing developers to freely add custom optimizations based on their needs.

[0036] In one optional embodiment, the source code is written in the open quantum assembly language OpenQASM. OpenQASM is an open-source quantum assembly language with a low learning curve based on a syntax similar to classical computer assembly language. It also provides extensive documentation and example code to help users get started quickly. Furthermore, OpenQASM provides a rich set of quantum gates and measurement operations that can be used to build a variety of quantum algorithms. Therefore, writing source code in OpenQASM can reduce the learning cost for developers and support their development of various types of quantum algorithms.

[0037] S302: performing hierarchical processing on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control the quantum bit to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate expression to the quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit.

[0038] In view of the fact that quantum chips require electromagnetic waves for result reading and quantum bit operations, in step S302, after obtaining the intermediate expression converted from the quantum algorithm, the multi-level intermediate expression compiler framework is used to perform hierarchical processing on the intermediate expression, bind the intermediate expression to the quantum bit, and generate electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit. In this way, the quantum algorithm is truly implemented at the executable level of the quantum chip, realizing end-to-end compilation of the quantum algorithm.

[0039] S303: Based on the electromagnetic wave information, generate an executable file of a quantum chip, where the quantum chip includes a plurality of the quantum bits.

[0040] The electromagnetic wave information corresponds to the electromagnetic wave used to control the quantum bit to implement the quantum gate operation. In this way, based on the electromagnetic wave information, an executable file that can control the execution of the quantum chip can be generated to complete the compilation operation of the quantum algorithm.

[0041] In some embodiments, taking the quantum computer shown in FIG2 as an example, after obtaining the executable file, it is necessary to generate the electromagnetic wave actually sent to the quantum chip 13 through the control system 12. Therefore, when the system architecture of the control system 12 is not compatible with the first target compiler framework, it is necessary to convert (lower) the electromagnetic wave information to meet the requirements of the control system 12 that is not developed for the first target compiler framework. Specifically, generating the executable file for the quantum chip based on the electromagnetic wave information includes:

[0042] The electromagnetic wave information is converted into information to be converted, where the information to be converted meets the format requirements of a second target compiler framework; the second target compiler framework is a compiler framework different from the first target compiler framework.

[0043] The information to be converted is converted into binary information using a compiler tool of the second target compiler framework.

[0044] The executable file is generated based on the binary information.

[0045] In this embodiment, the second target compiler framework is a different compiler framework from the first target compiler framework, specifically a compiler framework adapted to the control system of the quantum computer. This allows the generated executable file to be effectively executed by the control system, generating electromagnetic waves to control the quantum chip.

[0046] Optionally, in some embodiments, the control system may be a control system using a multi-core RISCV-SOC (a system-on-chip based on the RISC-V instruction set architecture) and a control system based on RISCV to a self-developed quantum instruction set. Accordingly, the second target compiler framework may include a low-level virtual machine LLVM framework adapted to the control system.

[0047] Traditional control systems mainly optimize and migrate SIMD (Single Instruction Multiple Data) instructions and vectorized instructions in traditional CPU control to the field of quantum computing. These solutions are easier to develop under the current hardware scale of quantum chips (tens of qubits), but in the foreseeable future, the hardware scale will rapidly grow from dozens of qubits to hundreds of qubits. At that time, traditional control systems will be unable to cope. The use of multi-core RISCV-SOC and control systems based on RISCV to self-developed quantum instruction sets can effectively solve the problem of rapid growth in the hardware scale of quantum chips.

[0048] When the second target compiler framework is the LLVM framework, the MLIR tool chain and the LLVM tool chain can be well combined in the compilation method of quantum algorithms to meet the requirements for the use of executable files in multi-core RISCV-SOC and control systems based on RISCV to self-developed quantum instruction sets.

[0049] In some embodiments, when hierarchical processing is performed on the intermediate representation in step S302, the hierarchical processing may include, in addition to the hardware implementation processing, general processing, wherein the general processing includes at least one of merging, eliminating, replacing, and rearranging the quantum gate operations represented by the intermediate representation.

[0050] The merging of quantum gate operations may include merging consecutive quantum gate operations into a single quantum gate to reduce the number of quantum gate operations. The elimination of quantum gate operations may include eliminating adjacent inverse operations on the same quantum bit, thereby reducing invalid quantum gate operations. The replacement of quantum gate operations may include replacing a complex quantum gate operation with a relatively simple sequence of quantum gate operations to reduce the complexity of the quantum gate operation. The rearrangement optimization of quantum gate operations may include rearranging the physical layout of quantum registers to reduce the total number of quantum gate operations.

[0051] In addition, the general processing may also include reduced measurement and error correction of quantum gate operations. The reduced measurement may include reducing the number of qubits required to be measured to reduce the number of measurement operations. The error correction may include correcting the sequence of quantum gate operations to reduce the impact of quantum errors.

[0052] In this embodiment, by universally processing the intermediate expression, the quantum algorithm can be optimized, thereby simplifying the quantum algorithm and improving the execution efficiency of the quantum algorithm.

[0053] In some embodiments, as shown in FIG4 , before converting the source code recording the quantum algorithm into an intermediate expression under the framework of the first target compiler, the process further includes:

[0054] S304: Utilize the parser of the first target compiler framework to preliminarily parse the source code, so as to convert characters of the source code into characters that comply with the specification of the first target compiler framework.

[0055] In this embodiment, a parser of the first target compiler framework performs some basic analysis on human-readable but machine-unreadable characters in the source code. Specifically, the parser converts the source code characters into characters that conform to the specifications of the first target compiler framework. This improves the fault tolerance of the quantum algorithm compilation method and avoids compilation errors or compilation failures caused by excessive machine-unreadable characters in the source code.

[0056] In some embodiments, after generating an executable file for a quantum chip based on the electromagnetic wave information, the method further includes:

[0057] A preset quantum function database is bound to the executable file, and the preset quantum function database is used to store quantum functions called when the executable file is executed.

[0058] In this embodiment, the quantum functions called when executing the executable file are stored in a preset quantum function database, and the preset quantum function database is bound to the executable file. This allows the executable file to call quantum functions from the preset quantum function database during execution, thereby more conveniently implementing the quantum algorithm.

[0059] Referring to FIG5 , FIG5 shows a feasible execution process of the quantum algorithm compilation method in one embodiment of this specification, which may specifically include:

[0060] S501: Input source code in the OpenQASM format, where the source code records a quantum algorithm.

[0061] S502: Convert the source code containing the quantum algorithm into an intermediate expression under the framework of a multi-level intermediate expression compiler.

[0062] S503: Perform hierarchical processing on the intermediate expression to obtain electromagnetic wave information.

[0063] S504: Convert the electromagnetic wave information into information to be converted, where the information to be converted meets the format requirements of the LLVM framework.

[0064] S505: Using the compiler tool of the LLVM framework, convert the information to be converted into binary information.

[0065] S506: Generate the executable file based on the binary information.

[0066] S507: Binding a preset quantum function database to the executable file, wherein the preset quantum function database is used to store quantum functions called when the executable file is executed.

[0067] The quantum algorithm compilation method utilizes a multi-level intermediate expression compiler framework to freely add multiple levels of intermediate expressions and implement conversions between different intermediate expressions before generating an executable file. The source code recording the quantum algorithm is converted into an intermediate expression under a first target compiler framework, and the intermediate expression is processed in layers. This allows the developer's custom optimization in the quantum algorithm to be compiled in the form of an intermediate expression, thus bypassing the language specification of the quantum algorithm and supporting the developer of the quantum algorithm to freely add custom optimizations based on demand.

[0068] Exemplary compiler and quantum computer

[0069] Based on the same concept, the embodiment of this specification also provides a compiler, as shown in FIG6 , including:

[0070] The first conversion module 601 is configured to convert source code containing a quantum algorithm into an intermediate representation under a first target compiler framework; the first target compiler framework includes a multi-level intermediate representation compiler framework; and the intermediate representation is used to represent quantum gate operations in the quantum algorithm.

[0071] The expression processing module 602 is used to perform hierarchical processing on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control the quantum bit to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate expression to the quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit.

[0072] The file generation module 603 is configured to generate an executable file of a quantum chip based on the electromagnetic wave information, where the quantum chip includes a plurality of quantum bits.

[0073] The compiler provided in this embodiment shares the same concept as the quantum algorithm compilation method provided in the aforementioned embodiments of this application. It can execute the quantum algorithm compilation method provided in any of the aforementioned embodiments of this specification and possesses the corresponding functional modules and beneficial effects of executing the quantum algorithm compilation method. For technical details not fully described in this embodiment, please refer to the specific processing content of the quantum algorithm compilation method provided in the aforementioned embodiments of this application and will not be further elaborated here.

[0074] Accordingly, the embodiments of this specification also provide a quantum computer, as shown in FIG2 , including: a quantum chip 13 , a control system 12 , and a compiler 11 as described in the above embodiments.

[0075] The compiler 11 is connected to the control system 12 . The control system 12 is used to execute the executable file output by the compiler 11 and output electromagnetic waves to the quantum chip 13 .

[0076] The quantum chip 13 is used to execute the quantum algorithm recorded in the executable file under the control of the electromagnetic wave.

[0077] Example computing devices, storage media, and software

[0078] Another embodiment of this specification further provides a computing device. As shown in FIG7 , an exemplary embodiment of this specification further provides a computing device, including: a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it performs the steps of the method for compiling a quantum algorithm according to various embodiments of this specification as described in the above embodiments of this specification.

[0079] The internal structure of the computing device can be shown in Figure 7. The computing device includes a processor, a memory, a network interface, and an input device connected via a system bus. The processor of the computing device is used to provide computing and control capabilities. The memory of the central control device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computing device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the steps of the method for compiling a quantum algorithm according to various embodiments of the present specification are described in the above embodiments of the present specification.

[0080] The processor may include a main processor, and may also include a baseband chip, a modem, etc.

[0081] The memory stores a computer program that executes the technical solution of the present invention, and may also store an operating system and other key programs. Specifically, the computer program may include program code, which includes computer operating instructions. More specifically, the memory may include read-only memory (ROM), other types of static storage devices that can store static information and instructions, random access memory (RAM), other types of dynamic storage devices that can store information and instructions, disk storage, flash memory, etc.

[0082] The processor may be a general-purpose processor, such as a general-purpose processor (CPU), a microprocessor, or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.

[0083] Input devices may include devices that receive data and information input by a user, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.

[0084] Output devices may include means that allow information to be output to a user, such as display screens, printers, speakers, and the like.

[0085] The communication interface may include any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0086] The processor executes the computer program stored in the memory and calls other devices, which can be used to implement the various steps of the compilation method of any quantum algorithm provided in the above embodiments of the present application.

[0087] The computing device may also include a display component and a voice component. The display component may be a liquid crystal display or an electronic ink display. The input device of the computing device may be a touch layer covering the display component, or a button, trackball or touchpad provided on the housing of the computing device, or an external keyboard, touchpad or mouse.

[0088] Those skilled in the art will understand that the structure shown in FIG7 is merely a block diagram of a portion of the structure related to the solution of this specification, and does not constitute a limitation on the computing device to which the solution of this specification is applied. The specific computing device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0089] In addition to the above-mentioned methods and devices, the quantum algorithm compilation method provided in the embodiments of this specification may also be a computer program product, which includes a computer program. When the computer program is executed by a processor, the processor executes the steps of the quantum algorithm compilation method according to various embodiments of this specification described in the "Exemplary Methods" section above.

[0090] The computer program product may be written in any combination of one or more programming languages ​​to implement the operations of the embodiments of this specification, including object-oriented programming languages ​​such as Java, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0091] In addition, an embodiment of this specification also provides a computer-readable storage medium on which a computer program is stored, and the computer program is used by a processor to execute the steps of the method for compiling a quantum algorithm according to various embodiments of this specification described in the "Example Method" section above.

[0092] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0093] It should be understood that the specific examples in this document are only intended to help those skilled in the art better understand the implementation methods of this specification, and are not intended to limit the scope of this specification.

[0094] It can be understood that in the various implementations of this specification, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the implementation methods of this specification.

[0095] It can be understood that the various embodiments described in this specification can be implemented individually or in combination, and the embodiments in this specification are not limited to this.

[0096] Unless otherwise indicated, all technical and scientific terms used in the embodiments of this specification have the same meaning as those commonly understood by those skilled in the art in the technical field of this specification. The terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the scope of this specification. The term "and / or" used in this specification includes any and all combinations of one or more related listed items. The singular forms "a", "above", and "the" used in the embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise.

[0097] It is understood that the processor in the embodiments of this specification can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiment can be completed by hardware integrated logic circuits in the processor or software instructions. The above processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this specification can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.

[0098] It will be understood that the memory in the embodiments of this specification may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory may be a random access memory (RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0099] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this specification.

[0100] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, devices and units can refer to the corresponding processes in the aforementioned method implementation methods and will not be repeated here.

[0101] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0102] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of this embodiment.

[0103] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0104] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this specification, or the part that contributes to the prior art, or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes various media that can store program codes, such as 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.

[0105] The above description is merely a specific embodiment of this specification, but the scope of protection of this specification is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this specification should be included in the scope of protection of this specification. Therefore, the scope of protection of this specification should be based on the scope of protection of the claims.

Claims

1. A method for compiling a quantum algorithm, characterized in that: include: Converting source code recording a quantum algorithm into an intermediate expression under a first target compiler framework; the first target compiler framework includes a multi-level intermediate expression compiler framework; the intermediate expression is used to represent quantum gate operations in the quantum algorithm; The intermediate expression is subjected to hierarchical processing to obtain electromagnetic wave information; the electromagnetic wave information corresponds to an electromagnetic wave used to control a quantum bit to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate expression to a quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit; Based on the electromagnetic wave information, an executable file of a quantum chip is generated, where the quantum chip includes a plurality of the quantum bits.

2. The method according to claim 1, characterized in that The step of generating an executable file of a quantum chip based on the electromagnetic wave information includes: Converting the electromagnetic wave information into information to be converted, wherein the information to be converted meets the format requirements of a second target compiler framework; the second target compiler framework is a compiler framework different from the first target compiler framework; Using a compiler tool of the second target compiler framework, converting the information to be converted into binary information; Based on the binary information, the executable file is generated.

3. The method according to claim 2, characterized in that The second target compiler framework includes a low-level virtual machine LLVM framework.

4. The method according to claim 1, characterized in that The hierarchical processing further includes: general processing, wherein the general processing includes at least one of merging, eliminating, replacing and rearranging the quantum gate operations represented by the intermediate expression.

5. The method according to claim 1, characterized in that Before converting the source code recording the quantum algorithm into an intermediate expression under the framework of the first target compiler, the method further includes: The source code is preliminarily parsed using a parser of the first target compiler framework to convert characters of the source code into characters conforming to the specification of the first target compiler framework.

6. The method according to claim 1, characterized in that After generating the executable file of the quantum chip based on the electromagnetic wave information, the method further includes: A preset quantum function database is bound to the executable file, and the preset quantum function database is used to store quantum functions called when the executable file is executed.

7. The method according to any one of claims 1 to 6, characterized in that: The source code is written in the open quantum assembly language OpenQASM.

8. A compiler, characterized in that include: A first conversion module, used to convert source code recording a quantum algorithm into an intermediate expression under a first target compiler framework; The first target compiler framework includes a multi-level intermediate expression compiler framework; the intermediate expression is used to represent the quantum gate operation in the quantum algorithm; The expression processing module is used to perform hierarchical processing on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control the quantum bit to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing The hardware implementation process includes binding the intermediate expression with the quantum bit, and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the quantum bit; A file generation module is used to generate an executable file of a quantum chip based on the electromagnetic wave information, wherein the quantum chip includes a plurality of the quantum bits.

9. A quantum computer, characterized in that: include: A quantum chip, a control system and a compiler as claimed in claim 8; The compiler is connected to the control system, and the control system is used to execute the executable file output by the compiler and output electromagnetic waves to the quantum chip; The quantum chip is used to execute the quantum algorithm recorded in the executable file under the control of the electromagnetic wave.

10. A computing device, characterized in that include: Processor and memory; Wherein, the memory is connected to the processor, and the memory is used to store a computer program; The processor is used to implement the quantum algorithm compilation method according to any one of claims 1 to 7 by running the computer program stored in the memory.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the compilation method of the quantum algorithm according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Software-defined quantum computer

    CN111417965A

  • Quantum control pulse generation method and device, equipment and storage medium

    CN112819169A

  • Compiling method, compiling device, electronic equipment and storage medium

    CN114461221A

  • Quantum algorithm compiling method, compiler, quantum computer and computing equipment

    CN116663671A

  • Systems and methods for unified computing on digital and quantum computers

    US20210286601A1