Quantum circuit construction method and apparatus, and device, storage medium and product
By constructing quantum circuit construction methods, including preparing quantum registers, building quantum gates and performing operations, the problem of limited quantum resources is solved and the ability to solve larger-scale computing problems under limited resources is realized.
Patent Information
- Application Number
- PCT/CN2024/138626
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-11
- Filing Date
- 2024-12-11
- Publication Date
- 2025-06-19
AI Technical Summary
The existing quantum computers provide limited quantum resources, which limits the scale of solving problems and the application prospects of quantum circuits.
By constructing a quantum circuit construction method, it includes determining the modulus N and the random number a of the modular function to be solved, preparing the first and second quantum registers, building the Adama gate and the modular multiplication module, performing square operations and constructing a controlled unitary gate, obtaining the entangled state of the quantum register, and performing inverse Fourier transform and measurements to obtain the phase estimation result of the modular function period.
This method implements quantum circuit construction without using auxiliary qubits, saves quantum resources and can solve larger-scale computing problems under limited quantum resources.
Smart Images

Figure CN2024138626_19062025_PF_FP_ABST
Abstract
Description
Quantum circuit construction methods, devices, equipment, storage media and products
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on December 11, 2023, with application number 202311698923.4 and application name “Quantum circuit construction method, device, equipment, storage medium and product”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of data processing technology, and in particular to a quantum circuit construction method, device, equipment, storage medium and product. Background Art
[0003] With the development of quantum computing technology, breakthroughs have been made in the research and development of quantum computers, and the computing power of quantum computing has continued to increase. The use of quantum algorithms to solve difficult problems in classical computing environments has gradually moved from theory to practice.
[0004] Quantum computing will have significant advantages over classical computing in solving certain problems. For example, Shor's algorithm, which can transform difficult mathematical problems into periodic modular function problems, offers exponentially faster performance than existing classical algorithms when factoring large integers.
[0005] As the difficulty of the problems to be solved increases, the difficulty of solving modular functions and the complexity of quantum circuits increase rapidly. Consequently, the required quantum resources, such as the number of qubits, the number of quantum gates, and the depth of quantum circuits, increase rapidly. Currently, the scarcity of quantum resources limits the scale of solvable problems and the potential applications of quantum circuits. Summary of the Invention
[0006] The present application provides a quantum circuit construction method, apparatus, device, storage medium and product, aiming to solve the problem that the scale of solvable problems is limited due to the limited quantum resources that can be provided by quantum computers.
[0007] In a first aspect, the present application provides a method for constructing a quantum circuit, the method comprising: determining a modulus N and a random number a corresponding to a modulus function to be solved; preparing a first quantum register and a second quantum register according to the modulus N; the first quantum register comprising 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n}, where n is the binary expansion length of the modulus N; constructing a Hadamard gate for the quantum initial state of each of the first quantum bits to obtain an equiprobable quantum superposition state of the first quantum register; constructing a first modular multiplication module U for the quantum initial state of the second quantum register based on the modulus N and the random number a a ; On the second quantum register, the first modular multiplication module U a Continuously perform 2n-1 square operations and construct 2n-1 second modular multiplication modules in sequence, which are recorded as Sequentially place multiple first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and multiple second modular multiplication modules As the controlled party, 2n controlled unitary gates are constructed to obtain the entangled state of the first quantum register and the second quantum register; an inverse Fourier transform is performed on the first quantum register, and a measurement circuit is constructed for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
[0008] In a second aspect, the present application provides a quantum circuit construction device, the device comprising: a determination module for determining a modulus N and a random number a corresponding to a modulus function to be solved; a preparation module for preparing a first quantum register and a second quantum register according to the modulus N; the first quantum register comprises 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n}, wherein n is the binary expansion length of the modulus N; a first building block is used to construct a Hadamard gate for the quantum initial state of each of the first quantum bits to obtain an equiprobable quantum superposition state of the first quantum register; a second building block is used to construct a first modular multiplication module U for the quantum initial state of the second quantum register based on the modulus N and the random number a a A first computing module, configured to perform the multiplication of the first modular multiplication module U on the second quantum register a Continuously perform 2n-1 square operations and construct 2n-1 second modular multiplication modules in sequence, which are recorded as The third building block is used to sequentially convert multiple first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and multiple second modular multiplication modules As the controlled party, 2n controlled unitary gates are constructed to obtain the entangled state of the first quantum register and the second quantum register; a measurement module is used to perform an inverse Fourier transform on the first quantum register and construct a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
[0009] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method as described above.
[0010] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the method as described above when executed by a processor.
[0011] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which implements the method described above when executed by a processor.
[0012] In a sixth aspect, the present application provides a quantum computer, which is a superconducting system and is used to implement the method as described above.
[0013] In combination with the above technical solutions, in the quantum circuit construction method, apparatus, device, storage medium and product provided in the present application, the modulus N and random number a corresponding to the modular function to be solved are determined; a first quantum register including 2n first quantum bits and a second quantum register including n first quantum bits are prepared according to the modulus N, where n is the binary expansion length of the modulus N; an equal probability quantum superposition state of the first quantum register is obtained by constructing a Hadamard gate; a first modular multiplication module and 2n-1 second modular multiplication modules are constructed on the second quantum register; multiple first quantum bits are sequentially used as control bits, and the first modular multiplication module and 2n-1 second modular multiplication modules are sequentially used as controlled parties to construct 2n controlled unitary gates to obtain an entangled state of the first quantum register and the second quantum register; an inverse Fourier transform is performed on the first quantum register, and a measurement circuit is constructed for the first quantum register to obtain a phase estimation result corresponding to the modular function period r. The solution of the present application applies n second quantum bits to commonly used quantum gates to construct and encapsulate a first modular multiplication module, and by continuously performing 2n-1 square operations on the first modular multiplication module, 2n-1 second modular multiplication modules are sequentially constructed; 2n controlled unitary gates are set to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain the phase estimation result corresponding to the modular function period r; and this solution can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources provided by quantum computers are limited, it provides support for solving larger-scale computing problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] FIG1 is a schematic diagram of a flow chart of a method for constructing a quantum circuit according to a first embodiment of the present application;
[0015] FIG2 is a schematic diagram of constructing a Adama gate according to Example 1 of the present application;
[0016] FIG3 is a schematic diagram of the construction of a controlled unitary gate provided in Example 1 of the present application;
[0017] FIG4 is a schematic diagram of a switch gate structure provided in Example 1 of the present application;
[0018] FIG5 is a schematic diagram of a Modulo-N processing circuit according to the first embodiment of the present application;
[0019] FIG6 is a flow chart of another method for constructing a quantum circuit according to the first embodiment of the present application;
[0020] FIG7 is a schematic structural diagram of a quantum circuit construction device provided in Example 2 of the present application;
[0021] FIG8 is a schematic diagram of the structure of an electronic device provided in Example 3 of the present application. DETAILED DESCRIPTION
[0022] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0023] It should be noted that the brief descriptions of terms in this application are only for the purpose of facilitating the understanding of the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings.
[0024] In the specification and claims of this application and the drawings, the terms "first," "second," and the like are used to distinguish similar or similar objects or entities and are not necessarily intended to limit a particular order or precedence, unless otherwise indicated. It should be understood that the terms used in this manner are interchangeable where appropriate, for example, enabling implementation in an order other than that shown or described in the drawings or descriptions of the embodiments of this application.
[0025] In addition, the terms "including" and "having" and any variations thereof are intended to cover, but not exclude, inclusion. For example, a product or device comprising a list of components is not necessarily limited to those components explicitly listed, but may include other components not explicitly listed or inherent to such products or devices. The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with the element.
[0026] The term "quantum bit (qubit)" used in various embodiments of this application refers to the basic unit of data in quantum computing. Unlike classical bits, qubits can be in a superposition of states 0 and 1. For example, for a quantum computing system containing m qubits, when all qubits are in a superposition state, the system can simultaneously represent 2 m Quantum computing can be in only one of these states at any given moment. This is why it is so exponentially faster than traditional computing methods.
[0027] With the development of quantum computing technology, breakthroughs in quantum computer development have been made, and quantum computing power continues to increase. The use of quantum algorithms to solve difficult problems in classical computing environments has gradually moved from theory to practice. Quantum computing offers significant advantages over classical computing in solving certain problems. For example, Shor's algorithm offers exponential speedups when factoring large integers compared to existing classical algorithms. Shor's algorithm can transform difficult mathematical problems into problems solving modular function periods.
[0028] In practice, Shor's algorithm rapidly solves classically difficult mathematical problems in three steps: first, convert the mathematical problem into a problem of finding the period of a modular function and determine the modular function; second, apply a quantum algorithm to solve the period of the modular function; and third, determine the solution to the mathematical problem based on the period of the modular function obtained. As the difficulty of the problem increases, the difficulty of solving the modular function period increases rapidly, as does the complexity of the quantum circuit. This increases the quantum resources required, such as the number of qubits, the number of quantum gates, and the depth of the quantum circuit. Currently, existing quantum computers offer limited quantum resources, limiting the scale of problems that can be solved.
[0029] The technical content provided by this application is intended to solve the above-mentioned technical problems in related technologies. In the solution of the embodiment of this application, n second quantum bits are used to construct and encapsulate a first modular multiplication module using commonly used quantum gates. By continuously performing 2n-1 square operations on the first modular multiplication module, 2n-1 second modular multiplication modules are constructed in sequence; and 2n controlled unitary gates are set to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain the phase estimation result corresponding to the modular function period r; In addition, this solution can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0030] The technical solutions of the present application and the technical solutions of the present application are described in detail below with reference to specific embodiments. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in certain embodiments. In the description of the present application, unless otherwise clearly specified and limited, each term should be understood in a broad sense within the art. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0031] FIG1 is a flow chart of a quantum circuit construction method provided in Example 1 of the present application. The execution subject of the quantum circuit construction method can be a quantum circuit construction device. There are many ways to implement the quantum circuit construction device. For example, it can be implemented through a computer program, such as application software, etc.; or, for example, a chip, etc. It can also be implemented as a medium storing relevant computer programs, such as a USB flash drive, a cloud disk, etc.; or it can also be implemented through a physical device integrated or installed with relevant computer programs, such as a server, etc. As shown in FIG1, the method includes the following steps:
[0032] Step 101: Determine the modulus N and random number a corresponding to the modulus function to be solved.
[0033] In practical applications, quantum computing can be used to solve difficult mathematical problems. For example, Shor's algorithm can transform the problem of solving a mathematical problem into the problem of solving the period of a modular function. By using quantum computing to solve the period of the modular function, the solution to the difficult mathematical problem can be obtained based on the period calculation of the modular function obtained. It is understandable that different mathematical problems correspond to different modular functions. Shor's algorithm can be used to determine the modular function to be solved for the mathematical problem to be solved. The process of determining the modular function corresponding to the mathematical problem can be referred to the existing technology and will not be elaborated on here. This solution is applied to solving the period of the modular function.
[0034] In this embodiment, the modular function to be solved can be expressed as f(x):=a x mod N, where x is the independent variable, a is the random number corresponding to the modular function to be solved, and N is the modulus corresponding to the modular function to be solved. Therefore, after obtaining the modular function to be solved using Shor's algorithm, the modular function N and random number a corresponding to the modular function can be determined.
[0035] Step 102: Prepare a first quantum register and a second quantum register according to the modulus N.
[0036] In this embodiment, the first quantum register includes 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n}, where n is the binary expansion length of the modulus N, and a quantum register refers to a set of qubits. Specifically, after determining the modulus N, the modulus N is binary expanded to determine the binary length n of the expanded modulus N. A first quantum register comprising 2n first qubits and a second quantum register comprising n second qubits are prepared.
[0037] Step 103: construct a Hadamard gate for the quantum initial state of each first quantum bit to obtain an equiprobable quantum superposition state of the first quantum register.
[0038] In practical applications, the Hadamard (H) gate can convert a single quantum state into a quantum state with equal probability of |0> and |1>. The matrix form of the Hadamard gate can be expressed as Specifically, when the quantum initial state is |0>, after the Hadamard gate, the output quantum state can be expressed as When the quantum state of the quantum is |1>, after the Hadamard gate, the output quantum state can be expressed as
[0039] In order to understand the specific construction process of the Hadamard gate, an example is given in conjunction with Figure 2. Figure 2 is a schematic diagram of the construction of the Hadamard gate provided in Example 1 of the present application. As shown in Figure 2, in this embodiment, a Hadamard gate is set for each first quantum bit, that is, 2n Hadamard (H) gates are set accordingly. Through the action of the 2n Hadamard gates, the quantum state of each first quantum bit is converted from the quantum initial state to an equiprobable superposition state, thereby obtaining an equiprobable quantum superposition state of the first quantum register.
[0040] Step 104: Construct a first modular multiplication module for the quantum initial state of the second quantum register based on the modulus N and the random number a.
[0041] In this embodiment, the first modular multiplication module is represented by U a , the first modular multiplication module U a It is obtained by constructing and encapsulating the first modular multiplication module U a can be regarded as acting on n second qubits {q 3n-1 ,q 3n-2 ,…q 2n} on the quantum gate, the first modular multiplication module U a The action matrix is n second quantum bits {q 3n-1 ,q 3n-2 ,…q 2n} is the unitary matrix corresponding to .
[0042] Specifically, 2 n -N-1 is binary expanded, and the first expansion is recorded as N n-1 N n-2 ...N0; and perform binary expansion on the random number a to obtain the second expansion, which is recorded as a l-1 a l-2 ...a0. The second quantum bits {q 3n-1 ,q 3n-2 ,…q 2n} and the first expansion Nn-1 N n-2 ...each binary bit in N0 corresponds to each other. Specifically, q 3n-1 The highest bit in the second register corresponds to the highest bit N in the first expansion n-1 ,q 2n The lowest bit in the second register corresponds to the lowest bit N0 in the first expanded expression.
[0043] For the second expansion a l-1 a l-2 ...a0, a0 is the lowest bit, a l-1 As the highest bit, perform the modulo N processing on each binary bit in order from high to low, encapsulate the quantum circuit corresponding to the modulo N processing of each binary bit of the second expansion, and obtain the first modular multiplication module U a Specifically, for a binary bit a in the second expansion i , 0≤i≤l-1, for multiple second quantum bits, perform a cyclic left shift operation in the order from high to low; if a i = 0, then perform a modulo N process on the second quantum register. If a i =1, a second modulo N process is performed on the second quantum register, and, before the second modulo N process, the initial quantum state of the second quantum register is superimposed on the current quantum state of the second quantum register.
[0044] It should be noted that for the highest binary bit a l-1 The corresponding modulo N processing is performed on the quantum initial state of the n second qubits. For the modulo N processing corresponding to the non-highest bit binary bit, the corresponding modulo N processing needs to be performed on the current quantum state of the n second qubits. For example, if a l-2 =1, then in a l-1 After the corresponding modulo N processing is completed, for multiple second quantum bits, a cyclic left shift operation is performed in order from high to low, and two modulo N processings are performed on the quantum states of the n second quantum bits. It should be noted that before the second modulo N processing, the quantum initial state of the second quantum register is superimposed on the current quantum state of the second quantum register. For example, if a l-2 =0, then in a l-1 After the corresponding modulo N processing is completed, a cyclic left shift operation is performed on the multiple second quantum bits in order from high to low, and a modulo N processing is performed on the quantum states of the n second quantum bits.
[0045] In some exemplary techniques, a first modular multiplication module U is constructed a Auxiliary quantum bits need to be set up. In this implementation, the first modular multiplication module U is constructed. aThe first modular multiplication module U can be realized without using auxiliary quantum bits in the process a The construction of this scheme can realize the first modular multiplication module U by applying n second quantum bits a Therefore, quantum resources are saved in this scheme.
[0046] Step 105: Continuously perform 2n-1 square operations on the first modular multiplication module on the second quantum register to sequentially construct 2n-1 second modular multiplication modules.
[0047] Among them, the 2n-1 second modular multiplication modules are recorded as It should be noted that the 2n-1 second modular multiplication modules are located in the first modular multiplication module U a Specifically, the first modular multiplication module U on the second quantum register is a Perform a square operation to obtain the second modular multiplication module The second modular multiplication module on the second quantum register Perform a square operation to obtain the second modular multiplication module It can be understood that the 2n-1 second modular multiplication modules are obtained by performing a square operation on the basis of the previous modular multiplication module. Therefore, the construction of the 2n-1 second modular multiplication modules does not require the preparation of new quantum bits, and can be obtained through conventional square operations, saving quantum resources.
[0048] Step 106: sequentially use the plurality of first quantum bits as control bits, and sequentially use the first modular multiplication module and the plurality of second modular multiplication modules as controlled parties to construct 2n controlled unitary gates, and obtain the entangled state of the first quantum register and the second quantum register.
[0049] The controlled unitary gate (CU gate) is divided into two parts: the control bit (represented by the black dotted line) and the unitary gate (also known as the target bit). If the quantum state of the control bit quantum bit is |1>, the unitary gate acts on the target quantum bit, otherwise it does not act. For example, if the quantum state of the first quantum bit q0 is |e>=c|0>+d|1>, the first modular multiplication module U a The quantum state of the second quantum register on the input side is |Ψ>, the first quantum bit q0 is the control bit, and the first modular multiplication module U a is the controlled party, then the first modular multiplication module U a The quantum state of the second quantum register on the output side is: c|Ψ>+dU a |Ψ>.
[0050] In order to understand the specific construction process of the controlled unitary gate, an example is given in conjunction with FIG3, which is a schematic diagram of the construction of the controlled unitary gate provided in the first embodiment of the present application. As shown in FIG3, a Hadamard gate is set for each first quantum bit to obtain an equal probability quantum superposition state of the first quantum register. The first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and multiple second modular multiplication modules As the controlled party, 2n controlled unitary gates are constructed to obtain the entangled state of the first quantum register and the second quantum register.
[0051] Step 107: Perform inverse Fourier transform on the first quantum register, and construct a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
[0052] Specifically, after constructing 2n controlled unitary gates in step 106, the phase Added to the probability amplitudes of the first qubits in the first quantum register, the quantum state of the first quantum register can be expressed as |W1>. The state to be measured in the first quantum register can be expressed as |W2>, and the relationship between |W2> and |W1> is as follows: |W2> = QFT - |W1>.
[0053] In practical applications, by performing Fourier transform on the first quantum register, the phase on the probability amplitude of each first quantum bit can be stored in the quantum state of each first quantum bit, thereby obtaining the measured state |W2> of the first quantum register. Thus, by measuring the measured quantum state of the first quantum register, the phase estimation result corresponding to the modular function period r can be obtained.
[0054] In practical applications, after constructing the controlled unitary gate, the first quantum register is subjected to an inverse Fourier transform, and a measurement circuit is constructed for the first quantum register. The phase estimation result corresponding to the modular function period r can be measured and obtained. The modular function period r can be calculated based on the phase estimation result. Based on the modular function period r, the solution to the mathematical problem to be solved can be obtained through calculation.
[0055] In this embodiment, n second qubits are constructed and packaged using commonly used quantum gates to obtain a first modular multiplication module U a , by the first modular multiplication module U a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules. 2n controlled unitary gates are set up to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain the phase estimation result corresponding to the modular function period r; moreover, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0056] Furthermore, regarding the first modular multiplication module U a As an example, in a possible implementation, the above step 104 includes:
[0057] 2 n -N-1 is binary expanded to get 2 n -N-1 corresponds to the first expansion is recorded as N n-1 N n-2 ...N0; perform binary expansion on the random number a and obtain the second expansion corresponding to the random number a, which is recorded as a l-1 a l-2 …a0; the plurality of second qubits in the second quantum register correspond one-to-one to each binary bit in the first expansion;
[0058] In descending order, process each binary bit in the second expansion to obtain the first modular multiplication module U a The above-mentioned processing includes: for multiple second quantum bits, constructing exchange gates between adjacent second quantum bits in order from high to low; if the value of the binary bit is 0, performing a modulo N processing on the second quantum register; if the value of the binary bit is 1, performing two modulo N processing on the second quantum register, and before the second modulo N processing, superimposing the quantum initial state of the second quantum register on the current quantum state of the second quantum register; wherein the modulo N processing includes: for the lowest bit N0 of the first expansion, if N0=1, performing a modulo N processing on the second quantum bit q 2n Perform a NOT operation on the second qubit q 2n Overlay 2 n -N-1 times, the second quantum bit q before performing the modulo N processing 3n-1 quantum state.
[0059] Among them, the highest binary bit of the first expansion is N n-1 , corresponding to the second quantum bit q in the second quantum register 3n-1 ; The lowest binary bit of the first expansion is N0, which corresponds to the second quantum bit q in the second quantum register 2n For example, after the second quantum register is prepared in step 102, the n second quantum bits {q3n-1 ,q 3n-2 ,…q 2n The quantum initial state of
[0060] In practical applications, the random number a is an integer less than the modulus N, l is the length of the binary expansion of the random number a, and n is the binary length of the binary expansion of the modulus N. Therefore, l≤n. Among them, the highest binary bit of the second expansion is a l-1 , the lowest binary bit of the second expanded expression is a0. Specifically, in descending order, each binary bit in the second expanded expression is processed to obtain the first modular multiplication module U a , specifically refers to the l-1 a l-2 ...a0, and the processing is performed on each binary bit. It can be understood that the highest binary bit a of the second expansion l-1 The corresponding processing is performed on the quantum initial state of the second quantum sender; the non-highest binary bit a of the second expansion l-2 ...a0, the processing is performed based on the processing corresponding to the previous binary bit. That is, the quantum state of the second register before each binary bit is processed is the quantum state of the second register after the processing of the previous binary bit. For example, after executing the processing corresponding to a1, the processing corresponding to a0 is performed based on this. Accordingly, the quantum state of the second quantum register before executing the processing corresponding to a0 is the quantum state of the second quantum register after executing the processing corresponding to a1.
[0061] In order to understand the specific construction of the exchange gate, the following is an example description in conjunction with Figure 4, which is a schematic diagram of the construction of the exchange gate provided in Example 1 of the present application. As shown in Figure 4, for multiple second quantum bits, the exchange gate is constructed between adjacent second quantum bits in order from high to low. As an example, the quantum state corresponding to n second quantum bits can be recorded as In practical applications, it is possible to realize the second quantum bit q 3n-2 ,…q 2n The quantum state performs ×2 operation and converts the quantum state Superposition to the second quantum bit q 2n At this time, the quantum state corresponding to the n second quantum bits is
[0062] In practical applications, a l-1 a l-2 …The quantum circuit corresponding to the processing of a0 is encapsulated as the first modular multiplication module U a In this embodiment, n second quantum bits are constructed and packaged using commonly used quantum gates to obtain a first modular multiplication module U a, reduces the first modular multiplication module U a The cost of construction, and in this embodiment, the first modular multiplication module U is constructed a The process can be realized without using auxiliary quantum bits, which saves quantum resources. a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules. 2n controlled unitary gates are set up to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain the phase estimation result corresponding to the modular function period r; moreover, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0063] Furthermore, regarding the specific process of Modulo N processing, in one possible implementation, the Modulo N processing includes:
[0064] If N0=1, then for the second quantum bit q 2n Perform a NOT gate operation;
[0065] For the non-least significant N digits of the first expansion j , 1≤j≤n-1, if N j =1, then the second quantum bit q corresponding to the lowest bit N0 of the first expansion among the multiple second quantum bits 2n and the non-lowest bit N j The next N j-1 The corresponding second quantum bit q 2n+j-1 As a control bit, the non-lowest bit N j The corresponding second quantum bit q 2n+j As a controlled bit, a controlled NOT gate is constructed.
[0066] For example, FIG5 is a schematic diagram of the module N processing circuit provided in the first embodiment of the present application. As shown in FIG5, N0=1, then the second quantum bit q 2n Performs a NOT gate operation. N n-1 =1, the second lowest quantum bit q 2n and q n-2 The corresponding second quantum bit q 3n-2 As a control bit, N n-1 The corresponding quantum bit q 3n-1 As a controlled bit, a controlled NOT gate is constructed. It should be noted that for N1, the second quantum bit corresponding to N1 is q 2n+1 , the second quantum bit corresponding to the next bit N0 of N1 is the second quantum bit q 2n, if N1=1, then the second quantum bit q 2n As a control bit, the second quantum bit q corresponding to N1 is 2n+1 As a controlled bit, a controlled NOT gate is constructed.
[0067] It can be understood that for multiple second qubits, after constructing the exchange gates between adjacent second qubits in order from high to low, it is equivalent to cyclically shifting the quantum states of all second qubits to the left, and converting the second qubit q 3n-1 The quantum state Superposition to the second quantum bit q 2n On the quantum bit, on this basis, after the modulo N processing, it is equivalent to converting 2 n -N-1 times the quantum state Superposition on the second quantum bit q 2n On the quantum bit.
[0068] In practical applications, after obtaining the phase estimation result through measurement in step 107, the period r of the modulo function to be solved can be obtained by calculation. As an example, in one possible implementation, after the above step 107, the method further includes:
[0069] The phase estimation result is expanded into a continued fraction to calculate the period r of the modular function.
[0070] Specifically, the phase estimation result satisfies the first inequality Where q = 2 2n ,k=0...,n. By expanding the first inequality into a continued fraction, when the greatest common divisor of k and z is 1, the value of z at this time is taken as the period r of the modular function.
[0071] In practical applications, difficult mathematical problems can be converted into problems for solving modular function periods using Shor's algorithm. As an example, integer decomposition problems can be converted into problems for solving modular function periods using Shor's algorithm. The quantum circuit construction method provided in the above embodiment can be applied to the integer decomposition process. As an example, in one possible implementation, FIG6 is a flow chart of another quantum circuit construction method provided in Example 1 of the present application. As shown in FIG6 , based on the above embodiment, before step 101, the method further includes:
[0072] Step 601: randomly selecting an initial random number that is smaller than the integer to be factored, and calculating the greatest common factor of the initial random number and the integer to be factored;
[0073] Step 602: If the greatest common factor is greater than 1, the greatest common factor is used as a non-trivial factor of the integer to be factored;
[0074] The above step 101 specifically includes:
[0075] Step 603: If the greatest common factor is equal to 1, the integer to be decomposed is used as the modulus N corresponding to the modulus function to be solved, and the initial random number is used as the random number a corresponding to the modulus function to be solved.
[0076] The initial random number is any integer smaller than the integer to be factored. A nontrivial factor is an integer greater than 1 that is divisible by the integer to be factored. In practical applications, factoring an integer is the process of determining two nontrivial factors of the integer to be factored. The product of these two nontrivial factors is the integer to be factored. Therefore, once one nontrivial factor of the integer to be factored is determined, the other nontrivial factor can be determined, and the integer factorization process is complete.
[0077] Specifically, after randomly selecting an initial random number, the greatest common factor of the initial random number and the integer to be factored is calculated using classical mathematical calculation methods. If the greatest common factor is greater than 1, the greatest common factor is used as a non-trivial factor of the integer to be factored, and the integer factorization process ends. If the greatest common factor is equal to 1, the two non-trivial factors of the integer to be factored are solved by solving the period of the modular function. Specifically, if the greatest common factor is equal to 1, the integer to be factored is used as the modular number N corresponding to the modular function to be solved, and the initial random number is used as the random number a corresponding to the modular function to be solved. The modular function is constructed and the quantum circuit construction method shown in the above embodiment is used to solve the two non-trivial factors of the integer to be factored.
[0078] In this embodiment, during the integer factorization process, an initial random number is randomly selected, and the greatest common factor of the initial random number and the integer to be factored is preliminarily calculated using classical calculation methods. A determination is then made as to whether the greatest common factor is greater than 1 to determine whether the greatest common factor is a non-trivial factor of the integer to be factored. When the greatest common factor is equal to 1, the integer factorization problem is converted into a quantum circuit construction problem. This quantum circuit construction method can be used to quickly solve the integer factorization result, thereby improving the efficiency of the integer factorization calculation.
[0079] Furthermore, after calculating the period r of the modular function, two non-trivial factors corresponding to the integer to be decomposed can be obtained by calculation. As an example, in one possible implementation, after step 107, the method further includes:
[0080] If the period r of the modular function is abnormal, then return to the step of randomly selecting an initial random number that is smaller than the integer to be decomposed, and calculating the greatest common factor of the initial random number and the integer to be decomposed; wherein the abnormal period r of the modular function includes: the period r of the modular function is an odd number, or,
[0081] Otherwise, and the first greatest common factor of the integer to be factored, and, and the second greatest common factor of the integer to be decomposed, as the two non-trivial factors corresponding to the integer to be decomposed; wherein the product of the two non-trivial factors is the integer to be decomposed.
[0082] It can be understood that the integer to be decomposed is the modulus N corresponding to the modulus function to be solved. Specifically, the first greatest common factor can be expressed as The second common factor can be expressed as In this embodiment, when the period r of the modular function is normal, two non-trivial factors corresponding to the integer to be decomposed are obtained by calculating the first common factor and the second common factor.
[0083] Among them, when the period r of the modular function is abnormal, the two non-trivial factors corresponding to the integer to be decomposed cannot be calculated. In this embodiment, after calculating the period r of the modular function, it is first determined whether the period r of the modular function is abnormal. When the period r of the modular function is normal, the two non-trivial factors corresponding to the integer to be decomposed are calculated based on the period r, which can ensure the accuracy of the integer decomposition calculation.
[0084] In the quantum circuit construction method provided in this embodiment, the modulus N and the random number a corresponding to the modulus function to be solved are determined; a first quantum register including 2n first quantum bits and a second quantum register including n first quantum bits are prepared according to the modulus N, where n is the binary expansion length of the modulus N; an equiprobable quantum superposition state of the first quantum register is obtained by constructing a Hadamard gate; a first modular multiplication module and 2n-1 second modular multiplication modules are constructed on the second quantum register; multiple first quantum bits are sequentially used as control bits, and the first modular multiplication module and the 2n-1 second modular multiplication modules are sequentially used as controlled parties to construct 2n controlled unitary gates to obtain an entangled state of the first quantum register and the second quantum register; an inverse Fourier transform is performed on the first quantum register, and a measurement circuit is constructed for the first quantum register to obtain a phase estimation result corresponding to the period r of the modular function. In an embodiment of the present application, n second quantum bits are used to construct and encapsulate a first modular multiplication module using commonly used quantum gates. By continuously performing 2n-1 square operations on the first modular multiplication module, 2n-1 second modular multiplication modules are constructed in sequence. 2n controlled unitary gates are set to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain a phase estimation result corresponding to the modular function period r. Moreover, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0085] FIG7 is a schematic diagram of the structure of a quantum circuit construction device provided in Example 2 of the present application. As shown in FIG7 , the device includes:
[0086] A determination module 71 is used to determine the modulus N and the random number a corresponding to the modulus function to be solved;
[0087] A preparation module 72, configured to prepare a first quantum register and a second quantum register according to the modulus N;
[0088] A first construction module 73 is configured to construct a Hadamard gate for the quantum initial state of each first quantum bit to obtain an equiprobable quantum superposition state of the first quantum register;
[0089] The second building module 74 is used to build a first modular multiplication module U for the quantum initial state of the second quantum register based on the modulus N and the random number a. a ;
[0090] The first computing module 75 is used to calculate the first modular multiplication module U on the second quantum register. a Continuously perform 2n-1 square operations and construct 2n-1 second modular multiplication modules in sequence, which are recorded as
[0091] The third building block 76 is used to sequentially convert the plurality of first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and multiple second modular multiplication modules As the controlled party, construct 2n controlled unitary gates to obtain the entangled state of the first quantum register and the second quantum register;
[0092] The measurement module 77 is used to perform inverse Fourier transform on the first quantum register and construct a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
[0093] In practical applications, quantum computing can be used to solve difficult mathematical problems. For example, Shor's algorithm can transform the problem of solving a mathematical problem into the problem of solving the period of a modular function. By using quantum computing to solve the period of the modular function, the solution to the difficult mathematical problem can be obtained based on the period calculation of the modular function obtained. It is understandable that different mathematical problems correspond to different modular functions. Shor's algorithm can be used to determine the modular function to be solved for the mathematical problem to be solved. The process of determining the modular function corresponding to the mathematical problem can be referred to the existing technology and will not be elaborated on here. This solution is applied to solving the period of the modular function.
[0094] In this embodiment, the modular function to be solved can be expressed as f(x):=a xmod N, where x is the independent variable, a is the random number corresponding to the modular function to be solved, and N is the modulus corresponding to the modular function to be solved. Therefore, after obtaining the modular function to be solved using Shor's algorithm, the modular function N and random number a corresponding to the modular function can be determined.
[0095] In this embodiment, the first quantum register includes 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n}, where n is the binary expansion length of the modulus N, and a quantum register refers to a set of qubits. Specifically, after determining the modulus N by the determination module 71, the preparation module 72 performs a binary expansion on the modulus N, thereby determining the binary length n after the expansion of the modulus N. A first quantum register comprising 2n first qubits and a second quantum register comprising n second qubits are prepared.
[0096] In practical applications, the Hadamard (H) gate can convert a single quantum state into a quantum state with equal probability of |0> and |1>. The matrix form of the Hadamard gate can be expressed as Specifically, when the quantum initial state is |0>, after the Hadamard gate, the output quantum state can be expressed as H When the quantum state of the quantum is |1>, after the Hadamard gate, the output quantum state can be expressed as
[0097] In this embodiment, the first construction module 73 sets a corresponding Hadamard gate for each first quantum bit, that is, sets 2n Hadamard gates accordingly. Through the action of the 2n Hadamard gates, the quantum state of each first quantum bit is converted from the quantum initial state to an equal probability superposition state, thereby obtaining an equal probability quantum superposition state of the first quantum register.
[0098] In this embodiment, the first modular multiplication module is represented by U a , the first modular multiplication module U a The first modular multiplication module U is constructed and packaged by the second construction module 74. a It can be regarded as a quantum gate acting on n second quantum bits. The first modular multiplication module U a The action matrix of is the unitary matrix corresponding to the n second quantum bits.
[0099] Specifically, 2 n -N-1 is binary expanded, and the first expansion is recorded as N n-1 N n-2...N0; and perform binary expansion on the random number a to obtain the second expansion, which is recorded as a l-1 a l-2 ...a0. The second quantum bits {q 3n-1 ,q 3n-2 ,…q 2n} and the first expansion N n-1 N n-2 ...each binary bit in N0 corresponds to each other. Specifically, q 3n-1 The highest bit in the second register corresponds to the highest bit N in the first expansion n-1 ,q 2n The lowest bit in the second register corresponds to the lowest bit N0 in the first expanded expression.
[0100] For the second expansion a l-1 a l-2 ...a0, a0 is the lowest bit, a l-1 As the highest bit, perform the modulo N processing on each binary bit in order from high to low, encapsulate the quantum circuit corresponding to the modulo N processing of each binary bit of the second expansion, and obtain the first modular multiplication module U a Specifically, for a binary bit a in the second expansion i , 0≤i≤l-1, for multiple second quantum bits, perform a cyclic left shift operation in the order from high to low; if a i = 0, then perform a modulo N process on the second quantum register. If a i =1, a second modulo N process is performed on the second quantum register, and, before the second modulo N process, the initial quantum state of the second quantum register is superimposed on the current quantum state of the second quantum register.
[0101] It should be noted that for the highest binary bit a l-1 The corresponding modulo N processing is performed on the quantum initial state of the n second qubits. For the modulo N processing corresponding to the non-highest bit binary bit, the corresponding modulo N processing needs to be performed on the current quantum state of the n second qubits. For example, if a l-2 =1, then in a l-1 After the corresponding modulo N processing is completed, for multiple second quantum bits, a cyclic left shift operation is performed in order from high to low, and two modulo N processings are performed on the quantum states of the n second quantum bits. It should be noted that before the second modulo N processing, the quantum initial state of the second quantum register is superimposed on the current quantum state of the second quantum register. For example, if a l-2 =0, then in a l-1After the corresponding modulo N processing is completed, a cyclic left shift operation is performed on the multiple second quantum bits in order from high to low, and a modulo N processing is performed on the quantum states of the n second quantum bits.
[0102] In some exemplary techniques, a first modular multiplication module U is constructed a Auxiliary quantum bits need to be set. In this embodiment, the second building block 74 builds the first modular multiplication module U a The first modular multiplication module U can be realized without using auxiliary quantum bits in the process a The construction of this scheme can realize the first modular multiplication module U by applying n second quantum bits a Therefore, quantum resources are saved in this scheme.
[0103] It should be noted that the 2n-1 second modular multiplication modules are the first calculation module 75 in the first modular multiplication module U a Specifically, the first calculation module 75 performs the first modular multiplication module U on the second quantum register. a Perform a square operation to obtain the second modular multiplication module The first calculation module 75 performs a multiplication on the second modular multiplication module on the second quantum register. Perform a square operation to obtain the second modular multiplication module It can be understood that the 2n-1 second modular multiplication modules are obtained by performing a square operation on the basis of the previous modular multiplication module. Therefore, the 2n-1 second modular multiplication modules The construction does not require the preparation of new quantum bits, which can be obtained through conventional square operations, saving quantum resources.
[0104] The controlled unitary gate (CU gate) consists of two parts: the control bit (represented by a black dotted line) and the unitary gate (also known as the target bit). If the quantum state of the control bit qubit is |1>, the unitary gate acts on the target qubit; otherwise, it does not act.
[0105] It can be understood that for 2n first qubits {q 2n-1 ,q 2n-2 ,…q0}, the first building block 73 sets a Hadamard gate for each first quantum bit to obtain an equal probability quantum superposition state of the first quantum register. The third building block 76 sequentially sets the first quantum bits q0,…,q0 in the equal probability quantum superposition state. 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and multiple second modular multiplication modules As the controlled party, 2n controlled unitary gates are constructed to obtain the entangled state of the first quantum register and the second quantum register.
[0106] Specifically, after constructing 2n controlled unitary gates through the third building module 76, the phase Where j = 2 0 ,…,2 2n-1 Added to the probability amplitudes of the first qubits in the first quantum register, the quantum state of the first quantum register can be expressed as |W1>. The state to be measured in the first quantum register can be expressed as |W2>, and the relationship between |W2> and |W1> is as follows: |W2> = QFT - |W1>.
[0107] In practical applications, the measurement module 77 can store the phase on the probability amplitude of each first quantum bit in the quantum state of each first quantum bit by performing Fourier transform on the first quantum register, thereby obtaining the measured state |W2> of the first quantum register. Therefore, the measurement module 77 can obtain the phase estimation result corresponding to the modular function period r by measuring the measured quantum state of the first quantum register.
[0108] In practical applications, after constructing the controlled unitary gate, the measurement module 77 performs an inverse Fourier transform on the first quantum register and constructs a measurement circuit for the first quantum register, so as to obtain the phase estimation result corresponding to the modular function period r. The modular function period r can be calculated based on the phase estimation result, and the solution to the mathematical problem to be solved can be obtained through calculation based on the modular function period r.
[0109] In this embodiment, the second building module 74 uses n second quantum bits to construct and encapsulate the first modular multiplication module U using a commonly used quantum gate. a The first calculation module 75 performs the first modular multiplication module U a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules. The third construction module 76 sets 2n controlled unitary gates to obtain the entangled state of the first quantum register and the second quantum register. The measurement module 77 measures the first quantum register to obtain the phase estimation result corresponding to the modular function period r. In addition, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0110] Optionally, in a possible implementation, the second building module 74 includes:
[0111] Expand unit for 2 n-N-1 is binary expanded to get 2 n -N-1 corresponds to the first expansion is recorded as N n-1 N n-2 ...N0; perform binary expansion on the random number a and obtain the second expansion corresponding to the random number a, which is recorded as a l-1 a l-2 …a0; the plurality of second qubits in the second quantum register correspond one-to-one to each binary bit in the first expansion;
[0112] A processing unit is used to process each binary bit in the second expansion in descending order to obtain the first modular multiplication module U a The above-mentioned processing includes: for multiple second quantum bits, constructing exchange gates between adjacent second quantum bits in order from high to low; if the value of the binary bit is 0, performing a modulo N processing on the second quantum register; if the value of the binary bit is 1, performing two modulo N processing on the second quantum register, and before the second modulo N processing, superimposing the quantum initial state of the second quantum register on the current quantum state of the second quantum register; wherein the modulo N processing includes: for the lowest bit N0 of the first expansion, if N0=1, performing a modulo N processing on the second quantum bit q 2n Perform a NOT operation on the second qubit q 2n Overlay 2 n -N-1 times, the second quantum bit q before performing the modulo N processing 3n-1 quantum state.
[0113] Among them, the highest binary bit of the first expansion is N n-1 , corresponding to the second quantum bit q in the second quantum register 3n-1 ; The lowest binary bit of the first expansion is N0, which corresponds to the second quantum bit q in the second quantum register 2n For example, after the preparation module 72 prepares the second quantum register, it can 3n-1 ,q 3n-2 ,…q 2n The quantum initial state of
[0114] In practical applications, the random number a is an integer less than the modulus N, l is the length of the binary expansion of the random number a, and n is the binary length of the binary expansion of the modulus N. Therefore, l≤n. Among them, the highest binary bit of the second expansion is a l-1 , the lowest binary bit of the second expanded expression is a0. Specifically, the processing unit processes each binary bit in the second expanded expression in descending order, and encapsulates the first modular multiplication module U a , specifically refers to thel-1 a l-2 ...a0, and the processing is performed on each binary bit. It can be understood that the highest binary bit a of the second expansion l-1 The corresponding processing is performed on the quantum initial state of the second quantum sender; the non-highest binary bit a of the second expansion l-2 ...a0, the processing is performed based on the processing corresponding to the previous binary bit. That is, the quantum state of the second register before each binary bit is processed is the quantum state of the second register after the processing of the previous binary bit. For example, after executing the processing corresponding to a1, the processing corresponding to a0 is performed based on this. Accordingly, the quantum state of the second quantum register before executing the processing corresponding to a0 is the quantum state of the second quantum register after executing the processing corresponding to a1.
[0115] As an example, the quantum state corresponding to n second qubits can be recorded as For multiple second qubits, exchange gates are constructed between adjacent second qubits in order from high to low. In practical applications, the second qubit q 3n-2 ,…q 2n The quantum state performs ×2 operation and the second quantum bit q 3n-1 The quantum state Superposition to the second quantum bit q 2n At this time, the quantum state corresponding to the n second quantum bits is
[0116] In actual application, the second building block 74 converts a l-1 a l-2 …The quantum circuit corresponding to the processing of a0 is encapsulated as the first modular multiplication module U a In this embodiment, the second building module 74 uses n second quantum bits to construct and encapsulate the first modular multiplication module U using a commonly used quantum gate. a , reduces the first modular multiplication module U a The cost of construction, and in this embodiment, the second construction module 74 constructs the first modular multiplication module U a The process can be realized without using auxiliary quantum bits, thus saving quantum resources. a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules. The third construction module 76 sets 2n controlled unitary gates to obtain the entangled state of the first quantum register and the second quantum register. The measurement module 77 measures the first quantum register to obtain the phase estimation result corresponding to the modular function period r. In addition, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0117] Optionally, in a possible implementation manner, when the above-mentioned processing unit is used for modulo N processing, it is specifically the same as:
[0118] If N0=1, then for the second quantum bit q 2n Perform a NOT gate operation;
[0119] For the non-least significant N digits of the first expansion j , 1≤j≤n-1, if N j =1, then the second quantum bit q corresponding to the lowest bit N0 of the first expansion among the multiple second quantum bits 2n and the non-lowest bit N j The next N j-1 The corresponding second quantum bit q 2n+j-1 As a control bit, the non-lowest bit N j The corresponding second quantum bit q 2n+j As a controlled bit, a controlled NOT gate is constructed.
[0120] For example, N n-1 =1, the second lowest quantum bit q 2n and q n-2 The corresponding second quantum bit q 3n-2 As a control bit, N n-1 The corresponding quantum bit q 3n-1 As a controlled bit, a controlled NOT gate is constructed. It should be noted that for N1, the second quantum bit corresponding to N1 is q 2n+1 , the second quantum bit corresponding to the next bit N0 of N1 is the second quantum bit q 2n , if N1=1, then the second quantum bit q 2n As a control bit, the second quantum bit q corresponding to N1 is 2n+1 As a controlled bit, a controlled NOT gate is constructed.
[0121] It can be understood that the processing unit constructs the exchange gates between the adjacent second qubits in the order from high to low for the multiple second qubits, which is equivalent to cyclically shifting the quantum states of all the second qubits to the left, and converting the second qubits q 3n-1 The quantum state Superposition to the second quantum bit q 2n On the quantum bit, on this basis, the processing unit is equivalent to 2 n -N-1 times the quantum state Superposition on the second quantum bit q 2n On the quantum bit.
[0122] In practical applications, after the phase estimation result is obtained by the measurement module 77, the period r of the modulo function to be solved can be obtained by calculation. As an example, in one possible implementation, the device further includes:
[0123] The second calculation module is used to perform continued fraction expansion on the phase estimation result to calculate the period r of the modular function.
[0124] Specifically, the phase estimation result satisfies the first inequality Where q = 2 2n ,k=0...,n. By expanding the first inequality into a continued fraction, when the greatest common divisor of k and z is 1, the value of z at this time is taken as the period r of the modular function.
[0125] In practical applications, difficult mathematical problems can be converted into problems for solving modular function periods by using Shor's algorithm. As an example, integer decomposition problems can be converted into problems for solving modular function periods by using Shor's algorithm. The quantum circuit construction method provided in the above embodiment can be applied to the integer decomposition process. As an example, in one possible implementation, the device includes: a third computing module;
[0126] a third calculation module, configured to randomly select an initial random number that is smaller than the integer to be decomposed, calculate the greatest common factor of the initial random number and the integer to be decomposed; if the greatest common factor is greater than 1, use the greatest common factor as a non-trivial factor of the integer to be decomposed;
[0127] The determination module 71 is specifically configured to:
[0128] If the greatest common factor is equal to 1, the integer to be decomposed is used as the modulus N corresponding to the modulus function to be solved, and the initial random number is used as the random number a corresponding to the modulus function to be solved.
[0129] The initial random number is any integer smaller than the integer to be factored. A nontrivial factor is an integer greater than 1 that is divisible by the integer to be factored. In practical applications, factoring an integer is the process of determining two nontrivial factors of the integer to be factored. The product of these two nontrivial factors is the integer to be factored. Therefore, once one nontrivial factor of the integer to be factored is determined, the other nontrivial factor can be determined, and the integer factorization process is complete.
[0130] Specifically, after randomly selecting an initial random number, the third calculation module calculates the greatest common factor of the initial random number and the integer to be factored using classical mathematical calculation methods. If the greatest common factor is greater than 1, the greatest common factor is used as a non-trivial factor of the integer to be factored, and the integer factorization process ends. If the greatest common factor is equal to 1, the two non-trivial factors of the integer to be factored are solved by solving the period of the modular function. Specifically, if the greatest common factor is equal to 1, the determination module 71 uses the integer to be factored as the modular number N corresponding to the modular function to be solved, and uses the initial random number as the random number a corresponding to the modular function to be solved, constructs the modular function, and uses the quantum circuit construction method shown in the above embodiment to solve the two non-trivial factors of the integer to be factored.
[0131] In this embodiment, during the integer factorization process, an initial random number is randomly selected, and the greatest common factor of the initial random number and the integer to be factored is preliminarily calculated using classical calculation methods. A determination is then made as to whether the greatest common factor is greater than 1 to determine whether the greatest common factor is a non-trivial factor of the integer to be factored. When the greatest common factor is equal to 1, the integer factorization problem is converted into a quantum circuit construction problem. The quantum circuit construction device described above can quickly solve the integer factorization result, thereby improving the efficiency of the integer factorization calculation.
[0132] Furthermore, after the second calculation module calculates the period r of the modular function, two non-trivial factors corresponding to the integer to be decomposed can be obtained by calculation. As an example, in a possible implementation, the device further includes: a period calculation module;
[0133] The cycle calculation module is specifically used for:
[0134] If the period r of the modular function is abnormal, return to the step of randomly selecting an initial random number that is smaller than the integer to be decomposed, and calculating the greatest common factor of the initial random number and the integer to be decomposed; wherein the abnormal period r of the modular function includes: the period r of the modular function is an odd number, or,
[0135] Otherwise, and the first greatest common factor of the integer to be factored, and, and the second greatest common factor of the integer to be decomposed, as the two non-trivial factors corresponding to the integer to be decomposed; wherein the product of the two non-trivial factors is the integer to be decomposed.
[0136] It can be understood that the integer to be decomposed is the modulus N corresponding to the modulus function to be solved. Specifically, the first greatest common factor can be expressed as The second common factor can be expressed as In this embodiment, when the period r of the modular function is normal, two non-trivial factors corresponding to the integer to be decomposed are obtained by calculating the first common factor and the second common factor.
[0137] Among them, when the period r of the modular function is abnormal, the two non-trivial factors corresponding to the integer to be decomposed cannot be calculated. In this embodiment, after calculating the period r of the modular function, it is first determined whether the period r of the modular function is abnormal. When the period r of the modular function is normal, the two non-trivial factors corresponding to the integer to be decomposed are calculated based on the period r, which can ensure the accuracy of the integer decomposition calculation.
[0138] In the quantum circuit construction device provided by this embodiment, a determination module determines the modulus N and random number a corresponding to the modulus function to be solved; a preparation module prepares a first quantum register including 2n first quantum bits and a second quantum register including n first quantum bits according to the modulus N, where n is the binary expansion length of the modulus N; a first construction module obtains an equiprobable quantum superposition state of the first quantum register by constructing a Hadamard gate; a second construction module constructs a first modular multiplication module on the second quantum register, and a first calculation module constructs 2n-1 second modular multiplication modules; a third construction module sequentially uses multiple first quantum bits as control bits, and sequentially uses the first modular multiplication module and the 2n-1 second modular multiplication modules as controlled parties to construct 2n controlled unitary gates to obtain an entangled state of the first quantum register and the second quantum register; a measurement module performs an inverse Fourier transform on the first quantum register, and constructs a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the period r of the modular function. In an embodiment of the present application, n second quantum bits are used to construct and encapsulate a first modular multiplication module using commonly used quantum gates. By continuously performing 2n-1 square operations on the first modular multiplication module, 2n-1 second modular multiplication modules are constructed in sequence. 2n controlled unitary gates are set to obtain the entangled state of the first quantum register and the second quantum register, and the first quantum register is measured to obtain a phase estimation result corresponding to the modular function period r. Moreover, this scheme can realize quantum circuit construction without using auxiliary quantum bits, saving the quantum resources required for quantum computing. When the quantum resources that can be provided by quantum computers are limited, it provides support for solving larger-scale computing problems.
[0139] FIG8 is a schematic diagram of the structure of an electronic device provided in Example 3 of the present application. As shown in FIG8 , the electronic device includes:
[0140] The main control device includes a processor 81 and a memory 82; it may also include a communication interface 83 and a bus 84. The processor 85, memory 82, and communication interface 83 can communicate with each other via bus 84. Communication interface 83 can be used for information transmission. The processor 81 can call logic instructions in memory 82 to execute the method of the above embodiment.
[0141] In addition, the logic instructions in the memory 82 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0142] Memory 82, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. Processor 81 executes the software programs, instructions, and modules stored in memory 82 to perform functional applications and data processing, thereby implementing the methods in the above-mentioned method embodiments.
[0143] The memory 82 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal device. Furthermore, the memory 82 may include high-speed random access memory and non-volatile memory.
[0144] The present application also provides a computer-readable storage medium having computer-executable instructions stored therein. When executed by a processor, the computer-executable instructions implement the method of any of the embodiments. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0145] In an exemplary embodiment, a quantum computer is further provided. The quantum computer is a superconducting system and is used to implement the method in any of the above embodiments.
[0146] In an exemplary embodiment, a computer program product is further provided, including a computer program, which implements the above method when executed by a processor.
[0147] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0148] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for constructing a quantum circuit, characterized in that: The method comprises: Determine the modulus N and random number a corresponding to the modulus function to be solved; According to the modulus N, a first quantum register and a second quantum register are prepared; the first quantum register includes 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n }, wherein n is the binary expansion length of the modulus N; Constructing a Hadamard gate for each quantum initial state of the first quantum bit to obtain an equiprobable quantum superposition state of the first quantum register; Constructing a first modular multiplication module U for the quantum initial state of the second quantum register based on the modulus N and the random number a a ; On the second quantum register, the first modular multiplication module U a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules, recorded as Sequentially place multiple first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and a plurality of second modular multiplication modules As a controlled party, construct 2n controlled unitary gates to obtain the entangled state of the first quantum register and the second quantum register; An inverse Fourier transform is performed on the first quantum register, and a measurement circuit is constructed for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
2. The method according to claim 1, characterized in that The first modular multiplication module U is constructed based on the modulus N and the random number a for the quantum initial state of the second quantum register. a ,include: 2 n -N-1 performs binary expansion and gets 2 n -N-1 corresponds to the first expansion N n-1 N n-2 ...N0; perform binary expansion on the random number a to obtain the second expansion corresponding to the random number a, denoted as a l-1 a l-2 …a0; the plurality of second quantum bits in the second quantum register correspond one-to-one to each binary bit in the first expansion; In order from high to low, each binary bit in the second expansion is processed to obtain the first modular multiplication module U a ; The processing includes: for the plurality of second quantum bits, in order from high to low, sequentially constructing exchange gates between adjacent second quantum bits; if the value of the binary bit is 0, performing a modulo N processing on the second quantum register; if the value of the binary bit is 1, performing a modulo N processing on the second quantum register twice, and before the second modulo N processing, superimposing the quantum initial state of the second quantum register on the current quantum state of the second quantum register; wherein the modulo N processing includes: for the lowest bit N0 of the first expansion, if N0=1, performing a modulo N processing on the second quantum bit q 2n Perform a NOT operation on the second qubit q 2n Overlay 2 n -N-1 times, the second quantum bit q before the modulo N processing is performed 3n-1 The quantum state of .
3. The method according to claim 2, characterized in that The module N processing comprises: If N0 = 1, then for the second quantum bit q 2n Perform a NOT gate operation; For the non-least significant digit N of the first expansion j , 1≤j≤n-1, if N j =1, then the second quantum bit q corresponding to the lowest bit N0 of the first expansion among the plurality of second quantum bits is 2n And the non-lowest bit N j The next N j-1 The corresponding second quantum bit q 2n+j-1 As a control bit, the non-lowest bit N j The corresponding second quantum bit q 2n+j As a controlled bit, a controlled NOT gate is constructed.
4. The method according to claim 1, characterized in that: After performing inverse Fourier transform on the first quantum register and constructing a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r, the method further includes: The phase estimation result is expanded into a continued fraction to calculate the period r of the modular function.
5. The method according to claim 1, characterized in that Before determining the modulus N and the random number a corresponding to the modulus function to be solved, the method further includes: Randomly select an initial random number that is smaller than the integer to be decomposed, and calculate the greatest common factor of the initial random number and the integer to be decomposed; If the greatest common factor is greater than 1, the greatest common factor is used as a non-trivial factor of the integer to be decomposed; The step of determining the modulus N and the random number a corresponding to the modulus function to be solved specifically includes: If the greatest common factor is equal to 1, the integer to be decomposed is used as the modulus N corresponding to the modulus function to be solved, and the initial random number is used as the random number a corresponding to the modulus function to be solved.
6. The method according to any one of claims 1 to 5, characterized in that: After performing inverse Fourier transform on the first quantum register and constructing a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r, the method further includes: If the period r of the modular function is abnormal, return to the step of randomly selecting an initial random number that is smaller than the integer to be decomposed, and calculating the greatest common factor of the initial random number and the integer to be decomposed; wherein the abnormal period r of the modular function includes: the period r of the modular function is an odd number, or, Otherwise, and the first greatest common factor of the integer to be factored, and, and the second greatest common divisor of the integer to be decomposed, as the two non-trivial factors corresponding to the integer to be decomposed; wherein the product of the two non-trivial factors is the integer to be decomposed.
7. A quantum circuit construction device, characterized in that: The device comprises: A determination module, used to determine the modulus N and the random number a corresponding to the modulus function to be solved; A preparation module is used to prepare a first quantum register and a second quantum register according to the modulus N; the first quantum register includes 2n first quantum bits denoted as {q 2n-1 ,q 2n-2 ,…q0}, the second quantum register includes n second quantum bits denoted as {q 3n-1 ,q 3n-2 ,…q 2n }, wherein n is the binary expansion length of the modulus N; A first construction module is used to construct a Hadamard gate for the quantum initial state of each of the first quantum bits to obtain an equiprobable quantum superposition state of the first quantum register; A second building module is used to build a first modular multiplication module U for the quantum initial state of the second quantum register based on the modulus N and the random number a. a ; a first computing module, configured to calculate the first modular multiplication module U on the second quantum register; a Continuously perform 2n-1 square operations to construct 2n-1 second modular multiplication modules, recorded as The third building block is used to sequentially convert a plurality of first quantum bits q0, ..., q 2n-2 ,q 2n-1 As the control bit, the first modular multiplication module U a and a plurality of second modular multiplication modules As a controlled party, construct 2n controlled unitary gates to obtain the entangled state of the first quantum register and the second quantum register; A measurement module is used to perform an inverse Fourier transform on the first quantum register and construct a measurement circuit for the first quantum register to obtain a phase estimation result corresponding to the modular function period r.
8. The device according to claim 7, characterized in that The second building block comprises: Expand unit for 2 n -N-1 performs binary expansion and gets 2 n -N-1 corresponds to the first expansion N n-1 N n-2 ...N0; perform binary expansion on the random number a to obtain the second expansion corresponding to the random number a, denoted as a l-1 a l-2 …a0; the plurality of second quantum bits in the second quantum register correspond one-to-one to each binary bit in the first expansion; A processing unit, configured to process each binary bit in the second expanded expression in a descending order, and encapsulate the first modular multiplication module U a ; The processing includes: for the plurality of second quantum bits, in order from high to low, sequentially constructing exchange gates between adjacent second quantum bits; if the value of the binary bit is 1, performing two modulo N processing on the second quantum register, and before the second modulo N processing, superimposing the quantum initial state of the second quantum register on the current quantum state of the second quantum register; wherein the modulo N processing includes: for the lowest bit N0 of the first expansion, if N0=1, performing the second quantum bit q 2n Perform a NOT operation on the second qubit q 2n Overlay 2 n -N-1 times, the second quantum bit q before the modulo N processing is performed 3n-1 The quantum state of .
9. The device according to claim 8, characterized in that When the processing unit is used for modulo N processing, it is specifically used for: If N0 = 1, then for the second quantum bit q 2n Perform a NOT gate operation; For the non-least significant digit N of the first expansion j , 1≤j≤n-1, if N j =1, then the second quantum bit q corresponding to the lowest bit N0 of the first expansion among the plurality of second quantum bits is 2n And the non-lowest bit N j The next N j-1 The corresponding second quantum bit q 2n+j-1 As a control bit, the non-lowest bit N j The corresponding second quantum bit q 2n+j As a controlled bit, a controlled NOT gate is constructed.
10. The device according to claim 7, characterized in that The device also includes: The second calculation module is used to perform a continued fraction expansion on the phase estimation result to calculate the period r of the modular function.
11. The device according to claim 7, characterized in that The device further comprises: a third calculation module; The third calculation module is used to randomly select an initial random number that is smaller than the integer to be decomposed, and calculate the greatest common factor of the initial random number and the integer to be decomposed; if the greatest common factor is greater than 1, the greatest common factor is used as a non-trivial factor of the integer to be decomposed; The determination module is specifically used for: If the greatest common factor is equal to 1, the integer to be decomposed is used as the modulus N corresponding to the modulus function to be solved, and the initial random number is used as the random number a corresponding to the modulus function to be solved.
12. The device according to any one of claims 7 to 11, characterized in that: The device also includes: a period calculation module; The cycle calculation module is specifically used for: If the period r of the modular function is abnormal, return to the step of randomly selecting an initial random number that is smaller than the integer to be decomposed, and calculating the greatest common factor of the initial random number and the integer to be decomposed; wherein the abnormal period r of the modular function includes: the period r of the modular function is an odd number, or, Otherwise, and the first greatest common factor of the integer to be factored, and, and the second greatest common divisor of the integer to be decomposed, as the two non-trivial factors corresponding to the integer to be decomposed; wherein the product of the two non-trivial factors is the integer to be decomposed.
13. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
15. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Implementation method of universal quantum comparison circuit
CN111310928A
Quantum computing simulation platform and linear equation set quantum solving simulation method and system
CN112232512A
Quantum circuit operation method and system, electronic equipment, and medium
CN114021729A
Quantum circuit construction method and device, equipment, storage medium and product
CN117744812A
Systems and methods for preparation of normal distributions on quantum computers
US20220391468A1
Cited By
Electric power system reliability evaluation method based on quantum convolution
CN122414557A