Quantum circuit simulation method and device, electronic equipment and storage medium
By constructing directed acyclic graphs and sub-quantum circuits, optimizing the scale of quantum circuits solves the problem that quantum simulators cannot satisfy universal quantum circuit simulations, and achieves efficient quantum circuit simulation and effective utilization of resources.
Patent Information
- Application Number
- CN202410706173.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-30
AI Technical Summary
Current quantum simulators cannot meet the needs of universal quantum circuit simulation, resulting in redundant calculations and waste of resources, and the simulation of global entangled systems is not accurate enough.
By obtaining the quantum gate information in the quantum circuit, generate a directed acyclic graph, construct a sub-quantum circuit, estimate resources, compare the target resource amounts of the original quantum circuit and the sub-quantum circuit, dynamically select the optimal simulation circuit, and optimize the scale of the quantum circuit to reduce redundant calculations.
It achieves efficient quantum circuit simulation, reduces the number of qubits and quantum gate operations, improves simulation flexibility and efficiency, and meets the needs of general quantum circuit simulation.
Smart Images

Figure CN118569402A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a quantum circuit simulation method, device, electronic device and storage medium. Background Art
[0002] Quantum computing is a technology that uses the principles of quantum mechanics to process information. Quantum bits (qubits) are the basic units of information in quantum computing. Quantum circuits are the basic model of quantum computing, consisting of a series of quantum gates that operate on quantum bits to achieve information processing and calculation. Quantum circuit simulation refers to simulating the operation of a quantum computer on a classical computer.
[0003] Due to the development limitations of quantum hardware, research on quantum algorithms mainly relies on quantum simulators, which use classical computers to simulate the output results of quantum circuits. Current quantum simulators include state vector simulators and simulators based on tensor networks. State vector simulators can simulate all quantum state amplitudes, while tensor network simulators are used to simulate partial amplitudes.
[0004] However, current state vector simulators need to simulate the entire quantum circuit to simulate various quantum algorithms, which actually performs redundant computing steps and leads to redundant computing and waste of computing resources. Tensor network simulators are only applicable to locally entangled quantum systems and are not accurate enough for globally entangled systems. In other words, current quantum simulators cannot meet the quantum computing requirements of general quantum circuit simulation, further affecting the effectiveness of quantum circuit simulation. Summary of the invention
[0005] In view of this, the present invention aims to propose a quantum circuit simulation method, device, electronic device and storage medium to solve the problem that current quantum simulators cannot meet the quantum computing requirements of general quantum circuit simulation, affecting the effectiveness of quantum circuit simulation, and realize effective quantum circuit simulation.
[0006] According to a first aspect of the present invention, a quantum circuit simulation method is provided, the method comprising:
[0007] Acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information;
[0008] Using the directed acyclic graph and the pre-acquired operator to be measured, generating a sub-quantum circuit of the operator to be measured;
[0009] Performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit;
[0010] Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit;
[0011] The target quantum circuit is used to perform quantum circuit simulation.
[0012] Optionally, the obtaining of quantum gate information in the original quantum circuit and generating a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information includes:
[0013] Obtaining quantum gate information in the original quantum circuit; wherein the quantum gate information includes the quantum gate and the quantum bit corresponding to the quantum gate;
[0014] Obtaining an intersection relationship of quantum bits corresponding to the quantum gates, and using the intersection relationship to determine the execution order of the quantum gates;
[0015] According to the execution order of the quantum gates, a directed acyclic graph corresponding to the original quantum circuit is generated.
[0016] Optionally, generating a directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates includes:
[0017] According to the quantum gates of the original quantum circuit, an initial directed acyclic graph is constructed; wherein each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit;
[0018] The quantum gate execution order is adopted to add directed edges from nodes corresponding to the first executed quantum gates to nodes corresponding to the second executed quantum gates, thereby generating a directed acyclic graph corresponding to the original quantum circuit.
[0019] Optionally, the step of using the directed acyclic graph and the pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured includes:
[0020] Obtaining a predetermined operator to be measured;
[0021] Adding the operator to be measured to a directed acyclic graph, and generating a sub-directed acyclic graph corresponding to the directed acyclic graph;
[0022] The sub-directed acyclic graph is used to generate a sub-quantum circuit of the operator to be measured.
[0023] Optionally, the adding the operator to be measured to a directed acyclic graph and generating a directed acyclic subgraph corresponding to the directed acyclic graph includes:
[0024] Performing inversion processing on the directed acyclic graph after adding the operator to be measured to obtain an inverse graph of the directed acyclic graph;
[0025] Using the node corresponding to the operator to be measured as a starting point to traverse the reverse graph, determine the target node connected to the operator to be measured, and the connection relationship between the node of the operator to be measured and the target node;
[0026] A sub-directed acyclic graph corresponding to the directed acyclic graph is generated according to the target node and the connection relationship.
[0027] Optionally, the adopting the sub-directed acyclic graph to generate the sub-quantum circuit of the operator to be measured includes:
[0028] Performing inversion processing on the sub-directed acyclic graph to obtain multiple sub-graphs of the directed acyclic graph corresponding to the original quantum circuit;
[0029] The plurality of subgraphs are topologically sorted to generate sub-quantum circuits of the operator to be measured.
[0030] Optionally, the performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit includes:
[0031] Obtain the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits of the original quantum circuit and the sub-quantum circuit;
[0032] The target resource amount of the original quantum circuit and the sub-quantum circuit is determined by using the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits; wherein the target resource amount includes simulation duration and space occupancy.
[0033] Optionally, the use of the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits to determine the target resource amount of the original quantum circuit and the sub-quantum circuit; wherein the target resource amount includes simulation duration and space occupancy, including:
[0034] Calculating the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits to generate a first simulation duration of the original quantum circuit and a second simulation duration of the sub-quantum circuit;
[0035] The number of quantum bits of the quantum gate is used to calculate the first spatial proportion of the original quantum circuit and the second spatial proportion of the sub-quantum circuit.
[0036] Optionally, the first simulation duration and the second simulation duration are calculated by the following formula:
[0037]
[0038] Among them, N g is the number of quantum gates in the quantum circuit, N is the number of quantum bits, and N cis the number of quantum gate control bits, N t is the target number of qubits, is the number of cycles of non-target bits, is the complexity of matrix-vector multiplication on the target bits.
[0039] Optionally, comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit includes:
[0040] Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to generate a circuit resource comparison result;
[0041] The target quantum circuit is determined using the circuit resource comparison result.
[0042] Optionally, the using the circuit resource comparison result to determine the target quantum circuit includes:
[0043] Obtain target simulation requirements for quantum circuits;
[0044] According to the comparison result between the target simulation requirement and the circuit resources, a target quantum circuit matching the target simulation requirement is determined.
[0045] Optionally, determining a target quantum circuit matching the target simulation requirement according to a comparison result between the target simulation requirement and the circuit resources includes:
[0046] Adjust the priority order of simulation duration and space usage according to the target simulation requirements;
[0047] If the target simulation requirement is to prioritize simulation duration, the target quantum circuit is determined by comparing the simulation durations of the original quantum circuit and the sub-quantum circuit;
[0048] If the target simulation requirement is to prioritize space proportion, the target quantum circuit is determined by comparing the space proportions of the original quantum circuit and the sub-quantum circuit.
[0049] Optionally, if the target simulation requirement is to prioritize simulation duration, using the simulation duration comparison result of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit includes:
[0050] When the target simulation requirement is to prioritize simulation duration, obtaining a comparison result of simulation durations of the original quantum circuit and the sub-quantum circuit;
[0051] If the simulation time of the original quantum circuit is longer than the simulation time of the sub-quantum circuit, determining the sub-quantum circuit as the target quantum circuit;
[0052] If the simulation time of the original quantum circuit is less than the simulation time of the sub-quantum circuit, the original quantum circuit is determined to be the target quantum circuit.
[0053] Optionally, if the target simulation requirement is to prioritize space share, using a comparison result of the space share of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit includes:
[0054] When the target simulation requirement is to prioritize space proportion, obtaining a comparison result of the space proportions of the original quantum circuit and the sub-quantum circuit;
[0055] If the space proportion of the original quantum circuit is greater than the space proportion of the sub-quantum circuit, the sub-quantum circuit is determined to be the target quantum circuit;
[0056] If the space proportion of the original quantum circuit is less than the space proportion of the sub-quantum circuit, the original quantum circuit is determined to be the target quantum circuit.
[0057] Optionally, the adopting the target quantum circuit to perform quantum circuit simulation includes:
[0058] Determine a local Pauli string in a target quantum circuit and a quantum bit position corresponding to the local Pauli string;
[0059] According to the quantum bit position of the local Pauli string, the target quantum circuit is simulated to calculate the operator average value of the local Pauli string in the quantum state.
[0060] Optionally, simulating the target quantum circuit according to the quantum bit position of the local Pauli string and calculating the operator average value of the local Pauli string in the quantum state includes:
[0061] According to the quantum bit position of the local Pauli string, a certain target quantum circuit is used for simulation to calculate the quantum state amplitude;
[0062] The quantum state amplitude is used to calculate the operator average of the localized Pauli string.
[0063] Optionally, the operator average of the target quantum circuit is calculated by the following formula:
[0064] If the target quantum circuit is the original quantum circuit, the operator average value of the original quantum circuit is:
[0065]
[0066] in, is the quantum gate U k The Hermitian conjugate of j is a local operator;
[0067] If the target quantum circuit is a sub-quantum circuit, the operator average value of the sub-quantum circuit is:
[0068]
[0069] in, is the quantum gate U k The Hermitian conjugate, U k-out and U k-in are the quantum gate sets, and U k-out and U k-in The Hermitian conjugate of j is a local operator
[0070] According to a second aspect of the present invention, a quantum circuit simulation device is provided, the device comprising:
[0071] A quantum information acquisition module is used to acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information;
[0072] A local circuit generation module is used to generate a sub-quantum circuit of the operator to be measured by using the directed acyclic graph and the pre-acquired operator to be measured;
[0073] A line resource estimation module, used to estimate the resources of the original quantum line and the sub-quantum line to obtain the target resource amounts of the original quantum line and the sub-quantum line;
[0074] Determine a simulation circuit module, used to compare the target resource amounts of the original quantum circuit and the sub-quantum circuit, and determine the target quantum circuit;
[0075] The quantum circuit simulation module is used to perform quantum circuit simulation using the target quantum circuit.
[0076] According to another aspect of the present invention, there is also provided an electronic device, comprising:
[0077] processor;
[0078] a memory for storing instructions executable by the processor;
[0079] The processor is configured to execute the instructions to implement the quantum circuit simulation method as described above.
[0080] According to another aspect of the present invention, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the quantum circuit simulation method described above are implemented.
[0081] The quantum circuit simulation method provided by the embodiment of the present invention obtains the quantum gate information in the original quantum circuit, generates a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information, uses the directed acyclic graph and the pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured, estimates the resources of the original quantum circuit and the sub-quantum circuit, obtains the target resource amount of the original quantum circuit and the sub-quantum circuit, compares the target resource amount of the original quantum circuit and the sub-quantum circuit, determines the target quantum circuit, and uses the target quantum circuit to simulate the quantum circuit. The embodiment of the present invention creates and generates a local sub-quantum circuit, and the scale of the optimized sub-quantum circuit is much smaller than the scale of the original quantum circuit. The strategy of estimating the resources required for circuit simulation is adopted, and the optimal simulation circuit is dynamically selected according to the resource consumption. The present invention provides a general framework that can be optimized for different types of quantum circuits and measurement operators, has universality, improves the flexibility and efficiency of simulation, and selects the optimal simulation circuit, reduces the number of quantum bits and quantum gate operations required for simulation, and avoids redundant computing consumption of resources when executing quantum algorithms, thereby meeting the quantum computing requirements of general quantum circuit simulation and realizing effective quantum circuit simulation.
[0082] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0084] Figure 1 is a flowchart of a quantum circuit simulation method provided by an embodiment of the present invention;
[0085] Figure 2 yes Figure 1 A flowchart of step 101 in the quantum circuit simulation method provided by an embodiment of the present invention;
[0086] Figure 3 yes Figure 1 A flowchart of step 102 in the quantum circuit simulation method provided in an embodiment of the present invention;
[0087] Figure 4 yes Figure 1 A flowchart of step 105 in the quantum circuit simulation method provided by an embodiment of the present invention;
[0088] Figure 5 is a tensor network schematic diagram of a quantum circuit simulation method provided by an embodiment of the present invention;
[0089] Figure 6 is a schematic diagram of a scenario of a quantum circuit simulation method provided by an embodiment of the present invention;
[0090] Figure 7 Schematic diagram of the effect of the quantum circuit simulation method provided by an embodiment of the present invention;
[0091] Figure 8 is a schematic diagram of the structure of a quantum circuit simulation device provided by an embodiment of the present invention;
[0092] Fig. 9 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0093] To make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented. The division of the following embodiments is for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.
[0094] Reference Figure 1 , shows a flowchart of the steps of a quantum circuit simulation method provided by an embodiment of the present invention, the method may include:
[0095] Step 101, obtaining quantum gate information in the original quantum circuit, and generating a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information.
[0096] In an embodiment of the present invention, in order to solve the problem that the current quantum simulator cannot meet the quantum computing requirements of general quantum circuit simulation, which affects the effectiveness of quantum circuit simulation, an optimized quantum circuit simulation method of measuring locality is adopted, which can reduce the scale of the quantum circuit according to the required local information, and dynamically adjust the quantum circuits in different quantum algorithms by pre-estimating the computing resources required for small-scale quantum circuit simulation and the resources required for the original quantum circuit, and optimize different types of quantum circuits and measurement operators. It has universality, improves the flexibility and efficiency of simulation, selects the optimal simulation circuit, and reduces the number of quantum bits and quantum gate operations required for simulation.
[0097] The executor of the embodiment of the present invention is a quantum simulator, which is applicable to various quantum simulators, including tensor network simulators such as matrix product state simulators. The quantum simulator can be various quantum simulation backends, which are generally computing programs deployed on a personal computer or a quantum cloud platform backend, and are used to simulate quantum circuits and calculate the average value of local operators.
[0098] This embodiment obtains quantum gate information in the original quantum circuit through a quantum simulator, and generates a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information. It should be noted that the original quantum circuit is the original quantum circuit required to simulate the target quantum bits in the calculation quantum gate, and the quantum gate information includes the quantum gates in the original quantum circuit and the quantum bits corresponding to the quantum gates.
[0099] Specifically, the intersection relationship between the quantum gates and the quantum bits corresponding to the quantum gates in the original quantum circuit is determined, and the execution order of the quantum gates is determined according to the intersection relationship, so as to construct the directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates. It should be noted that the directed acyclic graph (DAG) corresponding to the original quantum circuit in this embodiment is a way to represent the dependency relationship between quantum gates in the quantum circuit. The structure of the directed acyclic graph helps to understand and analyze the execution order of the quantum circuit, as well as to effectively allocate resources when optimizing and simulating the quantum circuit.
[0100] Step 102: using the directed acyclic graph and the pre-acquired operator to be measured, generating a sub-quantum circuit of the operator to be measured.
[0101] In an embodiment of the present invention, a quantum simulator uses a directed acyclic graph and a pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured, combines the directed acyclic graph of the original quantum circuit with the operator to be measured, reduces the scale of the quantum circuit according to the required local information, and generates a local sub-quantum circuit.
[0102] Reference Figure 6 In this embodiment, the operator to be measured obtained in advance may be the operator to be measured input by the user, and the operator may be a Pauli operator and a bit measurement operator. The Pauli operator includes three basic operators σ x , σ y , σ z, the Pauli string is composed of the tensor product of the Pauli operator, which is represented by the Pauli operator and the bit space on which it acts. The bit measurement operator is obtained by sampling the state of the quantum bit, which will not be described one by one here. Specifically, in this embodiment, the quantum simulator obtains a predetermined operator to be measured, adds the operator to be measured to the directed acyclic graph, and generates a sub-directed acyclic graph corresponding to the directed acyclic graph. The sub-directed acyclic graph is used to generate a sub-quantum circuit of the operator to be measured. Specifically, the directed acyclic graph after the operator to be measured is inverted to obtain the reverse graph of the directed acyclic graph. The node corresponding to the operator to be measured is taken as the starting point, and the reverse graph is traversed to determine the target node connected to the operator to be measured, as well as the connection relationship between the operator node to be measured and the target node. According to the target node and the connection relationship, a sub-directed acyclic graph corresponding to the directed acyclic graph is generated, and the sub-directed acyclic graph is inverted to obtain multiple sub-graphs of the directed acyclic graph corresponding to the original quantum circuit. The multiple sub-graphs are topologically sorted to generate the sub-quantum circuit of the operator to be measured.
[0103] Step 103, performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit.
[0104] In the embodiment of the present invention, since resource estimation of simulating quantum circuits is an important issue in quantum computing, which directly affects the efficiency and feasibility of simulation, simulation resources mainly include time and space complexity. The more quantum gates contained in the quantum circuit, the longer the simulation time is required. Specifically, the quantum simulator obtains the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits of the original quantum circuit and the sub-quantum circuit, and determines the target resource amount of the original quantum circuit and the sub-quantum circuit based on the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits. In this embodiment, the target resource amount includes simulation duration and space occupancy.
[0105] It should be noted that the number of qubits determines the dimension of the state vector. As the number of qubits increases, the dimension of the state vector grows exponentially, resulting in a sharp increase in simulation time. The number of quantum gate control bits and the number of target qubits are affected by different types of quantum gates, and may involve different numbers of control bits and target qubits. For example, a single-qubit gate affects only one qubit, while a multi-qubit gate (such as CNOT, Toffoli, etc.) may affect multiple qubits. The operation of each quantum gate requires matrix-vector multiplication, and its complexity is related to the number of qubits involved. The complexity of matrix-vector multiplication of the target qubit is the main part of the simulation time complexity. The spatial complexity mainly depends on the number of qubits. As the number of qubits increases, the required storage space grows exponentially. Therefore, in this embodiment, under normal circumstances, for the sub-quantum circuit optimized by local measurement, its simulation time and space occupancy may be reduced. Specifically, since the sub-quantum circuit only contains quantum gates and quantum bits related to the operator to be measured, the number of quantum gates and the number of quantum bits involved may be reduced, thereby reducing the simulation time. The number of quantum bits in the sub-quantum circuit may be reduced, so the space occupied will also be reduced accordingly. In contrast, the original quantum circuit contains all quantum gates and quantum bits, and the simulation time is usually longer. The original quantum circuit has the largest number of quantum bits and occupies a larger space.
[0106] Step 104, comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit, and determining the target quantum circuit.
[0107] In the embodiment of the present invention, the quantum simulator can obtain the target simulation requirements of the quantum circuit, compare the target resource amounts of the original quantum circuit and the sub-quantum circuit, and determine the target quantum circuit that matches the target simulation requirements based on the comparison results of the target simulation requirements and the circuit resources. It should be noted that the target simulation requirements include the shortest simulation time or the smallest space occupancy, which are specifically set according to the actual simulation requirements and are not specifically limited here.
[0108] Specifically, the priority order of simulation duration and space proportion can be adjusted according to the target simulation requirements. If the target simulation requirement is the shortest simulation duration, the simulation durations of the original quantum circuit and the sub-quantum circuit are compared first, and the quantum circuit with the shortest simulation duration is selected as the target quantum circuit. If the target simulation requirement is the smallest space proportion, the space proportions of the original quantum circuit and the sub-quantum circuit are compared first, and the quantum circuit with the smallest space proportion is selected as the target quantum circuit.
[0109] This embodiment can determine the target quantum circuit that is more suitable for simulation under given resource constraints by comparing the simulation time and space occupancy of the original quantum circuit and the optimized sub-quantum circuit. Specifically, if the resource consumption of the sub-quantum circuit is significantly lower than that of the original quantum circuit, it will be more efficient to use the sub-quantum circuit for simulation. The resource estimation method of this embodiment helps to dynamically select the optimal simulation strategy.
[0110] Step 105, using the target quantum circuit to perform quantum circuit simulation.
[0111] In the embodiment of the present invention, after determining the target quantum circuit with the best resource consumption, the quantum simulator uses the target quantum circuit to simulate the quantum circuit. Specifically, the local Pauli string in the target quantum circuit and the quantum bit position corresponding to the local Pauli string are determined, and the target quantum circuit is simulated according to the quantum bit position of the local Pauli string, and the operator average value of the local Pauli string in the quantum state is calculated. Specifically, according to the quantum bit position of the local Pauli string, the quantum gate and quantum bit outside the local Pauli string can be removed, and the quantum gate in the processed target quantum circuit can be determined as the initial quantum state, and the quantum state amplitude is calculated. The quantum state amplitude is used to calculate the operator average value of the local Pauli string, and the quantum simulator realizes the effective calculation of the average value of the local operator based on the simulated quantum circuit.
[0112] Reference Figure 7 , Figure 7 The test results of the quantum circuit simulation method provided by the embodiment of the present invention when applied to the matrix product state simulator to simulate quantum sampling are shown. It should be noted that the original quantum circuit contains 100 quantum bits and 10 layers of brick-wall quantum circuits (configuration as Figure 5 As shown), the second and fourth bit states are sampled and simulated. Figure 7 The quantum programming framework in is qiskit, which provides a matrix product state quantum circuit simulator. The matrix product state simulator in the self-developed quantum software pyiqcs applies the quantum circuit simulation method provided by the present invention. It can be obtained that under the same test environment, the quantum circuit simulation method of the embodiment of the present invention has a much smaller sub-circuit scale after optimization than the original circuit scale, which greatly improves the simulation efficiency.
[0113] The quantum circuit simulation method provided by the embodiment of the present invention obtains the quantum gate information in the original quantum circuit, generates a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information, uses the directed acyclic graph and the pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured, estimates the resources of the original quantum circuit and the sub-quantum circuit, obtains the target resource amount of the original quantum circuit and the sub-quantum circuit, compares the target resource amount of the original quantum circuit and the sub-quantum circuit, determines the target quantum circuit, and uses the target quantum circuit to simulate the quantum circuit. The embodiment of the present invention creates and generates a local sub-quantum circuit, and the scale of the optimized sub-quantum circuit is much smaller than the scale of the original quantum circuit. The strategy of estimating the resources required for circuit simulation is adopted, and the optimal simulation circuit is dynamically selected according to the resource consumption. The present invention provides a general framework that can be optimized for different types of quantum circuits and measurement operators, has universality, improves the flexibility and efficiency of simulation, and selects the optimal simulation circuit, reduces the number of quantum bits and quantum gate operations required for simulation, and avoids redundant computing consumption of resources when executing quantum algorithms, thereby meeting the quantum computing requirements of general quantum circuit simulation and realizing effective quantum circuit simulation.
[0114] Further, see Figure 2 , showing Figure 1 A flowchart of step 101 in a quantum circuit simulation method is provided, which is basically the same as the quantum circuit simulation method provided in the first embodiment of the present invention. Step 101 obtains quantum gate information in the original quantum circuit, and generating a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information may include:
[0115] Step 201, obtaining quantum gate information in the original quantum circuit; wherein the quantum gate information includes the quantum gate and the quantum bit corresponding to the quantum gate.
[0116] Step 202, obtaining the intersection relationship between quantum gates and quantum bits, and using the intersection relationship to determine the execution order of the quantum gates.
[0117] It should be noted that, in the embodiment of the present invention, since the execution order of quantum gates cannot be changed, it is necessary to determine whether the target quantum bit of the current quantum gate has an intersection with the previous quantum gate. If there is an intersection, it indicates that the current quantum gate depends on the previous quantum gate. For two quantum gates with a dependent relationship, a directed edge is added from the node corresponding to the quantum gate executed first to the node corresponding to the quantum gate executed later.
[0118] Step 203: Generate a directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates.
[0119] In the embodiment of the present invention, in the above steps, the quantum gate information in the original quantum circuit is first obtained, an empty directed acyclic graph is created, and an initial directed acyclic graph is constructed according to the quantum gates of the original quantum circuit, that is, an empty directed acyclic graph is created, and each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit. The quantum gate execution order is adopted, and directed edges are added from the nodes corresponding to the first executed quantum gates to the nodes corresponding to the later executed quantum gates, so as to generate a directed acyclic graph corresponding to the original quantum circuit.
[0120] Specifically, the step of generating a directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates may specifically include the following steps:
[0121] First, an initial directed acyclic graph is constructed according to the quantum gates of the original quantum circuit; wherein each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit;
[0122] Secondly, the quantum gate execution order is adopted to add directed edges from the nodes corresponding to the first executed quantum gates to the nodes corresponding to the second executed quantum gates, thereby generating a directed acyclic graph corresponding to the original quantum circuit.
[0123] It should be noted that, in this embodiment, an initial directed acyclic graph is constructed according to the quantum gates of the original quantum circuit, that is, an empty directed acyclic graph is created. Each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit. The quantum gate execution order is adopted to add directed edges from the nodes corresponding to the first executed quantum gates to the nodes corresponding to the later executed quantum gates, so as to generate a directed acyclic graph corresponding to the original quantum circuit.
[0124] For example, each quantum gate will be represented as a node in the graph. Starting from the first quantum gate in the quantum circuit, all quantum gates in the circuit are traversed one by one. For each quantum gate, a corresponding node is created in the directed acyclic graph. The node can contain information about the quantum gate, such as type, quantum bits operated, etc. By checking whether the target quantum bit of the current quantum gate has an intersection with the previous quantum gate, if there is an intersection, it means that the current quantum gate depends on the previous quantum gate, and the execution order of the quantum gates cannot be changed. For two quantum gates with dependencies, a directed edge is added from the node corresponding to the first executed quantum gate to the node corresponding to the second executed quantum gate, where the directed edge represents the dependency of the execution order, that is, the second quantum gate must be executed after the first quantum gate is executed. Continue to traverse the next quantum gate in the quantum circuit until all quantum gates are processed. When all quantum gates are added to the graph and all dependencies are represented by directed edges, the directed acyclic graph is constructed.
[0125] Further, see Figure 3 , showing Figure 1A flowchart of step 102 in a quantum circuit simulation method is provided, which is basically the same as the quantum circuit simulation method provided in the first embodiment of the present invention. Step 102 uses the directed acyclic graph and the pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured, including:
[0126] Step 301: Obtain a predetermined operator to be measured.
[0127] It should be noted that the predetermined operator to be measured is an operator input by the user or required by quantum computing. The operator to be measured generally refers to an operator used to measure the state of a quantum system, which may be a Pauli operator or other types of quantum operators. The selection of the operator to be measured depends on the purpose of the quantum algorithm and the required output, and this embodiment does not specifically limit this. The Pauli operator is one of the most commonly used measurement operators in quantum computing, and is generally used to measure the state of a single quantum bit. In some embodiments, the operator to be measured may also be a bit measurement operator, which is the tensor product of a single quantum bit operator, or a multi-qubit operator, such as a CNOT gate, a Toffoli gate, and the like.
[0128] Step 302: Add the operator to be measured to the directed acyclic graph, and generate a sub-directed acyclic graph corresponding to the directed acyclic graph.
[0129] In this embodiment, the operator to be measured is added to the directed acyclic graph, and a sub-directed acyclic graph corresponding to the directed acyclic graph is generated. Specifically, for the directed acyclic graph corresponding to the original quantum circuit that has been constructed, the operator to be measured is added as the last node to the end of the directed acyclic graph, and the directed acyclic graph after the operator to be measured is inverted to obtain a reverse graph of the directed acyclic graph. The reverse graph is traversed using the node corresponding to the operator to be measured as the starting point to determine the target node connected to the operator to be measured and the connection relationship between the operator node to be measured and the target node. According to the target node and the connection relationship, a sub-directed acyclic graph corresponding to the directed acyclic graph is generated.
[0130] Step 303: Use the sub-directed acyclic graph to generate a sub-quantum circuit of the operator to be measured.
[0131] The embodiment of the present invention combines a directed acyclic graph with the operator to be measured and performs a breadth-first traversal of the reverse graph, so as to accurately identify quantum gates directly or indirectly related to the operator to be measured, thereby ensuring that the generated sub-quantum circuit only contains the necessary parts that affect the measurement result. By constructing and using the sub-directed acyclic graph, the resources required for simulating the quantum circuit can be significantly reduced. Since the scale of the sub-quantum circuit is smaller than the original quantum circuit, the calculation can be completed faster during simulation.
[0132] Specifically, the step of adding the operator to be measured to a directed acyclic graph and generating a directed acyclic subgraph corresponding to the directed acyclic graph may specifically include the following steps:
[0133] Performing inversion processing on the directed acyclic graph after adding the operator to be measured to obtain an inverse graph of the directed acyclic graph;
[0134] Using the node corresponding to the operator to be measured as a starting point to traverse the reverse graph, determine the target node connected to the operator to be measured, and the connection relationship between the node of the operator to be measured and the target node;
[0135] A sub-directed acyclic graph corresponding to the directed acyclic graph is generated according to the target node and the connection relationship.
[0136] It should be noted that in the above steps, a directed acyclic graph is constructed based on the quantum gate information in the original quantum circuit. Each node represents a quantum gate, and the directed edges represent the execution dependencies between quantum gates. The operator to be measured is added to the end of the directed acyclic graph as a new node, which represents the final measurement operation. The directed acyclic graph with the operator to be measured is inverted to obtain an inverse graph, in which the edge originally pointing from A to B in the inverse graph now points from B to A, reflecting the inverse dependency of the quantum gate execution. Starting from the node of the operator to be measured, the inverse graph is traversed. Usually, a breadth-first search or depth-first search algorithm is used to find all nodes directly or indirectly connected to the operator node to be measured. During the traversal process, all target nodes connected to the operator node to be measured and the connection relationship between them are recorded. According to the determined target nodes and connection relationships, a new sub-directed acyclic graph is generated. The sub-directed acyclic graph contains quantum gate nodes connected to the operator node to be measured and the dependency relationship between them. The generated sub-directed acyclic graph is inverted to obtain the sub-graph of the directed acyclic graph corresponding to the original quantum circuit. The sub-graph is used to reflect the execution order of all quantum gates that affect the measurement result from the operator node to be measured. The sub-graph is topologically sorted to obtain the execution order of the sub-quantum circuit in the "light cone" corresponding to the operator to be measured.
[0137] The embodiment of the present invention uses sub-quantum circuits for simulation and only simulates quantum gates related to the operator to be measured, which significantly reduces the computing resources required for the simulation, can reduce the resources required for the simulation, and improve the simulation efficiency.
[0138] Specifically, the step adopts the sub-directed acyclic graph to generate the sub-quantum circuit of the operator to be measured, including:
[0139] Performing inversion processing on the sub-directed acyclic graph to obtain multiple sub-graphs of the directed acyclic graph corresponding to the original quantum circuit;
[0140] The plurality of subgraphs are topologically sorted to generate sub-quantum circuits of the operator to be measured.
[0141] In this embodiment, the "light cone" in quantum computing is used to describe the range of influence of quantum gate operations on the final measurement results. Only quantum gates located in the "light cone" will affect the results of the operator to be measured. Therefore, the sub-quantum circuits output by topological sorting only contain those quantum gates located in the "light cone". By simulating only the quantum gates related to the operator to be measured, the computing resources required for the simulation are significantly reduced. Since the scale of the sub-quantum circuit is smaller than the original quantum circuit, the simulation process can be completed faster, and corresponding sub-quantum circuits can be generated according to different operators to be measured, which has high flexibility.
[0142] Specifically, step 103 performs resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit, which may specifically include the following steps:
[0143] First, the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits of the original quantum circuit and the sub-quantum circuit are obtained;
[0144] Secondly, the target resource amount of the original quantum circuit and the sub-quantum circuit is determined by using the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits; wherein the target resource amount includes simulation time and space occupancy.
[0145] In an embodiment of the present invention, the original quantum circuit includes the following features: the number of quantum gates N, the number of quantum bits n, the number of control bits of the quantum gates, and the number of target quantum bits, wherein each quantum gate may involve a different number of control bits and target quantum bits. Based on the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits in the quantum circuit, the simulation time and space occupancy of the original quantum circuit and the sub-quantum circuit are calculated respectively.
[0146] Specifically, the target resource amount of the original quantum circuit and the sub-quantum circuit is determined by using the number of quantum gates, the number of quantum gate control bits, and the target number of quantum bits, including:
[0147] Calculating the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits to generate a first simulation duration of the original quantum circuit and a second simulation duration of the sub-quantum circuit;
[0148] The number of quantum bits of the quantum gate is used to calculate the first spatial proportion of the original quantum circuit and the second spatial proportion of the sub-quantum circuit.
[0149] It should be noted that the first simulation duration and the second simulation duration are obtained by using the same or similar simulation duration calculation method. The specific duration is determined by the number of quantum gates, the number of quantum gate control bits and the number of target quantum bits. According to the actual quantum gate information calculation, the first space proportion and the second space proportion are exponentially related to the number of quantum bits, which will not be elaborated one by one in this embodiment.
[0150] Specifically, the first simulation duration and the second simulation duration are calculated by the following formula:
[0151]
[0152] Among them, N g is the number of quantum gates in the quantum circuit, N is the number of quantum bits, and N c is the number of quantum gate control bits, N t is the target number of qubits, is the number of cycles of non-target bits, is the complexity of matrix-vector multiplication on the target bits.
[0153] It should be noted that, is the number of cycles of non-target bits, is the complexity of matrix-vector multiplication on the target bit, since the space complexity only depends on the number of quantum bits, which is 2 N , for the sub-quantum circuit C after local measurement optimization i , and its simulation time is ∑ i T(C i ), the space occupied is The simulation time of the original quantum circuit is T(C), and the space occupied is 2 N(C) .
[0154] Specifically, step 104 compares the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit, which may specifically include:
[0155] Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to generate a circuit resource comparison result;
[0156] The target quantum circuit is determined using the circuit resource comparison result.
[0157] Specifically, the step of using the circuit resource comparison result to determine the target quantum circuit includes:
[0158] Obtaining a target simulation requirement of a quantum circuit; and determining a target quantum circuit that matches the target simulation requirement based on a comparison result between the target simulation requirement and the circuit resources.
[0159] Specifically, determining a target quantum circuit matching the target simulation requirement according to a comparison result between the target simulation requirement and the circuit resources includes:
[0160] Adjust the priority order of simulation duration and space usage according to the target simulation requirements;
[0161] If the target simulation requirement is to prioritize simulation duration, the target quantum circuit is determined by comparing the simulation durations of the original quantum circuit and the sub-quantum circuit;
[0162] If the target simulation requirement is to prioritize space proportion, the target quantum circuit is determined by comparing the space proportions of the original quantum circuit and the sub-quantum circuit.
[0163] For example, if the target simulation requirement is simulation duration priority, the target quantum circuit is determined by using the simulation duration comparison result of the original quantum circuit and the sub-quantum circuit, including: when the target simulation requirement is simulation duration priority, obtaining the simulation duration comparison result of the original quantum circuit and the sub-quantum circuit, if the simulation duration of the original quantum circuit is greater than the simulation duration of the sub-quantum circuit, determining the sub-quantum circuit as the target quantum circuit; if the simulation duration of the original quantum circuit is less than the simulation duration of the sub-quantum circuit, determining the original quantum circuit as the target quantum circuit. Specifically, if the target simulation requirement is space proportion priority, the target quantum circuit is determined by using the space proportion comparison result of the original quantum circuit and the sub-quantum circuit, including: when the target simulation requirement is space proportion priority, obtaining the space proportion comparison result of the original quantum circuit and the sub-quantum circuit; if the space proportion of the original quantum circuit is greater than the space proportion of the sub-quantum circuit, determining the sub-quantum circuit as the target quantum circuit, if the space proportion of the original quantum circuit is less than the space proportion of the sub-quantum circuit, determining the original quantum circuit as the target quantum circuit.
[0164] In this embodiment, the measurement operator O required by the specific quantum algorithm to be run i The generated sub-quantum circuit can be compared with the original circuit simulation time and space occupancy, and the simulation method suitable for the current algorithm and simulation purpose can be selected. In the case of , select the simulated sub-quantum circuit to simulate more quantum bits; if ∑ i T(C i )<T(C), choose to simulate sub-quantum circuits to improve the efficiency of the simulator in executing quantum algorithms. In the case where the sub-circuits cannot improve the simulation efficiency and reduce the space occupied, directly simulate the original quantum circuit.
[0165] Further, see Figure 4 , showing Figure 1A flowchart of step 105 in a quantum circuit simulation method is provided, which is basically the same as the quantum circuit simulation method provided in the first embodiment of the present invention. Step 105 uses the target quantum circuit to perform quantum circuit simulation, including:
[0166] Step 401, determining the local Pauli string in the target quantum circuit and the quantum bit position corresponding to the local Pauli string.
[0167] Step 402, simulating the target quantum circuit according to the quantum bit position of the local Pauli string, and calculating the operator average value of the local Pauli string in the quantum state.
[0168] It should be noted that in quantum computing, the state of a quantum bit is described by a two-dimensional vector in Hilbert space |ψ>=c0|0>+c1|1>, where the basis vectors |0> and |1> represent the quantum bit in Two eigenstates under the operator basis. For multiple qubits, the basis of the system is composed of the tensor product of the basis vectors of a single qubit. In this case, the quantum state is |ψ>=c 0...0 |0...0>+...+c 1...1 |1...1>, where is the quantum state amplitude, N is the number of quantum bits, and the dimension of the state vector is 2 N ,The tensor network simulator represents each quantum bit and quantum gate as a local tensor, and the simulation process of the quantum circuit is represented by the contraction between tensors.
[0169] Reference Figure 5 In this embodiment, the locality of the measurement operator can be used to optimize the quantum circuit simulation process. Since the operator σ j is local, that is, its position outside j is the unit operator. Some quantum gates are used to calculate the operator The average value of the quantum gate does not contribute anything, so the remaining quantum gate can be directly recorded as U k-in To calculate the average value, use the sub-quantum circuit U in the "light cone" k-in To calculate the local average value, the tensor network of this process is as follows Figure 5 As shown, the dotted line (above and below) represents the sub-quantum circuit U in the "light cone". k-in , while the quantum gate outside the dashed line becomes the unit operator due to unitarity. k-in The scale of the constructed quantum circuit is generally smaller than the original quantum circuit, which can effectively reduce the complexity of quantum circuit simulation.
[0170] Specifically, step 402 simulates the target quantum circuit according to the quantum bit position of the local Pauli string, and calculates the operator average value of the local Pauli string in the quantum state, including: according to the quantum bit position of the local Pauli string, using a determined target quantum circuit to simulate, calculate the quantum state amplitude, and using the quantum state amplitude to calculate the operator average value of the local Pauli string.
[0171] Specifically, the operator average value of the target quantum circuit is calculated by the following formula:
[0172] If the target quantum circuit is the original quantum circuit, the operator average value of the original quantum circuit is:
[0173]
[0174] in, is the quantum gate U k The Hermitian conjugate of j is a local operator;
[0175] If the target quantum circuit is a sub-quantum circuit, the operator average value of the sub-quantum circuit is:
[0176]
[0177] in, is the quantum gate U k The Hermitian conjugate, U k-out and U k-in are the quantum gate sets, and U k-out and U k-in The Hermitian conjugate of j is a local operator.
[0178] Reference Figure 8 , showing a schematic diagram of the structure of a quantum circuit simulation device provided by an embodiment of the present invention, the device comprising:
[0179] A quantum information acquisition module 501 is used to acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information;
[0180] A local circuit generation module 502 is used to generate a sub-quantum circuit of the operator to be measured by using the directed acyclic graph and the pre-acquired operator to be measured;
[0181] A line resource estimation module 503 is used to estimate the resources of the original quantum line and the sub-quantum line to obtain the target resource amounts of the original quantum line and the sub-quantum line;
[0182] A simulation circuit determination module 504 is used to compare the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit;
[0183] The quantum circuit simulation module 505 is used to perform quantum circuit simulation using the target quantum circuit.
[0184] Optionally, the module for acquiring quantum information 501 includes:
[0185] A first acquisition submodule is used to acquire quantum gate information in the original quantum circuit; wherein the quantum gate information includes the quantum gate and the quantum bit corresponding to the quantum gate;
[0186] A second acquisition submodule is used to obtain the intersection relationship of the quantum bits corresponding to the quantum gates, and use the intersection relationship to determine the execution order of the quantum gates;
[0187] The first generating submodule is used to generate a directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates.
[0188] Optionally, the first generating submodule includes:
[0189] A construction unit, used to construct an initial directed acyclic graph according to the quantum gates of the original quantum circuit; wherein each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit;
[0190] The first processing unit is used to add directed edges from nodes corresponding to the first executed quantum gates to nodes corresponding to the second executed quantum gates, using the quantum gate execution order, to generate a directed acyclic graph corresponding to the original quantum circuit.
[0191] Optionally, the generating local line module 502 includes:
[0192] A third acquisition submodule is used to acquire a predetermined operator to be measured;
[0193] A second generating submodule, used for adding the operator to be measured to a directed acyclic graph, and generating a sub-directed acyclic graph corresponding to the directed acyclic graph;
[0194] The third generation submodule is used to use the sub-directed acyclic graph to generate the sub-quantum circuit of the operator to be measured.
[0195] Optionally, the second generating submodule includes:
[0196] A second processing unit is used to perform inverse processing on the directed acyclic graph after adding the operator to be measured, so as to obtain an inverse graph of the directed acyclic graph;
[0197] A first determining unit is used to traverse the reverse graph by taking the node corresponding to the operator to be measured as a starting point to determine the target node connected to the operator to be measured and the connection relationship between the node of the operator to be measured and the target node;
[0198] The first generating unit is used to generate a sub-directed acyclic graph corresponding to the directed acyclic graph according to the target node and the connection relationship.
[0199] Optionally, the third generation submodule includes:
[0200] A third processing unit is used to perform inversion processing on the sub-directed acyclic graph to obtain multiple sub-graphs of the directed acyclic graph corresponding to the original quantum circuit;
[0201] The second generating unit is used to topologically sort the multiple subgraphs to generate sub-quantum circuits of the operator to be measured.
[0202] Optionally, the line resource estimation module 503 includes:
[0203] The fourth acquisition submodule is used to obtain the number of quantum gates, the number of quantum gate control bits and the number of target quantum bits of the original quantum circuit and the sub-quantum circuit;
[0204] The first determination submodule is used to determine the target resource amount of the original quantum circuit and the sub-quantum circuit by using the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits; wherein the target resource amount includes simulation time and space occupancy.
[0205] Optionally, the first determining submodule includes:
[0206] A third generating unit is used to calculate the number of quantum gates, the number of quantum gate control bits and the number of target quantum bits to generate a first simulation duration of the original quantum circuit and a second simulation duration of the sub-quantum circuit;
[0207] The proportion calculation unit is used to calculate the first spatial proportion of the original quantum circuit and the second spatial proportion of the sub-quantum circuit by using the number of quantum bits of the quantum gate.
[0208] Optionally, the first simulation duration and the second simulation duration are calculated by the following formula:
[0209]
[0210] Among them, N g is the number of quantum gates in the quantum circuit, N is the number of quantum bits, and N c is the number of quantum gate control bits, N t is the target number of qubits, is the number of cycles of non-target bits, is the complexity of matrix-vector multiplication on the target bits.
[0211] Optionally, the analog line determination module 504 includes:
[0212] A comparison submodule, used to compare the target resource amounts of the original quantum circuit and the sub-quantum circuit, and generate a circuit resource comparison result;
[0213] The second determination submodule is used to determine the target quantum circuit using the circuit resource comparison result.
[0214] Optionally, the second determining submodule includes:
[0215] A first acquisition unit, used to acquire target simulation requirements of the quantum circuit;
[0216] The second determining unit is used to determine a target quantum circuit that matches the target simulation requirement according to a comparison result between the target simulation requirement and the circuit resources.
[0217] Optionally, the second determining unit includes:
[0218] The adjustment subunit is used to adjust the priority order of simulation duration and space proportion according to the target simulation requirements;
[0219] A first determination subunit is configured to determine a target quantum circuit by comparing the simulation durations of the original quantum circuit and the sub-quantum circuit if the target simulation requirement is simulation duration priority;
[0220] The second determination subunit is used to determine the target quantum circuit by using the comparison result of the space proportions of the original quantum circuit and the sub-quantum circuit if the target simulation requirement is space proportion priority.
[0221] Optionally, the first determination subunit is specifically configured to: when the target simulation requirement is simulation duration priority, obtain a comparison result of the simulation durations of the original quantum circuit and the sub-quantum circuit; if the simulation duration of the original quantum circuit is greater than the simulation duration of the sub-quantum circuit, determine the sub-quantum circuit as the target quantum circuit; if the simulation duration of the original quantum circuit is less than the simulation duration of the sub-quantum circuit, determine the original quantum circuit as the target quantum circuit.
[0222] Optionally, the second determination subunit is specifically configured to: when the target simulation requirement is to prioritize space share, obtain a comparison result of the space share of the original quantum circuit and the sub-quantum circuit; if the space share of the original quantum circuit is greater than the space share of the sub-quantum circuit, determine the sub-quantum circuit as the target quantum circuit; if the space share of the original quantum circuit is less than the space share of the sub-quantum circuit, determine the original quantum circuit as the target quantum circuit.
[0223] Optionally, the quantum circuit simulation module 505 includes:
[0224] A third determination submodule is used to determine the local Pauli string in the target quantum circuit and the quantum bit position corresponding to the local Pauli string;
[0225] The simulation calculation submodule is used to simulate the target quantum circuit according to the quantum bit position of the local Pauli string, and calculate the operator average value of the local Pauli string in the quantum state.
[0226] Optionally, the simulation calculation submodule includes:
[0227] A simulation unit, used to perform simulation according to the quantum bit position of the local Pauli string using a determined target quantum circuit to calculate the quantum state amplitude;
[0228] The first calculation unit is used to calculate the operator average of the local Pauli string by using the quantum state amplitude.
[0229] Optionally, the operator average of the target quantum circuit is calculated by the following formula:
[0230] If the target quantum circuit is the original quantum circuit, the operator average value of the original quantum circuit is:
[0231]
[0232] in, is the quantum gate U k The Hermitian conjugate of j is a local operator;
[0233] If the target quantum circuit is a sub-quantum circuit, the operator average value of the sub-quantum circuit is:
[0234]
[0235] in, is the quantum gate U k The Hermitian conjugate, U k-out and U k-in are the quantum gate sets, and Uk-out and U k-in The Hermitian conjugate of j is a local operator.
[0236] The quantum circuit simulation device provided by the embodiment of the present invention obtains the quantum gate information in the original quantum circuit, generates the directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information, uses the directed acyclic graph and the pre-acquired operator to be measured to generate the sub-quantum circuit of the operator to be measured, estimates the resources of the original quantum circuit and the sub-quantum circuit, obtains the target resource amount of the original quantum circuit and the sub-quantum circuit, compares the target resource amount of the original quantum circuit and the sub-quantum circuit, determines the target quantum circuit, and uses the target quantum circuit to simulate the quantum circuit. The embodiment of the present invention creates and generates a local sub-quantum circuit, and the scale of the optimized sub-quantum circuit is much smaller than the scale of the original quantum circuit. The strategy of estimating the resources required for circuit simulation is adopted, and the optimal simulation circuit is dynamically selected according to the resource consumption. The present invention provides a general framework that can be optimized for different types of quantum circuits and measurement operators, has universality, improves the flexibility and efficiency of simulation, and selects the optimal simulation circuit, reduces the number of quantum bits and quantum gate operations required for simulation, and avoids redundant computing consumption of resources when executing quantum algorithms, thereby meeting the quantum computing requirements of general quantum circuit simulation and realizing effective quantum circuit simulation.
[0237] Reference Fig. 9 , an embodiment of the present invention further provides an electronic device, such as Fig. 9 As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0238] Memory 603, used for storing computer programs;
[0239] The processor 601 is used to execute the program stored in the memory 603 to implement the following steps:
[0240] Acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information;
[0241] Using the directed acyclic graph and the pre-acquired operator to be measured, generating a sub-quantum circuit of the operator to be measured;
[0242] Performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit;
[0243] Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit;
[0244] The target quantum circuit is used to perform quantum circuit simulation.
[0245] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0246] The communication interface is used for communication between the above terminal and other devices.
[0247] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0248] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0249] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the quantum circuit simulation method described in any of the above embodiments.
[0250] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0251] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0252] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0253] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A quantum circuit simulation method, characterized in that: The method comprises: Acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information; Using the directed acyclic graph and the pre-acquired operator to be measured, generating a sub-quantum circuit of the operator to be measured; Performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit; Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit; The target quantum circuit is used to perform quantum circuit simulation.
2. The method according to claim 1, characterized in that The step of obtaining quantum gate information in the original quantum circuit and generating a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information includes: Obtaining quantum gate information in the original quantum circuit; wherein the quantum gate information includes the quantum gate and the quantum bit corresponding to the quantum gate; Obtaining an intersection relationship of quantum bits corresponding to the quantum gates, and using the intersection relationship to determine an execution order of the quantum gates; According to the execution order of the quantum gates, a directed acyclic graph corresponding to the original quantum circuit is generated.
3. The method according to claim 2, characterized in that Generating a directed acyclic graph corresponding to the original quantum circuit according to the execution order of the quantum gates includes: According to the quantum gates of the original quantum circuit, an initial directed acyclic graph is constructed; wherein each node in the initial directed acyclic graph is used to represent a quantum gate of the original quantum circuit; The quantum gate execution order is adopted to add directed edges from nodes corresponding to the first executed quantum gates to nodes corresponding to the second executed quantum gates, thereby generating a directed acyclic graph corresponding to the original quantum circuit.
4. The method according to claim 1, characterized in that: The step of using the directed acyclic graph and the pre-acquired operator to be measured to generate a sub-quantum circuit of the operator to be measured includes: Obtaining a predetermined operator to be measured; Adding the operator to be measured to a directed acyclic graph, and generating a sub-directed acyclic graph corresponding to the directed acyclic graph; The sub-directed acyclic graph is used to generate a sub-quantum circuit of the operator to be measured.
5. The method according to claim 4, characterized in that The step of adding the operator to be measured to a directed acyclic graph and generating a directed acyclic subgraph corresponding to the directed acyclic graph includes: Performing inversion processing on the directed acyclic graph after adding the operator to be measured to obtain an inverse graph of the directed acyclic graph; Using the node corresponding to the operator to be measured as a starting point to traverse the reverse graph, determine the target node connected to the operator to be measured, and the connection relationship between the node of the operator to be measured and the target node; A sub-directed acyclic graph corresponding to the directed acyclic graph is generated according to the target node and the connection relationship.
6. The method according to claim 4, characterized in that The step of using the sub-directed acyclic graph to generate the sub-quantum circuit of the operator to be measured comprises: Performing inversion processing on the sub-directed acyclic graph to obtain multiple sub-graphs of the directed acyclic graph corresponding to the original quantum circuit; The plurality of subgraphs are topologically sorted to generate sub-quantum circuits of the operator to be measured.
7. The method according to claim 1, characterized in that The performing resource estimation on the original quantum circuit and the sub-quantum circuit to obtain target resource amounts of the original quantum circuit and the sub-quantum circuit includes: Obtain the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits of the original quantum circuit and the sub-quantum circuit; The target resource amount of the original quantum circuit and the sub-quantum circuit is determined by using the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits; wherein the target resource amount includes simulation duration and space occupancy.
8. The method according to claim 7, characterized in that The target resource amount of the original quantum circuit and the sub-quantum circuit is determined by using the number of quantum gates, the number of quantum gate control bits and the target number of quantum bits; wherein the target resource amount includes simulation duration and space occupancy, including: Calculating the number of quantum gates, the number of quantum gate control bits, and the number of target quantum bits to generate a first simulation duration of the original quantum circuit and a second simulation duration of the sub-quantum circuit; The number of quantum bits of the quantum gate is used to calculate the first spatial proportion of the original quantum circuit and the second spatial proportion of the sub-quantum circuit.
9. The method according to claim 8, characterized in that The first simulation duration and the second simulation duration are specifically calculated by the following formula: Among them, N g is the number of quantum gates in the quantum circuit, N is the number of quantum bits, and N c is the number of quantum gate control bits, N t is the target number of qubits, is the number of cycles of non-target bits, is the complexity of matrix-vector multiplication on the target bits.
10. The method according to claim 1, characterized in that The comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit includes: Comparing the target resource amounts of the original quantum circuit and the sub-quantum circuit to generate a circuit resource comparison result; The target quantum circuit is determined using the circuit resource comparison result.
11. The method according to claim 10, characterized in that The step of using the circuit resource comparison result to determine the target quantum circuit includes: Obtain target simulation requirements for quantum circuits; According to the comparison result between the target simulation requirement and the circuit resources, a target quantum circuit matching the target simulation requirement is determined.
12. The method according to claim 11, characterized in that Determining a target quantum circuit matching the target simulation requirement according to the comparison result between the target simulation requirement and the circuit resources includes: Adjust the priority order of simulation duration and space usage according to the target simulation requirements; If the target simulation requirement is to prioritize simulation duration, the target quantum circuit is determined by comparing the simulation durations of the original quantum circuit and the sub-quantum circuit; If the target simulation requirement is to prioritize space proportion, the target quantum circuit is determined by comparing the space proportions of the original quantum circuit and the sub-quantum circuit.
13. The method according to claim 12, characterized in that If the target simulation requirement is to prioritize simulation duration, then using the simulation duration comparison result of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit, including: When the target simulation requirement is to prioritize simulation duration, obtaining a comparison result of simulation durations of the original quantum circuit and the sub-quantum circuit; If the simulation time of the original quantum circuit is longer than the simulation time of the sub-quantum circuit, determining the sub-quantum circuit as the target quantum circuit; If the simulation time of the original quantum circuit is less than the simulation time of the sub-quantum circuit, the original quantum circuit is determined to be the target quantum circuit.
14. The method according to claim 12, characterized in that If the target simulation requirement is to prioritize space proportion, then using the space proportion comparison result of the original quantum circuit and the sub-quantum circuit to determine the target quantum circuit, including: When the target simulation requirement is to prioritize space proportion, obtaining a comparison result of the space proportions of the original quantum circuit and the sub-quantum circuit; If the space proportion of the original quantum circuit is greater than the space proportion of the sub-quantum circuit, the sub-quantum circuit is determined to be the target quantum circuit; If the space proportion of the original quantum circuit is less than the space proportion of the sub-quantum circuit, the original quantum circuit is determined to be the target quantum circuit.
15. The method according to claim 1, characterized in that The step of using the target quantum circuit to perform quantum circuit simulation includes: Determine a local Pauli string in a target quantum circuit and a quantum bit position corresponding to the local Pauli string; According to the quantum bit position of the local Pauli string, the target quantum circuit is simulated to calculate the operator average value of the local Pauli string in the quantum state.
16. The method according to claim 15, characterized in that The method of simulating the target quantum circuit according to the quantum bit position of the local Pauli string and calculating the operator average value of the local Pauli string in the quantum state includes: According to the quantum bit position of the local Pauli string, a certain target quantum circuit is used for simulation to calculate the quantum state amplitude; The quantum state amplitude is used to calculate the operator average of the localized Pauli string.
17. The method according to claim 15, characterized in that The operator average of the target quantum circuit is calculated by the following formula: If the target quantum circuit is the original quantum circuit, the operator average value of the original quantum circuit is: in, is the quantum gate U k The Hermitian conjugate of j is a local operator; If the target quantum circuit is a sub-quantum circuit, the operator average value of the sub-quantum circuit is: in, is the quantum gate U k The Hermitian conjugate, U k-out and U k-in are the quantum gate sets, and U k-out and U k-in The Hermitian conjugate of j is a local operator.
18. A quantum circuit simulation device, characterized in that: The device comprises: A quantum information acquisition module is used to acquire quantum gate information in the original quantum circuit, and generate a directed acyclic graph corresponding to the original quantum circuit according to the quantum gate information; A local circuit generation module is used to generate a sub-quantum circuit of the operator to be measured by using the directed acyclic graph and the pre-acquired operator to be measured; A line resource estimation module, used to estimate the resources of the original quantum line and the sub-quantum line to obtain the target resource amounts of the original quantum line and the sub-quantum line; Determine a simulation circuit module, used to compare the target resource amounts of the original quantum circuit and the sub-quantum circuit, and determine the target quantum circuit; The quantum circuit simulation module is used to perform quantum circuit simulation using the target quantum circuit.
19. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the instructions to implement the quantum circuit simulation method according to any one of claims 1 to 17.
20. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the quantum circuit simulation method according to any one of claims 1 to 17 is implemented.
