Quantum programming system, electronic device and storage medium

Through the interface module, quantum gate library module, quantum operation library and quantum circuit module of the quantum programming system, the limitations of the quantum programming framework in the existing technology in terms of programming efficiency and scalability are solved, and the control of different quantum computers and hardware resources is realized. The adaptation improves the efficiency and scalability of quantum programming.

CN118378713BActive Publication Date: 2024-10-11GUOKAIKE QUANTUM TECH (ANHUI) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410814670.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-11
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

Existing quantum programming frameworks have limitations in programming efficiency, scalability, and hardware resource interfaces, and cannot effectively support complex quantum computing tasks.

Method used

Provide a quantum programming system, including interface module, quantum gate library module, quantum operation library module, quantum circuit module and program compilation module. Through these modules, the definition and analysis of general and specific quantum gates and operations are realized, and executable quantum Program instructions and support adaptation to different types of quantum computers and hardware resources.

Benefits of technology

It simplifies quantum programming tasks and improves quantum programming efficiency. The generated quantum program is highly scalable and suitable for different types of quantum computers and hardware resources, improving programming flexibility and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378713B_ABST
    Figure CN118378713B_ABST
Patent Text Reader

Abstract

The present invention discloses a quantum programming system, an electronic device and a storage medium, which belong to the field of quantum computing. The quantum programming system includes an interface module, a quantum gate library module, a quantum operation library module, a quantum circuit module, a program compilation module and a back-end communication module, wherein the quantum gate library module is used to provide general quantum gates, specific quantum gates and customized quantum gates; the quantum operation library module is used to provide general quantum operations and specific quantum operations; the quantum circuit module is used to parse the input programming code to obtain quantum circuits and corresponding quantum program instruction sets; the program compilation module is used to compile the quantum program instruction set into an executable program instruction set run by the back-end device; the back-end communication module is used to send the specified executable program instruction set to the corresponding back-end device and receive the operation data of the back-end device. The use of the embodiments of the present invention can effectively simplify quantum programming tasks and improve quantum programming efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of quantum computing, and in particular to a quantum programming system, an electronic device and a storage medium. Background Art

[0002] Generally, a programming framework refers to a software development system that provides common functions and structures. Developers can build and deploy applications faster through programming frameworks. Programming frameworks usually include libraries, APIs, tools, and runtime environments, which can help developers build applications without writing code from scratch. Common front-end frameworks include Vue and Node, and common back-end frameworks include Mybatis, Spring, SpringBoot, etc. Whether it is a front-end framework or a back-end framework, their common characteristics are simplicity and efficiency, which improves the development efficiency of software engineers.

[0003] With the development of quantum computers, quantum programs have emerged in the field of quantum computing. In order to efficiently provide quantum programs running on quantum computers, quantum simulation computing systems or quantum simulators, a programming framework is also needed. However, due to the difference between quantum computing and traditional computing, the programming framework for providing quantum programs is different from the traditional front-end framework or back-end framework.

[0004] Existing quantum programming frameworks include Qiskit created and developed by IBM Research, Cirq released by the Google QuantumAI team, and Quipper jointly developed by Dalhousie University in Canada and the Institute for Advanced Study in Princeton, USA. The aforementioned quantum programming frameworks provide some tools and libraries for quantum programming. However, these quantum programming frameworks have certain limitations in different aspects, which limit programming efficiency, such as limited quantum gates and quantum operations, fixed and complex programming interfaces, lack of scalability, and single interfaces for connecting to hardware resources. Summary of the invention

[0005] In view of this, embodiments of the present invention provide a quantum programming system, an electronic device, and a storage medium for improving the efficiency of quantum programming.

[0006] According to one aspect of the present invention, the present invention provides a quantum programming system, comprising:

[0007] an interface module configured to provide a programming code input interface and a display interface;

[0008] A quantum gate library module, configured to provide general quantum gates, specific quantum gates, and custom quantum gates;

[0009] A quantum operation library module configured to provide general quantum operations and specific quantum operations;

[0010] A quantum circuit module; configured to parse an input programming code to obtain a quantum circuit and a corresponding set of quantum program instructions;

[0011] A program compiling module configured to compile a quantum program instruction set into an executable program instruction set to be run by a backend device;

[0012] a backend communication module configured to send a specified set of executable program instructions to a corresponding backend device and receive operation data of the backend device;

[0013] The quantum gate library module includes a quantum gate definition unit, and the quantum gate definition unit includes:

[0014] structural subunits configured to provide one or more gate structures constituting a quantum gate;

[0015] a parameter subunit configured to provide one or more gate parameters and / or gate operations for each gate structure;

[0016] A parsing subunit, configured to parse the quantum gate programming code to obtain corresponding quantum gate data and qubit data when the quantum gate programming code to be parsed is obtained when parsing the quantum programming code;

[0017] A binding subunit is configured to create a quantum operation, wherein the data structure corresponding to the quantum operation includes a quantum bit parameter and a command data structure, the quantum gate data obtained by parsing is stored in the command data structure, and the quantum bit data obtained by parsing is stored in the quantum bit parameter; when the quantum operation is applied to a quantum circuit, the calculation of the quantum gate is implemented based on the quantum gate data and the quantum bit data stored in the data structure corresponding to the quantum operation.

[0018] Optionally, in the aforementioned quantum programming system, the quantum gate library module further includes:

[0019] a universal quantum gate unit configured to provide a variety of universal quantum gates;

[0020] A specific quantum gate unit is configured to provide a plurality of specific quantum gates, wherein the specific quantum gates include one or more of the following quantum gates:

[0021] All gates that perform the same quantum operation on all qubits of a given quantum circuit;

[0022] The Reset gate resets the quantum state of the specified quantum bit to the initial state;

[0023] Barrier gate used to segment quantum circuits.

[0024] Optionally, the quantum gate data obtained by the parsing subunit parsing the quantum gate programming code includes one or more of a gate structure, a gate parameter value, and a gate operation, the quantum bit data obtained by the parsing subunit parsing the quantum gate programming code includes at least a target bit, and the gate structure includes a matrix structure and / or a universal quantum gate structure.

[0025] Optionally, in the aforementioned quantum programming system, when the parsing subunit parses a definition instruction of a composite quantum gate when parsing the quantum programming code, the binding subunit creates a composite gate function, wherein the composite gate function includes a plurality of quantum gate data structures; when the parsing subunit identifies a separation identifier in the programming code, the programming code corresponding to each separation identifier is stored in the corresponding quantum gate data structure;

[0026] Correspondingly, the parsing subunit parses the programming code in each quantum gate data structure to obtain corresponding quantum gate data and quantum bit data;

[0027] Correspondingly, the binding subunit creates a respective quantum operation for each quantum gate data structure, and saves the quantum gate data and qubit data obtained by parsing the programming code in each quantum gate data structure into the corresponding parameters of the corresponding data structure of the corresponding quantum operation;

[0028] When the composite quantum gate is applied to a quantum circuit, the quantum operations in each quantum gate data structure are provided to the quantum circuit one by one, and the calculation of the corresponding quantum gate is implemented based on the quantum gate data and quantum bit data stored in the data structure corresponding to the quantum operation.

[0029] Optionally, in the aforementioned quantum programming system, the quantum operation library module includes:

[0030] a universal operation unit configured to provide universal quantum operations;

[0031] A specific operation unit configured to provide a specific quantum operation;

[0032] The specific quantum operation includes one or more of an amplitude amplification operation, a uniform superposition quantum state preparation operation, a classical quantum state preparation operation, an initial quantum state preparation operation, and a displacement operation on a current quantum state.

[0033] Optionally, in the aforementioned quantum programming system, the quantum circuit module includes:

[0034] a programming code parsing unit configured to parse the programming code to identify instructions, quantum gates and / or quantum operations, and obtain corresponding parameter values;

[0035] a quantum gate parsing unit configured to, in response to the identified quantum gate and the corresponding instruction, parse the quantum gate to obtain the corresponding quantum instruction, and pass the parsed quantum gate parameter value to the quantum instruction;

[0036] a quantum operation parsing unit configured to, in response to the identified quantum operation and the corresponding instruction, parse the quantum operation to obtain the corresponding quantum instruction, and pass the parameter value corresponding to the quantum operation to the quantum instruction;

[0037] a quantum program generation unit configured to integrate the obtained quantum instruction sequence into a quantum program instruction set based on the parsing order of the programming code;

[0038] The quantum circuit drawing unit is configured to render the quantum gates and quantum operations in the specified quantum circuit obtained by parsing into a graphical representation according to the logical relationship and time sequence based on the drawing instruction of the specified quantum circuit.

[0039] Optionally, in the aforementioned quantum programming system, when the programming code parsing unit parses the programming code to obtain a quantum bit creation instruction, it creates corresponding registers based on the quantum bit structure in the quantum bit creation instruction to store quantum bits; wherein the quantum bit structure is a dispersed structure or a concentrated structure; when the quantum bit structure in the quantum bit creation instruction is a dispersed structure, a corresponding number of registers are created based on the number of dispersed parameters in the dispersed structure to respectively store the quantum bits specified by each dispersed parameter; when the quantum bit structure in the quantum bit creation instruction is a concentrated structure, a register is created based on the concentrated parameters in the concentrated structure to store the quantum bits specified by the concentrated parameters.

[0040] Optionally, in the aforementioned quantum programming system, the quantum circuit module further includes one or more of the following units:

[0041] A parameterization unit configured to provide operating parameters that allow developers to dynamically set parameter values; when the operating parameters and parameter values ​​are identified during the parsing of the programming code, the parameterization unit assigns the current parameter values ​​to the operating parameters in the specified quantum circuit;

[0042] A quantum circuit combining unit is configured to provide quantum circuit combining parameters; correspondingly, when the quantum circuit combining parameters and parameter values ​​are identified during the parsing of the programming code, a quantum circuit to be combined, a target quantum circuit and a combining position are identified from the quantum circuit combining parameters; the quantum circuit to be combined is inserted into the combining position of the target quantum circuit, and the quantum program instruction set of the quantum circuit to be combined is inserted into the combining position in the target quantum program instruction set;

[0043] A quantum circuit conversion unit is configured to convert the programming code of the target quantum circuit described in the original language into the programming code described in the target language when a conversion instruction and the original language and the target language of the quantum circuit are identified during the process of parsing the programming code;

[0044] The operation data statistics unit is configured to obtain corresponding statistical data from the operation data based on the operation data returned by the back-end device according to preset statistical item parameters and statistical algorithms.

[0045] According to another aspect of the present invention, the present invention further provides an electronic device, comprising a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the aforementioned quantum programming system is implemented.

[0046] According to another aspect of the present invention, the present invention further provides a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the aforementioned quantum programming system is implemented.

[0047] The embodiments of the present invention can effectively simplify quantum programming tasks, improve quantum programming efficiency, and generate quantum programs with strong scalability and can be applied to different types of quantum computers and hardware resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings in the embodiment of the present invention are briefly introduced below.

[0049] Figure 1 is a principle block diagram of a quantum programming system according to an embodiment of the present invention;

[0050] Figure 2 is a principle block diagram of a quantum gate library module according to an embodiment of the present invention;

[0051] Figure 3 is a flow chart of a method for a quantum programming system according to one embodiment of the present invention;

[0052] Figure 4 is a principle block diagram of a quantum operation library module according to an embodiment of the present invention;

[0053] Figure 5 is a principle block diagram of a quantum circuit module according to an embodiment of the present invention;

[0054] Figure 6 is a principle block diagram of a quantum circuit module according to another embodiment of the present invention;

[0055] Figure 7 is a schematic diagram of a quantum circuit corresponding to a Fourier transform operation according to an embodiment of the present invention;

[0056] Figure 8 is a principle block diagram of a quantum circuit module according to yet another embodiment of the present invention;

[0057] Fig. 9 It is a structural principle block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirit of the present invention clearer and more thorough, so that those skilled in the art can better understand and implement the principles and spirit of the present invention. The exemplary embodiments provided herein are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments herein, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] In the present invention, terms such as first, second, third, etc. are only used to distinguish one entity (or operation) from another entity (or operation), but are not intended to require or imply any order or relationship between these entities (or operations).

[0060] Figure 1 1 is a block diagram of a quantum programming system according to an embodiment of the present invention. The quantum programming system 1 provided by the embodiment of the present invention includes an interface module 11, a quantum gate library module 12, a quantum operation library module 13, a quantum circuit module 14, a program compilation module 15 and a back-end communication module 16. Among them, the interface module 11 is at least configured with a programming code input interface and a display interface. The quantum gate library module 12 is configured to provide general quantum gates, specific quantum gates and generate quantum gates based on defined instructions. The quantum operation library module 13 is configured to provide general quantum operations and specific quantum operations. The quantum circuit module 14 is configured to parse the input programming code to obtain a quantum circuit and a corresponding quantum program instruction set. The program compilation module 15 is configured to compile the quantum program instruction set into an executable program instruction set for a back-end device. The back-end communication module 16 is configured to send the specified executable program instruction set to the corresponding back-end device and receive the operation data of the back-end device.

[0061] The interface module 11 is used to interact with developers, edit quantum programs, view generated quantum circuits and operation data, etc. When developers use the quantum programming system 1 for quantum programming, they can input programming codes through the programming code input interface. For example, the programming code input interface provides an editing area, and developers can input and edit codes in the editing area. For another example, the programming code input interface also provides a code file read button, and developers can provide a code file address and a read instruction through the code file read button, and the quantum programming system 1 reads the code file at the address and imports the programming code therein into the editing area.

[0062] When the developer gives a drawing instruction for drawing a quantum circuit of a certain quantum program through programming code, the corresponding quantum circuit is displayed graphically in the display interface of the interface module 11. For another example, when the quantum program is executed by the back-end device, the operation data (including the operation results) from the back-end device can be displayed through the display interface.

[0063] Quantum gates are the basic operating units in quantum computing, similar to logic gates in classical computing. They are used to perform various operations, such as changing the relative phase between quantum bits, rotating the state of quantum bits, and achieving quantum entanglement. Figure 2 1 is a block diagram of the quantum gate library module according to an embodiment of the present invention. The quantum gate library module 12 in this embodiment includes a universal quantum gate unit 121, a specific quantum gate unit 122 and a quantum gate definition unit 123, wherein the universal quantum gate unit 121 is used to provide a variety of universal quantum gates, such as the universal quantum gate unit 121 can realize CR, H, I, ISwap, Measure, CNOT, Toffoli, P, R, Rx, Ry, Rz, S, Sdg, T, Tdg, X, Y, Z, X1, Y1, Z1, NOT, Swap, SqrtSwap, SqrtX, Rxx, Ryy, Rzz, U1, U2, U3, etc. The quantum gates implemented above are some universal quantum gates that have been standardized and defined.

[0064] In addition to being able to implement some standardized quantum gates in quantum computing, the quantum gate library module 12 in this embodiment also implements some specific quantum gates based on the needs of quantum programming. The specific quantum gate unit 122 provides an All gate, a Reset gate, and a Barrier gate. The All gate is used to perform the same quantum operation for all quantum bits of a circuit, thereby improving the execution efficiency of the quantum circuit. For example, when the programming code written by the developer using the All gate is as shown in Table 1, it can be implemented to execute a measurement gate for all quantum bits in the quantum register.

[0065] Table 1

[0066] Programming Code Serial number All(Measure)*qureg 1-1

[0067] The Reset gate can be used to easily reset the quantum state of a specified quantum bit to its initial state. For example, when a developer uses the programming code written by the Reset gate, such as the programming code of sequence number 1-2 in Table 2, the amplitude of the first quantum bit in the quantum register can be reset. When the programming code is the programming code of sequence number 1-3 in Table 2, the amplitude of all quantum bits in the quantum register can be reset.

[0068] Table 2

[0069] Programming Code Serial number Reset*qureg[0] 1-2 Reset*qureg 1-3

[0070] Barrier gates can be used to segment quantum programming codes and quantum circuits. By inserting barrier gates at appropriate locations, quantum circuits can be divided into different parts, making the structure of quantum circuits clearer and more readable, and helping to improve the readability and organization of programming codes.

[0071] In one embodiment, the interface module 11 provides an entry to a quantum gate tool library, through which developers can select the general quantum gates provided therein and the specific quantum gates provided by the present invention.

[0072] Universal quantum gates such as H, NOT, CR, etc. are standardized quantum calculations with fixed definitions. For example, when the H gate is applied, the matrix of the H gate (1.0 / cmath.sqrt(2.0)*np.array([[1,1],[1,-1]])) is actually applied to the quantum vector. Although this calculation method is fixed in the form of the H gate, which simplifies the programming logic, it also limits certain calculations. For example, the matrix applied in the calculation of the aforementioned H gate is (1.0 / cmath.sqrt(2.0)*np.array([[1,1],[1,-1]])), which is fixed and cannot be changed, and the matrix required by the developer cannot be applied to the quantum bit. Therefore, in order to facilitate developers to flexibly implement various calculations, the embodiment of the present invention provides a quantum gate definition unit 123, which can generate a quantum gate based on the definition instruction input by the interface. When the developer needs to define a quantum gate, the definition instruction and the corresponding programming code can be input through the input interface, and the structure, parameters, etc. of the quantum gate can be specified through the programming code. The quantum gate definition unit 123 generates corresponding quantum gates based on the definition instructions and corresponding programming codes for use by developers.

[0073] In one embodiment, the quantum gate definition unit 123 includes a structure subunit 1231, a parameter subunit 1232, a parsing subunit 1233 and a binding subunit 1234, wherein the structure subunit 1231 provides one or more gate structures constituting a quantum gate, wherein the gate structure includes the aforementioned general quantum gate structure, a specific quantum gate structure and a matrix structure, wherein the general quantum gate structure and the specific quantum gate structure are gate structures of a class of standard computing units and correspond to corresponding matrix data. The matrix structure is, for example, any square matrix that can act on a quantum bit. The matrix structure is provided to developers, for example, in the form of a structure of "Matrix([[a,b],[c,d]])". When programming, developers can fill in the positions of letters a, b, c, and d as needed, such as "Matrix([[1,0],[1,0]])". The parameter subunit 1232 provides one or more gate parameters and / or gate operations for the gate structure. Each gate structure has corresponding necessary parameters. Gate parameters are, for example, parameters used to define the name / identification of the quantum gate. For a matrix structure, gate parameters include, for example, matrix parameters, such as matrix order parameters and matrix element parameters, etc. The matrix elements and the matrix order are numerical values ​​or variables or functional relationships. Gate operations are, for example, some functional functions that implement quantum operations, such as the ctrl function that implements the control bit setting operation, the inv function that implements the matrix transposition operation, etc. When programming, developers select the parameters to be used as needed and assign values ​​to them.

[0074] For example, a developer defines a quantum gate according to the matrix structure provided by the structure subunit 1231 and the parameters provided by the parameter subunit 1232, such as the programming codes of sequence numbers 1-4 in Table 3.

[0075] Table 3

[0076] Programming Code Serial number Matrix([[1,0],[1,0]],'a').ctrl(3)*(qc[0],qc[1],qc[2],qc[3]) 1-4

[0077] Among them, Matrix() represents a matrix structure; [[1,0], [1,0]] is the specific matrix data; 'a' represents the identifier (or name) of the quantum gate; ctrl(3) represents the control bit setting operation, and the parameter value is 3, which means setting 3 control bits, and (qc[0], qc[1], qc[2], qc[3]) represents four quantum bits.

[0078] When parsing the aforementioned programming code, the parsing subunit 1233 parses the developer's programming code to obtain quantum gate data and qubit data, such as the specific matrix "[[1,0],[1,0]]", the quantum gate identifier 'a' and the control bit setting operation "ctrl(3)", and the qubit data such as "(qc[0],qc[1],qc[2],qc[3])". In one embodiment, the parsing subunit 1233 calls the _init_ method of Matrix to save the above parsed data. In a further embodiment, the parsing subunit 1233 also performs various checks during the data parsing process, such as checking whether the qubit data structure of the qubit is legal; calculating the number of control bits and target bits, and specifying the control bits and target bits from the identified qubits; checking whether the setting of the control bits is reasonable; checking whether the matrix order in the matrix parameters matches the number of target bits; checking whether there is a matrix transposition operation in the gate operation and whether the matrix elements in the matrix parameters constitute a unitary matrix when there is a matrix transposition operation, etc. When any of the above checks fails, a prompt message is generated and displayed to the developer through the interface. When all the checks pass, it is determined that the checks are passed, and the data is saved at this time.

[0079] The binding subunit 1234 creates a quantum operation, such as a command operation, and the data structure corresponding to the quantum operation includes multiple parameters. The parsed quantum gate data and quantum bit data are saved in the corresponding parameters in the quantum operation data structure, so that when the quantum operation is submitted to the quantum circuit, the calculation of the quantum gate is realized when the quantum operation is executed.

[0080] In conventional quantum programming methods, only one quantum gate can be used to act on a quantum bit at a time. The present invention provides a composite quantum gate that can be defined by developers, which can merge multiple quantum gates together, thereby simplifying the development work of developers. The composite quantum gate can realize specific functions and can be applied to any quantum circuit.

[0081] From another aspect, the present invention also provides a method for a quantum programming system, for implementing a quantum gate. Figure 3 As shown, Figure 3 is a flow chart of a method for a quantum programming system according to an embodiment of the present invention, comprising the following steps:

[0082] Step S1, parse the quantum gate programming code, and parse and obtain quantum gate data and qubit data therefrom. The quantum gate data includes one or more of the gate structure, gate parameter value and gate operation, and the qubit data includes at least the target bit. For example, when parsing the quantum programming code in Table 3, the quantum gate data obtained is such as the specific matrix "[[1,0],[1,0]]", the quantum gate identifier 'a' and the control bit setting operation "ctrl(3)", and the qubit data is such as "(qc[0],qc[1],qc[2],qc[3])".

[0083] Step S2: creating a quantum operation, wherein the data structure corresponding to the quantum operation includes multiple parameters.

[0084] Step S3, saving the parsed quantum gate data and quantum bit data into corresponding parameters of the data structure corresponding to the quantum operation.

[0085] In one specific embodiment, before step S2, that is, before creating the quantum operation, the method further includes the following verification steps, such as:

[0086] (1) Check whether the qubit data structure in the qubit data is legal based on the preset qubit data structure rules. The qubit data structure rules are, for example: the qubit after the symbol "*" should be a QuBit object, and the QuBit object is represented by "qr[]", where "[]" is a positive integer starting from 0; when there are multiple QuBit objects, the multiple QuBit objects should be placed in brackets and separated by commas. After the symbol "*" is obtained, check whether the qubit after the symbol "*" is a QuBit object. If the qubit obtained by parsing is a QuBit object and the expression method conforms to the aforementioned qubit data structure rules, it means that the qubit data structure meets the requirements and is legal, otherwise it is illegal. For the example shown in Table 3, the expression method of "qr[0], qc[1], qc[2], qc[3]" after the symbol "*" conforms to the expression method of the QuBit object, so the qubit data structure in Table 3 is legal.

[0087] (2) Check whether the type and number of qubits are legal based on the preset qubit legality conditions, where the types of qubits include target bits and control bits. The qubit legality conditions are, for example: when there is only one qubit after the symbol "*", there cannot be a control bit; the number of control bits cannot be greater than or equal to the total number of qubits. During the inspection, it is determined whether the conditions are met based on the determined control bits, target bits and their respective numbers. If they are met, the current type and number of qubits are legal, that is, the setting of the control bits and target bits of the qubits is reasonable. In order to perform this inspection, the number of control bits and target bits is first calculated, and the control bits and target bits are specified from the identified qubits. For example, when there is a control bit setting operation in the gate operation, the number of control bits is determined according to the parameter value in the control bit setting operation, the number of target bits is obtained by subtracting the number of control bits from the total number of qubits, and the control bits and target bits are respectively specified from the total number of qubits according to the specified rules. For example, for the quantum gate programming code in Table 3, which includes the qubit control bit setting operation "ctrl(3)", since its parameter value is 3, it is determined that there are three control bits. In this embodiment, the first three qubits "qr[0], qc[1], qc[2]" are designated as control bits, and the remaining "qr[3]" are designated as target bits. This embodiment specifies in order from front to back. Of course, the specified order can also be from back to front, or according to certain rules, which will not be repeated here. If there is no control bit setting operation, the current qubits are all designated as target bits. After the number of control bits and target bits is obtained, the qubit legality condition is checked. Taking Table 3 as an example, there are four qubits, including three control bits and one target bit, which meet the legal conditions of the qubit type and meet the condition that the number of control bits cannot be greater than or equal to the total number of qubits. The programming code in Table 3 meets the qubit legality condition.

[0088] (3) Check whether the gate parameter value matches the qubit. Specifically, check whether the matrix order in the matrix parameter is equal to the exponential calculation value with 2 as the base and the target number of bits as the exponent; if the matrix order is equal to the exponential calculation value with 2 as the base and the target number of bits as the exponent, then the test is determined to be passed. For example, the format of the matrix structure must satisfy N = 2 n In the example of Table 3, the target bit is one, that is, n=1, and the matrix [[1,0], [1,0]] is a 2*2 matrix, that is, the matrix order N=2=2 1 , thus satisfying the format requirements of the matrix structure, when the matrix order in the matrix parameter is checked and the target bit number does not match, it indicates that there is an error in the current programming code. In this embodiment, the matrix parameter is a gate parameter, that is, in this embodiment, what is checked is whether the gate parameter value matches the qubit.

[0089] (4) Check whether the gate parameter value matches the gate operation. Specifically, when the gate operation is a matrix transposition operation, check whether the matrix elements in the matrix parameters form a unitary matrix. If the matrix elements form a unitary matrix, it is determined that the test has passed.

[0090] The qubit data structure in the qubit data conforms to the preset qubit data structure rule, the type and quantity of the qubits conform to the qubit legality condition, the gate parameter value matches the qubit, and the gate parameter value matches the gate operation, and it is determined that all checks pass.

[0091] In step S2, the data structure corresponding to the created quantum operation includes a qubit parameter and a command data structure; the command data structure includes at least a matrix real part parameter, a matrix imaginary part parameter and a unitary matrix description parameter; the quantum gate data is stored in the command data structure, and the qubit data is stored in the qubit parameter. The identified gate structure, gate parameter value, qubit or gate operation is respectively stored in the corresponding parameters in the quantum operation data structure. For example, the matrix data in the quantum gate data is respectively stored in the matrix real part parameter and the matrix imaginary part parameter, and the unitary matrix description parameter is set to indicate whether the current matrix is ​​a unitary matrix or not, and the determined target bit or control bit is respectively stored in the corresponding target bit parameter and control bit parameter in the qubit parameter.

[0092] When the gate operation obtained by parsing includes a control bit setting operation of a qubit, a control bit is specified in the parsed qubit data, and the specified control bit is saved to a control bit parameter in a qubit parameter, and the remaining qubits in the qubit data are saved to a target bit parameter in a qubit parameter.

[0093] The present invention provides a definition instruction of a composite quantum gate used in programming and a separation identifier for separating multiple quantum gates. Therefore, when the parsing subunit 1233 parses the programming code to obtain the definition instruction and separation identifier of the composite quantum gate, the binding subunit 1234 creates a composite gate function, and the composite gate function includes multiple quantum gate data structures. When the parsing subunit 1233 parses the separation identifier, the binding subunit 1234 saves the programming code corresponding to the separation identifier to a quantum gate data structure in the composite gate function, and each quantum gate data structure includes quantum gate parameters and quantum bit parameters. In one embodiment, the binding subunit 1234 calls the transfer (_Ishift_) function to save a part of the programming code corresponding to the separation identifier to the quantum gate parameters, and the other part to the quantum bit parameters. Take the programming code entered by the developer as shown in Table 4 below as an example:

[0094] Table 4

[0095]

[0096]

[0097] When parsing the above-mentioned programming code, the parsing subunit 1233 determines the content of the subsequent programming code according to the instructions "def my_gate(a,b,c,d)" and "return Gate()" for realizing a composite quantum gate. A composite gate function is created based on the programming code "my_gate()", and the composite gate function includes multiple quantum gate data structures, each of which includes quantum gate parameters and quantum bit parameters. In this embodiment, the symbol "<<()" is used as a separator for different quantum gates, and the content of each symbol "<<()" is used as a quantum gate calculation unit. In one embodiment, the separator identifier in the programming code is identified, and the programming code corresponding to each separator identifier is stored in the quantum gate data structure. Specifically, when parsing the programming code corresponding to the separator identifier, a transfer (_Ishift_) function is created and called, and the data in the separator identifier is transferred to the corresponding parameter through the _Ishift_ function. For example, for the data in the first separator, the _Ishift_ function saves the "Matrix([[-0.5,0.5],[0.5,0.5]]).ctrl(2)" before the comma in the quantum gate parameter, and saves the "(a,b,c)" after the comma in the quantum bit parameter. Similarly, "(Matrix([[0.5,-0.5],[0.5,0.5]]).ctrl(1),(a,c))", "(Matrix([[0.5,0.5],[-0.5,0.5]]),b)", "(H,d)" and "(X,d)" are saved in the remaining four quantum gate data structures respectively.

[0098] At this time, the programming code in the first quantum gate data structure is used as the quantum gate programming code to be parsed.

[0099] Then, as described above, the parsing subunit 1233 parses the programming code corresponding to each separation mark to obtain the gate structure, gate parameter value, qubit and gate operation of the quantum gate, etc. The qubit at least includes the target bit, the gate structure is, for example, a universal quantum gate structure, the corresponding gate parameter value is, for example, matrix data corresponding to the universal quantum gate structure, and the gate operation is, for example, a control bit setting operation or a matrix transposition operation, etc. Taking the programming code in Table 4 as an example, when parsing the first three quantum gate programming codes, the matrix structure is obtained, and when parsing the last two quantum gate programming codes, the H gate and X gate are obtained respectively.

[0100] The binding subunit 1234 creates a quantum operation for each quantum gate data structure, and saves the parsed data into the corresponding parameters in the data structure corresponding to the quantum operation, thereby binding multiple quantum gates together to form a composite quantum gate computing unit.

[0101] In the above embodiment, the composite quantum gate is composed of three quantum gates, an H gate, and an X gate defined by the developer, wherein the first quantum gate is a three-bit quantum gate, qubit a and qubit b are control bits, qubit c is the target bit, and the matrix [[-0.5, 0.5], [0.5, 0.5]] is applied to the target bit. The second quantum gate is a two-bit quantum gate, qubit a is the control bit, qubit c is the target bit, and the matrix [[0.5, -0.5], [0.5, 0.5]] is applied to the target bit. The third quantum gate is a single-bit quantum gate, and the matrix [[0.5, 0.5], [-0.5, 0.5]] is applied to qubit b. The fourth quantum gate is an H gate, which acts on qubit d. The fifth quantum gate is an X gate, which acts on qubit d. The above five quantum gates constitute a four-bit composite quantum gate.

[0102] From the above description, it can be seen that the quantum gate definition unit 123 enables developers to define quantum gates in the programming process according to the functions to be implemented and the requirements of calculations, so as to implement some specific quantum calculations. It can be used in quantum programming like a general quantum gate, making the implementation of quantum calculations more flexible. At the same time, some operations and calculations can be integrated together to simplify the programming code and improve the programming efficiency and calculation efficiency.

[0103] The quantum operation library module 13 is configured to provide general quantum operations and specific quantum operations. Figure 4 , Figure 4It is a block diagram of the principle of a quantum operation library module according to an embodiment of the present invention. In this embodiment, the quantum operation library module 13 includes a general operation unit 131 and a specific operation unit 132, wherein the general operation unit 131 is configured to provide a general quantum operation, such as Fourier transform. The specific operation unit 132 is configured to provide a specific quantum operation, such as an amplitude amplification (Quantum Amplitude Amplification, referred to as QAA) operation, a uniform superposition quantum state (referred to as PLUS superposition state) preparation operation, a classical quantum state (referred to as Classical state) preparation operation, an initial quantum state preparation operation (referred to as AMP operation), and an operation of shifting the current quantum state (referred to as ADD operation) One or more. Among them, each specific operation has a specific name to distinguish it, and each specific operation has a corresponding processing logic. For example, for the QAA operation, it provides parameter values, which respectively represent the state value and the number of amplifications to be amplified. When applying the QAA operation, the developer can set the corresponding parameter value according to actual needs. For example, the programming code for the developer to apply the QAA operation is shown in Table 5.

[0104] Table 5

[0105] Programming Code Serial number circuit = QCircuit() 1-6 qureg = circuit.allocate(4) 1-7 All(H)*qureg 1-8 QAA(3,7)*qureg 1-9

[0106] Among them, a quantum circuit is defined according to the programming code of sequence number 1-6, 4 quantum bits are allocated to the quantum circuit according to the programming code of sequence number 1-7, a superposition operation is performed on the initial amplitude of the 4 quantum bits according to the programming code of sequence number 1-8, and according to the programming code of sequence number 1-9, the quantum state sequence number 7 is used as the mark value, and the amplitude of the quantum state corresponding to the mark value is amplified three times.

[0107] In this embodiment, the quantum states of the four qubits are 2 4 =16, "QAA()" represents the amplitude amplification operation, the parameter "3" represents 3 amplification operations, and the parameter "7" represents the quantum state number of the amplification operation.

[0108] After executing the circuit, after each amplification operation on the quantum state with quantum state number 7, the probability of quantum state number 7 is as follows:

[0109] prob of state|7>=0.4726562499999991 (first amplification operation)

[0110] prob of state|7>=0.9084472656249968(second amplification operation)

[0111] prob of state|7>=0.9613189697265575 (third amplification operation)

[0112] From the above execution results, it can be seen that after three iterations of QAA operation, the probability of the quantum state with state number 7 exceeds 96%. This operator can effectively increase the probability of a quantum state.

[0113] Regarding the PLUS superposition state preparation operation, it can evenly superimpose the amplitudes of the specified quantum bits. For example, the programming code is shown in Table 6.

[0114] Table 6

[0115] Programming Code Serial number circuit = QCircuit() 1-10 qureg = circuit.allocate(2) 1-11 PLUS*qureg 1-12

[0116] A uniform superposition state is prepared for each quantum bit in the current quantum circuit based on the programming codes numbered 1-12. After executing the quantum circuit, the four quantum states of the quantum circuit are [0.5+0.j0.5+0.j 0.5+0.j 0.5+0.j]. It can be seen that the amplitude of each quantum state is in a superposition state.

[0117] Regarding the Classical operation, it can conveniently prepare the classical quantum state, and the parameters set therein affect the initialized quantum state. In one embodiment, the Classical operation can be expressed as "Classical (a)", and the parameter "a" represents the quantum state number for preparing the quantum state as the "1" state. Through this operation, the quantum state with the quantum state number "a" is prepared as the "1" state, and the other quantum states are prepared as the "0" state. The usage examples are shown in Table 7.

[0118] Table 7

[0119] Programming Code Serial number circuit = QCircuit() 1-13 qureg = circuit.allocate(2) 1-14 Classical(0)*qureg 1-15

[0120] Prepare the classical quantum state for the current quantum circuit according to the programming code of sequence number 1-15. After executing the quantum circuit, the four quantum states are represented as follows:

[0121] [1.+0.j 0.+0.j 0.+0.j 0.+0.j]

[0122] It can be seen that the amplitude of the first quantum state has initially become the "1" state, and the amplitudes of the other three quantum states are in the "0" state.

[0123] Regarding the AMP operation, the AMP operation enables developers to easily prepare any desired initial quantum state. For example, "APM (a, b, c)" represents the AMP operation, where a, b, and c are three parameters. The first parameter "a" is used to specify the initial state, the second parameter "b" is used to specify the quantum state number to be initialized, and the third parameter "c" is used to specify the number of quantum states to be initialized. The usage example is shown in Table 8.

[0124] Table 8

[0125] Programming Code Serial number circuit = QCircuit() 1-16 qureg = circuit.allocate(4) 1-17 AMP([1-2j,2+3j,3-4j,0.5+0.7j],1,2)*qr 1-18

[0126] The programming code based on serial numbers 1-18 creates a specified initial quantum state for the two quantum bits in the quantum circuit.

[0127] Among them, the first parameter "a" is [1-2j, 2+3j, 3-4j, 0.5+0.7j], which represents the specified initialization state (in this embodiment, the quantum state is represented by amplitude), the second parameter "b" is "1", which means starting from the second quantum state, and the third parameter "c" is "2", which means initializing 2 quantum states.

[0128] Based on the first parameter "a", the matrix is ​​first normalized, and then starting from the second quantum state, the two quantum states are normalized to obtain the corresponding quantum states. After executing the quantum circuit, the four quantum states are [1.+0.j 0.52810695-0.21309473j0.57063177+0.44419322j 0.+0.j]. It can be seen that the second and third quantum states have been initialized to the states set by the developer, while the first and fourth quantum states are still classical states.

[0129] Regarding the ADD operation, the ADD operation is used to realize the displacement of the classical quantum state, and its calculation method is addition operation. In one embodiment, the operator of the ADD operation is expressed as "ADD(a)", and the parameter "a" represents the number of bits to shift the current classical quantum state, as shown in Table 9.

[0130] Table 9

[0131] Programming Code Serial number circuit = QCircuit() 1-19 qureg = circuit.allocate(4) 1-20 Classical(3)*qr 1-21 print(circuit.get_statevector()) 1-22 ADD(3)*qr 1-23 print(circuit.get_statevector()) 1-24

[0132] Among them, according to the programming codes of serial numbers 1-21, a classical quantum state is prepared for the quantum circuit (the fourth quantum state is a "1" state, and the other quantum states are a "0" state).

[0133] Run the quantum circuit based on the programming code of sequence number 1-22 and obtain the state vector. The results are as follows:

[0134] [0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j

[0135] 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]

[0136] According to the programming code of serial number 1-23, the position of the classical quantum state "1" is shifted back by 3 bits. Based on the programming code of serial number 1-24, the quantum circuit is run and the state vector is obtained. The results are as follows:

[0137] [0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j

[0138] 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]

[0139] It can be seen that the amplitude bit of the fourth quantum state of the quantum circuit before adding the ADD operation is in the "1" state, and the amplitude bit of the seventh quantum state of the quantum circuit after adding the ADD operation is in the "1" state.

[0140] The aforementioned quantum gate library module 12 and quantum operation library module 13 provide developers with abundant and flexible quantum gates and quantum operations, which can simplify the programming code of developers and improve the programming efficiency of developers.

[0141] Figure 5 1 is a principle block diagram of a quantum circuit module according to an embodiment of the present invention. In this embodiment, the quantum circuit module 14 includes a programming code parsing unit 141, a quantum gate parsing unit 142, a quantum operation parsing unit 143 and a quantum program generating unit 144.

[0142] The programming code parsing unit 141 is used to parse the programming code to identify instructions, quantum gates and / or quantum operations, and obtain corresponding parameter values. For example, when the programming code is "qc = QCircuit()", the current programming code is determined to be a quantum circuit creation instruction according to "QCircuit()", and the quantum circuit is named "QC". For another example, when the programming code is "qr = qc.allocate(2)", the current programming code is determined to be a quantum bit creation instruction according to "allocate". In one embodiment, the quantum bit creation instruction includes a quantum bit structure to limit the storage method of the created quantum bit. For example, the quantum bit structure includes two structures, a distributed structure and a centralized structure. When the quantum bit structure in the quantum bit creation instruction is a distributed structure, a corresponding number of registers are created based on the number of distributed parameters in the distributed structure to store the quantum bits specified by each distributed parameter. For example, the quantum bit structure corresponding to "allocate([1, 1])" is a distributed structure, and the two numbers separated by commas in the brackets represent a distributed parameter respectively. In this embodiment, there are two distributed parameters. The specific parameter value of the distributed parameter is used to specify the number of quantum bits stored in a register. In this embodiment, there are two scattered parameters, so two registers need to be created, each scattered parameter specifies a quantum bit, that is, one quantum bit is stored in each register. In other embodiments, the number of scattered parameters can be more than two, and the parameter value of the scattered parameter can also be a numerical value greater than 1, that is, more than one quantum bit can be specified to be stored in one register. When the quantum bit structure in the quantum bit creation instruction is a centralized structure, a register is created to store the number of quantum bits specified by the centralized parameter. For example, the quantum bit structure corresponding to "allocate(2)" is a centralized structure, and the number in the brackets is a centralized parameter, which is used to specify the number of quantum bits. In this embodiment, two quantum bits are specified. Therefore, it is necessary to create a register and store two quantum bits in it.

[0143] When parsing the programming code, the programming code parsing unit 141 can obtain the corresponding quantum gate by identifying the quantum gate name in the code. Quantum gate names include general quantum gate names, such as CR, H, I, ISwap, Measure, CNOT, P, Rx, Ry...X, Y, etc., and also include specific quantum gates, such as All, Reset, Barrier, etc. When a quantum gate is identified, it also includes obtaining the corresponding parameter value. For example, the H quantum gate (hereinafter referred to as the H gate) is identified from the programming code "H*qureg[0]", and the information of "applying the H gate operation to the first quantum bit" is obtained. For another example, the amplitude amplification instruction is parsed from the programming code "QAA(3,7)*qureg", and the parameter value used to represent the number of amplifications is determined to be "3", and the parameter value of the quantum state sequence number corresponding to the amplification operation is determined to be "7", and so on.

[0144] The quantum gate parsing unit 142 is used to respond to the identified quantum gate and the corresponding instruction, parse the quantum gate and the instruction to obtain the corresponding quantum instruction, and pass the parameter value obtained by parsing to the quantum instruction. In one embodiment, the developer cooperates with the quantum gate in the programming code with a variety of different methods (or functions) to implement different gate operations. The method described is, for example:

[0145] 1) The __mul__ method and the __or__ method are used to apply the target quantum gate to the target quantum bit. For example, in the programming code "H*qureg[0]", "*" represents the __mul__ method, the corresponding target quantum gate parameter is the "H gate" in the circuit, and the target quantum bit parameter is the "first quantum bit". Based on the H gate and the __mul__ method identified from the programming code "H*qureg[0]", the instruction to call the __mul__ method is determined, and at the same time, the "first quantum bit is the target quantum bit" and the matrix of the H gate are set. Passed to the __mul__ method, resulting in a series of quantum instructions.

[0146] 2) __str__ method, used to obtain the string description of the quantum gate. For example, in the programming code "H_str = str(H)", the H gate and the __str__ method are identified, thereby obtaining the quantum instruction of "obtaining the string description of the quantum gate", and passing the "H gate" as a specific quantum gate parameter to the __str__ method.

[0147] 3) commit method, which is used to receive a quantum operation (Command type) data structure, which includes multiple parameters, such as the quantum gate, the target bit of the quantum gate, the rotation angle, and whether to perform a matrix inversion and transposition operation on the quantum gate, etc., and sequentially combine the data structure into multiple quantum instructions.

[0148] 4) inv method, used to apply the transposition operation of the quantum gate matrix. For example, from the programming code "NOT.inv()*qureg[0]", the NOT quantum gate, __mul__ method, inv method and target bit are identified. The specific parameter value of the target bit is the first quantum bit, and the quantum instruction obtained is the transposition operation of the NOT quantum gate on the first quantum bit. This instruction can be used to easily apply the inverse operation of a quantum gate.

[0149] 5) The ctrl method is used to specify the number of control bits of the target quantum gate to be applied, and the corresponding parameter is the number of control bits. For example, the P gate is identified from the programming code "P(pi / 2).ctrl(1)*(qureg[0],qureg[1])", and the corresponding methods include the ctrl method and the __mul__ method. The corresponding parameters are the control gate CP gate of the P gate, qureg[0] represents the first quantum bit, qureg[1] represents the second quantum bit, and "ctrl(1)" indicates that a control bit should be set. Therefore, according to the setting order from front to back, the first quantum bit qureg[0] is designated as the control bit, and the second quantum bit qureg[1] is designated as the target bit, thereby obtaining the quantum instruction of applying the control gate CP gate of the P gate to the first quantum bit and the second quantum bit, wherein the first quantum bit is the control bit of the CP gate, and the second quantum bit is the target bit of the CP gate.

[0150] The quantum operation parsing unit 143 is used to respond to the identified quantum operation and the corresponding instruction, parse the quantum operation to obtain the corresponding quantum instruction, and pass the parameter value corresponding to the quantum operation to the quantum instruction.

[0151] The quantum operation can be the various quantum gate operations mentioned above, or other operations, such as the QAA operation, PLUS superposition state preparation operation, Classical state preparation operation, AMP operation and ADD operation in one embodiment of the present invention. The quantum operation parsing unit 143 identifies the specific operation based on the operation name, such as determining that the current quantum operation is a QAA operation based on "QAA()" in "QAA(3,7)*qureg", and determining the corresponding amplitude superposition instruction based on the QAA operation, and the corresponding parameters are, for example, the 7th quantum state and superposition 3 times.

[0152] The quantum program generation unit 144 integrates the obtained quantum instruction sequence into a quantum program instruction set based on the parsing sequence of the programming code.

[0153] After being processed by the aforementioned quantum circuit module 14, a corresponding quantum program instruction set is obtained based on the programming code, and the quantum program instruction set is compiled into an executable program instruction set of the back-end device by the program compilation module 15, and the executable program instruction set is sent to the corresponding back-end device by the back-end communication module 16, and is run by the back-end device.

[0154] In the programming process, the developer obtains a code in the form of characters by programming in a certain programming language. The quantum program obtained in the end is also a set of characters. The code in the form of characters is not intuitive enough compared to graphics. Even in some quantum operations, since only the quantum operation name or quantum algorithm name needs to be given in the programming code, the quantum instruction set can be obtained after the processing of each unit in the aforementioned quantum circuit module 14, but it is not presented to the developer, which is not intuitive enough. Therefore, in another embodiment of the present invention, see Figure 6 The quantum circuit module 14 further includes a quantum circuit drawing unit 145 for rendering the parsed quantum gates and / or quantum operations into graphical representations in a logical order. For example, the programming code written by the developer is shown in Table 10.

[0155] Table 10

[0156] Programming Code illustrate Serial number circuit = QCircuit() Defining a quantum circuit 1-25 qureg = circuit.allocate(4) Allocating 4 qubits 1-26 QFT*qureg Perform Fourier Transform 1-27 circuit.draw() Drawing the quantum circuit 1-28

[0157] The programming code parsing unit 141 of the quantum circuit module 14 obtains the Fourier transform operation when parsing the programming code. The quantum operation parsing unit 143 determines the quantum gates, corresponding quantum operations and parameters used in the operation based on the identified Fourier transform operation. The quantum circuit drawing unit 145 renders the parsed quantum gates and quantum operations into a graphical representation in a logical order, such as Figure 7 As shown, the quantum gates used for the Fourier transform operation are obtained, such as the H gate, CP gate, and the quantum bits operated by each quantum gate. In this embodiment, there are 4 quantum bits, namely q[0], q[1], q[2] and q[3], which include control bits and target bits. For example, for the CP gate in the first row, q[0] is the control bit and q[3] is the target bit. The present invention uses a graphical quantum circuit to represent the aforementioned programming code, which can intuitively represent the specific quantum computing process.

[0158] In practical applications, after a quantum program is obtained based on certain logic programming, it needs to be run multiple times according to different parameters. For example, a quantum program used to implement a machine learning algorithm needs to input sample data multiple times during the training process. Therefore, setting parameters for the quantum program that can change specific data is a solution to meet the application requirements. In one embodiment, Figure 8As shown, the quantum circuit module 14 also includes a parameterization unit 146, which provides operating parameters that can dynamically set parameter values. In one embodiment, the developer can set the operating parameters in the form of parameter placeholders, and the corresponding parameter values ​​are stored in the corresponding registers. When programming, the developer can set the operating parameters for the specified quantum circuit. When the programming code parsing unit 141 identifies the operating parameters in the process of parsing the programming code, the parameterization unit 146 provides corresponding registers for storing the corresponding parameter values. The developer dynamically sets parameter values ​​for the operating parameters according to the needs of the operation. When the programming code parsing unit 141 identifies the operating parameters and their parameter values ​​when parsing the programming code, the parameterization unit 146 assigns the operating parameter values ​​to the operating parameters in the specified quantum circuit, and the operating parameter values ​​are written into the corresponding registers.

[0159] As shown in the programming code in Table 11 below, the developer sets two operating parameters for the quantum circuit, namely "theta" and "phi", and dynamically sets the parameter values ​​twice. After running the quantum circuit twice, two different quantum state results are obtained.

[0160] Table 11

[0161]

[0162]

[0163] By executing the programming codes of sequence numbers 1-35 and 1-37, the quantum circuits are run respectively and the running results obtained are as follows:

[0164] [0.77015115+0.j 0.42073549+0.j 0.42073549+0.j 0.22984885+0.j]

[0165] [0.29192658+0.j 0.45464871+0.j 0.45464871+0.j 0.70807342+0.j]

[0166] It can be seen that when different parameter values ​​are set for the same quantum circuit, different results can be obtained by running the quantum circuit with corresponding parameter values, which makes it easier for developers to use quantum circuits to implement applications such as machine learning models.

[0167] Furthermore, the quantum circuit module 14 also includes a quantum circuit combining unit 147 for providing quantum circuit combining parameters. When programming, developers can effectively save code input time and save a lot of development work by using quantum circuit combining parameters to combine corresponding multiple quantum circuits. In one embodiment, the quantum circuit combining parameters are exemplified as "circuitA.append_circuit(circuitB)", where A and B are parameter values, A is the target quantum circuit, and B is the quantum circuit to be combined. When the programming code parsing unit 141 identifies the quantum circuit combining parameters and their parameter values ​​in the process of parsing the programming code, the quantum circuit combining unit 146 merges the quantum circuit to be combined specified in the quantum circuit combining parameters into the target position of the target quantum circuit; the quantum program generating unit 144 inserts the quantum program instruction set of the quantum circuit to be combined into the insertion position in the target quantum program instruction set corresponding to the target position.

[0168] For example, the programming code shown in Table 12 below:

[0169] Table 12

[0170]

[0171] The programming code parsing unit 141 identifies two quantum circuits named circuit1 and circuit2 respectively when parsing the above programming code, and extracts the quantum circuit combination parameters and their parameter values ​​"circuit2" and "circuit1" from circuit2.append_circuit(circuit1). Then the quantum circuit combination unit 147 merges the quantum circuit circuit1 to be combined specified in the quantum circuit combination parameters into the target position of the target quantum circuit circuit2. In this embodiment, the target position is the position where the quantum circuit combination parameter code is located. The quantum program generation unit 144 inserts the quantum program instruction set of the quantum circuit to be combined into the insertion position of the target quantum program instruction set corresponding to the target position of the target quantum circuit.

[0172] Furthermore, the quantum circuit module 14 further includes the quantum circuit conversion unit 148. When the programming code parsing unit 141 parses the programming code to obtain the circuit conversion instruction, the quantum circuit conversion unit 148 converts the programming code of the target quantum circuit from the source language to the target language based on the quantum circuit source language and the target language in the conversion instruction. The quantum circuit conversion unit 148 stores the grammatical rules corresponding to various programming languages ​​and the corresponding conversion logics. For example, the quantum circuit conversion unit 148 stores the grammatical rule correspondence and conversion logic of the OpenQASM quantum programming language and the QUSL quantum programming language. Therefore, in this embodiment, the quantum program written in the QUSL quantum programming language and the quantum program written in the OpenQASM quantum programming language can be converted to each other, thereby solving the problem of needing to rewrite due to different programming languages, saving programming time, and improving programming efficiency.

[0173] The quantum circuit module 14 sends the quantum program instruction set to the program compilation module 15, and the program compilation module 15 compiles the quantum program instruction set into an executable program instruction set of the back-end device. After receiving the running instruction, the back-end communication module 16 sends the executable program instruction set corresponding to the running instruction to the corresponding back-end device, and receives the running data of the back-end device. The running data includes the type of the back-end device, such as the local back-end device, the cloud back-end device, etc. The running data also includes the quantum bits in the quantum circuit, the quantum gates used, the execution time of each quantum gate, the time from the running instruction to sending the quantum instruction set to the back-end device (referred to as the front-end time), the time from sending the quantum instruction set to the back-end device to receiving the back-end return data (referred to as the back-end time), etc. Therefore, in order to enable developers to fully understand the various statistical information of the running quantum program, further, the quantum circuit module 14 also includes a running data statistics unit 149, based on the running data returned by the back-end device, according to the preset statistical item parameters, the target running data in the running data is counted. Such as the number of quantum bits, the number of quantum gates, the total execution time of the quantum circuit, including the execution time of the front and back ends, the type of back-end device, the result status, etc.

[0174] The program compilation module 15 in the embodiment of the present invention is compiled into a corresponding executable program instruction set based on the operation mode of the back-end device, such as a single-point CPU, a single-point graphics processor (Graphics Processing Unit, referred to as GPU), a multi-point MPI CPU / GPU, etc. When the back-end device is in a single-point operation mode, the program compilation module 15 compiles the quantum program instruction set into a single executable program instruction set, and the back-end device at this time runs the executable program instruction set on the CPU or GPU to realize the operation of the quantum circuit or quantum program generated by the aforementioned device. When the back-end device is in a distributed operation mode of a multi-point MPI CPU / GPU, the back-end device includes a plurality of node devices, and the program compilation module 15 compiles the quantum program instruction set into a plurality of joint executable program instruction sets jointly operated by the node devices, and sends them to each node device respectively, each node device receives the executable program instruction set, and runs the received executable program instruction set through its respective processor (CPU / GPU), and jointly realizes the quantum circuit or quantum program generated by the aforementioned device. Through the distributed operation mode of multi-point MPI CPU / GPU, the hardware resources of multiple node devices together constitute the hardware environment for running quantum circuits, so that quantum programs with a large number of quantum bits and complex logic can be executed, which not only reduces the resource requirements for a single node device, but also improves the operation speed.

[0175] In a specific implementation, the backend device may be, for example, a local Python simulation backend, that is, a simulation system installed in the same system (such as a server, a device, or a server cluster of the same system) as the quantum programming system 1. The backend device may also be a simulator deployed on different servers, which interacts with the quantum programming system 1 of the present invention through network communication. The backend device may also be a cloud device provided by a third party, such as a cloud service device named "Amazon Braket", which includes a local quantum simulator, an SVL simulator using cloud resources, and an ionq real machine using cloud resources. The cloud service device provided by a third party is also, for example, a cloud service and platform related to quantum computing provided by IBM, which includes a quantum simulator.

[0176] The quantum programming system 1 sends the executable program instructions compiled by the program compilation module 15 to one of the above-mentioned various back-end devices determined by the developer through the back-end communication module 16, so that the developer can use the aforementioned various back-end devices to run the quantum program implemented by the quantum programming system 1 provided by the present invention. The back-end device sends the running data to the quantum programming system 1.

[0177] In another aspect, the present invention further provides an electronic device, see Fig. 9 , Fig. 91 is a block diagram of the structure principle of an electronic device according to an embodiment of the present invention. Fig. 9 As shown, the electronic device includes a processor 601 and a memory 602 storing computer program instructions; when the processor 601 executes the computer program instructions, the quantum programming system 1 in the above-mentioned embodiment is implemented.

[0178] Specifically, the processor 601 may include a central processing unit (CPU) or a graphics processing unit (GPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of an embodiment of the present invention. The memory 602 may include a memory for data or instructions. For example, the memory 602 may be at least one of the following: a hard disk drive (HDD), a read-only memory (ROM), a random access memory (RAM), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, a universal serial bus (USB) drive or other physical / tangible memory storage device. For another example, the memory 602 includes a removable or non-removable (or fixed) medium. For another example, the memory 602 may be inside or outside the integrated gateway disaster recovery device. The memory 602 may be a non-volatile solid-state memory. In other words, typically the memory 602 includes a tangible (non-transitory) computer-readable storage medium (such as a memory device) encoded with executable instructions, wherein when the stored executable instructions are executed by the processor 601 (such as executed by one or more processors), the quantum programming system 1 in the embodiment of the present invention can be implemented.

[0179] In one example, Fig. 9 The electronic device shown may also include a communication interface 603 and a bus 610. The processor 601, the memory 602, and the communication interface 603 are connected and communicate with each other via the bus 610. The communication interface 603 is mainly used to implement communication between modules, devices, units, and / or devices in the electronic device.

[0180] The bus 610 includes hardware, software, or both, and can couple the components of the online data traffic metering device to each other. For example, the bus may include at least one of the following: an accelerated graphics port (AGP) or other graphics bus, an enhanced industrial standard architecture (EISA) bus, a front-side bus (FSB), a hypertransport (HT) interconnect, an industrial standard architecture (ISA) bus, an infinite bandwidth interconnect, a low pin count (LPC) bus, a memory bus, a microchannel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standard association local (VLB) bus, or other suitable buses. The bus 610 may include one or more buses. Although the embodiments of the present invention describe or illustrate a specific bus, the embodiments of the present invention may consider any suitable bus or interconnection method.

[0181] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the aforementioned quantum programming system 1 is implemented.

[0182] The flowchart and / or block diagram of the method and system of the embodiment of the present invention are described above by way of example, and various aspects of the related aspects are described. It should be understood that each box or combination thereof in the flowchart and / or block diagram can be implemented by computer program instructions, or by dedicated hardware that performs specified functions or actions, or by a combination of dedicated hardware and computer instructions. For example, these computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to form a machine that enables these instructions executed by such a processor to enable the implementation of the functions / actions specified in each box or combination thereof in the flowchart and / or block diagram. Such a processor can be a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit.

[0183] The functional blocks shown in the structural block diagram of the embodiment of the present invention can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc.; when implemented in software, it is a program or code segment used to perform the required task. The program or code segment can be stored in a memory, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0184] It should be noted that the present invention is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific implementation mode of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be covered within the protection scope of the present invention.

Claims

1. A quantum programming system, It is characterized in that include: an interface module configured to provide a programming code input interface and a display interface; A quantum gate library module, configured to provide general quantum gates, specific quantum gates, and custom quantum gates; A quantum operation library module configured to provide general quantum operations and specific quantum operations; A quantum circuit module, configured to parse an input programming code to obtain a quantum circuit and a corresponding set of quantum program instructions; A program compiling module configured to compile a quantum program instruction set into an executable program instruction set to be run by a backend device; a backend communication module configured to send a specified set of executable program instructions to a corresponding backend device and receive operation data of the backend device; The quantum gate library module includes a quantum gate definition unit, and the quantum gate definition unit includes: structural subunits configured to provide one or more gate structures constituting a quantum gate; a parameter subunit configured to provide one or more gate parameters and / or gate operations for each gate structure; A parsing subunit, configured to parse the quantum gate programming code to obtain corresponding quantum gate data and qubit data when the quantum gate programming code to be parsed is obtained when parsing the quantum programming code; A binding subunit is configured to create a quantum operation, wherein the data structure corresponding to the quantum operation includes a quantum bit parameter and a command data structure, the quantum gate data obtained by parsing is stored in the command data structure, and the quantum bit data obtained by parsing is stored in the quantum bit parameter; when the quantum operation is applied to a quantum circuit, the calculation of the quantum gate is implemented based on the quantum gate data and the quantum bit data stored in the data structure corresponding to the quantum operation.

2. The quantum programming system according to claim 1, It is characterized in that The quantum gate library module also includes: a universal quantum gate unit configured to provide a variety of universal quantum gates; A specific quantum gate unit is configured to provide a plurality of specific quantum gates, wherein the specific quantum gates include one or more of the following quantum gates: All gates that perform the same quantum operation on all qubits of a given quantum circuit; The Reset gate resets the quantum state of the specified quantum bit to the initial state; Barrier gate used to segment quantum circuits.

3. The quantum programming system according to claim 1, It is characterized in that The quantum gate data includes one or more of a gate structure, a gate parameter value, and a gate operation, the quantum bit data includes at least a target bit, and the gate structure includes a matrix structure and / or a universal quantum gate structure.

4. The quantum programming system according to claim 1, It is characterized in that The quantum operation library module includes: a universal operation unit configured to provide universal quantum operations; A specific operation unit configured to provide a specific quantum operation; The specific quantum operation includes one or more of an amplitude amplification operation, a uniform superposition quantum state preparation operation, a classical quantum state preparation operation, an initial quantum state preparation operation, and a displacement operation on a current quantum state.

5. The quantum programming system according to claim 1, It is characterized in that The quantum circuit module includes a parameterization unit configured to provide operating parameters that allow developers to dynamically set parameter values; When the operating parameters and parameter values ​​are identified during the parsing of the programming code, the parameterization unit assigns the current parameter values ​​to the operating parameters in the specified quantum circuit.

6. The quantum programming system according to claim 1, It is characterized in that The quantum circuit module includes a quantum circuit combining unit configured to provide quantum circuit combining parameters; correspondingly, when the quantum circuit combining parameters and parameter values ​​are identified in the process of parsing the programming code, the quantum circuit to be combined, the target quantum circuit and the combining position are identified from the quantum circuit combining parameters; the quantum circuit to be combined is inserted into the combining position of the target quantum circuit, and the quantum program instruction set of the quantum circuit to be combined is inserted into the combining position in the target quantum program instruction set.

7. The quantum programming system according to claim 1, It is characterized in that The quantum circuit module includes a quantum circuit conversion unit, which is configured to convert the programming code of the target quantum circuit described in the original language into the programming code described in the target language when a conversion instruction and the original language and the target language of the quantum circuit are identified during the process of parsing the programming code.

8. The quantum programming system according to claim 1, It is characterized in that The quantum circuit module includes an operation data statistics unit, which is configured to obtain corresponding statistical data from the operation data according to preset statistical item parameters and statistical algorithms based on the operation data returned by the back-end device.

9. An electronic device, It is characterized in that The invention comprises a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the quantum programming system according to any one of claims 1 to 8 is implemented.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the quantum programming system according to any one of claims 1 to 8 is implemented.