Disclosure of Invention
The invention aims to provide a method, a device, a storage medium, electronic equipment and a system for debugging a quantum program, which aim to realize the debugging of the quantum program.
In a first aspect, an embodiment of the present invention provides a quantum program debugging method, applied to a front-end display device, the method including:
responding to an execution instruction sent by a user, and sending a quantum program, a breakpoint set in the quantum program and a current operating point to background processing equipment;
And receiving and displaying a target calculation result sent by the background processing equipment, wherein the target calculation result is calculated by quantum computing equipment aiming at a target calculation task and is sent to the background processing equipment, and the target calculation task is created by the background processing equipment based on the quantum program, the breakpoint and the current running point and is sent to the quantum computing equipment.
Optionally, the target computing task is a computing task corresponding to a target breakpoint in a plurality of computing tasks created by the background processing device based on the quantum program, and the target breakpoint is determined by the background processing device based on the breakpoint and the current running point.
Optionally, the quantum logic gate corresponding to the position of the target breakpoint is a quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point.
Optionally, a plurality of the computing tasks are sent to the quantum computing device in order of priority of the plurality of computing tasks from high to low.
Optionally, the calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position where the target breakpoint is located is a secondary target calculation task, and the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after the receiving and displaying the target calculation result sent by the background processing device, the method further includes:
Responding to a single step forward instruction or a single step backward instruction sent by the user, and receiving and displaying a secondary target calculation result sent by the background processing equipment; and the secondary target calculation result is calculated by the quantum computing device aiming at the secondary target calculation task and is sent to the background processing device.
Optionally, after the receiving and displaying the target calculation result sent by the background processing device, the method further includes:
And responding to a single-step forward instruction or a single-step backward instruction sent by the user, updating the current execution point, and sending the updated current execution point to the background processing equipment so that the background processing equipment adjusts the priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
In a second aspect, an embodiment of the present invention provides a quantum program debugging method, applied to a background processing apparatus, the method comprising:
Receiving a quantum program sent by front-end display equipment, a breakpoint set in the quantum program and a current operating point;
creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
Receiving a target calculation result calculated by the quantum computing device aiming at the target calculation task;
And sending the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user and displays the target calculation result.
Optionally, the creating a target computing task based on the quantum program, the breakpoint, and the current running point includes:
creating a plurality of computing tasks based on the quantum program, and determining a target breakpoint based on the breakpoint and the current operating point;
And determining a target computing task corresponding to the target breakpoint from a plurality of computing tasks.
Optionally, the determining the target breakpoint based on the breakpoint and the current operation point includes:
And determining the quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point, as the quantum logic gate corresponding to the position of the target breakpoint, and determining the first breakpoint as the target breakpoint.
Optionally, the sending the target computing task to a quantum computing device includes:
and sequentially sending the plurality of computing tasks to the quantum computing device according to the order of the priorities of the plurality of computing tasks from high to low.
Optionally, before the sending the plurality of computing tasks to the quantum computing device in order of priority of the plurality of computing tasks from high to low, the method further includes:
And determining a calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position of the target breakpoint as a secondary target calculation task, wherein the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method further includes:
receiving a secondary target calculation result calculated by the quantum computing device aiming at the secondary target calculation task;
And sending the secondary target calculation result to the front-end display device, so that the front-end display device responds to a single-step forward instruction or a single-step backward instruction sent by a user to display the secondary target calculation result.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method further includes:
Receiving a new current execution point sent by the front-end display device, wherein the new current execution point is updated by the front-end display device in response to a single-step forward instruction or a single-step backward instruction sent by a user;
And adjusting the priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
In a third aspect, an embodiment of the present invention provides a quantum program debugging apparatus, applied to a front-end display device, the apparatus comprising:
The communication unit is used for responding to an execution instruction sent by a user and sending a quantum program, a breakpoint set in the quantum program and a current running point to the background processing equipment;
The display unit is further used for receiving and displaying a target calculation result sent by the background processing device, wherein the target calculation result is calculated by the quantum computing device according to a target calculation task and sent to the background processing device, and the target calculation task is created by the background processing device based on the quantum program, the breakpoint and the current running point and sent to the quantum computing device.
Optionally, the target computing task is a computing task corresponding to a target breakpoint in a plurality of computing tasks created by the background processing device based on the quantum program, and the target breakpoint is determined by the background processing device based on the breakpoint and the current running point.
Optionally, the quantum logic gate corresponding to the position of the target breakpoint is a quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point.
Optionally, a plurality of the computing tasks are sent to the quantum computing device in order of priority of the plurality of computing tasks from high to low.
Optionally, the calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position where the target breakpoint is located is a secondary target calculation task, and the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving and displaying the target calculation result sent by the background processing device, the display unit is further configured to:
Responding to a single step forward instruction or a single step backward instruction sent by the user, and receiving and displaying a secondary target calculation result sent by the background processing equipment; and the secondary target calculation result is calculated by the quantum computing device aiming at the secondary target calculation task and is sent to the background processing device.
Optionally, after receiving and displaying the target calculation result sent by the background processing device, the communication unit is further configured to:
And responding to a single-step forward instruction or a single-step backward instruction sent by the user, updating the current execution point, and sending the updated current execution point to the background processing equipment so that the background processing equipment adjusts the priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
In a fourth aspect, an embodiment of the present invention provides a quantum program debugging apparatus, applied to a background processing device, the apparatus comprising:
The communication unit is used for receiving the quantum program sent by the front-end display device, the breakpoint set in the quantum program and the current running point;
A processing unit for creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
the communication unit is further used for receiving a target calculation result calculated by the quantum computing device aiming at the target calculation task;
The communication unit is further configured to send the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user and displays the target calculation result.
Optionally, the creating a target computing task based on the quantum program, the breakpoint, and the current running point, and the processing unit is specifically configured to:
creating a plurality of computing tasks based on the quantum program, and determining a target breakpoint based on the breakpoint and the current operating point;
And determining a target computing task corresponding to the target breakpoint from a plurality of computing tasks.
Optionally, the determining a target breakpoint based on the breakpoint and the current operating point, where the processing unit 602 is specifically configured to:
And determining the quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point, as the quantum logic gate corresponding to the position of the target breakpoint, and determining the first breakpoint as the target breakpoint.
Optionally, the sending the target computing task to a quantum computing device, and the communication unit is specifically configured to:
and sequentially sending the plurality of computing tasks to the quantum computing device according to the order of the priorities of the plurality of computing tasks from high to low.
Optionally, before the sending the plurality of computing tasks to the quantum computing device in order of priority of the plurality of computing tasks from high to low, the processing unit is further configured to:
And determining a calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position of the target breakpoint as a secondary target calculation task, wherein the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the communication unit is further configured to:
receiving a secondary target calculation result calculated by the quantum computing device aiming at the secondary target calculation task;
And sending the secondary target calculation result to the front-end display device, so that the front-end display device responds to a single-step forward instruction or a single-step backward instruction sent by a user to display the secondary target calculation result.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method includes:
The communication unit is further configured to receive a new current execution point sent by the front-end display device, where the new current execution point is updated by the front-end display device in response to a single-step forward instruction or a single-step backward instruction sent by a user;
the processing unit is further configured to adjust priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
In a fifth aspect, a further embodiment of the invention provides a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the method of any of the first or second aspects above when run.
In a sixth aspect, a further embodiment of the invention provides an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the method of any of the first or second aspects above.
In a seventh aspect, a further embodiment of the invention provides a quantum program debugging system, the system comprising a front-end display device comprising quantum program debugging means as described in the third aspect and a background processing device comprising quantum program debugging means as described in the fourth aspect.
Compared with the prior art, the front-end display device responds to an execution instruction sent by a user, sends the quantum program, the breakpoint and the current running point set in the quantum program to the background processing device, creates a target calculation task based on the received quantum program, the breakpoint and the current running point, then sends the target calculation task to the quantum calculation device, calculates the target calculation task to obtain a target calculation result, and forwards the target calculation result to the front-end display device through the background quantum calculation device for display, so that the user can debug the quantum program based on the displayed target calculation result.
Detailed Description
The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
The embodiment of the invention firstly provides a quantum program debugging method which can be applied to electronic equipment such as computer terminals, in particular to common computers, quantum computers and the like.
The following describes the operation of the computer terminal in detail by taking it as an example. Fig. 1 is a hardware block diagram of a computer terminal of a quantum program debugging method according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one is shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA) and a memory 104 for storing a quantum program debugging method, and optionally, a transmission device 106 for communication functions and an input-output device 108. It will be appreciated by those skilled in the art that the configuration shown in fig. 1 is merely illustrative and is not intended to limit the configuration of the computer terminal described above. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the method of quantum program debugging in the embodiment of the present invention, and the processor 102 executes the software programs and modules stored in the memory 104 to perform various functional applications and data processing, i.e., implement the method described above. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located relative to the processor 102, which may be connected to the computer terminal via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission means 106 is arranged to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
It should be noted that a real quantum computer is a hybrid structure, which includes two major parts: part of the computers are classical computers and are responsible for performing classical computation and control; the other part is quantum equipment, which is responsible for running quantum programs so as to realize quantum computation. The quantum program is a series of instruction sequences written in a quantum language such as QRunes language and capable of running on a quantum computer, so that the support of quantum logic gate operation is realized, and finally, quantum computing is realized. Specifically, the quantum program is a series of instruction sequences for operating the quantum logic gate according to a certain time sequence.
In practical applications, quantum computing simulations are often required to verify quantum algorithms, quantum applications, etc., due to the development of quantum device hardware. Quantum computing simulation is a process of realizing simulated operation of a quantum program corresponding to a specific problem by means of a virtual architecture (namely a quantum virtual machine) built by resources of a common computer. In general, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program, namely the program for representing the quantum bit and the evolution thereof written in the classical language, wherein the quantum bit, the quantum logic gate and the like related to quantum computation are all represented by corresponding classical codes.
Quantum circuits, which are one embodiment of quantum programs and weigh sub-logic circuits as well, are the most commonly used general quantum computing models, representing circuits that operate on qubits under an abstract concept, and their composition includes qubits, circuits (timelines), and various quantum logic gates, and finally the result often needs to be read out through quantum measurement operations.
Unlike conventional circuits, which are connected by metal lines to carry voltage or current signals, in a quantum circuit, the circuit can be seen as being connected by time, i.e., the state of the qubit naturally evolves over time, as indicated by the hamiltonian operator, during which it is operated until a logic gate is encountered.
One quantum program is corresponding to one total quantum circuit, and the quantum program refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits of the quantum program. It can be understood that: one quantum program may consist of a quantum circuit, a measurement operation for the quantum bits in the quantum circuit, a register to hold the measurement results, and a control flow node (jump instruction), and one quantum circuit may contain several tens of hundreds or even thousands of quantum logic gate operations. The execution process of the quantum program is a process of executing all quantum logic gates according to a certain time sequence. Note that the timing is the time sequence in which a single quantum logic gate is executed.
It should be noted that in classical computation, the most basic unit is a bit, and the most basic control mode is a logic gate, and the purpose of the control circuit can be achieved by a combination of logic gates. Similarly, the way in which the qubits are handled is a quantum logic gate. Quantum logic gates are used, which are the basis for forming quantum circuits, and include single-bit quantum logic gates, such as Hadamard gates (H gates, ada Ma Men), bery-X gates (X gates), bery-Y gates (Y gates), bery-Z gates (Z gates), RX gates, RY gates, RZ gates, and the like; multi-bit quantum logic gates such as CNOT gates, CR gates, iSWAP gates, toffoli gates, and the like. Quantum logic gates are typically represented using unitary matrices, which are not only in matrix form, but also an operation and transformation. The general function of a quantum logic gate on a quantum state is to calculate through a unitary matrix multiplied by a matrix corresponding to the right vector of the quantum state.
Referring to fig. 2, fig. 2 is a flow chart of a quantum program debugging method provided by an embodiment of the present invention, which is applied to a front-end display device, and the method includes:
Step 201: responding to an execution instruction sent by a user, and sending a quantum program, a breakpoint set in the quantum program and a current operating point to background processing equipment;
the executing instruction and the single step forward instruction or the single step backward instruction described below may be triggered by detecting a click or a touch operation of a user on a certain target area of the front-end display device. For example, the front-end display device includes a display screen or touch screen on which a debugging interface for the quantum program is displayed, the interface including execution buttons. And triggering the execution instruction when detecting the clicking or touch operation of the execution button by the user.
The execution instructions may include breakpoint execution instructions and execution instructions. The running instruction refers to the running from the first quantum logic gate to the quantum logic gate where the first breakpoint is located in the quantum circuit, and the breakpoint executing instruction refers to the running from the quantum logic gate where the current running point is located in the quantum circuit to the quantum logic gate where the next breakpoint is located.
The quantum program may be a patterned quantum program or a quantum program formed by codes written in a quantum programming language, and is not limited herein.
Wherein, the breakpoint is a mark that the debugger sets the source program to automatically enter an interrupt mode during execution. When the program runs to the breakpoint, the program is interrupted to execute and enters a debugging state. Errors in the running of the program can be found by setting breakpoints. The break point set in the quantum program may be on a quantum logic gate in the quantum wire.
The current execution point may be located on the last quantum logic gate that is currently executed.
Step 202: and receiving and displaying a target calculation result sent by the background processing equipment, wherein the target calculation result is calculated by quantum computing equipment aiming at a target calculation task and is sent to the background processing equipment, and the target calculation task is created by the background processing equipment based on the quantum program, the breakpoint and the current running point and is sent to the quantum computing equipment.
The quantum computing device is a real quantum chip and/or a quantum virtual machine.
The quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result comprises a real computing result computed by the real quantum chip and a simulation computing result computed by the quantum virtual machine.
It can be seen that the user can comprehensively judge the bug of the quantum program by combining the real calculation result and the simulation calculation result, and debug the bug, namely the debugging of the quantum program is realized.
Specifically, the target computing task created by the background processing device based on the quantum program, the breakpoint, and the current running point and sent to the quantum computing device may be:
The target computing task is a computing task corresponding to a target breakpoint in a plurality of computing tasks created by the background processing equipment based on the quantum program, and the target breakpoint is determined by the background processing equipment based on the breakpoint and the current running point.
Further, the background processing device creates a plurality of computing tasks based on the quantum program, which may be:
the background processing device determines all quantum logic gates included in the quantum program;
the background processing device determines each of the quantum logic gates and a quantum logic gate preceding each of the quantum logic gates;
The background processing equipment adds measurement operation on each quantum logic gate and a quantum bit acted by a quantum logic gate before each quantum logic gate to construct a plurality of quantum circuits;
The background processing equipment creates a plurality of quantum computing tasks corresponding to the quantum circuits.
For example, assume that the quantum wires are cir0 < H q <1 > - > H q <2 > - > CNOT q 1, q 2 > - > MEASURE q 1, q 2. Wherein H, CNOT is a quantum logic gate, q 1, q 2 are qubits, and measurement is a measurement operation. The first quantum circuit is cir1 < Hq 1 > - > MEASURE q 1, q 2, the second quantum circuit is cir2 < H q [1] - > H q [2] - > MEASURE q 1, q 2, the third quantum circuit is cir3 < H q [1] - > H q [2] - > MEASURE q 1, q 2, the quantum circuit is constructed by accumulating the current quantum logic gate with the previous quantum logic gate and then adding measurement works, and the number of the quantum circuits is the same as that of the quantum logic gates.
It should be noted that the addition of a measurement operation to all the qubits may be performed by adding a measurement operation to only the qubits having the quantum logic gate function. For example, quantum circuit cir1 has only H q [1], and the added measurement operation can also be M q [1].
Further, the target breakpoint is determined by the background processing device based on the breakpoint and the current running point, including:
the quantum logic gate corresponding to the position of the target breakpoint is the quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point.
For example, as shown in fig. 3, fig. 3 is an interface schematic diagram of a quantum program debugging interface according to an embodiment of the present invention. The interface includes a patterned quantum circuit and a quantum circuit written by a code in a code compiler, and related buttons for debugging the interface, such as a reset button indicated by "<",An execute button represented, ">" a single step forward button represented, ">" a full execute button represented, and a clear breakpoint button. When the related operation is carried out on the graphical quantum circuit, the quantum circuit written by the code in the code compiler can also carry out the corresponding operation at the same time, and similarly, when the related operation is carried out on the quantum circuit written by the code in the code compiler, the graphical quantum circuit carries out the corresponding operation.
In fig. 3, the quantum logic gate corresponding to the current execution point is T q [1], which includes two break points, wherein one of the break points corresponds to a quantum logic gate of CNOT q [1], q [0], and the other of the break points corresponds to a quantum logic gate of CNOT q [2], q [0]. The quantum logic gate corresponding to the position of the target breakpoint is the quantum logic gate corresponding to the position of the first breakpoint operated after the quantum logic gate corresponding to the position of the current operating point, and the quantum logic gate corresponding to the target breakpoint can be determined to be CNOT q [1], q [0].
Further, the plurality of computing tasks are sent to the quantum computing device in order of priority of the plurality of computing tasks from high to low.
The quantum logic gate of the position of the target breakpoint and the calculation task corresponding to the quantum logic gate of the next operation are secondary target calculation tasks, and the priority of the secondary target calculation tasks is lower than that of the target calculation tasks and higher than that of other calculation tasks.
Also illustrated in FIG. 3, the quantum logic gates at the locations of the target break points in FIG. 3 are CNOT q [1], q [0], which correspond to the target computing tasks of: h q [0] - > T q [1] - > S q [2] - > CNOT q [1], q [0] - > MEASURE q [0], q [1], q [2]. The former one is S q [2], and the latter one is CNOT q [2], q [1]. Thus, the secondary target computing task is: h q < 0 > T q < 1 > S q < 2 > MEASURE q < 0 >, q < 1 >, q < 2 >; and H q [0] - > T q [1] - > S q [2] - > CNOT q [1], q [0] - > CNOT q [2], q [1] - > MEASURE q [0], q [1], q [2].
Further, after receiving and displaying the target calculation result sent by the background processing device, the method further includes:
Responding to a single step forward instruction or a single step backward instruction sent by the user, and receiving and displaying a secondary target calculation result sent by the background processing equipment; and the secondary target calculation result is calculated by the quantum computing device aiming at the secondary target calculation task and is sent to the background processing device.
The order of priority from high to low is: target computing tasks, sub-target computing tasks, and other computing tasks. The quantum computing device sequentially calculates the target computing task, the sub-target computing task and other computing tasks according to the computing sequence of the priority. Therefore, when the front-end display device displays the target calculation result corresponding to the target calculation task, the single-step forward button (single-step backward button) is used for further knowing the calculation result of the calculation task corresponding to the quantum logic gate (the next quantum logic gate) before the target breakpoint, namely the secondary target calculation result of the secondary target calculation task, as the quantum calculation device has already calculated in advance according to the priority, the quantum calculation device does not need to wait for calculation and feedback of the quantum calculation device, so that the secondary target calculation result corresponding to the secondary target calculation task is displayed on the front-end display device in time, and a user can conveniently debug the quantum program according to the target calculation result of the target calculation task and the secondary target calculation result of the secondary target calculation task.
Further, after receiving and displaying the target calculation result sent by the background processing device, the method further includes:
And responding to a single-step forward instruction or a single-step backward instruction sent by the user, updating the current execution point, and sending the updated current execution point to the background processing equipment so that the background processing equipment adjusts the priorities of other computing tasks based on the new current execution point.
It should be noted that, the step of receiving and displaying the secondary target calculation result sent by the background processing device, and the step of updating the current execution point and sending the updated current execution point to the background processing device may be performed simultaneously or not simultaneously, which is not limited herein.
As illustrated in fig. 3, when the user clicks the execute button in fig. 3When the execution instruction is triggered, the quantum program runs to the target breakpoint CNOT q [1], q [0]. Then when the user clicks the single step forward button ">" in fig. 3 to trigger the single step forward instruction, the current running point is updated to become the target breakpoint, the priority of the computing task needs to be determined again according to the updated current running point, that is, the target breakpoint, and the computing task does not need to be re-created. Then the new target computing task is the computing task corresponding to the quantum logic gate (CNOT q2, q 1) of the quantum logic gate (CNOT q2, q 0) of the next execution corresponding to the target breakpoint, and the new sub-target computing task is the computing task corresponding to the target breakpoint and the computing task corresponding to the quantum logic gate (CNOT q2, q 0) of the next execution. The priority of the target computing task is then again set to be higher than the priority of the secondary target computing task over the priority of the other computing tasks.
Compared with the prior art, the front-end display device responds to an execution instruction sent by a user, sends the quantum program, the breakpoint and the current running point set in the quantum program to the background processing device, creates a target calculation task based on the received quantum program, the breakpoint and the current running point, then sends the target calculation task to the quantum calculation device, calculates the target calculation task to obtain a target calculation result, and forwards the target calculation result to the front-end display device through the background quantum calculation device for display, so that the user can debug the quantum program based on the displayed target calculation result.
Referring to fig. 4, fig. 4 is a flow chart of a quantum program debugging method provided by an embodiment of the present invention, which is applied to a background processing device, and the method includes:
step 401: receiving a quantum program sent by front-end display equipment, a breakpoint set in the quantum program and a current operating point;
step 402: creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
Step 403: receiving a target calculation result calculated by the quantum computing device aiming at the target calculation task;
Step 404: and sending the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user and displays the target calculation result.
Optionally, the creating a target computing task based on the quantum program, the breakpoint, and the current running point includes:
creating a plurality of computing tasks based on the quantum program, and determining a target breakpoint based on the breakpoint and the current operating point;
And determining a target computing task corresponding to the target breakpoint from a plurality of computing tasks.
Optionally, the determining the target breakpoint based on the breakpoint and the current operation point includes:
And determining the quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point, as the quantum logic gate corresponding to the position of the target breakpoint, and determining the first breakpoint as the target breakpoint.
Optionally, the sending the target computing task to a quantum computing device includes:
and sequentially sending the plurality of computing tasks to the quantum computing device according to the order of the priorities of the plurality of computing tasks from high to low.
Optionally, before the sending the plurality of computing tasks to the quantum computing device in order of priority of the plurality of computing tasks from high to low, the method further includes:
And determining a calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position of the target breakpoint as a secondary target calculation task, wherein the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method further includes:
receiving a secondary target calculation result calculated by the quantum computing device aiming at the secondary target calculation task;
And sending the secondary target calculation result to the front-end display device, so that the front-end display device responds to a single-step forward instruction or a single-step backward instruction sent by a user to display the secondary target calculation result.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method further includes:
Receiving a new current execution point sent by the front-end display device, wherein the new current execution point is updated by the front-end display device in response to a single-step forward instruction or a single-step backward instruction sent by a user;
And adjusting the priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
It should be noted that, referring to the specific implementation manner of the embodiment of the present invention shown in fig. 2 and fig. 3, no further description is given here.
Compared with the prior art, the front-end display device responds to an execution instruction sent by a user, sends the quantum program, the breakpoint and the current running point set in the quantum program to the background processing device, creates a target calculation task based on the received quantum program, the breakpoint and the current running point, then sends the target calculation task to the quantum calculation device, calculates the target calculation task to obtain a target calculation result, and forwards the target calculation result to the front-end display device through the background quantum calculation device for display, so that the user can debug the quantum program based on the displayed target calculation result.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a quantum program debugging device according to an embodiment of the present invention, which is applied to a front-end display device, and the device includes:
a communication unit 501, configured to respond to an execution instruction sent by a user, and send a quantum program, a breakpoint set in the quantum program, and a current operating point to a background processing device;
The display unit 502 is further configured to receive and display a target calculation result sent by the background processing device, where the target calculation result is calculated by a quantum computing device for a target calculation task and sent to the background processing device, and the target calculation task is created by the background processing device based on the quantum program, the breakpoint, and the current running point and sent to the quantum computing device.
Optionally, the target computing task is a computing task corresponding to a target breakpoint in a plurality of computing tasks created by the background processing device based on the quantum program, and the target breakpoint is determined by the background processing device based on the breakpoint and the current running point.
Optionally, the quantum logic gate corresponding to the position of the target breakpoint is a quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point.
Optionally, a plurality of the computing tasks are sent to the quantum computing device in order of priority of the plurality of computing tasks from high to low.
Optionally, the calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position where the target breakpoint is located is a secondary target calculation task, and the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving and displaying the target calculation result sent by the background processing device, the display unit 502 is further configured to:
Responding to a single step forward instruction or a single step backward instruction sent by the user, and receiving and displaying a secondary target calculation result sent by the background processing equipment; and the secondary target calculation result is calculated by the quantum computing device aiming at the secondary target calculation task and is sent to the background processing device.
Optionally, after receiving and displaying the target calculation result sent by the background processing device, the communication unit 501 is further configured to:
And responding to a single-step forward instruction or a single-step backward instruction sent by the user, updating the current execution point, and sending the updated current execution point to the background processing equipment so that the background processing equipment adjusts the priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
Compared with the prior art, the front-end display device responds to an execution instruction sent by a user, sends the quantum program, the breakpoint and the current running point set in the quantum program to the background processing device, creates a target calculation task based on the received quantum program, the breakpoint and the current running point, then sends the target calculation task to the quantum calculation device, calculates the target calculation task to obtain a target calculation result, and forwards the target calculation result to the front-end display device through the background quantum calculation device for display, so that the user can debug the quantum program based on the displayed target calculation result.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a quantum program debugging device according to an embodiment of the present invention, which is applied to a background processing apparatus, and the device includes:
A communication unit 601, configured to receive a quantum program sent by a front-end display device, a breakpoint set in the quantum program, and a current operating point;
A processing unit 602 for creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
The communication unit 601 is further configured to receive a target calculation result calculated by the quantum computing device for the target calculation task;
The communication unit 601 is further configured to send the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user to display the target calculation result.
Optionally, the creating a target computing task based on the quantum program, the breakpoint, and the current running point, and the processing unit 602 is specifically configured to:
creating a plurality of computing tasks based on the quantum program, and determining a target breakpoint based on the breakpoint and the current operating point;
And determining a target computing task corresponding to the target breakpoint from a plurality of computing tasks.
Optionally, the determining a target breakpoint based on the breakpoint and the current operating point, where the processing unit 602 is specifically configured to:
And determining the quantum logic gate corresponding to the position of the breakpoint, which is operated after the quantum logic gate corresponding to the position of the current operating point, as the quantum logic gate corresponding to the position of the target breakpoint, and determining the first breakpoint as the target breakpoint.
Optionally, the sending the target computing task to a quantum computing device, and the communication unit 601 is specifically configured to:
and sequentially sending the plurality of computing tasks to the quantum computing device according to the order of the priorities of the plurality of computing tasks from high to low.
Optionally, before the sending the plurality of computing tasks to the quantum computing device in order of priority of the plurality of computing tasks from high to low, the processing unit 602 is specifically configured to:
And determining a calculation task corresponding to the quantum logic gate operated before and the quantum logic gate operated after the quantum logic gate at the position of the target breakpoint as a secondary target calculation task, wherein the priority of the secondary target calculation task is lower than that of the target calculation task and higher than that of other calculation tasks.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the communication unit 601 is further configured to:
receiving a secondary target calculation result calculated by the quantum computing device aiming at the secondary target calculation task;
And sending the secondary target calculation result to the front-end display device, so that the front-end display device responds to a single-step forward instruction or a single-step backward instruction sent by a user to display the secondary target calculation result.
Optionally, after receiving the target calculation result calculated by the quantum computing device for the target calculation task, the method includes:
the communication unit 601 is further configured to receive a new current execution point sent by the front-end display device, where the new current execution point is updated by the front-end display device in response to a single-step forward instruction or a single-step backward instruction sent by a user;
the processing unit 602 is further configured to adjust priorities of other computing tasks based on the new current execution point.
Optionally, the quantum computing device is a real quantum chip and/or a quantum virtual machine.
Optionally, the quantum computing device is the real quantum chip and the quantum virtual machine, and the target computing result includes a real computing result calculated by the real quantum chip and a simulation computing result calculated by the quantum virtual machine.
Compared with the prior art, the front-end display device responds to an execution instruction sent by a user, sends the quantum program, the breakpoint and the current running point set in the quantum program to the background processing device, creates a target calculation task based on the received quantum program, the breakpoint and the current running point, then sends the target calculation task to the quantum calculation device, calculates the target calculation task to obtain a target calculation result, and forwards the target calculation result to the front-end display device through the background quantum calculation device for display, so that the user can debug the quantum program based on the displayed target calculation result.
The embodiment of the invention also provides a storage medium in which a computer program is stored, wherein the computer program is arranged to perform the steps of the method embodiment of any of the above figures 2 or 4 when run.
Specifically, in the present embodiment, the above-described storage medium may be configured to store a computer program for executing the steps of:
responding to an execution instruction sent by a user, and sending a quantum program, a breakpoint set in the quantum program and a current operating point to background processing equipment;
And receiving and displaying a target calculation result sent by the background processing equipment, wherein the target calculation result is calculated by quantum computing equipment aiming at a target calculation task and is sent to the background processing equipment, and the target calculation task is created by the background processing equipment based on the quantum program, the breakpoint and the current running point and is sent to the quantum computing equipment.
Or the above-mentioned storage medium may be arranged to store a computer program for performing the steps of:
Receiving a quantum program sent by front-end display equipment, a breakpoint set in the quantum program and a current operating point;
creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
Receiving a target calculation result calculated by the quantum computing device aiming at the target calculation task;
And sending the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user and displays the target calculation result.
Specifically, in the present embodiment, the storage medium may include, but is not limited to: a usb disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing a computer program.
Still another embodiment of the present invention provides an electronic device comprising a memory having a computer program stored therein and a processor configured to run the computer program to perform the steps of the method embodiment of any of the above.
Specifically, the electronic apparatus may further include a transmission device and an input/output device, where the transmission device is connected to the processor, and the input/output device is connected to the processor.
Specifically, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
responding to an execution instruction sent by a user, and sending a quantum program, a breakpoint set in the quantum program and a current operating point to background processing equipment;
And receiving and displaying a target calculation result sent by the background processing equipment, wherein the target calculation result is calculated by quantum computing equipment aiming at a target calculation task and is sent to the background processing equipment, and the target calculation task is created by the background processing equipment based on the quantum program, the breakpoint and the current running point and is sent to the quantum computing equipment.
Or the processor may be arranged to perform the following steps by means of a computer program:
Receiving a quantum program sent by front-end display equipment, a breakpoint set in the quantum program and a current operating point;
creating a target computing task based on the quantum program, the breakpoint, and the current operating point, and sending the target computing task to a quantum computing device;
Receiving a target calculation result calculated by the quantum computing device aiming at the target calculation task;
And sending the target calculation result to the front-end display device, so that the front-end display device responds to an execution instruction sent by a user and displays the target calculation result.
Yet another embodiment of the present invention also provides a quantum program debugging system, the system comprising a front-end display device comprising a quantum program debugging apparatus as shown in fig. 5 and a background processing device comprising a quantum program debugging apparatus as shown in fig. 6.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.