CN113128015A - Method and system for predicting resources required by single-amplitude analog quantum computation - Google Patents

Method and system for predicting resources required by single-amplitude analog quantum computation Download PDF

Info

Publication number
CN113128015A
CN113128015A CN201911412718.0A CN201911412718A CN113128015A CN 113128015 A CN113128015 A CN 113128015A CN 201911412718 A CN201911412718 A CN 201911412718A CN 113128015 A CN113128015 A CN 113128015A
Authority
CN
China
Prior art keywords
quantum
tensor
vertex
edge
undirected graph
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911412718.0A
Other languages
Chinese (zh)
Other versions
CN113128015B (en
Inventor
王晶
窦猛汉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Origin Quantum Computing Technology Co Ltd
Original Assignee
Origin Quantum Computing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Origin Quantum Computing Technology Co Ltd filed Critical Origin Quantum Computing Technology Co Ltd
Priority to CN201911412718.0A priority Critical patent/CN113128015B/en
Publication of CN113128015A publication Critical patent/CN113128015A/en
Application granted granted Critical
Publication of CN113128015B publication Critical patent/CN113128015B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena

Abstract

The invention discloses a method and a system for predicting resources required by single-amplitude analog quantum computation, and belongs to the field of quantum computation. The method comprises the steps of obtaining a quantum line to be simulated and a configured process, constructing an undirected graph corresponding to the quantum line to be simulated, determining the total quantity of tensor elements which can be stored by the process according to the parameter information of the process and the data types of the tensor elements, determining the splitting times of the undirected graph to be calculated according to the total quantity of the tensor elements, and finally determining resources required by calculation of the single-amplitude simulation quantum according to the splitting times of the undirected graph to be calculated, so that the resources required by calculation of the single-amplitude simulation quantum can be estimated in advance during single-amplitude simulation.

Description

Method and system for predicting resources required by single-amplitude analog quantum computation
Technical Field
The invention belongs to the technical field of quantum computation, and particularly relates to a method for predicting resources required by single-amplitude analog quantum computation.
Background
The quantum computation simulation is a simulation computation which simulates and follows the law of quantum mechanics by means of numerical computation and computer science, and is used as a simulation program which describes the space-time evolution of quantum states by utilizing the high-speed computing capability of a computer according to the basic law of quantum bits of the quantum mechanics.
At present, the quantum computation simulation mainly comprises three modes of full-amplitude simulation, partial-amplitude simulation and single-amplitude simulation, wherein a quantum program comprises N quantum bits, and the single-amplitude simulation means that only 2 quantum bits are computed at a timeNAmplitude of one of the quantum state components, i.e. the target quantum state componentThe amplitude of (d). Compared with full-amplitude simulation, single-amplitude simulation reduces the requirement on memory resources, and in practical application, only one or more amplitudes of all the amplitudes of the qubits are needed, and in this case, one or more times of simulation can be performed in a targeted manner by using a single-amplitude simulation method.
Based on the method, the computing resources at least needed when the single-amplitude quantum computing simulation is carried out on the quantum circuit to be simulated are estimated in advance for the distributed computer cluster carrying out the single-amplitude quantum simulation algorithm.
Disclosure of Invention
The invention provides a method for predicting resources required by single-amplitude analog quantum computation.
A method for predicting resources required by single-amplitude analog quantum computation comprises the following steps:
acquiring a quantum line to be simulated and a configuration process;
constructing a corresponding undirected graph to be calculated according to the quantum line to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements;
determining the splitting times of the undirected graph to be calculated according to the total amount of the tensor elements;
and determining resources required by the computation of the single-amplitude analog quantum according to the splitting times of the undirected graph to be computed.
Preferably, the constructing a corresponding undirected graph to be computed according to the quantum wires to be simulated includes:
analyzing the quantum circuit to be simulated to obtain a linked list for recording the information of the quantum circuit to be simulated;
traversing the linked list, and creating an edge with a tensor order of 1 when the type of the quantum logic gate in the linked list is a first single quantum logic gate; the edge is connected with the last vertex of the corresponding vertex chain of the quantum bit operated by the first single-quantum logic gate, and the unitary matrix of the first single-quantum logic gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second single quantum logic gate, creating an edge with the tensor order of 2 and a vertex connected with the edge; the edge is connected with the last vertex of the corresponding vertex chain of the quantum bit operated by the second single-quantum logic gate, and the unitary matrix of the second single-quantum logic gate is a non-diagonal matrix;
when the type of the quantum logic gate in the linked list is a first double quantum logic gate, creating an edge with the tensor order of 2; the edge is connected with the last vertex in the vertex chain respectively corresponding to the two quantum bits operated by the first double-quantum logic gate, and the unitary matrix of the first double-quantum logic gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second double-quantum logic gate, creating an edge with the tensor order of 4 and two vertexes connected with the edge; the edge is connected with the last vertex in the vertex chain respectively corresponding to the two quantum bits operated by the second double-quantum logic gate, and the unitary matrix of the second double-quantum logic gate is a non-diagonal matrix;
and obtaining the undirected graph to be calculated corresponding to the quantum line to be simulated.
Preferably, the determining, according to the parameter information of the process and the data type of the tensor elements, the total amount of tensor elements that can be stored by the process includes:
determining memory resources used for single-amplitude quantum simulation calculation in a single process according to the parameter information of the process;
determining the memory required by each element of the tensor according to the data type expressing the tensor element;
and determining the total amount of tensor elements which can be stored by the process according to the memory resources and the memory required by each element.
Preferably, wherein:
if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM and the data type representing the tensor element is the Float type, the total amount of the tensor elements which can be stored by the process is m multiplied by 1024 multiplied by 1024/8;
if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM, and the data type representing the tensor elements is a Double type, the total amount of the tensor elements which can be stored in the process is m × 1024 × 1024/16, wherein m is any positive number.
Preferably, determining the splitting times of the undirected graph to be calculated according to the total number of tensor elements which can be stored in the process includes:
according to a preset sequence, obtaining information of edges connected with each vertex in the undirected graph to be calculated;
executing fusion operation on the edges connected with the current vertex according to the information of the edges connected with the current vertex;
after the edges connected with the current vertex execute the fusion operation, updating the undirected graph to be calculated;
judging whether the sum of the number of tensor elements corresponding to all edges in the undirected graph to be calculated is greater than the total number of tensor elements which can be stored by the process;
if the number of the elements of the tensor which can be stored by the process is not larger than the total number of the elements of the tensor which can be stored by the process, executing value determination reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing the step of executing the fusion operation on the edges connected with the current vertex;
if the total quantity of the elements of the tensor which can be stored by the process is larger than the total quantity of the elements of the tensor which can be stored by the process, returning the undirected graph to be calculated which is updated last time, executing deletion operation on each vertex before the current vertex and information of edges connected with each vertex before the current vertex, executing definite value reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing fusion operation on the edges connected with the current vertex;
and determining the splitting times of the undirected graph to be calculated according to the execution times of the deleting operation.
Preferably, determining the splitting times of the undirected graph to be calculated according to the total number of tensor elements which can be stored in the process, further includes:
before the information of the edges connected with the vertexes in the undirected graph to be calculated is obtained according to the preset sequence, determining a first vertex and a last vertex of the undirected graph to be calculated according to the undirected graph to be calculated;
and respectively executing determined value reduction operation on the edge connected with the first vertex and the edge connected with the last vertex.
Preferably, the step of fusing comprises:
determining a first edge and a second edge to be fused;
according to a vertex which is not connected with the first edge in a second vertex group of the second edge, performing step-up operation on a first tensor of the first edge, and updating the first tensor by the raised tensor;
determining a corresponding element of each element in the first tensor in a second tensor of the second edge according to a corresponding relation between a first vertex group corresponding to the first tensor and the second vertex group;
traversing each element in the first tensor to update the element by the product of the element and its corresponding element in the second tensor;
deleting the second edge and connecting other vertices of the second edge except the current vertex to the first edge.
The invention also provides a system for predicting resources required by single-amplitude analog quantum computation, which comprises the following steps:
the acquisition module is used for acquiring the quantum line to be simulated and the configured process;
the construction module is used for constructing a corresponding undirected graph to be calculated according to the quantum line to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
a tensor element determining module, configured to determine, according to the parameter information of the process and the data type of the tensor elements, a total amount of tensor elements that can be stored in the process;
the splitting frequency determining module is used for determining the splitting frequency of the undirected graph to be calculated according to the total amount of the tensor elements;
and the calculation resource determining module is used for determining resources required by the single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.
The invention also provides a storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the method of any of the above when run.
The invention also 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 above.
Compared with the prior art, the method comprises the steps of obtaining the quantum line to be simulated and the configured process, constructing the undirected graph corresponding to the quantum line to be simulated, determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements, determining the splitting times of the undirected graph to be calculated according to the total amount of the tensor elements, and finally determining the resources required by the calculation of the single-amplitude simulation quantum according to the splitting times of the undirected graph to be calculated, so that the resources required by the calculation of the single-amplitude simulation quantum can be estimated in advance during the single-amplitude simulation.
Drawings
Fig. 1 is a specific example of a quantum program splitting into different paths corresponding to quantum wires;
FIG. 2 is a schematic flow chart of a method for estimating resources required for single-amplitude analog quantum computation;
fig. 3 is a schematic view of an undirected graph constructed by different types of quantum logic gates in the single-amplitude quantum computation simulation method according to the embodiment of the present invention;
fig. 4 is an undirected graph corresponding to an example of a quantum wire to be simulated according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a system for estimating resources required for single-amplitude analog quantum computation.
Detailed Description
The invention is further described with reference to the accompanying drawings and specific embodiments.
Qubits are the basic unit of information in quantum computing, so that there is a correspondence of 2 for N qubitsNThe quantum state components, for example:
1 qubit is in a logic state that is a superposition of 2 quantum state components, the 2 quantum state components being |0> and |1>, respectively, and the logic state of the 1 qubit can be expressed as:
ψ=a|0>+b|1>
wherein, a and b are the amplitude of |0> and |1>, and a and b are complex forms.
The matrix for ψ is represented as:
Figure BDA0002350383770000051
after measurement, the 1 qubit is in a logic state that collapses to a fixed quantum state |0>Or |1>Wherein, collapse to |0>Has a probability of2Collapse to |1>Has a probability of b2,a2+b2=1。
The 3 qubits are in a logic state of 23(i.e., 8) superposition states of quantum state components, wherein the 8 quantum state components are respectively |000>、|001>、|010>、|011>、|100>、|101>、|110>And |111>At this time, any logic state ψ in which the 3 qubits are located can be expressed as:
ψ=c0|000>+c1|001>+c2|010>+c3|011>+c4|100>+c5|101>+c6|110>+c7|111>
and psi corresponds to the matrix expressed as:
Figure BDA0002350383770000052
wherein each quantum state component in the 8 quantum states has an amplitude c0To c7One of these plural numbers, c0To c7The subscript value of (c) is the binary corresponding decimal value of the quantum state to which the amplitude belongs0To c7Each of these complex numbers is referred to as a single amplitude.
The process of quantum computation is a process of operating corresponding quantum bits by different quantum logic gates in order, wherein, the sequence of quantum logic gates combined in order is called a quantum wire. In the quantum computation simulation process, a unitary matrix is used for representing the quantum logic gate, and the process of quantum logic gate operation corresponding to the quantum bit is the process of matrix multiplication computation by multiplying the unitary matrix by a matrix corresponding to a quantum state right vector. Therefore, quantum computation can also be understood as that unitary matrixes corresponding to different quantum logic gates perform left multiplication on initial quantum states in order. Wherein:
single quantum logic gates (e.g., Aldamard, Paly-X, Paly-Y, Paly-Z, etc.) are a 2X 2 matrix, where an operation of a single quantum logic gate on a qubit in a quantum wire only changes the amplitude of the state to which the qubit corresponds, and where the states to which the qubit corresponds are present in groups of 2 qubits; a dual quantum logic gate (e.g., a control not gate, a switching gate, etc.) is a 4 x 4 matrix, where operating on two qubits in a quantum wire only changes the amplitudes of the states corresponding to the two qubits, and where the states corresponding to the qubits occur in groups of 4 quantum states.
It should be noted that the qubits of the qubits implemented by the dual-quantum logic gate include two control bits and two operation bits, respectively, a common dual-quantum logic gate is a CNOT gate (i.e., a control not gate), q1 in the CNOT (q1, q2) is a control bit, q2 is an operation bit, and the roles of the qubits are: the quantum state of operational bit q2 is unchanged when the control bit is in the |0> state and the quantum state of operational bit q2 is inverted when the control bit is in the |1> state. It should be noted that the control bit and the operation bit are not allowed to be the same qubit when constructing the quantum wire.
The quantum computation simulation mainly comprises amplitude simulation, partial amplitude simulation and single amplitude simulation, wherein:
single amplitude simulation means one-time simulation to calculate 2 of N qubitsNThe amplitude of one of the quantum state components, i.e. the amplitude of the target quantum state component. Specifically, single-amplitude simulation is to map quantum lines onto an undirected graph, split the undirected graph into multiple computation processes (or called "computation nodes") by combining a path integration method, and compute corresponding sub-undirected graphs by each process, thereby realizing parallel computation. The whole calculation process is based on simple operation of elements in the tensor, and compared with full-amplitude simulation, the requirement on memory resources is greatly reduced.
In addition, in practical application, sometimes only one or more than one amplitude of the full amplitude of the qubits is needed, and in this case, if full-amplitude simulation is adopted, that is, all the amplitudes are simulated at one time, the waste of resources such as a memory and time is undoubted; and by applying the single-amplitude simulation method, one or more times of simulation can be performed in a targeted manner, and only one or more single amplitudes required can be simulated, so that resources and time are greatly saved.
However, with the separation of the undirected graph, the resources required for single-amplitude simulation also change, even increase, which seriously affects the simulation efficiency of quantum computation, and therefore, a method for estimating the resources required for single-amplitude simulation quantum computation is needed.
It should be noted that, in the single-amplitude simulation, it is assumed that the initial quantum state |0.. 0 of the qubit is divided in the quantum line (or quantum program) to be simulated>And the last state is involved in M1Quantum state, then, since the state of each qubit can be at |0>And |1>So as to be directed to M1One quantum state in the quantum well, splitting it into |0>And |1>Then, the initial quantum state to the final state component X ═ X can be obtained0...xn-1>2 of (2)M1Calculating the amplitude of each path by using possible transformation paths, and calculating the amplitude of each pathThe final state component, i.e., the amplitude of the target quantum state component, is obtained by summing. Wherein M is1Is a positive integer.
For example, a quantum wire to be simulated involves 2 qubits, respectively: q. q.s0、q1Initial state s0=|00>The target quantum state component is |11>(a quantum state component of the last state), the quantum wire contains 2H gates (Hadamard Gate ): h1H 21 CNOT Gate (Control-not Gate).
As shown in FIG. 1a, which gives a simple illustration of the quantum process with respect to a quantum wire, it can be seen that the quantum wire divides the initial quantum state |00>And a target quantum state component |11>In addition, 4 quantum states are involved: s0 1、 s0 2、s1 1、s1 2Where each quantum state can be represented as |0>And |1>In the stacked state. If will s1 1Splitting into |0>And |1>Two parts, then, from the initial quantum state |00>To |11>It can be split into two paths as shown in (1b) and (1c) to obtain the initial quantum state |00>Transformed into |11 via two paths>And summing the sub-amplitudes to obtain an amplitude value corresponding to the target quantum program, thereby completing the simulation.
It will be appreciated that if M in a quantum wire is to be used1Quantum state, all splitting it into |0>And |1>Two parts, then the initial quantum state to the final state component is obtained
Figure BDA0002350383770000073
And calculating the amplitude of each path by using the possible transformation paths, and summing to obtain the target single amplitude of the quantum state.
In a quantum wire (or quantum program) with only single-quantum logic gates and diagonal dual-quantum logic gates, the initial quantum state of a given qubit is |0.. 0>When the final state component, i.e. the target quantum state component, takes the value of x ═ x0...xn-1>Then, the calculation formula of the amplitude can be expressed as:
Figure BDA0002350383770000071
formula (1) is a basic formula of the quantum mechanical path integration method.
It should be noted that psi functions in formula (1) are all complex functions related to boolean variables, and represent the contribution of quantum logic gates to quantum states, and for better illustration, formula (1) only represents one of the three types of psi functions, and omits other psi functions;
Figure BDA0002350383770000072
the quantum bit with the value of {0, 1}, corresponding to the quantum bit j, is subjected to the action of the kth quantum logic gate to obtain the quantum state component. The value of psi function is mainly related to two factors, namely, the quantum state of quantum bit operated by the quantum logic gate before and after the quantum logic gate is executed, and unitary matrix of the quantum logic gate.
In particular, the amount of the solvent to be used,
Figure BDA0002350383770000081
is about a Boolean variable
Figure BDA0002350383770000082
And
Figure BDA0002350383770000083
the value of the complex function is determined by the values of two variables and the unitary matrix of the corresponding diagonal dual-quantum logic gate,
Figure BDA0002350383770000084
and
Figure BDA0002350383770000085
respectively corresponding to qubits of v1And v2The two quantum bits are not subjected to the component of the quantum state before the action of the v diagonal double-quantum logic gate;
Figure BDA0002350383770000086
is about a Boolean variable
Figure BDA0002350383770000087
The value of the complex function is determined by the value of the variable and the unitary matrix corresponding to the diagonal single-quantum logic gate,
Figure BDA0002350383770000088
the quantum bit corresponding to the quantum bit u is not subjected to the component of the quantum state before the action of the u' th diagonal single-quantum logic gate;
Figure BDA0002350383770000089
is about a Boolean variable
Figure BDA00023503837700000810
And
Figure BDA00023503837700000811
the value of the complex function is determined by the values of two variables and a unitary matrix corresponding to the non-diagonal single-quantum logic gate,
Figure BDA00023503837700000812
and
Figure BDA00023503837700000813
the quantum bit corresponding to the quantum bit j has the components of the quantum state before and after the action of the ith off-diagonal single-quantum logic gate. It is understood that j, k, v1、v2、v1′、v2', u', i are all non-negative integers.
As shown in fig. 2, the present embodiment provides a method for estimating resources required for single-amplitude analog quantum computation, including the following steps S100 to S500, where:
s100, acquiring a quantum wire to be simulated and a configuration process.
For ease of understanding, as described below with reference to fig. 1 and the specific example, the quantum wire to be simulated is, for example, the following 1# quantum wire, the distributed computer cluster simulating the 1# quantum wire is configured with 4 procedures based on MPI communication, the target quantum state component is |101>, and the corresponding amplitude of the target quantum state component is the single amplitude to be calculated:
QCircuitcir;
cir<<RY(q[0],PI/2)<<H(q[2])
<<CNOT(q[2],q[1])
<<CNOT(q[0],q[1])<<H(q[2])
<<H(q[0])<<CNOT(q[1],q[2]).
among these, those skilled in the art will appreciate that:
h represents an adama Hadamard gate, X represents a Paly-X gate (a matrix corresponding to the gate is a Paly matrix sigma X), Y represents a Paly-Y gate (a matrix corresponding to the gate is a Paly matrix sigma Y), Z represents a Paly-Z gate (a matrix corresponding to the gate is a Paly matrix sigma Z), RX represents an arbitrary rotating Pay-X gate, RY represents an arbitrary rotating Pay-Y gate, RZ represents an arbitrary rotating Pay-Z gate, and CNOT represents a Control NOT gate (Control-NOT);
q0, q1, q2 refer to qubits in bits from 0 to 2. It should be noted that the representation of quantum state corresponds to the arrangement rule of q2q1q0, and the corresponding bit from right to left in q2q1q0 is from low to high.
Therefore, from this quantum circuit, it can be determined that the quantum logic gate H (q0) is a single quantum logic gate, and the bit of the quantum bit it acts on is 0, similarly: determining that H (q1) is a single quantum logic gate and the bit of the quantum bit acted by the single quantum logic gate is 1; determining RY (q0) as a single quantum logic gate and the bit of the quantum bit acted by RY is 2; ...; determining that CNOT (q1, q2) is a double-quantum logic gate, and the bits of the applied qubits are 2 and 1; .......
S200, constructing a corresponding undirected graph to be calculated according to the quantum line to be simulated; wherein the vertices of the undirected graph represent quantum states of the operated-on qubits before or after operation of the quantum logic gate, and the edges of the undirected graph represent tensors.
The quantum circuit to be simulated comprises quantum logic gate information and related quantum bits, and an undirected graph is constructed by analyzing the quantum circuit to be simulated and sequentially reading data obtained by analysis; or configuring information of a target type format obtained after the quantum line to be simulated is analyzed, and constructing an undirected graph according to the information of the target type format. The target type format can be a linked list, a queue and the like, and the linked list is optimized in consideration of higher efficiency in subsequent undirected graph construction.
It should be noted that:
in the process of constructing the undirected graph to be computed, when a vertex is created, the vertex belonging to the second vertex of the qubit operated by the current quantum logic gate is recorded.
In the constructed undirected graph to be calculated, each quantum bit corresponds to vertex chain information, and the vertex chain information comprises vertex values from a first vertex to a last vertex, information of edges connected with the vertices and vertex identifications. The vertex identification uniquely determines a vertex, and the quantum bit to which the corresponding vertex belongs, the value of the quantum bit, the information of the connected edges and the like can be determined according to the identification; after the value of the vertex is determined, the value is 0 or 1; however, when the vertex value is uncertain, the vertex value may be null, or any agreed numerical value or character that conforms to the vertex value type, such as-1, for determining the vertex value condition in the implementation process. The vertex values may be expressed as tensors, or may be expressed as variables or other reasonable data types.
The undirected graph to be computed further includes tensor information of the edges, which may include a tensor array and identifications of vertices connected by the edges corresponding to the tensor.
Wherein, the vertexes of the undirected graph to be calculated correspond to the quantum state components of the operated qubits before or after the operation of the quantum logic gate, and the values are all {0, 1}, corresponding to the variables in the formula (1)
Figure BDA0002350383770000091
And the operated qubit is the qubit corresponding to the operation of the quantum logic gate. The edges of the undirected graph correspond to quantum logic gates in the quantum circuit to be simulated, and specifically, the edges corresponding to each quantum logic gate correspond to a tensor (that is, the tensor is related to the characteristics of the quantum logic gate), and the tensor includesThe element of (2) is determined by the unitary matrix corresponding to the quantum logic gate and the vertex value connected with the corresponding edge, and the tensor corresponds to the psi function in the formula (1).
Tensor (Tensor) is a quantity defined in several linear spaces simultaneously, and is a generalization of the concept of vectors and matrices. Each tensor can be indexed using subscript notation, e.g., tensor T12The number of subscripts is the order of the tensor (rank), which represents the dimension of the tensor. For example, the scalar is a 0 th order tensor, the vector is a 1 st order tensor, and the matrix is a 2 nd order tensor. The shape of the tensor is then the number of elements in each dimension; the number of tensor elements is determined by their shape.
In the embodiment of the invention, the order of the tensor is equal to the number of vertexes connected with corresponding edges of the tensor, and the subscript of the tensor is the number of vertexes in the undirected graph. Since each vertex can only take a value of 0 or 1, there are only two possibilities, and thus, for an n-order tensor, its shape is [2, 2, 2.. 2 ]]The number of elements is 2n
The number of each tensor element can be represented as a binary number, and each bit of the binary number can be represented as a value of a corresponding vertex.
For example, edge EmConnecting 4 vertices, the corresponding tensor is a 4 th order tensor with 2 total elements4The element number can be represented as a binary number: (0000)2~(1111)2. When edge EmThe 4 connected vertexes are arranged according to a certain sequence to obtain a vertex sequence, and when the four vertexes all take the value of O, the combined value of the vertex sequence is 0000, and the (0000) th corresponding tensor is obtained2A bit element; when edge EmThe value of the first vertex of the connection is 1, the value of the second vertex is 0, the value of the third vertex is 0, and the value of the fourth vertex is 1, the combined value of the vertex sequences is '1001', corresponding to the tensor (1001)2A bit element.
It can be understood that, in the process of constructing the undirected graph to be computed in the present embodiment, the vertices and edges are added according to the order of the quantum logic gates in the quantum wires to be simulated and the conversion condition of the quantum states of the quantum bits of the operations of the quantum logic gates. The following further explains the construction of the undirected graph to be computed in combination with different types of quantum logic gates, specifically as follows:
in the first case: the quantum logic gate is a diagonal single-quantum logic gate or a diagonal double-quantum logic gate
In this case, when the unitary matrix corresponding to the single-quantum logic gate or the dual-quantum logic gate is a diagonal matrix, the quantum logic gate acts on the qubit, usually only the amplitude is changed, and the quantum state component corresponding to the qubit — corresponding to the quantum state component in the formula (1)
Figure BDA0002350383770000101
There is typically no change.
Single quantum logic gates of this type, typically Pauli-Z gates, have a unitary matrix of
Figure BDA0002350383770000111
When a qubit is operated on with a Poly-Z gate, the basic state |0> of the qubit is left unchanged and |1> is converted to- |1 >.
A dual quantum logic gate of this type, typically a CZ gate, has a unitary matrix of:
Figure BDA0002350383770000112
when for two qubits Q0、Q1(Q0To control bits, Q1Target bit) when performing a CZ gate operation, Q is the same as the target bit0Quantum state of (b) is |0>When is, Q1The quantum state of (a) is unchanged; when Q is0Quantum state of |1>When is, Q1Quantum state retention of 0>Invariably, will |1>Change to- |1>。
It can be seen that either the pauli-Z gate or the CZ gate brings about only a change in the amplitude of the quantum state component, with the quantum state component being unchanged. Therefore, when an undirected graph is constructed for such a quantum logic gate, i.e., a single quantum logic gate or a double quantum logic gate in which a unitary matrix is a diagonal matrix, an edge corresponding to the quantum logic gate is added to the undirected graph.
As shown in FIG. 3a, for diagonal single quantum logic gate, only one edge E is added when constructing an undirected graph1That is, one end of the edge and the vertex V0Are connected. Wherein, V0The current last vertex of the corresponding quantum bit, namely the vertex corresponding to the quantum state directly acted by the quantum logic gate.
It can be understood that, as shown in FIG. 3 (a), the edge E1 connects to only one vertex, so its tensor
Figure BDA0002350383770000113
Is tensor of order 1 and has a total of 212 elements, the tensor corresponds to ψ in equation (1)uA function representing the contribution of the diagonal single quantum logic gate to a quantum state.
For example, when the edge E1When the corresponding edge of the diagonal single quantum logic gate Pagli-Z gate is known, the tensor can be known according to the unitary matrix of the Pagli-Z gate
Figure BDA0002350383770000114
As shown in FIG. 3b, for diagonal double-quantum logic gate, only one edge E needs to be added when constructing an undirected graph12One end of the edge and the vertex V1Connected with one end of the vertex V2Are connected. Wherein, V1And V2The two qubits of the diagonal double-quantum logic gate operation are respectively corresponding to the current last vertex, i.e. the vertex corresponding to the quantum state directly acted by the diagonal double-quantum logic gate.
It will be appreciated that edge E, as shown in FIG. 3b12With two vertices V1And V2Are connected so their tensors
Figure BDA0002350383770000115
Is 2-order tensor and has a total of 224 elements, the tensor corresponds to ψ in equation (1)νA function of expressing theContribution of diagonal dual quantum logic gates to quantum states.
For example, when the edge E12When the corresponding edge of the diagonal biquantum logic gate CZ gate is obtained, the tensor can be known according to the unitary matrix
Figure BDA0002350383770000121
In the second case: the quantum logic gate is an off-diagonal single-quantum logic gate
When the quantum logic gate is a single-quantum logic gate and the unitary matrix corresponding thereto is an off-diagonal matrix, i.e., an off-diagonal single-quantum logic gate, such as an H-gate, the unitary matrix is
Figure BDA0002350383770000122
Through the operation of the H gate, |0>Will become into
Figure BDA0002350383770000123
|1>Will become into
Figure BDA0002350383770000124
Both the amplitude and the quantum state components are changed. For the quantum logic gate, when an undirected graph is constructed, a vertex corresponding to a new quantum state and an edge corresponding to a quantum logic gate after a single quantum logic gate operation need to be added to the undirected graph.
As shown in FIG. 3c, for the non-diagonal single quantum logic gate, when constructing an undirected graph, a vertex V is added4An edge E34One end of the edge and the vertex V3Connected with one end of the vertex V4Are connected. Wherein, V3The current last vertex corresponding to the qubit operated by the off-diagonal single-quantum logic gate, namely the vertex corresponding to the quantum state directly acted by the off-diagonal quantum logic gate; v4And the new vertex corresponds to a new quantum state after the operation of the off-diagonal single-quantum logic gate.
As can be appreciated, edge E34With two vertices V3And V4Are connected so their tensors
Figure BDA0002350383770000125
Is 2-order tensor and has a total of 224 elements, the tensor corresponds to ψ in equation (1)iA function representing the contribution of the off-diagonal single quantum logic gate to a quantum state.
For example, when the edge E34When the corresponding edge of the H gate of the non-diagonal single quantum logic gate is known according to the unitary matrix, tensor
Figure BDA0002350383770000126
In the third case: the quantum logic gate is an off-diagonal double-quantum logic gate
In this case, the quantum logic gate is a dual-quantum logic gate and the corresponding unitary matrix is an off-diagonal matrix, for example, for an off-diagonal dual-quantum logic gate CNOT, the unitary matrix is:
Figure BDA0002350383770000131
then, through the operation of the CNOT gate, when the quantum state of the control bit is |0>, the quantum state of the controlled bit is not changed, that is, when the quantum states of the control bit and the controlled bit are |00> and |01>, the quantum states are still |00> and |01> respectively after the operation of the CNOT gate; when the quantum state of the control bit is |1>, the quantum state of the controlled bit is not operated, i.e., |0> is changed to |1> and |1> is changed to |0>, i.e., the quantum states of the control bit and the controlled bit are |10> and |11>, respectively changed to |11> and |10> after being operated by the CNOT gate. Since two qubits are usually in the superposition state of |00>, |01>, |10> and |11>, after operation of the CNOT gate, it can be seen that both the amplitude and the quantum state components of the two qubits involved will change. For such quantum logic gates, when an undirected graph is constructed, for each qubit, a vertex corresponding to a new quantum state of the undirected graph after the operation of the dual-quantum logic gate, that is, two new vertices, is added to the undirected graph, and a corresponding edge of the dual-quantum logic gate is added to the undirected graph.
As shown in fig. 3d, for an off-diagonal dual quantum logic gate,when constructing an undirected graph, an edge E needs to be added5678For the sake of clarity, two edges are shown here, but it should be noted that the two edges in fig. 3d are actually the same edge E5678. Newly added edge end and vertex V5、V7Connected with one end of the vertex V6、V8Are connected. Wherein, V5And V6Respectively for the current last vertex, V, corresponding to the two qubits of the off-diagonal dual-quantum logic gate operation7And V8Respectively corresponding to the new quantum state of the two quantum bits after the operation of the off-diagonal double-quantum logic gate. In particular, when the non-diagonal double-quantum logic gate is a control logic gate, V5、V7Corresponding to the control bit, V6、V8Corresponding to the controlled bits.
It will be understood by those skilled in the art that any multi-qubit gate can be constructed with a single-quantum logic gate plus any double-quantum logic gate, which in most cases is a multi-select CNOT gate. In a sense, the CNOT gate and the single quantum logic gate are prototypes of all other gates. The method provided by the present application is also applicable to quantum wires (or quantum programs) with multi-qubit logic gates.
Therefore, in conjunction with the above analysis, a specific implementation of step S200 can be obtained as follows:
s210, analyzing the quantum circuit to be simulated to obtain a linked list for recording the information of the quantum circuit to be simulated;
s220, traversing the linked list, sequentially reading the types and unitary matrix forms of the quantum logic gates in the linked list, and adding corresponding vertexes and edges, wherein:
when the type of the quantum logic gate in the linked list is a first single quantum gate, creating an edge with a tensor order of 1; wherein the edge is connected with the last vertex of the vertex chain corresponding to the quantum bit operated by the first single quantum gate, and the unitary matrix of the first single quantum gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second single quantum gate, creating an edge with the tensor order of 2 and a vertex connected with the edge; the edge is connected with the last vertex of the corresponding vertex chain of the quantum bit operated by the second single quantum gate, and the unitary matrix of the second single quantum gate is a non-diagonal matrix;
when the type of the quantum logic gate in the linked list is a first double quantum gate, an edge with the tensor order of 2 is created; wherein the edge is connected with the last vertex in the vertex chain respectively corresponding to the two qubits operated by the first dual-quantum gate, and the unitary matrix of the first dual-quantum gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second double quantum gate, an edge with the tensor order of 4 and two vertexes connected with the edge are created; the edge is connected with the last vertex in the vertex chain respectively corresponding to the two qubits operated by the second double-quantum gate, and the unitary matrix of the second double-quantum gate is a non-diagonal matrix;
s230, completing traversal, and completing adding vertices and edges, i.e., constructing an undirected graph of the quantum line to be simulated to obtain an undirected graph corresponding to the quantum line to be simulated, where the undirected graph to be calculated corresponding to the quantum line to be simulated (1# quantum line) provided in this embodiment is as shown in fig. 4.
The undirected graph shown in fig. 4 describes vertex chain information of each quantum bit in the 1# quantum line, and the vertex chain information includes values of vertices from the first vertex to the last vertex, information of edges connected to the vertices, vertex identifiers, and tensor information of the edges.
For the 1# quantum wire in this embodiment, the vertex of its undirected graph is labeled V1To V13The information of the edge connected to each vertex and the tensor information of the edge are as follows:
TABLE 11 # Quantum line corresponding to the tensor order of the edge connected urgently by the edges connected by each vertex in the undirected graph to be computed
Figure BDA0002350383770000141
Note: the tensor order of the connected edges is arranged in the table.
S300, determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements.
As a specific implementation manner of the embodiment of the present invention, S300 includes the following steps:
s310, determining memory resources used for single-amplitude quantum simulation calculation in a single process according to the parameter information of the process;
s320, determining a memory required by each element of the tensor according to the data type of the tensor element;
and S330, determining the total amount of tensor elements which can be stored by the process according to the memory resources and the memory required by each element.
Wherein: if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM (M is a unit of 'mega') and the data type representing the tensor element is the Float type, the total amount of the tensor elements which can be stored by the process is M × 1024 × 1024/8; if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM (M is a unit of "mega") and the data type representing the tensor element is a Double type, the total amount of tensor elements which can be stored in the process is M × 1024 × 1024/16, wherein M is any positive number.
The parameter information of the process in this step refers to parameters that determine memory resources used by the process for single-amplitude quantum simulation calculation, such as a memory of the process, a set memory proportion used for single-amplitude quantum simulation calculation, and the like.
S400, determining the splitting times of the undirected graph to be calculated according to the total quantity of tensor elements which can be stored in the process.
The method comprises the steps of simulating quantum computation, namely realizing matrix multiplication, updating an undirected graph to be computed after performing fusion operation on edges in the undirected graph when the undirected graph to be computed simulates quantum computation, wherein the upper limit which can be reached by tensor elements corresponding to the undirected graph to be computed cannot exceed the total amount of the tensor elements determined in the previous step, and therefore the splitting times of the undirected graph to be computed can be determined.
As a specific embodiment, step S400 includes:
s430, acquiring information of edges connected with each vertex in the undirected graph to be calculated according to a preset sequence;
s440, executing fusion operation on the edges connected with the current vertex according to the information of the edges connected with the current vertex;
it should be noted here that, in order to facilitate quick determination of data to be calculated, vertices corresponding to a tensor are generally arranged in a certain order, and binary numbers of combined values of the vertex sequence correspond to position numbers of elements in the tensor one by one.
S450, after the edges connected with the current vertex execute the fusion operation, updating the undirected graph to be calculated;
s460, judging whether the sum of the number of tensor elements corresponding to all edges in the undirected graph to be calculated is larger than the total number of the elements of the tensor which can be stored by the process;
if the number of the elements of the tensor which can be stored by the process is not larger than the total number of the elements of the tensor which can be stored by the process, executing value determination reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing the step of executing the fusion operation on the edges connected with the current vertex;
if the total quantity of the elements of the tensor which can be stored by the process is larger than the total quantity of the elements of the tensor which can be stored by the process, returning the undirected graph to be calculated which is updated last time, executing deletion operation on each vertex before the current vertex and information of edges connected with each vertex before the current vertex, executing definite value reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing fusion operation on the edges connected with the current vertex;
s470, determining the splitting times of the undirected graph to be calculated according to the execution times of the deleting operation.
The following describes how a vertex is fused and reduced in order for all its connected edges.
In an implementation manner, a step of performing a fusion operation on all edges connected to the vertex to obtain a target edge, specifically, two edges of all edges connected to the vertex may be fused to obtain at least one fused edge, and then, under the condition that the number of new edges obtained by fusion is not less than 2, two-to-two fusion operation on the new edges is continued until a fused edge, that is, the target edge, is finally obtained.
In another implementation manner, the step of performing a fusion operation on all edges connected to the vertex to obtain a target edge may specifically be to first perform fusion on any two edges of all edges connected to the vertex to obtain a new edge, then select one edge from the remaining unfused edges to be fused with the new edge, and repeat the above steps until all connected edges of the vertex are fused into one edge.
Of course, in practical applications, the above two implementation manners may be combined or other manners may be adopted to implement the edge fusion, which is not limited herein.
Specifically, the step of the fusion operation in this embodiment includes:
s431, determining a first edge and a second edge to be fused;
s433, according to a vertex which is not connected with the first edge in the second vertex group of the second edge, performing a step-up operation on the first tensor of the first edge, and updating the first tensor by the stepped-up tensor;
s433, determining a corresponding element of each element in the first tensor in the second tensor of the second edge according to a corresponding relationship between the first vertex group and the second vertex group corresponding to the first tensor;
s434, traversing each element in the first tensor, and updating the element by the product of the element and its corresponding element in the second tensor;
s435, deleting the second edge, and connecting other vertexes of the second edge except the current vertex to the first edge.
For exampleFor an undirected graph, S is the current vertex and the connecting edge thereof12、S16、S25、S3、S4The fusion operation comprises the following steps:
for vertex 1, S12、S16Fuse into a new edge S126For its tensor A126Reduced to A26The corresponding edge becomes S26 Delete vertex 1;
for vertex 2, the current connecting edge S25、S26Fuse into a new edge S256For its tensor A256Reduced to A56Corresponding side S56Delete vertex 2;
for vertex 3, only edge S is connected3For its tensor A3The order is reduced to A ═ x3(scalar quantity) for changing the corresponding edge to the edge s with tensor order 03Delete vertex 3;
for vertex 4, only edge S is connected4For its tensor A4Reduced to A' ═ x4(scalar quantity) for changing the corresponding edge to the edge s with tensor order 04Delete vertex 4;
for vertex 5, currently only edge S is connected56The tensor A is unchanged after fusion56Reduced to A6Corresponding side S6Delete vertex 5;
for vertex 6, currently only edge S is connected6For its tensor A6The order is reduced to A ″ ═ x6(scalar quantity) for changing the corresponding edge to the edge s with tensor order 06Vertex 6 is deleted.
With reference to the undirected graph to be computed corresponding to the 1# quantum line in this embodiment, an exemplary description is given to how to determine the splitting times of the undirected graph to be computed according to the total amount of tensor elements that can be stored by the process:
the preset vertex sequence in the undirected graph to be calculated corresponding to the 1# quantum wire is assumed to be V1、V2、…、V13The edge in the undirected graph to be calculated is S12、S2367、S34、S56(10)(11)、S78(12)(13)、S9(10)、S(11)(12)(wherein, eachThe tensor order corresponding to the edge is R12、R2367、R34、R56(10)(11)、R78(12)(13)、R9(10)、R(11)(12)) In this embodiment, it is assumed that the number of elements of the determined tensor that can be stored by the process is 64 (this number is only required for the exemplary explanation in this embodiment, and is determined according to the foregoing step S300 in the actual application), so:
for vertex 1, the current connecting edge S12New edge S after fusion operation12Corresponding tensor is A12(number of tensor elements is 22) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000171
A12reduced to A2(the number of corresponding tensor elements is 212), the corresponding edge becomes S2 Delete vertex 1;
for vertex 2, the current connecting edge S2367、S2New edge S after fusion operation2367Corresponding tensor is A2367(number of tensor elements is 24) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000181
A2367reduced to A367(number of tensor elements is 238), corresponding to the edge S367Delete vertex 2;
for vertex 3, the current connecting edge S367、S34New edge S after fusion operation3467Corresponding tensor is A3467(number of tensor elements is 24) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000182
A3467reduced to A467(number of tensor elements is 238), the corresponding edge becomes S467Delete vertex 3;
for vertex 4, currently only edge S is connected467New edge S after fusion operation467Corresponding tensor is A467(number of tensor elements is 23) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000183
A467reduced to A67(the number of tensor elements is 22) The corresponding edge becomes S67Delete vertex 4;
for vertex 5, the current connecting edge S56(10)(11)New edge S after fusion operation56(10)(11)Corresponding tensor is A56(10)(11)(number of tensor elements is 24) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000184
A56(10)(11)reduced to A6(10)(11)(the number of tensor elements is 23) The corresponding edge becomes S6(10)(11)Delete vertex 5;
for vertex 6, the current connecting edge S6(10)(11)、S67New edge S after fusion operation67(10)(11)Corresponding to tensor A67(10)(11)(number of tensor elements is 2416), updating the undirected graph to be calculated, wherein the sum of the tensor element numbers corresponding to all edges is as follows:
Figure BDA0002350383770000185
A67(10)(11)reduced to A7(10)(11)(the number of tensor elements is 23) Corresponding side S7(10)(11)Vertex 6 is deleted;
for vertex 7, the current connecting edge S78(12)(13)、S7(10)(11)New edge S after fusion operation78(10)(11)(12)(13)Corresponding to tensor A78(10)(11)(12)(13)(number of tensor elements is 26) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000186
A78(10)(11)(12)(13)reduced to A8(10)(11)(12)(13)(number of tensor elements is 25) The corresponding edge becomes S8(10)(11)(12)(13)Vertex 7 is deleted.
Since 72 is greater than 64, returning to the undirected graph to be computed updated after the edge fusion operation for vertex 6 connection, a deletion operation is performed for information of vertex 6 and the edge connected to vertex 6 (note: this deletion operation is different from the operation of deleting vertex after reduction in the foregoing step), and deterministic value reduction is performed for the edge connected to vertex 7, vertex 7 currently connecting edge S78(12)(13)、S7(10)(11)After determining the value reduction, respectively is S8(12)(13)、 S(10)(11)At this time, the sum of the tensor element numbers corresponding to all edges is:
Figure BDA0002350383770000191
for vertex 8, the current connecting edge S8(12)(13)New edge S after fusion operation8(12)(13)Corresponding to tensor A8(12)(13)(number of tensor elements is 22) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000192
A8(12)(13)reduced to A(12)(13)(number of tensor elements is 22) The corresponding edge becomes S(12)(13)Vertex 8 is deleted;
for vertex 9, the current connecting edge S9(10)New edge S after fusion operation9(10)Corresponding to tensor A9(10)(number of tensor elements is 2)2) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000193
A9(10)reduced to A(10)The corresponding edge becomes S(10)Delete vertex 9;
for vertex 10, the current connecting edge S(10)(11)、S(10)New edge S after fusion operation(10)(11)Corresponding to tensor A(10)(11)(number of tensor elements is 22) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000194
A(10)(11)reduced to A(11)The corresponding edge becomes S(11)Delete vertex 10;
for vertex 11, the current connecting edge S(11)、S(11)(12)New edge S after fusion operation(11)(12)Corresponding to tensor A(11)(12)(number of tensor elements is 22) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000195
A(11)(12)reduced to A(12)Correspond toEdge is changed into S(12)Delete vertex 11;
for vertex 12, the current connecting edge S(12)、S(12)(13)New edge S after fusion operation(12)(13)Corresponding to tensor A(12)(13)(number of tensor elements is 22) And updating the undirected graph to be calculated, wherein the sum of the tensor element quantities corresponding to all edges is as follows:
Figure BDA0002350383770000196
A(12)(13)reduced to A(13)Corresponding side S(13)Delete vertex 12;
for vertex 13, the current connecting edge S(13)New edge S after fusion operation(13)Corresponding to tensor A(13)(the number of tensor elements is 2), updating the undirected graph to be calculated, wherein the sum of the number of the tensor elements corresponding to all edges is as follows:
Figure BDA0002350383770000201
A(13)the order is reduced to A ″ ═ x13(scalar quantity) corresponding to the side S whose order of the side tensor is 0(13)Vertex 13 is deleted.
Based on the above process, the splitting frequency of the undirected graph to be computed can be determined according to the execution frequency of the deletion operation, that is, the splitting frequency of the undirected graph to be computed corresponding to the quantum line example to be simulated provided by this embodiment is 1.
As a preferred implementation manner, the determining, according to the maximum order, the number of times of performing the fusion operation on the edge in the undirected graph to be computed in S400 further includes, before step S430, the following steps:
s410, determining a first vertex and a last vertex of the undirected graph to be calculated according to the undirected graph to be calculated.
In particular, according to the undirected graph to be calculated and the initial state of the quantum bit involved in the quantum wire to be simulated during each single-amplitude simulation calculationAnd target quantum state component, determining the first vertex and the last vertex of the undirected graph to be calculated, wherein the first vertex in the undirected graph of the quantum line to be simulated is V in the embodiment1、 V5、V9Last vertex V4、V8、V13
And S420, respectively executing determined value reduction operation on the edge corresponding to the first vertex and the edge corresponding to the last vertex.
It should be noted that, the determined value reduction of the vertices and edges is substantially determined value reduction of the relevant tensor, and in the embodiment of the present application, the determined value reduction is performed according to the initial state of the qubit involved in the analog quantum circuit and the target quantum state component.
Specifically, the determined value of the tensor is reduced, that is, the corresponding element is determined in the original tensor according to the determined subscript value, and then the element of the tensor is updated to the determined corresponding element.
For example, the 4 th order tensor A1234With the index 2 being determined to be 0, then from A1234Find the element with subscript 2 having a value of 0: the first (0000)2、(0001)2、(0010)2、(0011)2、(1000)2、(1001)2、 (1010)2、(1011)2Bit elements, these numbering minus the second digit in the subscript being (000)2、(001)2、(010)2、 (011)2、(100)2、(101)2、(110)2、(111)2They form a new 3 rd order tensor A134This operation is a deterministic value reduction.
The reduction of the edges in the undirected graph in the present application is essentially the reduction of the tensors of the opposite edges, and is not described in detail in the present application.
In this embodiment, the edge corresponding to the first vertex in the undirected graph of the quantum wire to be simulated is S12、S56(10)(11)、S9(10)Assume that the initial state of the involved qubit is |000>I.e. vertex V1、V5、V9Are all |0>To, forS12、S56(10)(11)、S9(10)Respectively executing definite value reducing operation, the new edge after reducing is S2、S6(10)(11)、 S(10)
The edge corresponding to the last vertex is S34、S78(12)(13)The target quantum state component is |101>I.e. V4、V8、V13Respectively correspond to |1>、|0>、|1>To S34、S78(12)(13)Respectively executing definite value reducing operation, the new edge after reducing is S3、S7(12)
Performing deterministic value reduction operation on the edge corresponding to the first vertex and the edge corresponding to the last vertex respectively, wherein the tensor order of the edge connected with each vertex in the undirected graph of the quantum line to be simulated in table 1 changes, which is specifically shown in table 2:
TABLE 2 tensor order of edges connected urgently to each vertex in the undirected graph to be computed after performing deterministic value reduction
Figure BDA0002350383770000211
Note: the tensor order of the connected edges is arranged in the table.
In the present embodiment, the undirected graph to be computed can be optimized through S410 to S420, and then the resource condition that is needed the lowest when the optimized undirected graph is used for performing the simulated quantum computation is determined through S430 to S470, and the fusion process refers to the above exemplary description.
And S500, determining resources required by single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.
Specifically, if the splitting frequency of the undirected graph to be calculated is N, the resource required by the computation of the single-amplitude analog quantum is 2NTherefore, the resource required for performing single-amplitude analog quantum computation by using the quantum wire example to be simulated provided in this embodiment is 2 processes.
In this embodiment, a quantum line to be simulated and a configured process are acquired, an undirected graph corresponding to the quantum line to be simulated is constructed, the total amount of tensor elements which can be stored by the process is determined according to parameter information of the process and data types of the tensor elements, the splitting times of the undirected graph to be calculated is determined according to the total amount of the tensor elements, and finally, resources required by calculation of a single-amplitude simulated quantum are determined according to the splitting times of the undirected graph to be calculated, so that the resources required by calculation of the single-amplitude simulated quantum can be estimated in advance during single-amplitude simulation.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a system for predicting resources required for single-amplitude analog quantum computation according to an embodiment of the present invention, which corresponds to the flow shown in fig. 2, and this embodiment further provides a system for predicting resources required for single-amplitude analog quantum computation, including:
an obtaining module 601, configured to obtain a quantum line to be simulated and a configured process;
a constructing module 602, configured to construct a corresponding undirected graph according to the quantum line to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
a tensor element determining module 603, configured to determine, according to the parameter information of the process and the data type of the tensor element, a total amount of tensor elements that can be stored in the process;
a splitting frequency determining module 604, configured to determine, according to the total amount of the tensor elements, a splitting frequency of the undirected graph to be calculated;
and the calculation resource determining module 605 is configured to determine resources required by single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.
An embodiment of the present invention further provides a storage medium, where a computer program is stored in the storage medium, where the computer program is configured to execute the steps in any of the above method embodiments when the computer program runs.
Specifically, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s100, acquiring a quantum line to be simulated and a configuration process;
s200, constructing a corresponding undirected graph according to the quantum wires to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
s300, determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements;
s400, determining the splitting times of the undirected graph to be calculated according to the total amount of the tensor elements;
and S500, determining resources required by single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.
An embodiment of the present invention further provides an electronic apparatus, which includes a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the above method embodiments.
Specifically, 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.
Specifically, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s100, acquiring a quantum line to be simulated and a configuration process;
s200, constructing a corresponding undirected graph according to the quantum wires to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
s300, determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements;
s400, determining the splitting times of the undirected graph to be calculated according to the total amount of the tensor elements;
and S500, determining resources required by single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.

Claims (10)

1. A method for predicting resources required by single-amplitude analog quantum computation is characterized by comprising the following steps:
acquiring a quantum line to be simulated and a configuration process;
constructing a corresponding undirected graph to be calculated according to the quantum line to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
determining the total amount of tensor elements which can be stored by the process according to the parameter information of the process and the data type of the tensor elements;
determining the splitting times of the undirected graph to be calculated according to the total amount of the tensor elements;
and determining resources required by the computation of the single-amplitude analog quantum according to the splitting times of the undirected graph to be computed.
2. The method of claim 1, wherein constructing a corresponding undirected graph to be computed according to the quantum wires to be simulated comprises:
analyzing the quantum circuit to be simulated to obtain a linked list for recording the information of the quantum circuit to be simulated;
traversing the linked list, and creating an edge with a tensor order of 1 when the type of the quantum logic gate in the linked list is a first single quantum logic gate; the edge is connected with the last vertex of the corresponding vertex chain of the quantum bit operated by the first single-quantum logic gate, and the unitary matrix of the first single-quantum logic gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second single quantum logic gate, creating an edge with the tensor order of 2 and a vertex connected with the edge; the edge is connected with the last vertex of the corresponding vertex chain of the quantum bit operated by the second single-quantum logic gate, and the unitary matrix of the second single-quantum logic gate is a non-diagonal matrix;
when the type of the quantum logic gate in the linked list is a first double quantum logic gate, creating an edge with the tensor order of 2; the edge is connected with the last vertex in the vertex chain respectively corresponding to the two quantum bits operated by the first double-quantum logic gate, and the unitary matrix of the first double-quantum logic gate is a diagonal matrix;
when the type of the quantum logic gate in the linked list is a second double-quantum logic gate, creating an edge with the tensor order of 4 and two vertexes connected with the edge; the edge is connected with the last vertex in the vertex chain respectively corresponding to the two quantum bits operated by the second double-quantum logic gate, and the unitary matrix of the second double-quantum logic gate is a non-diagonal matrix;
and obtaining the undirected graph to be calculated corresponding to the quantum line to be simulated.
3. The method for estimating resources required for single-amplitude simulated quantum computation according to claim 1, wherein the determining the total amount of tensor elements that the process can store according to the parameter information of the process and the data type of the tensor elements comprises:
determining memory resources used for single-amplitude quantum simulation calculation in a single process according to the parameter information of the process;
determining the memory required by each element of the tensor according to the data type expressing the tensor element;
and determining the total amount of tensor elements which can be stored by the process according to the memory resources and the memory required by each element.
4. The method of claim 3, wherein the method comprises:
if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM and the data type representing the tensor element is the Float type, the total amount of the tensor elements which can be stored by the process is m multiplied by 1024 multiplied by 1024/8;
if the memory resource used for single-amplitude quantum simulation calculation in a single process is mM, and the data type representing the tensor elements is a Double type, the total amount of the tensor elements which can be stored in the process is m × 1024 × 1024/16, wherein m is any positive number.
5. The method for estimating resources required by single-amplitude simulated quantum computation according to claim 1, wherein the determining the number of splits of the undirected graph to be computed according to the total number of tensor elements that can be stored by the process comprises:
according to a preset sequence, obtaining information of edges connected with each vertex in the undirected graph to be calculated;
executing fusion operation on the edges connected with the current vertex according to the information of the edges connected with the current vertex;
after the edges connected with the current vertex execute the fusion operation, updating the undirected graph to be calculated;
judging whether the sum of the number of tensor elements corresponding to all edges in the undirected graph to be calculated is greater than the total number of tensor elements which can be stored by the process;
if the number of the elements of the tensor which can be stored by the process is not larger than the total number of the elements of the tensor which can be stored by the process, executing value determination reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing the step of executing the fusion operation on the edges connected with the current vertex;
if the total quantity of the elements of the tensor which can be stored by the process is larger than the total quantity of the elements of the tensor which can be stored by the process, returning the undirected graph to be calculated which is updated last time, executing deletion operation on each vertex before the current vertex and information of edges connected with each vertex before the current vertex, executing definite value reduction on the edges connected with the current vertex, taking the next vertex as the current vertex, returning and executing the information of the edges connected according to the current vertex, and executing fusion operation on the edges connected with the current vertex;
and determining the splitting times of the undirected graph to be calculated according to the execution times of the deleting operation.
6. The method of estimating resources required for single-amplitude simulated quantum computation according to claim 5, wherein the determining the number of splits of the undirected graph to be computed according to the total number of tensor elements that can be stored in the process further comprises:
before the information of the edges connected with the vertexes in the undirected graph to be calculated is obtained according to the preset sequence, determining a first vertex and a last vertex of the undirected graph to be calculated according to the undirected graph to be calculated;
and respectively executing determined value reduction operation on the edge connected with the first vertex and the edge connected with the last vertex.
7. The method of estimating resources required for single-amplitude analog quantum computing as claimed in claim 5, wherein the step of fusing comprises:
determining a first edge and a second edge to be fused;
according to a vertex which is not connected with the first edge in a second vertex group of the second edge, performing step-up operation on a first tensor of the first edge, and updating the first tensor by the raised tensor;
determining a corresponding element of each element in the first tensor in a second tensor of the second edge according to a corresponding relation between a first vertex group corresponding to the first tensor and the second vertex group;
traversing each element in the first tensor to update the element by the product of the element and its corresponding element in the second tensor;
deleting the second edge and connecting other vertices of the second edge except the current vertex to the first edge.
8. A system for predicting resources required for single-amplitude analog quantum computing, comprising:
the acquisition module is used for acquiring the quantum line to be simulated and the configured process;
the construction module is used for constructing a corresponding undirected graph to be calculated according to the quantum line to be simulated; wherein, the vertex of the undirected graph represents the quantum state of the operated quantum bit before or after the operation of the quantum logic gate, and the edge of the undirected graph represents tensor;
a tensor element determining module, configured to determine, according to the parameter information of the process and the data type of the tensor elements, a total amount of tensor elements that can be stored in the process;
the splitting frequency determining module is used for determining the splitting frequency of the undirected graph to be calculated according to the total amount of the tensor elements;
and the calculation resource determining module is used for determining resources required by the single-amplitude analog quantum calculation according to the splitting times of the undirected graph to be calculated.
9. A storage medium, in which a computer program is stored, wherein the computer program is arranged to perform the method of any of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 7.
CN201911412718.0A 2019-12-31 2019-12-31 Method and system for predicting resources required by single-amplitude analog quantum computation Active CN113128015B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911412718.0A CN113128015B (en) 2019-12-31 2019-12-31 Method and system for predicting resources required by single-amplitude analog quantum computation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911412718.0A CN113128015B (en) 2019-12-31 2019-12-31 Method and system for predicting resources required by single-amplitude analog quantum computation

Publications (2)

Publication Number Publication Date
CN113128015A true CN113128015A (en) 2021-07-16
CN113128015B CN113128015B (en) 2023-04-07

Family

ID=76770625

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911412718.0A Active CN113128015B (en) 2019-12-31 2019-12-31 Method and system for predicting resources required by single-amplitude analog quantum computation

Country Status (1)

Country Link
CN (1) CN113128015B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114254755A (en) * 2021-12-24 2022-03-29 中国科学院理论物理研究所 Method and device for simulating quantum bit tail state probability amplitude and quantum virtual machine
CN116341667A (en) * 2023-04-03 2023-06-27 正则量子(北京)技术有限公司 Quantum circuit building method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101909022A (en) * 2010-06-24 2010-12-08 北京邮电大学 Transmission method based on non-codebook based precoding in time-varying channel
CN107683460A (en) * 2015-05-05 2018-02-09 凯恩迪股份有限公司 The QUANTON that analog quantity increment calculates in conventional processors is represented
WO2018172629A1 (en) * 2017-03-24 2018-09-27 Bull Sas Method for simulating, on a conventional computer, a quantum circuit
CN108647790A (en) * 2018-05-16 2018-10-12 合肥本源量子计算科技有限责任公司 Interface system and method for unified quantum computer and quantum virtual machine
WO2019058161A1 (en) * 2017-09-22 2019-03-28 International Business Machines Corporation Simulating quantum circuits
WO2019078907A1 (en) * 2017-10-18 2019-04-25 Google Llc Simulation of quantum circuits
CN110188885A (en) * 2019-06-28 2019-08-30 合肥本源量子计算科技有限责任公司 A kind of quantum calculation analogy method, device, storage medium and electronic device
CN110428055A (en) * 2018-04-27 2019-11-08 阿里巴巴集团控股有限公司 Quantum computing method and equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101909022A (en) * 2010-06-24 2010-12-08 北京邮电大学 Transmission method based on non-codebook based precoding in time-varying channel
CN107683460A (en) * 2015-05-05 2018-02-09 凯恩迪股份有限公司 The QUANTON that analog quantity increment calculates in conventional processors is represented
WO2018172629A1 (en) * 2017-03-24 2018-09-27 Bull Sas Method for simulating, on a conventional computer, a quantum circuit
WO2019058161A1 (en) * 2017-09-22 2019-03-28 International Business Machines Corporation Simulating quantum circuits
WO2019078907A1 (en) * 2017-10-18 2019-04-25 Google Llc Simulation of quantum circuits
CN110428055A (en) * 2018-04-27 2019-11-08 阿里巴巴集团控股有限公司 Quantum computing method and equipment
CN108647790A (en) * 2018-05-16 2018-10-12 合肥本源量子计算科技有限责任公司 Interface system and method for unified quantum computer and quantum virtual machine
CN110188885A (en) * 2019-06-28 2019-08-30 合肥本源量子计算科技有限责任公司 A kind of quantum calculation analogy method, device, storage medium and electronic device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
XUEZHONG GUAN ET AL.: "Sunspot number time series prediction using neural networks with quantum gate nodes", 《IEEE XPLORE》 *
李志强 等: "基于新型量子逻辑门库的最优NCV三量子电路快速综合算法", 《万方数据库》 *
王建伟: "振幅相干态的量子统计性质", 《大学物理》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114254755A (en) * 2021-12-24 2022-03-29 中国科学院理论物理研究所 Method and device for simulating quantum bit tail state probability amplitude and quantum virtual machine
CN114254755B (en) * 2021-12-24 2022-12-02 中国科学院理论物理研究所 Method and device for simulating quantum bit tail state probability amplitude and quantum virtual machine
CN116341667A (en) * 2023-04-03 2023-06-27 正则量子(北京)技术有限公司 Quantum circuit building method and device
CN116341667B (en) * 2023-04-03 2024-03-12 正则量子(北京)技术有限公司 Quantum circuit building method and device

Also Published As

Publication number Publication date
CN113128015B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN110825375B (en) Quantum program conversion method and device, storage medium and electronic device
WO2020151129A1 (en) Quantum machine learning framework construction method and apparatus, and quantum computer and computer storage medium
CN110516810B (en) Quantum program processing method and device, storage medium and electronic device
CN110826719B (en) Quantum program processing method and device, storage medium and electronic device
CN111027702B (en) Method and device for realizing quantum circuit replacement, storage medium and electronic device
CN111915011B (en) Single-amplitude quantum computing simulation method
CN110929873A (en) Quantum program processing method and device, storage medium and electronic device
CN111027703B (en) Quantum circuit query method and device, storage medium and electronic device
CN110889507A (en) Method and device for transferring quantum program into directed acyclic graph, storage medium and electronic device
CN111914378A (en) Single-amplitude quantum computation simulation method
CN113128015B (en) Method and system for predicting resources required by single-amplitude analog quantum computation
CN113222155B (en) Quantum circuit construction method and device, electronic device and storage medium
CN111931939B (en) Single-amplitude quantum computing simulation method
CN111178532B (en) Quantum circuit matching method and device, storage medium and electronic device
CN115146485B (en) Radio frequency link simulation method based on GPU acceleration
CN114819163B (en) Training method and device for quantum generation countermeasure network, medium and electronic device
CN116011681A (en) Meteorological data prediction method and device, storage medium and electronic device
CN115775029A (en) Quantum line conversion method, device, medium, and electronic device
WO2004068342A1 (en) Software development preprocessing method, software control method, software development method, and software development device
CN115983392A (en) Method, device, medium and electronic device for determining quantum program mapping relation
CN114692880B (en) Quantum state amplitude simulation method and device in quantum circuit
CN117151231A (en) Method, device and medium for solving linear system by using variable component sub-line
Akl et al. Introduction to parallel computation
CN115114569A (en) Nonlinear partial differential equation solving method and device based on quantum line
CN114372583A (en) Quantum program optimization method based on machine learning framework and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant