A quantum circuit editing method, device, equipment and medium

By generating quantum gate component images in response to user instructions and displaying quantum gate slots in different states, the problem of lack of display effects in the editing process in the existing technology is solved, and the user experience of quantum circuit editing is improved.

CN116702912BActive Publication Date: 2024-09-10SHENZHEN SPINQ TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310618169.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2024-09-10
Estimated Expiration
2043-05-29

AI Technical Summary

Technical Problem

Existing quantum logic circuit editing applications lack the display effect of different editing states during the editing process, which affects the user experience.

Method used

By responding to the user's touch and drag instructions, a quantum gate component image is generated, and quantum gate slots in different states are displayed in the quantum circuit editing area to achieve the visualization of different editing steps, including state transitions and the storage and modification of attribute information. .

Benefits of technology

The user experience during the drag and edit process of quantum gates is improved, allowing users to better understand and operate complex quantum circuit diagrams through clear interactive effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116702912B
    Figure CN116702912B
Patent Text Reader

Abstract

The present application relates to a quantum circuit editing method, device, equipment and medium. The method includes: in response to a touch instruction of any quantum gate component in a quantum gate selection bar, storing the attribute information of the quantum gate component into a preset editing data object, generating a quantum gate component image; in response to a drag instruction of the quantum gate component image, dragging the quantum gate component image and the preset editing data object from the quantum gate selection bar to the quantum circuit editing area; in response to any quantum gate slot in the quantum editing area monitoring its own area range and dragging the quantum gate component image, the slot display state of the quantum gate slot is converted; in response to a release event of the quantum gate component image, determining whether the release event is in the area range of any quantum gate slot to be edited; if so, displaying the quantum gate component image in the quantum gate slot to be edited, and storing the attribute information of the quantum gate component in the preset editing data object in the quantum gate slot to be edited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application is applicable to the field of quantum computing technology, and in particular, relates to a quantum circuit editing method, device, equipment and medium. Background Art

[0002] Quantum computing is developing rapidly, and a quantum computing algorithm is usually composed of one or more quantum logic gates (hereinafter referred to as quantum gates), which are expressed in the form of quantum circuit diagrams. As the complexity of the algorithm increases, the arrangement and combination of quantum gates becomes more and more complex. At this time, intuitively and smoothly displaying and editing complex quantum circuit diagrams will greatly improve the design efficiency of quantum computing algorithms. Summary of the invention

[0003] The inventor of the present application has found that, although the existing quantum logic circuit editing application can realize visual editing of quantum circuits on the client and can intuitively display quantum gate components, it lacks the display effect of different editing states during the editing process, which affects the user experience during the interaction process. In view of this, the embodiments of the present application provide a quantum circuit editing method, device, equipment and medium.

[0004] In a first aspect, an embodiment of the present application provides a quantum circuit editing method, the method comprising:

[0005] In response to a touch instruction on any quantum gate component in the quantum gate selection column, the attribute information of the quantum gate component is stored in a preset editing data object to generate a quantum gate component image;

[0006] In response to a drag command for the quantum gate component image, the quantum gate component image and the preset editing data object are dragged from the quantum gate selection bar to the quantum circuit editing area;

[0007] In response to any quantum gate slot in the quantum editing area monitoring the region range of the quantum gate component being dragged into the region range, the slot display of the quantum gate slot is converted from a first state to a second state;

[0008] In response to a release event of the quantum gate component mirror, determining whether the release event is within a region of any quantum gate slot to be edited;

[0009] If so, the quantum gate component image is displayed in the quantum gate slot to be edited, and the attribute information of the quantum gate component in the preset editing data object is stored in the quantum gate slot to be edited.

[0010] In one or some optional embodiments, after the quantum gate slot to be edited displays the corresponding quantum gate component image and stores the attribute information of the quantum gate component in the preset edit data object into the quantum gate slot to be edited, the method further includes:

[0011] If the quantum gate component displayed in the quantum gate slot to be edited is a multi-bit quantum gate, the slot displays of other quantum gate slots at the same depth as the quantum gate slot to be edited are converted from the first state to the third state.

[0012] In one or some optional embodiments, the method further comprises:

[0013] For other quantum gate slots at the same depth as the quantum gate slot to be edited:

[0014] If a click operation instruction is received, the clicked quantum gate slot is connected to the quantum gate slot to be edited, and the slot displays of all quantum gate slots on the connection line are converted from the third state to the fourth state, and the slot displays of the remaining quantum gate slots outside the connection line are converted from the third state to the first state.

[0015] In one or some optional embodiments, the attribute information of the multi-bit quantum gate includes control end attribute information, and the method further includes:

[0016] Determine whether the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located;

[0017] If yes, modify the control end attribute information of the quantum gate component of the quantum gate slot to be edited to be connected upward;

[0018] If not, the control end attribute information of the quantum gate component of the quantum gate slot to be edited is modified to be connected downward.

[0019] In one or some optional embodiments, the attribute information of the quantum gate slot includes type information, and the method further includes:

[0020] If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, the type information of the clicked quantum gate slot is modified to be selected and connected downward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down;

[0021] If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is smaller than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, the type information of the clicked quantum gate slot is modified to be selected and connected upward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down.

[0022] In one or some optional embodiments, after the quantum gate slot to be edited displays a transition from a first state to a second state, the method further comprises:

[0023] In response to the quantum gate component image dragged in by the quantum gate slot monitoring being out of the range of its own area, the slot display of the quantum gate slot is converted from the second state to the first state.

[0024] In one or some optional embodiments, before the quantum gate slot to be edited displays the corresponding quantum gate component image and stores the attribute information of the quantum gate component in the preset edit data object into the quantum gate slot to be edited, the method further includes:

[0025] Determine whether the quantum gate slot to be edited is empty. If not, move the quantum gate component image and the attribute information of the corresponding quantum gate component of the quantum gate slot whose depth in the quantum circuit editing area is greater than or equal to the depth of the quantum gate slot to be edited to the quantum gate slot of the next depth in sequence.

[0026] In one or some optional embodiments, the method further comprises:

[0027] If it is determined that the release event is not within the region of any quantum gate slot to be edited, the quantum gate component image and the attribute information of the corresponding quantum gate component in the preset editing data object are deleted.

[0028] In one or some optional embodiments, the method further comprises:

[0029] In response to a dragging instruction to drag the quantum gate component image of the quantum gate slot to be edited to the removal area, the removal area is displayed.

[0030] In one or some optional embodiments, the method further comprises:

[0031] In response to a release operation event of the quantum gate component of the quantum gate slot to be edited in the removal area, deleting the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object, or,

[0032] In response to a release operation instruction after dragging the quantum gate component of the quantum gate slot to be edited out of the removal area, the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object are retained.

[0033] In one or some optional embodiments, the method further comprises:

[0034] In response to a sliding instruction on the quantum gate editing area, a visualization area range of the quantum gate editing area is displayed following the sliding instruction.

[0035] In a second aspect, an embodiment of the present application provides a quantum circuit editing device, the device comprising:

[0036] A quantum gate selection module is configured to respond to a touch instruction of any quantum gate component in the quantum gate selection column, store the attribute information of the quantum gate component into a preset editing data object, and generate a quantum gate component image;

[0037] A processing module is configured to, in response to a drag instruction for the quantum gate component image, drag the quantum gate component image and the preset editing data object from the quantum gate selection bar to the quantum circuit editing area;

[0038] A display state switching module is configured to switch the slot display of the quantum gate slot from a first state to a second state in response to any quantum gate slot in the quantum editing area monitoring the region within which the quantum gate component image is dragged;

[0039] A judgment module is configured to respond to a release event of the quantum gate component mirror and judge that the release event is within a region of any quantum gate slot to be edited;

[0040] The editing module is configured to display the quantum gate component image at the quantum gate slot to be edited if the release event is in the area range of the quantum gate slot to be edited, and store the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited.

[0041] In a third aspect, an embodiment of the present application provides a computer device for editing a quantum circuit, the computer device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the quantum circuit editing method as described in the first aspect when executing the computer program.

[0042] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the quantum circuit editing method as described in the first aspect is implemented.

[0043] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer device, enables the computer device to execute the quantum circuit editing method as described in the first aspect.

[0044] In a sixth aspect, an embodiment of the present application provides a chip, the chip comprising a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the quantum circuit editing method as described in the first aspect.

[0045] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0046] The quantum circuit editing method provided by the embodiment of the present application can generate an image of the quantum gate component in the quantum gate selection column according to the user's instructions during the human-computer interaction process, and can follow the user's dragging instructions to realize the display of the quantum gate component image in the quantum editing area, and switch the display state of the quantum gate slot according to different operation stages of quantum circuit editing. For any quantum gate slot in the initial first state, the second state is displayed when the quantum gate component image appears in the regional range of the quantum gate slot, and the quantum gate component image is displayed after the quantum gate component image is inserted into the quantum gate slot, so as to realize the visual presentation of different interactive effects in different quantum editing steps, so that the display effect of different editing states in the process of quantum gate drag editing is more perfect, and the user experience of the user in the interactive process is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0048] Figure 1 It is a flowchart of a quantum route editing method provided in one embodiment of the present application;

[0049] Figure 2 A schematic diagram of an operation interface of a display screen of a client provided in an embodiment of the present application;

[0050] Figure 3 for Figure 2 A schematic diagram of the overall layout structure of the layout components of each area of ​​the operation interface shown;

[0051] Figure 4 for Figure 2 A partial schematic diagram of the quantum circuit editing area of ​​the operation interface shown;

[0052] Figure 5 for Figure 2 A schematic diagram of editing quantum circuits in the quantum circuit editing area of ​​the operation interface shown;

[0053] Figure 6 Schematic diagram of the quantum circuit data list in the quantum circuit editing area;

[0054] Figure 7 A schematic diagram showing the changes in the quantum circuit data list when a quantum gate component is inserted into the quantum gate slot in the quantum circuit editing area;

[0055] Figure 8 for Figure 7 The schematic diagram of the change of attribute information in the schematic diagram of the change of quantum circuit data list shown;

[0056] Fig. 9 A schematic diagram showing changes in another quantum circuit data list when a quantum gate component is inserted into a quantum gate slot in a quantum circuit editing area;

[0057] Fig.10 Schematic diagram of different states of quantum gate slots in the quantum circuit editing area;

[0058] Fig.11 A schematic diagram of the state of a slot at the same depth and the attribute information of the quantum gate slot when a CNOT quantum gate component is inserted into the quantum gate slot in the quantum circuit editing area;

[0059] Fig.12 For Fig.11 The schematic diagram of the CNOT quantum gate component after selecting the control slot shown;

[0060] Fig.13 For the corresponding Fig.12 Schematic diagram of the change in the attribute information of the quantum gate slot after the CNOT quantum gate component is inserted;

[0061] Fig.14 For Figure 2 A schematic diagram of sliding the quantum circuit editing area of ​​the operation interface shown;

[0062] Fig.15 It is a schematic diagram of the structure of a quantum route editing device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0063] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0064] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0065] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0066] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0067] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0068] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0069] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0070] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.

[0071] Embodiment 1

[0072] The embodiment of the present application provides a quantum route editing method, which can be applied to various clients with display screens, including but not limited to mobile phones, tablet computers, portable computers and desktop computers. The client implements quantum route editing by interacting with a user object, and the user object issues an operation instruction by touching the display screen of the client, and the client implements interaction with the user object according to the corresponding operation instruction.

[0073] See also Figure 1 , is a flow chart of a quantum circuit editing method provided in Example 1 of the present application, referring to Figure 1 As shown, the quantum circuit editing method may include the following steps:

[0074] S101: In response to a touch instruction on any quantum gate component in the quantum gate selection column, the attribute information of the quantum gate component is stored in a preset editing data object to generate a quantum gate component image.

[0075] In the above step S101, any quantum gate component in the quantum gate selection column monitors the touch event in real time and responds to the touch instruction of any quantum gate component in the quantum gate selection column.

[0076] In a specific embodiment, the display screen of the client displays the operation interface of the application executing the quantum route editing method, referring to Figure 2 As shown, the operation interface at least presents the following areas:

[0077] The area labeled "1" is the quantum gate selection bar. You can select quantum gate components by dragging the quantum gate components in this area.

[0078] The area labeled "2" is the depth of the quantum circuit, from which you can clearly understand the depth position of the current quantum circuit;

[0079] The area labeled “3” is the number of the quantum circuit, Q0, Q2, ... Qn represent the quantum bits in the quantum circuit, and “|0>” represents the initial state of the quantum bit;

[0080] The area labeled "4" is the corresponding bit measurement mark. You can click the icon in this area to choose whether to measure the projection probability of the corresponding bit;

[0081] The area labeled "5" is the removal area of ​​the quantum circuit. It is hidden and invisible in normal conditions. When you drag the quantum gate component image to the removal area, the removal area will be displayed.

[0082] The area labeled "6" is the quantum circuit editing area, where quantum circuits can be inserted, connected, adjusted, and deleted.

[0083] Taking the Android client as an example, the above operation interface can be combined and laid out using the layout components RecyclerView, LinearLayout and NestedScrollView in the Android SDK. The overall layout structure of the layout components in each area of ​​the operation interface is as follows: Figure 3 As shown in the figure, since the quantum circuit editing area needs to achieve more quantum bits within a limited visualization area, the quantum circuit editing area is laid out using the NestedScrollView layout component. The NestedScrollView layout component is used to adjust the vertical area by sliding up and down, and the RecyclerView layout component is used to adjust the horizontal area by sliding left and right to display a larger quantum depth.

[0084] After implementing the operation interface through the above layout method, you need to add a quantum gate component to the quantum gate selection bar. The quantum gate component inherits the public component RelativeLayout and adds ImageView to display the quantum gate component image. For Rx, Ry, and Rz rotation quantum gates, you can also add TextView text components to display the quantum gate type and angle value; you can create a quantum gate type attribute in the quantum gate component, that is, the type attribute, and you can display different quantum gate component images by setting different type attributes; create a rotation quantum gate angle attribute in the quantum gate component, that is, the angle attribute. For example, for the image of the Ry rotation quantum gate, you can set the angle value in its upper right corner to represent the angle attribute of the quantum gate component.

[0085] After adding a quantum gate component in the quantum gate selection column, you need to drag it to the quantum gate slot in the quantum circuit editing area to implement the quantum circuit editing function. The quantum gate slot refers to the location where the quantum gate component is placed. Figure 4 As shown in the figure, each box represents the area range of a quantum gate slot. The quantum gate slot can be implemented by customizing the View component. The quantum gate slot has an attribute used to record the state of the component, that is, the state of the quantum gate slot.

[0086] After implementing the function of quantum gate slots, multiple quantum gate slots can be spliced ​​together through the RecyclerView layout component to realize a complete quantum circuit, such as Figure 5 As shown, the boxed area is a quantum circuit.

[0087] In a specific embodiment, the attribute information GateInfo of the quantum gate component may be included in a data packet in the following format of the attribute information GateInfo data packet of a three-bit quantum gate component:

[0088] {"angle":0.0,"controlQubit":-1,"controlQubit2":-1,"delay":0.0,"qubitIndex":0,"timeslot":0,"type":"CCNOT"};

[0089] in:

[0090] The angle attribute information "angle" indicates the angle of the rotating quantum gate, such as the angle of the Rx, Ry and Rz rotating quantum gates, corresponding to the value of the upper right corner of the rotating quantum gate component;

[0091] The control end attribute information "controlQubit" and "controlQubit2" represent the two control endpoints of the three-bit gate, such as the two control endpoints of CCNOT. The control endpoint is the connection point in the slot state. The slot component will determine the state of the same depth position on other quantum bit lines according to this data of the quantum gate component in the slot;

[0092] The delay attribute information "delay" indicates the delay time of the delay quantum gate, corresponding to the value in the upper right corner of the delay quantum gate component;

[0093] The quantum bit attribute information "qubitIndex" indicates the quantum bit where the quantum gate component is located, corresponding to Q0~Q2...Qn on the operation interface;

[0094] The depth attribute information "timeslot" indicates the depth position of the quantum gate component on the quantum circuit;

[0095] The type attribute information "type" indicates the corresponding quantum gate type. The icon on the quantum gate component displays different icons based on this data. Quantum gate types include H quantum gate, X quantum gate and CNOT quantum gate.

[0096] In some other embodiments, for a two-bit gate, the control terminal attribute information only has one "controlQubit" to record a control terminal of the two-bit gate, such as a control terminal of a CNOT, representing another bit connected to the two-bit gate. For a single-bit gate, the control terminal attribute information is not included.

[0097] In the above step S101, any quantum gate component in the quantum gate selection bar responds to the touch command because the quantum gate component monitors the touch event onTouchEvent. After the quantum gate component responds to the touch command, the attribute information GateInfo of the quantum gate component is stored in the preset editing data object, which can be set as a ClipData object, and then the startDrag method of the quantum gate component is called, and the ClipData object with the attribute information of the quantum gate component is passed to the startDrag method. At the same time, a quantum gate component image is generated, and the quantum gate component image carrying the ClipData object can be dragged at this time.

[0098] In an embodiment of the present application, if the quantum gate component inserted into any quantum gate slot in the quantum circuit editing area responds to the touch command, the attribute information of the quantum gate component is stored in a preset editing data object, a quantum gate component image is generated, and the quantum gate component in the quantum gate slot is image-hidden.

[0099] S102: In response to a drag instruction for the quantum gate component image, the quantum gate component image and the preset editing data object are dragged from the quantum gate selection bar to the quantum circuit editing area.

[0100] In the above step S102, after the quantum gate component responds to the touch command, a quantum gate component image is generated. At this time, if the quantum gate component image is dragged by an object, the quantum gate component image and the preset editing data object are dragged from the quantum gate selection bar to the quantum circuit editing area in response to the drag command. Here, the quantum gate component image carries the attribute information GateInfo of the quantum gate component.

[0101] S103: In response to any quantum gate slot in the quantum editing area monitoring the region within its own area and dragging the quantum gate component image, the slot display of the quantum gate slot is converted from a first state to a second state.

[0102] In a specific embodiment, after executing the above step S103, after the display of the quantum gate slot to be edited is converted from the first state to the second state, the method may further include:

[0103] In response to the quantum gate component image dragged in by the quantum gate slot monitoring being out of the range of its own area, the slot display of the quantum gate slot is converted from the second state to the first state.

[0104] In the above step S103, any quantum gate slot in the quantum editing area is bound to OnDragListener by setOnDragListener for monitoring. In the onDrag callback of OnDragListener, it is detected whether the quantum gate component image is dragged into the area of ​​a quantum gate slot itself. If it has entered the range, the slot display of the quantum gate slot is changed from the first state to the second state. Thereafter, if the quantum gate component image dragged by the quantum gate slot monitors that it is out of its own area, that is, the quantum gate component image is again monitored in the onDrag callback to have been removed from the quantum gate slot's own area, the slot display of the quantum gate slot is converted from the second state to the first state. The first state is the initial state displayed before the quantum gate slot is operated, and the second state is the intermediate process state displayed by the quantum gate slot during the operation.

[0105] S104: In response to a release event of the quantum gate component mirror, determining whether the release event is within the region of any quantum gate slot to be edited; if so, executing step S105; if not, executing step S106;

[0106] S105: Displaying the quantum gate component image in the quantum gate slot to be edited, and storing the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited;

[0107] S106: Delete the quantum gate component image and the attribute information of the corresponding quantum gate component in the preset editing data object.

[0108] In the embodiment of the present application, after the object is used to release the dragged quantum gate component image, the quantum gate component image can monitor the release event in onDrag, respond to the release event, and determine whether the release event is in the area range of any quantum gate slot to be edited. If the release event is not in the area range of any quantum gate slot to be edited, it is an invalid drag, and the attribute information of the corresponding quantum gate component in the quantum gate component image and the preset editing data object is deleted. At this time, an invalid drag process is formed. If the quantum gate component in the quantum circuit editing area is invalidly dragged, after the object is used to release the dragged quantum gate component image, the quantum gate component for image hiding is redisplayed in the quantum circuit editing area.

[0109] Before executing the above step S105, displaying the corresponding quantum gate component image in the quantum gate slot to be edited, and storing the attribute information of the quantum gate component in the preset edit data object into the quantum gate slot to be edited, the method may further include:

[0110] Determine whether the quantum gate slot to be edited is empty. If not, move the quantum gate component image and the attribute information of the corresponding quantum gate component of the quantum gate slot whose depth in the quantum circuit editing area is greater than or equal to the depth of the quantum gate slot to be edited to the quantum gate slot of the next depth in sequence.

[0111] In the embodiment of the present application, the basic data packet format of a quantum gate component attribute is GateInfo, and each slot on a quantum circuit contains a quantum gate component, that is, a collection of GateInfo, such as Figure 6 As shown, the format used by each quantum circuit is a List. After confirming that the release event is in the area range of any quantum gate slot to be edited, it is necessary to store the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited. At this time, it is also necessary to determine whether the quantum gate slot to be edited is empty. If so, that is, no quantum gate component is placed in this quantum gate slot, such as Figure 7 As shown, the parameters such as type, angle and delay of the attribute information GateInfo of the quantum gate component in the preset editing data object are directly stored in the attribute information GateInfo of the quantum gate component of the quantum gate slot to be edited; if not, that is, the quantum gate component has been placed in this quantum gate slot, such as Figure 8 As shown, the quantum gate component mirror image and the corresponding quantum gate component attribute information of the quantum gate slot whose depth is greater than or equal to the depth of the quantum gate slot to be edited in the quantum circuit editing area are moved to the quantum gate slot of the next depth in sequence, and then the parameters such as type, angle and delay of the attribute information GateInfo of the quantum gate component in the preset editing data object are stored in the attribute information GateInfo of the quantum gate component of the quantum gate slot to be edited.

[0112] In a specific embodiment, Fig. 9 As shown, when the Z quantum gate component image is placed in the quantum gate slot where the CNOT quantum gate component image is located, all quantum gate component images at the depth where the CNOT quantum gate component image is located and greater than this depth and the attribute information of the corresponding quantum gate components are moved to the quantum gate slot of the next depth in sequence.

[0113] In the embodiment of the present application, according to different states, the quantum gate slot can realize icons showing different slot states; in addition, the quantum gate slot has a quantum gate component that is invisible under normal conditions, which is only displayed when a quantum gate component is dragged in and placed, and the corresponding quantum gate component is displayed according to the current state. Among them, the icons of different slot states of the quantum gate slot are as follows Fig.10 As shown, it mainly includes the following types:

[0114] Normal state: refers to the state where the slot is normally unused;

[0115] Hovering state: refers to the state when the quantum gate component is dragged in but not released, indicating that the slot is selected. A dotted border is displayed in the "hovering state", indicating that the position is ready and waiting to be released;

[0116] Connection waiting to be clicked: This state is waiting to be clicked, prompting the user to click and confirm the connection slot;

[0117] Connection status: including up and down connection, selected and downward connection, selected and upward connection, and selected and up and down connection: refers to the status displayed by the slot when the quantum gate component of the slot is connected, which is used to show the connection relationship of the multi-bit gate.

[0118] In a specific embodiment, if the quantum gate component is placed in the quantum gate slot of the quantum circuit editing area, the attribute information of the quantum gate component will eventually be stored in the attribute information of the quantum gate slot by the preset editing data object ClipData. Therefore, in the embodiment of the present application, the quantum gate slot can also include some custom type attribute information, such as EMPTY for "normal", CNTED_PRE for "connection to be clicked", CNTED_CROSS for "up and down connection", CNTED for "selected and connected upward" or "selected and connected downward", which needs to be determined according to the size relationship between qubitIndex and controlQubit. When "qubitIndex" < "controlQubit", "selected and connected downward" is displayed, otherwise "selected and connected upward" is displayed. In addition, the custom type also includes "selected and connected upward and downward", which needs to meet the state CNTED_CROSS, and the value of qubitIndex is between controlQubit and controlQubit2 before it is displayed; "hover" is displayed when the state EMPTY is met and the quantum gate component is mirrored and dragged to the quantum gate slot range.

[0119] The first state may be a "normal state" and the second state may be a "hovering state".

[0120] After executing the above step S105, displaying the corresponding quantum gate component image in the quantum gate slot to be edited, and storing the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited, the method may further include:

[0121] If the quantum gate component displayed in the quantum gate slot to be edited is a multi-bit quantum gate, the slot displays of other quantum gate slots at the same depth as the quantum gate slot to be edited are converted from the first state to the third state.

[0122] The third state may be a "connection waiting to be clicked state".

[0123] When the quantum gate component displayed in the quantum gate slot to be edited is a multi-bit quantum gate, such as CNOT, CZ and CCNOT quantum gate components. At this time, it is necessary to affect the state of the quantum gate slots on other quantum circuits at the same depth. For multi-bit quantum gates, it is necessary to process other quantum gate slots at the same depth as the quantum gate slot to be edited. At this time, the slot state of other quantum gate slots at the same depth as the quantum gate slot to be edited is in the "connection waiting to be clicked state".

[0124] In a specific embodiment, Fig.11 As shown, taking the quantum gate component inserted into the quantum gate slot to be edited as a CNOT quantum gate component as an example, when the parameters such as type, angle and delay of the attribute information GateInfo of the CNOT quantum gate component are stored in the attribute information GateInfo of the quantum gate component of the quantum gate slot to be edited, the controlQubit and controlQubit2 parameters in the attribute information GateInfo of the quantum gate slot where the CNOT quantum gate component is located are both -1, indicating that the control is not connected. Since the CNOT quantum gate component is a two-bit gate, another bit needs to be selected as the control bit. At this time, the quantum gate type of other quantum gate slots at the same depth as the quantum gate slot to be edited is set to CNTED_PRE, and the slot display is converted from the first state to the third state. Among them, the first state can be "normal" and the third state can be "connected to be clicked".

[0125] In the above step S105, if the quantum gate component displayed in the quantum gate slot to be edited is a multi-bit quantum gate, the slot display of other quantum gate slots at the same depth as the quantum gate slot to be edited is converted from the first state to the third state, and further includes:

[0126] For other quantum gate slots at the same depth as the quantum gate slot to be edited:

[0127] If a click operation instruction is received, the clicked quantum gate slot is connected to the quantum gate slot to be edited, and the slot displays of all quantum gate slots on the connection line are converted from the third state to the fourth state, and the slot displays of the remaining quantum gate slots outside the connection line are converted from the third state to the first state.

[0128] The fourth state is the "connected state".

[0129] In a specific embodiment, the quantum gate component placed in the quantum gate slot to be edited may be a CNOT quantum gate component. At this time, other quantum gate slots at the same depth as the quantum gate slot to be edited are in a "connected to be clicked" state. Fig.12 As shown, after receiving the click operation instruction, the quantum gate slot after the click is connected with the quantum gate slot to be edited, and, referring to Fig.13 As shown, the controlQubit of the CNOT quantum gate component is set to the qubitIndex of the attribute information GateInfo of the quantum gate slot after clicking, and the slot display of all quantum gate slots on the connection line is converted from the "connection to be clicked" state to the fourth state, and the slot display of the remaining quantum gate slots outside the connection line is converted from the "connection to be clicked" state to the first state, wherein the first state may be "normal", and the fourth state needs to be specifically determined according to the connection situation, which may be "selected and connected upward" or "selected and connected downward".

[0130] In the above step S105, the attribute information of the multi-bit quantum gate includes the attribute information of the control end, and the method further includes:

[0131] Determine whether the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located;

[0132] If yes, modify the control end attribute information of the quantum gate component of the quantum gate slot to be edited to be connected upward;

[0133] If not, the control end attribute information of the quantum gate component of the quantum gate slot to be edited is modified to be connected downward.

[0134] In a specific embodiment, after the clicked quantum gate slot is connected to the quantum gate slot to be edited, it is determined whether the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, that is, it is determined whether the qubitIndex of the attribute information of the CNOT quantum gate component is greater than controlQubit. If "qubitIndex" > "controlQubit", the control end attribute information of the quantum gate component of the quantum gate slot to be edited is modified to be connected upward; if "qubitIndex" < "controlQubit", the control end attribute information of the quantum gate component of the quantum gate slot to be edited is modified to be connected downward.

[0135] In a specific embodiment, the attribute information of the quantum gate slot includes type information, and the method further includes:

[0136] If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, the type information of the clicked quantum gate slot is modified to be selected and connected downward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down;

[0137] If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is smaller than the quantum bit of the quantum circuit where the quantum gate slot after the click is located, the type information of the quantum gate slot after the click is modified to be selected and connected upward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down. At this time, the slot status of other quantum gate slots on the connection line presents "connected status".

[0138] After setting the data format of the quantum gate component and quantum circuit in the above way, you need to drag the quantum gate component to the quantum circuit editing area in the operation interface. Due to the limited range of the visualization area, refer to Fig.14 As shown, you need to slide the quantum circuit editing area up and down to scroll and display more quantum bits, or slide the quantum circuit editing area left and right to scroll and display more quantum circuit depth. In the layout of the operation interface, the RecyclerView layout component is used to adjust the display range by sliding. The quantum circuit diagram editing area is composed of multiple Recyclerview layout components, but because the individual Recyclerview layout components are independent of each other, the sliding event is the behavior of a single Recyclerview layout component, so it is key to keep each Recyclerview layout component aligned. Based on this, the sliding of the quantum circuit editing area can be achieved in the following way:

[0139] In response to a sliding instruction on the quantum gate editing area, a visualization area range of the quantum gate editing area is displayed following the sliding instruction.

[0140] Specifically, in NestedScrollView, multiple Recyclerviews are nested (one Recyclerview is used for one bit line) to implement each bit. Recyclerview can implement horizontal scrolling of a single bit, but in order to implement horizontal scrolling of multiple bits (that is, the entire editing area), the OnScrollListener method of Recyclerview is used to listen to the sliding event, and the onScrolled callback in OnScrollListener obtains the distance moved by the current Recyclerview in real time. Then, after obtaining the moving distance, other Recyclerviews use Recyclerview's scrollBy to move the same distance in the same direction, that is, each Recyclerview moves to the position before the next Recyclerview moves. Use the NestedScrollView component to implement up and down scrolling of the editing area. When the content exceeds the specified area, the component can be scrolled by sliding up and down gestures.

[0141] The quantum circuit editing area can be slid up, down, left, and right in the above manner, realizing the scalability of the quantum circuit depth. The depth and number of quantum circuits can be set arbitrarily. For quantum gate components beyond the visualization area, you only need to swipe the screen in the corresponding direction to view them.

[0142] In an optional embodiment, since during the quantum route editing process, the user may need to delete the quantum gate component during or after the editing process, based on this, the method may further include:

[0143] In response to a dragging instruction to drag the quantum gate component image of the quantum gate slot to be edited to the removal area, the removal area is displayed.

[0144] After displaying the removal area, the applicable object can choose to perform the deletion operation or retain the quantum gate component moved to the deletion area. Based on this, the method can also include:

[0145] In response to a release operation event of the quantum gate component of the quantum gate slot to be edited in the removal area, deleting the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object, or,

[0146] In response to a release operation instruction after dragging the quantum gate component of the quantum gate slot to be edited out of the removal area, the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object are retained.

[0147] The quantum circuit editing method provided by the embodiment of the present application can generate an image of the quantum gate component in the quantum gate selection column according to the user's instructions during the human-computer interaction process, and can follow the user's dragging instructions to realize the display of the quantum gate component image in the quantum editing area, and switch the display state of the quantum gate slot according to different operation stages of quantum circuit editing. For any quantum gate slot in the initial first state, the second state is displayed when the quantum gate component image appears in the regional range of the quantum gate slot, and the quantum gate component image is displayed after the quantum gate component image is inserted into the quantum gate slot, so as to realize the visual presentation of different interactive effects in different quantum editing steps, so that the display effect of different editing states in the process of quantum gate drag editing is more perfect, and the user experience of the user in the interactive process is improved.

[0148] Embodiment 2

[0149] Based on the same inventive concept, the embodiment of the present invention also provides a quantum circuit editing device, referring to Fig.15 As shown, the device comprises:

[0150] The quantum gate selection module 101 is configured to respond to a touch instruction of any quantum gate component in the quantum gate selection column, store the attribute information of the quantum gate component into a preset editing data object, and generate a quantum gate component image;

[0151] The processing module 102 is configured to, in response to a drag instruction for the quantum gate component image, drag the quantum gate component image and the preset editing data object from the quantum gate selection bar to the quantum circuit editing area;

[0152] The display state switching module 103 is configured to switch the slot display of the quantum gate slot from the first state to the second state in response to any quantum gate slot in the quantum editing area monitoring the region range of the quantum gate component being dragged into the region range of the quantum gate component;

[0153] The judgment module 104 is configured to respond to a release event of the quantum gate component mirror and judge that the release event is within a region of any quantum gate slot to be edited;

[0154] The editing module 105 is configured to display the quantum gate component image at the quantum gate slot to be edited if the release event is in the area range of the quantum gate slot to be edited, and store the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited.

[0155] Embodiment 3

[0156] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the quantum circuit editing method described in the above embodiment 1 is implemented.

[0157] Embodiment 4

[0158] Based on the same inventive concept, an embodiment of the present invention also provides a computer device for quantum circuit editing, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the quantum circuit editing method described in the above-mentioned embodiment 1 is implemented.

[0159] Embodiment 5

[0160] Based on the same inventive concept, an embodiment of the present invention further provides a computer program product comprising instructions. When the computer program product is run on a computer device, the computer device executes the quantum circuit editing method described in the above embodiment 1.

[0161] Embodiment 6

[0162] Based on the same inventive concept, an embodiment of the present invention further provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the quantum circuit editing method described in the above embodiment 1.

[0163] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0164] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0165] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0166] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0167] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A quantum circuit editing method, characterized in that: The method comprises: In response to a touch instruction on any quantum gate component in the quantum gate selection column, the attribute information of the quantum gate component is stored in a preset editing data object to generate a quantum gate component image; In response to a drag command for the quantum gate component image, the quantum gate component image and the preset editing data object are dragged from the quantum gate selection bar to the quantum circuit editing area; In response to any quantum gate slot in the quantum circuit editing area monitoring the region within itself dragging the quantum gate component image, the slot display of the quantum gate slot is converted from a first state to a second state; the first state is a normal state, which means that the slot is normally unused; the second state is a hovering state; In response to a release event of the quantum gate component mirror, determining whether the release event is within a region of any quantum gate slot to be edited; If so, the quantum gate component image is displayed in the quantum gate slot to be edited, and the attribute information of the quantum gate component in the preset editing data object is stored in the quantum gate slot to be edited.

2. The method according to claim 1, characterized in that After the quantum gate slot to be edited displays the corresponding quantum gate component image and stores the attribute information of the quantum gate component in the preset edit data object into the quantum gate slot to be edited, the method further includes: If the quantum gate component displayed in the quantum gate slot to be edited is a multi-bit quantum gate, the slot display of other quantum gate slots at the same depth as the quantum gate slot to be edited is converted from the first state to the third state; the third state is a connection waiting to be clicked state.

3. The method according to claim 2, characterized in that Also includes: For other quantum gate slots at the same depth as the quantum gate slot to be edited: If a click operation instruction is received, the clicked quantum gate slot is connected to the quantum gate slot to be edited, and the slot display of all quantum gate slots on the connection line is converted from the third state to the fourth state, and the slot display of the remaining quantum gate slots outside the connection line is converted from the third state to the first state; the fourth state is the connection state.

4. The method according to claim 3, characterized in that: The attribute information of the multi-bit quantum gate includes control end attribute information, and the method further includes: Determine whether the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located; If yes, modify the control end attribute information of the quantum gate component of the quantum gate slot to be edited to be connected upward; If not, the control end attribute information of the quantum gate component of the quantum gate slot to be edited is modified to be connected downward.

5. The method according to claim 4, characterized in that The attribute information of the quantum gate slot includes type information, and the method further includes: If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is greater than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, the type information of the clicked quantum gate slot is modified to be selected and connected downward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down; If the quantum bit of the quantum circuit where the quantum gate slot to be edited is located is smaller than the quantum bit of the quantum circuit where the clicked quantum gate slot is located, the type information of the clicked quantum gate slot is modified to be selected and connected upward, and the type information of other quantum gate slots on the connection line is modified to be connected up and down.

6. The method according to claim 1, characterized in that After the quantum gate slot to be edited is displayed to be converted from the first state to the second state, the method further includes: In response to the quantum gate component image dragged in by the quantum gate slot monitoring being out of the range of its own area, the slot display of the quantum gate slot is converted from the second state to the first state.

7. The method according to claim 1, characterized in that Before the quantum gate slot to be edited displays the corresponding quantum gate component image and stores the attribute information of the quantum gate component in the preset edit data object into the quantum gate slot to be edited, the method further includes: Determine whether the quantum gate slot to be edited is empty. If not, move the quantum gate component image and the attribute information of the corresponding quantum gate component of the quantum gate slot whose depth in the quantum circuit editing area is greater than or equal to the depth of the quantum gate slot to be edited to the quantum gate slot of the next depth in sequence.

8. The method according to any one of claims 1 to 7, characterized in that: Also includes: If it is determined that the release event is not within the region of any quantum gate slot to be edited, the quantum gate component image and the attribute information of the corresponding quantum gate component in the preset editing data object are deleted.

9. The method according to any one of claims 1 to 7, characterized in that: Also includes: In response to a dragging instruction to drag the quantum gate component image of the quantum gate slot to be edited to the removal area, the removal area is displayed.

10. The method according to claim 9, characterized in that Also includes: In response to a release operation event of the quantum gate component of the quantum gate slot to be edited in the removal area, deleting the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object, or, In response to a release operation instruction after dragging the quantum gate component of the quantum gate slot to be edited out of the removal area, the quantum gate component image in the quantum gate slot to be edited and the attribute information of the corresponding quantum gate component in the preset editing data object are retained.

11. The method according to any one of claims 1 to 7, characterized in that: Also includes: In response to a sliding instruction on the quantum circuit editing area, a visualization area range of the quantum circuit editing area is displayed following the sliding instruction.

12. A quantum circuit editing device, characterized in that: The device comprises: A quantum gate selection module is configured to respond to a touch instruction of any quantum gate component in the quantum gate selection column, store the attribute information of the quantum gate component into a preset editing data object, and generate a quantum gate component image; A processing module is configured to, in response to a drag instruction for the quantum gate component image, drag the quantum gate component image and the preset editing data object from the quantum gate selection bar to the quantum circuit editing area; The display state switching module is configured to switch the slot display of the quantum gate slot from a first state to a second state in response to any quantum gate slot in the quantum circuit editing area monitoring the quantum gate component image being dragged into the region of the quantum gate slot; the first state is a normal state, which means that the slot is normally unused; the second state is a hovering state; A judgment module is configured to respond to a release event of the quantum gate component mirror and judge that the release event is within a region of any quantum gate slot to be edited; The editing module is configured to display the quantum gate component image at the quantum gate slot to be edited if the release event is in the area range of the quantum gate slot to be edited, and store the attribute information of the quantum gate component in the preset editing data object into the quantum gate slot to be edited.

13. A computer device for quantum circuit editing, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the quantum circuit editing method according to any one of claims 1 to 11 when executing the computer program.

14. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the quantum circuit editing method as described in any one of claims 1 to 11.

15. A computer program product comprising instructions, which, when executed on a computer device, enables the computer device to execute the quantum circuit editing method according to any one of claims 1 to 11.

16. A chip, comprising a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the quantum circuit editing method as described in any one of claims 1 to 11.

Citation Information

Cited By

  • Peripheral electronic device for programming quantum circuits

    ES3079309A1