Quantum circuit simulation method, device and electronic equipment

By representing the quantum circuit as an atypical tensor network and determining whether matrix shaping and axis shifting operations are performed based on the tensor index information, the problem of low simulation efficiency of quantum circuits is solved, and more efficient quantum circuit simulation is achieved.

CN117556909BActive Publication Date: 2025-04-22BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311519178.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-15
Publication Date
2025-04-22
Estimated Expiration
2043-11-15

AI Technical Summary

Technical Problem

The efficiency of quantum circuit simulation is low, mainly due to frequent matrix shaping and axis shifting operations during tensor shrinkage, resulting in low computational efficiency.

Method used

By representing the quantum circuit as an atypical tensor network and determining whether the matrix representation of the tensor shrinkage object needs to be performed based on the tensor index information, unnecessary target operations are reduced, thereby improving the efficiency of quantum circuit simulation.

Benefits of technology

By reducing matrix shaping operations and axis shift operations, the efficiency of quantum circuit simulation is significantly improved, and the behavior of quantum systems can be simulated and studied more quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117556909B_ABST
    Figure CN117556909B_ABST
Patent Text Reader

Abstract

The present disclosure provides a quantum circuit simulation method, device and electronic device, which relates to the field of quantum computing technology, and specifically to the field of quantum circuit technology. The specific implementation scheme is: obtaining the structural information of the quantum circuit; based on the structural information, determining the target network used to express the quantum circuit structure, the target network includes the objects for tensor contraction during the quantum circuit simulation process, the objects include the initial quantum state and quantum gates of the quantum circuit, and the representation information of each object includes tensor index information; based on the tensor index information, judging the tensor contraction processing method of the objects obtained from the target network, and obtaining a judgment result, the judgment result is used to indicate whether the matrix representation of the two objects of tensor contraction performs the target operation during the tensor contraction process, and the target operation includes the matrix shaping operation and the axis shifting operation; tensor contraction is performed on the objects obtained from the target network according to the processing method indicated by the judgment result, and the simulation result of the quantum circuit is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of quantum computing technology, in particular to the field of quantum circuit technology, and specifically to a quantum circuit simulation method, device and electronic equipment. Background Art

[0002] Technological breakthroughs in the field of quantum computing have attracted widespread attention in the scientific and industrial communities, and its broad application scenarios have brought new opportunities for industrial development. Among them, quantum circuit simulation is one of the key technologies, which aims to simulate and study the behavior of quantum systems, and provides key tools and methods for measuring the performance of quantum computers, verifying the effectiveness of quantum algorithms, and exploring potential quantum algorithm applications.

[0003] Tensor networks play an important role in simulating large-scale quantum circuit tasks because they can efficiently express the complex structure of quantum circuits. Tensor networks allow complex quantum states and quantum gates to be represented as tensors, and the evolution of quantum circuits can be gradually simulated by merging tensors between tensor nodes. Summary of the invention

[0004] The present disclosure provides a quantum circuit simulation method, device and electronic device.

[0005] According to a first aspect of the present disclosure, a quantum circuit simulation method is provided, comprising:

[0006] Obtaining structural information of quantum circuits;

[0007] Based on the structural information, determining a target network for expressing the quantum circuit structure, the target network including objects for tensor contraction during the quantum circuit simulation process, the objects including an initial quantum state and a quantum gate of the quantum circuit, the representation information of each object including tensor index information, and when the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate;

[0008] Based on the tensor index information, a tensor contraction processing method of the object obtained from the target network is judged to obtain a judgment result, wherein the judgment result is used to indicate whether a target operation is performed in the tensor contraction process on the matrix representation of the two objects of the tensor contraction, wherein the target operation includes a matrix shaping operation and an axis shifting operation;

[0009] The objects obtained from the target network are tensor-contracted according to the processing method indicated by the judgment result to obtain a simulation result of the quantum circuit, and the simulation result is used to determine a task result of the quantum computing task performed by the quantum circuit.

[0010] According to a second aspect of the present disclosure, there is provided a quantum circuit simulation device, comprising:

[0011] A first acquisition module, used to acquire structural information of the quantum circuit;

[0012] A first determination module is used to determine a target network for expressing the structure of the quantum circuit based on the structure information, wherein the target network includes objects for tensor contraction during the quantum circuit simulation process, the objects include an initial quantum state and a quantum gate of the quantum circuit, and the representation information of each object includes tensor index information. When the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate;

[0013] A judgment module, used to judge the tensor shrinkage processing mode of the object obtained from the target network based on the tensor index information, and obtain a judgment result, wherein the judgment result is used to indicate whether the matrix representation of the two objects to be shrunk by the tensor performs a target operation during the tensor shrinkage process, and the target operation includes a matrix shaping operation and an axis shift operation;

[0014] A tensor contraction module is used to perform tensor contraction on the objects obtained from the target network according to the processing method indicated by the judgment result to obtain a simulation result of the quantum circuit, and the simulation result is used to determine the task result of the quantum computing task performed by the quantum circuit.

[0015] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0016] at least one processor; and

[0017] a memory communicatively connected to at least one processor; wherein,

[0018] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any method in the first aspect.

[0019] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute any one of the methods in the first aspect.

[0020] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which implements any one of the methods in the first aspect when executed by a processor.

[0021] The technology disclosed in the present invention solves the problem of low efficiency of quantum circuit simulation in the related art.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0024] Figure 1 is a flowchart of a quantum circuit simulation method according to the first embodiment of the present disclosure;

[0025] Figure 2 This is a complete flowchart of an example quantum circuit simulation method;

[0026] Figure 3 is a schematic structural diagram of a quantum circuit simulation device according to a second embodiment of the present disclosure;

[0027] Figure 4 is a schematic block diagram of an example electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0029] First embodiment

[0030] like Figure 1 As shown, the present disclosure provides a quantum circuit simulation method, comprising the following steps:

[0031] Step S101: Acquire the structural information of the quantum circuit.

[0032] In this embodiment, the quantum circuit simulation method relates to the field of quantum computing technology, and in particular to the field of quantum circuit technology. It can be widely used in quantum circuit simulation scenarios and has potential impacts on practical applications of quantum computing, such as information security, material science, pharmaceuticals, and artificial intelligence. The quantum circuit simulation method of the disclosed embodiment can be performed by the quantum circuit simulation device of the disclosed embodiment. The quantum circuit simulation device of the disclosed embodiment can be configured in any electronic device to perform the quantum circuit simulation method of the disclosed embodiment.

[0033] In the related art, as a key operation in quantum circuit simulation, the efficiency of tensor contraction processing directly affects the efficiency of quantum circuit simulation. The following explains tensor contraction.

[0034] Consider a quantum system of n qubits. The quantum state of this quantum system is an nth-order tensor, and assume that the dimension of each order of the tensor is 2.

[0035] The essence of any quantum state tensor or quantum gate tensor is a linear combination of a series of left vectors, right vectors, or tensors of both. For example, an nth-order quantum state tensor and an (m, m)-order quantum gate tensor can be expressed as equations (1) and (2) below respectively.

[0036]

[0037]

[0038] Among them, |x> represents the right vector on the qubit with index x. Similarly, <y| represents the left vector on the qubit with index y.

[0039] It can be represented by to represent the index vector of the quantum state tensor |ψ>. is the index of the right vector of the quantum state tensor |ψ>. represents the index vector of the quantum gate tensor U. (i0, i1, …, i m-1 ) is the index of the right vector of the quantum gate tensor U. (j0, j 1, …, j m-1 ) is the index of the left vector of the quantum gate tensor U.

[0040] Then, the above tensor contraction calculation of the quantum state and the quantum gate is converted to solving the following equation (3).

[0041]

[0042] And the set of acting qubits for the tensor contraction of the quantum state and the quantum gate is S = {p0, …, p n-1} ∩ {j0, …, j m-1}. Vectorize the set of acting qubits S to obtain the acting qubit index vector Here q is the number of elements in S. Then, the tensor contraction calculation of the quantum state and the quantum gate is converted to solving the following equation (4).

[0043]

[0044] Here is the index vector of the quantum gate tensor U in which except for the acting qubit index vector The remaining indicators is the index vector of the quantum state tensor |ψ> Divide the bit index vector The remaining indicators.

[0045] A new tensor representation can be obtained by exchanging indices, an operation called axis shifting. For example, given an index vector (i0, j0, i1, …, i m-1 ,j 1, …,j m-1 ), we can get a new tensor representation of U, as shown in equation (5).

[0046]

[0047] The matrix representation of a quantum state or a quantum gate can be obtained by matrix shaping operations based on the tensor representation of the quantum state or the quantum gate, and the tensor representation of a quantum state or a quantum gate can be obtained by matrix shaping operations based on the matrix representation of the quantum state or the quantum gate. For example, the index order of the left part of the given matrix (hereinafter referred to as the left index of the matrix representation) is The order of the indices on the right side of the matrix (hereinafter referred to as the right indices represented by the matrix) is Then the matrix of U is expressed as follows, which is a 2 2 ×2 2m-2 The dimension matrix is ​​as shown in formula (6).

[0048]

[0049] Here, the symbol ";" is used to distinguish the left part and the right part of the matrix.

[0050] The tensor shrinking and merging process can be based on the matrix product isomorphism of the tensor network, and the process is as follows:

[0051] Represent quantum initial states and quantum gates as tensors;

[0052] Perform axis shift transformation on the quantum state tensor so that the quantum gate action bit moves to the front end of the quantum circuit;

[0053] The quantum state after axis shifting is reshaped into a matrix representation, and the contraction and merging process between the quantum state tensor and the quantum gate tensor is converted into a matrix multiplication calculation. Matrix calculations are very well optimized on classical computers, so the tensor contraction and merging calculation can be accelerated.

[0054] The matrix obtained by tensor shrinkage and calculation is reshaped to restore the tensor representation, and updated to the new quantum state;

[0055] In this way, the above process is repeated to process each quantum gate tensor in the tensor network and obtain the quantum final state.

[0056] However, in the tensor network isomorphism scheme, each tensor contraction process requires matrix reshaping and axis shifting operations, and the time consumption of these operations cannot be ignored. That is, there are a large number of matrix reshaping and axis shifting operations in the quantum circuit simulation process, which affects the efficiency of quantum circuit simulation.

[0057] The main purpose of this embodiment is to represent the objects in the target network in matrix form and retain their tensor index information, and to judge whether to perform matrix shaping and axis shifting operations during the tensor shrinking process based on the matrix representation of the two objects of tensor shrinking of the tensor index information of the objects, i.e., nodes, in the target network, so as to reduce unnecessary matrix shaping and axis shifting operations, thereby improving the simulation efficiency of the quantum circuit.

[0058] The structural information may be a circuit diagram of a quantum circuit or a list of operation instructions of the quantum circuit, which is not specifically limited here. The structural information may indicate that the quantum circuit includes n quantum bits and N quantum gates, and the arrangement order of the quantum bits of the n quantum bits and the N quantum gates, where n and N are both positive integers.

[0059] The structural information of the quantum circuit generated by the device or input by the user can be obtained, and the structural information of the quantum circuit sent by other devices can also be received, which is not specifically limited here.

[0060] Step S102: Based on the structural information, determine a target network for expressing the quantum circuit structure, the target network includes objects that are tensor-contracted during the quantum circuit simulation process, the objects include the initial quantum state and quantum gates of the quantum circuit, the representation information of each object includes tensor index information, and when the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate.

[0061] Based on the structural information of the quantum circuit, the number of quantum bits and the indication information of the quantum gate of the quantum circuit can be obtained. The indication information of the quantum gate can include the type of quantum gate (such as the quantum gate is a CNOT gate) and structure, etc. Based on the number of quantum bits of the quantum circuit and the indication information of the quantum gate, a node can be constructed for each quantum gate of the quantum circuit to create a target network. Among them, each object in the target network is a node, which represents the initial quantum state or quantum gate of the quantum circuit. The simulation of the quantum circuit can be realized by sequentially performing tensor contraction on the objects in the target network.

[0062] The target network can be called an atypical tensor network, that is, in the target network, when the object is a quantum gate, the object is represented in matrix form, that is, the representation information of the object includes the matrix representation of the quantum gate and tensor index information.

[0063] In an optional implementation, in the target network, when the object is the initial quantum state of the quantum circuit, the representation information of the object may include the matrix representation and tensor index information of the initial quantum state. In this way, when the initial quantum state does not need to be subjected to an axis shift operation, tensor contraction and merging processing may be performed directly based on the matrix representation of the initial quantum state, thereby reducing some unnecessary operations.

[0064] In another optional implementation, in the target network, when the object is the initial quantum state of the quantum circuit, the representation information of the object may include the tensor representation and tensor index information of the initial quantum state. This conforms to the conventional representation of the initial quantum state and facilitates the axis shift operation of the initial quantum state.

[0065] In other words, the quantum circuit can be represented as an atypical tensor network. Specifically, based on the structural information of the quantum circuit, the number of quantum bits n can be obtained, and the initial quantum state of the quantum circuit can be represented as an n-order tensor |ψ>, where the representation information of the initial quantum state also includes the tensor index information of the initial quantum state.

[0066] A role m k The quantum gate U k Represented as a dimensional matrix, whose representation information can also include tensor index information.

[0067] Among them, the tensor index information of each object in the target network can include a left index and a right index. For the initial quantum state, its tensor index information can include an empty left index and a right indicator For a quantum gate, its tensor index information can include a left index Q L and a right index Q R .

[0068] It should be noted that from the perspective of tensors, the tensor index information of a quantum gate is composed of the index of the left vector and the index of the right vector; while the tensor index information of a quantum state only has the index of the right vector, not the index of the left vector. From the perspective of matrices, the tensor index information is divided into the index of the left part of the matrix (which can be referred to as the left index) and the index of the right part of the matrix (which can be referred to as the right index).

[0069] In this embodiment, the tensor index information of the object is distinguished from the perspectives of matrix and tensor. In the initial stage, the tensor index information of the object may include a left index and a right index. In the process of tensor contraction, due to the axis shift operation, the obtained left index of the object may contain the index corresponding to the left vector and the index corresponding to the right vector; similarly, the right index may also contain the index corresponding to the left vector and the index corresponding to the right vector at the same time.

[0070] Among them, the index is related to the corresponding quantum bit. For example, in the initial stage of the simulation of the quantum circuit, that is, the object in the target network has not undergone any tensor contraction, the index corresponding to the right vector of the quantum state of a three-qubit (such as qubits 1, 2, and 3) is (1, 2, 3), the right index is also (1, 2, 3), and the left index is empty. A two-qubit quantum gate acts on qubits 1 and 3. Then in the initial stage of the simulation, the index corresponding to its right vector and the right index are both (1, 3), and the index corresponding to the left vector and the left index are also (1, 3).

[0071] In fact, in order to distinguish the index of the right vector from the index of the left vector in the matrix representation, different symbols can be used to distinguish the left vector index and the right vector index in the left index or the right index in the specific implementation process. In this embodiment, the symbol can be used to represent, such as the index corresponding to the left vector The index corresponding to the right vector

[0072] For example, the CNOT gate acting on quantum bit 0 and quantum bit 1 is represented as a triple, which is the matrix representation of the quantum gate, the left index and the right index. The triple is (U CNOT ,(l0,l1),(r0,r1)). Among them, the matrix represents The left index is (l0,l1) and the right index is (r0,r1).

[0073] In the target network, quantum gates are not represented as tensors, but as matrices. The above representation can be called an atypical tensor network representation. However, in the target network, the tensor index information is not discarded, but is also used as part of the quantum gate representation, so it does not affect subsequent processes such as tensor contraction and calculation. In addition, the matrix shaping operation and axis shifting operation in the subsequent tensor contraction process can be reduced, thereby improving the simulation efficiency of quantum circuits.

[0074] Step S103: Based on the tensor index information, a tensor shrinkage processing method of the object obtained from the target network is judged to obtain a judgment result, wherein the judgment result is used to indicate whether the matrix representation of the two objects of the tensor shrinkage is subjected to a target operation during the tensor shrinkage process, wherein the target operation includes a matrix shaping operation and an axis shifting operation.

[0075] In this step, objects can be obtained from the target network in sequence according to a preset order or a predetermined order for tensor merging. Before each tensor merging process, the tensor merging processing method of the two objects to be merged can be judged based on the tensor index information to obtain a judgment result.

[0076] Among them, the two objects of tensor shrinkage can be two objects obtained from the target network. For example, when tensor shrinkage is performed for the first time, two objects need to be obtained from the target network for tensor shrinkage processing. The two objects of tensor shrinkage can also be an updated object obtained from the previous tensor shrinkage and an object obtained from the target network.

[0077] Before each tensor contraction, the tensor contraction processing method of the two objects can be judged based on the tensor index information of the two objects to be contracted, so as to judge whether the matrix representations of the two objects perform the target operation during the tensor contraction process. The target operation includes a matrix shaping operation and an axis shifting operation, and the two operations of the matrix shaping operation and the axis shifting operation are related. In the tensor contraction calculation, if the matrix representation of the object needs to be subjected to an axis shifting operation, the tensor representation after the axis shifting operation must be subjected to a matrix shaping operation to perform a matrix product operation and complete the tensor contraction process.

[0078] The criterion for determining whether the target operation is not required is: determining whether the index corresponding to the left vector in the tensor index information of the first object whose tensor is shrunk and sorted first is the same as the index corresponding to the right vector in the tensor index information of the second object whose tensor is sorted later.

[0079] The purpose of the axis shift operation is to make the right index of the first object and the left index of the second object the same, so that the two objects can perform matrix product operations. The tensor contraction processing method of the two objects can be determined by obtaining the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object in the tensor index information of the two objects to be contracted, and judging whether they are equal. If they are equal, the target operation does not need to be performed. If they are not equal, the target operation needs to be performed.

[0080] For example, the tensor contraction of quantum gate U and quantum gate V is U*V. The index corresponding to the left vector of quantum gate U is (1, 3, 4), and the index corresponding to the right vector of quantum gate V is (2, 3, 1). The index is equal to (1, 3). Then the matrix representations of quantum gate U and quantum gate V both need to perform target operations. For another example, the index corresponding to the left vector of quantum gate U is (1, 3, 4), and the index corresponding to the right vector of quantum gate V is (3, 1). The index is the same as (3, 1). Then the matrix representation of quantum gate U needs to perform target operations, while the matrix representation of quantum gate V does not need to perform target operations.

[0081] There are three situations for the judgment results. The first is that the matrix representations of the two objects of tensor merging need to perform target operations during the tensor merging process. The second is that the matrix representation of one of the two objects of tensor merging needs to perform target operations during the tensor merging process. The third is that the matrix representations of the two objects of tensor merging do not require target operations during the tensor merging process.

[0082] Step S104: performing tensor contraction and merging on the objects obtained from the target network according to the processing method indicated by the judgment result to obtain a simulation result of the quantum circuit, wherein the simulation result is used to determine a task result of the quantum computing task performed by the quantum circuit.

[0083] Accordingly, objects can be obtained from the target network in sequence according to a preset order or a predetermined order, and the tensor merging processing method of the two objects can be judged based on the tensor index information of the two objects to be tensor merging, and a judgment result can be obtained. The two objects can be tensor merging according to the processing method indicated by the judgment result to obtain a simulation result of the quantum circuit.

[0084] When the tensor shrinking and processing mode of the object indicates that a target operation needs to be performed, if the representation information of the object is stored in a matrix form, a matrix reshaping operation can be performed, that is, the matrix representation is reshaped into a tensor representation to perform an axis shift operation.

[0085] If the tensor shrinking processing method of the object indicates that the target operation is not required, the matrix shaping operation and the axis shifting operation can be omitted during the tensor shrinking process, and the tensor shrinking can be performed directly based on the matrix representation of the object. This can reduce unnecessary operations and thus improve the simulation efficiency of the quantum circuit.

[0086] The two objects can be subjected to tensor shrinkage processing according to the above formula (4). The tensor shrinkage processing is essentially the matrix product processing of the two objects. When the tensor shrinkage processing method of the two objects indicates that no target operation is required, the matrix representations of the two objects can be directly subjected to product processing. When the tensor shrinkage processing method of the objects indicates that a target operation is required, the objects can be first reshaped into tensor representations, the tensor representations of the objects can be subjected to axis shifting operations, and then the product processing can be performed based on the matrix representations after the axis shifting operations.

[0087] Accordingly, when the simulation result of the quantum circuit is obtained, a quantum state measurement can be performed based on the simulation result to determine the task result of the quantum computing task performed by the first quantum circuit. The quantum computing task can be a task in the field of quantum computing, such as quantum communication, quantum computing protocol, quantum key distribution protocol, etc.

[0088] In this embodiment, by representing the quantum circuit as an atypical tensor network, and based on the tensor index information of the objects in the atypical tensor network, the tensor contraction processing method of the objects obtained from the atypical tensor network is judged to obtain a judgment result, and the judgment result is used to indicate whether the matrix representation of the two objects of the tensor contraction performs matrix shaping and axis shifting operations during the tensor contraction process; then the objects obtained from the target network are tensor contracted according to the processing method indicated by the judgment result to obtain the simulation result of the quantum circuit. In this way, by representing the objects in the target network as matrices and retaining their tensor index information, the matrix representation of the two objects of the tensor contraction performs matrix shaping and axis shifting operations during the tensor contraction process based on the tensor index information of the objects, i.e., nodes in the target network, to reduce unnecessary matrix shaping and axis shifting operations, thereby improving the simulation efficiency of the quantum circuit.

[0089] Optionally, before step S103, the method further includes:

[0090] Based on the target network, determining an order for performing tensor contraction and merging of objects in the target network;

[0091] Obtain objects from the target network in sequence according to the sequence to obtain two objects for each tensor contraction.

[0092] Before tensor contraction, a preprocessing operation can be performed to confirm the order of contraction of the tensor network. For example, the order of contraction of the tensor network can be determined by heuristic algorithms, dynamic programming, etc. In this way, the order of contraction of tensors in the quantum circuit simulation process can be optimized, further improving the simulation efficiency of the quantum circuit.

[0093] Optionally, the step S103 specifically includes:

[0094] Based on the tensor index information, determining the active bit of tensor contraction of the object obtained from the target network;

[0095] Based on the tensor index information and the effect bit of tensor contraction, a tensor contraction processing method is judged to obtain a judgment result.

[0096] In this implementation, the effective bits of the tensor merging of the two objects can be obtained based on the tensor index information of the two objects to be tensor merging, and this can be used as a basis for judging whether to use matrix shaping operations and axis shift operations. That is, based on the effective bits, the tensor merging processing method of the two objects can be judged to obtain a judgment result.

[0097] Afterwards, the vector index represented by the object tensor in the tensor index information can be compared with the action bit to determine the tensor contraction processing method and obtain a determination result.

[0098] In this way, the effect bit of tensor contraction can be used as a basis for determining whether to use matrix reshaping operations and axis shifting operations, thereby simplifying the process of determining the tensor contraction processing method and the tensor contraction process.

[0099] Optionally, the tensor index information includes an index corresponding to a left vector and an index corresponding to a right vector in a tensor representation of the object, the two objects of tensor contraction include, from left to right, a first object and a second object, at least one of the first object and the second object is obtained from the target network, and determining, based on the tensor index information, an active bit of tensor contraction of the object obtained from the target network includes:

[0100] Acquire an index corresponding to a left vector of the first object and an index corresponding to a right vector of the second object from the tensor index information;

[0101] An intersection of an index corresponding to the left vector of the first object and an index corresponding to the right vector of the second object is determined as an active bit of tensor contraction.

[0102] In one embodiment, the first object and the second object are both obtained from the target network. In another embodiment, the second object is obtained from the target network, and the first object is an updated object obtained by the previous tensor contraction.

[0103] You can first find the index corresponding to the left vector of the first object The index corresponding to the right vector of the second object calculate and Intersection of sets of elements Will Vectorization, that is, the bitwise contraction of the first object and the second object tensor

[0104] In this way, the effective bits of tensor contraction can be determined.

[0105] Optionally, judging the tensor contraction processing method based on the tensor index information and the action bit of the tensor contraction to obtain a judgment result includes:

[0106] For each object of tensor contraction, obtaining target index information of the object from the tensor index information;

[0107] Comparing the target indicator information with the action bit of the tensor contraction to obtain a comparison result;

[0108] Based on the comparison result, a processing method of the object during the tensor contraction process is judged to obtain a first judgment result; the judgment result includes the first judgment result, and the first judgment result is used to indicate whether the matrix representation of the object performs a target operation during the tensor contraction process.

[0109] For each object in tensor contraction, the action bit can be bitten with the vector index represented by the object tensor in the tensor index information. When the action bit is equal to the vector index, it can be determined that the matrix representation of the object does not need to perform the target operation during the tensor contraction process. Otherwise, it is determined that the matrix representation of the object needs to perform the target operation during the tensor contraction process.

[0110] During the comparison process, the order of arrangement of the object in the tensor contraction can be used to determine whether to select the index of the left vector or the index of the right vector for comparison with the active bit. For example, in the tensor contraction U*V, for the first object U, the index corresponding to its left vector is compared with the active bit, and for the second object V, the index corresponding to its right vector is compared with the active bit. Based on the comparison result, it can be determined whether the matrix representation of the object needs to perform matrix shaping and axis shifting operations during the tensor contraction process to obtain a judgment result.

[0111] Correspondingly, the judgment result may include the first judgment result of each object of the tensor contraction. In this way, the judgment of the processing method of the object in the tensor contraction process can be realized.

[0112] The two objects of tensor contraction include a first object and a second object from left to right. Optionally, for each object of tensor contraction, obtaining target index information of the object from the tensor index information includes:

[0113] In a case where the object is the first object, acquiring an index corresponding to a left vector of the first object from the tensor index information;

[0114] In a case where the object is the second object, an index corresponding to the right vector of the second object is obtained from the tensor index information.

[0115] That is, if an object is sorted first in the tensor contraction process, the action bit can be compared with the index of the left vector represented by the tensor of the object; if an object is sorted last in the tensor contraction process, the action bit can be compared with the index of the right vector represented by the tensor of the object.

[0116] In this way, the target indicator information to be compared with the action bit can be obtained.

[0117] Optionally, judging, based on the comparison result, a processing method of the object in the tensor contraction process to obtain a first judgment result includes:

[0118] When the comparison result indicates that the target index information is equal to the effect bit of tensor contraction, determining that the first judgment result indicates that the matrix representation of the object does not perform a target operation during tensor contraction;

[0119] When the comparison result indicates that the target indicator information and the effect bit of tensor contraction are not equal, it is determined that the first judgment result indicates that the matrix representation of the object performs a target operation during tensor contraction.

[0120] In one embodiment, if the object is a quantum state, the index corresponding to the right vector in the tensor index information of the quantum state can be compared with the action bit. If the two are not equal, it is determined that the matrix representation of the quantum state requires a target operation during the tensor contraction process. If the two are equal, it is determined that the matrix representation of the quantum state does not require a target operation during the tensor contraction process.

[0121] In another embodiment, if the object is a quantum gate, and the quantum gate is the first object, the index corresponding to the left vector in the tensor index information of the quantum gate can be compared with the action bit. If the two are not equal, it is determined that the matrix representation of the quantum gate needs to perform a target operation during the tensor contraction process. If the two are equal, it is determined that the matrix representation of the quantum gate does not need to perform a target operation during the tensor contraction process.

[0122] If the object is a quantum gate, and the quantum gate is the second object, the index corresponding to the right vector in the tensor index information of the quantum gate can be compared with the action bit. If the two are not equal, it is determined that the matrix representation of the quantum gate needs to perform a target operation during the tensor contraction process. If the two are equal, it is determined that the matrix representation of the quantum gate does not need to perform a target operation during the tensor contraction process.

[0123] In this way, the first judgment result of whether the matrix representation of the object needs to perform the target operation can be determined based on the comparison result of the target indicator information and the action bit of the tensor contraction.

[0124] Optionally, judging a tensor shrinking and merging processing method of an object obtained from the target network based on the tensor index information to obtain a judgment result includes:

[0125] Determine, based on the object type obtained from the target network, a contraction type of a first tensor contraction, wherein the contraction type of the tensor contraction includes a first contraction type and a second contraction type, wherein the first contraction type indicates a tensor contraction between a quantum state and a quantum gate, and the second contraction type indicates a tensor contraction between a quantum gate and a quantum gate, and the first tensor contraction is any tensor contraction in the quantum circuit simulation process;

[0126] When the contraction type of the first tensor contraction is the first contraction type, based on the tensor index information, respectively judging the processing methods of the quantum state and the quantum gate in the first tensor contraction process to obtain a judgment result;

[0127] When the contraction type of the first tensor contraction is the second contraction type, based on the tensor index information, processing methods of two quantum gates in the first tensor contraction process are judged respectively to obtain a judgment result.

[0128] In the related art, quantum circuit simulation schemes based on tensor network isomorphism do not consider the contraction and merging processing between quantum gate tensor nodes. In this embodiment, not only the tensor contraction and merging calculation between quantum states and quantum gates is considered, but also the tensor contraction and merging calculation between quantum gates is considered, thereby improving the efficiency of tensor contraction and merging processing, and further improving the efficiency of quantum circuit simulation.

[0129] When the object obtained from the target network is a quantum state, the contraction type of the first tensor contraction is determined to be the first contraction type. When the object obtained from the target network is a quantum gate, the contraction type of the first tensor contraction can be determined in combination with another object of the tensor contraction. If the other object is a quantum gate, the contraction type of the first tensor contraction is determined to be the second contraction type.

[0130] When the contraction type of the tensor contraction is obtained, the processing methods of the two objects in the first tensor contraction process can be judged respectively to obtain a judgment result.

[0131] When the contraction type of the first tensor contraction is the first contraction type, the processing methods of the quantum state and the quantum gate in the first tensor contraction process are judged respectively, wherein the judgments of the tensor contraction processing methods of the quantum state and the quantum gate are different. When the contraction type of the first tensor contraction is the second contraction type, the processing methods of the two quantum gates in the first tensor contraction process are judged respectively.

[0132] In this way, the tensor contraction processing method can be extended to the case of tensor contraction between quantum gates. It can be applied to the entire process of quantum circuit simulation, including the calculation between quantum states and quantum gates and the calculation between quantum gates. It is universal.

[0133] For example, the initial quantum state of the quantum circuit is ψ, where the quantum gates are Z, X, and CX respectively. The final quantum state of the quantum circuit is the calculation result of CX*X*Z*ψ. Based on the tensor network of the quantum circuit, the calculation results can be obtained according to different tensor contraction orders. If the quantum gate Z and quantum gate X are obtained from the target network, the tensor contraction of quantum gate Z and quantum gate X is performed, the contraction type of the first tensor contraction is determined to be the second contraction type, and the result of (X*Z) is calculated; if the initial quantum state ψ is obtained from the target network, the tensor contraction between the quantum state and the result of the first tensor contraction (X*Z) is performed, the contraction type of the second tensor contraction is determined to be the first contraction type, and the result of ((X*Z)*ψ) is calculated. Finally, the tensor contraction between the quantum gate CX and the result of the second tensor contraction is performed to obtain the simulation result of the quantum circuit.

[0134] In the case where the target network is an atypical tensor network, optionally, performing tensor contraction on the objects obtained from the target network according to the processing method indicated by the judgment result to obtain the simulation result of the quantum circuit includes:

[0135] When the judgment result indicates that the matrix representations of the two objects of the tensor contraction do not perform the target operation in the current tensor contraction process, matrix product processing is performed on the matrix representations of the two objects to obtain representation information of the first updated object;

[0136] The object of the next tensor contraction includes the first update object, and the representation information of the first update object includes the matrix representation and tensor index information of the first update object.

[0137] That is, when neither object needs to perform the target operation, the matrix representations of the two objects can be directly multiplied to obtain the representation information of the first updated object.

[0138] Among them, the two objects of tensor contraction include the first object and the second object from left to right, and in the tensor index information of the first updated object, the left index represented by the matrix includes all the indexes of the first object except the effective bit of tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the effective bit of tensor contraction.

[0139] In this way, the quantum shrinking and merging process can be optimized, and the efficiency of quantum shrinking and merging can be improved by reducing unnecessary matrix shaping operations and axis shifting operations in the quantum shrinking and merging process, thereby improving the efficiency of quantum circuit simulation. In addition, by introducing matrix representation, the triple of left index and right index is used to represent the objects in the quantum circuit evolution process, so that the structure and evolution process of the quantum circuit can be described in a more fine-grained way.

[0140] Optionally, performing tensor contraction on the object obtained from the target network according to a processing method indicated by the judgment result to obtain a simulation result of the quantum circuit includes:

[0141] When the judgment result indicates that at least one of the matrix representations of the two objects of the tensor contraction is subjected to a target operation in the current tensor contraction process, shaping the first matrix representation of the target object to obtain the tensor representation of the target object;

[0142] Taking the active bits of the current tensor contraction as the target index order, performing an axis shift operation on the tensor representation of the target object to obtain representation information of the target object, wherein the representation information of the target object includes a second matrix representation and tensor index information of the target object;

[0143] Based on the representation information of the target object, performing matrix product processing on the two objects to obtain representation information of a second updated object;

[0144] Among them, the target object is the object that needs to perform the target operation in the current tensor contraction process, the object of the next tensor contraction includes the second update object, and the representation information of the second update object includes the matrix representation and tensor index information of the second update object.

[0145] That is, when at least one of the two objects needs to perform a target operation, the first matrix representation of the target object can be reshaped into a tensor representation, and then the tensor representation of the target object is shifted with the active bits of the current tensor contraction as the target index order to obtain the representation information of the target object. The representation information of the target object includes the second matrix representation and tensor index information of the target object.

[0146] Optionally, the two objects of the tensor contraction include a first object and a second object in sequence;

[0147] When the target object is the first object, in the tensor index information of the target object, the left index represented by the second matrix includes other indexes of all indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction, and the right index represented by the second matrix includes the active bit of the current tensor contraction;

[0148] When the target object is the second object, in the tensor index information of the target object, the left index represented by the second matrix includes the active bit of the current tensor contraction, and the right index represented by the second matrix includes other indexes of all the indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction.

[0149] In this way, the axis shift operation can make the right index of the first object equal to the left index of the second object, both of which are the active bits of the current tensor contraction, so that the tensor contraction can be converted into a matrix product operation, simplifying the tensor contraction process.

[0150] On the basis of performing an axis shift operation on the tensor representation of the target object, the matrix representations of the two objects can be multiplied based on the representation information of the target object obtained by the axis shift operation, thereby realizing the evolution of the quantum gates in the quantum circuit and obtaining the representation information of the second updated object.

[0151] Among them, the two objects of tensor contraction include a first object and a second object from left to right, and in the tensor index information of the second updated object, the left index represented by the matrix includes all the indexes of the first object except the active bit of the tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the active bit of the tensor contraction.

[0152] The update object obtained by tensor contraction can be a quantum state or a quantum gate. For example, the initial quantum state of the quantum circuit is ψ, where the quantum gates are Z, X, and CX respectively, then the quantum final state of the quantum circuit is the calculation result of CX*X*Z*ψ. Based on the tensor network of the quantum circuit, the calculation results can be obtained according to different tensor contraction orders. If the quantum gate Z and the quantum gate X are obtained from the target network, that is, the tensor contraction of the quantum gate Z and the quantum gate X is performed, the contraction type of the first tensor contraction is determined to be the second contraction type, and the result of (X*Z) is calculated. The update object obtained by the first tensor contraction is the quantum gate; if the initial quantum state ψ is obtained from the target network, the tensor contraction between the quantum state and the result of the first tensor contraction (X*Z) is performed, the contraction type of the second tensor contraction is determined to be the first contraction type, and the result of ((X*Z)*ψ) is calculated. The update object obtained by the second tensor contraction is the quantum state. Finally, tensor contraction is performed between the quantum gate CX and the result of the second tensor contraction to obtain the simulation result of the quantum circuit.

[0153] In this way, the quantum shrinking and merging process can be optimized, and the efficiency of quantum shrinking and merging can be improved by reducing unnecessary matrix shaping operations and axis shifting operations in the quantum shrinking and merging process, thereby improving the efficiency of quantum circuit simulation. In addition, by introducing matrix representation, the triple of left index and right index is used to represent the objects in the quantum circuit evolution process, so that the structure and evolution process of the quantum circuit can be described in a more fine-grained way.

[0154] Optionally, the two objects of tensor contraction include a first object and a second object from left to right; in the tensor index information of the updated object obtained by the current tensor contraction, the left index represented by the matrix includes all the indexes of the first object except the effective bit of the tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the effective bit of the tensor contraction.

[0155] The update object can be the first update object or the second update object. By introducing matrix representation, the triple of left index and right index is used to represent the object in the quantum circuit evolution process, so that the structure and evolution process of the quantum circuit can be described in a more fine-grained manner.

[0156] Optionally, the step S104 further includes:

[0157] When the object tensor contraction and merging obtained from the target network have been processed, reshaping the matrix representation of the quantum state obtained by the tensor contraction and merging into a tensor representation;

[0158] The simulation result is obtained by performing an axis shift operation on the tensor representation of the quantum state obtained by tensor contraction using the quantum bit index order of the initial quantum state of the quantum circuit as the target index order.

[0159] After completing all tensor contraction calculations, matrix shaping and axis shifting operations can be performed on the quantum state to ensure that the quantum final state meets expectations and obtain the simulation results of the quantum circuit.

[0160] The specific process of the quantum circuit simulation method of this embodiment is described in detail below with specific examples. Figure 2 As shown:

[0161] Step 1: Input a quantum circuit containing n quantum bits and N quantum gates;

[0162] Step 2: Represent the quantum circuit as an atypical tensor network;

[0163] Step 3: Perform preprocessing operations to confirm the order of tensor network contraction;

[0164] Step 4: If there is a next tensor contraction object in the target network, get the current tensor contraction processing object. If it is a quantum state and quantum gate tensor contraction, execute step 4.1; otherwise, execute step 5.1;

[0165] Step 4.1: Calculate the action bit of the quantum state and the quantum gate tensor contraction;

[0166] Step 4.2: Determine whether the quantum state and quantum gate require matrix shaping and axis shifting operations;

[0167] Step 4.3: If it is determined that the quantum state does not require matrix shaping and axis shifting, execute step 4.6; otherwise, execute step 4.4;

[0168] Step 4.4: Reshape the quantum state matrix representation into a tensor representation;

[0169] Step 4.5: Using the action bit as the target index order, shift the quantum state tensor and update the corresponding left index and right index; go to step 4.8;

[0170] Step 4.6: If the quantum state needs matrix reshaping and axis shifting, reshape the quantum gate matrix representation into a tensor representation;

[0171] Step 4.7: Using the action bit as the target index order, shift the quantum gate tensor and update the corresponding left index and right index;

[0172] Step 4.8: Calculate the product of the quantum gate and quantum state matrix, and update the result to the new quantum state, while updating its left index and right index;

[0173] Step 5.1: Calculate the action bits of the quantum gate and the quantum gate tensor contraction;

[0174] Step 5.2: Determine whether the two quantum gates require matrix shaping and axis shifting operations; if both quantum gates do not require matrix shaping and axis shifting, execute step 5.5; otherwise, execute step 5.3.

[0175] Step 5.3: Reshape the quantum gate matrix representation into a tensor representation;

[0176] Step 5.4: Using the action bit as the target index order, shift the quantum gate tensor and update the corresponding left index and right index;

[0177] Step 5.5: Calculate the matrix product of the quantum gate and quantum state gate, and update the result as the new quantum gate;

[0178] Step 6: Determine whether there is a next tensor contraction object; if so, go to step 4; otherwise, go to step 7;

[0179] Step 7: Reshape the quantum state matrix representation into a tensor representation;

[0180] Step 8: Using the index order of the initial quantum bits of the quantum circuit as the target index order, the quantum state tensor is shifted to obtain the tensor representation of the quantum final state.

[0181] Second embodiment

[0182] like Figure 3 As shown, the present disclosure provides a quantum circuit simulation device 300, comprising:

[0183] A first acquisition module 301 is used to acquire structural information of a quantum circuit;

[0184] A first determination module 302 is used to determine a target network for expressing the structure of the quantum circuit based on the structure information, wherein the target network includes objects for tensor contraction during the quantum circuit simulation process, the objects include an initial quantum state and a quantum gate of the quantum circuit, and the representation information of each object includes tensor index information. When the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate.

[0185] A judgment module 303 is used to judge the tensor shrinkage processing mode of the object obtained from the target network based on the tensor index information, and obtain a judgment result, wherein the judgment result is used to indicate whether the matrix representation of the two objects to be shrunk by the tensor performs a target operation during the tensor shrinkage process, and the target operation includes a matrix shaping operation and an axis shift operation;

[0186] The tensor shrinking module 304 is used to perform tensor shrinking on the objects obtained from the target network according to the processing method indicated by the judgment result to obtain the simulation result of the quantum circuit, and the simulation result is used to determine the task result of the quantum computing task performed by the quantum circuit.

[0187] Optionally, the device further comprises:

[0188] A second determination module is used to determine, based on the target network, an order in which tensor contraction is performed on each object in the target network;

[0189] The second acquisition module is used to sequentially acquire objects from the target network in the order described above, and obtain two objects for each tensor contraction.

[0190] Optionally, the judging module 303 includes:

[0191] A determination submodule, configured to determine, based on the tensor index information, an action bit for tensor contraction of an object obtained from the target network;

[0192] The judgment submodule is used to judge the tensor contraction processing method based on the tensor index information and the action bit of the tensor contraction to obtain a judgment result.

[0193] Optionally, the tensor index information includes an index corresponding to a left vector and an index corresponding to a right vector in a tensor representation of the object, and the two objects of the tensor contraction include, from left to right, a first object and a second object, at least one of the first object and the second object is obtained from the target network, and the determination submodule is specifically used to:

[0194] Acquire an index corresponding to a left vector of the first object and an index corresponding to a right vector of the second object from the tensor index information;

[0195] An intersection of an index corresponding to the left vector of the first object and an index corresponding to the right vector of the second object is determined as an active bit of tensor contraction.

[0196] Optionally, the judgment submodule includes:

[0197] An acquisition unit, configured to acquire, for each object of tensor contraction, target index information of the object from the tensor index information;

[0198] A comparison unit, used to compare the target indicator information with the action bit of the tensor contraction to obtain a comparison result;

[0199] A judgment unit is used to judge the processing method of the object in the tensor contraction process based on the comparison result to obtain a first judgment result; the judgment result includes the first judgment result, and the first judgment result is used to indicate whether the matrix representation of the object performs a target operation in the tensor contraction process.

[0200] Optionally, the acquisition unit is specifically used to:

[0201] In a case where the object is the first object, acquiring an index corresponding to a left vector of the first object from the tensor index information;

[0202] In a case where the object is the second object, an index corresponding to the right vector of the second object is obtained from the tensor index information.

[0203] Optionally, the judging unit is specifically configured to:

[0204] When the comparison result indicates that the target index information is equal to the effect bit of tensor contraction, determining that the first judgment result indicates that the matrix representation of the object does not perform a target operation during tensor contraction;

[0205] When the comparison result indicates that the target indicator information and the effect bit of tensor contraction are not equal, it is determined that the first judgment result indicates that the matrix representation of the object performs a target operation during tensor contraction.

[0206] Optionally, the judging module 304 is specifically configured to:

[0207] Determine, based on the object type obtained from the target network, a contraction type of a first tensor contraction, wherein the contraction type of the tensor contraction includes a first contraction type and a second contraction type, wherein the first contraction type indicates a tensor contraction between a quantum state and a quantum gate, and the second contraction type indicates a tensor contraction between a quantum gate and a quantum gate, and the first tensor contraction is any tensor contraction in the quantum circuit simulation process;

[0208] When the contraction type of the first tensor contraction is the first contraction type, based on the tensor index information, respectively judging the processing methods of the quantum state and the quantum gate in the first tensor contraction process to obtain a judgment result;

[0209] When the contraction type of the first tensor contraction is the second contraction type, based on the tensor index information, processing methods of two quantum gates in the first tensor contraction process are judged respectively to obtain a judgment result.

[0210] Optionally, in the target network, when the object is the initial quantum state of the quantum circuit, the representation information of the object also includes a tensor representation of the initial quantum state of the quantum circuit.

[0211] Optionally, the tensor shrinking module 304 is specifically used to:

[0212] When the judgment result indicates that the matrix representations of the two objects of the tensor contraction do not perform the target operation in the current tensor contraction process, matrix product processing is performed on the matrix representations of the two objects to obtain representation information of the first updated object;

[0213] The object of the next tensor contraction includes the first update object, and the representation information of the first update object includes the matrix representation and tensor index information of the first update object.

[0214] Optionally, the tensor shrinking module 304 is specifically used to:

[0215] When the judgment result indicates that at least one of the matrix representations of the two objects of the tensor contraction is subjected to a target operation in the current tensor contraction process, shaping the first matrix representation of the target object to obtain the tensor representation of the target object;

[0216] Taking the active bits of the current tensor contraction as the target index order, performing an axis shift operation on the tensor representation of the target object to obtain representation information of the target object, wherein the representation information of the target object includes a second matrix representation and tensor index information of the target object;

[0217] Based on the representation information of the target object, performing matrix product processing on the two objects to obtain representation information of a second updated object;

[0218] Among them, the target object is the object that needs to perform the target operation in the current tensor contraction process, the object of the next tensor contraction includes the second update object, and the representation information of the second update object includes the matrix representation and tensor index information of the second update object.

[0219] Optionally, the two objects of the tensor contraction include, from left to right, a first object and a second object;

[0220] When the target object is the first object, in the tensor index information of the target object, the left index represented by the second matrix includes other indexes of all indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction, and the right index represented by the second matrix includes the active bit of the current tensor contraction;

[0221] When the target object is the second object, in the tensor index information of the target object, the left index represented by the second matrix includes the active bit of the current tensor contraction, and the right index represented by the second matrix includes other indexes of all the indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction.

[0222] Optionally, the two objects of tensor contraction include a first object and a second object from left to right; in the tensor index information of the updated object obtained by the current tensor contraction, the left index represented by the matrix includes all the indexes of the first object except the effective bit of the tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the effective bit of the tensor contraction.

[0223] Optionally, the tensor shrinking module 304 is specifically used to:

[0224] When the object tensor contraction and merging obtained from the target network have been processed, reshaping the matrix representation of the quantum state obtained by the tensor contraction and merging into a tensor representation;

[0225] The simulation result is obtained by performing an axis shift operation on the tensor representation of the quantum state obtained by tensor contraction using the quantum bit index order of the initial quantum state of the quantum circuit as the target index order.

[0226] The quantum circuit simulation device 300 provided in the present disclosure can implement each process implemented by the quantum circuit simulation method embodiment and can achieve the same beneficial effects. To avoid repetition, it will not be described here.

[0227] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0228] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0229] Figure 4 A schematic block diagram of an example electronic device that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0230] like Figure 4 As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0231] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0232] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as the quantum circuit simulation method. For example, in some embodiments, the quantum circuit simulation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the computing unit 401, one or more steps of the quantum circuit simulation method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the quantum circuit simulation method in any other appropriate manner (e.g., by means of firmware).

[0233] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0234] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0235] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0236] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0237] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0238] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0239] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0240] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A quantum circuit simulation method, comprising: Obtaining structural information of quantum circuits; Based on the structural information, a target network for expressing the quantum circuit structure is determined, wherein the target network includes objects for tensor contraction during the quantum circuit simulation process, wherein the objects include an initial quantum state and a quantum gate of the quantum circuit, and the representation information of each object includes tensor index information. When the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate, and the tensor index information of the object includes an index corresponding to a left vector and an index corresponding to a right vector; Based on the tensor index information, a tensor contraction processing method of the object obtained from the target network is judged to obtain a judgment result, wherein the judgment result is used to indicate whether a target operation is performed in the tensor contraction process on the matrix representation of the two objects of the tensor contraction, wherein the target operation includes a matrix shaping operation and an axis shifting operation; Performing tensor contraction and merging on the object obtained from the target network according to the processing method indicated by the judgment result to obtain a simulation result of the quantum circuit, wherein the simulation result is used to determine a task result of the quantum computing task performed by the quantum circuit; Based on the tensor index information, a tensor contraction processing method of the object obtained from the target network is judged to obtain a judgment result, including: obtaining the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object in the tensor index information of the two objects to be tensor contracted, if the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object are equal, determining not to perform the target operation, if the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object are not equal, determining to perform the target operation.

2. The method according to claim 1, wherein the method of determining the tensor shrinking and merging processing method of the object obtained from the target network based on the tensor index information, before obtaining the determination result, further comprises: Based on the target network, determining an order for performing tensor contraction and merging of objects in the target network; Obtain objects from the target network in sequence according to the sequence to obtain two objects for each tensor contraction.

3. The method according to claim 1, wherein: The step of judging the tensor shrinking and merging processing method of the object obtained from the target network based on the tensor index information to obtain a judgment result includes: Based on the tensor index information, determining the active bit of tensor contraction of the object obtained from the target network; Based on the tensor index information and the effect bit of tensor contraction, a tensor contraction processing method is judged to obtain a judgment result.

4. The method according to claim 3, wherein: The tensor index information includes an index corresponding to a left vector and an index corresponding to a right vector in a tensor representation of the object, the two objects of tensor contraction include a first object and a second object from left to right, at least one of the first object and the second object is obtained from the target network, and determining the active bit of tensor contraction of the object obtained from the target network based on the tensor index information includes: Acquire an index corresponding to a left vector of the first object and an index corresponding to a right vector of the second object from the tensor index information; An intersection of an index corresponding to the left vector of the first object and an index corresponding to the right vector of the second object is determined as an active bit of tensor contraction.

5. The method according to claim 4, wherein: The method of processing tensor contraction based on the tensor index information and the effect bit of tensor contraction is judged to obtain a judgment result, including: For each object of tensor contraction, obtaining target index information of the object from the tensor index information; Comparing the target indicator information with the action bit of the tensor contraction to obtain a comparison result; Based on the comparison result, a processing method of the object during the tensor contraction process is judged to obtain a first judgment result; the judgment result includes the first judgment result, and the first judgment result is used to indicate whether the matrix representation of the object performs a target operation during the tensor contraction process.

6. The method according to claim 5, wherein: For each object of tensor contraction, obtaining target index information of the object from the tensor index information includes: In a case where the object is the first object, acquiring an index corresponding to a left vector of the first object from the tensor index information; In a case where the object is the second object, an index corresponding to the right vector of the second object is obtained from the tensor index information.

7. The method according to claim 5, wherein: The method of processing the object in the tensor contraction process is judged based on the comparison result to obtain a first judgment result, including: When the comparison result indicates that the target index information is equal to the effect bit of tensor contraction, determining that the first judgment result indicates that the matrix representation of the object does not perform a target operation during tensor contraction; In a case where the comparison result indicates that the target indicator information and the effect bit of tensor contraction are not equal, it is determined that the first judgment result indicates that the matrix representation of the object performs a target operation during tensor contraction.

8. The method according to any one of claims 1 to 7, wherein: The step of judging the tensor shrinking and merging processing method of the object obtained from the target network based on the tensor index information to obtain a judgment result includes: Determine, based on the object type obtained from the target network, a contraction type of a first tensor contraction, wherein the contraction type of the tensor contraction includes a first contraction type and a second contraction type, wherein the first contraction type indicates a tensor contraction between a quantum state and a quantum gate, and the second contraction type indicates a tensor contraction between a quantum gate and a quantum gate, and the first tensor contraction is any tensor contraction in the quantum circuit simulation process; When the contraction type of the first tensor contraction is the first contraction type, based on the tensor index information, respectively judging the processing methods of the quantum state and the quantum gate in the first tensor contraction process to obtain a judgment result; When the contraction type of the first tensor contraction is the second contraction type, based on the tensor index information, processing methods of two quantum gates in the first tensor contraction process are judged respectively to obtain a judgment result.

9. The method according to claim 1, wherein: In the target network, when the object is the initial quantum state of the quantum circuit, the representation information of the object further includes a tensor representation of the initial quantum state of the quantum circuit.

10. The method according to claim 9, wherein: The object obtained from the target network is subjected to tensor contraction according to the processing method indicated by the judgment result to obtain the simulation result of the quantum circuit, including: When the judgment result indicates that the matrix representations of the two objects of the tensor contraction do not perform the target operation in the current tensor contraction process, matrix product processing is performed on the matrix representations of the two objects to obtain representation information of the first updated object; The object of the next tensor contraction includes the first update object, and the representation information of the first update object includes the matrix representation and tensor index information of the first update object.

11. The method according to claim 9, wherein: The object obtained from the target network is subjected to tensor contraction according to the processing method indicated by the judgment result to obtain the simulation result of the quantum circuit, including: When the judgment result indicates that at least one of the matrix representations of the two objects of the tensor contraction is subjected to a target operation in the current tensor contraction process, shaping the first matrix representation of the target object to obtain the tensor representation of the target object; Taking the active bits of the current tensor contraction as the target index order, performing an axis shift operation on the tensor representation of the target object to obtain representation information of the target object, wherein the representation information of the target object includes a second matrix representation and tensor index information of the target object; Based on the representation information of the target object, performing matrix product processing on the two objects to obtain representation information of a second updated object; Among them, the target object is the object that needs to perform the target operation in the current tensor contraction process, the object of the next tensor contraction includes the second update object, and the representation information of the second update object includes the matrix representation and tensor index information of the second update object.

12. The method according to claim 11, wherein: The two objects of tensor contraction include, from left to right, a first object and a second object; When the target object is the first object, in the tensor index information of the target object, the left index represented by the second matrix includes other indexes of all indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction, and the right index represented by the second matrix includes the active bit of the current tensor contraction; When the target object is the second object, in the tensor index information of the target object, the left index represented by the second matrix includes the active bit of the current tensor contraction, and the right index represented by the second matrix includes other indexes of all the indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction.

13. The method according to claim 10 or 11, wherein: The two objects of tensor contraction include a first object and a second object from left to right; in the tensor index information of the updated object obtained by the current tensor contraction, the left index represented by the matrix includes all the indexes of the first object except the active bit of the tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the active bit of the tensor contraction.

14. The method according to claim 1, wherein: The obtaining of the simulation result of the quantum circuit comprises: When the object tensor contraction obtained from the target network has been processed, the matrix representation of the quantum state obtained by the tensor contraction is reshaped into a tensor representation; The simulation result is obtained by performing an axis shift operation on the tensor representation of the quantum state obtained by tensor contraction using the quantum bit index order of the initial quantum state of the quantum circuit as the target index order.

15. A quantum circuit simulation device, comprising: A first acquisition module, used to acquire structural information of the quantum circuit; A first determination module is used to determine a target network for expressing the structure of the quantum circuit based on the structure information, wherein the target network includes objects for tensor contraction during the quantum circuit simulation process, the objects include an initial quantum state and a quantum gate of the quantum circuit, the representation information of each object includes tensor index information, and when the object is a quantum gate, the representation information of the object also includes a matrix representation of the quantum gate, and the tensor index information of the object includes an index corresponding to a left vector and an index corresponding to a right vector; A judgment module, used to judge the tensor shrinkage processing mode of the object obtained from the target network based on the tensor index information, and obtain a judgment result, wherein the judgment result is used to indicate whether the matrix representation of the two objects to be shrunk by the tensor performs a target operation during the tensor shrinkage process, and the target operation includes a matrix shaping operation and an axis shift operation; A tensor contraction module, used to perform tensor contraction on the objects obtained from the target network according to the processing method indicated by the judgment result, so as to obtain a simulation result of the quantum circuit, wherein the simulation result is used to determine a task result of the quantum computing task performed by the quantum circuit; The judgment module is specifically used to obtain the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object in the tensor index information of the two objects of tensor contraction. If the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object are equal, it is determined not to perform the target operation; if the index corresponding to the left vector of the first object and the index corresponding to the right vector of the second object are not equal, it is determined to perform the target operation.

16. The apparatus according to claim 15, further comprising: A second determination module is used to determine, based on the target network, an order in which tensor contraction is performed on each object in the target network; The second acquisition module is used to sequentially acquire objects from the target network in the order described above, and obtain two objects for each tensor contraction.

17. The device according to claim 15, wherein: The judging module comprises: A determination submodule, configured to determine, based on the tensor index information, an action bit for tensor contraction of an object obtained from the target network; The judgment submodule is used to judge the tensor contraction processing method based on the tensor index information and the action bit of the tensor contraction to obtain a judgment result.

18. The device according to claim 17, wherein: The tensor index information includes an index corresponding to a left vector and an index corresponding to a right vector in the tensor representation of the object, the two objects of the tensor contraction include a first object and a second object from left to right, at least one of the first object and the second object is obtained from the target network, and the determination submodule is specifically used to: Acquire an index corresponding to a left vector of the first object and an index corresponding to a right vector of the second object from the tensor index information; An intersection of an index corresponding to the left vector of the first object and an index corresponding to the right vector of the second object is determined as an active bit of tensor contraction.

19. The device according to claim 18, wherein: The judgment submodule includes: An acquisition unit, configured to acquire, for each object of tensor contraction, target index information of the object from the tensor index information; A comparison unit, used to compare the target indicator information with the action bit of the tensor contraction to obtain a comparison result; A judgment unit is used to judge the processing method of the object in the tensor contraction process based on the comparison result to obtain a first judgment result; the judgment result includes the first judgment result, and the first judgment result is used to indicate whether the matrix representation of the object performs a target operation in the tensor contraction process.

20. The device according to claim 19, wherein The acquisition unit is specifically used for: In a case where the object is the first object, acquiring an index corresponding to a left vector of the first object from the tensor index information; In a case where the object is the second object, an index corresponding to the right vector of the second object is obtained from the tensor index information.

21. The device according to claim 19, wherein The judging unit is specifically used for: When the comparison result indicates that the target index information is equal to the effect bit of tensor contraction, determining that the first judgment result indicates that the matrix representation of the object does not perform a target operation during tensor contraction; In a case where the comparison result indicates that the target indicator information and the effect bit of tensor contraction are not equal, it is determined that the first judgment result indicates that the matrix representation of the object performs a target operation during tensor contraction.

22. The device according to any one of claims 15 to 21, wherein The judgment module is specifically used for: Determine, based on the object type obtained from the target network, a contraction type of a first tensor contraction, wherein the contraction type of the tensor contraction includes a first contraction type and a second contraction type, wherein the first contraction type indicates a tensor contraction between a quantum state and a quantum gate, and the second contraction type indicates a tensor contraction between a quantum gate and a quantum gate, and the first tensor contraction is any tensor contraction in the quantum circuit simulation process; When the contraction type of the first tensor contraction is the first contraction type, based on the tensor index information, respectively judging the processing methods of the quantum state and the quantum gate in the first tensor contraction process to obtain a judgment result; When the contraction type of the first tensor contraction is the second contraction type, based on the tensor index information, processing methods of two quantum gates in the first tensor contraction process are judged respectively to obtain a judgment result.

23. The device according to claim 15, wherein: In the target network, when the object is the initial quantum state of the quantum circuit, the representation information of the object further includes a tensor representation of the initial quantum state of the quantum circuit.

24. The device according to claim 23, wherein: The tensor shrinking module is specifically used for: When the judgment result indicates that the matrix representations of the two objects of the tensor contraction do not perform the target operation in the current tensor contraction process, matrix product processing is performed on the matrix representations of the two objects to obtain representation information of the first updated object; The object of the next tensor contraction includes the first update object, and the representation information of the first update object includes the matrix representation and tensor index information of the first update object.

25. The device according to claim 23, wherein: The tensor shrinking module is specifically used for: When the judgment result indicates that at least one of the matrix representations of the two objects of the tensor contraction is subjected to a target operation in the current tensor contraction process, shaping the first matrix representation of the target object to obtain the tensor representation of the target object; Taking the active bits of the current tensor contraction as the target index order, performing an axis shift operation on the tensor representation of the target object to obtain representation information of the target object, wherein the representation information of the target object includes a second matrix representation and tensor index information of the target object; Based on the representation information of the target object, performing matrix product processing on the two objects to obtain representation information of a second updated object; Among them, the target object is the object that needs to perform the target operation in the current tensor contraction process, the object of the next tensor contraction includes the second update object, and the representation information of the second update object includes the matrix representation and tensor index information of the second update object.

26. The device according to claim 25, wherein The two objects of tensor contraction include, from left to right, a first object and a second object; When the target object is the first object, in the tensor index information of the target object, the left index represented by the second matrix includes other indexes of all indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction, and the right index represented by the second matrix includes the active bit of the current tensor contraction; When the target object is the second object, in the tensor index information of the target object, the left index represented by the second matrix includes the active bit of the current tensor contraction, and the right index represented by the second matrix includes other indexes of all the indexes of the two objects of the current tensor contraction except the active bit of the tensor contraction.

27. The device according to claim 24 or 25, wherein: The two objects of tensor contraction include a first object and a second object from left to right; in the tensor index information of the updated object obtained by the current tensor contraction, the left index represented by the matrix includes all the indexes of the first object except the active bit of the tensor contraction, and the right index represented by the matrix includes all the indexes of the second object except the active bit of the tensor contraction.

28. The device according to claim 15, wherein: The tensor shrinking module is specifically used for: When the object tensor contraction obtained from the target network has been processed, the matrix representation of the quantum state obtained by the tensor contraction is reshaped into a tensor representation; The simulation result is obtained by performing an axis shift operation on the tensor representation of the quantum state obtained by tensor contraction using the quantum bit index order of the initial quantum state of the quantum circuit as the target index order.

29. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 14.

30. A non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the method according to any one of claims 1-14.

31. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Quantum circuit simulation method, device and equipment and storage medium

    CN111738448A

  • Distributed tensor network contraction scheme based on dynamic sorting segmentation

    CN115066589A