CN116187463A - Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment - Google Patents

Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment Download PDF

Info

Publication number
CN116187463A
CN116187463A CN202310147343.XA CN202310147343A CN116187463A CN 116187463 A CN116187463 A CN 116187463A CN 202310147343 A CN202310147343 A CN 202310147343A CN 116187463 A CN116187463 A CN 116187463A
Authority
CN
China
Prior art keywords
instruction
list
quantum
measurement
instructions
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.)
Granted
Application number
CN202310147343.XA
Other languages
Chinese (zh)
Other versions
CN116187463B (en
Inventor
方堃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202310147343.XA priority Critical patent/CN116187463B/en
Publication of CN116187463A publication Critical patent/CN116187463A/en
Application granted granted Critical
Publication of CN116187463B publication Critical patent/CN116187463B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/80Quantum programming, e.g. interfaces, languages or software-development kits for creating or handling programs capable of running on quantum computers; Platforms for simulating or accessing quantum computers, e.g. cloud-based quantum computing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computational Mathematics (AREA)
  • Computing Systems (AREA)
  • Evolutionary Computation (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Superconductor Devices And Manufacturing Methods Thereof (AREA)
  • Devices For Executing Special Programs (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a compiling method and device from a quantum measurement mode to a quantum circuit and electronic equipment, relates to the technical field of quantum computing, and particularly relates to the technical field of blind quantum computing. The specific implementation scheme is as follows: acquiring a first instruction list of a quantum measurement mode, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction; based on a first instruction list, deferring a state preparation instruction and an entanglement instruction in a quantum measurement mode to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is as follows: preparing instructions, entanglement instructions and measurement instructions from front to back; and performing equivalent compiling of the instructions based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.

Description

Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment
Technical Field
The disclosure relates to the technical field of quantum computing, in particular to the technical field of blind quantum computing, and specifically relates to a compiling method and device from a quantum measurement mode to a quantum circuit and electronic equipment.
Background
Quantum calculation provides a brand new and very promising information processing mode by utilizing the unique operation rule in the quantum world. The essence of the calculation is that an initially prepared quantum state is evolved into another quantum state which is expected by a specific mode, and measurement is carried out on the evolved quantum state to obtain a calculation result.
Under different quantum computing models, the evolution modes of quantum states are different. The evolution is accomplished by quantum gating of quantum states using a more common quantum circuit model, which can be understood as a quantum version of a classical computational model, which is widely used in the field of quantum computing. The one-way quantum computer (one-way quantum computer,1 WQC) model is a completely different calculation mode from the quantum circuit model.
The quantum circuit model and the 1WQC model are universal quantum computing models, and any quantum algorithm can be realized. However, the calculation modes of the two models are different, and the expression modes of specific quantum algorithms are also different.
Disclosure of Invention
The disclosure provides a compiling method and device for quantum measurement mode to quantum circuit and electronic equipment.
According to a first aspect of the present disclosure, there is provided a method of compiling a quantum measurement mode into a quantum circuit, comprising:
acquiring a first instruction list of a quantum measurement mode, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction;
based on the first instruction list, deferring the state preparation instruction and the entanglement instruction in the quantum measurement mode to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is as follows: preparing instructions, entanglement instructions and measurement instructions from front to back;
and performing equivalent compiling of instructions based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
According to a second aspect of the present disclosure, there is provided a quantum measurement mode-to-quantum circuit compiling apparatus, comprising:
The first acquisition module is used for acquiring a first instruction list of the quantum measurement mode, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction;
the deferral processing module is configured to defer the state preparation instruction and the entanglement instruction in the quantum measurement mode based on the first instruction list to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is: preparing instructions, entanglement instructions and measurement instructions from front to back;
and the equivalent compiling module is used for carrying out equivalent compiling of the instruction based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform any one of the methods of the first aspect.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform any of the methods of the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements any of the methods of the first aspect.
The technology solves the problem that the 1WQC model is difficult to operate, and simplifies the operation of the 1WQC model.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a flow diagram of a method of compiling quantum measurement modes into quantum circuits according to a first embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an exemplary quantum circuit diagram;
FIG. 3 is a schematic diagram of the structure of a quantum measurement mode of an exemplary 1WQC model;
Fig. 4 is a schematic structural diagram of a quantum measurement mode-to-quantum circuit compiling apparatus according to a second embodiment of the present disclosure;
fig. 5 is a schematic block diagram of an example electronic device used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
First embodiment
As shown in fig. 1, the present disclosure provides a method for compiling a quantum measurement mode into a quantum circuit, comprising the steps of:
step S101: a first instruction list of a quantum measurement mode is obtained, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction.
In this embodiment, a method for compiling a quantum measurement mode to a quantum circuit relates to the technical field of quantum computing, in particular to the technical field of blind quantum computing, and can be widely applied to the design scene of a blind quantum computing protocol. The compiling method of the quantum measurement mode to the quantum circuit according to the embodiment of the present disclosure may be performed by the compiling apparatus of the quantum measurement mode to the quantum circuit according to the embodiment of the present disclosure. The compiling apparatus of the quantum measurement mode to the quantum circuit of the embodiment of the present disclosure may be configured in any electronic device to perform the compiling method of the quantum measurement mode to the quantum circuit of the embodiment of the present disclosure.
The quantum circuit model and the 1WQC model are universal quantum computing models, and any quantum algorithm can be realized. However, the calculation modes of the two models are different, and the expression modes of specific quantum algorithms are also different. Algorithms in quantum circuit models are typically described in terms of quantum circuits, specifically including initial quantum states, quantum gates, and quantum measurement operations. The algorithm in the 1WQC model is described by adopting a quantum measurement mode, and specifically comprises a calculation space, an input node, an output node and a calculation instruction.
The quantum circuit model and the 1WQC model can be simply understood as two different quantum computing languages, similar to the different languages used (e.g., chinese, english, etc.), each of which has its unique advantages. Although both quantum computing languages can represent arbitrary quantum algorithms, translation between languages is very complex. I.e. the conversion between different quantum computing modes is a fundamental problem in quantum computing.
In an application scenario, blind quantum computing is an important application in quantum internet, and cloud agent computing can be performed while protecting user privacy. The existing blind quantum computing protocols are all developed based on a 1WQC model. However, to directly implement the algorithm of the 1WQC model, there are at least two difficulties: 1) The 1WQC model requires a large number of qubits; 2) The current quantum computer is developed based on platforms such as superconductors and ion traps, is more suitable for running the algorithm of the quantum circuit model, and cannot directly run the algorithm of the 1WQC model.
The purpose of the embodiment is to translate the quantum measurement mode into a quantum circuit, so that on one hand, a new angle for quantum algorithm research can be provided, and the research and development of the quantum algorithm can be accelerated; on the other hand, the advantages of different quantum computing languages can be fully utilized in practical application, and the algorithm is designed and executed more efficiently. And the quantum measurement mode corresponding to the 1WQC model is compiled into a dynamic quantum circuit corresponding to the equivalent quantum circuit model, so that the number of quantum bits required by execution can be greatly reduced, and the quantum circuit can be more conveniently executed on a superconducting and ion trap equivalent quantum hardware platform.
The 1WQC model and the quantum circuit model are described in detail below.
Quantum circuit models are one type of commonly used quantum computing model. And (3) completing the evolution of the quantum state by carrying out quantum gate operation on the initial quantum state, and extracting a calculation result by quantum measurement. The quantum circuit diagram shows the whole process of quantum circuit model calculation.
Fig. 2 is a schematic diagram of an exemplary quantum circuit diagram, and as shown in fig. 2, a qubit system may be represented by a horizontal line, where qubits are numbered sequentially from top to bottom, where the qubits are often numbered beginning with zero.
The time evolution direction in the quantum circuit diagram is from left to right, the leftmost end is an initial quantum state, wherein each quantum bit is initialized to be a zero state, and then different quantum gate operations are sequentially applied to the initial state to complete the evolution of the quantum state. Meanwhile, quantum measurement can be carried out on some qubits, and measurement results are obtained.
In some application scenarios, an operation in a quantum circuit may occur to perform quantum measurement on a part of the qubits, and regulate the evolution of the rest of the qubits according to the measurement result, and such an operation is called classical control quantum operation, such as classical control quantum gate 201 shown in fig. 2. The measured qubit may be reset, which may be referred to as a reset operation, such as reset operation 202 shown in FIG. 2, for continued use in subsequent computations. A quantum circuit comprising intermediate measurement, classical control quantum operations, and reset operations may be referred to as a dynamic quantum circuit, e.g. the quantum circuit shown in fig. 2 is a dynamic quantum circuit.
The remainder of the quantum circuit diagram, except for the initial state, may be generally represented by an ordered list of instructions in the order of action of the quantum gates, each element in the list representing a quantum gate, classical control quantum gate, quantum measurement or reset operation instruction. Specifically, it is possible to combine:
Each single qubit gate (e.g., H, X, Y, Z, S, T, rx, ry, rz, etc.) is represented as an instruction containing four elements [ name, while_qubit, parameters, condition ]. Where name is the name of the quantum gate, while_qubit is the qubit that the quantum gate acts on, parameters are parameters of the quantum gate (no if there is no parameter), and condition indicates which of the qubits the quantum gate operation is controlled by (no if there is no parameter).
For example, [ Rx,2, pi, none ] represents acting an Rx rotation gate on the qubit on qubit 2, with a rotation angle pi. For another example, classical control quantum gate 201 in fig. 2 is a classical controlled quantum X gate, which may be denoted as [ X,2, none, 'a' ], i.e. the bery Pauli X gate acting on qubit 2, with the controlled condition that the measurement result with measurement identity ID 'a' acts as a quantum gate if the measurement result is 0 and not as a quantum gate if the measurement result is 1.
Each two-qubit gate (e.g., control not gate CNOT, CZ gate) is represented as an instruction containing four elements [ name, white_qubit, parameters, condition ]. Where name is the name of the quantum gate, while_qubit is a list of qubits that the two-qubit gate acts on (in particular, for a controlled quantum gate, a list of control bits and controlled bits), parameters is the parameter of the quantum gate (default to None if there is no parameter), and the condition indicates which quantum bit the quantum gate operation is controlled by (default to None if there is no parameter).
For example, [ CNOT, [1,3], none ] represents a control NOT acting on qubit 1 and qubit 3, where qubit 1 is the control bit and qubit 3 is the control bit. [ CZ, [1,2], none ] indicates that a CZ gate acts between qubit 1 and qubit 2.
Each single bit measurement is represented as an instruction containing four elements [ measure, white_qubit, basic, mid ]. The basic is determined by four parameters, including the measurement angle, the measurement plane, the field set s, the field set t, and mid is the identification ID identifying the current measurement.
For example, [ measure,2, [0, 'YZ', [1], [2] ], and 'a' ] indicate that the qubit 2 is measured, the measurement angle is 0, the measurement plane is the 'YZ' plane, the field set s is the qubit 1, the field set t is the qubit 2, and the identification ID of the current measurement instruction is 'a'.
Each reset operation instruction may be represented as an instruction containing four elements [ reset, while_qubit, matrix, none ]. The while_qubit is a quantum bit to be reset, the matrix is a quantum state matrix of the bit to be reset, and the quantum bit after the reset operation can be used for subsequent calculation.
The 1WQC model is another quantum computing approach than the quantum circuit model. The core idea of the model is to measure part of bits of one quantum entangled state, a quantum system which is not measured can realize corresponding evolution, and any needed evolution can be realized through controlling a measurement mode.
The calculation process under the 1WQC model mainly comprises three steps: first, a resource state, i.e., a highly entangled multi-body quantum state, is prepared, which can be prepared before computation begins and can be independent of the specific computing task; secondly, sequentially carrying out single-bit measurement on each bit of the prepared resource state, wherein the measurement mode of the subsequent bit can be correspondingly adjusted according to the measurement result of the measured bit, namely, the adaptability measurement is allowed; and thirdly, performing classical data processing on the measurement results of all bits to obtain a required calculation result.
FIG. 3 is a schematic diagram of the structure of a quantum measurement mode of an exemplary 1WQC model. As shown in FIG. 3, the grid represents a common quantum resource state, each node on the grid represents a qubit, and the entire grid represents a highly entangled quantum state.
Each bit may be measured in turn, and X, Y, Z, XY, etc. in a node represent the corresponding measurement basis. After all the nodes are measured according to preset rules, calculation tasks can be completed by counting measurement results.
An algorithm of a 1WQC model can also be described in terms of measurement modes. Each measurement mode consists of four parts: the computation space, input nodes, output nodes, and computation instructions, i.e., measurement patterns, can be expressed as: measurement pattern p= (computation space S, input node I, output node O, computation instruction C).
The "computation space" is a node set related to all the 1WQC models, "input node" is a node set of initial quantum states, "output node" is an output node set of quantum states or measurement results, "computation instructions" are an ordered list (agreed computation instructions are read from left to right) composed of three basic instructions in the following table 1, and all state preparation instructions in a standard order are arranged at the forefront, followed by entanglement instructions, and then all measurement instructions. Wherein, the state preparation instruction and the entanglement instruction jointly determine the preparation process of the multi-body entanglement state in the 1WQC model.
Table 1 storage rules and execution mode table of calculation instructions in measurement mode
Figure BDA0004090849670000071
In step S101, the quantum measurement mode may be a measurement mode of 1WQC, and the first instruction list may be a part of calculation instructions in the measurement mode, which is represented by an ordered list, and the list formed by the calculation instructions is the first instruction list.
The first instruction list may be an instruction list of a standard quantum measurement mode, for example, the first instruction list is: [ [ N,0], [ N,1], [ N,2], [ E, [0,1] ], [ E, [1,2] ], [ M,0], [ M,1], [ M,2] ]. In the instruction list of the standard quantum measurement mode, all state preparation instructions are arranged at the forefront, then entanglement instructions are arranged, then all measurement instructions are arranged, and only the first two parameters of the instructions are written for simplifying the expression.
Step S102: based on the first instruction list, deferring the state preparation instruction and the entanglement instruction in the quantum measurement mode to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is as follows: preparing instructions, entanglement instructions and measurement instructions from front to back.
In the step, the state preparation instruction and the entanglement instruction in the quantum measurement mode are the state preparation instruction and the entanglement instruction in the first instruction list.
Since in the standard quantum measurement mode, the state preparation instruction is the forefront of all instructions, followed by the entanglement instruction, and then the measurement instruction. The state preparation instruction and the entanglement instruction of the quantum measurement mode can be deferred.
In an alternative embodiment, the instructions in the first instruction list may be moved to the right of the instruction list by sequential exchange between instructions, resulting in a second instruction list of the quantum measurement mode.
In another alternative embodiment, the instructions in the first instruction list may be rearranged to achieve the effect of deferring the state preparation instruction and the entangled instruction in the first instruction list, so as to obtain the second instruction list.
When the deferral treatment is performed, the deferral treatment is limited as follows:
the relative position sequence of all measurement instructions needs to be kept unchanged;
different instructions on the same node need to keep the relative position sequence of the preparation instruction, the entanglement instruction and the measurement instruction unchanged from front to back.
When moving these instructions in the first instruction list to the right of the instruction list by sequential exchange between instructions, the restriction is also required: the precondition for the exchange of different types of instructions is that the system on which the two instructions act has no intersection.
Under the premise of the limitations, the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and the relative position sequence of the preparation instruction, the entanglement instruction and the measurement instruction of different instructions on the same node of the quantum measurement mode is kept unchanged from front to back.
For example, the first instruction list is: the second instruction list obtained after deferring the processing is [ [ N,0], [ N,1], [ N,2], [ E, [0,1] ], [ E, [1,2] ], [ M,0], [ M,1], [ M,2] ], and is [ [ N,0], [ N,1], [ E, [0,1] ], [ M,0], [ N,2], [ E, [1,2] ], [ M,2] ].
Step S103: and performing equivalent compiling of instructions based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
In this step, for each instruction in the second instruction list, an equivalent compilation may be performed on the instruction to compile the instruction into an instruction in a quantum circuit equivalent to the instruction. The quantum circuit may be a dynamic quantum circuit.
The instructions in the second instruction list can be equivalently compiled in sequence according to the ordering sequence of the instructions in the second instruction list, and a third instruction list of the quantum circuit equivalent to the quantum measurement mode can be obtained under the condition that compiling is completed.
When equivalent compiling is performed, a node of an instruction in the second instruction list can be obtained, a register unit is allocated for the node, and the register unit can correspond to quantum bits in the quantum circuit. The instruction can be mapped to a dynamic quantum circuit, and specifically, the operation on each node (namely, the node indicated by the instruction in the second instruction list) in the quantum measurement mode can be dynamically loaded into a register unit of the quantum circuit.
In an alternative embodiment, if the current node indicated by an instruction in the second instruction list has been loaded (i.e. a register unit has been allocated for that node), then the instruction may be executed on the corresponding register unit, i.e. if different instructions in the second instruction list indicate the same node, then the instructions may all be executed on the register unit allocated for that node. And if the current node is not loaded, it may be assigned a register unit. In this way, the number of qubits required to execute the model can be greatly reduced.
In this embodiment, a first instruction list of a quantum measurement mode is obtained, where the first instruction list includes a state preparation instruction, an entanglement instruction, and a measurement instruction; based on the first instruction list, deferring the state preparation instruction and the entanglement instruction in the quantum measurement mode to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is as follows: preparing instructions, entanglement instructions and measurement instructions from front to back; and performing equivalent compiling of instructions based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode. Therefore, the compiling from the quantum measurement mode to the quantum circuit can be realized, the number of quantum bits required by executing the model is greatly reduced, and the quantum measurement mode can be more conveniently executed on a superconducting and ion trap equivalent quantum hardware platform.
Optionally, the step S102 specifically includes:
splitting the first instruction list to obtain a first list, a second list and a third list, wherein the first list is a list formed by state preparation instructions in the first instruction list, the second list is a list formed by entanglement instructions in the first instruction list, and the third list is a list formed by measurement instructions in the first instruction list;
Based on the second list and the third list, deferring the entangled instruction in the quantum measurement mode to obtain a fourth list, wherein the fourth list comprises entangled instructions in the second list and measurement instructions in the third list, and in the fourth list, different instructions on the same node of the quantum measurement mode keep relative position sequences of the entangled instruction and the measurement instruction from front to back;
and carrying out deferral processing on the state preparation instruction in the quantum measurement mode based on the first list and the fourth list to obtain the second instruction list.
In this embodiment, the entangled instruction in the quantum measurement mode may be deferred first, and in the case where the deferred processing of the entangled instruction is completed, the deferred processing of the state preparation instruction in the quantum measurement mode may be further performed, and accordingly, the deferred processing of the state preparation instruction and the entangled instruction in the quantum measurement mode may be performed, so as to obtain the second instruction list.
Specifically, in the case of performing deferral processing separately, the first instruction list may be split, where the result of the splitting is that three lists are obtained, a list formed by all state preparation instructions (i.e., the first list) is denoted as commands_n, a list formed by all entangled instructions (i.e., the second list) is denoted as commands_e, and a list formed by all measurement instructions (i.e., the third list) is denoted as new_commands.
The entangled instruction in the quantum measurement mode may be deferred based on the second list and the third list to obtain a fourth list, where the deferred processing is limited as follows:
the relative position sequence of all measurement instructions needs to be kept unchanged;
different instructions on the same node need to keep the relative position sequence of entanglement instructions and measurement instructions from front to back unchanged;
the precondition for the exchange of different types of instructions is that the system on which the two instructions act has no intersection.
Correspondingly, in the fourth list, different instructions on the same node of the quantum measurement mode keep the relative position sequence of entanglement instructions and measurement instructions from front to back, and the relative position sequence of the measurement instructions in the fourth list is the same as the relative position sequence of the measurement instructions in the third list.
Then, under the condition that the entanglement instruction deferral processing is completed, deferral processing can be performed on the state preparation instruction in the quantum measurement mode based on the first list and the fourth list, and a second instruction list is obtained. When the deferral treatment is performed, the deferral treatment is limited as follows:
the relative position sequence of all measurement instructions needs to be kept unchanged;
different instructions on the same node need to keep the relative position sequence of the front-to-back state preparation instruction, the entanglement instruction and the measurement instruction unchanged;
The precondition for the exchange of different types of instructions is that the system on which the two instructions act has no intersection.
In this embodiment, by first deferring the entangled instruction in the quantum measurement mode, and then deferring the state preparation instruction in the quantum measurement mode when the deferring of the entangled instruction is completed, the state preparation instruction and the entangled instruction in the quantum measurement mode can be deferred accordingly, and a second instruction list is obtained. In this way, the process of deferring the state preparation instructions and entanglement instructions in the quantum measurement mode can be simplified.
Optionally, based on the second list and the third list, deferring the entangled instruction in the quantum measurement mode to obtain a fourth list, including:
traversing the second list aiming at the entanglement instructions, and recording the entanglement instructions of the current traversal;
traversing the third list aiming at the measurement instruction to obtain a target measurement instruction, wherein the node acted by the entanglement instruction of the current traversal comprises the node acted by the target measurement instruction;
inserting the currently traversed entanglement instruction into a first position in the third list, wherein the first position is the position of the target measurement instruction in the third list;
And determining the updated third list as the fourth list under the condition that the second list traversing is completed.
In this embodiment, the second list may be traversed for the entangled instruction, and the entangled instruction currently traversed may be recorded, which may be denoted as cmd_e.
In the traversing process of the second list aiming at the entangled instruction, the third list can be traversed aiming at the measured instruction to obtain a target measured instruction, and the node acted by the target measured instruction is contained in the nodes acted by the entangled instruction cmd_E of the current traversing.
Under the condition that the target measurement instruction is obtained through traversing, the entanglement instruction cmd_E of the current traversing is inserted into the position (i.e. the ith bit) of the target measurement instruction in the third list, and the target measurement instruction and the instruction positioned behind the ith bit in the third list are sequentially moved to the right end. Otherwise, continuing to traverse the third list for the measurement instruction until the target measurement instruction is traversed.
Accordingly, in the case where the traversal of the second list is completed, the updated third list is determined as the fourth list. In this way, a process of deferring the entangled instruction in the quantum measurement mode can be realized.
Optionally, the deferring processing is performed on the state preparation instruction in the quantum measurement mode based on the first list and the fourth list, to obtain the second instruction list, including:
traversing the state preparation instructions for the first list, and recording the state preparation instructions of the current traversal;
traversing the fourth list aiming at the entangled instruction to obtain a target entangled instruction, wherein the node acted by the target entangled instruction comprises the node acted by the currently traversed state preparation instruction;
inserting the currently traversed state preparation instruction into a second position in the fourth list, wherein the second position is the position of the target entanglement instruction in the fourth list;
and determining the updated fourth list as the second instruction list under the condition that the first list traversing is completed.
In this embodiment, the state preparation instruction for the first list may be traversed, and the state preparation instruction of the current traversal may be recorded, which may be denoted as cmd_n.
In the traversing process of the state preparation instruction for the first list, the traversing of the entanglement instruction for the fourth list can be performed to obtain a target entanglement instruction, wherein the node acted by the target entanglement instruction comprises the node acted by the state preparation instruction cmd_N of the current traversing.
Under the condition that the target entanglement instruction is obtained through traversing, the state preparation instruction cmd_N which is traversed currently is inserted into the position (such as the j-th bit) of the target entanglement instruction in the fourth list, and the target entanglement instruction and the instructions positioned behind the j-th bit in the fourth list sequentially move to the right end. Otherwise, continuing to traverse the fourth list for the entanglement instruction until the target entanglement instruction is traversed.
Accordingly, in the case where the traversal of the first list is completed, the updated fourth list is determined as the second instruction list. Thus, the process of deferring the processing of the state preparation instructions in the quantum measurement mode can be realized.
The process of deferring the state preparation instruction and the entanglement instruction in the quantum measurement mode is specifically as follows:
input: a first instruction list command of quantum measurement mode;
and (3) outputting: the reordered instruction list, the second instruction list.
Step 1: the list formed by all state preparation instructions in the first instruction list is marked as command_N (namely a first list), the list formed by all entanglement instructions is marked as command_E (namely a second list), and the list formed by all measurement instructions is marked as new_commands (namely a third list);
Step 2: the list commands_E is traversed circularly, the currently circulated element is recorded as cmd_E, and the following operation a) is performed:
a) Cycling through the list new_commands, recording the currently cycled element as cmd, and the cmd is in the ith bit of new_commands; if cmd is a measurement instruction and the acted node is included in the acted node of cmd_E, then cmd_E is inserted into the ith bit of the new_commands list and the layer cycle is jumped out; otherwise, continuing to traverse the list new_commands;
step 3: the list commands_N is traversed circularly, the element currently circulated is recorded as cmd_N, and the following operation b) is performed:
b) The list new_commands is cycled through, recording the currently cycled element as cmd, and cmd is at the j-th bit of new_commands: if cmd is an entangled instruction and the acted node contains the node acted by cmd_N, inserting cmd_N into the j-th bit of the new_commands list, and jumping out of the layer cycle; otherwise, continuing to traverse the list new_commands;
step 4: the new_commands list is returned as output, i.e., the second instruction list is output.
Optionally, the step S103 specifically includes:
for each instruction in the second instruction list, performing the following operations:
Obtaining a target node acted by the instruction;
determining a target identifier of a register unit of the quantum circuit allocated for the target node based on the target node and a register unit dictionary, wherein the register unit dictionary comprises a corresponding relation between the register unit and the nodes in the quantum measurement mode;
based on the target identification, carrying out equivalent compiling on the instruction to obtain an instruction in a quantum circuit equivalent to the instruction;
the third instruction list comprises instructions in the quantum circuit obtained through equivalent compiling.
In this embodiment, equivalent compilation may be performed for each instruction in the second instruction list.
The instructions in the second instruction list may include instruction types and acted node labels vertex, and the target node acted by the instructions may be obtained by obtaining vertex.
The target identification of the register cell of the quantum circuit allocated for the target node may be determined based on the target node and the constructed register cell dictionary. Wherein the register unit dictionary may be used for recording the state of the register unit, i.e. the keys of the data in the register unit dictionary may be the identities, e.g. labels, of the register units, and the corresponding values may be which node in the quantum measurement mode the register unit is assigned to.
For example, the registering unit dictionary may be: {0:a,1:none,2:b }, indicating that register unit 0 is allocated to node a, register unit 1 is idle (i.e., register unit 1 is not allocated), and register unit 2 is allocated to node b.
In an alternative embodiment, before performing equivalent compiling of the second instruction list, an empty register unit dictionary may be constructed, and correspondingly, when performing equivalent compiling of the instruction in the second instruction list, a register unit may be allocated for a node indicated by the instruction based on the register unit dictionary (e.g., if the register unit dictionary is empty, a new register unit may be created and an identifier of the register unit is recorded), and the register unit dictionary may be updated based on a correspondence between the node and the register unit, so as to record a state of the register unit. Thereafter, equivalent compilation of instructions in the second instruction list may proceed based on the nodes indicated by the instructions in the second instruction list and the updated register unit dictionary.
In the case of obtaining the target identifier, the instructions in the second instruction list may be equivalently compiled based on the target identifier, where the target identifier may indicate a qubit of a qubit acted upon by the instruction in a quantum circuit equivalent to the instruction. The equivalent compiling process will be described in detail in the following embodiments.
In this way, an equivalent compilation of instructions for the quantum measurement mode can be achieved to obtain instructions in the quantum circuit equivalent to the quantum measurement mode.
Optionally, the determining, based on the target node and the register unit dictionary, the target identifier of the register unit of the quantum circuit allocated to the target node includes at least one of the following:
under the condition that the corresponding relation of the target node is included in the register unit dictionary, determining the identification of the register unit corresponding to the target node as the target identification;
and under the condition that the corresponding relation of the target node is not included in the register unit dictionary, distributing the register unit to the target node based on the register unit dictionary, determining the identification of the register unit distributed by the target node as the target identification, and updating the register unit dictionary based on the identification of the register unit distributed by the target node.
In this embodiment, if the current node indicated by the instruction in the second instruction list is already loaded (i.e. a register unit has been allocated to the node), that is, the register unit dictionary may include a correspondence relationship between target nodes (e.g. 0:a, where node a is a target node), the identifier of the register unit corresponding to the target node may be determined as the target identifier (e.g. identifier 0 is determined as the target identifier), that is, the instruction may be executed on the register unit corresponding to the target identifier.
That is, if the instruction preceding the instruction in the second instruction list also indicates the target node and the register unit has been allocated to the target node (i.e. the register unit dictionary records the correspondence), then the instructions may all be executed on the register unit allocated to the target node.
If the current node is not loaded (i.e. the corresponding relation of the target node is not included in the register unit dictionary), a register unit can be allocated for the current node, the identification of the register unit allocated by the target node is determined as the target identification, and meanwhile, the register unit dictionary is updated based on the identification of the register unit allocated by the target node, i.e. the corresponding relation between the label of the target node and the target identification is added into the register unit dictionary. In this way, the number of qubits required to execute the model can be greatly reduced.
Optionally, the allocating a register unit for the target node based on the register unit dictionary includes at least one of:
under the condition that the registering unit dictionary comprises the identification of a first registering unit, the first registering unit is allocated to the target node, and the first registering unit is not allocated to the node;
And under the condition that the register unit dictionary does not comprise the identification of the first register unit, acquiring the number of the register units represented by the register unit dictionary, determining the identification of the created second register unit based on the number, and distributing the second register unit to the target node.
In this embodiment, the register units are dynamically increased as required, if there are idle units (e.g. 1: none, indicating that the register unit 1 is an idle register unit), then the idle units are preferentially allocated, otherwise a new register unit is created, and based on the number of register units represented by the register unit dictionary (e.g. register unit dictionary {0: a,1: b }, the number of represented register units is 2), the identity of the created second register unit is determined, and the second register unit is allocated to the target node. Thus, the width of the compiled dynamic quantum circuit can be ensured to be as small as possible.
Optionally, the first register unit is the smallest identified register unit among the register units not allocated to the node.
In this embodiment, the node may be searched for the idle unit with the smallest address in all created register units to allocate the register units, so that the register unit allocation may be ensured to be performed accurately and orderly.
The specific process of allocating register units to nodes is as follows:
input: registering a unit dictionary qreg, and calculating a node label vertex of an instruction in a quantum measurement mode;
and (3) outputting: the index idx of the register unit allocated, and the updated register unit dictionary qreg.
Step 1: searching for the vertex in qreg, if the vertex is allocated with a register unit, returning the index idx of the corresponding register unit, and returning to the register unit dictionary qreg; if vertex is not allocated a register unit, then the following operation a) continues:
operation a) searches for free register units in qreg, i.e. register units with corresponding values None, and records the list of labels of these register units as available_regs. If the available_regs is not an empty set, namely, an idle register unit exists currently, the smallest register unit label in the available_regs is found to be idx; if available_regs is an empty set, which indicates that no idle register unit exists currently, calculating the length of qreg to be n, creating a new register unit with a register unit label of n, and recording idx=n; updating a register unit qreg, and writing a value with a corresponding relation with idx as vertex;
step 2: the assigned quantum register unit index idx and the updated register unit dictionary qreg are returned.
Optionally, based on the target identifier, performing equivalent compiling on the instruction to obtain an instruction in the quantum circuit equivalent to the instruction, where the instruction includes at least one of the following:
under the condition that the instruction is a state preparation instruction, based on the target identifier, equivalently compiling the instruction into a reset operation instruction in a quantum circuit, wherein the reset operation instruction is used for resetting the quantum state of a register unit corresponding to the target identifier into the quantum state indicated by the state preparation instruction;
under the condition that the instruction is an entanglement instruction, based on the target identifier, equivalently compiling the instruction into a quantum gate operation instruction in a quantum circuit, wherein the quantum gate operation instruction is used for carrying out quantum gate operation corresponding to the entanglement instruction based on a register unit corresponding to the target identifier;
and under the condition that the instruction is a measurement instruction, based on the target identifier, equivalently compiling the instruction into a quantum measurement operation instruction in a quantum circuit, wherein the quantum measurement operation instruction is used for carrying out quantum measurement operation indicated by the measurement instruction based on a register unit corresponding to the target identifier.
In this embodiment, the instructions in the second instruction list may include an instruction type, which may be indicated as a state preparation instruction (e.g., N), an entanglement instruction (e.g., E), or a measurement instruction (e.g., M).
In the case that the instruction is determined to be the state preparation instruction based on the instruction type, the instruction can be equivalently compiled into a reset operation instruction in the quantum circuit based on the target identifier, wherein the reset operation instruction is used for resetting the quantum state of the register unit corresponding to the target identifier to the quantum state indicated by the state preparation instruction. For example, the state preparation instruction is [ N, vertex, matrix ], and can be equivalently compiled into [ reset, idx, matrix, none ] based on the target identifier idx. Wherein matrix is the quantum state indicated by the state preparation instructions.
In the case where the instruction is determined to be an entangled instruction based on the instruction type, the instruction is equivalently compiled into a quantum gate operation instruction in the quantum circuit based on the target identification, and the quantum gate operation instruction may be a CZ gate. For example, the entanglement instruction is [ E, [ vertex0, vertex1] ], and can be equivalently compiled into [ CZ, [ idx0, idx1], none ] based on the target identifier (vertex 0 corresponds to the target identifier idx0, vertex1 corresponds to the target identifier idx 1).
In the case where the instruction is determined to be a measurement instruction based on the instruction type, the instruction is equivalently compiled into a quantum measurement operation instruction in the quantum circuit based on the target identification. For example, the measurement instruction is [ M, vertex, angle, plane, domain_s, domain_t ], and can be equivalently compiled into [ measurement, idx, [ angle, plane, domain_s, domain_t ], vertex ] based on the target identifier idx.
In this way, an equivalent compilation of instructions of quantum measurement modes into instructions of quantum circuits can be achieved.
Optionally, in the case that the instruction is a measurement instruction, the quantum measurement operation instruction includes a measurement identifier, where the measurement identifier is a node identifier acted on by the measurement instruction.
In this embodiment, when the instruction is a measurement instruction in the equivalent compiling of the instruction, since multiple quantum measurements may occur in the same register unit, the quantum measurement operation instruction may carry a measurement identifier to identify the ID of the current measurement.
Correspondingly, the node identifier acted by the measurement instruction can be obtained, and the node identifier acted by the measurement instruction is determined to be the measurement identifier, for example, the vertex in [ angle, plane, domain_s, domain_t ], vertex ] is the node identifier of the measurement instruction, so that the accuracy of equivalent compiling can be improved.
Optionally, in the case that the instruction is a measurement instruction, after the instruction is equivalently compiled into a quantum measurement operation instruction in a quantum circuit based on the target identifier, the method further includes:
and updating the registering unit dictionary based on the target identifier, wherein the updated registering unit dictionary indicates that the registering unit corresponding to the target identifier is a registering unit which is not allocated to the node.
In this embodiment, when the instruction is a measurement instruction in the equivalent compilation of the instruction, after the equivalent compilation of the measurement instruction, the register unit denoted by idx in the register unit dictionary qreg may be recovered, that is, the value corresponding to the register unit denoted by idx is updated to None, and the register unit is indicated to be an idle unit, that is, a register unit not allocated to a node, for use by a subsequent instruction. Therefore, the width of the equivalent compiled dynamic quantum circuit can be ensured to be as small as possible, and the execution of the algorithm of the quantum circuit on hardware is facilitated.
The specific process of equivalent compiling is as follows:
input: instruction list commands (i.e., second instruction list) for quantum measurement mode;
and (3) outputting: instruction list of dynamic quantum circuit (i.e. third instruction list).
Step 1: initializing an empty registering unit dictionary qreg for recording the allocation condition of the current registering unit; initializing an empty list cir_list for recording an instruction list of the converted quantum circuit;
step 2: cycling through an instruction list command of a quantum measurement mode, and recording the currently cycled element (instruction) as cmd; and executing the following operations according to the instruction type carried by the instruction:
Operation a) if cmd is a state preparation instruction, let cmd= [ N, vertex, matrix ]; taking qreg and vertex as inputs to obtain output idx and updated qreg; generating an instruction gate= [ reset, idx, matrix, none ] in the quantum circuit;
operation b) if cmd is an entangled instruction, setting cmd= [ E, [ vertex0, vertex1] ]; taking qreg and vertex0 as inputs to obtain output idx0 and updated qreg; taking qreg and vertex1 as inputs to obtain output idx1 and updated qreg; generating instructions gate= [ CZ, [ idx0, idx1], none ] in the quantum circuit;
operation c) if cmd is a measurement instruction, set cmd= [ M, vertex, angle, plane, domain_s, domain_t ]; taking qreg and vertex as inputs to obtain output idx and updated qreg; generating instructions gate= [ measure, idx, [ angle, plane, domain_s, domain_t, vertex ] in the quantum circuit; recovering a unit marked with idx in the register unit dictionary qreg, namely writing a corresponding value into None;
step 3: adding an instruction gate in the generated quantum circuit into the cir_list;
step 4: and returning the cir_list as an output result.
Second embodiment
As shown in fig. 4, the present disclosure provides a quantum measurement mode-to-quantum circuit compiling apparatus 400, comprising:
A first obtaining module 401, configured to obtain a first instruction list of a quantum measurement mode, where the first instruction list includes a state preparation instruction, an entanglement instruction, and a measurement instruction;
the deferral processing module 402 is configured to defer the state preparation instruction and the entangled instruction in the quantum measurement mode based on the first instruction list, to obtain a second instruction list of the quantum measurement mode, where a relative position order of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and a relative position order of different instructions on a same node of the quantum measurement mode is unchanged, where the relative position order of the different instructions is: preparing instructions, entanglement instructions and measurement instructions from front to back;
and the equivalent compiling module 403 is configured to perform equivalent compiling of the instruction based on the second instruction list, and obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
Optionally, the deferral processing module 402 includes:
the splitting module is used for splitting the first instruction list to obtain a first list, a second list and a third list, wherein the first list is a list formed by state preparation instructions in the first instruction list, the second list is a list formed by entanglement instructions in the first instruction list, and the third list is a list formed by measurement instructions in the first instruction list;
The first deferral processing submodule is used for deferring the entangled instruction in the quantum measurement mode based on the second list and the third list to obtain a fourth list, the fourth list comprises the entangled instruction in the second list and the measurement instruction in the third list, and in the fourth list, different instructions on the same node of the quantum measurement mode keep the relative position sequence of the entangled instruction and the measurement instruction from front to back;
and the second deferral processing submodule is used for deferring the state preparation instruction in the quantum measurement mode based on the first list and the fourth list to obtain the second instruction list.
Optionally, the first deferral processing sub-module is specifically configured to:
traversing the second list aiming at the entanglement instructions, and recording the entanglement instructions of the current traversal;
traversing the third list aiming at the measurement instruction to obtain a target measurement instruction, wherein the node acted by the entanglement instruction of the current traversal comprises the node acted by the target measurement instruction;
inserting the currently traversed entanglement instruction into a first position in the third list, wherein the first position is the position of the target measurement instruction in the third list;
And determining the updated third list as the fourth list under the condition that the second list traversing is completed.
Optionally, the second deferral processing sub-module is specifically configured to:
traversing the state preparation instructions for the first list, and recording the state preparation instructions of the current traversal;
traversing the fourth list aiming at the entangled instruction to obtain a target entangled instruction, wherein the node acted by the target entangled instruction comprises the node acted by the currently traversed state preparation instruction;
inserting the currently traversed state preparation instruction into a second position in the fourth list, wherein the second position is the position of the target entanglement instruction in the fourth list;
and determining the updated fourth list as the second instruction list under the condition that the first list traversing is completed.
Optionally, the equivalent compiling module 403 includes:
the node acquisition sub-module is used for acquiring a target node acted by each instruction in the second instruction list;
the determining submodule is used for determining a target identifier of a register unit of the quantum circuit distributed for the target node based on the target node and a register unit dictionary, and the register unit dictionary comprises a corresponding relation between the register unit and the node in the quantum measurement mode;
And the equivalent compiling sub-module is used for carrying out equivalent compiling on the instruction based on the target identifier to obtain an instruction in the quantum circuit equivalent to the instruction, and the third instruction list comprises the instruction in the quantum circuit obtained by equivalent compiling.
Optionally, the determining submodule includes:
a first determining unit, configured to determine, when it is queried that the register unit dictionary includes a correspondence relation of the target node, an identifier of a register unit corresponding to the target node as the target identifier;
and the second determining unit is used for allocating a register unit to the target node based on the register unit dictionary under the condition that the corresponding relation of the target node is not included in the register unit dictionary, determining the identification of the register unit allocated by the target node as the target identification, and updating the register unit dictionary based on the identification of the register unit allocated by the target node.
Optionally, the second determining unit is specifically configured to:
under the condition that the registering unit dictionary comprises the identification of a first registering unit, the first registering unit is allocated to the target node, and the first registering unit is not allocated to the node;
And under the condition that the register unit dictionary does not comprise the identification of the first register unit, acquiring the number of the register units represented by the register unit dictionary, determining the identification of the created second register unit based on the number, and distributing the second register unit to the target node.
Optionally, the first register unit is the smallest identified register unit among the register units not allocated to the node.
Optionally, the equivalent compiling submodule includes:
the first equivalent compiling unit is used for equivalently compiling the instruction into a reset operation instruction in the quantum circuit based on the target identifier under the condition that the instruction is a state preparation instruction, wherein the reset operation instruction is used for resetting the quantum state of the register unit corresponding to the target identifier into the quantum state indicated by the state preparation instruction;
the second equivalent compiling unit is used for equivalently compiling the instruction into a quantum gate operation instruction in a quantum circuit based on the target identifier under the condition that the instruction is an entanglement instruction, wherein the quantum gate operation instruction is used for carrying out quantum gate operation corresponding to the entanglement instruction based on a register unit corresponding to the target identifier;
And the third equivalent compiling unit is used for equivalently compiling the instruction into a quantum measurement operation instruction in a quantum circuit based on the target identifier under the condition that the instruction is a measurement instruction, wherein the quantum measurement operation instruction is used for carrying out quantum measurement operation indicated by the measurement instruction based on a register unit corresponding to the target identifier.
Optionally, in a case where the instruction is a measurement instruction, the quantum measurement operation instruction includes a measurement identifier, and the apparatus further includes:
the second acquisition module is used for acquiring the node identification acted by the measurement instruction;
and the determining module is used for determining the node identification acted by the measurement instruction as the measurement identification.
Optionally, in the case that the instruction is a measurement instruction, the apparatus further includes:
and the updating module is used for updating the registering unit dictionary based on the target identifier, and the updated registering unit dictionary indicates that the registering unit corresponding to the target identifier is a registering unit which is not allocated to the node.
The quantum measurement mode-to-quantum circuit compiling device 400 provided by the present disclosure can realize each process realized by the quantum measurement mode-to-quantum circuit compiling method embodiment, and can achieve the same beneficial effects, so that repetition is avoided, and no further description is provided here.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
FIG. 5 illustrates a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 5, the apparatus 500 includes a computing unit 501 that can perform various suitable actions and processes according to a computer program stored in a Read Only Memory (ROM) 502 or a computer program loaded from a storage unit 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, ROM 502, and RAM 503 are connected to each other by a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Various components in the device 500 are connected to the I/O interface 505, including: an input unit 506 such as a keyboard, a mouse, etc.; an output unit 507 such as various types of displays, speakers, and the like; a storage unit 508 such as a magnetic disk, an optical disk, or the like; and a communication unit 509 such as a network card, modem, wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 501 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 501 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as the quantum measurement mode-to-quantum circuit compilation method. For example, in some embodiments, the quantum measurement mode-to-quantum circuit compilation method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 500 via the ROM 502 and/or the communication unit 509. When a computer program is loaded into RAM 503 and executed by computing unit 501, one or more steps of the quantum measurement mode-to-quantum circuit compilation method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the quantum measurement mode-to-quantum circuit compilation method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (25)

1. A method of compiling a quantum measurement mode into a quantum circuit, comprising:
acquiring a first instruction list of a quantum measurement mode, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction;
based on the first instruction list, deferring the state preparation instruction and the entanglement instruction in the quantum measurement mode to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, and the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is as follows: preparing instructions, entanglement instructions and measurement instructions from front to back;
And performing equivalent compiling of instructions based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
2. The method of claim 1, wherein deferring the state preparation instructions and entanglement instructions in the quantum measurement mode based on the first instruction list to obtain a second instruction list of the quantum measurement mode, comprising:
splitting the first instruction list to obtain a first list, a second list and a third list, wherein the first list is a list formed by state preparation instructions in the first instruction list, the second list is a list formed by entanglement instructions in the first instruction list, and the third list is a list formed by measurement instructions in the first instruction list;
based on the second list and the third list, deferring the entangled instruction in the quantum measurement mode to obtain a fourth list, wherein the fourth list comprises entangled instructions in the second list and measurement instructions in the third list, and in the fourth list, different instructions on the same node of the quantum measurement mode keep relative position sequences of the entangled instruction and the measurement instruction from front to back;
And carrying out deferral processing on the state preparation instruction in the quantum measurement mode based on the first list and the fourth list to obtain the second instruction list.
3. The method of claim 2, wherein deferring entangled instructions in the quantum measurement mode based on the second list and the third list to obtain a fourth list, comprising:
traversing the second list aiming at the entanglement instructions, and recording the entanglement instructions of the current traversal;
traversing the third list aiming at the measurement instruction to obtain a target measurement instruction, wherein the node acted by the entanglement instruction of the current traversal comprises the node acted by the target measurement instruction;
inserting the currently traversed entanglement instruction into a first position in the third list, wherein the first position is the position of the target measurement instruction in the third list;
and determining the updated third list as the fourth list under the condition that the second list traversing is completed.
4. The method of claim 2, wherein deferring state preparation instructions in the quantum measurement mode based on the first list and the fourth list to obtain the second list of instructions, comprising:
Traversing the state preparation instructions for the first list, and recording the state preparation instructions of the current traversal;
traversing the fourth list aiming at the entangled instruction to obtain a target entangled instruction, wherein the node acted by the target entangled instruction comprises the node acted by the currently traversed state preparation instruction;
inserting the currently traversed state preparation instruction into a second position in the fourth list, wherein the second position is the position of the target entanglement instruction in the fourth list;
and determining the updated fourth list as the second instruction list under the condition that the first list traversing is completed.
5. The method of claim 1, wherein the performing equivalent compilation of instructions based on the second instruction list results in a third instruction list of a quantum circuit equivalent to the quantum measurement mode, comprising:
for each instruction in the second instruction list, performing the following operations:
obtaining a target node acted by the instruction;
determining a target identifier of a register unit of the quantum circuit allocated for the target node based on the target node and a register unit dictionary, wherein the register unit dictionary comprises a corresponding relation between the register unit and the nodes in the quantum measurement mode;
Based on the target identification, carrying out equivalent compiling on the instruction to obtain an instruction in a quantum circuit equivalent to the instruction;
the third instruction list comprises instructions in the quantum circuit obtained through equivalent compiling.
6. The method of claim 5, wherein the determining, based on the target node and a register unit dictionary, a target identification of a register unit of a quantum circuit allocated for the target node comprises at least one of:
under the condition that the corresponding relation of the target node is included in the register unit dictionary, determining the identification of the register unit corresponding to the target node as the target identification;
and under the condition that the corresponding relation of the target node is not included in the register unit dictionary, distributing the register unit to the target node based on the register unit dictionary, determining the identification of the register unit distributed by the target node as the target identification, and updating the register unit dictionary based on the identification of the register unit distributed by the target node.
7. The method of claim 6, wherein the allocating a register unit for the target node based on the register unit dictionary comprises at least one of:
Under the condition that the registering unit dictionary comprises the identification of a first registering unit, the first registering unit is allocated to the target node, and the first registering unit is not allocated to the node;
and under the condition that the register unit dictionary does not comprise the identification of the first register unit, acquiring the number of the register units represented by the register unit dictionary, determining the identification of the created second register unit based on the number, and distributing the second register unit to the target node.
8. The method of claim 7, wherein the first register unit is a least-identified register unit of the register units not allocated to the node.
9. The method of claim 5, wherein the equivalently compiling the instruction based on the target identifier to obtain an instruction in a quantum circuit equivalent to the instruction comprises at least one of:
under the condition that the instruction is a state preparation instruction, based on the target identifier, equivalently compiling the instruction into a reset operation instruction in a quantum circuit, wherein the reset operation instruction is used for resetting the quantum state of a register unit corresponding to the target identifier into the quantum state indicated by the state preparation instruction;
Under the condition that the instruction is an entanglement instruction, based on the target identifier, equivalently compiling the instruction into a quantum gate operation instruction in a quantum circuit, wherein the quantum gate operation instruction is used for carrying out quantum gate operation corresponding to the entanglement instruction based on a register unit corresponding to the target identifier;
and under the condition that the instruction is a measurement instruction, based on the target identifier, equivalently compiling the instruction into a quantum measurement operation instruction in a quantum circuit, wherein the quantum measurement operation instruction is used for carrying out quantum measurement operation indicated by the measurement instruction based on a register unit corresponding to the target identifier.
10. The method of claim 9, wherein, in the event that the instruction is a measurement instruction, the quantum measurement operation instruction includes a measurement identity that is a node identity acted upon by the measurement instruction.
11. The method of claim 9, wherein, in the case where the instruction is a measurement instruction, after the equivalent compilation of the instruction into a quantum measurement operation instruction in a quantum circuit based on the target identification, the method further comprises:
and updating the registering unit dictionary based on the target identifier, wherein the updated registering unit dictionary indicates that the registering unit corresponding to the target identifier is a registering unit which is not allocated to the node.
12. A quantum measurement mode-to-quantum circuit compiling apparatus, comprising:
the first acquisition module is used for acquiring a first instruction list of the quantum measurement mode, wherein the first instruction list comprises a state preparation instruction, an entanglement instruction and a measurement instruction;
the deferral processing module is configured to defer the state preparation instruction and the entanglement instruction in the quantum measurement mode based on the first instruction list to obtain a second instruction list of the quantum measurement mode, wherein the relative position sequence of each measurement instruction in the first instruction list and the second instruction list is kept unchanged, the relative position sequence of different instructions on the same node of the quantum measurement mode is unchanged, and the relative position sequence of the different instructions is: preparing instructions, entanglement instructions and measurement instructions from front to back;
and the equivalent compiling module is used for carrying out equivalent compiling of the instruction based on the second instruction list to obtain a third instruction list of the quantum circuit equivalent to the quantum measurement mode.
13. The apparatus of claim 12, wherein the deferral processing module comprises:
the splitting module is used for splitting the first instruction list to obtain a first list, a second list and a third list, wherein the first list is a list formed by state preparation instructions in the first instruction list, the second list is a list formed by entanglement instructions in the first instruction list, and the third list is a list formed by measurement instructions in the first instruction list;
The first deferral processing submodule is used for deferring the entangled instruction in the quantum measurement mode based on the second list and the third list to obtain a fourth list, the fourth list comprises the entangled instruction in the second list and the measurement instruction in the third list, and in the fourth list, different instructions on the same node of the quantum measurement mode keep the relative position sequence of the entangled instruction and the measurement instruction from front to back;
and the second deferral processing submodule is used for deferring the state preparation instruction in the quantum measurement mode based on the first list and the fourth list to obtain the second instruction list.
14. The apparatus of claim 13, wherein the first deferral processing sub-module is specifically configured to:
traversing the second list aiming at the entanglement instructions, and recording the entanglement instructions of the current traversal;
traversing the third list aiming at the measurement instruction to obtain a target measurement instruction, wherein the node acted by the entanglement instruction of the current traversal comprises the node acted by the target measurement instruction;
inserting the currently traversed entanglement instruction into a first position in the third list, wherein the first position is the position of the target measurement instruction in the third list;
And determining the updated third list as the fourth list under the condition that the second list traversing is completed.
15. The apparatus of claim 13, wherein the second deferral processing sub-module is specifically configured to:
traversing the state preparation instructions for the first list, and recording the state preparation instructions of the current traversal;
traversing the fourth list aiming at the entangled instruction to obtain a target entangled instruction, wherein the node acted by the target entangled instruction comprises the node acted by the currently traversed state preparation instruction;
inserting the currently traversed state preparation instruction into a second position in the fourth list, wherein the second position is the position of the target entanglement instruction in the fourth list;
and determining the updated fourth list as the second instruction list under the condition that the first list traversing is completed.
16. The apparatus of claim 12, wherein the equivalent compiling module comprises:
the node acquisition sub-module is used for acquiring a target node acted by each instruction in the second instruction list;
the determining submodule is used for determining a target identifier of a register unit of the quantum circuit distributed for the target node based on the target node and a register unit dictionary, and the register unit dictionary comprises a corresponding relation between the register unit and the node in the quantum measurement mode;
And the equivalent compiling sub-module is used for carrying out equivalent compiling on the instruction based on the target identifier to obtain an instruction in the quantum circuit equivalent to the instruction, and the third instruction list comprises the instruction in the quantum circuit obtained by equivalent compiling.
17. The apparatus of claim 16, wherein the determination submodule comprises:
a first determining unit, configured to determine, when it is queried that the register unit dictionary includes a correspondence relation of the target node, an identifier of a register unit corresponding to the target node as the target identifier;
and the second determining unit is used for allocating a register unit to the target node based on the register unit dictionary under the condition that the corresponding relation of the target node is not included in the register unit dictionary, determining the identification of the register unit allocated by the target node as the target identification, and updating the register unit dictionary based on the identification of the register unit allocated by the target node.
18. The apparatus of claim 17, wherein the second determining unit is specifically configured to:
under the condition that the registering unit dictionary comprises the identification of a first registering unit, the first registering unit is allocated to the target node, and the first registering unit is not allocated to the node;
And under the condition that the register unit dictionary does not comprise the identification of the first register unit, acquiring the number of the register units represented by the register unit dictionary, determining the identification of the created second register unit based on the number, and distributing the second register unit to the target node.
19. The apparatus of claim 18, wherein the first register unit is a least-identified register unit of the register units not allocated to the node.
20. The apparatus of claim 16, wherein the equivalent compiling sub-module comprises:
the first equivalent compiling unit is used for equivalently compiling the instruction into a reset operation instruction in the quantum circuit based on the target identifier under the condition that the instruction is a state preparation instruction, wherein the reset operation instruction is used for resetting the quantum state of the register unit corresponding to the target identifier into the quantum state indicated by the state preparation instruction;
the second equivalent compiling unit is used for equivalently compiling the instruction into a quantum gate operation instruction in a quantum circuit based on the target identifier under the condition that the instruction is an entanglement instruction, wherein the quantum gate operation instruction is used for carrying out quantum gate operation corresponding to the entanglement instruction based on a register unit corresponding to the target identifier;
And the third equivalent compiling unit is used for equivalently compiling the instruction into a quantum measurement operation instruction in a quantum circuit based on the target identifier under the condition that the instruction is a measurement instruction, wherein the quantum measurement operation instruction is used for carrying out quantum measurement operation indicated by the measurement instruction based on a register unit corresponding to the target identifier.
21. The apparatus of claim 20, wherein, where the instruction is a measurement instruction, the quantum measurement operation instruction includes a measurement identity that is a node identity acted upon by the measurement instruction.
22. The apparatus of claim 20, wherein, in the case where the instruction is a measurement instruction, the apparatus further comprises:
and the updating module is used for updating the registering unit dictionary based on the target identifier, and the updated registering unit dictionary indicates that the registering unit corresponding to the target identifier is a registering unit which is not allocated to the node.
23. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.
24. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-11.
25. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-11.
CN202310147343.XA 2023-02-20 2023-02-20 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment Active CN116187463B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310147343.XA CN116187463B (en) 2023-02-20 2023-02-20 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310147343.XA CN116187463B (en) 2023-02-20 2023-02-20 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN116187463A true CN116187463A (en) 2023-05-30
CN116187463B CN116187463B (en) 2023-10-03

Family

ID=86444073

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310147343.XA Active CN116187463B (en) 2023-02-20 2023-02-20 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN116187463B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11348027B1 (en) * 2021-03-22 2022-05-31 Alibaba Singapore Holding Private Limited Methods and systems of fully-randomized benchmarking for quantum circuits
CN115169570A (en) * 2022-07-26 2022-10-11 北京百度网讯科技有限公司 Quantum network protocol simulation method and device and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11348027B1 (en) * 2021-03-22 2022-05-31 Alibaba Singapore Holding Private Limited Methods and systems of fully-randomized benchmarking for quantum circuits
CN115169570A (en) * 2022-07-26 2022-10-11 北京百度网讯科技有限公司 Quantum network protocol simulation method and device and electronic equipment

Also Published As

Publication number Publication date
CN116187463B (en) 2023-10-03

Similar Documents

Publication Publication Date Title
CN115169570B (en) Quantum network protocol simulation method and device and electronic equipment
CN110941494A (en) Deep learning-oriented GPU parallel computing data processing method
CN116151384B (en) Quantum circuit processing method and device and electronic equipment
CN114970865B (en) Quantum circuit processing method and device on quantum chip and electronic equipment
CN114691148B (en) Model reasoning acceleration method, device, electronic equipment and storage medium
CN115860128A (en) Quantum circuit operation method and device and electronic equipment
CN113312175A (en) Operator determining and operating method and device
CN116167445B (en) Quantum measurement mode processing method and device and electronic equipment
CN116611527B (en) Quantum circuit processing method and device and electronic equipment
CN116151381B (en) Quantum circuit processing method and device and electronic equipment
CN116167446B (en) Quantum computing processing method and device and electronic equipment
CN116187463B (en) Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment
CN116187464B (en) Blind quantum computing processing method and device and electronic equipment
CN113408304B (en) Text translation method and device, electronic equipment and storage medium
CN116167447B (en) Quantum circuit processing method and device and electronic equipment
CN116187458B (en) Quantum circuit processing method and device and electronic equipment
CN113408636A (en) Pre-training model obtaining method and device, electronic equipment and storage medium
CN117827619B (en) Time-consuming prediction simulation method, device, equipment, medium and system for heterogeneous calculation force
CN117391206A (en) Quantum circuit processing method and device and electronic equipment
CN117313878A (en) Quantum circuit processing method and device and electronic equipment
CN117313882A (en) Quantum circuit processing method and device and electronic equipment
CN116226314A (en) Method and device for processing objects in object storage
CN117313877A (en) Quantum circuit processing method and device and electronic equipment
CN117313880A (en) Quantum circuit processing method and device and electronic equipment
CN115983281A (en) Information extraction and model acquisition method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40088768

Country of ref document: HK