Quantum circuit generation method and system

CN115361115BActive Publication Date: 2026-09-08BEIJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210772991.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-30
Publication Date
2026-09-08
Estimated Expiration
2042-06-30

AI Technical Summary

Technical Problem

[0004]现有的量子电路设计方法往往只能在低量子比特规模下有较优解,一旦量子电路规模扩大,构建逻辑函数和量子电路的映射关系所使用的经典计算机算力开销将变得无法接受

Benefits of technology

[0016] The quantum circuit generation method and system provided by this invention proposes a quantum circuit generation method based on quantum Karnaugh maps, building upon Karnaugh maps for classical digital circuits. This method has good scalability and can efficiently and automatically generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles, making the generation of quantum circuits as simple as possible.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115361115B_ABST
    Figure CN115361115B_ABST
Patent Text Reader

Abstract

The application provides a quantum circuit generation method and system, the method comprising: converting a quantum Karnaugh map of each variable in a logic function into a corresponding identity quantum Karnaugh map according to an exchange rule; obtaining a sub quantum circuit in a conversion process of the quantum Karnaugh map into the corresponding identity quantum Karnaugh map; and obtaining a quantum circuit of the logic function or the permutation matrix according to the corresponding sub quantum circuit of each variable. The system executes the method. The application proposes a quantum circuit generation method based on a quantum Karnaugh map on the basis of a Karnaugh map on a classical digital circuit, has good scalability, can efficiently automatically generate a corresponding quantum circuit for logic functions or permutation matrices of different scales and different styles, and makes the generation of the quantum circuit as simple as possible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantum computing technology, and in particular to a method and system for generating quantum circuits. Background Technology

[0002] Deploying adjacency matrices onto quantum circuits involves decomposing them into the product of permutation and phase-reversal matrices. Then, a corresponding sub-quantum circuit is designed for each permutation matrix using quantum circuit design methods. The results obtained using these methods are typically superior to those obtained by directly using Hamiltonian decomposition. These efficient quantum circuit design methods balance the computational overhead of classical computers with the complexity of quantum circuits corresponding to permutation matrices.

[0003] Existing quantum circuit design methods include direct truth table solving, permutation group method, adjacency matrix method, template method, and Reed-Muller expansion method. These quantum circuit construction methods are usually designed for specific logic functions, such as adders, multipliers, and decoders, and are extended to higher bits by stacking.

[0004] Existing quantum circuit design methods often only yield relatively good solutions at low qubit scales. As the scale of quantum circuits increases, the computational overhead of classical computers required to construct the mapping relationship between logic functions and quantum circuits becomes unacceptable. Especially when dealing with adjacency matrices, the permutation matrices obtained from the decomposition are diverse, and the corresponding invertible logic circuits may contain some irrelevant terms. Invertible circuit design algorithms such as truth tables, permutation groups, and RM expansions require obtaining the global state of the invertible function before they can be computed. Summary of the Invention

[0005] The quantum circuit generation method and system provided by this invention are used to solve at least one of the above-mentioned problems in the prior art. Based on Karnaugh maps on classical digital circuits, a quantum circuit generation method based on quantum Karnaugh maps is proposed. It has good scalability and can efficiently generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles, making the generation of quantum circuits as simple as possible.

[0006] This invention provides a method for generating quantum circuits, comprising: According to the commutation rule, the quantum Karnaugh map of each variable in the logic function is converted into the corresponding identity quantum Karnaugh map; Obtain the sub-quantum circuit in the conversion process of the quantum Karnaugh map into the corresponding identity quantum Karnaugh map; Based on the sub-quantum circuit corresponding to each variable, obtain the quantum circuit of the logic function or the permutation matrix.

[0007] According to a quantum circuit generation method provided by the present invention, the quantum Karnaugh map of each variable in the logic function or permutation matrix is ​​determined in the following manner: Determine the permutation matrix corresponding to the logical function; The quantum Karnaugh map is determined based on the column and row indices of the permutation matrix; wherein the column and row indices of the permutation matrix are determined based on the input and output values. The row and column indices of the quantum Karnaugh map are arranged in binary order and follow Gray code encoding rules.

[0008] According to a quantum circuit generation method provided by the present invention, the... Determining the permutation matrix corresponding to the logical function includes: When the logic function is an irreversible logic function, after converting the irreversible logic function into the reversible logic function, the permutation matrix corresponding to the converted irreversible logic function is determined according to the mapping relationship between the input value and the output value of each variable in the converted irreversible logic function. When the logic function is the invertible logic function, the permutation matrix corresponding to the invertible logic function is determined according to the mapping relationship between the input value and the output value of each variable in the invertible logic function.

[0009] According to a quantum circuit generation method provided by the present invention, the step of converting the quantum Karnaugh map of each variable in the logic function into the corresponding identity quantum Karnaugh map according to the commutation rule includes: Determine the first target column and the second target column in the quantum Karnaugh map; According to the row swapping rule, the values ​​of the first row and the second row in the first target column are swapped to determine the identity quantum Karnaugh map corresponding to the quantum Karnaugh map; According to the column swapping rule, the values ​​of the second row in the second target column are swapped to determine the identity quantum Karnaugh map corresponding to the quantum Karnaugh map; The first target column includes a first column and a second column; The second target column includes the third and fourth columns; The value of the first row in the first column is a first preset value, and the value of the second row is a second preset value or an auxiliary quantum bit; The value of the first row of the second column is the auxiliary quantum bit, and the value of the second row is the second preset value; The values ​​of the first and second rows of the third column are both the first preset values; The values ​​of the first and second rows of the fourth column are both the second preset values; The swap rules include the row swap rules and the column swap rules.

[0010] A quantum circuit generation method according to the present invention further includes: Determine each candidate column in the quantum Karnaugh map whose Hamming distance to the first target column is equal to a third preset value; Filter out the third target column from the candidate columns, where the values ​​in the first and second rows are the same; Add the third target column to the first target column and update the first target column.

[0011] According to a quantum circuit generation method provided by the present invention, the step of obtaining the quantum circuit of the logic function or the permutation matrix based on the sub-quantum circuit corresponding to each variable includes: The sub-quantum circuits corresponding to each variable are connected sequentially to obtain the quantum circuit.

[0012] The present invention also provides a quantum circuit generation system, comprising: a first acquisition module, a second acquisition module, and a third acquisition module; The first acquisition module is used to convert the quantum Karnaugh map of each variable in the logic function into the corresponding identity quantum Karnaugh map according to the exchange rule; The second acquisition module is used to acquire the sub-quantum circuit in the conversion process of the quantum Karnaugh map into the corresponding identity quantum Karnaugh map; The third acquisition module is used to acquire the quantum circuit of the logic function or the permutation matrix based on the sub-quantum circuit corresponding to each variable.

[0013] The present invention also provides an electronic device, including a processor and a memory storing a computer program, wherein the processor executes the program to implement the quantum circuit generation method described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the quantum circuit generation method as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the quantum circuit generation method as described above.

[0016] The quantum circuit generation method and system provided by this invention proposes a quantum circuit generation method based on quantum Karnaugh maps, building upon Karnaugh maps for classical digital circuits. This method has good scalability and can efficiently and automatically generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles, making the generation of quantum circuits as simple as possible. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the quantum circuit generation method provided by the present invention; Figure 2 This is a schematic diagram illustrating the mapping process between the permutation matrix and the three-variable truth table provided by the present invention; Figure 3 This invention provides four different quantum wires and one generalized Toffoli quantum gate; Figure 4 This is a schematic diagram of a universally applicable quantum Karnaugh map transformation provided by the present invention; Figure 5 This invention provides a quantum Karnaugh map after converting an irreversible logic function into a reversible logic function; Figure 6 This is a schematic diagram of the row swapping rules provided by the present invention; Figure 7 This is a schematic diagram of the column swapping rules provided by the present invention; Figure 8 This is a schematic diagram of the passive exchange rule provided by the present invention; Figure 9 This is a schematic diagram illustrating the optimization of the quantum Karnaugh map provided by the present invention; Figure 10 This is an optimized schematic diagram of a pair of generalized Toffoli gates with a Hamming distance of 1 provided by the present invention; Figure 11 This is an optimized schematic diagram of a pair of generalized Toffoli gates with a Hamming distance of 2 provided by the present invention; Figure 12 This is a schematic diagram of a pair of interchangeable generalized Toffoli gates provided by the present invention; Figure 13 This is a schematic diagram of the quantum circuit generation system provided by the present invention; Figure 14 This is a schematic diagram of the physical structure of the electronic device provided by the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0020] This invention provides a quantum circuit generation method that addresses the problem of generating corresponding quantum circuits for arbitrary logic functions or permutation matrices. It generates quantum circuits based on quantum Karnaugh maps (QKM). Existing reversible quantum circuit design methods often only yield optimal solutions at low qubit scales. Once the scale of quantum circuits increases, the computational overhead required to construct the mapping relationship between logic functions or permutation matrices and quantum circuits becomes unacceptable. Furthermore, existing methods are inadequate when logic functions are irreversible (i.e., multiple inputs correspond to the same output) or when permutation matrices are powers of 2. Therefore, based on the shortcomings of current quantum circuit design schemes and inspired by Karnaugh maps in classical digital circuits, this invention proposes a quantum circuit generation method based on quantum Karnaugh maps. This method has good scalability and can efficiently and automatically generate corresponding quantum circuits for logic functions / permutation matrices of different sizes and styles. It can also be further combined with existing quantum circuit optimization methods to ensure that the quantum circuits are as simple as possible. The specific implementation is as follows: Figure 1 This is a flowchart illustrating the quantum circuit generation method provided by the present invention, as shown below. Figure 1 As shown, the method includes: Step 100: According to the commutation rule, convert the quantum Karnaugh map of each variable in the logic function into the corresponding identity quantum Karnaugh map; Step 200: Obtain the sub-quantum circuit in the conversion process of quantum Karnaugh map into corresponding identity quantum Karnaugh map; Step 300: Obtain the quantum circuit of the logic function or permutation matrix based on the sub-quantum circuit corresponding to each variable.

[0021] It should be noted that the above method can be implemented by computer equipment.

[0022] Optionally, in step 100, a logic function can be viewed as a process of transforming a Boolean variable from input to output according to certain rules. When there is a one-to-one correspondence between the input and output, this mapping is called a reversible logic function because it can deduce the input from the output (conversely, multiple inputs corresponding to the same output are called an irreversible logic function). The Boolean values ​​of each variable are considered as a dimension of... A column vector, for example: For a single variable: There are 2! cases (which can be understood as the number of reversible logical functions), namely: The arrows here refer to a certain logical function.

[0023] The corresponding column vector can be written as: For ease of writing, Dirac notation is used to represent column vectors, i.e.: ; .

[0024] Here, the arrows correspond to a matrix transformation. We can see that to achieve the above column vector transformation, we only need to multiply the input vector by a permutation matrix (i.e., a matrix where each row and column has only one element equal to 1). These are: Similarly, for two variables, There are 4! cases, which can be understood as the number of invertible logical functions or permutation matrices. And so on, for... There are 10 variables, totaling 100 variables. A number of different invertible logic functions or permutation matrices. Indicates in In a dimensional column vector, the th One element is equal to 1, and the rest are equal to 0.

[0025] like Figure 2 The table shows the truth table of the output column vector obtained by right-multiplying a permutation matrix by a column vector. According to the matrix multiplication rule, the column index of a permutation matrix corresponds to its input value, while the row index corresponds to its output value. This establishes an equivalence relationship between invertible logic functions and permutation matrices; that is, for any invertible logic function, there can always be a permutation matrix that implements the same mapping relationship.

[0026] Obtain the quantum Karnaugh map corresponding to the logic function or permutation matrix.

[0027] Definition 1: Qubit Line: There are 4 types of qubit lines; Positive Control Line: such as Figure 3 of As shown, if '0' is input on this qubit line, the value of the target line will not change. If '1' is input, the other positive / negative control lines determine whether the value on the target line is reversed. If there are no other control lines, the value of the target line is reversed, and the values ​​of the control lines will not change.

[0028] Negative Control Line: such as Figure 3 of As shown, if '1' is input on this qubit line, the value of the target line will not change. If the input is '0', the value on the target line is determined by other positive / negative control lines. If there are no other control lines, the value of the target line will be reversed, and the values ​​of the control lines will not change.

[0029] Target Line: such as Figure 3 of As shown, whether the value of the target line changes depends on the input value of the control line.

[0030] Irrelevant line: such as Figure 3 of As shown, the values ​​of unrelated rows remain unchanged from beginning to end and do not affect other rows.

[0031] According to the commutation rule, the quantum Karnaugh map of each variable in the logic function or permutation matrix is ​​converted into the corresponding identity quantum Karnaugh map, and the sub-quantum circuit in the conversion process of quantum Karnaugh map to corresponding identity quantum Karnaugh map is obtained.

[0032] Based on the sub-quantum circuits of all the variables obtained, the quantum circuits of the logic functions can be obtained.

[0033] The quantum circuit generation method provided by this invention proposes a quantum circuit generation method based on quantum Karnaugh maps, which has good scalability and can efficiently generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles, making the generation of quantum circuits as simple as possible.

[0034] Furthermore, in one embodiment, the quantum Karnaugh map of each variable in the logic function or permutation matrix in step 100 is determined as follows: Step 1001: Determine the permutation matrix corresponding to the logic function; Step 1002: Determine the quantum Karnaugh map based on the column and row indices of the permutation matrix; The column and row indices of the permutation matrix are determined based on the input and output values. The row and column indices of the quantum Karnaugh map are arranged in binary order and follow Gray code encoding rules.

[0035] Furthermore, in one embodiment, step 1001 may specifically include: Step 10011: When the logic function is an irreversible logic function, after converting the irreversible logic function into an irreversible logic function, determine the permutation matrix corresponding to the converted irreversible logic function based on the mapping relationship between the input value and the output value of each variable in the converted irreversible logic function. Step 10012: When the logic function is an invertible logic function, determine the permutation matrix corresponding to the invertible logic function based on the mapping relationship between the input value and the output value of each variable in the invertible logic function.

[0036] Optionally, in a place with In a quantum system with 10 qubits, a generalized Tooffoli gate spans... The generalized Tooffoli gate is represented as qubits. ,in, This represents the set of control bit lines (including positive and negative control lines), i.e. ; Indicates the target bit line, i.e. ; This represents an uncorrelated line, and the value of each element in the set is the index of the qubit. The length of the set The sum of the lengths of the control line and the target line is: For ease of description, positive control lines, negative control lines, target lines, and irrelevant lines are represented by '1', '0', '_', and '*', respectively. A function is used... To map the generalized Tooffoli gate on the qubit line The value of '0' or '1'; '_'; '*'. For example, such as Figure 3 As shown, a generalized Tooffoli gate spans four qubit lines and can be denoted as: '10_*'.

[0037] Logic functions generally include reversible logic functions and irreversible logic functions. If a logic function has... Given several variables, the logical function can be expressed as: ,in A function whose input and output are Boolean values, respectively, and whose input and output values ​​satisfy a one-to-one correspondence, is called a reversible logic function. Invertible logic function with one variable Equivalent to a permutation matrix In this type of matrix, each row and column has only one element with a value of 1, while all other elements have a value of 0. There is a one-to-one correspondence between the indices of the non-zero elements in each row and column. .

[0038] If a logic function has Given several variables, the logical function can be expressed as: ,in A function whose input and output are Boolean values, and which exhibits a many-to-one relationship between input and output values, is called an irreversible logic function. The matrix corresponding to an irreversible logic function is a non-unitary matrix, meaning that some rows and columns have multiple non-zero elements, while others have no non-zero elements. To ensure unitarity, a matrix containing... A quantum system with 100 qubits is used to perform... An irreversible logical function of variables, where The number of auxiliary bits. Assume a maximum of [number of occurrences]. If the same input corresponds to the same output value, then at least... One auxiliary bit.

[0039] For a person with Invertible logic function with one variable (It can also be equivalent to a permutation matrix) For example, it is necessary to... The input value is transformed into Each output value requires bit-by-bit transformation. That is, m logical functions need to be found. This is equivalent to the original invertible logic function. This is equivalent to finding m permutation matrices. The product of the products is equivalent to the final permutation matrix. The transformation process is shown in the following equation: It should be noted that the above transformation process is based on the cost function of the generalized Toffoli gate, which is determined by the ease with which the generalized Toffoli gate can be implemented in quantum devices. Table 1 shows the cost functions corresponding to the generalized Toffoli gate. This indicates that the number of control bits in a generalized Toffoli gate is m.

[0040] Table 1 Following the above idea of ​​bit-by-bit transformation, it is necessary to construct... Zhang Quantum Karnaugh Map. And according to the... A quantum Karnaugh map can be used for invertible logic functions. The corresponding permutation matrix Find the corresponding sub-quantum circuit. The quantum Karnaugh map of the k-th bit transformation is as follows: Figure 4 As shown, to facilitate subsequent operations, the values ​​of the remaining m-1 bits are placed in a column (totaling...). There are 3 different values, that is, the quantum Karnaugh map has 10 different values. The k-th value is placed in the row (there are two possible values, hence two rows). The cells of the quantum Karnaugh map are filled with the output value of the k-th bit when the input value is the corresponding row and column value. The row and column indices are arranged in binary and follow Gray code encoding rules (there are multiple arrangements that can satisfy Gray code requirements). The ultimate goal is to... Figure 4 The quantum Karnaugh map in subgraph (b) is transformed by exchange into Figure 4 The form of subgraph (a) in the diagram. For any invertible logic function / permutation matrix, the number of '0's and '1's in the quantum Karnaugh map is the same, therefore, by the commutation rule, it is always possible to... Figure 4 Subgraph (b) in the middle is transformed into Figure 4 The form of the subgraph (a) in the diagram.

[0041] It should be noted that the cell represents the output result based on the current bit of the input qubit. Figure 4 Subgraph (a) in the diagram is the identity quantum Karnaugh map. Figure 4 Subgraph (b) in the text is or Quantum Karnaugh maps.

[0042] Gray code: An encoding method that requires adjacent binary strings to have only one different bit. Gray code can be used as an index in a quantum Karnaugh map. In a quantum Karnaugh map, there is more than one permutation that satisfies the Gray code requirement.

[0043] To generate quantum circuits from irreversible logic functions, additional auxiliary qubits are needed to transform the many-to-one mapping into a one-to-one mapping. The number of auxiliary qubits... It depends on the maximum number of repetitions of the same output. If the maximum number of repetitions is... Then at least There are auxiliary bits. For example, there is an irreversible Boolean function. The maximum number of repetitions of the same output is 2, therefore an auxiliary qubit is needed to transform an irreversible Boolean function into a reversible Boolean function, i.e. The first one is the auxiliary qubit.

[0044] The irreversible logic function is converted into a reversible logic function using the above method. Based on the mapping relationship between the input and output values ​​of each variable in the converted irreversible logic function, the permutation matrix corresponding to the converted irreversible logic function is obtained.

[0045] Adding auxiliary qubits introduces some uncorrelated terms. Uncorrelated terms mean that the logic function is satisfied regardless of whether its output is '0' or '1'. These uncorrelated terms are also reflected in the quantum Karnaugh map. Figure 5 The function was displayed. All quantum Karnaugh maps. Auxiliary qubits '?' are used to fill in cells with irrelevant entries. Similarly, by... Figure 5 In the quantum Karnaugh map shown, all '0's are located in the first row, all '1's are located in the second row, and the position of '?' is unrestricted; '?' can be either '0' or '1', thus completing the conversion from a quantum Karnaugh map to an identity quantum Karnaugh map.

[0046] The quantum circuit generation method provided by this invention can generate reversible quantum circuits from permutation matrices of reversible logic functions, irreversible logic functions (i.e., multiple inputs corresponding to the same output), or integer powers other than 2.

[0047] Furthermore, in one embodiment, step 100 may specifically include: Step 1003: Determine the first target column and the second target column in the quantum Karnaugh map; Step 1004: According to the row swapping rule, swap the values ​​of the first row and the second row in the first target column to determine the identity quantum Karnaugh map corresponding to the quantum Karnaugh map; Step 1005: According to the column swapping rule, swap the values ​​in the second row of the second target column to determine the identity quantum Karnaugh map corresponding to the quantum Karnaugh map; The first target column includes a first column and a second column; The second target column includes the third and fourth columns; The value of the first row in the first column is the first preset value, and the value of the second row is the second preset value or an auxiliary quantum bit; The values ​​in the first row of the second column are auxiliary qubits, and the values ​​in the second row are the second preset values; The values ​​in the first and second rows of the third column are both the first preset values; The values ​​in the first and second rows of the fourth column are both the second preset values; The swap rules include row swap rules and column swap rules.

[0048] Alternatively, in any column of a quantum Karnaugh map, there are three possible cases: 1. The values ​​of the first and second rows of a column are ('0', '1'), ('0', '?'), and ('?', '1').

[0049] 2. The values ​​of the first and second rows of a certain column are ('1', '0'), ('1', '?'), and ('?', '0').

[0050] 3. The values ​​of the first and second rows of a certain column are ('0', '0') and ('1', '1').

[0051] For the first case, no action is taken. For the second and third cases, the following exchange rules apply.

[0052] Row swapping rule: For the second case above, corresponding to the first target column, in the k-th quantum Karnaugh map, mark the first target column, which includes the first column and the second column. The value of the first row of the first column is the first preset value ('1') and the value of the second row is the second preset value ('0') or the auxiliary qubit ('?'); the value of the first row of the second column is the auxiliary qubit ('?') and the value of the second row is the second preset value ('0'). Swap the two marked cells in the same column to become the first case.

[0053] During the switching process, corresponding circuits are generated, namely several generalized Tooffoli gates, using simple... Let C be the index of the column that needs to be row-swapped; T be the k-th qubit; and R be an empty set. Figure 6 This demonstrates the process of mapping the operation of swapping the first and second row marker cells in the same column of the first target column to a quantum gate.

[0054] in, Figure 6 The left subgraph in the diagram is a quantum Karnaugh map, in which column indices represent the values ​​of the control qubits and row indices represent the values ​​of the target qubits. The values ​​in the first row of cells are swapped with the values ​​in the second row of cells. Figure 6 The right subgraph in the diagram represents the corresponding generated sub-quantum circuit.

[0055] Column swapping rules: For the third case above, corresponding to the second target column, each column has only one marked cell. That is, the values ​​of the first and second rows in the third column of the second target column are both the first preset value ('1'), and the values ​​of the first and second rows in the fourth column of the second target column are both the second preset value ('0'). Select a pair of columns with all '0's and '1's and the closest Hamming distance, and swap the values ​​of the cells in the second row. Figure 7 (The cells '1000' and '1010' were swapped.) Record the bits with different values ​​in these two columns and assign these bits to a set. The other cells in the second row are also swapped in pairs, as shown in the following formula: Among them, the function Indicates that belonging to the set of The bits in the array are inverted. The above operation corresponds to several generalized Toffoli gates (also called CNOT gates), and the number of generalized Toffoli gates is equal to the Hamming distance between these two columns (i.e., the set). (the number of elements in the qubit), and the control qubit is the first A set of qubits, the target qubit being the qubit corresponding to an element in the set. After the above operations, the newly generated [number]th [item]... Zhang's quantum Karnaugh map must have some sequences that satisfy the second condition. Figure 7 A quantum Karnaugh map of a 4-qubit system is shown.

[0056] In the column swapping rule, the column index represents the value of the control qubit, and the row index represents the value of the target qubit. This quantum Karnaugh map shows the set of bits with different values ​​in the two columns that are swapped. .

[0057] Among them, the Hamming distance of the generalized Toffoli gate pair: in a given... In a quantum system with n qubits, there exists a pair of generalized Tooffoli gates, denoted as and When the preconditions are met. and At that time, the Hamming distance of the generalized Toffoli gate equal to the control line The quantity, of which , As shown in the following formula: In addition, whenever the When a quantum Karnaugh map performs a swap operation, other quantum Karnaugh maps passively follow suit and perform swap operations without requiring additional quantum gates. The index of the swap unit is the same across all quantum Karnaugh maps. Figure 8 A 3-qubit quantum Karnaugh map is shown as an example illustrating the passive swapping rule. The first map performs the swapping operation, as shown... Figure 8 As shown in the middle sub-image, image 0 (e.g.) Figure 8 (as shown in the left sub-image) and the second image (as shown in the image below) Figure 8 (As shown in the right sub-figure) Quantum Karnaugh maps also passively perform swap operations. The cells that need to be swapped in these three quantum Karnaugh maps have the same index.

[0058] The quantum circuit generation method provided by this invention converts the quantum Karnaugh map corresponding to the logic function into an identity quantum Karnaugh map based on row and column exchange rules, and generates a quantum circuit. It has good scalability and can efficiently generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles. It overcomes the shortcomings of excessive computational overhead and unacceptable computational cost caused by the increase in the number of qubits.

[0059] Furthermore, in one embodiment, the above method further includes: Determine the candidate columns in the quantum Karnaugh map whose Hamming distance from the first target column is equal to the third preset value; Filter out the third target column from the candidate columns whose values ​​are the same as those in the first and second rows; Add the third target column to the first target column and update the first target column.

[0060] Alternatively, to facilitate the generation of quantum circuits for logic functions on a quantum computer, three optimization methods compatible with quantum Karnaugh maps are proposed here: 1. Circuit Optimization Based on Quantum Karnaugh Map Labels: This section mainly focuses on optimizing the row swapping rules. To reduce the number of control qubits mapped from the quantum Karnaugh map to the generalized Toffoli gate, it is necessary to draw a "circle" that is as large as possible.

[0061] The specific explanation of "circle" is as follows: for the first target column that needs row swapping. (That is, if the two cell values ​​are ('1', '0'), ('1', '?'), or ('?', '0'), determine the relationship between the first target column and the quantum Karnaugh map.) For each candidate column whose Hamming distance is equal to a third preset value (e.g., 1), select the third target column from each candidate column whose values ​​in the first and second rows are the same. (That is, the two cell values ​​are ('0', '0'), ('1', '1'), ('?', '?')), and the third target column is added to the first target column, updating the first target column. At this point, and The different bit becomes an irrelevant entry, thus reducing the control bit by one. Similarly, ... and Treating these two columns as a whole, recursively find two more columns and combine them with the existing ones. and The Hamming distance is also only 1, which reduces the control bit by 1.

[0062] See Figure 9 Initially, it is necessary to use This represents the row swap in column '_001' that occurred in the quantum Karnaugh map. Because it was found... '_001', '_011' Therefore, these two columns can be merged into '_0*1'. Recursively, it was also found that... '_0*1', '_1*1' ('_1*1' is a combination of '_101' and '_111'), therefore, one The door turned into a That is, '_**1'. Among them, the '_011', '_101' and '_111' columns are not affected by row swapping.

[0063] like Figure 9 As shown in the left-middle sub-diagram, column '_001' requires a row swap. Columns '_011', '_101', and '_111' are not affected by the row swap, and since the row swap is performed simultaneously, the corresponding quantum circuit diagram can be simplified. Figure 9 The right-hand sub-diagram shows the original sub-quantum circuit and the optimized sub-quantum circuit, respectively.

[0064] 2. Circuit optimization based on Hamming distance: Obviously, when the Hamming distance... At that time, that is, in the control line The quantity is 1, this pair of generalized Toffoli gates and They can be merged into one door ,in , , ; , , ,like Figure 10 As shown.

[0065] Similarly, when At that time, for this pair of generalized Tofoli gates and Add two identical generalized Toffoli gates , making and This allows us to use the optimization method for generalized Toffoli gate pairs with a Hamming distance of 1, such as... Figure 11 As shown. Following the same line of thought, if necessary, a pair of generalized Toffoli gates with a greater Hamming distance can be simplified.

[0066] 3. Circuit optimization based on the execution order of generalized Toffoli gates: See Figure 12 , in having In a quantum system with 1 qubit, if a pair of generalized Toffoli gates and Two doors are interchangeable if one of the following rules is met.

[0067] (1) and ; (2) and satisfy in, Figure 12 The subgraph (a) in the diagram corresponds to the rule (1) of the commutative generalized Toffoli gate. Figure 12 The subgraph (b) in the diagram corresponds to the rule (2) of the commutative generalized Toffoli gate.

[0068] The quantum circuit generation method provided by this invention optimizes the row swapping rules, making the final generated quantum circuit simpler. At the same time, the quantum circuit generated by this invention can integrate existing quantum circuit optimization methods (such as Hamming distance-based circuit optimization and generalized Toffoli gate execution order-based circuit optimization), thereby making the generated quantum circuit simpler.

[0069] Furthermore, in one embodiment, step 300 may specifically include: Optionally, according to the above exchange rules, the exchange operations of the same column and the same row are continuously and alternately performed until all quantum Karnaugh maps are converted into identity quantum Karnaugh maps. Connecting the sub-quantum circuits corresponding to all identity quantum Karnaugh maps sequentially together yields the quantum circuit corresponding to the given logic function.

[0070] Compared to other quantum circuit design methods that can only provide quantum circuits with a scale of three or four qubits, the quantum circuit generation method provided by this invention can randomly generate 1,000 permutation matrices for each of 5-qubit to 10-qubit systems (i.e., permutation matrix sizes from 32×32 to 1024×1024), and find the corresponding quantum circuits through quantum Karnaugh maps.

[0071] Compared to existing quantum circuit design methods, the quantum circuit generation method provided by this invention can handle larger-scale quantum systems. Furthermore, the quantum circuit generation method provided by this invention is compatible with some commonly used quantum circuit optimization methods. As the number of qubits increases, the difference in quantum circuit complexity before and after optimization becomes more pronounced. As can be seen from the box plot, most quantum gates with a large number of control qubits can be replaced by quantum gates with fewer control qubits, thereby reducing the overall complexity of the quantum circuit.

[0072] In the actual experiment, an Intel(R) Core(TM) i7-4600U CPU with a clock speed of 2.10GHz was used, and Python 3.7 was employed as the programming software to verify the time required to find the corresponding quantum circuit for a reversible logic function / permutation matrix ranging from 5 qubits to 10 qubits. The experiment revealed that as the number of qubits increases, the time required to find the corresponding quantum circuit for the logic function / permutation matrix also gradually increases, with the increase in time being approximately a factor of four with the increase in the number of qubits. Specifically, for a 10-qubit logic function / permutation matrix, the average time required to generate the quantum circuit before optimization was 21.824 seconds, while the average time after optimization was 29.161 seconds, which is considered an acceptable running time.

[0073] The quantum circuit generation method provided by this invention can automatically construct corresponding quantum circuits for reversible or irreversible logic functions / permutation matrices of arbitrary size. It can integrate and be compatible with other quantum circuit optimization methods, and can still be executed efficiently in large-scale / multi-variable scenarios.

[0074] The quantum circuit generation system provided by the present invention is described below. The quantum circuit generation system described below and the quantum circuit generation method described above can be referred to in correspondence.

[0075] Figure 13 This is a schematic diagram of the quantum circuit generation system provided by the present invention, as shown below. Figure 13 As shown, it includes: The first acquisition module 1310, the second acquisition module 1311, and the third acquisition module 1312; The first acquisition module 1310 is used to convert the quantum Karnaugh map of each variable in the logic function into the corresponding identity quantum Karnaugh map according to the exchange rule; The second acquisition module 1311 is used to acquire the sub-quantum circuit in the conversion process of quantum Karnaugh map into corresponding identity quantum Karnaugh map; The third acquisition module 1312 is used to acquire the quantum circuit of the logic function or the permutation matrix according to the sub-quantum circuit corresponding to each variable.

[0076] The quantum circuit generation system provided by this invention proposes a quantum circuit generation method based on quantum Karnaugh maps, building upon Karnaugh maps for classical digital circuits. This method has good scalability and can efficiently and automatically generate corresponding quantum circuits for logic functions or permutation matrices of different sizes and styles, making the generation of quantum circuits as simple as possible.

[0077] Figure 14 This is a schematic diagram of the physical structure of an electronic device provided by the present invention, such as... Figure 14 As shown, the electronic device may include a processor 1410, a communication interface 1411, a memory 1412, and a bus 1413, wherein the processor 1410, the communication interface 1411, and the memory 1412 communicate with each other via the bus 1413. The processor 1410 can call logical instructions in the memory 1412 to execute the following methods: According to the commutation rule, the quantum Karnaugh map of each variable in the logic function is converted into the corresponding identity quantum Karnaugh map; Obtain the sub-quantum circuits in the conversion process of quantum Karnaugh maps into corresponding identity quantum Karnaugh maps; Based on the sub-quantum circuit corresponding to each variable, obtain the quantum circuit of the logic function or permutation matrix.

[0078] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and can be sold or used as independent products. When implemented as a software product, the software product can be stored in a computer-readable storage medium and includes several instructions for causing a computer device to perform all or part of the steps of the methods described in the various embodiments of the present invention. The computer device can be a personal computer, a server, a cloud computing node, or other electronic device with data processing capabilities.

[0079] Furthermore, this invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when these instructions are executed by a computer, the computer can execute the quantum circuit generation method provided in the above-described method embodiments, for example, including: According to the commutation rule, the quantum Karnaugh map of each variable in the logic function is converted into the corresponding identity quantum Karnaugh map; Obtain the sub-quantum circuits in the conversion process of quantum Karnaugh maps into corresponding identity quantum Karnaugh maps; Based on the sub-quantum circuit corresponding to each variable, obtain the quantum circuit of the logic function or permutation matrix.

[0080] On the other hand, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the quantum circuit generation methods provided in the above embodiments, including, for example: According to the commutation rule, the quantum Karnaugh map of each variable in the logic function is converted into the corresponding identity quantum Karnaugh map; Obtain the sub-quantum circuits in the conversion process of quantum Karnaugh maps into corresponding identity quantum Karnaugh maps; Based on the sub-quantum circuit corresponding to each variable, obtain the quantum circuit of the logic function or permutation matrix.

[0081] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0082] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer power supply (which may be a personal computer, server, or network power supply, etc.) to execute the methods described in various embodiments or some parts of the embodiments.

[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating quantum circuits, characterized in that, include: According to the exchange rules, the quantum Karnaugh map of each variable in the logic function or permutation matrix is ​​converted into the corresponding identity quantum Karnaugh map; the quantum Karnaugh map is a Karnaugh map in which the row index and column index are both represented in binary and follow the Gray code encoding rules; the identity quantum Karnaugh map is the one obtained after converting the quantum Karnaugh map according to the exchange rules; the exchange rules include row exchange rules and column exchange rules; the row exchange rules are used to exchange the values ​​of the first row and the second row of each column in the first target column of the quantum Karnaugh map; the column exchange rules are used to exchange the values ​​of the second row in the second target column of the quantum Karnaugh map; the first target column includes a first column and a second column; the value of the first row of the first column is 1 and the value of the second row is 0 or an unrelated item; the value of the first row of the second column is the unrelated item and the value of the second row is 0; the unrelated item is 0 or 1; the second target column includes a third column and a fourth column; the values ​​of the first row and the second row of the third column are both 1, and the values ​​of the first row and the second row of the fourth column are both 0. Obtain the sub-quantum circuit in the conversion process of the quantum Karnaugh map into the corresponding identity quantum Karnaugh map; By sequentially connecting the sub-quantum circuits corresponding to each variable, the quantum circuit of the logic function or the permutation matrix can be obtained.

2. The quantum circuit generation method according to claim 1, characterized in that, The quantum Karnaugh map for each variable in the logic function or permutation matrix is ​​determined as follows: Determine the permutation matrix corresponding to the logical function; The quantum Karnaugh map is determined based on the column and row indices of the permutation matrix; Wherein, the column index of the permutation matrix is ​​determined by the variable input value of the logic function, and the row index is determined by the variable output value of the logic function, wherein the variable input value and the variable output value are both Boolean values ​​of the variable; The row and column indices of the quantum Karnaugh map are arranged in binary order and follow Gray code encoding rules.

3. The quantum circuit generation method according to claim 2, characterized in that, Determining the permutation matrix corresponding to the logical function includes: When the logic function is an irreversible logic function, after converting the irreversible logic function into the reversible logic function, the permutation matrix corresponding to the converted irreversible logic function is determined according to the mapping relationship between the input value and the output value of each variable in the converted irreversible logic function. When the logic function is the invertible logic function, the permutation matrix corresponding to the invertible logic function is determined according to the mapping relationship between the input value and the output value of each variable in the invertible logic function.

4. The quantum circuit generation method according to claim 1, characterized in that, Also includes: Determine the candidate columns in the quantum Karnaugh map whose Hamming distance to the first target column is equal to 1; Filter out the third target column from the candidate columns, where the values ​​in the first and second rows are the same; Add the third target column to the first target column and update the first target column.

5. A quantum circuit generation system, characterized in that, include: The first acquisition module, the second acquisition module, and the third acquisition module; The first acquisition module is used to convert the quantum Karnaugh map of each variable in the logic function or permutation matrix into a corresponding identity quantum Karnaugh map according to the exchange rules. The quantum Karnaugh map is a Karnaugh map where the row and column indices are arranged in binary order and follow Gray code encoding rules. The identity quantum Karnaugh map is obtained after converting the quantum Karnaugh map according to the exchange rules. The exchange rules include row exchange rules and column exchange rules. The row exchange rules are used to exchange the values ​​of the first and second rows of each column in the first target column of the quantum Karnaugh map. The column exchange rules are used to exchange the values ​​of the second row in the second target column of the quantum Karnaugh map. The first target column includes a first column and a second column. The value of the first row of the first column is 1, and the value of the second row is 0 or an unrelated item. The value of the first row of the second column is the unrelated item, and the value of the second row is 0. The unrelated item is 0 or 1. The second target column includes a third column and a fourth column. The values ​​of the first and second rows of the third column are both 1, and the values ​​of the first and second rows of the fourth column are both 0. The second acquisition module is used to acquire the sub-quantum circuit in the conversion process of the quantum Karnaugh map into the corresponding identity quantum Karnaugh map; The third acquisition module is used to sequentially connect the sub-quantum circuits corresponding to each variable to acquire the quantum circuit of the logic function or the permutation matrix.

6. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the quantum circuit generation method according to any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the quantum circuit generation method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the quantum circuit generation method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for performing a quantum algorithm to simulate a genetic algorithm

    US20080140749A1

  • Quantum karnaugh map

    US20110138344A1