Quantum compiling method, quantum compiling device and electronic equipment
By responding to the compilation instructions of the quantum circuit in the quantum compilation method, determining the compilation workflow and updating variable parameters, the problems of insufficient optimization capabilities and low parameterization compilation efficiency in the existing technology are solved, and more efficient quantum algorithm execution and more flexible compilation strategies are realized.
Patent Information
- Application Number
- CN202411448107.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-03-14
AI Technical Summary
The existing quantum compilation technology has insufficient optimization capabilities and lacks flexibility, especially in variable component quantum algorithms, which limits the execution performance and scale of quantum algorithms on real hardware.
A quantum compilation method is proposed, which determines the compilation workflow and compiles the quantum circuit based on the workflow by responding to the compilation instructions of the quantum circuit. This method supports updating and replacing variable parameters in compiled quantum circuits without recompiling the entire quantum circuit.
This method saves compilation overhead, improves the execution speed of quantum algorithms, enhances the flexibility and efficiency of quantum compilers, and adapts to different quantum algorithms and hardware characteristics.
Smart Images

Figure CN119623660A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of quantum compilation, and in particular, to a quantum compilation method and a quantum compilation device, an electronic device, and a non-transitory computer-readable storage medium. Background Art
[0002] Quantum computing is an emerging technology that uses the principles of quantum mechanics to process information and calculate. Compared with classical computing, quantum computing has an exponential acceleration advantage in certain specific problems and has broad application prospects in cryptography, chemical simulation, optimization problems and other fields.
[0003] Quantum algorithms achieve quantum computing by manipulating quantum bits. In the quantum circuit model, quantum algorithms are described as a combination of a series of quantum logic gates acting on quantum bits, which ultimately form a quantum circuit. Variational quantum algorithms are an important class of quantum-classical hybrid algorithms, the core of which is parameterized quantum circuits. By optimizing the parameters in the circuit, the output of the circuit can be made close to the target state, thereby completing the corresponding quantum computing task.
[0004] Quantum circuit compilation involves a series of steps to convert high-level quantum circuits into hardware-specific representations based on the constraints and characteristics of the target quantum device, including: mapping logical qubits to physical qubits, routing qubits to meet device connectivity constraints, gate decomposition and optimization, and scheduling gates to avoid crosstalk. The compilation process has a significant impact on the efficiency and fidelity of quantum circuit execution, and therefore affects the effectiveness of quantum computing modes.
[0005] The existing quantum circuit compilation technology mainly has the following technical problems and shortcomings:
[0006] Existing quantum compilers have limited optimization capabilities and can only provide fixed compilation strategies. Users cannot customize optimizations based on specific quantum algorithms and hardware characteristics, and lack customization and flexibility.
[0007] For parameterized quantum circuits in variational quantum algorithms, existing compilers need to recompile the entire circuit every time the parameters are updated, which introduces a large compilation overhead and limits the execution speed of variational quantum algorithms.
[0008] In summary, the main problems with existing quantum compilation technology are insufficient optimization capabilities and lack of flexibility, especially the low efficiency of parameterized compilation of specific circuits such as variational algorithms, which limits the execution performance and scale of quantum algorithms on real hardware. Summary of the invention
[0009] The present application aims to propose a quantum compilation method and a quantum compilation device, an electronic device, and a non-transitory computer-readable storage medium to solve the problem that merchants need to spend a lot of energy preparing materials when releasing new products.
[0010] According to one aspect of the present application, a quantum compilation method is proposed, comprising: determining a compilation workflow of the quantum circuit in response to a compilation instruction of the quantum circuit; compiling the quantum circuit according to the compilation workflow to obtain a compiled quantum circuit; and updating and replacing variable parameters in the compiled quantum circuit.
[0011] According to some embodiments, the compilation workflow includes a plurality of functional modules, and determining the compilation workflow of the quantum circuit includes: determining the execution order of the plurality of functional modules in the compilation workflow according to the compilation instruction.
[0012] According to some embodiments, determining the execution order of multiple functional modules in the compilation workflow includes: sequentially combining the multiple functional modules in a pipeline manner to obtain the compilation workflow.
[0013] According to some embodiments, the compilation instruction includes a compilation workflow customization instruction or a preset compilation workflow selection instruction.
[0014] According to some embodiments, before updating and replacing the variable parameters in the compiled quantum circuit, the method further includes: establishing a mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit.
[0015] According to some embodiments, establishing a mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit includes: establishing a mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit by using a dictionary data format and the same identifier.
[0016] According to some embodiments, updating and replacing the variable parameter in the compiled quantum circuit includes: using the identifier to search for the original variable parameter in the quantum circuit; and using the identifier to update the value of the variable parameter in the compiled quantum circuit to the original variable parameter value.
[0017] According to one aspect of the present application, a quantum compilation device is proposed, comprising: a compilation workflow determination unit, for determining a compilation workflow of a quantum circuit in response to a compilation instruction of the quantum circuit; a quantum circuit compilation unit, for compiling the quantum circuit according to the compilation workflow to obtain a compiled quantum circuit; and a variable parameter updating unit, for updating and replacing variable parameters in the compiled quantum circuit.
[0018] According to some embodiments, the compilation workflow includes multiple functional modules, and the multiple functional modules are sequentially combined in a pipeline manner, and the multiple functional modules include a variable parameter update module, and the variable parameter update module is located at the last position of the multiple functional modules.
[0019] According to one aspect of the present application, an electronic device is proposed, comprising one or more processing units; a storage unit for storing one or more programs; when the one or more programs are executed by the one or more processing units, the one or more processing units implement the quantum compilation method as described in any of the previous embodiments.
[0020] According to one aspect of the present application, a non-transitory computer-readable storage medium is provided, on which computer-readable instructions are stored. When the instructions are executed by a processor, the processor executes the quantum compilation method as described in any of the previous embodiments.
[0021] According to the embodiments of the present application, variable parameters in a compiled quantum circuit can be directly updated and replaced without the need to recompile the entire quantum circuit, thereby saving compilation overhead and improving the execution speed of the quantum algorithm.
[0022] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. By describing the exemplary embodiments in detail with reference to the drawings, the above and other objectives, features and advantages of the present application will become more apparent.
[0024] Figure 1 A schematic diagram of a quantum circuit compilation system architecture according to an exemplary embodiment of the present application is shown.
[0025] Figure 2 A flow chart of a quantum compilation method according to an exemplary embodiment of the present application is shown.
[0026] Figure 3 A schematic diagram of a modular compilation framework architecture according to an example embodiment of the present application is shown.
[0027] Figure 4 A schematic diagram of a ParaSubstitution class supporting variable parameter substitution according to an exemplary embodiment of the present application is shown.
[0028] Figure 5 A block diagram of a quantum compilation device according to an exemplary embodiment of the present application is shown.
[0029] Figure 6 An electronic device according to an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0030] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this application will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. In the figures, the same figures show the same or similar parts, and thus their repeated description will be omitted.
[0031] 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 application 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.
[0032] The described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of these specific details, or other modes, components, materials, devices or operations may be adopted. In these cases, known structures, methods, devices, implementations, materials or operations will not be shown or described in detail.
[0033] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0034] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0035] The specific embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0036] Figure 1 A schematic diagram of a quantum circuit compilation system architecture according to an exemplary embodiment of the present application is shown.
[0037] like Figure 1 As shown, the user terminal sends the quantum circuit and compilation parameters to the server according to the user instructions. The compilation parameters include custom instructions or priority parameters of the compilation workflow.
[0038] The server receives the quantum circuit submitted by the user, compiles and optimizes the quantum circuit using the compilation framework of the present application according to the compilation parameters, generates a circuit that can be executed on the target quantum hardware, and sends the compiled quantum circuit to the quantum hardware backend.
[0039] The quantum hardware backend receives the compiled quantum circuit sent from the server and executes it, and sends the execution result to the user end.
[0040] In the embodiment of the present application, the compilation framework adopts a modular design and supports users to customize the compilation process and optimization strategy to adapt to different quantum algorithms and hardware characteristics.
[0041] Figure 2 A flow chart of a quantum compilation method according to an exemplary embodiment of the present application is shown. Figure 2 The quantum compilation method shown includes steps S201, S203 and S205. Figure 2 Taking as an example, a quantum compilation method according to an exemplary embodiment of the present application is described in detail.
[0042] like Figure 2 As shown, in step S201, in response to a compilation instruction of a quantum circuit, a compilation workflow of the quantum circuit is determined.
[0043] According to an embodiment of the present application, the compilation workflow includes multiple functional modules. In step S201, the compilation workflow of the quantum circuit is determined, that is, the execution order of multiple functional modules in the compilation workflow is determined according to the compilation instruction.
[0044] In some embodiments, compiling the instructions includes compiling a workflow customization instruction.
[0045] For example, according to the user's customized instructions, the user is allowed to customize the compilation process, and the execution order of multiple functional modules in the compilation workflow is determined according to the user's definition.
[0046] In some other embodiments, the compilation instruction includes a preset compilation workflow selection instruction.
[0047] For example, the preset compilation workflow selection instruction includes a priority. In the compilation server, before step S201, according to the characteristics of the quantum circuit and the hardware platform, a correspondence between multiple priorities and predefined compilation workflows is preset, so that in step S201, the corresponding predefined compilation workflow can be selected according to the priority in the preset compilation workflow selection instruction.
[0048] According to an embodiment of the present application, multiple functional modules in the compilation workflow are sequentially combined in a pipeline manner to form a complete compilation process to obtain a final compilation workflow. That is, each functional module receives the quantum circuit processed by the previous functional module as input, and passes the processed quantum circuit to the next functional module.
[0049] In step S203, the quantum circuit is compiled according to the compilation workflow to obtain a compiled quantum circuit.
[0050] After the compilation workflow of the quantum circuit is determined in step S201, step S203 may be executed, that is, the quantum circuit is compiled according to the sequential combination of the functional modules included in the compilation workflow to obtain a compiled quantum circuit.
[0051] In step S205, the variable parameters in the compiled quantum circuit are updated and replaced.
[0052] According to an embodiment of the present application, before step S205, it is necessary to first establish a mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit.
[0053] In some embodiments, a mapping relationship between a quantum circuit and a variable parameter in a compiled quantum circuit is established using a dictionary data format and a unique identifier.
[0054] For example, first, the original variable parameter value in the quantum circuit is found using the identifier, and then, the variable parameter value in the compiled quantum circuit is updated to the original variable parameter value using the identifier.
[0055] In a specific embodiment, when establishing a mapping relationship between a quantum circuit and a variable parameter in a compiled quantum circuit, first, for each variable parameter in the quantum circuit, a unique identifier is defined, for example, the variable parameter name is used as the identifier; then, the unique identifier is used as a key, and the variable parameter value in the quantum circuit is used as a value, and all key-value pairs are constructed as dictionary constants; when the variable parameter needs to be updated, the unique identifier can be used to replace all values of the variable parameter in the compiled quantum circuit with the updated parameter value corresponding to the identifier in the key-value pair in the dictionary constant, so that it is no longer necessary to recompile the entire quantum circuit each time the variable parameter is updated, thereby saving compilation overhead and improving the execution speed of the quantum algorithm.
[0056] according to Figure 1 The illustrated embodiment can directly update and replace the variable parameters in the compiled quantum circuit without the need to recompile the entire quantum circuit, thereby saving compilation overhead and improving the execution speed of the quantum algorithm.
[0057] According to other embodiments, the quantum circuit may be compiled according to a user-defined compilation workflow, which is more flexible than the existing compilation method of a fixed compilation workflow.
[0058] Figure 3 A schematic diagram of a modular compilation framework architecture according to an exemplary embodiment of the present application is shown. Figure 3 The compilation framework shown is composed of multiple modules, namely Compiler (or compilation) object module, Model (or parameter) object module, Backend (or immutable parameter) object module, PresetPassflow (or preset workflow) module and Pass (function) object module.
[0059] According to the embodiment of the present application, the Compiler object module is used to implement the core functions of the compilation framework, responsible for managing the compilation process and coordinating the data flow between various modules. The input quantum circuits of the Compiler object module include QuantumCircuit circuits and DAGCircuit circuits.
[0060] The Backend object module is used to store parameters related to the real or simulated hardware of the quantum computer. For example, the number of quantum bits, the coupling diagram between the quantum bits of the chip, the basic gate operations supported, etc. The Model object module is used to store various public basic parameters and quantities required in the compilation process, including parameters related to the Backend object and parameters not related to the Backend object.
[0061] In a specific embodiment, immutable parameters are stored in a Backend object, and mutable parameters are stored in a non-Backend object.
[0062] In some embodiments, non-Backend objects in the Model object can be dynamically updated during the compilation process to reflect changes in the compilation process.
[0063] The Pass object module is a functional module that implements compilation. Each Pass object can complete a specific task in the compilation process. For example, decomposition of quantum gates, mapping of quantum bits, circuit optimization, etc. Pass objects are sequentially combined into a complete compilation process in a pipeline manner. Each Pass object receives the quantum circuit processed by the previous Pass as input and passes the processed quantum circuit to the next Pass. If a Pass needs to use the information of the Model object, the set_model method is designed in the corresponding Pass class. If a Pass object will change the information of the Model object, the get_model method is designed in the corresponding Pass class.
[0064] The PresetPassflow module predefines the default compilation flow in the Compiler object module, and provides different Pass object combination sequences according to different optimization levels selected by the user (defined as optimization_level), so that users can flexibly select or customize the most appropriate compilation strategy according to the specific application scenario and the limitations of the target quantum hardware to make a trade-off between compilation time, circuit performance and resource consumption.
[0065] It is noted here that the Compiler object includes the Model object. Figure 3 The Model object shown in is the Model object in the Compiler object.
[0066] The following is a reference Figure 3 ,right Figure 3 The working process of the modular compilation framework shown is described in detail.
[0067] First, create a Backend object 1 and assign it to Model object 2 in the Model class. In this way, Model object 2 contains the information of Backend object 1.
[0068] Then, use the set_model method to send Model object 2 to the Compiler module and assign it to the Model attribute of the Compiler object. During the entire compilation process, the Model attribute of the Compiler object will be relied upon. Among them, the Model attribute of the Compiler object contains various data and backend information required for compilation.
[0069] Then, choose Compile Workflow.
[0070] For example, the PresetPassflow module selects a preset sequence of Pass object combinations according to priority and assigns it to the compilation workflow in the Compiler, allowing users to choose the most appropriate compilation strategy based on specific application scenarios and hardware limitations to make a trade-off between compilation time, circuit performance, and resource consumption.
[0071] For example, the compilation process consisting of a user-defined list of Pass objects (such as Figure 3 The UserDefine Passflow (shown in Figure 1) is assigned to the workflow workflow in the Compiler object. This approach provides greater flexibility, allowing users to freely combine different Pass objects to adapt to different quantum computing platforms (such as superconducting quantum computing, ion trap quantum computing, etc.), and to design single-process or multi-process compilation passes, as well as compilation passes that adjust and replace parameters to adapt to parameter updates.
[0072] At compile time, the Compiler object module takes the quantum circuit as input data and uses the compile method to traverse each Pass object in the compilation workflow:
[0073] The Compiler object detects whether the Pass has a set_model method that modifies the Model object. If so, the set_model method is used to obtain the Model object information from the model attribute of the Compiler object and pass it to the Pass.
[0074] Then, the run method of the Pass object is called to run the Pass object to transform and optimize the circuit to modify and optimize the quantum circuit.
[0075] The Compiler object detects whether the Pass has a get_model method to obtain the Model object. If so, the get_model method is used to update the model attribute in the Compiler as the changed Model object in the Pass to ensure that subsequent Pass objects use the updated Model object information and ensure the correctness of the compilation process.
[0076] After compilation is completed, the Compiler returns the final optimized quantum circuit.
[0077] according to Figure 3The embodiment shown provides a flexible and efficient way to optimize quantum circuits through this modular and scalable design, so as to adapt to different quantum algorithms and hardware characteristics. And users can customize the compilation process and optimization strategy according to specific needs to make full use of the performance of quantum hardware and improve the execution efficiency and fidelity of quantum algorithms. At the same time, by encapsulating hardware-related information in Backend objects and Model objects, different quantum computing platforms can be flexibly adapted. Therefore, it has strong versatility and portability.
[0078] According to an embodiment of the present application, Figure 3 The compilation framework shown also supports updating of variable parameters after compilation. In a specific embodiment, the Pass object supporting the replacement of variable parameters is designed. When the update and replacement of variable parameters are required, the Pass object is added to Figure 3 In the user-defined compilation workflow (eg, User DefinePassflow) shown in FIG. , the Pass object is located at the last position of the compilation workflow.
[0079] Figure 4 A schematic diagram of a ParaSubstitution class supporting variable parameter replacement according to an exemplary embodiment of the present application is shown, wherein the corresponding ParaSubstitution object is used to replace the variable parameters in the compiled quantum circuit with the original parameters defined in the quantum circuit. Among them, the ParaSubstitution class and the Pass class are both based on the base class BasePass. The base class BasePass is used to store the basic configuration information of the quantum circuit.
[0080] In a specific embodiment, the ParaSubstitution object is mainly used to process variable parameterization operations in quantum circuits, which is achieved by updating global variables in the circuit and parameters in gates.
[0081] According to an embodiment of the present application, the updated parameters include replacement of parameters in the global variable parameter list, replacement of variable parameters included in the quantum gate, and replacement of variable parameters in each expression containing variable parameters.
[0082] In a specific embodiment, a recursive form is used to replace variable parameters in an expression containing variable parameters.
[0083] Refer to the following Figure 4 , the methods of the ParaSubstitution class are explained in detail.
[0084] __init__: It is the initialization method of the ParaSubstitution class, which sets the basic configuration of the base class BasePass and initializes the list para_list used to store parameters.
[0085] set_mode: Sets the Model object model and extracts parameter information from the Model object model. This method assumes that the model has a data dictionary datadict, which contains the key variables, corresponding to the list of variable parameters that need to be used in the circuit.
[0086] run: The main method that performs variable argument substitution.
[0087] In a specific embodiment, the run method receives a quantum circuit as input, first checks whether the circuit type is DAGCircuit, and if so, converts it to QuantumCircuit. Then, a mapping dictionary para_dict is created to map the compiled quantum circuit variable parameter names to the actual original uncompiled original quantum circuit variable parameter objects through the unique identifiers as described above. The global variable parameter variables in the circuit are updated by calling the update_global_variables method, and the parameters in the gate are updated by calling the circuit_update_gates_para method, completing the variable parameter replacement, and finally returning the updated circuit.
[0088] update_global_variables: used to update the global variables in the quantum circuit. This method overwrites the global variables _variables of the quantum circuit with the parameter values in para_dict.
[0089] circuit_update_gates_para: Iterates over all gates in the circuit and calls the update_gate_para method to update the parameters in each gate.
[0090] update_gate_para: Updates the parameters in a single gate. For each parameter in the gate, if the parameter type is Parameter or ParameterExpression (an expression type with variable parameters), it is updated using the update_para_variables method.
[0091] update_para_variables: is a recursive method used to update variable parameter objects. For Parameter type, the original parameter object is directly obtained from para_dict to complete the replacement; for ParameterExpression type, update_para_variables is recursively used to update its pivot and operand.
[0092] As mentioned above, the main function of the ParaSubstitution class is to use a unique identifier to replace the variable parameters in the compiled circuit with the original parameters defined in the Model object model in order to update the parameters. The original parameters defined in the Model object model are extracted from the original quantum circuit before compilation. In this way, the value of the original parameter object is updated to achieve the complete update of the variable parameter values involved in all quantum gates in the compiled circuit.
[0093] In the compilation process, a new quantum circuit object is used to store the compiled circuit information. The variable parameter object in the new circuit is not the same object as the parameter object in the original circuit. Therefore, directly updating the original parameter list without using the ParaSubstitution class to compile the pipeline will not affect the parameter object in the compiled circuit. Therefore, this problem needs to be dealt with. The following is a detailed description of the update process of variable parameters using the ParaSubstitution class.
[0094] In order to establish the parameter mapping relationship between the compiled quantum circuit and the original quantum circuit:
[0095] First, for each variable parameter in the original quantum circuit, define a unique identifier. For example, use the variable parameter name as the identifier
[0096] Then, create a dictionary para_dict with the unique identifiers of the variable parameters as keys and the corresponding original parameter objects as values.
[0097] Then, in the compiled quantum circuit, the corresponding original parameter object in para_dict is found by the unique identifier of the variable parameter.
[0098] Finally, the parameter objects in the compiled circuit are replaced with the corresponding original parameter objects in para_dict.
[0099] After establishing the mapping relationship between the compiled circuit and the parameter objects in the original circuit in this way, when the parameters are subsequently updated, only the parameter objects of the original circuit need to be updated, and the parameter objects in the compiled circuit will be automatically updated, thus avoiding the overhead of repeated compilation.
[0100] For example, for a variable parameter list in the original quantum circuit, suppose
[0101]
[0102] Using the ParaSubstitution class will generate a dictionary para_dict, which contains two key-value pairs. One of the keys is "Theta[0]", and its value is Theta[0](0.1) object 0; the other key is "Theta[1]", and its value is Theta[1](0.2) object 1. This dictionary para_dict is {"Theta[0]":Theta[0](0.1) object 0, "Theta[1]":Theta[1](0.2) object 1}.
[0103] In the compiled quantum circuit, gates with variable parameters will have new parameter objects that are different from the parameter objects in the original circuit, for example, Theta[0](0.1) object 0', Theta[1](0.2) object 1'.
[0104] ParaSubstitution uses the unique parameter identifiers "Theta[0]" and "Theta[1]" to find the corresponding original parameter objects in para_dict and replace the new parameter objects in the compiled circuit with the original parameter objects. Replace the variable parameters Theta[0](0.1) object 0' and Theta[1](0.2) object 1' in all quantum gates with Theta[0](0.1) object 0 and Theta[1](0.2) object 1 in the original quantum circuit.
[0105] Since the storage location of the variable parameters in the original quantum circuit remains unchanged, once the value of the variable parameter list of the compiled quantum circuit is updated, the variable parameters of all quantum gates will be updated accordingly. For example, the updated value is:
[0106]
[0107] Then the value of Theta[0] in all gates becomes 0.2, the value of Theta[1] becomes 0.3, and the value of the expression Theta[0]+Theta[1] containing variable parameters will also become 0.2+0.3=0.5.
[0108] Through this parameter replacement mechanism, ParaSubstitution realizes the parameter update function after compilation. Users only need to compile once to update the parameters repeatedly, making it possible to quickly update the parameters in the variational quantum algorithm, and can be used for various optimization algorithms, such as gradient descent, without having to recompile the entire circuit every time, thus avoiding repeated time-consuming compilation processes, greatly reducing compilation overhead, speeding up the execution of the algorithm, and improving the execution efficiency and performance of quantum circuits.
[0109] In this embodiment, the adaptability and portability of this embodiment are enhanced through the Backend object module and the Model object module, and different quantum computing platforms and hardware can be easily adapted, thereby enhancing the adaptability and portability of the compilation framework. The modular design and clear interface definition allow the Pass function module to be easily integrated, thus improving the scalability of the framework. And by providing a unified interface and workflow, users only need to focus on the design and implementation of quantum algorithms without manually optimizing quantum circuits. The server-side deployment of the compilation framework allows users to easily submit quantum circuits and compilation parameters through client software or API interfaces, obtain optimized quantum circuits and execution results, and simplify the development and deployment process of quantum algorithms.
[0110] In this embodiment, by providing a user-defined compilation process and an efficient parameter update mechanism, the flexibility and efficiency of the quantum compiler are significantly improved, and the problems of limited compiler optimization capability and low parameter update efficiency in the prior art are solved. This not only improves the performance of quantum circuits, but also lays the foundation for the practical application of quantum algorithms and the industrial development of quantum computing.
[0111] The above mainly introduces the embodiments of the present application from the perspective of the method. Those skilled in the art should easily appreciate that, in combination with the operations or steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Those skilled in the art can use different ways to implement the described functions for each specific operation or method, and such implementation should not be considered to be beyond the scope of the present application.
[0112] The following describes the device embodiments of the present application. For details not described in the device embodiments of the present application, reference can be made to the method embodiments of the present application.
[0113] Figure 5 A block diagram of a quantum compilation device according to an exemplary embodiment of the present application is shown. Figure 5The quantum compilation device shown includes a compilation workflow determination unit 501, a quantum circuit compilation unit 503, and a variable parameter updating unit 505. The compilation workflow determination unit 501 is used to determine the compilation workflow of the quantum circuit in response to the compilation instruction of the quantum circuit; the quantum circuit compilation unit 503 is used to compile the quantum circuit according to the compilation workflow to obtain a compiled quantum circuit; and the variable parameter updating unit 505 is used to update and replace the variable parameters in the compiled quantum circuit.
[0114] According to some embodiments, the compilation workflow includes multiple functional modules, and the multiple functional modules are sequentially combined in a pipeline manner, and the multiple functional modules include a variable parameter update module, and the variable parameter update module is located at the last position of the multiple functional modules.
[0115] Figure 6 An electronic device according to an exemplary embodiment of the present application is shown. Figure 6 The electronic device 200 according to this embodiment of the present application is described. Figure 6 The electronic device 200 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0116] like Figure 6 As shown, the electronic device 200 is in the form of a general computing device. The components of the electronic device 200 may include, but are not limited to: at least one processing unit 210, at least one storage unit 220, a bus 230 connecting different system components (including the storage unit 220 and the processing unit 210), a display unit 240, etc.
[0117] The storage unit stores program codes, which can be executed by the processing unit 210, so that the processing unit 210 executes the methods described in this specification according to various exemplary embodiments of the present application. For example, the processing unit 210 can execute the methods shown in any of the previous embodiments.
[0118] The storage unit 220 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 2201 and / or a cache memory unit 2202 , and may further include a read-only memory unit (ROM) 2203 .
[0119] The storage unit 220 may also include a program / utility 2204 having a set (at least one) of program modules 2205, such program modules 2205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0120] Bus 230 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0121] The electronic device 200 may also communicate with one or more external devices 300 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 200, and / or communicate with any device that enables the electronic device 200 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 250. Furthermore, the electronic device 200 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 260. The network adapter 260 may communicate with other modules of the electronic device 200 via the bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0122] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. The technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the implementation method of the present application.
[0123] The software product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0124] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0125] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, Python, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0126] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the computer-readable medium implements the aforementioned functions.
[0127] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.
[0128] According to an embodiment of the present application, a computer program is provided, including a computer program or an instruction. When the computer program or the instruction is executed by a processor, the method described above can be executed.
[0129] The embodiments of the present application are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. At the same time, changes or deformations made by those skilled in the art based on the ideas of the present application, the specific implementation methods and the scope of application of the present application, all belong to the scope of protection of the present application. In summary, the content of this specification should not be construed as a limitation on the present application.
Claims
1. A quantum compilation method, characterized in that: include: In response to a compilation instruction of a quantum circuit, determining a compilation workflow of the quantum circuit; Compile the quantum circuit according to the compilation workflow to obtain a compiled quantum circuit; The variable parameters in the compiled quantum circuit are updated and replaced.
2. The quantum compilation method according to claim 1, characterized in that: The compilation workflow includes a plurality of functional modules, and determining the compilation workflow of the quantum circuit includes: According to the compilation instruction, the execution order of multiple functional modules in the compilation workflow is determined.
3. The quantum compilation method according to claim 2, characterized in that: Determining the execution order of multiple functional modules in the compilation workflow includes: The multiple functional modules are sequentially combined in a pipeline manner to obtain the compilation workflow.
4. The quantum compilation method according to claim 1, characterized in that: The compilation instructions include compilation workflow custom instructions or preset compilation workflow selection instructions.
5. The quantum compilation method according to claim 1, characterized in that: Before updating and replacing the variable parameters in the compiled quantum circuit, the method further includes: A mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit is established.
6. The quantum compilation method according to claim 5, characterized in that: Establishing a mapping relationship between the quantum circuit and the variable parameters in the compiled quantum circuit includes: A mapping relationship between the variable parameters in the quantum circuit and the compiled quantum circuit is established by using a dictionary data format and the same identifier.
7. The quantum compilation method according to claim 6, characterized in that: Updating and replacing variable parameters in the compiled quantum circuit includes: Using the identifier to search for an original variable parameter in the quantum circuit; Using the identifier, the value of the variable parameter in the compiled quantum circuit is updated to the original variable parameter value.
8. A quantum compilation device, characterized in that: include: A compilation workflow determination unit, configured to determine a compilation workflow of the quantum circuit in response to a compilation instruction of the quantum circuit; A quantum circuit compiling unit, used to compile the quantum circuit according to the compiling workflow to obtain a compiled quantum circuit; A variable parameter updating unit is used to update and replace the variable parameters in the compiled quantum circuit.
9. The quantum compilation device according to claim 8, characterized in that: The compilation workflow includes multiple functional modules, and the multiple functional modules are sequentially combined in a pipeline manner. The multiple functional modules include a variable parameter update module, and the variable parameter update module is located at the last position of the multiple functional modules.
10. An electronic device comprising: processor; as well as A memory storing a computer program, which, when executed by the processor, enables the processor to perform the quantum compilation method according to any one of claims 1 to 7.
11. A non-transitory computer-readable storage medium having computer-readable instructions stored thereon, which, when executed by a processor, causes the processor to execute the quantum compilation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Quantum computing program compiling method and device
CN117910588A
System and method of partial compilation with variational algorithms for quantum computers
US20220374390A1