Quantum state phase encoding method, device, equipment and medium based on Gray code
Through the quantum state phase coding method based on Gray code, the quantum circuit structure is simplified and the encoding efficiency is improved, and the encoding accuracy problem caused by the number of quantum gates in the prior art is solved, thereby achieving higher fidelity and efficiency.
Patent Information
- Application Number
- CN202510019107.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-07
AI Technical Summary
There are many quantum gates used in existing quantum state encoding methods, which are susceptible to environmental noise and interference, resulting in the impact of encoding accuracy.
Using the quantum state phase encoding method based on the Gray code, by obtaining the vector to be encoded, creating the Gray code sequence and the XOR sequence, quantum circuits are constructed, including the H gate column and the alternately applied X gate and controlled phase gate, simplifying the quantum circuit structure and improving coding efficiency.
It effectively reduces the usage of quantum logic gates, simplifies the quantum circuit structure, improves the execution efficiency of the quantum state encoding process, reduces the accumulation error in quantum operations, and enhances the fidelity of quantum state encoding.
Smart Images

Figure CN119420421B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a quantum state phase encoding method, device, equipment and storage medium based on Gray code. Background Art
[0002] Quantum algorithm is a new computing method based on the principles of quantum mechanics. Compared with classical algorithms, quantum algorithms use qubits as the basic unit of information and use the characteristics of quantum mechanics such as quantum superposition, quantum entanglement and quantum interference to perform efficient information processing tasks. In specific problem areas, quantum algorithms have been proven to surpass traditional computing models. For example, Shor's algorithm and Grover's algorithm are two iconic algorithms in the field of quantum computing. Shor's algorithm effectively solves the prime factorization problem of large integers in polynomial time, achieving an exponential acceleration of the time complexity of classical algorithms. Grover's algorithm is designed to solve search problems. It realizes the search for specific items in an unordered database, and its time complexity is quadratic compared to classical algorithms. These two algorithms not only highlight the huge potential of quantum computing in dealing with specific complex problems, but also provide a broad vision and profound inspiration for the future development and application of quantum computing technology.
[0003] Another type of quantum algorithm is a quantum-classical hybrid algorithm that uses classical optimizers to optimize parameters in parameterized quantum circuits, also known as variational quantum algorithms (VQA). VQA is very suitable for applications in noisy intermediate-scale quantum (NISQ) circuits, and can effectively approximate problems under conditions of incomplete error correction. VQA includes variational quantum eigensolvers (VQEs), quantum approximate optimization algorithms (QAOA), and quantum neural networks (QNNs). Overall, VQA provides a powerful framework that is suitable for solving many types of computational problems. Whether it is an optimization problem or a combinatorial optimization problem, VQA can find effective solutions through iterative adjustments of parameterized quantum circuits and classical optimizers, opening up new paths for the application of quantum computing in practical problems.
[0004] In the process of using quantum algorithms to solve classical problems, quantum state encoding is an indispensable step. As the basis of quantum information processing, quantum state encoding is a conversion process that maps classical information to quantum states, which is crucial for quantum algorithms to solve classical problems.
[0005] Current quantum state encoding methods include but are not limited to ground state encoding, amplitude encoding, angle encoding, phase encoding, and IQP encoding (Instantaneous Quantum Polynomial Encoding), and the mapping process can be achieved through corresponding quantum circuits. However, the current quantum state encoding methods use a large number of quantum gates. Since quantum bits are extremely fragile and easily affected by environmental noise and interference, a large number of quantum gates will increase the errors accumulated due to noise during the execution of quantum gates, thereby affecting the accuracy of quantum state encoding. Summary of the invention
[0006] In response to the technical problems existing in the prior art, the present invention proposes a quantum state phase encoding method, device, equipment and medium based on Gray code, which can effectively simplify quantum circuits, improve encoding efficiency and enhance the fidelity of quantum state encoding.
[0007] In order to solve the above technical problem, according to one aspect of the present invention, the present invention provides a quantum state phase encoding method based on Gray code, comprising the following steps:
[0008] Obtaining a vector to be encoded, where the vector to be encoded includes a plurality of elements;
[0009] Create a Gray code sequence according to the vector to be encoded;
[0010] Creating an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence is composed of XOR values of two adjacent Gray codes in the Gray code sequence;
[0011] Constructing a quantum circuit for a vector to be encoded, the quantum circuit comprising an H gate column and alternately applied X gates and controlled phase gates, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of H gates applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on the corresponding XOR value in the XOR code sequence, and the phase parameter value in the controlled phase gate is calculated based on the element of the vector to be encoded determined by the corresponding Gray code in the Gray code sequence;
[0012] The quantum circuit is run to evolve a target quantum state, wherein the vector to be encoded is encoded into the phase of the target quantum state.
[0013] Optionally, the vector to be encoded includes 2 n elements arranged in sequence, n is a natural number; correspondingly, when creating a Gray code sequence according to the vector to be encoded, 2 n Gray codes, each Gray code includes n bits.
[0014] Optionally, an X gate in the quantum circuit and a controlled phase gate adjacent thereto constitute an operation unit for encoding an element of a vector to be encoded, in each operation unit, an X gate action bit is determined based on an XOR value, a corresponding element in the vector to be encoded is determined based on a Gray code having the same sequence number as the XOR value, and a phase parameter value of the controlled phase gate is calculated based on the corresponding element.
[0015] Optionally, the step of constructing a quantum circuit for the vector to be encoded includes:
[0016] Initialize a quantum circuit of n quantum bits to obtain an initial state of the quantum circuit, where the initial state is ;
[0017] Based on the initial state, H gates are applied to n qubits to obtain 2 n A uniform superposition of quantum ground states;
[0018] Create 2 consecutive n operation units, each operation unit corresponds to an XOR value and a Gray code; in each operation unit, an X gate is applied to the quantum bit determined by the corresponding XOR value, and a controlled phase gate is applied after each X gate, and the phase parameter value in the controlled phase gate is calculated by the element of the vector to be encoded determined by the corresponding Gray code.
[0019] Optionally, the step of creating a Gray code sequence comprises:
[0020] Generate the first Gray code of the sequence, randomly set one bit of the first Gray code to 0 and the remaining bits to 1;
[0021] Starting from the first Gray code in the sequence, the following steps are executed cyclically to generate a new Gray code until a Gray code with all bits set to 1 is obtained:
[0022] The first leftmost bit of the latest Gray code in the sequence is inverted to generate a Gray code, and the Gray code is used as the latest Gray code in the sequence;
[0023] A Gray code is generated by inverting the right adjacent bit of the first 0 bit from the left of the current latest Gray code, and is used as the latest Gray code in the sequence.
[0024] Optionally, the step of creating an XOR code sequence includes:
[0025] Determine that the bits of the XOR code are the same as the bits of the Gray code;
[0026] Traverse the Gray code sequence, perform XOR calculation on the first Gray code and the last Gray code of the Gray code sequence to obtain the first XOR code;
[0027] Starting from the first Gray code in the Gray code sequence, two adjacent Gray codes are XORed in sequence to obtain an XOR code whose sequence number in the XOR code sequence is the same as the sequence number of the Gray code with the larger sequence number being XORed.
[0028] Optionally, the target quantum state includes 2 n The target quantum state has a linear combination of 2 n Phase, 2 n The phases correspond to the 2 n elements.
[0029] On the other hand, the present invention also provides a quantum state phase encoding device based on Gray code, the device comprising:
[0030] A data acquisition unit configured to acquire a vector to be encoded;
[0031] A Gray code sequence creation unit configured to create a Gray code sequence according to a vector to be encoded;
[0032] an XOR code sequence creating unit, configured to create an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence is composed of XOR values of two adjacent Gray codes in the Gray code sequence;
[0033] a quantum circuit construction unit configured to construct a quantum circuit for a vector to be encoded, wherein the quantum circuit comprises an H gate column and alternately applied X gates and controlled phase gates, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of H gates applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on the corresponding XOR value in the XOR code sequence, and the phase parameter value in the controlled phase gate is determined based on the corresponding Gray code in the Gray code sequence;
[0034] An operating unit is configured to operate the quantum circuit to evolve a target quantum state, wherein the vector to be encoded is encoded into a phase of the target quantum state.
[0035] According to another aspect of the present invention, the present invention further provides an electronic device, comprising a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the aforementioned quantum state phase encoding method based on Gray code is implemented.
[0036] According to another aspect of the present invention, the present invention further provides a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the aforementioned quantum state phase encoding method based on Gray code is implemented.
[0037] The embodiments of the present invention significantly reduce the usage of quantum logic gates through a concise quantum state phase encoding circuit, which not only simplifies the quantum circuit structure, but also improves the execution efficiency of the quantum state encoding process, effectively reduces the cumulative error in quantum operations, and thus enhances the fidelity of quantum state encoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The preferred embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, wherein:
[0039] Figure 1 is a flow chart of a method for quantum state phase encoding based on Gray code according to an embodiment of the present invention;
[0040] Figure 2 is a flow chart of a method for creating a Gray code sequence according to one embodiment of the present invention;
[0041] Figure 3 is a flow chart of a method for creating an XOR code sequence according to an embodiment of the present invention;
[0042] Figure 4 is a schematic diagram of a quantum circuit according to an embodiment of the present invention;
[0043] Figure 5 is a principle block diagram of a quantum state phase encoding device based on Gray code according to an embodiment of the present invention;
[0044] Figure 6 It is a structural principle block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] In the following detailed description, reference may be made to the various specification drawings that are part of the present application and are used to illustrate specific embodiments of the present application. In the accompanying drawings, similar reference numerals describe substantially similar components in different figures. The various specific embodiments of the present application are described below in sufficient detail so that a person of ordinary skill in the art with relevant knowledge and skills in the art can implement the technical solutions of the present application. It should be understood that other embodiments may also be used or structural, logical or electrical changes may be made to the embodiments of the present application.
[0047] In the practical application of quantum information processing, an appropriate quantum state encoding strategy can be selected according to the specific characteristics of the data set. In the present invention, the classical data sample used for encoding is an N-bit binary number consisting of only 0 and 1, that is, {0,1} N , where N=2 n . Hereinafter, the classical data sample used for encoding is referred to as the vector to be encoded, and each binary number therein is referred to as an element of the vector to be encoded, and the element number corresponds to the data bit number of the binary number one by one. The present invention proposes a quantum state phase encoding method based on Gray code. Gray code, also known as reflected binary code, is a special form of binary encoding, and its characteristic is that only one binary bit of the continuous values in the sequence is flipped. Specifically, in the Gray code sequence, any two adjacent binary numbers differ only in a single bit, and the first and last values of the sequence also meet this condition to ensure the cyclicity of the entire sequence. This encoding method makes the Hamming distance (Hamming distance, the number of different characters in the corresponding positions of two strings) between any two adjacent binary numbers constant to 1. Based on the characteristics of Gray code, the present invention utilizes its minimum change principle in data bit flipping to effectively reduce quantum gates and simplify the quantum circuits used for encoding, thereby achieving the purpose of effectively reducing the errors accumulated due to noise in the process of executing quantum gates.
[0048] Ginseng Figure 1 , Figure 1 1 is a flow chart of a method for quantum state phase encoding based on Gray code according to an embodiment of the present invention. The method for quantum state phase encoding of a vector to be encoded comprises the following steps:
[0049] Step S1, obtaining a vector to be encoded. In this embodiment, the vector to be encoded X is an N-bit binary number, expressed as: X=[theta_0,theta_1,...,theta_k,...,theta_(N-1)], and satisfies N=2 n , n is a natural number, theta_k is the kth element, belonging to {0,1}, k is the element index, k=0,1,...,N-1.
[0050] Step S2, creating a Gray code sequence, wherein the Gray code sequence includes 2 n There are different Gray codes, each Gray code includes n bits, only one bit of the first Gray code in the Gray code sequence is 0, and all bits of the last Gray code are 1.
[0051] Step S3, creating an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence includes 2 nXOR codes, each XOR code contains n bits, and each XOR code is the XOR value of the Gray code with the same sequence number in the Gray code sequence and the adjacent previous Gray code.
[0052] Step S4, constructing a quantum circuit for the vector to be encoded. The quantum circuit includes an H gate column and alternately applied X gates and controlled phase gates, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of H gates applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on the corresponding XOR value in the XOR code sequence, and the phase parameter value in the controlled phase gate is calculated based on the vector element to be encoded determined by the corresponding Gray code in the Gray code sequence.
[0053] Step S5, running the quantum circuit to evolve a target quantum state, wherein the vector to be encoded is encoded into the phase of the target quantum state.
[0054] See also Figure 2 , Figure 2 is a flow chart of a method for creating a Gray code sequence according to an embodiment of the present invention. In this embodiment, the method for creating a Gray code sequence includes the following steps:
[0055] Step S11, based on the total number of elements N of the vector to be encoded satisfying the condition N=2 n , determine that the number of bits of the Gray code is n. In this embodiment, the parameter gray is set to represent the Gray code, and the parameter j represents the Gray code sequence number, j=1,2,...,2 n .
[0056] Step S12, initializing an empty queue A for storing the Gray code sequence.
[0057] Step S13, let j=1, generate the first Gray code gray1 of the sequence, and store it in queue A as the latest Gray code. Here, one bit of the first Gray code is randomly set to 0, and the remaining bits are 1. In one embodiment, the first Gray code gray1=11…10, that is, the first n-1 bits are 1, and the last bit, that is, the nth bit, is 0. However, it can be known that any other bit can also be 0.
[0058] Step S14, determine whether j is less than 2 n , if j is less than 2 n , execute step S15, if it is equal to 2 n , then the process ends.
[0059] Step S15, let j=j+1, invert the first left bit of the latest Gray code in the sequence to generate a Gray code and store it in queue A, which is the latest Gray code in the sequence.
[0060] Step S16, determine whether j is less than 2 n , if j is less than 2 n , execute step S17, if it is equal to 2 n , then the process ends.
[0061] Step S17, let j=j+1, invert the right adjacent bit of the first 0 bit from the left of the current latest Gray code to generate a Gray code and store it in queue A, which is the latest Gray code in the sequence, and then return to step S14.
[0062] A Gray code sequence is obtained through the above process and stored in queue A. The Gray code sequence includes 2 n Gray codes correspond one to one with the elements of the vector to be encoded, and the sequence number of the Gray code is the same as the sequence number of the element.
[0063] See also Figure 3 , Figure 3 is a flow chart of a method for creating an XOR code sequence according to an embodiment of the present invention. In this embodiment, the method for creating an XOR code sequence includes the following steps:
[0064] Step S21, determine that the number of bits of the XOR code is the same as the number of Gray code, that is, n. In this embodiment, the parameter xor is set to represent the XOR code, and the parameter m is set to represent the XOR code sequence number, m=1, 2, ..., 2 n .
[0065] Step S22, initialize an empty queue B for storing XOR codes.
[0066] Step S23, let m=1, generate the first XOR code xor1 of the sequence. Specifically, perform XOR calculation on the first Gray code and the last Gray code of the Gray code sequence to obtain the first XOR code xor1, and store it in queue B.
[0067] Step S24, determine whether m is less than 2 n , if m is less than 2 n , execute step S25, if it is equal to 2 n , then the process ends.
[0068] Step S25, let m = m + 1, and take two Gray codes corresponding to j = m and j = m-1 from queue A. m and gray m-1 .
[0069] Step S26, Gray code gray m-1 and gray m Perform XOR calculation to get an XOR code xor m, and store it in queue B, and return to step S24. The obtained XOR code sequence number is the same as the Gray code sequence number of the large sequence number.
[0070] Through the above process, an XOR code sequence is obtained and stored in queue B. It can be seen that the XOR code sequence includes 2 n XOR codes are provided, and according to the calculation of the XOR codes, the XOR codes and Gray codes with the same sequence numbers in the two sequences have a calculation relationship, so the two constitute a group. In the following description, for the convenience of description, the XOR codes and Gray codes with the same sequence numbers are called control codes.
[0071] Since the encoding process needs to be implemented by executing the quantum circuit, in step S4, when constructing a quantum circuit containing n quantum bits, the quantum circuit of n quantum bits is first initialized to obtain the initial state of the quantum circuit as ; Then, based on the initial state, the H gate is applied to the n qubits to obtain 2 n A uniform superposition state of quantum ground states; then, an X gate is applied to the quantum bit corresponding to the XOR value of each XOR code, and a controlled phase gate is applied after each X gate, and the phase parameter value in the controlled phase gate is calculated by the element of the vector to be encoded determined by the Gray code of the same group as the XOR code that determines the previous adjacent X gate. Specifically, an element in the vector to be encoded with the same sequence number as the Gray code is determined according to the sequence number of the Gray code. In one embodiment, the element is multiplied by an angle, and the calculation result is used as the phase parameter value in the controlled phase gate, so that an element in the vector to be encoded is applied to the phase of the controlled phase gate.
[0072] Therefore, it can be seen that the X gate in the quantum circuit of the present invention and the controlled phase gate adjacent thereto constitute an operation unit for encoding an element of the vector to be encoded. In each operation unit, the X gate action bit is determined based on the XOR value of the XOR code, the element number of the vector to be encoded is determined based on the Gray code with the same sequence number, and the phase parameter value in the controlled phase gate is calculated based on the element.
[0073] In an alternative solution, the X gate in the quantum circuit of the present invention can also be an R gate with a rotation angle of pi. X Gate, or a combination of Z gate and H gate, etc.
[0074] The controlled phase gate in the present invention is, for example, a C^{n-1}PS(alpha_k) gate, in which the highest quantum bit is the target bit, the remaining n-1 quantum bits are control bits, and alpha_k is the phase parameter value. In one embodiment, alpha_k=theta_k·pi, where theta_k is the kth element and pi is pi. Wherein C^{n-1}PS(alpha_k)=diag[1,1,…,1,e^{i·alpha_k}], i is an imaginary unit, and diag[1,1,…,1,e^{i·alpha_k}] represents a 2 n •2 n The diagonal matrix of the matrix has two elements on the diagonal. n -1 1 and e^{i·alpha_k}, the rest of the elements are 0, and n is the number of quantum bits. The controlled phase gate in the present invention can also be replaced by other quantum gates or quantum gate combinations, such as R Z Door, R y Gate, Z Gate, S Gate, T Gate, and R X Combined with H gate, etc.
[0075] The target quantum state obtained in step S5 includes 2 n The target quantum state has a linear combination of 2 n Phase, 2 n The phases correspond to the 2 n elements, thus achieving the goal of being able to n The purpose of this is to encode classical data consisting of 0s and 1s into the quantum state of n quantum bits.
[0076] In summary, the quantum circuit in the present invention includes a preprocessing operation unit and a plurality of operation units corresponding to one element respectively. The preprocessing operation unit includes an H gate acting on one quantum bit respectively, and each operation unit includes an X gate and a controlled phase gate for performing a quantum state flipping operation. From the perspective of the quantum circuit as a whole, the quantum circuit includes an H gate column and alternately applied X gates and controlled phase gates, and two adjacent controlled phase gates are separated by only a single X gate. The number of applied quantum gates is small, and a faster simulation speed can be achieved when simulating on a quantum computing simulator, and large noise interference can be avoided when running on real hardware, thereby achieving higher fidelity.
[0077] The following is a specific example to illustrate the quantum state phase encoding method based on Gray code. In this example, the vector to be encoded X = [0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0], and its total number of data bits is 16, 16 = 2 4The process of applying the present invention to perform quantum state phase encoding on the encoding vector X is as follows:
[0078] First create a Gray code sequence, see Figure 2 In the process shown, in this embodiment, the first Gray code gray1=1110 is generated according to step S13, and is stored in queue A to become the latest Gray code in queue A. Since the current sequence number j is determined to be 1, and sequence number 1 is less than 16, the sequence number j is determined to be 2 according to step S15, and the second Gray code gray2 is generated, that is, the first bit from the left of gray1 is inverted, and the obtained gray2=0110. Since sequence number 2 is less than 16, the sequence number j is determined to be 3 according to step S17, and the third Gray code gray3 is generated, that is, the right adjacent bit of the first 0 bit from the left of gray2 is inverted to obtain gray3=0010. Repeat the above steps until the sequence number j is equal to 16, and the generated Gray code sequence is shown in the following queue A:
[0079] Queue A = [1110, 0110, 0010, 1010, 1000, 0000, 0100, 1100, 1101, 0101,0001, 1001, 1011, 0011, 0111, 1111].
[0080] Then create an XOR code sequence based on the Gray code sequence, see Figure 3 In the process shown, the first Gray code and the last Gray code of queue A are XORed to obtain the first XOR code, that is, xor1=0001. Then, the second Gray code and the first Gray code are XORed to obtain the second XOR code xor2=1000. The third Gray code and the second Gray code are XORed to obtain the third XOR code xor3=0100. And so on. The XOR code sequence obtained by analogy is shown in queue B:
[0081] Queue B = [0001, 1000, 0100, 1000, 0010, 1000, 0100, 1000, 0001, 1000,0100, 1000, 0010, 1000, 0100, 1000].
[0082] Then, the Gray code in the Gray code sequence of the same sequence number and the XOR code in the XOR code sequence are used as a group of control codes. For the aforementioned queues A and B, the Gray code gray and the XOR code xor with the same sequence number in queues A and B are used as a group of control codes, and there are 16 groups of control codes in total.
[0083] In this embodiment, since the number of elements is 16=2 4, so it is necessary to create a 4-qubit quantum circuit, which includes a column of H gates and multiple columns of continuous operation units. Each column of operation units corresponds to a group of control codes. For the convenience of operation and description, the parameter i is used to represent the serial number of the operation unit, 0≤i≤15, and the serial number of the control code is the same as the serial number parameter i of the operation unit. Each operation unit includes an X gate and a C^{3}PS(alpha_k) gate. The bit number with a value of 1 in the XOR code xor in each group of control codes (that is, the decimal value corresponding to the XOR code, referred to as the XOR value) is determined as the quantum bit number of the X gate applied in the corresponding operation unit, and the decimal value of the Gray code in the same group of control codes is determined as the target element number of the vector to be encoded, and alpha_k=theta_k·pi is calculated to obtain the corresponding phase parameter value.
[0084] According to the above method, the control code is traversed to obtain the data in Table 1, which includes the operation unit number i, the XOR code xor and the Gray code gray in each group of control codes, the determined quantum bit number of the X gate (the action bit of the X gate), the element number k in the vector to be encoded X corresponding to the operation unit (the element number k is equal to the decimal value of the Gray code), the binary number theta of the element, and the phase parameter alpha of the controlled phase gate (the controlled Ry gate in this embodiment) in the operation unit.
[0085] Table 1:
[0086]
[0087] Based on this, we get the quantum circuit as Figure 4 As shown, Figure 4 : is a schematic diagram of a quantum circuit according to an embodiment of the present invention. The first column is column H, which is a pre-processing operation unit. The two quantum gates between each two gray lines constitute an operation unit. The numbers from 0 to 15 above the operation unit represent the operation unit number, that is, the number corresponding to the letter i in Table 1.
[0088] In running as Figure 4 When the quantum circuit shown in FIG. 1 is used, the four quantum bits are first initialized to the ground state |0>. At this time, the quantum initial state of the quantum system composed of the four quantum bits is 0.
[0089] Then an H gate is applied to all quantum bits. At this time, the quantum state of the quantum system |φ MS > is a uniform superposition state:
[0090] |φ MS >=(|0000>+|0001>+|0010>+|0011>+|0100>+|0101>+|0110>+|0111>+
[0091] |1000>+|1001>+|1010>+|1011>+|1100>+|1101>+|1110>+|1111>) / 4.
[0092] In the 0th operation unit, after the X gate is applied to the 0th quantum bit q0, the quantum state of the quantum system |φ 01 >For:
[0093] |φ 01 >=(|0001>+|0000>+|0011>+|0010>+|0101>+|0100>+|0111>+|0110>+
[0094] |1001>+|1000>+|1011>+|1010>+|1101>+|1100>+|1111>+|1110>) / 4.
[0095] Comparing the quantum state before executing the X gate, it can be seen that the overall quantum state of the quantum system has not changed.
[0096] Then execute C on the four qubits ^ {3}PS(0) gate operation adds the phase parameter value alpha_14 obtained from the 14th element to the 14th quantum state |1111>. That is, e -ialpha_14 |1111>, where alpha_14=0, then e -ialpha_14 =1, then the quantum state of the current quantum system |φ 02 > is represented as:
[0097] |φ 02 >=(|0001>+|0000>+|0011>+|0010>+|0101>+|0100>+|0111>+|0110>+
[0098] |1001>+|1000>+|1011>+|1010>+|1101>+|1100>+|1111>+|1110>) / 4.
[0099] The black bold quantum state is the quantum state after the phase factor is added.
[0100] In the first operation unit, after the X gate is applied to the third quantum bit q3, the quantum state of the quantum system |φ 03 >For:
[0101] |φ 03 >=(|1001>+|1000>+|1011>+|1010>+|1101>+|1100>+|1111>+|1110>+
[0102] |0001>+|0000>+|0011>+|0010>+|0101>+|0100>+|0111>+|0110>) / 4.
[0103] Then execute C on the four qubits ^ {3}PS(0) gate operation adds the phase parameter value alpha_6 obtained from the sixth element to the sixth quantum state |1111>. That is, e -ialpha_6 |1111>, where alpha_6=π, then e -ialpha_6 =-1, then the quantum state of the current quantum system |φ 04 > is represented as:
[0104] |φ 04 >=(|1001>+|1000>+|1011>+|1010>+|1101>+|1100>-|1111>+|1110>+
[0105] |0001>+|0000>+|0011>+|0010>+|0101>+|0100>+|0111>+|0110>) / 4.
[0106] In the second operation unit, after the X gate is applied to the second quantum bit q2, the quantum state of the quantum system |φ 05 >For:
[0107] |φ 05 >=(|1101>+|1100>+|1111>+|1110>+|1001>+|1000>-|1011>+|1010>+
[0108] |0101>+|0100>+|0111>+|0110>+|0001>+|0000>+|0011>+|0010>) / 4.
[0109] Then execute C on the four qubits ^ {3}PS(0) gate operation adds the phase parameter value alpha_2 obtained from the second element to the second quantum state |1111>. That is, e -ialpha_2 |1111>, where alpha_2=π, then e -ialpha_2 =-1, then the quantum state of the current quantum system |φ 06 > is represented as:
[0110] |φ 06 >=(|1101>+|1100>-|1111>+|1110>+|1001>+|1000>-|1011>+|1010>+
[0111] |0101>+|0100>+|0111>+|0110>+|0001>+|0000>+|0011>+|0010>) / 4.
[0112] By analogy, after the evolution Figure 4 After the quantum circuit shown, the final quantum state of the quantum system |φ is obtained final > is represented as:
[0113] =(|0000>+|0001>-|0010>+|0011>-|1001>+|0100>-|0101>-|0111> +|1000>+|1001>-|1010>-|1011>-|1100>-|1101>+ |1110>+|1111>) / 4.
[0114] It can be seen that the evolution is complete Figure 4 The quantum state obtained by the quantum circuit shown can be expressed as a linear combination of 16 computational basis states on 4 quantum bits. The quantum state has 16 phases, which correspond to the 16 elements of the vector to be encoded X=[0,0,1,0,1,1,1,1,0,0,1,1,1,1,0,0], and the phase positive 1 corresponds to the element 0 at the same position in the vector to be encoded X, and the phase negative 1 corresponds to the element 1 at the same position in X.
[0115] Based on the method described in the embodiment of the present invention, the quantum circuit for implementing quantum state phase encoding only includes 36 quantum gates, and only one X gate is included between adjacent controlled gates. Compared with the quantum circuit for implementing quantum state phase encoding by other methods, the number of quantum gates is effectively reduced. As the dimension of the classical data to be encoded increases, the number of X gates reduced by the method provided by the present invention will also increase exponentially, and the optimization effect on the number of X gates is O(2 n ).
[0116] From the aforementioned Figures 1 to 3 The process shown and Figure 4 As can be seen from the quantum circuit shown, the present invention can use only n quantum bits to calculate N=2 n dimensional classical data. Since the dimension of each data sample (i.e. the number of data bits or elements) is N=2 n , then the number of quantum bits n is the minimum number of quantum bits used to encode classical data, without the need for auxiliary quantum bits, which reflects the advantage of quantum computing, namely quantum superposition.
[0117] In addition, the quantum state after quantum state phase encoding is a maximum entangled state. Since the elements in each classical data are only 0 and 1, encoding the classical information in the phase of the corresponding quantum state will not lose any classical information, and the quantum state after phase encoding is a maximum entangled state. Therefore, the present invention maximizes another advantage of quantum computing, namely quantum entanglement. This maximum entangled state is a very valuable resource in quantum computing, which represents the highest degree of non-local correlation that can be achieved between quantum systems.
[0118] The quantum circuit for quantum state encoding provided by the present invention can be realized by programming code, has low programming difficulty, is easy to implement, can be encoded and simulated on a software platform, and furthermore can comprehensively verify the accuracy and efficiency of the quantum state encoding process.
[0119] The present invention adopts Gray code to realize quantum state phase encoding. Compared with other quantum state phase encoding methods, it further reduces the use of quantum gates and significantly reduces the amount of quantum logic gates used. It not only simplifies the structure of quantum circuits, but also improves the execution efficiency of the quantum state encoding process, effectively reduces the cumulative error in quantum operations, thereby enhancing the fidelity of quantum state encoding.
[0120] On the other hand, see Figure 5 , Figure 5 : is a principle block diagram of a quantum state phase encoding device based on Gray code according to an embodiment of the present invention, the device comprises a data acquisition unit 10, a Gray code sequence creation unit 20, an XOR code sequence creation unit 30, a quantum circuit construction unit 40 and an operation unit 50, wherein the vector to be encoded is a multi-bit binary number, and the total number of data bits N of the binary number satisfies N=2 n , n is a natural number, that is, the vector to be encoded includes N elements. The data acquisition unit 10 is configured to acquire the vector to be encoded, thereby determining that each element, the element sequence number and the total number of elements N of the vector to be encoded satisfy the condition N=2 n The exponent n and other parameters in .
[0121] The Gray code sequence creation unit 20 is connected to the data acquisition unit 10 and is configured to create a Gray code sequence according to the vector to be encoded, which includes 2 n There are different Gray codes, each Gray code includes n bits, only one bit of the first Gray code in the Gray code sequence is 0, and all bits of the last Gray code are 1.
[0122] The XOR code sequence creation unit 30 is connected to the Gray code sequence creation unit 20 and is configured to create an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence includes 2 nXOR codes, each XOR code contains n bits, and each XOR code is the XOR value of the Gray code with the same sequence number in the Gray code sequence and the adjacent previous Gray code.
[0123] The quantum circuit construction unit 40 is connected to the data acquisition unit 10, the Gray code sequence creation unit 20 and the XOR code sequence creation unit 30 respectively, and is configured to construct a quantum circuit for a vector to be encoded, wherein the quantum circuit includes an H gate column and an X gate and a controlled phase gate applied alternately, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of an H gate applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on the corresponding XOR value in the XOR code sequence, and the phase parameter value in the controlled phase gate is determined based on the corresponding Gray code in the Gray code sequence. Each X gate and an adjacent controlled phase gate constitute an operation unit, encoding an element of the vector to be encoded into the phase of the controlled phase gate.
[0124] The operation unit 50 is connected to the quantum circuit construction unit 40 and is configured to operate the quantum circuit to obtain a target quantum state after evolution, which includes 2 n The target quantum state has a linear combination of 2 n Phase, 2 n The phases correspond to the 2 n elements.
[0125] The above-mentioned Gray code-based quantum state phase encoding device realizes Gray code-based quantum state phase encoding, effectively simplifies the quantum circuit, improves the execution efficiency of the quantum state encoding process, effectively reduces the cumulative error in quantum operations, and thus enhances the fidelity of quantum state encoding.
[0126] In one embodiment, the above-mentioned quantum state phase encoding device based on Gray code can be implemented by a classical computing device, which includes a classical data processing module and a quantum simulator. The aforementioned data acquisition unit 10, Gray code sequence creation unit 20, XOR code sequence creation unit 30 and quantum circuit construction unit 40 are implemented by a classical data processor, and the operation unit 50 is implemented by a quantum simulator. In another embodiment, the above-mentioned quantum state phase encoding device based on Gray code can be implemented by a classical computing device and a quantum computer, and the aforementioned data acquisition unit 10, Gray code sequence creation unit 20, XOR code sequence creation unit 30 and quantum circuit construction unit 40 are implemented by a classical computing device, and the operation unit 50 is implemented by a quantum computer.
[0127] In another aspect, the present invention further provides an electronic device, see Figure 6 , Figure 61 is a block diagram of the structure principle of an electronic device according to an embodiment of the present invention. Figure 6 As shown, the electronic device includes a processor 601 and a memory 602 storing computer program instructions; when the processor 601 executes the computer program instructions, the aforementioned quantum state phase encoding method based on Gray code is implemented.
[0128] Specifically, the processor 601 may include a central processing unit (CPU) or a graphics processing unit (GPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of an embodiment of the present invention. The memory 602 may include a memory for data or instructions. For example, the memory 602 may be at least one of the following: a hard disk drive (HDD), a read-only memory (ROM), a random access memory (RAM), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, a universal serial bus (USB) drive, or other physical / tangible memory storage device. For another example, the memory 602 includes a removable or non-removable (or fixed) medium. For another example, the memory 602 may be inside or outside the integrated gateway disaster recovery device. The memory 602 may be a non-volatile solid-state memory. In other words, typically the memory 602 includes a tangible (non-transitory) computer-readable storage medium (such as a memory device) encoded with executable instructions, wherein when the stored executable instructions are executed by the processor 601 (such as executed by one or more processors), the quantum state phase encoding method based on Gray code in the embodiment of the present invention can be implemented.
[0129] In one example, Figure 6 The electronic device shown may also include a communication interface 603 and a bus 610. The processor 601, the memory 602, and the communication interface 603 are connected and communicate with each other via the bus 610. The communication interface 603 is mainly used to implement communication between modules, devices, units, and / or devices in the electronic device.
[0130] The bus 610 includes hardware, software or both, and can couple the components of the online data traffic billing device to each other. For example, the bus may include at least one of the following: an accelerated graphics port (AGP) or other graphics bus, an enhanced industrial standard architecture (EISA) bus, a front-side bus (FSB), a hypertransport (HT) interconnect, an industrial standard architecture (ISA) bus, an infinite bandwidth interconnect, a low pin count (LPC) bus, a memory bus, a microchannel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standard association local (VLB) bus or other suitable bus. The bus 610 may include one or more buses. Although the embodiments of the present invention describe or show a specific bus, the embodiments of the present invention may consider any suitable bus or interconnection method.
[0131] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program instruction is stored, and when the computer program instruction is executed by a processor, the aforementioned quantum state phase encoding method based on Gray code is implemented. The computer-readable storage medium is, for example, a classical computer-readable storage medium, such as a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device, or a storage medium for storing quantum information and readable by a quantum computer, such as a quantum random access memory (QRAM). QRAM can be regarded as a quantum version of RAM in a classical computer. Through QRAM, a quantum superposition state containing information can be created. Compared with RAM, which needs to be read one by one, superimposed data can be read with superimposed addresses. QRAM can be implemented in physical ways such as optics, semiconductor quantum dots, superconducting circuits, ion traps, etc.
[0132] The flowchart and / or block diagram of the method and system of the embodiment of the present invention are described above by way of example, and various aspects of the related aspects are described. It should be understood that each box or combination thereof in the flowchart and / or block diagram can be implemented by computer program instructions, or by dedicated hardware that performs specified functions or actions, or by a combination of dedicated hardware and computer instructions. For example, these computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to form a machine that enables these instructions executed by such a processor to enable the implementation of the functions / actions specified in each box or combination thereof in the flowchart and / or block diagram. Such a processor can be a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit.
[0133] The functional blocks shown in the structural block diagram of the embodiment of the present invention can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc.; when implemented in software, it is a program or code segment used to perform the required task. The program or code segment can be stored in a memory, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0134] The above embodiments are only used to illustrate the present invention, but not to limit the present invention. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the scope of the present invention. Therefore, all equivalent technical solutions should also fall within the scope of the present invention.
Claims
1. A quantum state phase encoding method based on Gray code, characterized in that: include: Obtaining a vector to be encoded, where the vector to be encoded includes multiple elements; Create a Gray code sequence according to the vector to be encoded; Creating an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence is composed of XOR values of two adjacent Gray codes in the Gray code sequence; Constructing a quantum circuit for a vector to be encoded, the quantum circuit comprising an H gate column and an X gate and a controlled phase gate applied alternately, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of H gates applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on the corresponding XOR value in the XOR code sequence, and the phase parameter value of the controlled phase gate is calculated based on the element of the vector to be encoded determined by the corresponding Gray code in the Gray code sequence; The quantum circuit is run to evolve a target quantum state, wherein the vector to be encoded is encoded into the phase of the target quantum state.
2. The quantum state phase encoding method based on Gray code according to claim 1 is characterized in that: The vector to be encoded includes 2 n elements arranged in sequence, n is a natural number; correspondingly, when creating a Gray code sequence according to the vector to be encoded, 2 n Gray codes, each Gray code includes n bits.
3. The quantum state phase encoding method based on Gray code according to claim 2 is characterized in that: An X gate in the quantum circuit and a controlled phase gate adjacent thereto constitute an operation unit for encoding an element of a vector to be encoded. In each operation unit, an X gate action bit is determined based on an XOR value, a corresponding element in the vector to be encoded is determined based on a Gray code having the same sequence number as the XOR value, and a phase parameter value of the controlled phase gate is calculated based on the corresponding element.
4. The quantum state phase encoding method based on Gray code according to claim 2 is characterized in that: The steps of constructing a quantum circuit for the vector to be encoded include: Initialize a quantum circuit of n quantum bits to obtain an initial state of the quantum circuit, where the initial state is ; Based on the initial state, H gates are applied to n qubits to obtain 2 n A uniform superposition of quantum ground states; Create 2 consecutive n operation units, each operation unit corresponds to an XOR value and a Gray code; in each operation unit, an X gate is applied to the quantum bit determined by the corresponding XOR value, and a controlled phase gate is applied after each X gate, and the phase parameter value in the controlled phase gate is calculated by the element of the vector to be encoded determined by the corresponding Gray code.
5. The quantum state phase encoding method based on Gray code according to claim 1 or 2, characterized in that: The steps to create a Gray code sequence include: Generate the first Gray code of the sequence, randomly set one bit of the first Gray code to 0 and the remaining bits to 1; Starting from the first Gray code in the sequence, the following steps are executed cyclically to generate a new Gray code until a Gray code with all bits set to 1 is obtained: The first leftmost bit of the latest Gray code in the sequence is inverted to generate a Gray code, and the Gray code is used as the latest Gray code in the sequence; A Gray code is generated by inverting the right adjacent bit of the first 0 bit from the left of the current latest Gray code, and is used as the latest Gray code in the sequence.
6. The quantum state phase encoding method based on Gray code according to claim 1 or 2, characterized in that: The steps to create an XOR code sequence include: Determine that the number of bits of the XOR code is the same as the number of bits of the Gray code; Traverse the Gray code sequence, perform XOR calculation on the first Gray code and the last Gray code of the Gray code sequence to obtain the first XOR code; Starting from the first Gray code in the Gray code sequence, two adjacent Gray codes are XORed in sequence to obtain an XOR code whose sequence number in the XOR code sequence is the same as the sequence number of the Gray code with the larger sequence number being XORed.
7. The quantum state phase encoding method based on Gray code according to claim 1, characterized in that: The target quantum state includes 2 n The target quantum state has a linear combination of 2 n Phase, 2 n The phases correspond to the 2 n elements.
8. A quantum state phase encoding device based on Gray code, characterized in that: The device comprises: A data acquisition unit, configured to acquire a vector to be encoded, wherein the vector to be encoded includes a plurality of elements; A Gray code sequence creation unit configured to create a Gray code sequence according to a vector to be encoded; an XOR code sequence creating unit, configured to create an XOR code sequence based on the Gray code sequence, wherein the XOR code sequence is composed of XOR values of two adjacent Gray codes in the Gray code sequence; a quantum circuit construction unit configured to construct a quantum circuit for a vector to be encoded, wherein the quantum circuit comprises an H gate column and an X gate and a controlled phase gate applied alternately, and two adjacent controlled phase gates are separated by only a single X gate, wherein the H gate column is composed of H gates applied to each quantum bit of the quantum circuit, the action bit of the X gate is determined based on a corresponding XOR value in the XOR code sequence, and the phase parameter value in the controlled phase gate is calculated based on an element of the vector to be encoded determined by a corresponding Gray code in the Gray code sequence; An operating unit is configured to operate the quantum circuit to evolve a target quantum state, wherein the vector to be encoded is encoded into a phase of the target quantum state.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the quantum state phase encoding method based on Gray code as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the quantum state phase encoding method based on Gray code as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Quantum information preparation method and device, computer equipment and storage medium
CN117077796A
Method, device and equipment for quantum phase coding and storage medium
CN118036764A