A method and system for constructing a shallow quantum circuit of a hamming weight calculation and a symmetric boolean function, a terminal and a storage medium
Patent Information
- Application Number
- CN202611103063.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-23
AI Technical Summary
[0006]本发明的主要目的在于提供一种汉明权重计算与对称布尔函数的浅层量子线路构建方法、系统、终端及计算机可读存储介质,旨在解决现有技术中汉明权重计算和对称布尔函数的量子线路构造方法在低线路深度与少辅助量子比特开销之间难以兼顾,且无法有效适配具有几何连接约束的量子硬件拓扑结构的问题
[0017]本发明的有益效果为:通过将输入量子比特划分为多个数据块并对各数据块并行执行局部汉明权重计算,该方法的线路深度不再随输入规模线性增长,而是由单个数据块的计算深度主导。各数据块的局部汉明权重以带权二进制量子比特形式展开并输入可逆加权求和模块进行汇总,使得局部计算与全局求和两个阶段解耦,数据块大小作为可调参数能够在线路深度与辅助量子比特数量之间形成折中。可逆加权求和模块对带权二进制量子比特执行求和计算,将全局汉明权重写入重量寄存器后,通过在重量寄存器上执行对称布尔函数值计算,将汉明权重计算与具体函数计算解耦,同一汉明权重计算结果可复用于多种对称布尔函数的预言机构造。反向执行正向过程中各操作的可逆逆操作,能够清除中间计算产生的临时信息并恢复辅助量子比特状态,同时保持输入寄存器状态不变。该反计算机制保证了中间寄存器和辅助量子比特的可复用性,使得整个线路模块可直接嵌入更大规模量子算法中而无需额外清理开销。整体上,该方法在全连接模型下能够实现对数级线路深度,在二维最近邻模型下通过将数据块布置于局部计算区域并路由至汇总区域,能够避免全连接线路直接映射所带来的额外路由开销,实现平方根量级线路深度。
Smart Images

Figure CN122965710A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum computing technology, and in particular to a method, system, terminal, and computer-readable storage medium for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions. Background Technology
[0002] Quantum algorithms are typically implemented using quantum circuits. The circuit depth is limited by the coherence time of the qubits and the gate operation errors, while the number of auxiliary qubits is constrained by the size of the quantum processor. Therefore, implementing fundamental quantum computing subroutines with lower circuit depth and less auxiliary qubit overhead is a crucial problem in quantum circuit optimization.
[0003] Hamming weight calculation is a fundamental subroutine in quantum computing used to count the number of bits with a value of 1 in an input bit string. It can be applied to tasks such as quantum counting, Hamming distance calculation, quantum machine learning, quantum state preparation, and quantum oracle construction. Hamming weight calculation can also be used to implement symmetric Boolean functions (including OR, AND, parity, majority, threshold, and exact counting functions). If the input Hamming weights can be calculated efficiently, quantum circuits for various symmetric Boolean functions can be further constructed.
[0004] Existing Hamming weighting and symmetric Boolean function quantum circuits still have limitations in terms of resource overhead. Some methods require fewer auxiliary qubits but have greater circuit depth, while others can reduce circuit depth but require a large number of auxiliary qubits. Furthermore, existing constructions are primarily designed for fully connected qubit models, assuming that two-qubit gates can be directly applied between any two qubits. However, in two-dimensional nearest-neighbor quantum processors, two-qubit gates can only operate on adjacent qubits; directly mapping fully connected circuits introduces additional routing overhead and increases circuit depth.
[0005] Therefore, existing technologies still need to be improved and developed. Summary of the Invention
[0006] The main objective of this invention is to provide a method, system, terminal, and computer-readable storage medium for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions. This aims to solve the problem that existing quantum circuit construction methods using Hamming weight calculation and symmetric Boolean functions struggle to balance low circuit depth and minimal auxiliary qubit overhead, and are unable to effectively adapt to quantum hardware topologies with geometric connection constraints.
[0007] To achieve the above objectives, this invention provides a method for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions. This method includes the following steps: Divide the multiple input qubits in the input register into multiple data blocks; For each data block, a local Hamming weight is calculated, and the local Hamming weight corresponding to each data block is written into the local weight register corresponding to that data block to obtain the local Hamming weight corresponding to each data block. Each of the local Hamming weights is expanded into multiple qubits with fixed binary weights; All the qubits with fixed binary weights are input to the reversible weighted summation module for summation calculation to obtain the global Hamming weight of the input register, and the global Hamming weight is written into the weight register; The global Hamming weight is calculated on the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight, and the symmetric Boolean function value is written into the target qubit. The quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation are executed in reverse order, clearing the information in the registers involved in the intermediate calculations, while keeping the state of the input register unchanged.
[0008] Furthermore, the step of dividing the multiple input qubits in the input register into multiple data blocks specifically includes: Obtain the total number of bits in the input register, and calculate the number of data blocks required to divide the input register into the data blocks based on the total number of bits; All input qubits in the input register are sequentially divided into the data blocks according to the number of data blocks.
[0009] Further, the step of calculating the local Hamming weight for each data block and writing the local Hamming weight corresponding to each data block into the local weight register corresponding to that data block to obtain the local Hamming weight for each data block specifically includes: A local weight register is allocated to each of the data blocks; The local weight register is initialized to a zero state, and a quantum Fourier transform is applied to the local weight register to obtain the superposition state encoding of the local weight register; A controlled phase rotation operation is performed on each input qubit in the data block and each qubit in the local weight register, and the number of input qubits with a value of 1 in the data block is encoded as the phase information in the local weight register. An inverse quantum Fourier transform is applied to the local weight register to decode the phase information into binary values, thereby obtaining the local Hamming weights of the data block.
[0010] Furthermore, the step of expanding each of the local Hamming weights into multiple qubits with fixed binary weights specifically includes: Obtain the binary representation of the local Hamming weight stored in each of the local weight registers, wherein the binary representation contains multiple binary bits; Each binary bit in the binary representation is output as a qubit with a fixed binary weight.
[0011] Furthermore, the step of summing all the qubits with fixed binary weights into a reversible weighted summation module to obtain the global Hamming weight of the input register, and writing the global Hamming weight into the weight register, specifically includes: Input all the qubits with fixed binary weights into the reversible weighted summation module; In the reversible weighted summation module, a summation calculation is performed on all the qubits with fixed binary weights to obtain the binary representation of the global Hamming weights of the input register, and the binary representation of the global Hamming weights is written into the weight register.
[0012] Further, the step of calculating the global Hamming weight on the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight, and writing the symmetric Boolean function value into the target qubit, specifically includes: Obtain the global Hamming weight stored in the weight register, and perform a function value calculation operation corresponding to the symmetric Boolean function on the global Hamming weight in the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight; Write the symmetric Boolean function value into the target qubit.
[0013] Furthermore, the reverse execution of the local Hamming weight calculation, expansion into qubits, and weighted summation processes, clearing the information in the registers involved in the intermediate calculations, and maintaining the state of the input registers unchanged, specifically includes: Following the reverse order of the quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation, the inverse operations of each quantum gate operation are applied sequentially to clear the information in the registers involved in the intermediate calculations. After confirming that the state of the input register is consistent with the initial state, the state of the input register remains unchanged, and the inverse calculation process ends.
[0014] Furthermore, to achieve the above objectives, the present invention also provides a shallow quantum circuit construction system for Hamming weight calculation and symmetric Boolean functions. This system is used to implement the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean functions as described above. The system comprises: The input block module is used to divide multiple input qubits in the input register into multiple data blocks; The local calculation module is used to perform local Hamming weight calculation on each data block, write the local Hamming weight corresponding to each data block into the local weight register corresponding to the data block, and obtain the local Hamming weight corresponding to each data block. The weight expansion module is used to expand each of the local Hamming weights into multiple qubits with fixed binary weights; The global summation module is used to sum all the qubits with fixed binary weights into the reversible weighted summation module to obtain the global Hamming weight of the input register, and write the global Hamming weight into the weight register. The function computation module is used to calculate the global Hamming weight on the weight register, obtain the symmetric Boolean function value determined by the global Hamming weight, and write the symmetric Boolean function value into the target qubit; The reverse clearing module is used to reverse the execution of the local Hamming weight calculation, expansion into qubits, and weighted summation process, clearing the information in the registers involved in the intermediate calculation, and keeping the state of the input register unchanged.
[0015] Furthermore, to achieve the above objectives, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a Hamming weight calculation and shallow quantum circuit construction program for symmetric Boolean functions stored in the memory and executable on the processor, wherein when the Hamming weight calculation and shallow quantum circuit construction program for symmetric Boolean functions is executed by the processor, it implements the steps of the Hamming weight calculation and shallow quantum circuit construction method for symmetric Boolean functions as described above.
[0016] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean function, wherein when the shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean function is executed by a processor, it implements the steps of the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function as described above.
[0017] The beneficial effects of this invention are as follows: By dividing the input qubits into multiple data blocks and performing local Hamming weight calculations in parallel on each data block, the circuit depth no longer increases linearly with the input size, but is dominated by the computational depth of a single data block. The local Hamming weights of each data block are expanded in the form of weighted binary qubits and input into a reversible weighted summation module for aggregation, thus decoupling the local computation and global summation stages. The data block size, as an adjustable parameter, can strike a trade-off between circuit depth and the number of auxiliary qubits. The reversible weighted summation module performs summation calculations on the weighted binary qubits, writes the global Hamming weights into the weight register, and then decouples the Hamming weight calculation from the specific function calculation by performing symmetric Boolean function value calculations on the weight register. The same Hamming weight calculation result can be reused in the oracle construction of various symmetric Boolean functions. Reversing the reversible inverse operations of each operation in the forward process can clear the temporary information generated by intermediate calculations and restore the state of the auxiliary qubits, while keeping the state of the input register unchanged. This anti-computation mechanism ensures the reusability of intermediate registers and auxiliary qubits, allowing the entire circuit module to be directly embedded into larger-scale quantum algorithms without additional cleanup overhead. Overall, this method achieves logarithmic circuit depth in the fully connected model, and in the two-dimensional nearest neighbor model, by arranging data blocks in local computation regions and routing them to the summarizing region, it avoids the additional routing overhead caused by direct mapping of fully connected circuits, achieving a square root-level circuit depth. Attached Figure Description
[0018] Figure 1 This is a flowchart of a preferred embodiment of the method for constructing shallow quantum circuits using Hamming weights and symmetric Boolean functions according to the present invention; Figure 2 This is the overall flowchart of the shallow quantum circuit construction method based on Hamming weight calculation and symmetric Boolean function of the present invention; Figure 3 This is a block diagram of the segmented Hamming weight calculation under the fully connected qubit model of the shallow quantum circuit construction method of Hamming weight calculation and symmetric Boolean function of the present invention; Figure 4 This is a layout diagram of the local computation region and the summary region under the two-dimensional nearest neighbor qubit model of this invention; Figure 5 This is a schematic diagram of the symmetric Boolean function quantum circuit or oracle mechanism of the present invention; Figure 6 This is a structural diagram of a preferred embodiment of the shallow quantum circuit construction system for Hamming weight calculation and symmetric Boolean functions of the present invention; Figure 7 This is a structural diagram of a preferred embodiment of the terminal of the present invention. Detailed Implementation
[0019] This application provides a method, system, terminal, and storage medium for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions. To make the objectives, technical solutions, and effects of this application clearer and more explicit, the following detailed description, with reference to the accompanying drawings and embodiments, further illustrates this application. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0020] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0021] Furthermore, if the embodiments of this invention involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.
[0022] The preferred embodiment of the present invention describes a shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean functions, such as... Figure 1 As shown, the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function includes the following steps: S10. Divide the multiple input qubits in the input register into multiple data blocks.
[0023] The purpose of this step is to split the input bit string into several smaller subsets, so that the subsequent local Hamming weight calculations can be performed in parallel on multiple data blocks, reducing the complexity of a single calculation and providing a flexible layout basis for subsequent hardware topology adaptation.
[0024] Furthermore, the step of dividing the multiple input qubits in the input register into multiple data blocks specifically includes: S11. Obtain the total number of bits in the input register, and calculate the number of data blocks required to divide the input register into the data blocks based on the total number of bits; S12. All input qubits in the input register are sequentially divided into the data blocks according to the number of data blocks.
[0025] In this embodiment, the input register X contains n input qubits for storing the input bit string x. The total number of bits n in the input register and the preset data block size B are obtained, where B is an adjustable parameter that can be selected based on the target line depth, the number of available auxiliary qubits, and the scale of the quantum processor hardware. Then, the number of data blocks L is calculated based on the total number of bits n and the preset data block size B, where L equals n divided by B and rounded up. All input qubits in the input register X are sequentially divided into data blocks 1 to L according to the number of data blocks L. The first L-1 data blocks each contain B input qubits, and the Lth data block contains all remaining input qubits. If multiple data blocks exist, they are mutually exclusive, and the set of input qubits from all data blocks constitutes the complete input register X. When adapting to a two-dimensional nearest neighbor hardware structure, the position of each data block on the physical grid can be further determined by combining hardware topology information.
[0026] It should be noted that data blocks can have the same size, or they can have different sizes depending on the circuit layout or hardware connection structure. In practical applications, non-uniform block partitioning, hierarchical block partitioning, or adaptive block partitioning methods can also be used, depending on the available area of the quantum hardware, the shape of the two-dimensional layout, the local circuit depth limit, or the number of auxiliary qubits.
[0027] S20. Calculate the local Hamming weight for each data block, and write the local Hamming weight corresponding to each data block into the local weight register corresponding to that data block to obtain the local Hamming weight corresponding to each data block.
[0028] The purpose of this step is to decompose the global Hamming weight calculation task into multiple independent and parallel subtasks. By independently calculating the local Hamming weights within each data block, intermediate results are provided for the subsequent global aggregation. At the same time, since each data block acts on a set of non-overlapping qubits, the local calculations can be executed in parallel to reduce the circuit depth.
[0029] Further, the step of calculating the local Hamming weight for each data block and writing the local Hamming weight corresponding to each data block into the local weight register corresponding to that data block to obtain the local Hamming weight for each data block specifically includes: S21. Allocate a local weight register for each of the data blocks; S22. initializing the local weight register to a zero state, and applying a Quantum Fourier Transform to the local weight register to obtain the superposition state encoding of the local weight register; S23. performing a controlled phase rotation operation on each input qubit in the data block and each qubit in the local weight register, so as to encode the number of input qubits with a value of 1 inside the data block into phase information in the local weight register; S24. applying an inverse Quantum Fourier Transform to the local weight register, to decode the phase information into a binary value, so as to obtain the local Hamming weight of the data block.
[0030] In this embodiment, a corresponding local weight register H_l is provided for each data block, for temporarily storing the local Hamming weight of the data block. For the l-th data block, which contains B_l input qubits, the local weight register H_l contains m_l qubits, where m_l= log2(B_l+1) , and let M_l=2^(m_l). Since the value range of the Hamming weight in the data block is 0 to B_l, and B_l<M_l, no overflow will occur by using the Quantum Fourier Transform encoding modulo M_l.
[0031] The specific gate sequence is as follows. First, S22 is performed to initialize the local weight register to a zero state |0 ^(m_l), and apply an m-qubit Quantum Fourier Transform QFT_(M_l) on this register. The following convention is adopted herein: QFT_(M_l)|h =(1 / √(M_l))∑{k=0}^{M_l-1}exp(2πihk / M_l)|k ; Therefore, QFT(M_l)|0 ^(m_l)=(1 / √(M_l))∑_{k=0}^{M_l-1}|k can be used as the Quantum Fourier Transform encoded state of the weight value 0.
[0032] Then, S23 is executed. For each input qubit x_i (i=1,2,...,B_l) in the data block and each qubit w_j (j=0,1,...,m_l-1) in the local weight register, a two-qubit controlled phase rotation gate is applied. Here, w_j is defined as the binary bit 2^j used to calculate tag k in the quantum Fourier transform encoding, i.e., k=∑{j=0}^{m_l-1}2^j k_j. The gate applied to qubits x_i and w_j is a controlled R(θ_j) gate, where x_i is the control qubit, w_j is the phase-acting qubit, R(θ_j)=diag(1,exp(iθ_j)), and the rotation angle is θ_j=2π·2^j / M_l. This two-qubit gate operates in the ground state |x_i, w_j|. The function of `diag(1,1,1, exp(iθ_j))` is to multiply by the phase `exp(iθ_j)` only when `x_i=1` and `w_j=1`. After performing the above controlled phase rotation for all `i=1,2,...,B_l` and `j=0,1,...,m_l-1`, the state of the local weight register becomes `(1 / √(M_l))∑{k=0}^{M_l-1}exp(2πih_l k / M_l)|k`. Where h_l = x_1 + x_2 + ... + x_(B_l) is the local Hamming weight of the current data block, and this state is precisely QFT_(M_l)|h_l .
[0033] Finally, step S24 is executed, applying an inverse quantum Fourier transform (QFT_(M_l)^(-1)) to the local weight register. This QFT is encoded and decoded into binary form, representing the local Hamming weights h_l, which are then written to the local weight register. At this point, the local Hamming weights for each data block have been calculated and stored in their corresponding local weight registers.
[0034] Since the controlled phase rotation gates mentioned above are all diagonal gates, and the contributions of different input qubits to the same local weight register are superimposed in a phase-cumulative manner, local Hamming weight calculations can be performed in parallel between different data blocks. The circuit size of each data block mainly consists of B_l and m_l = log2(B_l+1) The overall local computation depth is determined by the computation depth of a single data block, and does not increase linearly with the number of data blocks.
[0035] It should be noted that, in addition to the quantum Fourier transform encoding method mentioned above, the calculation of local Hamming weights can also be achieved using other equivalent reversible counting circuits, reversible addition trees, phase accumulation circuits, or lookup table-type local counting circuits.
[0036] S30. Expand each of the local Hamming weights into multiple qubits with fixed binary weights.
[0037] The purpose of this step is to convert the local Hamming weights of each data block from the binary storage format in the local weight register into a weighted binary qubit form that can directly participate in the global weighted summation, so that each local weight can obtain the correct weight coefficient according to its bit position in the binary representation to participate in the subsequent summation.
[0038] Furthermore, the step of expanding each of the local Hamming weights into multiple qubits with fixed binary weights specifically includes: S31. Obtain the binary representation of the local Hamming weight stored in each of the local weight registers, wherein the binary representation contains multiple binary bits; S32. Output each binary bit in the binary representation as a quantum bit with a fixed binary weight.
[0039] In this embodiment, for the local weight register H_l of the l-th data block, the stored local Hamming weight h_l exists in binary form. This binary representation is obtained, containing multiple binary bits. For each binary bit in this representation, it is output as a qubit with a fixed binary weight. Specifically, the local Hamming weight h_l of the l-th data block can be expanded as h_l = ∑{t=0}^{m_l-1} b{l,t}·2^t, where b_{l,t} is a binary bit (taking values of 0 or 1), and 2^t is the corresponding fixed binary weight. Each binary bit b_{l,t} is represented as a qubit, and the weight coefficient of this qubit is 2^t. Thus, the binary bits in all the local weight registers together constitute a set of weighted binary qubits, denoted as the set {(b_{l,t}, weight 2^t)}. These weighted qubits will be input to the subsequent reversible weighted summation module for aggregation calculation.
[0040] It should be noted that if a local weight register has unused high-order qubits (i.e., the number of qubits m_l in the register may be greater than the minimum number of bits required to actually represent the local Hamming weights), these high-order qubits should be in the zero state, and their corresponding weights will contribute zero to the summation process, without affecting the final global Hamming weight result.
[0041] S40. Perform summation calculation on all the qubits with fixed binary weights input to the reversible weighted summation module to obtain the global Hamming weight of the input register, and write the global Hamming weight into the weight register.
[0042] The purpose of this step is to aggregate the weighted binary qubits corresponding to all local weights into a global result, complete the merging calculation from local weights to global Hamming weights, and write the final calculation result into the output register for subsequent use.
[0043] Further, the step of summing all the qubits with fixed binary weights into a reversible weighted summation module to obtain the global Hamming weight of the input register, and writing the global Hamming weight into the weight register, specifically includes: S41. Input all the qubits with fixed binary weights into the reversible weighted summation module; S42. In the reversible weighted summation module, perform summation calculation on all the qubits with fixed binary weights to obtain the binary representation of the global Hamming weights of the input register, and write the binary representation of the global Hamming weights into the weight register.
[0044] In this embodiment, all qubits with fixed binary weights are input into a reversible weighted summation module. The goal of this module is to calculate S = ∑{l=1}^{L}h_l = ∑{l=1}^{L}∑{t=0}^{m_l-1}b{l,t}·2^t, the result of which is the global Hamming weight of the input register X. The reversible weighted summation module is implemented using a reversible carry-save summation structure. In this structure, multiple weighted binary qubits are compressed bit by bit layer by layer. Each layer compresses three binary qubits with the same weight into two binary qubits (one sum bit and one carry bit). After multiple layers of compression, two binary numbers are obtained. These two binary numbers are then added together by a reversible adder to finally obtain the binary representation of the global Hamming weight. This structure is suitable for parallel execution and can reduce the circuit depth required for summing multiple local weights. After obtaining the binary representation of the global Hamming weight, this binary representation is written to the weight register W. The length of the weight register W can be taken as the number of qubits required to represent binary numbers from 0 to n, i.e. log2(n+1) After the write operation is complete, the value stored in the weight register W is equal to the sum of all local Hamming weights, which is the total number of qubits with a value of 1 in the input register X.
[0045] It should be noted that, in addition to the reversible carry-save summation structure mentioned above, the reversible weighted summation module can also use other equivalent reversible weighted summation circuits such as ripple-carry adders, tree-structured reversible adders, quantum Fourier adders, hierarchical compression adders, or lookup table-type weighted summation modules.
[0046] S50. Calculate the global Hamming weight in the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight, and write the symmetric Boolean function value into the target qubit.
[0047] The purpose of this step is to use the calculated global Hamming weights to further construct a quantum oracle that depends only on the input Hamming weights and is a symmetric Boolean function, so that the present invention can serve as a general subroutine for a variety of quantum algorithm tasks.
[0048] Further, the step of calculating the global Hamming weight on the weight register to obtain a symmetric Boolean function value determined by the global Hamming weight, and writing the symmetric Boolean function value into the target qubit, specifically includes: S51. Obtain the global Hamming weight stored in the weight register, and perform a function value calculation operation on the global Hamming weight corresponding to the symmetric Boolean function on the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight. S52. Write the symmetric Boolean function value into the target qubit.
[0049] In this embodiment, for any symmetric Boolean function f, its function value depends only on the Hamming weights of the input bit string x, i.e., there exists a function g such that f(x) = g(|x|), where |x| represents the global Hamming weights of the input bit string x. First, the global Hamming weights |x| stored in the weight register W are obtained. Then, the calculation operation of function g is performed on the weight register W, implemented through reversible Boolean circuits, reversible comparators, threshold judgment circuits, modulo counting judgment circuits, or other equivalent reversible circuits. The input of g is the Hamming weight value stored in the weight register W, and the output is the corresponding function value g(|x|). Finally, the calculation result of g(|x|) is written to the target qubit T. For example, the target qubit T can be transformed from state t to the XOR result of t and g(|x|), thereby realizing the standard quantum oracle form of the symmetric Boolean function f. This process is applicable to various common symmetric Boolean functions, including OR functions, AND functions, parity functions, majority functions, threshold functions, exact counting functions, interval judgment functions, and modulo counting functions. For different functions, only the calculation module of function g needs to be replaced.
[0050] It should be noted that this step can also be used to construct a phase oracle. For a phase oracle, the corresponding phase can be applied to the input state according to g(|x|) through a phase kickback method, without necessarily explicitly writing the function value into the target qubit. Both oracle forms can be obtained by combining the same Hamming weight calculation module and function g calculation module.
[0051] S60. Reverse the local Hamming weight calculation, the expansion into qubits, and the quantum gate operations performed during the weighted summation process, clear the information in the registers involved in the intermediate calculation, and keep the state of the input register unchanged.
[0052] The purpose of this step is to eliminate the temporary information generated during the intermediate calculation process through inverse computation, so that the auxiliary qubit can be restored to the specified initial state or reusable state, while keeping the input register unchanged, thereby obtaining a reversible quantum circuit module that can be directly embedded in larger-scale quantum algorithms.
[0053] Furthermore, the reverse execution of the local Hamming weight calculation, the expansion into qubits, and the quantum gate operations performed during the weighted summation process, clearing the information in the registers participating in the intermediate calculations, and maintaining the state of the input registers unchanged, specifically includes: S61. Following the reverse order of the quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation, the inverse operations of each quantum gate operation are applied sequentially to clear the information in the registers involved in the intermediate calculation. S62. After confirming that the state of the input register is consistent with the initial state, keep the state of the input register unchanged and end the inverse calculation process.
[0054] In this embodiment, after writing the symmetric Boolean function value to the target qubit in step S50, it is necessary to clear all intermediate information generated during the calculation process. Specifically, firstly, the reversible weighted summation process in step S40 is executed in reverse order, that is, the inverse operations of each quantum gate operation are applied sequentially according to the reverse order of the quantum gate operations performed in the weighted summation process to clear the carry information and other intermediate information generated during the weighted summation process. Then, the expansion operation in step S30 is executed in reverse order, that is, the operation of outputting binary bits as weighted qubits is undone. Subsequently, the local Hamming weight calculation process of each data block in step S20 is executed in reverse order, that is, the inverse operations of each quantum gate operation are applied sequentially according to the reverse order of the quantum gate operations performed in the local Hamming weight calculation process to clear the local Hamming weight information in each local weight register. During the reverse calculation process, since all operations are reversible and are strictly executed in reverse order, clearing intermediate information will not affect the global Hamming weight result already written to the weight register W, nor will it affect the function value output already written to the target qubit T. During the inverse computation, the state of the input register X remains unchanged throughout both the forward and reverse computations. Once it is confirmed that the state of the input register X is consistent with its initial state, the state of the input register X is maintained, and the inverse computation process ends. After the inverse computation is complete, the input register X remains unchanged, the weight register W retains the global Hamming weight result (or the target qubit T retains the symmetric Boolean function value result), and the auxiliary qubit is restored to its specified state or reusable state. The entire method realizes a complete reversible quantum circuit transformation.
[0055] It should be noted that in some implementations, inverse calculation can also be achieved by means of staged inverse calculation, real-time inverse calculation in local areas, or clearing local weights and then clearing intermediate summation quantities, depending on the specific circuit structure. As long as the input register can be kept unchanged and the auxiliary qubits can be restored to the specified state in the end.
[0056] Furthermore, the present invention is not limited to two-dimensional square grids. For other quantum hardware connection structures that can simulate two-dimensional nearest neighbor connections with constant or small overhead, such as rectangular grids, hexagonal grids, two-dimensional grids with defects, locally connected superconducting chips, neutral atom arrays, or ion trap partitioning structures, the local computational region and summary region design concept of the present invention can also be adopted for adaptation.
[0057] In the two-dimensional nearest neighbor qubit model embodiment of the present invention, a preparatory step may be included before step S10: obtaining the two-dimensional grid topology of the target quantum processor, determining the position of the input qubit of each data block in the two-dimensional grid according to the two-dimensional grid topology; allocating a local computing region for each data block in the two-dimensional grid, arranging the input qubit of the data block in the corresponding local computing region, and setting a summary region in the two-dimensional grid, which is used to collect the local Hamming weight information of each data block. Before performing the reversible weighted summation in step S40, a routing step may be included: routing the qubits in the local weight registers corresponding to each data block from the local computing region to the summary region along the path in the two-dimensional grid through the SWAP gate operation between adjacent qubits. In step S60, the quantum gate operations performed during the weighted summation and routing process are reversed to clear the intermediate information generated during the routing process and restore the state of the auxiliary qubits.
[0058] right Figures 2 to 5 The explanation is as follows: Figure 2 This is a flowchart illustrating the overall process of the shallow quantum circuit construction method based on Hamming weight calculation and symmetric Boolean functions of this invention. Figure 2 As shown, the input qubits in the input register X first enter the data segmentation stage, where they are divided into several data blocks. Then, local Hamming weight calculations are performed in parallel on each data block to obtain the local weights of each data block. After binary expansion, each local weight enters the reversible weighted summation module for summation calculation to obtain the global Hamming weights, which are then stored in the weight register W. After the results are written, the inverse calculation stage begins, where the quantum gate operations performed during the intermediate calculation process are executed in reverse, the temporary information in the intermediate register A is cleared, and the final results in the input register X and the weight register W remain unchanged.
[0059] Figure 3 This is a block diagram of the segmented Hamming weight calculation under the fully connected qubit model of the shallow quantum circuit construction method of Hamming weight calculation and symmetric Boolean function of this invention. (See diagram for example.) Figure 3 As shown, the input register X is divided into multiple data blocks X1, X2, ..., XL. Each data block enters the corresponding local Hamming weight calculation module to obtain local weights H1, H2, ..., HL. These local weights are then input into a reversible weighted summation module to synthesize the global Hamming weight, which is then written to the weight register W. The data block size B is an adjustable parameter; by adjusting B, a trade-off can be achieved between line depth and the number of auxiliary qubits.
[0060] Figure 4 This is a layout diagram of the local computational region and the summary region under the two-dimensional nearest neighbor qubit model of this invention. For example... Figure 4As shown, the qubits are arranged in a two-dimensional nearest neighbor grid. Each data block and its corresponding local weight register are located in their respective local computation regions (local computation regions 1 to L), and these local computation regions are arranged in an array within the grid. The local weight information calculated in each region is transmitted to the aggregation region through local routing. In the aggregation region, a global weighted summation is performed, and finally, the global Hamming weight is written into the weight register W. This layout is compatible with two-dimensional nearest neighbor hardware structures and avoids the additional routing overhead caused by direct mapping of fully connected lines.
[0061] Figure 5 This is a diagram of the symmetric Boolean function quantum circuit or oracle mechanism of the present invention. For example... Figure 5 As shown, the input register X and weight register W first enter the Hamming weight calculation module, which calculates the Hamming weight |x| of the input bit string x and stores it in W. Then, the calculation module for function g is executed in the weight register W. This module calculates the function value corresponding to the symmetric Boolean function f(x) = g(|x|) and writes the result to the target qubit T. After writing the function value, the relevant calculation modules are executed in reverse, clearing the temporary information in W and the intermediate registers. This construction is suitable for quantum oracle constructions using various symmetric Boolean functions such as OR, AND, parity, majority, and threshold functions.
[0062] The technical advantages of this invention are as follows: by combining input block partitioning, local computation, weighted summation, and inverse computation clearing, an adjustable tradeoff between circuit depth and the number of auxiliary qubits is achieved, while simultaneously adapting to both fully connected and two-dimensional nearest neighbor hardware topologies. In the fully connected qubit model, logarithmic circuit depth and sublinear auxiliary qubit overhead can be achieved by adjusting the data block size B. In the two-dimensional nearest neighbor qubit model, a square root-level circuit depth can be achieved through the two-dimensional layout of local computation regions, phase accumulation, and summarization regions, using only logarithmic or logarithmic polynomial-level auxiliary qubits, avoiding the excessive routing overhead caused by directly mapping the fully connected circuit black box to a two-dimensional grid. In applications such as quantum circuit synthesis, quantum algorithm basic subroutine construction, and quantum oracle circuit optimization, this invention can effectively reduce circuit depth and auxiliary qubit overhead, improving the execution efficiency and hardware compatibility of quantum algorithms.
[0063] Furthermore, such as Figure 6 As shown, based on the above-mentioned method for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions, this invention also provides a system for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions. The system includes: The input block module 51 is used to divide multiple input qubits in the input register into multiple data blocks; Local calculation module 52 is used to perform local Hamming weight calculation on each data block, write the local Hamming weight corresponding to each data block into the local weight register corresponding to the data block, and obtain the local Hamming weight corresponding to each data block. The weight expansion module 53 is used to expand each of the local Hamming weights into multiple qubits with fixed binary weights; The global summation module 54 is used to sum all the qubits with fixed binary weights into the reversible weighted summation module to obtain the global Hamming weight of the input register, and write the global Hamming weight into the weight register. The function calculation module 55 is used to calculate the global Hamming weight on the weight register, obtain the symmetric Boolean function value determined by the global Hamming weight, and write the symmetric Boolean function value into the target qubit; The reverse clearing module 56 is used to reverse the quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation process, clear the information in the registers involved in the intermediate calculation, and keep the state of the input register unchanged.
[0064] Furthermore, such as Figure 7 As shown, based on the above-mentioned Hamming weight calculation and shallow quantum circuit construction method and system of symmetric Boolean function, the present invention also provides a terminal, which includes a processor 10, a memory 20 and a display 30. Figure 7 Only some of the terminal components are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0065] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory. In other embodiments, the memory 20 may be an external storage device of the terminal, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Further, the memory 20 may include both internal and external storage devices. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code installed on the terminal. The memory 20 can also be used to temporarily store data that has been output or will be output. In one embodiment, the memory 20 stores a shallow quantum circuit construction program 40 for Hamming weight calculation and symmetric Boolean functions. This shallow quantum circuit construction program 40 can be executed by the processor 10 to implement the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean functions in this application.
[0066] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in the memory 20 or process data, such as executing the Hamming weight calculation and shallow quantum circuit construction method of symmetric Boolean function.
[0067] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 30 is used to display information on the terminal and to display a visual user interface. The components of the terminal communicate with each other via a system bus.
[0068] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean function, wherein when the shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean function is executed by a processor, it implements the steps of the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function as described above.
[0069] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal. Unless otherwise specified, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or terminal that includes that element.
[0070] Of course, those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0071] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A method for constructing shallow quantum circuits using Hamming weight calculation and symmetric Boolean functions, characterized in that, The method for calculating Hamming weights and constructing shallow quantum circuits using symmetric Boolean functions includes the following steps: Divide the multiple input qubits in the input register into multiple data blocks; For each data block, a local Hamming weight is calculated, and the local Hamming weight corresponding to each data block is written into the local weight register corresponding to that data block to obtain the local Hamming weight corresponding to each data block. Each of the local Hamming weights is expanded into multiple qubits with fixed binary weights; All the qubits with fixed binary weights are input to the reversible weighted summation module for summation calculation to obtain the global Hamming weight of the input register, and the global Hamming weight is written into the weight register; The global Hamming weight is calculated on the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight, and the symmetric Boolean function value is written into the target qubit. The quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation are executed in reverse order, clearing the information in the registers involved in the intermediate calculations, while keeping the state of the input register unchanged.
2. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The process of dividing the multiple input qubits in the input register into multiple data blocks specifically includes: Obtain the total number of bits in the input register, and calculate the number of data blocks required to divide the input register into the data blocks based on the total number of bits; All input qubits in the input register are sequentially divided into the data blocks according to the number of data blocks.
3. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The step of calculating the local Hamming weight for each data block and writing the local Hamming weight corresponding to each data block into the local weight register corresponding to that data block to obtain the local Hamming weight for each data block specifically includes: A local weight register is allocated to each of the data blocks; The local weight register is initialized to a zero state, and a quantum Fourier transform is applied to the local weight register to obtain the superposition state encoding of the local weight register; A controlled phase rotation operation is performed on each input qubit in the data block and each qubit in the local weight register, and the number of input qubits with a value of 1 in the data block is encoded as the phase information in the local weight register. An inverse quantum Fourier transform is applied to the local weight register to decode the phase information into binary values, thereby obtaining the local Hamming weights of the data block.
4. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The step of expanding each of the local Hamming weights into multiple qubits with fixed binary weights specifically includes: Obtain the binary representation of the local Hamming weight stored in each of the local weight registers, wherein the binary representation contains multiple binary bits; Each binary bit in the binary representation is output as a qubit with a fixed binary weight.
5. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The step of summing all the qubits with fixed binary weights into a reversible weighted summation module to obtain the global Hamming weight of the input register, and then writing the global Hamming weight into the weight register, specifically includes: Input all the qubits with fixed binary weights into the reversible weighted summation module; In the reversible weighted summation module, a summation calculation is performed on all the qubits with fixed binary weights to obtain the binary representation of the global Hamming weights of the input register, and the binary representation of the global Hamming weights is written into the weight register.
6. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The step of calculating the global Hamming weight on the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight, and writing the symmetric Boolean function value into the target qubit, specifically includes: Obtain the global Hamming weight stored in the weight register, and perform a function value calculation operation corresponding to the symmetric Boolean function on the global Hamming weight in the weight register to obtain the symmetric Boolean function value determined by the global Hamming weight; Write the symmetric Boolean function value into the target qubit.
7. The shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function according to claim 1, characterized in that, The reverse execution of the quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation, clearing the information in the registers involved in the intermediate calculations, and maintaining the state of the input registers unchanged, specifically includes: Following the reverse order of the quantum gate operations performed during the local Hamming weight calculation, expansion into qubits, and weighted summation, the inverse operations of each quantum gate operation are applied sequentially to clear the information in the registers involved in the intermediate calculations. After confirming that the state of the input register is consistent with the initial state, the state of the input register remains unchanged, and the inverse calculation process ends.
8. A shallow quantum circuit construction system for Hamming weight calculation and symmetric Boolean functions, characterized in that, The Hamming weight calculation and symmetric Boolean function shallow quantum circuit construction system is used to implement the Hamming weight calculation and symmetric Boolean function shallow quantum circuit construction method as described in any one of claims 1-7, wherein the Hamming weight calculation and symmetric Boolean function shallow quantum circuit construction system comprises: The input block module is used to divide multiple input qubits in the input register into multiple data blocks; The local calculation module is used to perform local Hamming weight calculation on each data block, write the local Hamming weight corresponding to each data block into the local weight register corresponding to the data block, and obtain the local Hamming weight corresponding to each data block. The weight expansion module is used to expand each of the local Hamming weights into multiple qubits with fixed binary weights; The global summation module is used to sum all the qubits with fixed binary weights into the reversible weighted summation module to obtain the global Hamming weight of the input register, and write the global Hamming weight into the weight register. The function computation module is used to calculate the global Hamming weight on the weight register, obtain the symmetric Boolean function value determined by the global Hamming weight, and write the symmetric Boolean function value into the target qubit; The reverse clearing module is used to reverse the execution of the local Hamming weight calculation, expansion into qubits, and weighted summation process, clearing the information in the registers involved in the intermediate calculation, and keeping the state of the input register unchanged.
9. A terminal, characterized in that, The terminal includes: a memory, a processor, and a shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean function stored in the memory and executable on the processor. When the Hamming weight calculation and symmetric Boolean function shallow quantum circuit construction program is executed by the processor, it implements the steps of the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean function as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a shallow quantum circuit construction program for Hamming weight calculation and symmetric Boolean functions, which, when executed by a processor, implements the steps of the shallow quantum circuit construction method for Hamming weight calculation and symmetric Boolean functions as described in any one of claims 1-7.