A method and device for constructing a quantum circuit corresponding to a Bayesian network

By constructing quantum circuits of Bayesian networks and utilizing the superposition characteristics of quantum states, the problem of high computational complexity of complex random systems in the existing technology is solved, and efficient processing of large-scale multi-node networks is achieved.

CN115271076BActive Publication Date: 2024-09-24ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110474388.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-29
Publication Date
2024-09-24
Estimated Expiration
2041-04-29

AI Technical Summary

Technical Problem

Existing Bayesian network technology cannot effectively reduce the computational complexity of complex random systems, especially when the number of nodes increases, it is difficult to handle large-scale problems.

Method used

By constructing the quantum circuit corresponding to the Bayesian network, the nodes of the target network and the causal relationship between the nodes are obtained, the first sub-quantum circuit of the superposition state of the qubit is constructed for the root node, and the second sub-quantum of the conditional probability is constructed for the causal node. Lines, combine to obtain quantum lines of the target network, and use the superposition properties of quantum states to process multi-node networks with fewer resources.

Benefits of technology

It reduces the computational complexity of Bayesian networks, supports efficient processing of large-scale multi-node networks, and uses the superposition characteristics of quantum states to reduce storage and computing resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115271076B
    Figure CN115271076B
Patent Text Reader

Abstract

The present invention discloses a method and device for constructing a quantum circuit corresponding to a Bayesian network. The method comprises: obtaining each node included in a target network and the causal relationship between the nodes, constructing a first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node in each node, respectively constructing a second sub-quantum circuit corresponding to the causal relationship and used for encoding conditional probability for every two nodes with a causal relationship in each node, and obtaining a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit, thereby realizing a quantum implementation mode of a Bayesian network, reducing the computational complexity of the Bayesian network, realizing efficient computing, and utilizing the superposition characteristics of quantum states, thereby realizing processing supporting a large-scale multi-node network model with less storage and computing resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of quantum computing technology, and in particular to a method and device for constructing a quantum circuit corresponding to a Bayesian network. Background Art

[0002] Quantum computers are physical devices that follow the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have become a key technology under research because they have the ability to process mathematical problems more efficiently than ordinary computers. For example, they can speed up the time to crack RSA keys from hundreds of years to a few hours.

[0003] Bayesian network is a probabilistic graph model suitable for solving specific types of complex random systems. It assumes that there are multiple key factor nodes in the complex random system, most of which have no direct causal relationship, the causal relationship between directly related nodes is unidirectional, and there is no node that can go back to itself along the unidirectional causal relationship. It can more intuitively display a complex random system with discrete key factors, sparse, unidirectional causal relationship and no loops, and can complete the calculation of the joint probability of all nodes and the edge probability of a single node. However, the existing Bayesian network technology can only solve the problem that the display of complex random systems is not intuitive enough, and cannot reduce the computational complexity of probability solution in the system. In addition, the data volume computational complexity of the existing classical Bayesian network technology will increase exponentially with the increase of the number of nodes in the complex random system, making it difficult to handle large-scale problems.

[0004] Based on this, it is necessary to realize a quantum implementation of Bayesian networks to solve the shortcomings of existing technologies. Summary of the invention

[0005] The purpose of the present invention is to provide a method for constructing quantum circuits corresponding to a Bayesian network to address the deficiencies in the prior art. The method can reduce the computational complexity of the Bayesian network, achieve efficient computing, and utilize the superposition characteristics of quantum states to support the processing of large-scale multi-node network models with less storage and computing resources.

[0006] An embodiment of the present application provides a method for constructing a quantum circuit corresponding to a Bayesian network, the method comprising:

[0007] Obtaining each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes;

[0008] For a root node among the nodes, construct a first sub-quantum circuit for preparing a superposition state of a quantum bit, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution;

[0009] For every two nodes having a causal relationship among the nodes, respectively constructing a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability;

[0010] A quantum circuit corresponding to the target network is obtained according to the first sub-quantum circuit and the second sub-quantum circuit.

[0011] In the above-mentioned method for constructing a quantum circuit corresponding to a Bayesian network, preferably, the first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node among the nodes is constructed, including:

[0012] Determine, according to the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the number of preset quantum logic gates as a second number;

[0013] Determining parameters of the preset quantum logic gate according to the probability distribution of the root node;

[0014] A first sub-quantum circuit for encoding the state of the root node and its probability distribution is constructed according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

[0015] The method for constructing a quantum circuit corresponding to a Bayesian network as described above, wherein preferably, for each two nodes having a causal relationship among the nodes, respectively constructing a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability, comprises:

[0016] Determine a cause node and a result node of the two nodes having a causal relationship;

[0017] respectively constructing quantum logic gate combinations that are applied to the result nodes when the cause nodes take different states;

[0018] According to the conditional probabilities between the combinations of quantum logic gates, the cause nodes and the result nodes, a second sub-quantum circuit corresponding to the causal relationship is constructed.

[0019] In the above-mentioned method for constructing a quantum circuit corresponding to a Bayesian network, preferably, obtaining the quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit includes:

[0020] The first sub-quantum circuit and the second sub-quantum circuit are combined in sequence to obtain a quantum circuit corresponding to the target network.

[0021] In the above-mentioned method for constructing a quantum circuit corresponding to a Bayesian network, preferably, the step of obtaining the quantum circuit corresponding to the target network further includes:

[0022] A target node is selected, and a final quantum state of a quantum bit corresponding to the target node is measured and output, wherein the amplitude of the final quantum state corresponds to the probability distribution of the target node.

[0023] In the method for constructing a quantum circuit corresponding to a Bayesian network as described above, preferably, the quantum logic gate comprises a rotational logic gate.

[0024] Another embodiment of the present application provides a device for constructing a quantum circuit corresponding to a Bayesian network, the device comprising:

[0025] The acquisition module is used to acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes;

[0026] A first construction module is used to construct a first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node among the nodes, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution;

[0027] A second construction module is used to construct, for each two nodes having a causal relationship among the nodes, a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability;

[0028] An obtaining module is used to obtain a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

[0029] In the above-mentioned Bayesian network corresponding to the quantum circuit construction device, preferably, the first construction module includes:

[0030] A first determining unit is used to determine, according to the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the number of preset quantum logic gates as a second number;

[0031] A second determining unit, configured to determine the parameters of the preset quantum logic gate according to the probability distribution of the root node;

[0032] A first construction unit is used to construct a first sub-quantum circuit for encoding the state of the root node and its probability distribution according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

[0033] In the above-mentioned Bayesian network corresponding to the quantum circuit construction device, preferably, the second construction module includes:

[0034] A third determining unit, used to determine a cause node and a result node of the two nodes having a causal relationship;

[0035] A construction unit, used to respectively construct a combination of quantum logic gates applied to the result node when the cause node takes different states;

[0036] The second construction unit is used to construct a second sub-quantum circuit corresponding to the causal relationship according to the conditional probabilities between each combination of the quantum logic gates, the cause nodes and the result nodes.

[0037] In the above-mentioned Bayesian network corresponding to the quantum circuit construction device, preferably, the acquisition module includes:

[0038] A combining unit is used to combine the first sub-quantum circuit and the second sub-quantum circuit in sequence to obtain a quantum circuit corresponding to the target network.

[0039] The Bayesian network corresponding to the quantum circuit construction device as described above, wherein preferably, the acquisition module further includes:

[0040] An output unit is used to select a target node, measure and output a final quantum state of a quantum bit corresponding to the target node, wherein the amplitude of the final quantum state corresponds to the probability distribution of the target node.

[0041] Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute any of the above methods when running.

[0042] Yet another embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any of the methods described above.

[0043] Compared with the prior art, the present invention obtains each node included in the target network and the causal relationship between the nodes, constructs a first sub-quantum circuit for preparing the superposition state of quantum bits for the root node in each node, and constructs a second sub-quantum circuit corresponding to the causal relationship and used to encode conditional probability for every two nodes with a causal relationship in each node. According to the first sub-quantum circuit and the second sub-quantum circuit, a quantum circuit corresponding to the target network is obtained. The present invention realizes a quantum implementation method of a Bayesian network, which can reduce the computational complexity of the Bayesian network, realize efficient computing, and utilize the superposition characteristics of quantum states to realize processing supporting large-scale multi-node network models with less storage and computing resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a hardware structure block diagram of a computer terminal for a method for constructing a quantum circuit corresponding to a Bayesian network provided by an embodiment of the present invention;

[0045] Figure 2 It is a flow chart of a method for constructing a quantum circuit corresponding to a Bayesian network provided by an embodiment of the present invention;

[0046] Figure 3 It is a schematic diagram of a first sub-quantum circuit for encoding the state of a root node and its probability distribution provided by an embodiment of the present invention;

[0047] Figure 4 It is a schematic diagram of the first sub-quantum circuit of another encoding root node state and its probability distribution provided by an embodiment of the present invention;

[0048] Figure 5 It is a schematic diagram of a quantum circuit for constructing a causal relationship between nodes provided by an embodiment of the present invention;

[0049] Figure 6 It is a schematic diagram of a second sub-quantum circuit corresponding to a causal relationship between nodes provided by an embodiment of the present invention;

[0050] Figure 7 is a schematic diagram of a quantum circuit corresponding to a target network provided by an embodiment of the present invention;

[0051] Figure 8 It is a structural schematic diagram of a device for constructing a quantum circuit corresponding to a Bayesian network provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, but should not be construed as limiting the present invention.

[0053] The embodiment of the present invention first provides a method for constructing a quantum circuit corresponding to a Bayesian network. The method can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.

[0054] The following describes it in detail by taking running on a computer terminal as an example. Figure 1 The hardware structure block diagram of a computer terminal for a method of constructing a quantum circuit corresponding to a Bayesian network provided by an embodiment of the present invention. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the computer terminal may also include a transmission device 106 for communication functions and an input and output device 108. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0055] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / modules corresponding to the construction method of a Bayesian network corresponding to the quantum circuit in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0056] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0057] It should be noted that a true quantum computer is a hybrid structure, which consists of two parts: one part is a classical computer, which is responsible for performing classical calculations and control; the other part is a quantum device, which is responsible for running quantum programs and thus realizing quantum computing. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can be run on a quantum computer, which supports quantum logic gate operations and ultimately realizes quantum computing. Specifically, a quantum program is a sequence of instructions that operate quantum logic gates in a certain sequence.

[0058] In practical applications, due to the limitations of the development of quantum device hardware, quantum computing simulation is usually required to verify quantum algorithms, quantum applications, etc. Quantum computing simulation is the process of simulating the operation of quantum programs corresponding to specific problems using a virtual architecture (i.e., quantum virtual machine) built with the resources of ordinary computers. Usually, it is necessary to build a quantum program corresponding to a specific problem. The quantum program referred to in the embodiment of the present invention is a program written in a classical language to characterize quantum bits and their evolution, in which quantum bits, quantum logic gates, etc. related to quantum computing are represented by corresponding classical codes.

[0059] Quantum circuits, as a manifestation of quantum programs, are also called quantum logic circuits. They are the most commonly used general quantum computing model. They represent circuits that operate on quantum bits in an abstract concept. They are composed of quantum bits, circuits (timelines), and various quantum logic gates. Finally, the results often need to be read out through quantum measurement operations.

[0060] Unlike traditional circuits that are connected by metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as connected by time, that is, the state of the quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated.

[0061] A quantum program as a whole corresponds to a total quantum circuit. The quantum program described in the present invention refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits in the quantum program. It can be understood that a quantum program can be composed of a quantum circuit, measurement operations on quantum bits in the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution process of a quantum program is the process of executing all quantum logic gates in a certain time sequence. It should be noted that the time sequence is the time order in which a single quantum logic gate is executed.

[0062] It should be noted that in classical computing, the most basic unit is the bit, and the most basic control mode is the logic gate, which can achieve the purpose of controlling the circuit through the combination of logic gates. Similarly, the way to process quantum bits is quantum logic gates. Using quantum logic gates, quantum states can evolve. Quantum logic gates are the basis of quantum circuits. Quantum logic gates include single-bit quantum logic gates, such as Hadamard gates (H gates), Pauli-X gates (X gates), Pauli-Y gates (Y gates), Pauli-Z gates (Z gates), RX gates, RY gates, RZ gates, etc.; multi-bit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, Toffoli gates, etc. Quantum logic gates are generally represented by unitary matrices, which are not only in matrix form, but also an operation and transformation. The effect of a general quantum logic gate on a quantum state is calculated by multiplying the unitary matrix on the left by the matrix corresponding to the right vector of the quantum state.

[0063] The quantum state, that is, the logical state of the quantum bit, is represented by binary in the quantum algorithm (or quantum program). For example, a group of quantum bits is q0, q1, and q2, representing the 0th, 1st, and 2nd quantum bits, and is sorted from high to low as q2q1q0. The quantum state corresponding to this group of quantum bits has 2 to the power of the total number of quantum bits, which refers to 8 eigenstates (determined states): |000>, |001>, |010>, |011>, |100>, |101>, |110>, |111>. The bit of each quantum state corresponds to the quantum bit. For example, in the |000> state, 000 corresponds to q2q1q0 from high to low, and |> is the Dirac symbol.

[0064] Using a single qubit to illustrate, the logical state of a single qubit It may be in the |0> state, |1> state, or the superposition state of |0> state and |1> state (uncertain state), which can be specifically expressed as Among them, a and b are complex numbers representing the amplitude (probability amplitude) of the quantum state, the square of the amplitude represents the probability, |a| 2 、|b| 2 represents the probability of the |0> state and the |1> state, |a| 2 +|b| 2 =1, in short, the quantum state is a superposition state composed of various eigenstates. When the probability of other states is 0, it is in the only determined eigenstate.

[0065] Bayesian network is a probabilistic graph model. It is a graphical network based on probabilistic reasoning. Bayesian network is a mathematical model based on probabilistic reasoning. Probabilistic reasoning is the process of obtaining other probabilistic information through the information of some variables. Bayesian network based on probabilistic reasoning is proposed to solve the problems of uncertainty and incompleteness. It has great advantages in solving the failures caused by uncertainty and correlation of complex equipment and has been widely used in many fields. Bayesian network itself is an uncertain causal association model. Unlike other decision-making models, it is a probabilistic knowledge expression and reasoning model that visualizes multivariate knowledge graphs. It more accurately contains the causal relationship and conditional correlation between network node variables. Bayesian network has a strong ability to handle uncertainty problems. It uses conditional probability to express the correlation between various information elements. It can learn and reason under limited, incomplete and uncertain information conditions. And it can effectively express and fuse multi-source information. Bayesian theory is an important tool for processing uncertain information. As a probability-based uncertainty reasoning method, Bayesian networks have been used in intelligent systems that process uncertain information and have been successfully used in the fields of medical diagnosis, statistical decision-making, expert systems, learning prediction, etc. These successful applications fully demonstrate that Bayesian network technology is a powerful uncertainty reasoning method.

[0066] See also Figure 2 , Figure 2 A schematic flow chart of a method for constructing a quantum circuit corresponding to a Bayesian network provided in an embodiment of the present invention may include the following steps:

[0067] S201: Acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes.

[0068] Specifically, the target network (target Bayesian network) can be a complex random system with multiple nodes, most of which have no direct causal relationship, and the causal relationship between directly related nodes is unidirectional, and there is no node that can advance to itself along the unidirectional causal relationship. Therefore, the target network is a complex random system that can more intuitively show a node that is discrete, sparse, and has a unidirectional causal relationship without a loop.

[0069] Preferably, to obtain each node contained in the target network and the causal relationship between the nodes, the causal relationship between all root nodes and non-root nodes in each node can be obtained first, wherein the causal relationship between non-root nodes can include the pointing relationship between nodes and the conditional probability distribution of each state when the node contains several states.

[0070] For example, a target network containing four nodes A, B, C, and D is obtained, and the specific directional relationship between the nodes is: A→B→C→D, where the root node A contains two states, and the probability of each state is 50%. The above example only uses the root node to illustrate the several states contained in the node and the conditional probability distribution of each state. The states contained in the remaining nodes and the corresponding conditional probability distribution are not expanded here, but it should be noted that the sum of the probability distribution corresponding to each node state is 1.

[0071] S202: For a root node among the nodes, construct a first sub-quantum circuit for preparing a superposition state of quantum bits, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: various states of the root node and their probability distribution.

[0072] Specifically, the first step of constructing the first sub-quantum circuit is to initialize the corresponding quantum bits of all root nodes, that is, to complete the superposition state preparation of the corresponding quantum bits according to the probability distribution of the root nodes, which specifically includes the following steps:

[0073] S2021: Determine, based on the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the preset number of quantum logic gates as a second number.

[0074] Specifically, according to the state number M of the root node, the required first number m of quantum bits can be determined, where: The top bracket represents rounding up; according to the state number M of the root node, the required second number D of preset quantum logic gates can also be determined, where D=M-1.

[0075] S2022: Determine the parameters of the preset quantum logic gate according to the probability distribution of the root node.

[0076] Specifically, according to the probability distribution of the root node, the parameters of the preset quantum logic gate are determined. The preset quantum logic gate used is preferably a rotation logic gate RY gate, and its matrix form is:

[0077]

[0078] Quantum logic gate RY gate implementation:

[0079] RY(θ)|0>=cos(θ / 2)|0>+sin(θ / 2)|1>

[0080] Among them, determining the parameters of the preset quantum logic gate is to determine the parameters θ of the RY gate.

[0081] For example, assume that there is a 4-state root node A, denoted as

[0082]

[0083] where ∑p ij 2 =1, p ij 2 is the probability of occurrence of different states of the root node A.

[0084] That is, the first number of quantum bits required to encode the state of the root node is 2, and the second number of quantum logic gates is 3.

[0085]

[0086] remember

[0087]

[0088]

[0089] Therefore, the idea of ​​the specific encoding root node corresponding to the quantum circuit is to split it from top to bottom and implement it with a series of controlled rotating gates (controlled RY gates). The specific implementation process includes:

[0090] First, the probabilities corresponding to the four states of the root node are divided into two groups, one group is (P 00 , P 01 ), and the other group is (P 10 , P 11 ). The root of the sum of the squares of the two probabilities of each group is used as the amplitude value to encode the amplitude of the quantum state of the first quantum bit, and the encoded final state is obtained, that is:

[0091]

[0092] At this time, after the first equal division, the RY gate is applied to the first quantum bit, that is:

[0093]

[0094] Available, That is to say, by setting the value of θ1, the above-mentioned amplitude value encoding can be achieved, and the specific value of the rotation angle θ of the RY gate in the following figure can be determined in the same way.

[0095] Continuing with the second step of data splitting, 4 groups of data will be obtained, realizing the amplitude encoding of 2 quantum bits and a total of 4 quantum states, and obtaining:

[0096]

[0097]

[0098] S2023: Constructing a first sub-quantum circuit for encoding the state of the root node and its probability distribution according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

[0099] Specifically, following the above example, using 2 quantum bits and 3 preset quantum logic gates, that is, the specific value of the rotation angle θ of the confirmed RY gate, we can obtain Figure 3 The schematic diagram of the first sub-quantum circuit of the state of the encoding root node and its probability distribution is shown. In order to vividly show the control of the quantum logic gate RY gate, the hollow circle in the diagram of this application represents 0 control, indicating that when the quantum state of the quantum bit is 0, the RY(θ2) quantum logic gate will be executed; the solid black circle represents 1 control, indicating that when the quantum state of the quantum bit is 1, the RY(θ3) quantum logic gate will be executed, and the lines between the circles represent control.

[0100] It should be noted that if the root node contains only 2 states, only one quantum bit is required; if the root node contains more than 2 states, a group of quantum bits is required, and in order to save computing resources, the specific number of a group of quantum bits is determined according to the number of states.

[0101] Exemplarily, assuming that there is an 8-state root node A, similarly, at this time, the first number of quantum bits required to encode the state of the root node is 3, and the second number of preset quantum logic gates is 7. The specific implementation process includes:

[0102] First, the probabilities corresponding to the eight states of the root node are divided into two groups, one of which is (P 000 , P 001 , P 010 , P 011 ), and the other group is (P 100 , P 101 , P 110 , P 111 ). The root of the sum of the squares of the two probabilities of each group is used as the amplitude value to encode the amplitude of the quantum state of the first quantum bit, and the encoded final state is obtained, that is:

[0103]

[0104] Secondly, the two groups of data obtained in the above steps are further split to obtain 4 groups of data, each with two data, that is, (P 000 , P 001 )、(P 010 , P 011 )、(P 100 , P 101 )、(P 110 , P 111) 4 sets of data. The root of the sum of the squares of each set of data is used as the amplitude value and encoded into the 4 amplitudes of the first two quantum bits. We get:

[0105]

[0106]

[0107] Finally, the third step of data splitting will obtain eight groups of data, realizing the encoding of 3 quantum bits and a total of 8 quantum states, and obtaining:

[0108] |000>→P 000 |000>+P 001 |001>

[0109] |010>→P 010 |010>+P 011 |011>

[0110] |100>→P 100 |100>+P 101 |101>

[0111] |110>→P 110 |110>+P 111 |111>

[0112] At this time, after the third equal division, for the amplitude encoding of the eight data, the output contains the final quantum state of the eight quantum states encoded on the three quantum bits. The values ​​of the parameters θ1 to θ7 of the RY gate can be derived by the same logic as the root node example of the 2-bit, 4-state example above, and finally the following is obtained: Figure 4 A schematic diagram of the first sub-quantum circuit of another encoding root node state and its probability distribution is shown.

[0113] S203: For every two nodes having a causal relationship among the nodes, respectively construct a second sub-quantum circuit corresponding to the causal relationship and used for encoding the conditional probability.

[0114] Specifically, for every two nodes having a causal relationship in each node, a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability is constructed, specifically including:

[0115] 1. Determine a cause node and a result node among the two nodes having a causal relationship;

[0116] Specifically, determine the nodes that have a causal relationship between each other among all nodes, that is, there is a unidirectional pointing relationship and conditional probability between two nodes. For example, if node A points to node B, and node B does not point to node A, then nodes A and B are said to have a causal relationship, and A is the cause node and B is the result node.

[0117] 2. Constructing quantum logic gate combinations that are applied to the result nodes when the cause nodes take different states respectively;

[0118] For example, assuming that there is a cause node A in M ​​state that unidirectionally determines a result node B in K state, the causal relationship between nodes AB can be decomposed into different amplitude encoding processes for B when A takes different states, and the following is obtained: Figure 5 The schematic diagram of quantum circuit for constructing causal relationship between nodes provided by this embodiment is shown. In the figure, the PreA module represents the initialization quantum circuit related to node A, and the A0B, A1B modules and the subsequent ellipsis represent the quantum logic gate combination of A applied to B in different states.

[0119] It should be noted that Figure 5 Only A0B when A = 0 and A1B when A = 1 are shown. Each controlled quantum gate combination AiB (0≤i≤M-1) can be regarded as a small root node initialized amplitude coded quantum circuit, and the number of controlled quantum gate combinations AiB is equal to the number of states of node A.

[0120] 3. Construct a second sub-quantum circuit corresponding to the causal relationship according to the conditional probabilities between each combination of the quantum logic gates, the cause nodes and the result nodes.

[0121] For example, there is a 4-state cause node A that unidirectionally determines a 4-state result node B. The causal relationship between nodes A and B is decomposed into different amplitude encoding processes for B when A takes different states, and the following is obtained: Figure 6 A schematic diagram of the second sub-quantum circuit corresponding to a causal relationship between nodes is shown, wherein the A0B module represents the quantum logic gate combination applied by A to B in the first state, and the remaining A1B, A2B, and A3B represent the quantum logic gate combinations applied by A to B in the remaining different states.

[0122] It should be noted that the quantum logic gate combinations of modules A0B, A1B, A2B and A3B are all the same, and only the specific values ​​and controlled states of the rotation angles θ of the various RY gates are different.

[0123] S204: Obtain a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

[0124] Specifically, the first sub-quantum circuit and the second sub-quantum circuit are combined in sequence to obtain a quantum circuit corresponding to the target network.

[0125] Exemplarily, following the above example, the first sub-quantum circuit representing the four states of the coding root node and their probability distribution is combined with the above second sub-quantum circuit in sequence to obtain the following: Figure 7 A schematic diagram of a quantum circuit corresponding to a target network is shown.

[0126] After obtaining the quantum circuit corresponding to the target network, it can also include:

[0127] A target node is selected, and a final quantum state of a quantum bit corresponding to the target node is measured and output, wherein the amplitude of the final quantum state corresponds to the probability distribution of the target node.

[0128] Specifically, each node in the target network corresponds to one or a group of quantum bits, and each edge corresponds to a group of quantum logic gates. The output of the target network depends on the measurement of the quantum bits in the quantum circuit. The probability distribution of the target network nodes can be obtained by measuring the combination of quantum bits corresponding to all or some nodes.

[0129] For example, if the quantum bits corresponding to all nodes are selected for measurement and the results are output, the global state probability distribution can be obtained by analyzing the results.

[0130] Compared with the prior art, the present invention obtains each node included in the target network and the causal relationship between the nodes, constructs a first sub-quantum circuit for preparing the superposition state of quantum bits for the root node in each node, and constructs a second sub-quantum circuit corresponding to the causal relationship and used to encode conditional probability for every two nodes with a causal relationship in each node. According to the first sub-quantum circuit and the second sub-quantum circuit, a quantum circuit corresponding to the target network is obtained. The present invention realizes a quantum implementation method of a Bayesian network, which can reduce the computational complexity of the Bayesian network, realize efficient computing, and utilize the superposition characteristics of quantum states to realize processing supporting large-scale multi-node network models with less storage and computing resources.

[0131] See also Figure 8 , Figure 8 A schematic diagram of a structure of a Bayesian network corresponding to a quantum circuit provided by an embodiment of the present invention, and Figure 2 Corresponding to the process shown, the device may include:

[0132] The acquisition module 801 is used to acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes;

[0133] A first construction module 802 is used to construct a first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node among the nodes, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution;

[0134] A second construction module 803 is used to construct, for each two nodes having a causal relationship among the nodes, a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability;

[0135] The obtaining module 804 is used to obtain the quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

[0136] Preferably, the first construction module comprises:

[0137] A first determining unit is used to determine, according to the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the number of preset quantum logic gates as a second number;

[0138] A second determining unit, configured to determine the parameters of the preset quantum logic gate according to the probability distribution of the root node;

[0139] A first construction unit is used to construct a first sub-quantum circuit for encoding the state of the root node and its probability distribution according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

[0140] Preferably, the second construction module comprises:

[0141] A third determining unit, used to determine a cause node and a result node of the two nodes having a causal relationship;

[0142] A construction unit, used to respectively construct a combination of quantum logic gates applied to the result node when the cause node takes different states;

[0143] The second construction unit is used to construct a second sub-quantum circuit corresponding to the causal relationship according to the conditional probabilities between each combination of the quantum logic gates, the cause nodes and the result nodes.

[0144] Preferably, the obtaining module comprises:

[0145] A combining unit is used to combine the first sub-quantum circuit and the second sub-quantum circuit in sequence to obtain a quantum circuit corresponding to the target network.

[0146] Preferably, the obtaining module further includes:

[0147] An output unit is used to select a target node, measure and output a final quantum state of a quantum bit corresponding to the target node, wherein the amplitude of the final quantum state corresponds to the probability distribution of the target node.

[0148] Compared with the prior art, the present invention obtains each node included in the target network and the causal relationship between the nodes, constructs a first sub-quantum circuit for preparing the superposition state of quantum bits for the root node in each node, and constructs a second sub-quantum circuit corresponding to the causal relationship and used to encode conditional probability for every two nodes with a causal relationship in each node. According to the first sub-quantum circuit and the second sub-quantum circuit, a quantum circuit corresponding to the target network is obtained. The present invention realizes a quantum implementation method of a Bayesian network, which can reduce the computational complexity of the Bayesian network, realize efficient computing, and utilize the superposition characteristics of quantum states to realize processing supporting large-scale multi-node network models with less storage and computing resources.

[0149] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0150] Specifically, in this embodiment, the above storage medium may be configured to store a computer program for performing the following steps:

[0151] S201: Acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes;

[0152] S202: for a root node among the nodes, construct a first sub-quantum circuit for preparing a superposition state of a quantum bit, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution;

[0153] S203: for each two nodes having a causal relationship among the nodes, respectively construct a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability;

[0154] S204: Obtain a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

[0155] Compared with the prior art, the present invention obtains each node included in the target network and the causal relationship between the nodes, constructs a first sub-quantum circuit for preparing the superposition state of quantum bits for the root node in each node, and constructs a second sub-quantum circuit corresponding to the causal relationship and used to encode conditional probability for every two nodes with a causal relationship in each node. According to the first sub-quantum circuit and the second sub-quantum circuit, a quantum circuit corresponding to the target network is obtained. The present invention realizes a quantum implementation method of a Bayesian network, which can reduce the computational complexity of the Bayesian network, realize efficient computing, and utilize the superposition characteristics of quantum states to realize processing supporting large-scale multi-node network models with less storage and computing resources.

[0156] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0157] Specifically, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0158] Specifically, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0159] S201: Acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes;

[0160] S202: for a root node among the nodes, construct a first sub-quantum circuit for preparing a superposition state of a quantum bit, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution;

[0161] S203: for each two nodes having a causal relationship among the nodes, respectively construct a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability;

[0162] S204: Obtain a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

[0163] Compared with the prior art, the present invention obtains each node included in the target network and the causal relationship between the nodes, constructs a first sub-quantum circuit for preparing the superposition state of quantum bits for the root node in each node, and constructs a second sub-quantum circuit corresponding to the causal relationship and used to encode conditional probability for every two nodes with a causal relationship in each node. According to the first sub-quantum circuit and the second sub-quantum circuit, a quantum circuit corresponding to the target network is obtained. The present invention realizes a quantum implementation method of a Bayesian network, which can reduce the computational complexity of the Bayesian network, realize efficient computing, and utilize the superposition characteristics of quantum states to realize processing supporting large-scale multi-node network models with less storage and computing resources.

[0164] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the drawings. Any changes made according to the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the protection scope of the present invention.

Claims

1. A method for constructing a quantum circuit corresponding to a Bayesian network, characterized in that: The method comprises: Obtaining each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes; For a root node among the nodes, construct a first sub-quantum circuit for preparing a superposition state of a quantum bit, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution; For every two nodes with a causal relationship among the nodes, a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability is constructed respectively; wherein the method for constructing the second sub-quantum circuit includes: determining a cause node and a result node among the two nodes with a causal relationship; respectively constructing a quantum logic gate combination applied to the result node when the cause node takes different states, wherein the quantum logic gate combination is used to encode the node state and probability distribution of a node based on two quantum bits; and constructing the second sub-quantum circuit corresponding to the causal relationship according to the conditional probability distribution between each of the quantum logic gate combinations, the cause node and the result node; A quantum circuit corresponding to the target network is obtained according to the first sub-quantum circuit and the second sub-quantum circuit.

2. The method according to claim 1, characterized in that: The step of constructing a first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node among the nodes includes: Determine, according to the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the number of preset quantum logic gates as a second number; Determining parameters of the preset quantum logic gate according to the probability distribution of the root node; A first sub-quantum circuit for encoding the state of the root node and its probability distribution is constructed according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

3. The method according to claim 1, characterized in that The quantum logic gate combination includes a first parameter-containing RY gate acting on a first quantum bit, and a second parameter-containing RY gate and a third parameter-containing RY gate acting on a second quantum bit in sequence, wherein the second parameter-containing RY gate is controlled by the |O> state of the first quantum bit after the first parameter-containing RY gate acts, and the third parameter-containing RY gate is controlled by the |1> state of the first quantum bit after the first parameter-containing RY gate acts.

4. The method according to claim 3, characterized in that The step of obtaining a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit includes: The first sub-quantum circuit and the second sub-quantum circuit are combined in sequence to obtain a quantum circuit corresponding to the target network.

5. The method according to claim 1, characterized in that The step of obtaining the quantum circuit corresponding to the target network further includes: A target node is selected, and a final quantum state of a quantum bit corresponding to the target node is measured and output, wherein the amplitude of the final quantum state corresponds to the probability distribution of the target node.

6. The method according to claim 2, characterized in that The quantum logic gate comprises a rotation logic gate.

7. A device for constructing a quantum circuit corresponding to a Bayesian network, characterized in that: The device comprises: The acquisition module is used to acquire each node included in the target network and the causal relationship between the nodes; wherein the causal relationship includes: conditional probability between the nodes; A first construction module is used to construct a first sub-quantum circuit for preparing a superposition state of a quantum bit for a root node among the nodes, wherein one node corresponds to one or a group of quantum bits, and the superposition state includes: each state of the root node and its probability distribution; A second construction module is used to construct, for each two nodes with a causal relationship among the nodes, a second sub-quantum circuit corresponding to the causal relationship and used to encode the conditional probability; wherein the method for constructing the second sub-quantum circuit includes: determining a cause node and a result node among the two nodes with a causal relationship; respectively constructing a quantum logic gate combination applied to the result node when the cause node takes different states, wherein the quantum logic gate combination is used to encode the node state and probability distribution of a node based on two quantum bits; and constructing the second sub-quantum circuit corresponding to the causal relationship according to the conditional probability distribution between each of the quantum logic gate combinations, the cause node and the result node; An obtaining module is used to obtain a quantum circuit corresponding to the target network according to the first sub-quantum circuit and the second sub-quantum circuit.

8. The device according to claim 7, characterized in that The first construction module comprises: A first determining unit is used to determine, according to the number of states of the root node, the number of quantum bits required to encode the state of the root node as a first number, and the number of preset quantum logic gates as a second number; A second determining unit, configured to determine the parameters of the preset quantum logic gate according to the probability distribution of the root node; A first construction unit is used to construct a first sub-quantum circuit for encoding the state of the root node and its probability distribution according to the first number of quantum bits, the second number of preset quantum logic gates, and parameters of the preset quantum logic gates.

9. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 6 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 6.