WO2024255025A1 - 量子线路处理方法、装置、计算机、存储介质及程序产品 - Google Patents
量子线路处理方法、装置、计算机、存储介质及程序产品 Download PDFInfo
- Publication number
- WO2024255025A1 WO2024255025A1 PCT/CN2023/123812 CN2023123812W WO2024255025A1 WO 2024255025 A1 WO2024255025 A1 WO 2024255025A1 CN 2023123812 W CN2023123812 W CN 2023123812W WO 2024255025 A1 WO2024255025 A1 WO 2024255025A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- quantum
- gate
- circuits
- circuit
- gates
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N10/00—Quantum computing, i.e. information processing based on quantum-mechanical phenomena
- G06N10/20—Models of quantum computing, e.g. quantum circuits or universal quantum computers
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N10/00—Quantum computing, i.e. information processing based on quantum-mechanical phenomena
- G06N10/40—Physical realisations or architectures of quantum processors or components for manipulating qubits, e.g. qubit coupling or qubit control
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the present application relates to the field of computer technology, and in particular to a quantum circuit processing method, device, computer, storage medium and program product.
- Superconducting quantum chips are currently in the noisy intermediate-scale quantum (NISQ) era, with the following characteristics: qubit coherence time is limited, qubit gates have errors (limited fidelity), and qubit measurement operations introduce systematic errors.
- NISQ intermediate-scale quantum
- superconducting quantum computing is realized by running quantum circuits on superconducting quantum chips.
- the circuits usually contain many single-qubit gates and double-qubit gates. Based on this, it is necessary to perform timing control on quantum circuits.
- the timing control of quantum circuits is performed by users manually inputting a large number of restrictions, resulting in low efficiency in quantum circuit processing and complex quantum gate processing.
- the rules for aligning quantum gates are restricted, resulting in poor flexibility of quantum circuits.
- a quantum circuit processing method, device, computer, storage medium and program product are provided.
- an embodiment of the present application provides a quantum circuit processing method, which is executed by a computer device, including:
- a quantum processing instruction is generated according to the quantum gate arrangement circuit data, wherein the execution order of the quantum gates included in the N quantum circuits specified in the quantum processing instruction is different from the execution order of the quantum gates included in the N quantum circuits specified in the quantum program to be analyzed.
- an embodiment of the present application provides a quantum circuit processing device, which includes:
- a program acquisition module is used to obtain the quantum program to be parsed
- a program analysis module used to perform quantum circuit analysis on the quantum program to be analyzed to obtain circuit information included in the quantum program to be analyzed, wherein the circuit information includes N quantum circuits and quantum gates included in the N quantum circuits, where N is a positive integer;
- a quantum arrangement module configured to align the quantum gates included in the N quantum circuits based on the gate association relationship between the quantum gates included in the N quantum circuits, and obtain aligned quantum gate arrangement circuit data
- An instruction generation module is used to generate a quantum processing instruction according to the quantum gate arrangement circuit data, wherein the execution order of the quantum gates included in the N quantum circuits specified in the quantum processing instruction is different from the execution order of the quantum gates included in the N quantum circuits specified in the quantum program to be analyzed.
- an embodiment of the present application provides a computer device, including a processor and a memory, wherein the memory is used to store computer-readable instructions, and the processor is used to call the computer-readable instructions to execute a method of any embodiment of the present application;
- an embodiment of the present application provides a computer-readable storage medium, which stores computer-readable instructions.
- the computer-readable instructions are loaded and executed by a processor so that the processor executes the method of any embodiment of the present application.
- FIG6 is a schematic diagram of a directed graph construction scenario provided in an embodiment of the present application.
- FIG11 is a simplified flowchart of quantum analysis provided in an embodiment of the present application.
- FIG12 is a schematic diagram of a quantum circuit processing device provided in an embodiment of the present application.
- FIG. 13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.
- a prompt interface or pop-up window will be displayed before and during the collection.
- the prompt interface or pop-up window is used to prompt the user that certain data is currently being collected, such as quantum programs to be parsed, etc. Only after the user confirms the prompt interface or pop-up window, the relevant steps of data acquisition are started, otherwise the process ends.
- the acquired user data will be used in reasonable and legal scenarios or purposes.
- authorization can be requested from the user, and the user data can be used when the authorization is passed.
- FIG. 1 is a network interaction architecture diagram of quantum circuit processing provided by the embodiment of the present application.
- the computer device 101 can obtain the quantum program to be analyzed, perform quantum circuit analysis on the quantum program to be analyzed, model the quantum circuit corresponding to the quantum program to be analyzed, obtain quantum gate arrangement circuit data, and realize the timing control of the quantum circuit.
- the process realizes the independent modeling of the quantum circuit, can adapt to different quantum languages, and can improve the flexibility of timing control.
- the quantum gate arrangement circuit data is converted into a quantum processing instruction, which refers to an instruction at the physical level, wherein the quantum gates included in the N quantum circuits, the first execution timing in the quantum processing instruction is different from the second execution timing in the quantum program to be analyzed, and the timing arrangement of the quantum circuit is realized, the flexibility of quantum circuit management is improved, and the convenience and efficiency of quantum gate processing are improved.
- the computer device 101 can obtain the quantum program to be analyzed from the local storage space; or, the quantum program to be analyzed can be obtained from any business device, such as business device 102a, business device 102b or business device 102c.
- the computer device 101 may receive a quantum analysis request sent by the service device 102a, obtain the quantum program to be analyzed carried by the quantum analysis request, perform quantum circuit analysis on the quantum program to be analyzed, and perform quantum modeling based on the analysis result and the gate association relationship between the quantum gates indicated by the quantum program to be analyzed to obtain quantum gate arrangement circuit data. Convert quantum gate arrangement circuit data into quantum processing instructions; send the quantum processing instructions to business equipment 102a, etc.
- Figure 2 is a schematic diagram of a quantum circuit processing scenario provided by an embodiment of the present application.
- the computer device can obtain the quantum program 201 to be analyzed, perform quantum circuit analysis on the quantum program to be analyzed, and obtain the circuit information included in the quantum program 201 to be analyzed.
- the circuit information is used to represent the relevant information of the quantum circuit 202 corresponding to the quantum program 201 to be analyzed, such as the N quantum circuits included in the quantum circuit 202, and the quantum gates 203 included in the N quantum circuits, etc.
- the circuit information is used to represent the quantum semantics of the quantum program 201 to be analyzed, that is, the composition information of the quantum circuit, etc.
- the quantum gates included in the N quantum circuits can be aligned to obtain the aligned quantum gate arrangement circuit data 204, which is equivalent to realizing independent modeling of the quantum circuit 202 according to the quantum semantics of the quantum program 201 to be analyzed, so that the quantum gate arrangement circuit data 204 obtained by modeling not only conforms to the gate association relationship between the quantum gates 203 included in the N quantum circuits, but also realizes the timing control of the quantum gates 203 included in the N quantum circuits, that is, quantum gate alignment, so that the process is equivalent to an independent module, which can be compatible with different quantum languages and improve the flexibility and convenience of quantum gate processing.
- the quantum gate arrangement circuit data 204 can be converted into a quantum processing instruction 205.
- the first execution sequence of the quantum gates included in the N quantum circuits in the quantum processing instruction is different from the second execution sequence in the quantum program to be analyzed.
- the first execution sequence and the second execution sequence are both used to represent the execution order of the quantum gates included in the N quantum circuits, thereby realizing seamless expansion and translation of the model, realizing timing control and realization of the quantum circuit 202, and improving the accuracy and efficiency of quantum circuit processing.
- Quantum Circuit An abstract concept that represents the circuit for operating quantum bits in a quantum computer, including the representation of quantum bit units, circuits (timelines), and the operations of various quantum logic gates. Finally, quantum measurements are usually required to read the results.
- Quantum bit a unit of measurement in quantum information science. Traditional computers use 0 and 1, and quantum computers also use 0 and 1 to represent information, but the difference is that a quantum bit can be 0 and 1 at the same time. This effect is called quantum superposition, which is also a unique feature of quantum computers.
- Quantum gate The quantum gate in this application is slightly different from the conventional quantum gate.
- the quantum gate in this application includes quantum bit gate and quantum measurement gate.
- quantum bit gate and quantum measurement gate are collectively referred to as quantum gate.
- the qubit gate is a basic quantum circuit in quantum computing that operates a small number of qubits.
- quantum gates are reversible and can be represented by a unitary matrix, where the unitary matrix represents that the Hermitian conjugate matrix is equal to the inverse matrix.
- quantum gates include but are not limited to Hadamard gates, quantum NOT (Pauli-X) gates, quantum rotation Y (Pauli-Y) gates, quantum rotation Z (Pauli-Z) gates, quantum Switch (SWAP) gate and controlled NOT (CNOT) gate, etc.
- a single-bit gate refers to a logic gate that acts on a single quantum bit.
- a single-bit gate may include but is not limited to a Hadamard gate, a Pauli-X gate, a Pauli-Y gate, and a Pauli-Z gate, and may be referred to as an h-gate.
- a two-bit gate refers to a logic gate that acts on two qubits.
- a two-bit gate may include but is not limited to a SWAP gate and a CNOT gate, and may be referred to as a cx gate.
- a multi-bit gate refers to a logic gate that acts on multiple quantum bits, which may be two or more (in this case, the multi-bit gate may be considered to include a two-bit gate), or three or more.
- the multi-bit gate may include, but is not limited to, a quantum Fredkin (CSWAP) gate, etc., and may be called a CCNOT gate or a ccx gate, etc.
- CSWAP quantum Fredkin
- Quantum language is a research direction of quantum computing. Its fields include building a set of standard assembly instruction sets based on the logic gate capabilities of quantum computers, and can continue to abstractly build more advanced computer languages. It can even mix the fields of classical computer languages to make hybrid languages.
- Decoherence The full name is quantum decoherence, also known as decoherence, which is the effect that the quantum coherence of an open quantum system in quantum mechanics is gradually lost over time due to quantum entanglement with the external environment. Decoherence will cause the interference phenomenon between quantum states to disappear, and the quantum behavior of the system will be transformed into classical behavior.
- the data involved in the embodiments of the present application can be stored in a computer device, or the data can be stored based on cloud storage technology or a blockchain network, etc., which is not limited here.
- Figure 3 is a flow chart of a method for quantum circuit processing provided in an embodiment of the present application. As shown in Figure 3, the quantum circuit processing process includes the following steps:
- Step S301 obtaining a quantum program to be analyzed, performing quantum circuit analysis on the quantum program to be analyzed, and obtaining circuit information included in the quantum program to be analyzed, the circuit information including N quantum circuits and quantum gates included in the N quantum circuits, where N is a positive integer.
- a computer device can obtain a quantum program to be parsed, wherein each quantum program has its corresponding quantum language, and the grammatical rules of the quantum language are usually expressed in the form of standard Extended Backus-Naur Form (EBNF), that is, a meta-grammar that describes a context-free method of computer programming languages and formal languages.
- EBNF Extended Backus-Naur Form
- the circuit information includes N quantum circuits and quantum gates included in the N quantum circuits; N is a positive integer; each quantum gate is located in one or at least two quantum circuits, for example, a single-bit gate is located in one quantum circuit, a two-bit gate is located in two quantum circuits, and a multi-bit gate is located in two or more quantum circuits.
- a multi-bit gate refers to a logic gate that acts on multiple quantum bits, which can be two or more (in this case, the multi-bit gate can be considered to include a two-bit gate), or three or more, which can be specifically defined based on needs.
- the circuit information is used to represent the relevant information of the quantum circuit corresponding to the quantum program to be analyzed, and is used to represent the initial time frame corresponding to the quantum gates included in the N quantum circuits in the quantum program to be analyzed, which is equivalent to the circuit expression of the quantum program to be analyzed.
- the time frame is only used to represent the processing order of the corresponding quantum gates, and is not used to represent the processing time of the corresponding quantum gates. That is, the time lengths between two adjacent time frames may be different, such as the time length from time frame 1 to time frame 2 and the time length from time frame 2 to time frame 3 may be the same or different.
- FIG4 is a schematic diagram of a program parsing process provided by an embodiment of the present application.
- a computer device can perform lexical analysis on a quantum program to be parsed to obtain quantum keywords in the quantum program to be parsed; based on the quantum keywords, a grammatical analysis is performed on the quantum program to be parsed to obtain circuit information included in the quantum circuit to be parsed.
- the above-mentioned lexical analysis can be performed by a lexical analyzer, and the grammatical analysis can be performed by a grammatical analyzer, wherein the lexical analyzer and the grammatical analyzer can be pre-built.
- the program language type of the quantum program to be parsed can be obtained, and the quantum keywords corresponding to the program language type can be obtained, wherein the quantum keywords can include gate processing keywords.
- the quantum keywords can also include gate definition keywords, wherein the gate processing keywords are used to indicate the execution of the quantum gate, and the gate definition keywords are used to initialize the quantum gate. That is to say, only the relevant code statements for indicating the execution of the quantum gate can be obtained, and on this basis, the code statements for initializing the quantum gate can also be obtained.
- the gate correlation relationship between quantum gates refers to the dependence of quantum gates on other quantum gates in a quantum circuit, which can be called a dependency relationship.
- the quantum gate that depends on the other quantum gate will be affected by the arrangement of the quantum gate that depends on it.
- the timing frame corresponding to the quantum gate that depends on the other quantum gate is after the timing frame corresponding to the quantum gate that depends on it.
- Alignment can refer to aligning quantum gates on a time frame according to specific rules.
- a computer device can perform front partial order alignment on the quantum gates included in the N quantum circuits based on the gate association relationship between the quantum gates included in the N quantum circuits to obtain aligned quantum gate arrangement circuit data.
- the pre-partial order alignment refers to aligning the first quantum gate among the quantum gates included in each quantum circuit, and arranging the subsequent quantum gates included in the N quantum circuits without changing the properties of the quantum circuit, that is, without changing the gate correlation relationship between the quantum gates included in the N quantum circuits.
- the timing position corresponding to the first quantum gate among the quantum gates included in the N quantum circuits can be used as the first reference timing position, and based on the correlation relationship between the quantum gates included in the N quantum circuits, the quantum gates included in the N quantum circuits are aligned to the first reference timing position to obtain the aligned quantum gate arrangement circuit data; the first quantum gate refers to the first processed quantum gate indicated by the circuit information.
- the timing position corresponding to the first quantum gate among the quantum gates included in the N quantum circuits is used as the first reference timing position, that is, the first quantum gate can be kept unchanged.
- the first quantum gate is quantum gate 50a.
- FIG. 7 is a quantum gate arrangement schematic diagram 1 provided in an embodiment of the present application.
- each quantum gate in the quantum gate arrangement circuit data 701 conforms to the quantum directed graph model, and each quantum gate is aligned to the first reference timing position (i.e., time frame 701a), which reduces the running time of the quantum circuit, and can make the running process of the quantum circuit under the condition of quantum bit coherence as much as possible, thereby reducing the error caused by the limited coherence time of the quantum bit, and reducing the error of the quantum bit gate to a certain extent, thereby improving the accuracy and efficiency of quantum circuit processing and the efficiency of quantum gate processing.
- the first reference timing position i.e., time frame 701a
- quantum gate 50e and quantum gate 50f correspond to adjacent time frames, namely, time frame 701d and time frame 701e.
- quantum gate 50c is the first quantum gate in quantum circuit q0, and should be aligned to the first reference timing position (i.e., time frame 701a), and quantum gate 50c depends on quantum gate 50b located in quantum circuit q1 and quantum circuit q2, and quantum gate 50b depends on quantum gate 50a also located in quantum circuit q1, therefore, quantum gate 50c should be located after time frame 701a of quantum gate 50a and time frame 701b of quantum gate 50b, that is, quantum gate 50c corresponds to time frame 701c, etc.
- the pre-partial order alignment of quantum gates included in N quantum circuits can be achieved to obtain quantum gate arrangement circuit data.
- a computer device can perform post-partial order alignment on the quantum gates included in the N quantum circuits based on the gate correlation relationship between the quantum gates included in the N quantum circuits to obtain aligned quantum gate arrangement circuit data.
- post-partial order alignment refers to aligning the last quantum gate among the quantum gates included in each quantum circuit, and arranging the subsequent quantum gates included in the N quantum circuits without changing the properties of the quantum circuit, that is, without changing the gate correlation relationship between the quantum gates included in the N quantum circuits.
- the timing position corresponding to the second quantum gate among the quantum gates included in the N quantum circuits is used as the second reference timing position, and based on the correlation relationship between the quantum gates included in the N quantum circuits, the quantum gates included in the N quantum circuits are aligned to the second reference timing position to obtain the aligned quantum gate arrangement circuit data; the second quantum gate refers to the last processed quantum gate indicated by the circuit information.
- the timing position corresponding to the second quantum gate among the quantum gates included in the N quantum circuits is used as the second reference timing position, that is, the second quantum gate can be kept unchanged.
- the second quantum gate is quantum gate 50i.
- FIG. 8 is a second schematic diagram of a quantum gate arrangement provided in an embodiment of the present application.
- each quantum gate in the quantum gate arrangement circuit data 801 conforms to the quantum directed graph model, and each quantum gate is aligned to the second reference timing position (i.e., time frame 801e), which reduces the running time of the quantum circuit, and can make the running process of the quantum circuit under the condition of quantum bit coherence as much as possible, thereby reducing the error caused by the limited coherence time of the quantum bit, and reducing the error of the quantum bit gate to a certain extent, thereby improving the accuracy and efficiency of quantum circuit processing and the efficiency of quantum gate processing.
- the second reference timing position i.e., time frame 801e
- quantum gate 50e and quantum gate 50f correspond to adjacent time frames, namely, time frame 801d and time frame 801e.
- quantum gate 50b is adjacent to quantum gate 50h in quantum circuit q2, and quantum gate 50b depends on quantum gate 50c, and quantum gate 50c depends on quantum gate 50e. Therefore, the time frame of quantum gate 50b should be located before time frame 801c of quantum gate 50c and time frame 801d of quantum gate 50e, that is, time frame 801b is not adjacent to time frame 801d of quantum gate 50h. Similarly, the post-partial order alignment of quantum gates included in N quantum circuits can be achieved to obtain quantum gate arrangement circuit data.
- the gate association relationship between the quantum gates included in the N quantum circuits may include a pre-order association relationship and a post-order association relationship.
- the pre-order association relationship is used to indicate the quantum gates that need to wait for execution when each quantum gate is executed; the post-order association relationship is used to indicate the quantum gates that can be triggered after each quantum gate is executed.
- the pre-order association relationship can be used to realize quantum gate arrangement method 1; the post-order association relationship can be used to realize quantum gate arrangement method 2.
- a computer device can obtain M quantum measurement gates included in N quantum circuits, where M is a positive integer, and at least a portion of the N quantum circuits includes at least one quantum measurement gate. Based on the gate association relationship between the quantum gates included in the N quantum circuits, the execution order of the quantum bit gates in the quantum gates included in the N quantum circuits is maintained, and the M quantum measurement gates are aligned to obtain aligned quantum gate arrangement circuit data; the M quantum measurement gates in the quantum gate arrangement circuit data are in the same time frame; the quantum bit gate refers to the quantum gates included in the N quantum circuits, except the M quantum measurement gates; the time frame is used to represent the execution order of the quantum gates included in the N quantum circuits.
- FIG. 9 is a schematic diagram of a quantum gate arrangement provided in an embodiment of the present application.
- the computer device can align the quantum measurement gates corresponding to the N quantum circuits (such as the quantum measurement gate 50f in the quantum circuit q0, the quantum measurement gate 50g in the quantum circuit q1, and the quantum measurement gate 50i in the quantum circuit q2) to obtain an initial measurement alignment model 901, delete the idle time frames in the N quantum circuits, and obtain quantum gate arrangement circuit data 902.
- the quantum bit gates included in the N quantum circuits are maintained, and the quantum measurement gates corresponding to the N quantum circuits are aligned and placed after the quantum bit gates included in the N quantum circuits to obtain quantum gate arrangement circuit data 902, so that each quantum measurement gate in the quantum gate arrangement circuit data 902 is located in the same time frame.
- M quantum measurement gates included in N quantum circuits can be obtained, where M is a positive integer, and at least a portion of the N quantum circuits include at least one quantum measurement gate.
- Each quantum circuit does not include a quantum measurement gate or includes at least one quantum measurement gate.
- the execution order of the quantum bit gates in the quantum gates included in the N quantum circuits is maintained, and the M quantum measurement gates are aligned to obtain measurement alignment data; the M quantum measurement gates in the quantum gate arrangement circuit data are in the same time frame.
- the process of acquiring the measurement alignment data may refer to the process of generating quantum gate arrangement circuit data in quantum gate arrangement mode 3.
- the measurement alignment data obtained based on the example shown in FIG. 5 is the quantum gate arrangement circuit data 902 shown in FIG. 9 .
- FIG. 10 is a schematic diagram of a quantum gate arrangement provided in an embodiment of the present application.
- the M quantum measurement gates can be kept in the same time frame in the measurement alignment data, and the quantum bit gates can be aligned in the front partial order using the above-mentioned quantum gate arrangement method 1 to obtain quantum gate arrangement circuit data 1001; or, the M quantum measurement gates can be kept in the same time frame in the measurement alignment data, and the quantum bit gates can be aligned in the back partial order using the above-mentioned quantum gate arrangement method 2 to obtain quantum gate arrangement circuit data 1002.
- the computer device may obtain the bit coherence time of the quantum gates included in the N quantum circuits, and obtain the longest processing time corresponding to the N quantum circuits. If the bit coherence time is less than the longest processing time, the timing position corresponding to the second quantum gate in the quantum gates included in the N quantum circuits is used as the second reference timing position, and based on the correlation between the quantum gates included in the N quantum circuits, the quantum gates included in the N quantum circuits are aligned to the second reference timing position to obtain the aligned quantum gate arrangement circuit data; the second quantum gate refers to the last processed quantum gate indicated by the circuit information.
- the computer device can obtain the bit coherence of the quantum gates included in the N quantum circuits.
- the longest processing time corresponding to the N quantum circuits is obtained. If the bit coherence time is less than the longest processing time, that is, when the N quantum circuits are finally measured, some quantum gates may have been decoherent, then any of the above quantum gate arrangement method 1, quantum gate arrangement method 2 or quantum gate arrangement method 4 is used to align the quantum gates included in the N quantum circuits to obtain quantum gate arrangement circuit data.
- any one of the above-mentioned quantum gate arrangement method 1, quantum gate arrangement method 2, quantum gate arrangement method 3 or quantum gate arrangement method 4 is used to align the quantum gates included in the N quantum circuits to obtain quantum gate arrangement circuit data.
- the above-mentioned quantum gate arrangement method 1 or quantum gate arrangement method 2 is used to align the quantum gates included in the N quantum circuits to obtain quantum gate arrangement circuit data; if the bit coherence time is greater than or equal to the longest processing time, the above-mentioned quantum gate arrangement method 3 is used to align the quantum gates included in the N quantum circuits to obtain quantum gate arrangement circuit data.
- the bit coherence time of the quantum gate may be ignored and the quantum gate arrangement method 4 may be directly used to align the quantum gates included in the N quantum circuits to obtain quantum gate arrangement circuit data, etc.
- the calling conditions of the above-mentioned quantum gate arrangement methods may be updated as needed and are not limited here.
- the computer device may obtain circuit operation data of the quantum circuit corresponding to the quantum program to be analyzed, and determine the circuit optimization direction of the quantum circuit based on the circuit operation data.
- the circuit optimization direction may include but is not limited to time optimization direction, measurement optimization direction, and overall optimization direction.
- the target quantum alignment method corresponding to the circuit optimization direction can be obtained. Based on the gate correlation relationship between the quantum gates included in the N quantum circuits, the quantum gates included in the N quantum circuits are aligned using the target quantum alignment method to obtain the aligned quantum gate arrangement circuit data.
- the target quantum alignment corresponding to the time optimization direction is the above-mentioned quantum gate arrangement method one and quantum gate arrangement method two;
- the target quantum alignment corresponding to the measurement optimization direction is the above-mentioned quantum gate arrangement method three;
- the target quantum alignment corresponding to the comprehensive optimization direction is the above-mentioned quantum gate arrangement method four, etc.
- the quantum gate arrangement mode 1 or the quantum gate arrangement mode 2 is determined as the target quantum alignment mode, etc.
- the implementation process of the target quantum alignment mode can be based on the correspondence between the above-mentioned circuit optimization direction and the quantum gate arrangement mode, referring to the implementation process of the above-mentioned quantum gate arrangement mode 1 to quantum gate arrangement mode 4, which will not be repeated here.
- a computer device may obtain a timing control parameter, obtain a quantum gate arrangement corresponding to the timing control parameter, adopt the quantum gate arrangement corresponding to the timing control parameter, execute a gate association relationship between quantum gates included in the N quantum circuits, align the quantum gates included in the N quantum circuits, and obtain the aligned quantum gate arrangement circuit data.
- a timing control option can be output, and in response to a selection operation on a target timing control option in the timing control option, the timing control parameters carried by the target timing control option are obtained, making the timing control of quantum gates of the quantum program to be analyzed easier and improving the flexibility and convenience of quantum circuit processing.
- Step S303 generating a quantum processing instruction according to the quantum gate arrangement circuit data, wherein the execution order of the quantum gates included in the N quantum circuits specified in the quantum processing instruction is different from the execution order of the quantum gates included in the N quantum circuits specified in the quantum program to be analyzed.
- the first execution sequence refers to the execution order of the quantum gates included in the N quantum circuits in the quantum processing instructions, such as which quantum gates are executed in the same time frame, the order of different time frames, etc.
- the second execution sequence refers to the execution order of the quantum gates included in the N quantum circuits in the quantum program to be analyzed. order, thereby achieving the timing rearrangement of the quantum gates in the quantum circuit.
- the P quantum gates included in the quantum gate arrangement circuit data and the quantum circuit corresponding to each quantum gate can be obtained; the instruction generation language can be obtained, and the instruction template corresponding to the instruction generation language can be obtained.
- the instruction generation language is eqasm
- the instruction template of the instruction generation language eqasm includes the declaration template: SMIS Sd (used to declare a single-bit gate) and SMIS Td (used to declare a two-bit gate), etc., where d is used to represent the label of the corresponding quantum gate
- the instruction template can also include the execution template: H (used to represent a single-bit gate), CNOT (used to represent a two-bit gate), MEASZ (used to represent a quantum measurement gate) and “
- the above declaration template can be used to generate declaration instructions for P quantum gates and the quantum circuit corresponding to each quantum gate to obtain a quantum declaration instruction, as shown below:
- quantum applications can be performed based on quantum information.
- encryption parameters can be obtained based on quantum information and the measurement results of the measurement processing of the quantum program to be analyzed, and the encryption parameters can be used to encrypt the communication data to obtain encrypted data, which can then be transmitted.
- the timing control parameters may be obtained by referring to the relevant description in step S302 of FIG. 3 to determine the quantum gate arrangement for timing rearrangement of the quantum program to be analyzed.
- Step S1104 re-arrange the timing of the circuit information.
- the quantum gate arrangement method obtained in step S1103 is adopted to rearrange the circuit information in time sequence to generate quantum gate arrangement circuit data.
- Step S1105 Generate quantum processing instructions.
- a program analysis module 12 is used to perform quantum circuit analysis on the quantum program to be analyzed to obtain circuit information included in the quantum program to be analyzed, where the circuit information includes N quantum circuits and quantum gates included in the N quantum circuits, where N is a positive integer;
- a quantum arrangement module 13 configured to align the quantum gates included in the N quantum circuits based on the gate association relationship between the quantum gates included in the N quantum circuits, and obtain aligned quantum gate arrangement circuit data;
- the instruction generation module 14 is used to generate a quantum processing instruction according to the quantum gate arrangement circuit data, wherein the execution order of the quantum gates included in the N quantum circuits specified in the quantum processing instruction is different from the execution order of the quantum gates included in the N quantum circuits specified in the quantum program to be analyzed.
- the program analysis module 12 includes:
- a language parsing unit 12a used to obtain the program language type of the quantum program to be parsed
- a key acquisition unit 12b is used to acquire quantum keywords corresponding to the programming language type
- a code recognition unit 12c is used to recognize a quantum code segment in a quantum program to be analyzed based on quantum keywords, where the quantum code segment includes M code statements, where M is a positive integer;
- the circuit analysis unit 12d is used to perform quantum circuit analysis on the M code statements based on the statement order of the M code statements to obtain circuit information included in the quantum program to be analyzed, and the circuit information is used to characterize the quantum circuit indicated by the M code statements.
- the program analysis module 12 includes:
- a model parsing unit 12e is used to input the quantum program to be parsed into the program parsing model for parsing, and determine the type of program language corresponding to the quantum program to be parsed;
- a statement detection unit 12f is used to detect the code statements included in the quantum program to be parsed based on the program language type in the program parsing model, and obtain the quantum gate processing statements in the code statements included in the quantum program to be parsed;
- the information acquisition unit 12g is used to perform quantum circuit analysis on the quantum gate processing statement based on the statement sequence of the quantum gate processing statement to obtain circuit information included in the quantum program to be analyzed, where the circuit information is used to characterize the quantum circuit indicated by the quantum gate processing statement.
- the device 1200 further includes:
- a directed construction module 15 is used to use the quantum gates included in the N quantum circuits as nodes, determine the edges between the quantum gates included in the N quantum circuits based on the circuit information, and construct the nodes and the edges into a quantum directed graph model; the quantum directed graph model is used to indicate the gate association relationship between the quantum gates included in the N quantum circuits;
- the quantum arrangement module 13 is specifically used to align the quantum gates included in the N quantum circuits based on the quantum directed graph model to obtain aligned quantum gate arrangement circuit data.
- the quantum arrangement module 13 includes:
- the first arrangement unit 13a is used to use the timing position corresponding to the first quantum gate among the quantum gates included in the N quantum circuits as the first reference timing position, and based on the correlation relationship between the quantum gates included in the N quantum circuits, align the quantum gates included in the N quantum circuits to the first reference timing position to obtain the aligned quantum gate arrangement circuit data; the first quantum gate refers to the first processed quantum gate indicated by the circuit information.
- the quantum arrangement module 13 includes: a second arrangement unit 13b, which is used to use the timing position corresponding to the second quantum gate in the quantum gates included in the N quantum circuits as the second reference timing position, based on the N quantum circuits.
- the correlation relationship between the quantum gates included in the circuit is to align the quantum gates included in the N quantum circuits to the second reference timing position to obtain the aligned quantum gate arrangement circuit data, and the second quantum gate refers to the last processed quantum gate indicated by the circuit information.
- the quantum arrangement module 13 includes: a coherent analysis unit 13c, which is used to obtain the bit coherence time of the quantum gates included in the N quantum circuits, and obtain the longest processing time corresponding to the N quantum circuits.
- the second arrangement unit 13b is further used for, if the bit coherence time is less than the longest processing time, taking the timing position corresponding to the second quantum gate among the quantum gates included in the N quantum circuits as the second reference timing position, and based on the correlation relationship between the quantum gates included in the N quantum circuits, aligning the quantum gates included in the N quantum circuits to the second reference timing position to obtain the aligned quantum gate arrangement circuit data, wherein the second quantum gate refers to the last processed quantum gate indicated by the circuit information.
- the quantum arrangement module 13 includes:
- the measurement acquisition unit 13d is used to acquire M quantum measurement gates included in the N quantum circuits, where M is a positive integer, and at least a part of the N quantum circuits includes at least one quantum measurement gate.
- the third arrangement unit 13e is used to maintain the execution order of the quantum bit gates in the quantum gates included in the N quantum circuits based on the gate association relationship between the quantum gates included in the N quantum circuits, align the M quantum measurement gates, and obtain the aligned quantum gate arrangement circuit data, the M quantum measurement gates in the quantum gate arrangement circuit data are in the same time frame, the quantum bit gate refers to the quantum gate included in the N quantum circuits, except the M quantum measurement gates, and the time frame is used to represent the execution order of the quantum gates included in the N quantum circuits.
- the quantum arrangement module 13 includes:
- the measurement acquisition unit 13d is further used to acquire M quantum measurement gates included in the N quantum circuits, where M is a positive integer, and at least a part of the N quantum circuits includes at least one quantum measurement gate;
- the initial arrangement unit 13f is used to align the M quantum measurement gates based on the gate association relationship between the quantum gates included in the N quantum circuits, maintain the execution order of the quantum bit gates in the quantum gates included in the N quantum circuits, and obtain measurement alignment data.
- the M quantum measurement gates in the quantum gate arrangement circuit data are in the same time frame;
- the fourth arrangement unit 13g is used to keep the M quantum measurement gates in the same time frame in the measurement alignment data based on the gate association relationship between the quantum gates included in the N quantum circuits, align the quantum bit gates, and obtain the aligned quantum gate arrangement circuit data.
- the quantum arrangement module 13 includes:
- the optimization determination unit 13h is used to obtain the circuit operation data of the quantum circuit corresponding to the quantum program to be analyzed, and determine the circuit optimization direction of the quantum circuit based on the circuit operation data.
- the gate arrangement unit 13i is used to obtain the target quantum alignment method corresponding to the circuit optimization direction, and align the quantum gates included in the N quantum circuits using the target quantum alignment method based on the gate association relationship between the quantum gates included in the N quantum circuits to obtain the aligned quantum gate arrangement circuit data.
- the instruction generation module 14 includes:
- the gate analysis unit 14a is used to obtain P quantum gates included in the quantum gate arrangement circuit data, and the quantum circuit corresponding to each quantum gate; P is a positive integer.
- the instruction generation unit 14b is used to generate quantum processing instructions for the P quantum gates based on the target time frames where the P quantum gates are located in the quantum gate arrangement circuit data and the quantum circuit corresponding to each quantum gate.
- the quantum application module 17 is used to perform quantum applications based on quantum information.
- the computer device in the embodiment of the present application may include: one or more processors 1301, a memory 1302, and an input-output interface 1303.
- the processor 1301, the memory 1302, and the input-output interface 1303 are connected via a bus 1304.
- the memory 1302 is used to store a computer program, which includes computer-readable instructions, and the input-output interface 1303 is used to receive data and output data, such as for data interaction between a computer device and a business device, or for data interaction between a computer device and a quantum device;
- the processor 1301 is used to execute the program instructions stored in the memory 1302.
- the processor 1301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
- CPU central processing unit
- DSP digital signal processors
- ASIC application-specific integrated circuits
- FPGA field-programmable gate arrays
- a general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
- the computer device can execute the implementation methods provided by the various steps in FIG. 3 through its built-in functional modules.
- the implementation methods provided by the various steps in FIG. 3 please refer to the implementation methods provided by the various steps in FIG. 3 , which will not be repeated here.
- the embodiment of the present application provides a computer device, including: a processor, an input and output interface, and a memory.
- the processor obtains computer-readable instructions in the memory, executes the various steps of the method shown in Figure 3, and performs quantum circuit processing operations.
- the embodiment of the present application realizes obtaining a quantum program to be analyzed, performing quantum circuit analysis on the quantum program to be analyzed, and obtaining circuit information included in the quantum program to be analyzed, wherein the circuit information includes N quantum circuits and quantum gates included in the N quantum circuits, where N is a positive integer; based on the gate association relationship between the quantum gates included in the N quantum circuits, the quantum gates included in the N quantum circuits are aligned to obtain aligned quantum gate arrangement circuit data; and according to the quantum gate arrangement circuit data, a quantum processing instruction is generated, wherein the execution order of the quantum gates included in the N quantum circuits specified in the quantum processing instruction is different from the execution order of the quantum gates included in the N quantum circuits specified in the quantum program to be analyzed.
- the quantum circuit can be directly analyzed, that is, the quantum program to be analyzed corresponding to the quantum circuit, so that the automatic analysis of the quantum circuit can be realized, and based on the obtained quantum circuit, the alignment of each quantum gate is realized, and the timing control of the quantum gate is realized to suppress the noise influence caused by the characteristics of quantum and improve the accuracy of quantum computing results.
- the gate correlation relationship of the quantum gate is independently modeled to improve the efficiency and accuracy of quantum circuit processing, and improve the convenience and flexibility of quantum gate processing.
- the present application also provides a computer-readable storage medium, which stores a computer-readable storage medium.
- the computer-readable instructions are suitable for being loaded by the processor and executing the quantum circuit processing method provided by each step in FIG. 3.
- the description of the beneficial effects of adopting the same method will not be repeated.
- the computer-readable instructions can be deployed to be executed on one computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network.
- the computer-readable storage medium may be the quantum circuit processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device.
- the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device.
- the computer-readable storage medium may also include both the internal storage unit of the computer device and the external storage device.
- the computer-readable storage medium is used to store the computer-readable instructions and other programs and data required by the computer device.
- the computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
- the embodiment of the present application also provides a computer program product, which includes computer-readable instructions, which are stored in a computer-readable storage medium.
- the processor of the computer device reads the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions, so that the computer device executes the method provided in the various optional methods in Figure 3, and directly analyzes the quantum circuit, that is, the quantum program to be analyzed corresponding to the quantum circuit, so that the automatic analysis of the quantum circuit can be realized, and based on the obtained quantum circuit, the alignment of each quantum gate is realized, and the timing control of the quantum gate is realized to suppress the noise influence caused by the characteristics of the quantum and improve the accuracy of the quantum calculation results.
- the gate association relationship of the quantum gate is independently modeled to improve the efficiency and accuracy of quantum circuit processing, and improve the convenience and flexibility of quantum gate processing.
- each process and/or box of the method flow chart and/or structural schematic diagram, as well as the combination of the processes and/or boxes in the flow chart and/or block diagram can be implemented by computer-readable instructions.
- These computer-readable instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable quantum circuit processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable quantum circuit processing device generate a device for implementing the function specified in one process or multiple processes of the flow chart and/or one box or multiple boxes of the structural schematic diagram.
- These computer-readable instructions can also be stored in a computer-readable memory that can guide a computer or other programmable quantum circuit processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, which implements the function specified in one process or multiple processes of the flow chart and/or one box or multiple boxes of the structural schematic diagram.
- These computer-readable instructions can also be loaded onto a computer or other programmable quantum circuit processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more blocks in the structural diagram.
Landscapes
- Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Mathematical Analysis (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Condensed Matter Physics & Semiconductors (AREA)
- Computational Mathematics (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Artificial Intelligence (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
一种量子线路处理方法,由计算机设备执行,包括:获取待解析量子程序,对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路,及所述N个量子线路所包括的量子门,N为正整数(S301);基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据(S302);及根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序(S303)。
Description
相关申请
本申请要求2023年6月15日申请的,申请号为2023107153416,名称为“量子线路处理方法、装置、计算机、存储介质及程序产品”的中国专利申请的优先权,在此将其全文引入作为参考。
本申请涉及计算机技术领域,尤其涉及一种量子线路处理方法、装置、计算机、存储介质及程序产品。
超导量子芯片现阶段处于含有噪声的中型量子(Noisy Intermediate-Scale Quantum,NISQ)时代,具有以下特点:量子比特相干时间有限,量子比特门具有误差(保真度有限),量子比特测量操作会引入系统误差。其中,超导量子计算通过运行在超导量子芯片上的量子电路实现,电路通常包含许多单量子比特门和双量子比特门等,基于此,需要对量子电路进行时序控制,目前,是通过用户手动输入大量的限制条件,对量子电路进行时序控制,导致量子电路处理的效率较低,且量子门处理较为复杂。而且,目前在对量子电路的时序控制中,限制了对齐量子门的规则,导致的量子电路的灵活性较差。
发明内容
根据本申请的各种实施例,提供一种量子线路处理方法、装置、计算机、存储介质及程序产品。
本申请实施例一方面提供了一种量子线路处理方法,由计算机设备执行,包括:
获取待解析量子程序,对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路,及所述N个量子线路所包括的量子门,N为正整数;
基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及
根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序。
本申请实施例一方面提供了一种量子线路处理装置,该装置包括:
程序获取模块,用于获取待解析量子程序;
程序解析模块,用于对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路及所述N个量子线路所包括的量子门,N为正整数;
量子排布模块,用于基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及
指令生成模块,用于根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序。
本申请实施例一方面提供了一种计算机设备,包括处理器和存储器,所述存储器用于存储计算机可读指令,所述处理器用于调用所述计算机可读指令,以执行本申请任一实施例的方法;
本申请实施例一方面提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机可读指令,所述计算机可读指令由处理器加载并执行,以使得所述处理器执行本申请任一实施例的方法。
本申请实施例一方面提供了一种计算机程序产品,包括计算机可读指令,所述计算机可读指令被处理器执行时实现本申请任一实施例的方法。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
为了更清楚地说明本申请实施例或传统技术中的技术方案,下面将对实施例或传统技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据公开的附图获得其他的附图。
图1是本申请实施例提供的一种量子线路处理的网络交互架构图;
图2是本申请实施例提供的一种量子线路处理场景示意图;
图3是本申请实施例提供的一种量子线路处理的方法流程图;
图4是本申请实施例提供的一种程序解析流程示意图;
图5是本申请实施例提供的一种电路解析场景示意图;
图6是本申请实施例提供的一种有向图构建场景示意图;
图7是本申请实施例提供的一种量子门排布示意图一;
图8是本申请实施例提供的一种量子门排布示意图二;
图9是本申请实施例提供的一种量子门排布示意图三;
图10是本申请实施例提供的一种量子门排布示意图四;
图11是本申请实施例提供的一种量子解析简易流程图;
图12是本申请实施例提供的一种量子线路处理装置示意图;
图13是本申请实施例提供的一种计算机设备的结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
其中,若在本申请中需要收集对象(如用户等)数据,则在收集前、收集中,显示提示界面或者弹窗,该提示界面或者弹窗用于提示用户当前正在搜集某些数据,如待解析量子程序等,仅仅在获取到用户对该提示界面或者弹窗发出确认操作后,开始执行数据获取的相关的步骤,否则结束。而且,对于获取到的用户数据,会在合理合法的场景或用途等上进行使用。可选的,在一些需要使用用户数据但未得到用户授权的场景中,还可以向用户请求授权,在授权通过时,再使用用户数据。
在本申请实施例中,请参见图1,图1是本申请实施例提供的一种量子线路处理的网络交互架构图,如图1所示,计算机设备101可以获取待解析量子程序,对待解析量子程序进行量子电路解析,对待解析量子程序所对应的量子电路进行建模,得到量子门排布线路数据,实现对量子电路的时序控制,而且,该过程实现了对量子电路的独立建模,可以适配不同的量子语言,可以提高时序控制的灵活性。进而将量子门排布线路数据转换成量子处理指令,该量子处理指令是指物理层面的指令,其中,N个量子线路所包括的量子门,在量子处理指令中的第一执行时序,不同于在待解析量子程序中的第二执行时序,实现对量子电路的时序排布,提高量子电路管理的灵活性,提高量子门处理的便捷性及效率。可选的,计算机设备101可以从本地存储空间中获取待解析量子程序;或者,可以从任意一个业务设备中获取待解析量子程序,如业务设备102a、业务设备102b或业务设备102c等。例如,计算机设备101可以接收业务设备102a所发送的量子解析请求,获取该量子解析请求所携带的待解析量子程序,对待解析量子程序进行量子电路解析,并基于解析结果及待解析量子程序所指示的量子门之间的门关联关系进行量子建模,得到量子门排布线路数据,
将量子门排布线路数据转换成量子处理指令;将量子处理指令发送至业务设备102a等。
可以理解的是,本申请实施例中所提及的业务设备也可以认为是一种计算机设备,本申请实施例中的计算机设备包括但不限于终端设备或服务器。换句话说,计算机设备可以是服务器或终端设备,也可以是服务器和终端设备组成的系统。其中,以上所提及的终端设备可以是一种电子设备,包括但不限于手机、平板电脑、台式电脑、笔记本电脑、掌上电脑、车载设备、增强现实/虚拟现实(Augmented Reality/Virtual Reality,AR/VR)设备、头盔显示器、智能电视、可穿戴设备、智能音箱、数码相机、摄像头及其他具备网络接入能力的移动互联网设备(mobile internet device,MID),或者火车、轮船、飞行等场景下的终端设备等。如图1中所示,终端设备可以是一种笔记本电脑(如业务设备102b所示)、手机(如业务设备102c所示)或业务设备(如对象设备102a所示)等,图1仅例举出部分的设备,可选的,该业务设备102a是指位于交通工具103中的设备。其中,以上所提及的服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、车路协同、内容分发网络(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。其中,计算机设备可以是上述终端设备或服务器,与量子电路相连接,或者集成有量子电路;或者,计算机设备可以是携带量子的量子设备,如量子芯片等。
具体的,请参见图2,图2是本申请实施例提供的一种量子线路处理场景示意图。如图2所示,计算机设备可以获取待解析量子程序201,对待解析量子程序进行量子电路解析,得到待解析量子程序201所包括的电路信息,该电路信息用于表示待解析量子程序201所对应的量子电路202的相关信息,如该量子电路202所包括的N个量子线路,以及N个量子线路所包括的量子门203等,该电路信息用于表示待解析量子程序201的量子语义,也就是量子电路的组成信息等。进一步,可以基于N个量子线路所包括的量子门203之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据204,也就是相当于,根据待解析量子程序201的量子语义,实现对量子电路202的独立建模,使得建模得到的量子门排布线路数据204即符合N个量子线路所包括的量子门203之间的门关联关系,又实现对N个量子线路所包括的量子门203的时序控制,即量子门对齐,使得该过程相当于一个独立的模块,可以兼容适配不同的量子语言,提高量子门处理的灵活性及便捷性。并且进一步,可以将量子门排布线路数据204转换为量子处理指令205,N个量子线路所包括的量子门,在量子处理指令中的第一执行时序,不同于在待解析量子程序中的第二执行时序,该第一执行时序与第二执行时序,均是用于表示N个量子线路所包括的量子门的执行顺序,实现对模型的无缝扩展转译,实现对量子电路202的时序控制及实现,提高量子线路处理的精确性及效率。
进一步,对本申请中所涉及到的关键词汇进行如下解释:
量子电路(Quantum Circuit):是一种抽象概念,表示对量子计算机中量子比特进行操作的线路,包括量子比特单位的表征、线路(时间线),以及各种量子逻辑门的运算,最后通常需要使用量子测量将结果读取出来。
量子比特:量子信息学中的计量单位。传统电脑使用的是0和1,量子计算机中也用0和1表征信息,但不同的是,量子比特可以同时是0和1,这种效果叫量子叠加,也是量子计算机独有的特性。
量子门:本申请中的量子门与常规的量子门有些微的区别,本申请中的量子门包括量子比特门及量子测量门,为了统一称呼,将量子比特门与量子测量门统称为量子门。
其中,量子比特门:是量子计算中一个基本的、操作一个较小数量的量子比特的量子电路,和传统的逻辑门不同的是,量子门是可逆的,可以使用幺正矩阵表示,其中,该幺正矩阵表示的就是厄米共轭矩阵等于逆矩阵。其中,量子门包括但不限于阿达玛(Hadamard)门、量子非(Pauli-X)门、量子旋转Y(Pauli-Y)门、量子旋转Z(Pauli-Z)门、量子
交换(SWAP)门以及受控非(CNOT)门等。
单比特门,表示作用于单个量子比特的逻辑门。单比特门可以包括但不限于Hadamard门、Pauli-X门、Pauli-Y门及Pauli-Z门等,可以记作h门。
双比特门,表示作用于两个量子比特的逻辑门。双比特门可以包括但不限于SWAP门及CNOT等,可以记作cx门。
多比特门,表示作用于是指作用于多个量子比特的逻辑门,该多个可以是两个或两个以上(此时,多比特门可以认为包括双比特门),也可以是三个或三个以上。多比特门可以包括但不限于量子弗雷德金(CSWAP)门等,可以称为CCNOT门或ccx门等。
量子语言(Quantum Language):量子语言是量子计算的一个研究方向,其领域包括根据量子计算机的逻辑门能力,构建出一套标准的汇编指令集,并可以继续抽象构建更为高级的计算机语言,甚至可以混合经典计算机语言的领域,做成混合型语言。
退相干(decoherence):全称量子退相干,又称去相干,是量子力学中开放量子系统的量子相干性因为与外在环境发生量子纠缠而随着时间逐渐丧失的效应。退相干会使量子间的干涉现象消失,使系统的量子行为转变为经典行为。
可选的,本申请实施例中所涉及的数据可以存储在计算机设备中,或者可以基于云存储技术或区块链网络等对该数据进行存储,在此不做限制。
进一步地,请参见图3,图3是本申请实施例提供的一种量子线路处理的方法流程图。如图3所示,该量子线路处理过程包括如下步骤:
步骤S301,获取待解析量子程序,对待解析量子程序进行量子电路解析,得到待解析量子程序所包括的电路信息,电路信息包括N个量子线路,及N个量子线路所包括的量子门,N为正整数。
在本申请实施例中,计算机设备可以获取待解析量子程序,其中,每个量子程序都有其对应的量子语言,量子语言的语法规则通常以标准的扩展巴克斯范式(Extended Backus-Naur Form,EBNF)的形式进行表达,即,描述计算机编程语言和形式语言的上下文无关方法的元语法。
其中,电路信息包括N个量子线路及N个量子线路所包括的量子门;N为正整数;每个量子门位于一个或至少两个量子线路中,例如,单比特门位于一个量子线路中,双比特门位于两个量子线路中,多比特门位于两个或两个以上量子线路中。可选的,多比特门是指作用于多个量子比特的逻辑门,该多个可以是两个或两个以上(此时,多比特门可以认为包括双比特门),也可以是三个或三个以上,具体可以基于需要进行定义。
其中,该电路信息用于表示待解析量子程序所对应的量子电路的相关信息,用于表示N个量子线路所包括的量子门在待解析量子程序中对应的初始时间帧等,相当于是对待解析量子程序的电路表达。其中,时间帧仅用于表示对应的量子门的处理顺序,并不用于表示对应的量子门的处理时长,也就是,不同的相邻的两个时间帧之间的时长可能不同,如时间帧1到时间帧2的时长与时间帧2到时间帧3的时长可能相同,也可能不同。
具体的,一种程序解析方法,可以参见图4,图4是本申请实施例提供的一种程序解析流程示意图。如图4所示,计算机设备可以对待解析量子程序进行词法分析,得到待解析量子程序中的量子关键词;基于量子关键词对待解析量子程序进行语法分析,得到待解析量子电路所包括的电路信息。可选的,上述词法分析可以通过词法分析器进行,语法分析可以通过语法分析器进行,其中,该词法分析器与语法分析器可以是预先构建好的。
可选的,可以获取待解析量子程序的程序语言类型,获取程序语言类型所对应的量子关键词,其中,该量子关键词可以包括门处理关键词,可选的,量子关键词还可以包括门定义关键词,其中,门处理关键词用于指示量子门的执行,门定义关键词用于初始化量子门,也就是说,可以只获取用于指示量子门的执行的相关代码语句,也可以在此基础上还获取用于初始化量子门的代码语句。
例如,假定该程序语言类型为开放量子汇编语言(open quantum assembly language,
openQASM)类型,可以获取该开放量子汇编语言类型所对应的量子关键词,该量子关键词可以包括“h”、“cx”及“measz”等门处理关键词,可选的,量子关键词还可以包括“qreg”及“creg”等门定义关键词。进一步,可以基于量子关键词识别待解析量子程序中的量子代码段;量子代码段包括M个代码语句;M为正整数,例如,假定得到量子代码段:
qreg q[4];//表示定义4个量子比特;
creg c[4];//表示用于存储测量结果的经典比特;
h q[1];//位于量子线路q1中的单比特门;
cx q[1],q[2];//位于量子线路q1与量子线路q2的双比特门;
cx q[0],q[1];//位于量子线路q0与量子线路q1的双比特门;
h q[3];//位于量子线路q3中的单比特门;
h q[0];//位于量子线路q0中的单比特门;
measz q[0]—>c[0];//测量量子线路q0,并将测量结果存储至c[0]中;
measz q[1]—>c[1];//测量量子线路q1,并将测量结果存储至c[1]中;
h q[2];//位于量子线路q2中的单比特门;
measz q[2]—>c[2];//测量量子线路q2,并将测量结果存储至c[2]中;
…
其中,由于程序代码一般是一个代码语句一个代码语句依次执行,因此,可以认为上述每一个代码语句对应一个初始时间帧。进一步,可以基于M个代码语句的语句顺序,对M个代码语句进行量子电路解析,得到待解析量子程序所包括的电路信息;电路信息用于表征M个代码语句所指示的量子电路。
具体的,参见图5,图5是本申请实施例提供的一种电路解析场景示意图。如图5所示,对待解析量子程序501进行量子电路解析,得到待解析量子程序所包括的电路信息502,以上述量子代码段为例,对M个代码语句进行量子电路解析,得到用于对待解析量子程序进行可视化表达的电路信息502。
具体的,由代码语句“qreg q[4]”可以得到量子电路中存在量子线路q0、量子线路q1、量子线路q2及量子线路q3,也就是以N为4为例,并依次确定N个量子线路所包括的量子门,如依次为位于量子线路q1的量子门50a、位于量子线路q1与量子线路q2的量子门50b、位于量子线路q0与量子线路q1的量子门50c、位于量子线路q3中的量子门50d、位于量子线路q0中的量子门50e、位于量子线路q0中的量子门50f、位于量子线路q1中的量子门50g、位于量子线路q2中的量子门50h,以及位于量子线路q2中的量子门50i等。
其中,以图5为例,N个量子线路所包括的量子门存在单比特门5021(如量子门50a及量子门50e等)、双比特门5022(如量子门50b及量子门50c等)及量子测量门5023(如量子门50f及量子门50g等)。
其中,以上仅例举了图5中所示的各个量子门中的部分量子门。可选的,N个量子线路所包括的量子门中还可以包括位于至少三个量子线路的多比特门等,此处以单比特门与双比特门为例进行描述,多比特门的处理方式可以参见双比特门。
其中,双比特门与多比特门由于同时位于多个量子线路中,因此,一个量子线路的实现可能会依赖其他量子线路的情况,也就是不能直接对N个量子线路所包括的量子门进行时序控制,可以执行步骤S302。
可选的,一种程序解析方法,计算机设备可以将待解析量子程序输入程序解析模型中进行解析,确定待解析量子程序所对应的程序语言类型。该程序解析模型是指训练好的,可以解析量子程序中用于处理量子门的代码语句的模型。
进一步,在程序解析模型中,基于程序语言类型检测待解析量子程序所包括的代码语句,得到待解析量子程序所包括的代码语句中的量子门处理语句,也就是说,可以直接获取量子门处理语句,该量子门处理语句的数量为一或至少两个,存在至少两个量子门处理语句时,至少两个量子门处理语句在待解析量子程序中可能不连续。在程序解析模型中,
基于量子门处理语句的语句顺序,对量子门处理语句进行量子电路解析,得到待解析量子程序所包括的电路信息;电路信息用于表征量子门处理语句所指示的量子电路,如图5所示的电路信息502所示。其中,电路信息502中每一列相当于一个时间帧,N个量子线路所包括的量子门在电路信息中的时间帧排列顺序,与量子门处理语句的语句顺序相同。
进一步可选的,可以以N个量子线路所包括的量子门作为节点,基于电路信息确定N个量子线路所包括的量子门之间的边,将节点与边构建成量子有向图模型;量子有向图模型用于指示N个量子线路所包括的量子门之间的门关联关系,可以将量子有向图模型记作G=(V,E),V用于表示量子门,E用于表示N个量子线路所包括的量子门之间的边(即有向边),用于表示N个量子线路所包括的量子门之间的门关联关系。
具体的,参见图6,图6是本申请实施例提供的一种有向图构建场景示意图。如图6所示,假定得到电路信息601,例如,该电路信息601可以包括待解析量子程序中的单比特门6011、双比特门6012及量子测量门6013等。其中,任意一种量子门的数量可以为一个或至少两个。可选的,该电路信息601中还可以包括待解析量子程序中的多比特门等,此处以单比特门、双比特门及量子测量门为例进行描述,仅例举待解析量子程序所对应的部分可能的量子门。
进一步,以N个量子线路所包括的量子门作为节点,基于电路信息601确定N个量子线路所包括的量子门之间的边(即有向边),将节点与边构建成量子有向图模型602。其中,图6中所示的H()用于表示单比特门,cx()用于表示双比特门,Measz()用于表示量子测量门,例如,H(q1)用于表示位于量子线路q1中的单比特门。其中,量子有向图模型602中的节点与节点之间的有向边不可逆,即,基于量子有向图模型602的有向边不可逆的特性,表示N个量子线路所包括的量子门之间的门关联关系。
步骤S302,基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
在本申请实施例中,计算机设备可以基于量子有向图模型,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
其中,量子门之间的门关联关系,是指量子门在量子电路中依赖其它的量子门,可以称之为依赖关系。具有关联关系的两个量子门,若一个量子门依赖于另一个量子门,则依赖另一个量子门的量子门,排布时受被依赖的量子门排布的影响,比如,依赖另一个量子门的量子门对应的时序帧,在被依赖的量子门对应的时序帧之后。对齐,可以是指将量子门按照特定的规则在时间帧上对齐。
具体的,一种量子门排布方式一中,计算机设备可以基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行前偏序对齐,得到对齐后的量子门排布线路数据。
其中,前偏序对齐是指将各个量子线路所包括的量子门中的第一个量子门进行对齐,并将后续的量子门在不改变量子线路性质的情况下,即不改变N个量子线路所包括的量子门之间的门关联关系的情况下,实现对N个量子线路所包括的量子门的排布。
具体的,可以以N个量子线路所包括的量子门中的第一量子门所对应的时序位置作为第一基准时序位置,基于N个量子线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第一基准时序位置进行对齐,得到对齐后的量子门排布线路数据;第一量子门是指电路信息所指示的第一个处理的量子门。
具体以图5所示的电路信息502为例,以N个量子线路所包括的量子门中的第一个量子门所对应的时序位置作为第一基准时序位置,也就是,可以保持第一个量子门不变,如图5所示,该第一个量子门为量子门50a。
进一步,在保持N个量子线路所包括的量子门的门关联关系的情况下,将N个量子线路所包括的量子门向第一基准时序位置进行对齐,得到图7所示的量子门排布线路数据701,图7是本申请实施例提供的一种量子门排布示意图一。
此时,该量子门排布线路数据701中的各个量子门之间的门关联关系符合量子有向图模型,且各个量子门均向第一基准时序位置(即时间帧701a)对齐,使得减少了量子电路的运行时间,也就可以尽可能地使得量子电路的运行过程处于量子比特相干的条件下,从而可以减少量子比特相干时间有限所造成的误差,也就在一定程序上减少量子比特门的误差,提高了量子线路处理的精确性及效率,提高量子门处理的效率。
其中,此时的量子门排布线路数据701中,在同一个量子线路中,没有量子门间的门关联关系约束的相邻两个量子门,所处的时间帧也相邻。
例如,量子线路q0中,相邻的量子门50e及量子门50f之间不存在其他量子门之间的门关联关系的约束,因此,量子门50e与量子门50f对应于相邻的时间帧,即时间帧701d与时间帧701e。
再例如,以量子门50c为例,该量子门50c为量子线路q0中的第一个量子门,本应对齐于第一基准时序位置(即时间帧701a),而该量子门50c依赖于位于量子线路q1与量子线路q2的量子门50b,而量子门50b依赖于同样位于量子线路q1中的量子门50a,因此,该量子门50c应该位于量子门50a的时间帧701a,以及量子门50b的时间帧701b之后,也就是该量子门50c对应时间帧701c等。同理,可以实现对N个量子线路所包括的量子门的前偏序对齐,得到量子门排布线路数据。
一种量子门排布方式二中,计算机设备可以基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行后偏序对齐,得到对齐后的量子门排布线路数据。
其中,后偏序对齐是指将各个量子线路所包括的量子门中的最后一个量子门进行对齐,并将后续的量子门在不改变量子线路性质的情况下,即不改变N个量子线路所包括的量子门之间的门关联关系的情况下,实现对N个量子线路所包括的量子门的排布。
具体的,以N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于N个量子线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据;第二量子门是指电路信息所指示的最后一个处理的量子门。
具体以图5所示的电路信息502为例,以N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,也就是,可以保持第二量子门不变,如图5所示,该第二量子门为量子门50i。
进一步,在保持N个量子线路所包括的量子门的门关联关系的情况下,将N个量子线路所包括的量子门向第二基准时序位置进行对齐,得到图8所示的量子门排布线路数据801,图8是本申请实施例提供的一种量子门排布示意图二。
此时,该量子门排布线路数据801中的各个量子门之间的门关联关系符合量子有向图模型,且各个量子门均向第二基准时序位置(即时间帧801e)对齐,使得减少了量子电路的运行时间,也就可以尽可能地使得量子电路的运行过程处于量子比特相干的条件下,从而可以减少量子比特相干时间有限所造成的误差,也就在一定程序上减少量子比特门的误差,提高了量子线路处理的精确性及效率,提高量子门处理的效率。
其中,此时的量子门排布线路数据801中,在同一个量子线路中,没有量子门之间的门关联关系约束的相邻两个量子门,所处的时间帧也相邻。
例如,量子门50e与量子门50f对应于相邻的时间帧,即时间帧801d与时间帧801e。
再例如,以量子门50b为例,该量子门50b在量子线路q2中与量子门50h相邻,而量子门50b依赖于量子门50c,量子门50c依赖于量子门50e,因此,量子门50b的时间帧应该位于量子门50c的时间帧801c及量子门50e的时间帧801d之前,即时间帧801b,与量子门50h的时间帧801d不相邻。同理,可以实现对N个量子线路所包括的量子门的后偏序对齐,得到量子门排布线路数据。
其中,N个量子线路所包括的量子门之间的门关联关系可以包括前序关联关系及后序
关联关系,前序关联关系用于表示各个量子门在执行时,需要等待执行的量子门;后序关联关系用于表示各个量子门在执行后,所能触发执行的量子门。可以通过前序关联关系,实现量子门排布方式一;通过后序关联关系,实现量子门排布方式二。
可选的,一种量子门排布方式三中,计算机设备可以获取N个量子线路中所包括的M个量子测量门,M为正整数,N个量子线路中至少一部分量子线路包括至少一个量子测量门。基于N个量子线路所包括的量子门之间的门关联关系,保持N个量子线路所包括的量子门中的量子比特门的执行顺序,对M个量子测量门进行对齐,得到对齐后的量子门排布线路数据;量子门排布线路数据中的M个量子测量门处于同一个时间帧;量子比特门是指N个量子线路所包括的量子门中,除M个量子测量门之外的量子门;时间帧用于表示N个量子线路所包括的量子门的执行顺序。
举例来说,一种可能的实现过程可以参见图9,图9是本申请实施例提供的一种量子门排布示意图三,如图9所示,计算机设备可以对N个量子线路分别对应的量子测量门(如量子线路q0中的量子测量门50f、量子线路q1中的量子测量门50g,及量子线路q2中的量子测量门50i)进行对齐,得到初始测量对齐模型901,删除N个量子线路中的空闲的时间帧,得到量子门排布线路数据902。也就是说,保持N个量子线路所包括的量子比特门,将N个量子线路所对应的量子测量门进行对齐,置于N个量子线路所包括的量子比特门之后,得到量子门排布线路数据902,使得量子门排布线路数据902中的各个量子测量门位于同一个时间帧。通过以上过程,可以在同一时间对所有的量子比特门进行测量操作,可以减少量子比特测量所引入的系统误差,在一定程度上可以提高量子线路运行结果的精度。
进一步可选的,一种量子门排布方式四中,可以获取N个量子线路中所包括的M个量子测量门,M为正整数,N个量子线路中至少一部分量子线路包括至少一个量子测量门。每个量子线路不包括量子测量门或包括至少一个量子测量门。基于N个量子线路所包括的量子门之间的门关联关系,保持N个量子线路所包括的量子门中的量子比特门的执行顺序,对M个量子测量门进行对齐,得到测量对齐数据;量子门排布线路数据中的M个量子测量门处于同一个时间帧。
其中,该测量对齐数据的获取过程可以参见量子门排布方式三中,量子门排布线路数据的生成过程,如在图5所示的示例基础上所得到的测量对齐数据,为图9中所示的量子门排布线路数据902。
进一步,可以基于N个量子线路所包括的量子门之间的门关联关系,保持M个量子测量门在测量对齐数据中处于同一个时间帧,对量子比特门进行对齐,得到对齐后的量子门排布线路数据。具体的,参见图10,图10是本申请实施例提供的一种量子门排布示意图四,可以保持M个量子测量门在测量对齐数据中处于同一个时间帧,采用上述量子门排布方式一,对量子比特门进行前偏序对齐,得到量子门排布线路数据1001;或者,可以保持M个量子测量门在测量对齐数据中处于同一个时间帧,采用上述量子门排布方式二,对量子比特门进行后偏序对齐,得到量子门排布线路数据1002。
通过以上过程,可以既缩短量子线路处理所需的时间,提高量子线路处理的效率,避免量子比特退相干所造成的量子失效情况,提高量子线路处理的准确性,又可以提高量子线路运行的精度。
在一些实施例中,计算机设备可以获取N个量子线路所包括的量子门的比特相干性时间,获取N个量子线路所对应的最长处理时长。若比特相干性时间小于最长处理时长,则以N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于N个量子线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据;第二量子门是指电路信息所指示的最后一个处理的量子门。
在一些实施例中,计算机设备可以获取N个量子线路所包括的量子门的比特相干性时
间,获取N个量子线路所对应的最长处理时长。若比特相干性时间小于最长处理时长,也就是等到N个量子线路最后测量时,可能存在部分量子门已经退相干的情况,则采用上述量子门排布方式一、量子门排布方式二或量子门排布方式四任意一种方式,对N个量子线路所包括的量子门进行对齐,得到量子门排布线路数据。
进一步地,若比特相干性时间大于或等于最长处理时长,则采用上述量子门排布方式一、量子门排布方式二、量子门排布方式三或量子门排布方式四中的任意一种方式,对N个量子线路所包括的量子门进行对齐,得到量子门排布线路数据。
当然可选的,若比特相干性时间小于最长处理时长,则采用上述量子门排布方式一或量子门排布方式二,对N个量子线路所包括的量子门进行对齐,得到量子门排布线路数据;若比特相干性时间大于或等于最长处理时长,则采用上述量子门排布方式三,对N个量子线路所包括的量子门进行对齐,得到量子门排布线路数据。
可选的,还可以不考虑量子门的比特相干性时间,直接采用量子门排布方式四,对N个量子线路所包括的量子门进行对齐,得到量子门排布线路数据等。上述各个量子门排布方式的调用条件,可以基于需要进行更新,在此不做限制。
或者可选的,计算机设备可以获取待解析量子程序所对应的量子电路的电路运行数据,基于电路运行数据确定量子电路的电路优化方向。其中,该电路优化方向可以包括但不限于时间优化方向、测量优化方向及全面优化方向等。
进一步,可以获取电路优化方向所对应的目标量子对齐方式,基于N个量子线路所包括的量子门之间的门关联关系,采用目标量子对齐方式对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
例如,该时间优化方向所对应的目标量子对齐方式为上述量子门排布方式一,及量子门排布方式二;测量优化方向所对应的目标量子对齐方式为上述量子门排布方式三;全面优化方向所对应的目标量子对齐方式为上述量子门排布方式四等。
具体的,若电路优化方向为时间优化方向,则将量子门排布方式一或量子门排布方式二确定为目标量子对齐方式等。具体的,目标量子对齐方式的实现过程,可以基于上述电路优化方向与量子门排布方式的对应关系,参见上述量子门排布方式一至量子门排布方式四的实现过程,在此不再进行赘述。通过以上过程,使得可以采用更为符合待解析量子程序所对应的量子电路的需求的量子门排布方式,对待解析量子程序进行对齐,提高量子线路处理的精确性。
在一些实施例中,计算机设备可以获取时序控制参数,获取该时序控制参数所对应的量子门排布方式,采用该时序控制参数所对应的量子门排布方式,执行基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据的过程。
例如,可以输出时序控制选项,响应于针对时序控制选项中的目标时序控制选项的选择操作,获取目标时序控制选项所携带的时序控制参数。使得对于待解析量子程序的量子门时序控制更加简便,提高了量子线路处理的灵活性及便捷性。
步骤S303,根据量子门排布线路数据,生成量子处理指令,其中,量子处理指令中指定的N个量子线路所包括量子门的执行顺序,不同于待解析量子程序中指定的N个量子线路所包括量子门的执行顺序。
在本申请实施例中,可以获取量子门排布线路数据中所包括的P个量子门,以及每个量子门所对应的量子线路;P为正整数。基于P个量子门分别在量子门排布线路数据中所处的目标时间帧,以及每个量子门所对应的量子线路,生成针对P个量子门的量子处理指令;N个量子线路所包括的量子门,在量子处理指令中的第一执行时序,不同于在待解析量子程序中的第二执行时序。其中,第一执行时序是指在量子处理指令中,N个量子线路所包括的量子门的执行顺序,如哪几个量子门在同一个时间帧执行,不同的时间帧的先后顺序等;第二执行时序是指在待解析量子程序中,N个量子线路所包括的量子门的执行顺
序,从而实现对量子电路中的量子门的时序重排。
例如,可以获取量子门排布线路数据中所包括的P个量子门,以及每个量子门所对应的量子线路;获取指令生成语言,获取指令生成语言所对应的指令模板,例如,该指令生成语言为eqasm,得到该指令生成语言eqasm的指令模板包括声明模板:SMIS Sd(用于声明单比特门)及SMIS Td(用于声明双比特门)等,其中,d用于表示对应的量子门的标号;该指令模板还可以包括执行模板:H(用于表示单比特门)、CNOT(用于表示双比特门)、MEASZ(用于表示量子测量门)及“|”(用于划分量子门)。
其中,计算机设备可以响应针对量子电路的时序重排操作,显示候选指令语言选项;响应针对候选指令语言选项中的指令生成语言的选择操作,获取该指令生成语言。其中,该候选指令语言选项可以是指用于执行后续生成的量子处理指令的设备所支持的语言类型。或者,计算机设备可以获取由业务对象(即管理该量子电路的业务人员等)所配置的预设语言,将该预设语言确定为指令生成语言。或者,计算机设备可以直接将默认语言,确定为指令生成语言,该默认语言是指计算机设备在对任意一个量子电路中的量子门进行时序重排后,进行指令生成所采用的语言。
以图10所示的量子门排布线路数据1001为例,可以采用上述声明模板,对P个量子门及每个量子门所对应的量子线路进行声明指令生成,得到量子声明指令,如下所示:
SMIS S0,{0}//用于表示位于量子线路q0(即{0})中的单比特门S0,即量子门50e;
SMIS S1,{1}//用于表示位于量子线路q1(即{1})中的单比特门S1,即量子门50a;
SMIS S2,{2}//用于表示位于量子线路q2(即{2})中的单比特门S2,即量子门50h;
SMIS S3,{3}//用于表示位于量子线路q3(即{3})中的单比特门S3,即量子门50d;
SMIT T1,{1,2}//用于表示位于量子线路q1与量子线路q2(即{1,2})中的双比特门T1,即量子门50b;
SMIT T2,{0,1}//用于表示位于量子线路q0与量子线路q1(即{0,1})中的双比特门T2,即量子门50c。
采用上述执行模板,基于P个量子门分别在量子门排布线路数据1001中所处的目标时间帧,以及每个量子门所对应的量子线路,生成针对P个量子门的量子执行指令,如下所示:
0,H S1|H S3//用于表示在开始的时间帧(如假定为时间帧1)中,执行单比特门S1及单比特门S3,0用于表示不启动新的时间帧;
1,CNOT T1//用于表示在上一个时间帧基础上,启动新的时间帧(记作时间帧2),执行双比特门T1,1用于表示启动新的时间帧;
1,CNOT T2|H S2//用于表示在上一个时间帧基础上,启动新的时间帧(记作时间帧3),执行双比特门T2及单比特门S2;
1,H S0//用于表示在上一个时间帧基础上,启动新的时间帧(记作时间帧4),执行单比特门S0;
1,MEASZ S0|MEASZ S1|MEASZ S2//用于表示对量子线路q0、量子线路q1及量子线路q2进行测量处理。
进一步,将量子声明指令及量子执行指令组成针对P个量子门的量子处理指令。可选的,还可以在量子声明指令与量子执行指令之间插入等待指令,如QWAIT 10000等,生成针对P个量子门的量子处理指令。
进一步地,可以执行量子处理指令,对待解析量子程序进行测量处理,得到待解析量子程序所对应的量子的量子信息。具体的,该量子处理指令仍是针对上述量子电路的指令,只是是在对量子电路中的量子门进行时序重排后进行处理,而量子电路本身的量子门之间的连接方式等均未进行改变,换句话说,可以认为,计算机设备针对量子电路执行量子处理指令,实现对待解析量子程序的测量处理,具体是对量子电路中所包括的量子门(即N个量子线路所包括的量子门)进行测量处理,得到待解析量子程序所对应的量子的量子信
息。其中,该量子信息用于表示量子的物理状态及量子性质等。
进一步,可以基于量子信息进行量子应用。例如,在量子通信场景中,可以基于量子的量子信息,以及对待解析量子程序的测量处理的测量结果,获取加密参数,采用加密参数为通信数据进行加密,得到加密数据,对加密数据进行传输。
其中,该方式利用了量子的不可复制性及测量的随机性,生成量子密码(即加密参数),为通信数据进行加密。当然随着量子研究的发展,本申请所得到的量子信息还可以应用于其他场景中,在此不做过多描述。
其中,该量子电路可以是集成在计算机设备中,也可以是在目标业务设备(此时计算机设备可以将量子处理指令发送至目标业务设备)中,该目标业务设备可以是上述所提及的业务设备中集成有量子电路的业务设备,可以将量子电路所在的设备记作量子管理设备。在该量子管理设备中包括量子处理指令时,量子管理设备可以执行量子处理指令,对量子电路进行测量处理。
可选的,量子管理设备可以响应针对量子电路的量子测量请求,调用量子处理指令,执行该量子处理指令,对量子电路进行测量处理;或者,量子管理设备在获取到量子处理指令时,执行该量子处理指令,对量子电路进行测量处理,如量子管理设备为计算机设备,在计算机设备生成量子处理指令时,或者,量子管理设备为目标业务设备,在目标业务设备接收到量子处理指令时等。或者,将量子处理指令添加至待解析量子程序所在的代码位置处,对待解析量子程序进行注释处理,也就相当于将待解析量子程序替换为量子处理指令,这种情况下,可以直接采用待解析量子程序的触发方式,触发量子处理指令。其中,注释处理是指将待解析量子程序由可执行状态更改为不可执行状态。
具体的,以上过程可以简单归结为图11,图11是本申请实施例提供的一种量子解析简易流程图,如图11所示,该过程可以包括如下步骤:
步骤S1101,进行量子电路解析。
在本申请实施例中,可以参见上述图3的步骤S301中的相关描述,对待解析量子程序进行量子电路解析,得到电路信息。
步骤S1102,建立有向图模型。
在本申请实施例中,可以参见上述图3的步骤S301中的相关描述,基于电路信息构建有向图模型。
步骤S1103,获取时序控制参数。
在本申请实施例中,可以参见上述图3的步骤S302中的相关描述,获取时序控制参数,确定用于对待解析量子程序进行时序重排的量子门排布方式。
步骤S1104,对电路信息进行时序重排。
在本申请实施例中,可以参见上述图3的步骤S302中的相关描述,采用步骤S1103所得到的量子门排布方式,对电路信息进行时序重排,生成量子门排布线路数据。
步骤S1105,生成量子处理指令。
在本申请实施例中,可以参见上述图3的步骤S303中的相关描述,在此不再进行赘述。
在本申请实施例中,获取待解析量子程序,对待解析量子程序进行量子电路解析,得到待解析量子程序所包括的电路信息;电路信息包括N个量子线路及N个量子线路所包括的量子门;N为正整数;基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;根据量子门排布线路数据,生成量子处理指令。
通过以上过程,可以直接对量子电路进行解析,也就是该量子电路所对应的待解析量子程序,使得可以实现对量子电路的自动化解析,而且基于得到的量子电路,实现了对各个量子门的对齐,实现对量子门的时序控制,以抑制量子的特点所带来的噪声影响,提高量子计算结果的准确性。而且,根据输入的待解析量子程序的语义(即电路信息),将量
子门的门关联关系进行独立建模,提高量子电路处理的效率及精确性,提高量子门处理的便捷性及灵活性。
进一步地,请参见图12,图12是本申请实施例提供的一种量子线路处理装置示意图。该量子线路处理装置可以是运行于计算机设备中的一个计算机程序(包括程序代码等),例如该量子线路处理装置可以为一个应用软件;该装置可以用于执行本申请实施例提供的方法中的相应步骤。如图12所示,该量子线路处理装置1200可以用于图3所对应实施例中的计算机设备,具体的,该装置可以包括:程序获取模块11、程序解析模块12、量子排布模块13及指令生成模块14。
程序获取模块11,用于获取待解析量子程序;
程序解析模块12,用于对待解析量子程序进行量子电路解析,得到待解析量子程序所包括的电路信息,电路信息包括N个量子线路及N个量子线路所包括的量子门,N为正整数;
量子排布模块13,用于基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;
指令生成模块14,用于根据量子门排布线路数据,生成量子处理指令,其中,量子处理指令中指定的N个量子线路所包括量子门的执行顺序,不同于待解析量子程序中指定的N个量子线路所包括量子门的执行顺序。
其中,该程序解析模块12,包括:
语言解析单元12a,用于获取待解析量子程序的程序语言类型;
关键获取单元12b,用于获取程序语言类型所对应的量子关键词;
代码识别单元12c,用于基于量子关键词识别待解析量子程序中的量子代码段,量子代码段包括M个代码语句,M为正整数;
电路解析单元12d,用于基于M个代码语句的语句顺序,对M个代码语句进行量子电路解析,得到待解析量子程序所包括的电路信息,电路信息用于表征M个代码语句所指示的量子电路。
其中,该程序解析模块12,包括:
模型解析单元12e,用于将待解析量子程序输入程序解析模型中进行解析,确定待解析量子程序所对应的程序语言类型;
语句检测单元12f,用于在程序解析模型中,基于程序语言类型检测待解析量子程序所包括的代码语句,得到待解析量子程序所包括的代码语句中的量子门处理语句;
信息获取单元12g,用于基于量子门处理语句的语句顺序,对量子门处理语句进行量子电路解析,得到待解析量子程序所包括的电路信息,电路信息用于表征量子门处理语句所指示的量子电路。
其中,该装置1200还包括:
有向构建模块15,用于以N个量子线路所包括的量子门作为节点,基于电路信息确定N个量子线路所包括的量子门之间的边,将节点与边构建成量子有向图模型;量子有向图模型用于指示N个量子线路所包括的量子门之间的门关联关系;
该量子排布模块13,具体用于:基于量子有向图模型,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
在一些实施例中,该量子排布模块13,包括:
第一排布单元13a,用于以N个量子线路所包括的量子门中的第一量子门所对应的时序位置作为第一基准时序位置,基于N个量子线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第一基准时序位置进行对齐,得到对齐后的量子门排布线路数据;第一量子门是指电路信息所指示的第一个处理的量子门。
在一些实施例中,量子排布模块13,包括:第二排布单元13b,用于以N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于N个量子
线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据,第二量子门是指电路信息所指示的最后一个处理的量子门。
其中,该量子排布模块13,包括:相干解析单元13c,用于获取N个量子线路所包括的量子门的比特相干性时间,获取N个量子线路所对应的最长处理时长。
该第二排布单元13b,还用于若比特相干性时间小于最长处理时长,则以N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于N个量子线路所包括的量子门之间的关联关系,将N个量子线路所包括的量子门向第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据,第二量子门是指电路信息所指示的最后一个处理的量子门。
在一些实施例中,该量子排布模块13,包括:
测量获取单元13d,用于获取N个量子线路中所包括的M个量子测量门,M为正整数,N个量子线路中至少一部分量子线路包括至少一个量子测量门。
第三排布单元13e,用于基于N个量子线路所包括的量子门之间的门关联关系,保持N个量子线路所包括的量子门中的量子比特门的执行顺序,对M个量子测量门进行对齐,得到对齐后的量子门排布线路数据,量子门排布线路数据中的M个量子测量门处于同一个时间帧,量子比特门是指N个量子线路所包括的量子门中,除M个量子测量门之外的量子门,时间帧用于表示N个量子线路所包括的量子门的执行顺序。
在一些实施例中,该量子排布模块13,包括:
该测量获取单元13d,还用于获取N个量子线路中所包括的M个量子测量门,M为正整数,N个量子线路中至少一部分量子线路包括至少一个量子测量门;
初始排布单元13f,用于基于N个量子线路所包括的量子门之间的门关联关系,保持N个量子线路所包括的量子门中的量子比特门的执行顺序,对M个量子测量门进行对齐,得到测量对齐数据,量子门排布线路数据中的M个量子测量门处于同一个时间帧;
第四排布单元13g,用于基于N个量子线路所包括的量子门之间的门关联关系,保持M个量子测量门在测量对齐数据中处于同一个时间帧,对量子比特门进行对齐,得到对齐后的量子门排布线路数据。
在一些实施例中,该量子排布模块13,包括:
优化确定单元13h,用于获取待解析量子程序所对应的量子电路的电路运行数据,基于电路运行数据确定量子电路的电路优化方向。
门排布单元13i,用于获取电路优化方向所对应的目标量子对齐方式,基于N个量子线路所包括的量子门之间的门关联关系,采用目标量子对齐方式对N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
在一些实施例中,该指令生成模块14,包括:
门解析单元14a,用于获取量子门排布线路数据中所包括的P个量子门,以及每个量子门所对应的量子线路;P为正整数。
指令生成单元14b,用于基于P个量子门分别在量子门排布线路数据中所处的目标时间帧,以及每个量子门所对应的量子线路,生成针对P个量子门的量子处理指令。
在一些实施例中,该装置1200还包括:
指令执行模块16,用于执行量子处理指令,对待解析量子程序进行测量处理,得到待解析量子程序所对应的量子的量子信息;
量子应用模块17,用于基于量子信息进行量子应用。
本申请实施例提供了一种量子线路处理装置,该装置可以获取待解析量子程序,对待解析量子程序进行量子电路解析,得到待解析量子程序所包括的电路信息;电路信息包括N个量子线路及N个量子线路所包括的量子门;N为正整数;基于N个量子线路所包括的量子门之间的门关联关系,对N个量子线路所包括的量子门进行对齐,得到对齐后的量子
门排布线路数据;根据量子门排布线路数据,生成量子处理指令。通过以上过程,可以直接对量子电路进行解析,也就是该量子电路所对应的待解析量子程序,使得可以实现对量子电路的自动化解析,而且基于得到的量子电路,实现了对各个量子门的对齐,实现对量子门的时序控制,以抑制量子的特点所带来的噪声影响,提高量子计算结果的准确性。而且,根据输入的待解析量子程序的语义(即电路信息),将量子门的门关联关系进行独立建模,提高量子电路处理的效率及精确性,提高量子门处理的便捷性及灵活性。
参见图13,图13是本申请实施例提供的一种计算机设备的结构示意图。如图13所示,本申请实施例中的计算机设备可以包括:一个或多个处理器1301、存储器1302和输入输出接口1303。该处理器1301、存储器1302和输入输出接口1303通过总线1304连接。存储器1302用于存储计算机程序,该计算机程序包括计算机可读指令,输入输出接口1303用于接收数据及输出数据,如用于计算机设备与业务设备之间进行数据交互,或者用于计算机设备与量子设备之间进行数据交互等;处理器1301用于执行存储器1302存储的程序指令。
其中,该处理器1301至少可以执行如下操作:获取待解析量子程序,对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路,及所述N个量子线路所包括的量子门,N为正整数;基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序。
在一些可行的实施方式中,该处理器1301可以是中央处理单元(central processing unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
该存储器1302可以包括只读存储器和随机存取存储器,并向处理器901和输入输出接口1303提供指令和数据。存储器1302的一部分还可以包括非易失性随机存取存储器。例如,存储器1302还可以存储设备类型的信息。
具体实现中,该计算机设备可通过其内置的各个功能模块执行如该图3中各个步骤所提供的实现方式,具体可参见该图3中各个步骤所提供的实现方式,在此不再赘述。
本申请实施例通过提供一种计算机设备,包括:处理器、输入输出接口、存储器,通过处理器获取存储器中的计算机可读指令,执行该图3中所示方法的各个步骤,进行量子线路处理操作。本申请实施例实现了获取待解析量子程序,对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路,及所述N个量子线路所包括的量子门,N为正整数;基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序。通过以上过程,可以直接对量子电路进行解析,也就是该量子电路所对应的待解析量子程序,使得可以实现对量子电路的自动化解析,而且基于得到的量子电路,实现了对各个量子门的对齐,实现对量子门的时序控制,以抑制量子的特点所带来的噪声影响,提高量子计算结果的准确性。而且,根据输入的待解析量子程序的语义(即电路信息),将量子门的门关联关系进行独立建模,提高量子电路处理的效率及精确性,提高量子门处理的便捷性及灵活性。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机
可读指令,该计算机可读指令适于由该处理器加载并执行图3中各个步骤所提供的量子线路处理方法,具体可参见该图3中各个步骤所提供的实现方式,在此不再赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。对于本申请所涉及的计算机可读存储介质实施例中未披露的技术细节,请参照本申请方法实施例的描述。作为示例,计算机可读指令可被部署为在一个计算机设备上执行,或者在位于一个地点的多个计算机设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个计算机设备上执行。
该计算机可读存储介质可以是前述任一实施例提供的量子线路处理装置或者该计算机设备的内部存储单元,例如计算机设备的硬盘或内存。该计算机可读存储介质也可以是该计算机设备的外部存储设备,例如该计算机设备上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该计算机设备的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机可读指令以及该计算机设备所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括计算机可读指令,该计算机可读指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机可读指令,处理器执行该计算机可读指令,使得该计算机设备执行图3中的各种可选方式中所提供的方法,实现了直接对量子电路进行解析,也就是该量子电路所对应的待解析量子程序,使得可以实现对量子电路的自动化解析,而且基于得到的量子电路,实现了对各个量子门的对齐,实现对量子门的时序控制,以抑制量子的特点所带来的噪声影响,提高量子计算结果的准确性。而且,根据输入的待解析量子程序的语义(即电路信息),将量子门的门关联关系进行独立建模,提高量子电路处理的效率及精确性,提高量子门处理的便捷性及灵活性。
本申请实施例的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别不同对象,而非用于描述特定顺序。此外,术语“包括”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、装置、产品或设备没有限定于已列出的步骤或模块,而是可选地还包括没有列出的步骤或模块,或可选地还包括对于这些过程、方法、装置、产品或设备固有的其他步骤单元。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在该说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例提供的方法及相关装置是参照本申请实施例提供的方法流程图和/或结构示意图来描述的,具体可由计算机可读指令实现方法流程图和/或结构示意图的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。这些计算机可读指令可提供到通用计算机、专用计算机、嵌入式处理机或其他可编程量子线路处理设备的处理器以产生一个机器,使得通过计算机或其他可编程量子线路处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能的装置。这些计算机可读指令也可存储在能引导计算机或其他可编程量子线路处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能。这些计算机可读指令也可装载到计算机或其他可编程量子线路处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或结构示意一个方框或多个方框中指定的功能的步骤。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (16)
- 一种量子线路处理方法,由计算机设备执行,包括:获取待解析量子程序,对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路,及所述N个量子线路所包括的量子门,N为正整数;基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及根据所述量子门排布线路数据,生成量子处理指令,其中,所述N个量子线路所包括量子门,由所述量子处理指令指定的执行顺序,不同于由所述待解析量子程序指定的执行顺序。
- 如权利要求1所述的方法,所述对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,包括:获取所述待解析量子程序的程序语言类型,获取所述程序语言类型所对应的量子关键词;基于所述量子关键词识别所述待解析量子程序中的量子代码段,所述量子代码段包括M个代码语句,M为正整数;基于所述M个代码语句的语句顺序,对所述M个代码语句进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息用于表征所述M个代码语句所指示的量子电路。
- 如权利要求1所述的方法,所述对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,包括:将所述待解析量子程序输入程序解析模型中进行解析,确定所述待解析量子程序所对应的程序语言类型;在所述程序解析模型中,基于所述程序语言类型检测所述待解析量子程序所包括的代码语句,得到所述待解析量子程序所包括的代码语句中的量子门处理语句;基于所述量子门处理语句的语句顺序,对所述量子门处理语句进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息用于表征所述量子门处理语句所指示的量子电路。
- 如权利要求1至3任一项所述的方法,所述方法还包括:以所述N个量子线路所包括的量子门作为节点,基于所述电路信息确定所述N个量子线路所包括的量子门之间的边,将所述节点与所述边构建成量子有向图模型,所述量子有向图模型用于指示所述N个量子线路所包括的量子门之间的门关联关系;所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:基于所述量子有向图模型,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
- 如权利要求1至3任一项所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:以所述N个量子线路所包括的量子门中的第一量子门所对应的时序位置作为第一基准时序位置,基于所述N个量子线路所包括的量子门之间的关联关系,将所述N个量子线路所包括的量子门向所述第一基准时序位置进行对齐,得到对齐后的量子门排布线路数据,所述第一量子门是指所述电路信息所指示的第一个处理的量子门。
- 如权利要求1至3任一项所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子 门排布线路数据,包括:以所述N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于所述N个量子线路所包括的量子门之间的关联关系,将所述N个量子线路所包括的量子门向所述第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据,所述第二量子门是指所述电路信息所指示的最后一个处理的量子门。
- 如权利要求1至3任一项所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:获取所述N个量子线路所包括的量子门的比特相干性时间,获取所述N个量子线路所对应的最长处理时长;若所述比特相干性时间小于所述最长处理时长,则以所述N个量子线路所包括的量子门中的第二量子门所对应的时序位置作为第二基准时序位置,基于所述N个量子线路所包括的量子门之间的关联关系,将所述N个量子线路所包括的量子门向所述第二基准时序位置进行对齐,得到对齐后的量子门排布线路数据,所述第二量子门是指所述电路信息所指示的最后一个处理的量子门。
- 如权利要求1至3任一项所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:获取所述N个量子线路中所包括的M个量子测量门,M为正整数,所述N个量子线路中至少一部分量子线路包括至少一个量子测量门;基于所述N个量子线路所包括的量子门之间的门关联关系,保持所述N个量子线路所包括的量子门中的量子比特门的执行顺序,对所述M个量子测量门进行对齐,得到对齐后的量子门排布线路数据,所述量子门排布线路数据中的M个量子测量门处于同一个时间帧,所述量子比特门是指所述N个量子线路所包括的量子门中,除所述M个量子测量门之外的量子门,所述时间帧用于表示N个量子线路所包括的量子门的执行顺序。
- 如权利要求1至3任一项所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:获取所述N个量子线路中所包括的M个量子测量门,M为正整数,所述N个量子线路中至少一部分量子线路包括至少一个量子测量门;基于所述N个量子线路所包括的量子门之间的门关联关系,保持所述N个量子线路所包括的量子门中的量子比特门的执行顺序,对所述M个量子测量门进行对齐,得到测量对齐数据,所述量子门排布线路数据中的M个量子测量门处于同一个时间帧;基于所述N个量子线路所包括的量子门之间的门关联关系,保持所述M个量子测量门在所述测量对齐数据中处于同一个时间帧,对所述量子比特门进行对齐,得到对齐后的量子门排布线路数据。
- 如权利要求1所述的方法,所述基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据,包括:获取所述待解析量子程序所对应的量子电路的电路运行数据,基于所述电路运行数据确定所述量子电路的电路优化方向;获取所述电路优化方向所对应的目标量子对齐方式,基于所述N个量子线路所包括的量子门之间的门关联关系,采用所述目标量子对齐方式对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据。
- 如权利要求1至10任一项所述的方法,所述根据所述量子门排布线路数据,生成量子处理指令,包括:获取所述量子门排布线路数据中所包括的P个量子门,以及每个量子门所对应的量子线路,P为正整数;基于所述P个量子门分别在所述量子门排布线路数据中所处的目标时间帧,以及所述每个量子门所对应的量子线路,生成针对所述P个量子门的量子处理指令。
- 如权利要求1至11任一项所述的方法,所述方法还包括:执行所述量子处理指令,对所述待解析量子程序进行测量处理,得到所述待解析量子程序所对应的量子的量子信息;基于所述量子信息进行量子应用。
- 一种量子线路处理装置,所述装置包括:程序获取模块,用于获取待解析量子程序;程序解析模块,用于对所述待解析量子程序进行量子电路解析,得到所述待解析量子程序所包括的电路信息,所述电路信息包括N个量子线路及所述N个量子线路所包括的量子门,N为正整数;量子排布模块,用于基于所述N个量子线路所包括的量子门之间的门关联关系,对所述N个量子线路所包括的量子门进行对齐,得到对齐后的量子门排布线路数据;及指令生成模块,用于根据所述量子门排布线路数据,生成量子处理指令,其中,所述量子处理指令中指定的所述N个量子线路所包括量子门的执行顺序,不同于所述待解析量子程序中指定的所述N个量子线路所包括量子门的执行顺序。
- 一种计算机设备,包括处理器和存储器,所述存储器用于存储计算机可读指令,所述处理器用于调用所述计算机可读指令,以执行权利要求1-12任一项所述的方法。
- 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令由处理器加载并执行,以使得所述处理器执行权利要求1-12任一项所述的方法。
- 一种计算机程序产品,包括计算机可读指令,所述计算机可读指令被处理器执行时实现权利要求1-12任一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310715341.6A CN119150999A (zh) | 2023-06-15 | 2023-06-15 | 量子线路处理方法、装置、计算机、存储介质及程序产品 |
| CN202310715341.6 | 2023-06-15 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024255025A1 true WO2024255025A1 (zh) | 2024-12-19 |
Family
ID=93814452
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/123812 Ceased WO2024255025A1 (zh) | 2023-06-15 | 2023-10-10 | 量子线路处理方法、装置、计算机、存储介质及程序产品 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN119150999A (zh) |
| WO (1) | WO2024255025A1 (zh) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111027702A (zh) * | 2019-12-11 | 2020-04-17 | 合肥本源量子计算科技有限责任公司 | 一种实现量子线路替换的方法、装置、存储介质和电子装置 |
| CN111079933A (zh) * | 2019-11-15 | 2020-04-28 | 合肥本源量子计算科技有限责任公司 | 量子线路的图形化显示方法、系统、存储介质和电子装置 |
| CN114912618A (zh) * | 2021-02-07 | 2022-08-16 | 合肥本源量子计算科技有限责任公司 | 一种量子计算任务调度方法、装置及量子计算机操作系统 |
| US20220284336A1 (en) * | 2021-07-14 | 2022-09-08 | Beijing Baidu Netcom Science Technology Co., Ltd. | Processing method for quantum circuit, electronic device, and storage medium |
| CN115907024A (zh) * | 2021-08-17 | 2023-04-04 | 合肥本源量子计算科技有限责任公司 | 一种构建待映射量子程序的方法、装置及量子计算机 |
-
2023
- 2023-06-15 CN CN202310715341.6A patent/CN119150999A/zh active Pending
- 2023-10-10 WO PCT/CN2023/123812 patent/WO2024255025A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111079933A (zh) * | 2019-11-15 | 2020-04-28 | 合肥本源量子计算科技有限责任公司 | 量子线路的图形化显示方法、系统、存储介质和电子装置 |
| CN111027702A (zh) * | 2019-12-11 | 2020-04-17 | 合肥本源量子计算科技有限责任公司 | 一种实现量子线路替换的方法、装置、存储介质和电子装置 |
| CN114912618A (zh) * | 2021-02-07 | 2022-08-16 | 合肥本源量子计算科技有限责任公司 | 一种量子计算任务调度方法、装置及量子计算机操作系统 |
| US20220284336A1 (en) * | 2021-07-14 | 2022-09-08 | Beijing Baidu Netcom Science Technology Co., Ltd. | Processing method for quantum circuit, electronic device, and storage medium |
| CN115907024A (zh) * | 2021-08-17 | 2023-04-04 | 合肥本源量子计算科技有限责任公司 | 一种构建待映射量子程序的方法、装置及量子计算机 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119150999A (zh) | 2024-12-17 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7634761B2 (en) | Breakpoint logging and constraint mechanisms for parallel computing systems | |
| US20180196643A1 (en) | Generating web api specification from online documentation | |
| US12106182B2 (en) | Validating and estimating runtime for quantum algorithms | |
| US9280318B2 (en) | Managing lifecycle of objects | |
| US8719770B2 (en) | Verifying programming artifacts generated from ontology artifacts or models | |
| CN103297381A (zh) | 一种基于插件的业务访问方法及其系统 | |
| CN112764729B (zh) | 应用软件开发方法、装置、计算机设备及可读存储介质 | |
| CN118368236B (zh) | 发现接口资源的方法及相关设备 | |
| US10970055B2 (en) | Identifying software and hardware bottlenecks | |
| CN113722007A (zh) | Vpn分支设备的配置方法、装置及系统 | |
| US9747448B2 (en) | Cryptographic mechanisms to provide information privacy and integrity | |
| CN114756833B (zh) | 代码混淆方法、装置、设备、介质以及程序产品 | |
| WO2024255025A1 (zh) | 量子线路处理方法、装置、计算机、存储介质及程序产品 | |
| CN111191225B (zh) | 一种切换隔离对象的方法、装置、介质和电子设备 | |
| CN114595449A (zh) | 一种安全扫描方法及装置 | |
| CN106096403B (zh) | 一种软件隐私泄露行为的分析方法及装置 | |
| CN114936046A (zh) | Web服务公共组件的拓展方法、装置、电子设备及存储介质 | |
| CN115470737B (zh) | 生成数据流图的方法、电子设备及存储介质 | |
| CN119668967B (zh) | 检测方法和电子设备 | |
| US12517952B2 (en) | Semi-structured data decomposition | |
| US20240256300A1 (en) | Systems and methods of preventing user interface (ui) flickering | |
| Dong et al. | BUCKER 2.0: An unfolding based checker for CTL | |
| US11099970B2 (en) | Capturing task traces for multiple tasks | |
| CN119088664A (zh) | 编译优化选项分组方法、计算机设备及存储介质 | |
| Boucheneb et al. | Relevant timed schedules/clock vectors for constructing time Petri net reachability graphs |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23941249 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |