Compilation Method of Quantum Algorithm, Compiler, Quantum Computer and Computing Device

Through the multi-level intermediate expression compiler framework, the quantum algorithm source code is converted into intermediate expression and generate electromagnetic wave information, which solves the problem of limited custom optimization in quantum algorithm development and improves development freedom and compilation efficiency.

CN116663671BActive Publication Date: 2025-05-30ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310639499.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-31
Publication Date
2025-05-30
Estimated Expiration
2043-05-31

AI Technical Summary

Technical Problem

Existing quantum algorithm compilation methods do not support developers to add custom optimizations to quantum algorithms, making development difficult.

Method used

The multi-level intermediate expression compiler framework is adopted to convert the source code of the quantum algorithm into intermediate expressions, and generate electromagnetic wave information through layered processing, supporting customized optimization.

Benefits of technology

This enables quantum algorithm developers to freely increase custom optimizations during the compilation process, improving development freedom and compilation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116663671B_ABST
    Figure CN116663671B_ABST
Patent Text Reader

Abstract

The embodiments of this specification provide a compilation method for quantum algorithms, a compiler, a quantum computer, and a computing device. Before generating an executable file, the compilation method for quantum algorithms utilizes the characteristics of a multi-level intermediate representation compiler framework that can freely add various levels of intermediate representation and implement the conversion of different intermediate representations. The source code recording the quantum algorithm is converted into an intermediate representation under the first target compiler framework, and the intermediate representation is processed in a hierarchical manner, enabling the custom optimizations of developers in the quantum algorithm to be compiled in the form of intermediate representation, achieving the purpose of breaking out of the language specification of the quantum algorithm and supporting developers of quantum algorithms to freely add custom optimizations based on requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification relate to the field of computer application technologies. Specifically, they relate to quantum computing technologies in the field of computer application technologies. More specifically, they relate to a compilation method for quantum algorithms, a compiler, a quantum computer, and a computing device. Background Art

[0002] 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.

[0003] In a quantum computer, before a quantum chip executes a quantum algorithm, it is also necessary to use a compiler to convert the quantum algorithm into an executable file for the quantum chip. Conventional compilation methods for quantum algorithms do not support developers in adding custom optimizations to quantum algorithms, resulting in a relatively high development difficulty for quantum algorithms. Summary of the Invention

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

[0005] In a first aspect, an embodiment of this specification provides a compilation method for quantum algorithms, including:

[0006] Converting the source code recording the 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 characterize the quantum gate operations in the quantum algorithm;

[0007] Performing hierarchical processing on the intermediate representation to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operations; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate representation to qubits, and based on the binding relationship between the intermediate representation and the qubits, generating the electromagnetic wave information;

[0008] Generating an executable file for the quantum chip based on the electromagnetic wave information, where the quantum chip includes multiple qubits.

[0009] In a second aspect, an embodiment of this specification provides a compiler, including:

[0010] A first conversion module for converting the source code recording 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 characterize the quantum gate operations in the quantum algorithm;

[0011] An expression processing module for performing hierarchical processing on the intermediate representation to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operations; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate representation to qubits, and generating the electromagnetic wave information based on the binding relationship between the intermediate representation and the qubits;

[0012] A file generation module for generating an executable file of a quantum chip based on the electromagnetic wave information, where the quantum chip includes a plurality of the qubits.

[0013] In a third aspect, an embodiment of this specification provides a quantum computer, including: a quantum chip, a control system, and a compiler as described above;

[0014] The compiler is connected to the control system, and the control system is configured to execute the executable file output by the compiler and output an electromagnetic wave to the quantum chip;

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

[0016] In a fourth aspect, an embodiment of this specification provides a computing device, including: a processor and a memory;

[0017] Wherein, the memory is connected to the processor, and the memory is used to store a computer program;

[0018] The processor is configured to implement the compilation method of the quantum algorithm as described in any one of the above by running the computer program stored in the memory.

[0019] In a fifth aspect, an embodiment of this specification provides a storage medium, on which a computer program is stored, and when the computer program is run by a processor, the compilation method of the quantum algorithm as described above is implemented.

[0020] In a sixth aspect, an embodiment of the present specification provides a computer program product or a computer program, the computer program product or the computer program including computer instructions stored in a computer-readable storage medium; a 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 compilation method of the quantum algorithm are implemented.

[0021] For multiple embodiments provided in the present specification, before generating an executable file, by virtue of the feature that a multi-level intermediate representation compiler framework can freely add various levels of intermediate representations and implement conversions between different intermediate representations, the source code recording a quantum algorithm is converted into an intermediate representation under a first target compiler framework, and the intermediate representation is processed in a layered manner, enabling the custom optimizations of developers in the quantum algorithm to be compiled in the form of intermediate representations, achieving the goal of breaking out of the language specification of the quantum algorithm and supporting developers of the quantum algorithm to freely add custom optimizations based on requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A feasible application scenario of a compilation method of a quantum algorithm provided for an embodiment of the present specification;

[0023] Figure 2 A schematic diagram of the architecture of a quantum computer to which a compilation method of a quantum algorithm provided for an embodiment of the present specification may be applied;

[0024] Figure 3 A schematic flowchart of a compilation method of a quantum algorithm provided for an embodiment of the present specification;

[0025] Figure 4 A schematic flowchart of another compilation method of a quantum algorithm provided for an embodiment of the present specification;

[0026] Figure 5 A schematic flowchart of yet another compilation method of a quantum algorithm provided for an embodiment of the present specification;

[0027] Figure 6 A schematic diagram of the structure of a compiler provided for an embodiment of the present specification;

[0028] Figure 7 A schematic diagram of the structure of a computing device provided for an embodiment of the present specification. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0029] Unless otherwise defined, the technical terms or scientific terms used in the embodiments of this specification shall have the ordinary meanings as understood by those of ordinary skill in the art to which this specification pertains. The "first", "second" and similar terms used in the embodiments of this specification do not denote any order, quantity or importance, but are merely used to avoid confusion of components.

[0030] Unless the context otherwise requires, throughout this specification, "a plurality of" means "at least two", and "comprising" is interpreted in an open, inclusive sense, that is, "including, but not limited to". In the description of this specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples", etc. are intended to indicate that the specific features, structures, materials or characteristics related to the embodiment or example are included in at least one embodiment or example of this specification. The schematic representations of the above terms do not necessarily refer to the same embodiment or example.

[0031] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this specification without creative efforts shall fall within the scope of protection of this specification.

[0032] Overview

[0033] Since a quantum computer can perform calculations by utilizing the coherence of quantum states, the calculation speed of a quantum computer is faster than that of a traditional computer. Specifically, in a traditional computer, information is stored and processed in the form of binary codes, and each binary bit can only store 0 or 1, while in a quantum computer, information is stored and processed in the form of quantum bits (qubits). A qubit can be in a superposition state of multiple states, and this superposition state enables a quantum computer to simultaneously process multiple computing tasks, thereby completing a large number of computing tasks in a short time. In addition, a quantum computer also has characteristics such as quantum parallelism and quantum interference, which enable it to complete calculations faster than a traditional computer in certain specific computing tasks. For example, a quantum computer can solve large-scale factorization problems in polynomial time, while a traditional computer requires exponential time to complete the same task. This huge speed advantage makes quantum computers have broad application prospects in future scientific, engineering and commercial fields.

[0034] Based on the above advantages, quantum computers have become the focus of research and development by various computing manufacturers. Currently, when developing quantum algorithms for quantum computers, developers need to develop algorithms according to the DSL (Domain Specific Language) in the quantum field. Limited by the specifications of the quantum algorithm language, developers cannot add custom optimizations to quantum algorithms, which greatly restricts the development of quantum algorithms.

[0035] To solve this problem, the inventor found through research that the Multi-Level Intermediate Representation (MLIR) uses Intermediate Representation (IR, also known as intermediate representation) to represent source code and target code, and can optimize and compile the custom optimizations of developers in quantum algorithms in the form of intermediate representation during the compilation process, so as to break out of the language specifications of quantum algorithms and support developers of quantum algorithms to freely add custom optimizations based on their needs, thereby improving the development freedom of quantum algorithms.

[0036] Based on the above concept, the embodiments of this specification provide a compilation method for quantum algorithms. The compilation method for quantum algorithms will be described exemplarily below with reference to the accompanying drawings.

[0037] Scenario Example

[0038] Reference Figure 1 , Figure 1 shows a feasible application scenario of the compilation method for quantum algorithms. In this application scenario, developers have developed a quantum algorithm that needs to be executed by a quantum chip, and this quantum algorithm can be written based on the language specifications of quantum algorithms. Since this quantum algorithm is still based on the algorithm logic represented by characters and cannot be directly executed by the quantum chip, this quantum algorithm needs to be input into the compiler, and the compiler compiles the quantum algorithm to obtain an 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 this quantum algorithm. This electromagnetic wave is input into the quantum chip, enabling the quantum chip to implement this quantum algorithm, and finally obtaining the result output by the quantum chip when executing this quantum algorithm. During this process, the compiler can execute the compilation method for the quantum algorithm to compile the quantum algorithm.

[0039] The system architecture to which the compilation method for this quantum algorithm can be applied can be a quantum computer, such as Figure 2As shown, the quantum computer 10 may include a control system 12, a quantum chip 13, and a compiler 11. Among them, the compiler 11 is used to execute the compilation method of the quantum algorithm, convert the quantum algorithm into an executable file for the quantum chip 13, and the control system 12 generates electromagnetic waves according to the executable file and sends the waves to the quantum chip 13. Under the control of the electromagnetic waves, the quantum bits in the quantum chip 13 implement the quantum algorithm. The compiler 11 can be installed on a device with computing and communication capabilities, such as a desktop computer, a tablet computer, a laptop computer, a smart phone, a digital assistant, a smart wearable device, a shopping guide terminal, a television, a smart speaker, a microphone, etc. Among them, the smart wearable device includes but is not limited to a smart bracelet, a smart watch, a smart glasses, a smart helmet, a smart necklace, etc. The control system 12 can be a device with computing capabilities and electromagnetic wave emission capabilities. The quantum chip 13 may include multiple quantum bits, and the quantum bits can implement corresponding quantum algorithms under the control of electromagnetic waves.

[0040] Example Method

[0041] An embodiment of this specification provides a compilation method for a quantum algorithm, as Figure 3 shown, including:

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

[0043] In the multi-level intermediate representation compiler framework, the intermediate representation is an abstract representation between the source code and the machine code (such as binary code) in the executable file. The intermediate representation can support optimization and conversion. In the multi-level intermediate representation compiler framework, the generation of the executable file can be based on the intermediate representation. In this way, the custom optimizations of the developers of the quantum algorithm in the source code can be converted into the intermediate representation in step S301, and the custom optimizations can be compiled in the form of the intermediate representation in the subsequent steps, achieving the purpose of breaking out of the language specification of the quantum algorithm and supporting the developers of the quantum algorithm to freely add custom optimizations based on requirements.

[0044] In an alternative embodiment, the source code is written in the open quantum assembly language OpenQASM. OpenQASM is an open-source quantum assembly language. It is based on a syntax similar to that of classical computer assembly languages, has a low learning curve, and it also provides a large amount of documentation and example code to help users get started quickly. In addition, OpenQASM provides a rich set of quantum gates and measurement operations that can be used to construct various quantum algorithms. Therefore, writing the source code in an open quantum assembly language can reduce the learning cost for developers and support them in developing various types of quantum algorithms.

[0045] S302: Perform hierarchical processing on the intermediate representation to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate representation to the qubits and generating the electromagnetic wave information based on the binding relationship between the intermediate representation and the qubits.

[0046] Regarding the characteristics that a quantum chip requires electromagnetic waves for result reading and qubit operations, in step S302, after obtaining the intermediate representation converted from a quantum algorithm, taking advantage of the characteristic that a multi-level intermediate representation compiler framework can perform hierarchical processing on the intermediate representation, bind the intermediate representation to the qubits, and generate electromagnetic wave information based on the binding relationship between the intermediate representation and the qubits. In this way, the quantum algorithm can be truly implemented at the executable level of the quantum chip, achieving end-to-end compilation of the quantum algorithm.

[0047] S303: Generate an executable file for the quantum chip based on the electromagnetic wave information, where the quantum chip includes a plurality of the qubits.

[0048] The electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operation. Thus, an executable file that can control the execution of the quantum chip can be generated based on this electromagnetic wave information, completing the compilation operation of the quantum algorithm.

[0049] In some embodiments, taking Figure 2 the quantum computer shown 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 perform conversion (lowering) on the electromagnetic wave information to meet the requirements of the control system 12 developed with a non-first target compiler framework. Specifically, the generating an executable file for the quantum chip based on the electromagnetic wave information includes:

[0050] Convert the electromagnetic wave information 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;

[0051] Use the compiler tool of the second target compiler framework to convert the information to be converted into binary information;

[0052] Generate the executable file based on the binary information.

[0053] In this embodiment, the second target compiler framework is a compiler framework different from the first target compiler framework, and specifically may be a compiler framework adapted to the control system of the quantum computer. In this way, the finally generated executable file can be well executed by the control system to generate electromagnetic waves for controlling the quantum chip.

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

[0055] 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 relatively easy to develop under the current hardware scale (dozens of qubits) of quantum chips. However, in the foreseeable future, the hardware scale will rapidly grow from dozens of qubits to hundreds of qubits. By then, traditional control systems will be difficult to handle. Using a multi-core RISCV-SOC and a control system based on the RISC-V to self-developed quantum instruction set can effectively solve the problem of the rapid growth of the hardware scale of quantum chips.

[0056] When the second target compiler framework is the LLVM framework, it can well combine the MLIR toolchain and the LLVM toolchain in the compilation method of quantum algorithms to meet the usage requirements of the control system using a multi-core RISCV-SOC and a control system based on the RISC-V to self-developed quantum instruction set for the executable file.

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

[0058] Among them, the merging of quantum gate operations may include merging consecutively acting quantum gate operations into a single quantum gate to reduce the number of gate operations. The elimination of quantum gate operations may include eliminating adjacent inverse operations on the same qubit, thereby reducing ineffective 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 operations. The rearrangement optimization of quantum gate operations may include rearranging the physical layout of the quantum register to reduce the total number of quantum gate operations.

[0059] In addition, the general processing may further include reduced measurement and error correction of quantum gate operations. The reduced measurement may include reducing the number of qubits 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.

[0060] In this embodiment, through the general processing of the intermediate representation, the optimization of the quantum algorithm can be achieved, aiming to simplify the quantum algorithm and improve the execution efficiency of the quantum algorithm.

[0061] In some embodiments, such as Figure 4 shown, before converting the source code recording the quantum algorithm into the intermediate representation under the first target compiler framework, it further includes:

[0062] S304: Use the parser of the first target compiler framework to preliminarily parse the source code to convert the characters of the source code into characters that conform to the specifications of the first target compiler framework.

[0063] In this embodiment, through the parser of the first target compiler framework, some basic analyses are performed on the human-readable but machine-unreadable characters in the source code, that is, the characters of the source code are converted into characters that conform to the specifications of the first target compiler framework, so as to improve the fault tolerance rate of the compilation method of the quantum algorithm and avoid compilation errors or situations where compilation cannot proceed due to excessive machine-unreadable characters in the source code.

[0064] In some embodiments, after generating the executable file of the quantum chip based on the electromagnetic wave information, it further includes:

[0065] Bind a preset quantum function database to the executable file, and the preset quantum function database is used to store the quantum functions called when the executable file is executed.

[0066] In this embodiment, by storing the quantum functions called when the executable file is executed in the form of a preset quantum function database and binding the preset quantum function database to the executable file, the quantum functions can be called from the preset quantum function database during the execution of the executable file, so as to more conveniently implement the quantum algorithm.

[0067] Reference Figure 5 , Figure 5 shows a feasible execution process of the compilation method of the quantum algorithm in an embodiment of this specification. Specifically, it may include:

[0068] S501: Input the source code in OpenQASM format, and the source code records the quantum algorithm;

[0069] S502: Convert the source code recording the quantum algorithm into an intermediate representation under the multi-level intermediate representation compiler framework;

[0070] S503: Perform a layering process on the intermediate representation to obtain electromagnetic wave information;

[0071] S504: Convert the electromagnetic wave information into information to be converted, and the information to be converted meets the format requirements of the LLVM framework;

[0072] S505: Use the compiler tool of the LLVM framework to convert the information to be converted into binary information;

[0073] S506: Generate the executable file based on the binary information;

[0074] S507: Bind the preset quantum function database to the executable file, and the preset quantum function database is used to store the quantum functions called when the executable file is executed.

[0075] Before generating the executable file, the compilation method of the quantum algorithm utilizes the characteristics of the multi-level intermediate representation compiler framework that can freely add multiple levels of intermediate representations and implement the conversion of different intermediate representations. By converting the source code recording the quantum algorithm into an intermediate representation under the first target compiler framework and performing a layering process on the intermediate representation, the custom optimizations of developers in the quantum algorithm can be compiled in the form of intermediate representations, achieving the purpose of breaking out of the language specification of the quantum algorithm and supporting developers of the quantum algorithm to freely add custom optimizations based on requirements.

[0076] Exemplary Compiler and Quantum Computer

[0077] Based on the same concept, an embodiment of this specification also provides a compiler, as Figure 6 shown, including:

[0078] A first conversion module 601 is configured to convert the source code recording 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 characterize the quantum gate operations in the quantum algorithm.

[0079] An expression processing module 602 is configured to perform hierarchical processing on the intermediate representation to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operations; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate representation to qubits, and generating the electromagnetic wave information based on the binding relationship between the intermediate representation and the qubits.

[0080] A file generation module 603 is configured to generate an executable file for a quantum chip based on the electromagnetic wave information, where the quantum chip includes a plurality of the qubits.

[0081] The compiler provided in this embodiment and the compilation method of the quantum algorithm provided in the foregoing embodiments of the present application belong to the same inventive concept, can execute the compilation method of the quantum algorithm provided in any of the foregoing embodiments of this specification, and has the corresponding functional modules and beneficial effects for executing the compilation method of the quantum algorithm. For the technical details not described in detail in this embodiment, reference may be made to the specific processing content of the compilation method of the quantum algorithm provided in the foregoing embodiments of the present application, which will not be elaborated here.

[0082] Correspondingly, an embodiment of this specification further provides a quantum computer, as Figure 2 shown, including: a quantum chip 13, a control system 12, and a compiler 11 as described in the foregoing embodiment;

[0083] The compiler 11 is connected to the control system 12, and the control system 12 is configured to execute the executable file output by the compiler 11 and output an electromagnetic wave to the quantum chip 13;

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

[0085] Example Computing Device, Storage Medium and Software

[0086] Another embodiment of this specification further proposes a computing device, see Figure 7 shown, an exemplary embodiment of this specification further provides a computing device, including: a memory and a processor, where the memory stores a computer program, and the processor executes the steps in the compilation method of the quantum algorithm according to various embodiments of this specification described in the foregoing embodiments of this specification when executing the computer program.

[0087] The internal structure of the computing device can be as Figure 7 shown. The computing device includes a processor, a memory, a network interface, and an input device connected via a system bus. Among them, 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 computer programs. The internal memory provides an environment for the operation of the operating system and computer programs 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, it performs the steps in the compilation method of the quantum algorithm according to various embodiments of this specification described in the above embodiments of this specification.

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

[0089] The memory stores a computer program for implementing 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, and the program code includes computer operation instructions. More specifically, the memory may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk memory, a flash memory, etc.

[0090] The processor may be a general-purpose processor, such as a general-purpose processor (CPU), a microprocessor, etc., 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 devices, discrete gate or transistor logic devices, discrete hardware components.

[0091] The input device may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor, etc.

[0092] The output device may include a device for allowing information to be output to a user, such as a display screen, a printer, a speaker, etc.

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

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

[0095] The computing device may further include a display component and a voice component. The display component may be a liquid crystal display screen or an electronic ink display screen. 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, etc.

[0096] Those skilled in the art can understand that Figure 7 the structure shown in

[0097] is only a block diagram of some structures 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 those shown in the figure, or combine some components, or have a different component layout.

[0098] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of this specification. The programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as the "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0099] In addition, the embodiments of this specification also provide a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by the processor to perform the steps in the compilation method of the quantum algorithm according to various embodiments of this specification described in the above "exemplary method" section.

[0100] 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 for analysis, stored data, displayed data, etc.) involved in this specification are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or reject.

[0101] It can be understood that the specific examples in this article are only to help those skilled in the art better understand the embodiments of this specification, rather than limiting the scope of this specification.

[0102] It can be understood that in various embodiments of this specification, the magnitudes of the sequence numbers of each process do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this specification.

[0103] It can be understood that the various embodiments described in this specification can be implemented alone or in combination, and the embodiments of this specification do not limit this.

[0104] Unless otherwise specified, all technical and scientific terms used in the embodiments of this specification have the same meaning as commonly understood by those skilled 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 of the 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 the plural forms unless the context clearly indicates otherwise.

[0105] It can be understood that the processor in the embodiments of this specification can be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method embodiments can be completed by the integrated logic circuit in the hardware of the processor or instructions in the form of software. The above-mentioned 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, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this specification. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of this specification can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above method.

[0106] It can be understood that the memory in the embodiments of this specification can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can 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.

[0107] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this specification.

[0108] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0109] 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 only a logical function division, and there may be other division methods in actual implementation. For example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

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

[0111] In addition, in each embodiment of this specification, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.

[0112] 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, in essence, 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 causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of this specification. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0113] The above is only the specific embodiment of this specification, but the protection scope of this specification is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this specification, and all should be covered by the protection scope of this specification. Therefore, the protection scope of this specification should be subject to the protection scope of the claims.

Claims

1. A compilation method for a quantum algorithm, characterized in that, it includes: Converting the source code recording the 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 characterize the quantum gate operations in the quantum algorithm; Performing hierarchical processing on the intermediate representation to obtain electromagnetic wave information; the electromagnetic wave information corresponds to the electromagnetic wave used to control qubits to implement the quantum gate operations; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate representation to qubits, and generating the electromagnetic wave information based on the binding relationship between the intermediate representation and the qubits; Generating an executable file for a quantum chip based on the electromagnetic wave information, the quantum chip includes multiple qubits; Wherein, converting the electromagnetic wave information into information to be converted, and 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 the compiler tool of the second target compiler framework to convert the information to be converted into binary information; generating the executable file based on the binary information; the second target compiler framework includes a low-level virtual machine LLVM framework.

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

3. The method according to claim 1, characterized in that, Before converting the source code recording the quantum algorithm into an intermediate representation under a first target compiler framework, it further includes: Using a parser of the first target compiler framework to preliminarily parse the source code to convert the characters of the source code into characters that conform to the specifications of the first target compiler framework.

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

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

6. A compiler, characterized in that, it includes: A first conversion module for converting the source code recording the 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 characterize the quantum gate operations in the quantum algorithm; An expression processing module for performing hierarchical processing on the intermediate expression to obtain electromagnetic wave information; the electromagnetic wave information corresponds to an electromagnetic wave applied to control qubits to implement the quantum gate operation; the hierarchical processing includes hardware implementation processing; the hardware implementation processing includes binding the intermediate expression to the qubits and generating the electromagnetic wave information based on the binding relationship between the intermediate expression and the qubits; A file generation module for generating an executable file of a quantum chip based on the electromagnetic wave information, the quantum chip including a plurality of the qubits; Wherein, the electromagnetic wave information is converted into information to be converted, and 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; the information to be converted is converted into binary information by using a compiler tool of the second target compiler framework; and the executable file is generated based on the binary information; the second target compiler framework includes a low-level virtual machine LLVM framework.

7. A quantum computer, characterized in that, it includes: a quantum chip, a control system, and a compiler as claimed in claim 6; the compiler is connected to the control system, and the control system is configured to execute the executable file output by the compiler and output an electromagnetic wave to the quantum chip; the quantum chip is configured to execute the quantum algorithm recorded in the executable file under the control of the electromagnetic wave.

8. A computing device, characterized in that, it includes: a processor and a memory; wherein, the memory is connected to the processor, and the memory is configured to store a computer program; the processor is configured to implement the compilation method of the quantum algorithm as claimed in any one of claims 1 to 5 by running the computer program stored in the memory.

9. A computer-readable storage medium, characterized in that, a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the compilation method of the quantum algorithm as claimed in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Compiler and compiling method for extensible instruction set

    CN111078290A

  • Method for realizing secure transmission based on programmable logic array

    CN112256622A