A hybrid compilation method for quantum acceleration devices
By identifying and compiling the classical and quantum parts of the mixed code through the standardized quantum code programming interface, the problem of complex and inefficient mixed code segmentation in the existing technology is solved, an efficient and reliable hybrid compilation method is realized, the operation is simplified and the efficiency is improved. efficiency.
Patent Information
- Application Number
- CN202210933691.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-04
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-08-04
AI Technical Summary
In the existing technology, after hybrid code segmentation, the quantum algorithm code segment and the classical algorithm code segment need to be completed, resulting in a complex, inefficient and error-prone process, which cannot effectively utilize the performance advantages of quantum accelerated computing.
The standardized quantum code programming interface identifies the classical code and quantum code in the mixed code, and uses pre-run compilation and run-time compilation respectively to realize the sequential running of the mixed code, avoiding code segmentation and completion steps, and simplifying the operation process.
It implements a hybrid compilation method that is simple, efficient, and highly reliable. The system hierarchy is clear, the classical and quantum compilation processes are loosely coupled, parallel development and debugging are supported, and the system has good portability.
Smart Images

Figure CN115271084B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a hybrid compilation method for quantum acceleration devices. Background Art
[0002] Compared with existing high-performance computers, quantum computers have huge advantages in specific computing fields. Governments and industries have invested a lot of time and money in this field, hoping to develop practical quantum computers. In recent years, the rapid development of the field of physical experiments has led people to generally expect to achieve large-scale, full-featured quantum computer hardware within 10 to 20 years. At present, representative quantum computers that have been developed include the 53-bit Sycamore and 72-bit Bristlecone quantum computers launched by Google, the 49-bit quantum computer launched by Intel, the 53-bit quantum computer launched by IBM, the 76-bit Jiuzhang quantum computer launched by USTC, and the 62-bit Zu Chongzhi quantum computer launched by the Chinese Academy of Sciences.
[0003] Quantum hardware systems provide the physical basis for quantum computing. To unleash the supercomputing power of quantum computing, it is obviously not enough to rely solely on quantum hardware. Quantum software must also play a key role. Because of the unique physical properties of quantum systems, such as the non-cloning of quantum information, entanglement between quantum bits, and the non-commutability of observation results, software development technologies widely used on traditional computers cannot be directly applied to quantum computers. Currently widely used software development technologies cannot be directly applied to quantum accelerated computing. The essential differences between the classical world and the quantum world mean that new technologies are needed to program quantum computers.
[0004] In the field of high-performance computing, the performance advantages of quantum accelerated computing can only be fully utilized by combining the classical computing model with the quantum computing model, and combining the architecture for quantum acceleration with the quantum acceleration algorithm. In the prior art, a Chinese invention patent application with application number 202111119588.9 discloses a label identification and segmentation method, device and storage medium for quantum-classical hybrid algorithms. The method includes: receiving the source code of a quantum-classical hybrid algorithm, segmenting the source code to obtain a quantum program and a classical program; running the quantum program and the classical program, and performing quantum computing tasks and classical computing tasks at the same time.
[0005] The above method requires the hybrid code to be split first. Since it needs to execute quantum computing tasks and classical computing tasks simultaneously and separately, the quantum algorithm code segments and classical algorithm code segments need to be completed after the hybrid code is split, and then a complete compilable program can be obtained. The whole process is complicated, inefficient, and prone to errors. Summary of the invention
[0006] The purpose of the present invention is to solve the problems existing in the above-mentioned prior art and to provide a hybrid compilation method for quantum acceleration devices, which is simple and efficient to operate, easy to implement, and highly reliable.
[0007] The objective of the present invention is achieved through the following technical solutions:
[0008] A hybrid compilation method for a quantum acceleration device comprises the following steps:
[0009] Step S1, identifying the classical code and the quantum code in the hybrid code through a standardized quantum code programming interface;
[0010] Step S2, compile the classic code to generate executable code;
[0011] Step S3, run the executable code of the classical code. If the quantum code programming interface is encountered, proceed to step S4, and after receiving the running result of step S5, continue to run and repeat the operation of this step until the entire calculation process is completed;
[0012] Step S4, compile the quantum code to generate executable code;
[0013] Step S5, running the executable code of the quantum code.
[0014] The present invention uses a quantum code programming interface to eliminate the need to split the mixed code. Instead, pre-runtime compilation and runtime compilation are used for the classical code and the quantum code respectively, thereby realizing sequential running of the mixed code, greatly simplifying the operation and improving the overall efficiency.
[0015] As a preferred embodiment of the present invention, before step S1, it also includes: when writing the hybrid code, adding a programming interface for the quantum code segment therein, on the one hand, providing an identifier for identifying the quantum code in the hybrid code, and on the other hand, allowing the quantum compilation process to be debugged separately.
[0016] As a preferred embodiment of the present invention, the step S1 specifically includes:
[0017] Step S1.1, traverse the mixed code;
[0018] Step S1.2, marking the quantum code programming interface;
[0019] Step S1.3, traversing the quantum code contained in the marked programming interface;
[0020] Step S1.4, converting the traversed quantum code into a standardized text format.
[0021] As a preferred embodiment of the present invention, step S2 specifically includes:
[0022] Step S2.1, selecting a corresponding pre-runtime compiler according to the text format of the classic code;
[0023] Step S2.2, using a pre-runtime compiler to compile the standardized text of the classic code to generate executable code.
[0024] As a preferred embodiment of the present invention, step S3 specifically includes:
[0025] Step S3.1, create and start a classical computing process;
[0026] Step S3.2, running the executable code generated in step S2 in the process;
[0027] Step S3.3, if a quantum code programming interface is encountered during operation, proceed to step S4;
[0028] Step S3.4, receiving the running result of step S5, continuing to run and repeating steps S3.2 to S3.4 until the entire calculation process is completed.
[0029] As a preferred embodiment of the present invention, step S4 specifically includes:
[0030] Step S4.1, selecting a corresponding runtime compiler according to the text format of the quantum code;
[0031] Step S4.2, using a runtime compiler to compile the standardized text of the quantum code to generate executable code.
[0032] As a preferred embodiment of the present invention, the step S5 specifically includes:
[0033] Step S5.1, creating and starting a quantum computing process;
[0034] Step S5.2, running the executable code generated in step S4 in the process;
[0035] Step S5.3, run the quantum computing process until completion, and send the running result to the computing process of step S3.
[0036] The advantages of the present invention are:
[0037] 1. The entire operation process is simple and efficient, and highly reliable;
[0038] 2. The system hierarchy is clear, the classical and quantum compilation processes are loosely coupled, and the relationship between the two is relatively independent;
[0039] 3. The system is easy to implement, and the classical and quantum compilation processes can be developed and debugged in parallel;
[0040] 4. The system has good portability. Quantum compilation is organized in the form of a library and can support different classical compilers, that is, different host languages. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a flow chart of a hybrid compilation method for quantum acceleration devices according to the present invention. DETAILED DESCRIPTION
[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0043] like Figure 1 As shown, the present invention provides a hybrid compilation method for quantum acceleration devices. When writing hybrid code, a programming interface is added to the quantum code segment therein. On the one hand, it provides an identifier for identifying the quantum code in the hybrid code, and on the other hand, it enables the quantum compilation process to be debugged separately. Specifically, the method includes the following steps:
[0044] Step S1, identification of classical code and quantum code: mainly through the standardized quantum code programming interface, the classical code and quantum code in the mixed code are identified, specifically including:
[0045] Step S1.1, traverse the mixed code;
[0046] Step S1.2, marking the quantum code programming interface;
[0047] Step S1.3, traversing the quantum code contained in the programming interface marked in step S1.2;
[0048] Step S1.4, converting the traversed quantum code into a standardized text format.
[0049] Step S2, pre-run compilation: mainly compile the classic code before running to generate executable code, specifically including:
[0050] Step S2.1, selecting a corresponding pre-runtime compiler according to the text format of the classic code;
[0051] Step S2.2, using the pre-runtime compiler selected in step S2.1 to compile the standardized text of the classic code to generate executable code of the classic code.
[0052] Step S3, running the classical computing executable code: mainly creates and starts the classical computing process, and runs the executable code generated in step S2.2, specifically including:
[0053] Step S3.1, create and start a classical computing process;
[0054] Step S3.2, running the executable code generated in step S2.2 in the process;
[0055] Step S3.3, if the quantum code programming interface marked in step S1.2 is encountered during the operation, proceed to step S4;
[0056] Step S3.4, receiving the running result of step S5, continuing to run and repeating steps S3.2-S3.4 until the entire calculation process is completed. That is, when the classical code and quantum code in the hybrid code have multiple alternating segments, they need to be run in sequence. The classical code can be directly run as its executable code because it has been compiled before running; while the quantum code needs to be compiled at run time and run after obtaining the executable code.
[0057] Step S4, runtime compilation: mainly compile the quantum code at runtime to generate executable code, specifically including:
[0058] Step S4.1, selecting a corresponding runtime compiler according to the text format of the quantum code obtained in step S1.4;
[0059] Step S4.2, using the runtime compiler selected in step S4.1 to compile the standardized text of the quantum code to generate executable code.
[0060] Step S5, running the executable code of the quantum code: mainly creating and starting the quantum computing process, running the executable code generated in step S4.2, specifically including:
[0061] Step S5.1, creating and starting a quantum computing process;
[0062] Step S5.2, running the executable code generated in step S4 in the process;
[0063] Step S5.3, run the quantum computing process until completion, and send the running result to the computing process of step S3.
[0064] The present invention uses a quantum code programming interface, so that there is no need to split the mixed code, and the classical code and quantum code are respectively compiled before running and compiled during running, so as to realize the sequential running of the mixed code, greatly simplify the operation and improve the overall efficiency. In addition, the system hierarchy is clear, the classical and quantum compilation processes are loosely coupled, and the relationship between the two is relatively independent. The whole system is easy to implement, and the classical and quantum compilation processes can be developed and debugged in parallel. The system has good portability, and the quantum compilation is organized in the form of a library, which can support different classical compilers, that is, different host languages.
[0065] The above is only a preferred specific embodiment of the present invention, which is an implementation method based on the overall concept of the present invention, and the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A hybrid compilation method for quantum acceleration devices, characterized in that: The steps include: Step S1, identifying the classical code and the quantum code in the hybrid code through a standardized quantum code programming interface; Step S2, compile the classic code to generate executable code; Step S3, run the executable code of the classical code. If the quantum code programming interface is encountered, proceed to step S4, and after receiving the running result of step S5, continue to run and repeat the operation of this step until the entire calculation process is completed; Step S4, compile the quantum code to generate executable code; Step S5, running the executable code of the quantum code.
2. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: Before step S1, the method further includes: when writing the hybrid code, adding a programming interface to the quantum code segment therein.
3. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: The step S1 specifically includes: Step S1.1, traverse the mixed code; Step S1.2, marking the quantum code programming interface; Step S1.3, traversing the quantum code contained in the marked programming interface; Step S1.4, converting the traversed quantum code into a standardized text format.
4. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: The step S2 specifically includes: Step S2.1, selecting a corresponding pre-runtime compiler according to the text format of the classic code; Step S2.2, using a pre-runtime compiler to compile the standardized text of the classic code to generate executable code.
5. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: The step S3 specifically includes: Step S3.1, create and start a classical computing process; Step S3.2, running the executable code generated in step S2 in the process; Step S3.3, if a quantum code programming interface is encountered during operation, proceed to step S4; Step S3.4, receiving the running result of step S5, continuing to run and repeating steps S3.2 to S3.4 until the entire calculation process is completed.
6. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: The step S4 specifically includes: Step S4.1, selecting a corresponding runtime compiler according to the text format of the quantum code; Step S4.2, using a runtime compiler to compile the standardized text of the quantum code to generate executable code.
7. A hybrid compilation method for quantum acceleration devices according to claim 1, characterized in that: The step S5 specifically includes: Step S5.1, creating and starting a quantum computing process; Step S5.2, running the executable code generated in step S4 in the process; Step S5.3, run the quantum computing process until completion, and send the running result to the computing process of step S3.
Citation Information
Patent Citations
Label identification segmentation method and device for quantum-classical hybrid algorithm, and storage medium
CN114004361A
System and method of partial compilation with variational algorithms for quantum computers
WO2021050541A1
