Detailed Description
The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The technical scheme of the application document can be used in the quantum computing scene, and the specific execution device can be a quantum computer or a device for storing metadata of a quantum chip.
Example one
The method provided by the first embodiment of the present application may be executed in a computer terminal, or a similar computing device. Taking an example of the method running on a computer terminal, fig. 1 is a hardware structure block diagram of a computer terminal of a recording method of metadata according to an embodiment of the present application. As shown in fig. 1, the computer terminal 10 may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and optionally may also include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, the computer terminal 10 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 recording method of metadata in the embodiment of the present application, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, so as to implement the above-mentioned method. The 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 located remotely from the processor 102, which may be connected to the computer terminal 10 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 device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In the present embodiment, a method for recording metadata is provided, and fig. 2 is a flowchart of a method for recording metadata according to an embodiment of the present application, where as shown in fig. 2, the flowchart includes the following steps:
step S202, obtaining metadata of the quantum chip;
step S204, recording the metadata.
Through the steps, the metadata of the quantum chip to be used is obtained from the server inside or outside the quantum chip, the metadata is recorded, and the quantum program is converted according to the metadata when the quantum chip is used subsequently, so that the quantum program can be executed on the quantum chip, the problem that the operation range of the quantum program is limited due to the lack of a scheme for recording the metadata in the related technology is solved, the metadata is timely and accurately recorded, and the application range of the quantum program is increased.
Optionally, recording the metadata includes: the metadata is recorded in formatted text. The formatted text may include the form of JSON, XML, ini files, etc.
Optionally, the metadata comprises at least one of the following types: a connection structure between qubits on the quantum chip; a first set of single qubit operation gates supported by each qubit on the qubit chip; a second set of two qubit operation gates supported is connected between every two qubits on the qubit chip.
Optionally, when the metadata is a connection structure between the qubits, the method includes: in the formatted text, the connection structure between the qubits is recorded in the form of an unweighted graph.
Optionally, recording a connection structure between the qubits in the form of an unweighted graph, comprising: and recording the connection structure between the quantum bits by adopting an adjacent matrix method or an adjacent table method.
Optionally, the first set of single-qubit operation gates supported by each qubit on the qubit chip comprises single-qubit operation gates having: the matrix elements of the single-quantum bit operation gate are discrete elements; or, the matrix elements of the single-qubit operation gate are consecutive elements. When the matrix element is a discrete element, the matrix element is represented as a constant value; when the matrix element is a continuous element, it means that the matrix element is configured with at least one parameter, and the parameter may include a range.
Optionally, the second set of two-qubit operation gates supported by the connection between every two qubits on the qubit chip includes two-qubit operation gates having: matrix elements of the two qubit operation gates are discrete elements; alternatively, the matrix elements of the two qubit operation gates are consecutive elements.
According to another embodiment of the present document, there is also provided an operating method of a quantum program, including the steps of:
acquiring metadata of a quantum chip to be operated with a first quantum program;
step two, converting the first quantum program into a second quantum program according to the metadata;
and step three, executing the second quantum program on the quantum chip.
By adopting the steps, the first quantum program to be executed is timely converted into a quantum chip supporting mode, the problem that the operation range of the quantum program is limited due to the lack of a scheme for recording the metadata in the related technology is solved, the metadata is timely and accurately recorded, and the application range of the quantum program is enlarged.
Optionally, before the first quantum program is converted into the second quantum program according to the metadata, it is determined that the first quantum program cannot be run on the quantum chip according to the metadata. On the contrary, when it is determined that the first quantum program can be run on the quantum chip, the first quantum program is directly run without conversion.
The following description is made in conjunction with another embodiment of the present document.
Fig. 3 is a diagram of a quantum chip model according to the related art, and Q1, Q2, Q3, and Q4 represent qubits, as shown in fig. 3.
The metadata of the quantum chip contains the following information: (1) the topological structure of the quantum chip (the connection relation between quantum bits) is included; (2) the single-quantum-bit logic gate comprises a single-quantum-bit logic gate supported by each quantum bit in the quantum chip; (3) including two qubit logic gates supported by any connection in the quantum chip.
Metadata of quantum chips in the related art has two characteristics:
1. the metadata of each chip is a unique attribute of the chip, and in any quantum program, the quantum program can be executed on the chip only if the logic gates contained in the quantum program are consistent with the metadata. Such as: given a quantum chip, which only supports qubit flip operations, the quantum logic gates contained in the designed quantum program must be effectively converted out of the corresponding flip operation gates to be able to run on the chip.
2. In the related art scheme, there is no general scheme for recording the quantum chip metadata. The developers of quantum chips design their metadata according to their own conditions, and the common schemes do not reach consensus.
Some chip developers in the related art do not limit the addition of some quantum logic gates by recording metadata. This greatly increases the difficulty of creating quantum programs. For example, when adapting different quantum chips, the same program needs to be created or translated in different ways between the different chips. Such as: the given quantum chip defines the phase reversal operation, but the phase reversal is set as a general operation in the programming, so when the program is adapted to the quantum chip, because no metadata is recorded, the conversion operation cannot be made, and errors are inevitable.
The application adopts a general method to record the metadata of the quantum chip. The metadata can effectively help the automatic adaptation of the quantum program and the quantum chip, so that the purposes of 'one-time creation and everywhere running' of the quantum program are realized, and the creation of the quantum program is simplified. By recording the metadata, the creation of the quantum program is no longer limited by the chip structure.
The metadata of a quantum chip contains three types of information. First, a connection structure between qubits on a quantum chip; second, the set of single qubit operation gates supported by each qubit (corresponding to a node of the graph, see fig. 3); third, every two qubits connects the two qubit operation gate sets supported (for the edges of the graph in fig. 3).
For the first type of metadata, a connection structure of qubits on a quantum chip. Such connections are usually expressed in the form of "weightless graphs" in graph theory, such as adjacency matrix methods, adjacency list methods, and the like.
Fig. 4 is a schematic diagram of an example of a quantum chip link structure represented by an unweighted graph according to the application, and as shown in fig. 4, the left side is an unweighted graph used for representing an example of a link structure of a quantum chip on the right side, and the vertexes of the graph correspond to quantum bits on the quantum chip in a one-to-one manner. The edges of the graph correspond one-to-one to all the two qubit gates supported in the quantum chip. The edges of the graph are directed or undirected, and are determined according to whether quantum logic operation gates on two qubits are kept unchanged when exchanging positions. Fig. 5 is a schematic diagram of a CNOT gate and a CZ gate according to the present document, as shown in fig. 5, for the CNOT gate, expressed in the manner of a "directed graph" because the position is switched, the operation is not equivalent, as shown on the left side of fig. 5. For the CZ gate, ISWAP gate, we use "undirected graph" to describe, switch positions, and operate equivalently, as shown in the right side of fig. 5.
For the second type of metadata, each qubit on the chip supports a set of single-qubit operation gates. The set contains all the single qubit operating forms (unitary matrix form of 2 x 2) supported by the qubits. The set elements in this form are divided into two types, one is discrete elements, which represent elements whose operation matrix (called unitary transform matrix, quantum logic gate in the field of quantum computation) on a quantum chip is constant, such as Hadamard gate, X gate, Y gate, Z gate, T gate, etc.; the second is a continuous element, which represents an element of the operation matrix on the quantum chip configured by at least one parameter, such as an RX gate, a U3 gate, a U2 gate, and the like.
For the third type of metadata, a set of two qubit gates supported by every two connected qubits on the qubit chip. The set contains all the two-qubit operating forms supported by the two-by-two connection (unitary matrix form of 4 x 4). This form of set element is divided into two types, one being a discrete element which represents an operation whose matrix of operations is constant, such as a CNOT gate, an ISWAP gate, a CZ gate; the second is a continuous element, which represents an element of the operation matrix on the quantum chip configured by at least one parameter, such as a CPHASE gate, a C-U gate.
In the application, formatted text is adopted to record the quantum chip source data. Formatted text is a text file with information about style, layout, and format, and the use of formatted text records is a more optimized and persistent solution (which can be stored on a medium such as a hard disk for a long period of time). For example: compared with general texts, the formatted texts can increase the reading and configuration efficiency in the forms of JSON, XML, ini files and the like.
In the software construction, recording by using the adjacency matrix of the graph is a more optimized temporary recording (i.e. reading in the memory) scheme. Fig. 3 is described using a adjacency matrix, which in graph theory is a common storage representation representing a graph that stores information about data elements (e.g., 1,2,3,4 in fig. 3) and information about relationships (edges or arcs) between data elements (e.g., edges between 1,2,3,4 in fig. 3) in two arrays, respectively. Here, the diagonal elements in the adjacency matrix store the set of single-qubit logic-operated gates supported by the qubits; the off-diagonal elements in the matrix store the connections that can be supported by two qubits, and the two sets of quantum logic operation gates in the connections. The benefit of this scheme is that it is easy to index the relationship between qubits, and the presence of a connection can be judged by the temporal complexity of O (1).
Recording using the adjacency list of the graph is another more optimal temporary recording scheme. The graph is described by using an adjacency list (in graph theory, the adjacency list represents all edges or arcs in one graph), all nodes (corresponding to quantum bits on a chip) are stored by an array, and the nodes comprise single-quantum-bit logic gates supported by the quantum bits; and storing all edges, including the two qubit logic gates supported by this connection, via another array.
In this document, a generic data structure (e.g., formatted text) is used to store the connections on the quantum chip and the set of single-qubit and two-qubit logic gates that are supported. The single-quantum-bit logic gate and the two-quantum-bit logic gate can be a continuous set or a discrete set, and are suitable for the conditions of different quantum chip measurement and control systems. In the above scheme, a persistent storage scheme may be used, or a scheme recorded in a memory may be used.
By adopting the technical scheme, the following technical effects are realized:
1. a universal and unified data structure is used to store the connection relationship on the quantum chip and the collection of single-quantum-bit and two-quantum-bit logic gates supported.
2. Considering that the single-qubit logic gate and the two-qubit logic gate may be continuous and may be discrete sets, which is suitable for different quantum chip measurement and control systems.
3. The data adopts a graph model, is easy to record, and can use a persistent storage scheme or a scheme recorded in a memory.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present application.
Example two
In this embodiment, a metadata recording apparatus is further provided, and the apparatus is used to implement the foregoing embodiments and preferred embodiments, and the description already made is omitted for brevity. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
According to an embodiment of the present document, there is provided a metadata recording apparatus including:
the first acquisition module is used for acquiring metadata of the quantum chip;
and the recording module is used for recording the metadata.
By adopting the technical scheme, the metadata of the quantum chip to be used is obtained from the server inside or outside the quantum chip, the metadata is recorded, and the quantum program is converted according to the metadata when the quantum chip is used subsequently, so that the quantum program can be executed on the quantum chip, the problem that the operation range of the quantum program is limited due to the lack of a scheme for recording the metadata in the related technology is solved, the metadata is timely and accurately recorded, and the application range of the quantum program is increased.
According to another embodiment of the present document, there is also provided an apparatus for operating a quantum program, including:
the second acquisition module is used for acquiring metadata of a quantum chip to be operated with the first quantum program;
the conversion module is used for converting the first quantum program into a second quantum program according to the metadata;
an execution module to execute the second quantum program on the quantum chip.
By adopting the steps, the first quantum program to be executed is timely converted into a quantum chip supporting mode, the problem that the operation range of the quantum program is limited due to the lack of a scheme for recording the metadata in the related technology is solved, the metadata is timely and accurately recorded, and the application range of the quantum program is enlarged.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
EXAMPLE III
Embodiments of the present application also provide a storage medium. Alternatively, in the present embodiment, the storage medium may be configured to store program codes for performing the following steps:
s1, obtaining metadata of the quantum chip;
and S2, recording the metadata.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Embodiments of the present application further provide an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, obtaining metadata of the quantum chip;
and S2, recording the metadata.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.