Variational quantum circuit and quantum state amplitude encoding method, device, equipment and medium
By designing simplified variable component quantum circuits in quantum machine learning, quantum gates that only use single and double qubits, the problem of low amplitude coding efficiency is solved, and efficient encoding of high-dimensional data and accurate processing of information is achieved.
Patent Information
- Application Number
- CN202510034648.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-09
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-09
AI Technical Summary
Amplitude encoding is inefficient in quantum machine learning, limiting the performance of quantum algorithms when processing high-dimensional data.
A variable component quantum circuit is designed, using only single-qubit uncontrolled RY gates and dual-qubit controlled RY gates to achieve efficient amplitude encoding of the real vector to be encoded through classical optimizers training and optimization of training parameters.
The quantum circuit structure is simplified, the execution efficiency of amplitude encoding is improved, and the completeness and accuracy of information is ensured, which is suitable for a wider range of quantum computing tasks.
Smart Images

Figure CN119416903B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a variational quantum circuit and quantum state amplitude encoding method, device, equipment and medium. Background Art
[0002] Quantum computing, with its unique quantum mechanics as its cornerstone, has opened up a new era of computing. Its core component, the qubit, as the basic unit of information processing, endows quantum algorithms with extraordinary computing power through quantum properties such as quantum superposition and quantum entanglement. When dealing with specific problems, quantum algorithms have proven their superior performance over traditional algorithms. Taking the Shor algorithm as an example, it has demonstrated an exponential acceleration of classical algorithms in solving the problem of prime factorization of large numbers, bringing a revolutionary impact to the field of cryptography. The Grover algorithm, on the other hand, has achieved a square-level efficiency improvement over classical search algorithms in the task of searching unordered databases, greatly optimizing the information retrieval process. These groundbreaking achievements not only highlight the huge potential of quantum algorithms in solving complex problems, but also lay a solid foundation for the future development of quantum computing technology, heralding the arrival of a new era of computing.
[0003] In today's era of noisy intermediate-scale quantum (NISQ) computing, variational quantum algorithms (VQA) have become the focus of researchers. VQA, as an innovative quantum-classical hybrid computing paradigm, first needs to build a variational quantum circuit, and then optimize the parameters in the variational quantum circuit through a classical optimizer, dedicated to exploring the optimal solution or its approximate solution to the problem. The scope of VQA covers a variety of algorithms, including the variational quantum eigensolver (VQE), which is specifically used to calculate the ground state energy of molecules, providing a new analytical tool for the field of quantum chemistry. In addition, the quantum approximate optimization algorithm (QAOA) shows its unique advantages in solving complex combinatorial optimization problems and provides a new solution to optimization problems. Other VQA algorithms such as quantum neural networks (QNN) also show strong application potential in their respective fields. The diversity and adaptability of VQA make it a powerful tool for solving various problems, providing researchers with a series of efficient and innovative solutions, and promoting the application and development of quantum computing technology in multiple fields.
[0004] In the field of quantum machine learning, converting classical data into quantum states is a crucial step. Amplitude coding is a well-known quantum coding scheme that uses the amplitude characteristics of quantum states to characterize data, allowing quantum systems to process large data sets even with a limited number of quantum bits. Amplitude coding is popular because it can make full use of the multi-dimensional characteristics of quantum superposition states, providing quantum algorithms with the ability to process high-dimensional data. However, the efficiency of amplitude coding often becomes a key factor restricting the performance improvement of quantum machine learning algorithms. Summary of the invention
[0005] The purpose of the present invention is to provide a variational quantum circuit, a quantum state amplitude encoding method, a device and an electronic device.
[0006] An embodiment of the present invention provides a variational quantum circuit, including:
[0007] n quantum bits arranged in order from low to high, where n is an integer greater than or equal to 2;
[0008] A first operation column, comprising n-1 first uncontrolled RY gates; each first uncontrolled RY gate is respectively arranged on the second to nth quantum bits located at the second lowest position;
[0009] A circuit module, comprising a plurality of second operation columns that can be repeatedly operated, each of which comprises a second uncontrolled RY gate and n-1 controlled RY gates; the second uncontrolled RY gate is arranged on the first qubit at the lowest position; each controlled RY gate is arranged on the second qubit to the nth qubit at the second lowest position, and the control bit of the controlled RY gate is the previous low-order qubit adjacent to the controlled bit;
[0010] The third operation column includes n third uncontrolled RY gates, which are respectively set on n quantum bits; wherein,
[0011] The line module is located between the first operation column and the third operation column, and each of the uncontrolled RY gates and the controlled RY gates carries training parameters.
[0012] Further, the controlled RY gate is a two-qubit controlled RY gate; and / or,
[0013] When the control bit of the controlled RY gate is |1>, the RY gate operation is performed on the target quantum bit of the controlled RY gate.
[0014] Furthermore, two ends of the circuit module are respectively connected to one end of the first operation column and one end of the third operation column, the other end of the first operation column is connected to the input end of the variable component quantum circuit, and the other end of the third operation column is connected to the output end of the variable component quantum circuit.
[0015] Furthermore, the number of the second operation columns is determined by the fidelity between the real vector to be encoded and the training quantum state; wherein the training quantum state is the first quantum state after evolution of the variational quantum circuit and is output by substituting preset parameters as training parameters into the variational quantum circuit.
[0016] Furthermore, when the training parameters are fixed after training and optimization, a target variational quantum circuit is obtained to evolve a second quantum state; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
[0017] The embodiment of the present invention provides a quantum state amplitude encoding method, based on the variational quantum circuit, comprising:
[0018] And normalize the real vector to be encoded;
[0019] Get a set of random parameter initial values;
[0020] Substituting the initial value of the parameter into the variational quantum circuit as a training parameter to output a training quantum state after evolution of the variational quantum circuit;
[0021] Calculating a loss value between a normalized real vector to be encoded and a training quantum state, wherein the loss value is a negative value of the fidelity between the normalized real vector to be encoded and the training quantum state;
[0022] Constructing a quantum-classical hybrid neural network, training and optimizing the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network by a classical optimizer until the training parameters or the loss value converge to a set threshold;
[0023] In response to the training parameter or the loss value converging to a set threshold, a second quantum state evolved through the variational quantum circuit is output; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
[0024] Further, the obtaining of the real vector to be encoded and normalizing the obtained real vector to be encoded includes:
[0025] Determine whether the number of elements of the real vector to be encoded satisfies 2 n ;
[0026] If the number of elements of the real vector to be encoded does not satisfy 2 n , then zero padding is performed so that the number of elements of the real vector to be encoded satisfies 2 n ;in,
[0027] The modulus length of the real vector to be encoded after normalization is 1.
[0028] Furthermore, the loss value is calculated by the following conditional formula:
[0029]
[0030] In the formula, x is the real vector to be encoded, , where T represents transpose, is a real number, and i=0,1,...N-1; is the evolved quantum state; is the i-th element of the quantum state after evolution.
[0031] The embodiment of the present invention provides a quantum state amplitude encoding device, based on the variational quantum circuit, including:
[0032] A normalization module, which is used to normalize the real vector to be encoded;
[0033] An acquisition module, which is used to obtain a set of random parameter initial values;
[0034] A substitution module, which is used to substitute the initial value of the parameter as the training parameter into the variational quantum circuit to output the training quantum state after the evolution of the variational quantum circuit;
[0035] A calculation module, which is used to calculate a loss value between a normalized real vector to be encoded and a training quantum state, wherein the loss value is a negative value of the fidelity between the normalized real vector to be encoded and the training quantum state;
[0036] An optimization module, which is used to construct a quantum-classical hybrid neural network, train and optimize the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network through a classical optimizer until the training parameters or loss value converge to a set threshold;
[0037] A response module is used to output a second quantum state after evolution of the variational quantum circuit in response to a training parameter or a loss value converging to a set threshold; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
[0038] An embodiment of the present invention provides an electronic device, which includes a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the method described above are implemented.
[0039] An embodiment of the present invention provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the steps of the method described above are implemented.
[0040] The above technical solution of the present invention has the following beneficial technical effects:
[0041] The variational quantum circuit provided by the embodiment of the present invention only has two types of quantum gates, namely, a single-qubit uncontrolled RY gate and a dual-qubit controlled RY gate, thereby avoiding the use of multi-qubit gates, simplifying the structure of the variational quantum circuit, and further improving the execution efficiency of amplitude coding and reducing the use of quantum gates; moreover, each RY gate carries training parameters, which can be iteratively optimized. By combining classical optimization technology and quantum circuit algorithm, the real vector to be encoded can be accurately mapped to its corresponding amplitude-coded quantum state, thereby ensuring the integrity and accuracy of the information. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following briefly introduces the drawings in the embodiment of the present invention.
[0043] Figure 1 This is a schematic diagram of the structure of an existing amplitude-coded quantum circuit.
[0044] Figure 2 It is a structural schematic diagram of a variational quantum circuit according to an embodiment of the present invention.
[0045] Figure 3 It is a schematic diagram of the structure of another variational quantum circuit according to an embodiment of the present invention.
[0046] Figure 4 It is a schematic diagram of the structure of a target variation quantum circuit according to an embodiment of the present invention.
[0047] Figure 5 It is a flowchart of a quantum state amplitude encoding method according to an embodiment of the present invention.
[0048] Figure 6 It is a structural block diagram of a quantum state amplitude encoding device according to an embodiment of the present invention.
[0049] Figure 7 It is a schematic diagram of an electronic device used to implement a quantum state amplitude encoding method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirit of the present invention clearer and more thorough, so that those skilled in the art can better understand and implement the principles and spirit of the present invention. The exemplary embodiments provided herein are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments herein, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a variational quantum circuit, a quantum state amplitude encoding method, a device, an electronic device, and a computer-readable storage medium. Therefore, the present disclosure may be implemented in at least one of the following forms: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0052] In this document, terms such as first, second, etc. are only used to distinguish one entity (or operation) from another entity (or operation), and do not require or imply any order or association between these entities (or operations). In this document, the elements (such as parts, components, processes, steps) defined by the sentence "including..." do not exclude the existence of other elements in addition to the listed elements, that is, other elements that are not explicitly listed may also be included. In this document, any elements and their quantities in the drawings are used for illustration rather than limitation, and any names in the drawings are only used for distinction and do not have any limiting meaning.
[0053] The principle and spirit of the present invention are explained in detail below with reference to several exemplary or representative embodiments of the present invention.
[0054] If we use the existing amplitude coding scheme to encode a set of dimensions 2 5 =32 elements of the real vector x to be encoded, we can get Figure 1 The quantum circuit shown in the figure contains a total of 129 quantum gates, 31 of which are RY gates with parameters, and multiple multi-qubit gates such as C^4RY gates, C^3RY gates, and C^2RY gates need to be executed. These multi-qubit gates are difficult to implement in specific physical experiments; among them, C^4RY gates represent multi-qubit RY gates with 4 control bits, C^3RY gates represent multi-qubit RY gates with 3 control bits, and C^2RY gates represent multi-qubit RY gates with 2 control bits. And adjacent controlled R y One or more X gates are included between the gates, which complicates the quantum circuit and reduces the execution efficiency of amplitude coding.
[0055] Since amplitude coding plays a vital role in quantum machine learning, how to achieve efficient amplitude coding is the key to promoting the performance improvement of quantum machine learning algorithms.
[0056] Based on this, an embodiment of the present invention provides a variational quantum circuit, such as Figure 2 As shown, specifically, it may include:
[0057] n quantum bits arranged in order from low to high, where n is an integer greater than or equal to 2;
[0058] A first operation column, which includes n-1 first uncontrolled RY gates; each first uncontrolled RY gate is respectively set on the second qubit to the nth qubit located at the second lowest position;
[0059] A circuit module, comprising a plurality of second operation columns that can be repeatedly operated, each of which comprises a second uncontrolled RY gate and n-1 controlled RY gates; the second uncontrolled RY gate is arranged on the first qubit at the lowest position; each controlled RY gate is arranged on the second qubit to the nth qubit at the second lowest position, and the control bit of the controlled RY gate is the previous low-order qubit adjacent to the controlled bit;
[0060] The third operation column includes n third uncontrolled RY gates, which are respectively set on n quantum bits; wherein,
[0061] The line module is located between the first operation column and the third operation column, and each of the uncontrolled RY gates and the controlled RY gates carries training parameters.
[0062] Specifically, the first operation column, the circuit module and the third operation column can be arranged in sequence from front to back and perform quantum operations. The "front" and "back" mentioned here refer to the "front" and "back" in the sense of time, corresponding to Figure 2 , that is, the left is the front and the right is the back, in the order from front to back, that is, in the order from left to right. In this embodiment, the variational quantum circuit may include: n quantum bits arranged in sequence from low to high, the n quantum bits may be initialized so that each quantum bit is in the |0> state, and the n quantum bits may be used to make N=2 n The dimension of each set of real vectors to be encoded is N=2. n , then the number of quantum bits n is the minimum number of quantum bits required to encode classical data, and there is no need to add auxiliary quantum bits. Figure 2 The circuit module in the dotted box shown in FIG may include multiple second operation columns, and the second operation column may be arranged in P columns from left to right, that is, the second operation column may be repeatedly operated P times; for example, the second operation column may include 1 second uncontrolled RY gate and n-1 controlled RY gates; wherein the training parameter carried by the second uncontrolled RY gate may be expressed as ; The training parameters carried by the controlled RY gate can be expressed as The first operation column on the left may include n-1 first uncontrolled RY gates, and the training parameters carried by them can be expressed as follows: The third operation column on the right may include n third uncontrolled RY gates, and the training parameters carried by them can be expressed as follows: The training parameter is, for example, a rotation angle parameter of the RY gate. According to the pre-constructed quantum-classical hybrid neural network, a classical optimizer is used to train and optimize the training parameters of each uncontrolled RY gate and the controlled RY gate in the variational quantum circuit in the quantum neural network. After multiple iterations of optimization, the rotation angle parameter values of each RY gate after iterative optimization are obtained until the set convergence threshold is met, and the rotation angle parameter values are fixed to obtain a target variational quantum circuit, and a target quantum state evolved by the target variational quantum circuit can be output to realize amplitude coding of the real vector to be encoded. Since only two types of quantum gates, namely, a single-qubit uncontrolled RY gate and a double-qubit controlled RY gate, are provided in the variational quantum circuit provided by the embodiment of the present invention, the use of multi-qubit gates is avoided, so that the structure of the variational quantum circuit is simplified, and the execution efficiency of the amplitude coding can be further improved, and the use of quantum gates is reduced. Moreover, each RY gate carries training parameters, and the training parameters can be iteratively optimized. By combining classical optimization technology and quantum circuit algorithm, the real vector to be encoded can be accurately mapped to its corresponding amplitude-coded quantum state, thereby ensuring the integrity and accuracy of the information.
[0063] In an exemplary embodiment, the controlled RY gate is a two-qubit controlled RY gate; that is, the control bit of the two-qubit controlled RY gate is the previous low-bit qubit, which can be recorded as a CRY gate; compared with multi-qubit gates such as C^4RY gate, C^3RY gate and C^2RY gate, the CRY gate is easy to implement in specific physical experiments.
[0064] In an exemplary embodiment, when the control bit of the controlled RY gate is |1>, the RY gate operation is performed on the target quantum bit of the controlled RY gate; when the control bit of the controlled RY gate is |0>, no operation is performed on the target quantum bit.
[0065] In an exemplary embodiment, two ends of the circuit module are connected to the first operation column and the third operation column respectively, the other end of the first operation column is connected to the input end of the variable quantum circuit, and the other end of the third operation column is connected to the output end of the variable quantum circuit.
[0066] In some embodiments, the number of the second operation columns is determined by the fidelity between the real vector to be encoded and the training quantum state; wherein the training quantum state is the first quantum state after the variational quantum circuit is evolved and output by substituting the preset parameters as training parameters into the variational quantum circuit. Specifically, the more the number of the second operation columns is set, the higher the fidelity between the real vector to be encoded and the training quantum state, and the number of training steps in the iterative optimization process can be reduced accordingly. For example, for a dimension of 2 5When the real vector to be encoded is subjected to amplitude encoding by the variational quantum circuit in the embodiment of the present invention, when the number of the second operation columns is set to 6, the fidelity between the real vector to be encoded and the training quantum state can eventually reach 1, and the number of training steps is about 5000; when the number of the second operation columns is set to 3, the fidelity between the real vector to be encoded and the training quantum state can eventually reach 0.974, and the number of training steps is about 5000; therefore, for the real vector to be encoded with more dimensions, especially the dimension of 2 n When n is greater than or equal to 3, by appropriately increasing the number of second operation columns, not only the number of training steps can be reduced, but also the fidelity between the real vector to be encoded and the quantum state can be guaranteed.
[0067] In some embodiments, when the training parameters are fixed after training and optimization, the target variational quantum circuit is obtained to evolve the second quantum state; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state. Specifically, the quantum final state after the evolution of the target variational quantum circuit is output, so that the normalized real vector to be encoded can be accurately mapped to its corresponding amplitude-encoded quantum state, thereby achieving the integrity and accuracy of the information; based on this, quantum algorithms can be further applied to a wider range of fields to achieve more efficient data processing and deeper information mining.
[0068] Figure 5 A schematic flow chart of a quantum state amplitude encoding method according to an embodiment of the present invention is shown. Based on the variational quantum circuit according to the embodiment of the present invention, the method includes the following specific steps:
[0069] S110: performing normalization processing on the real vector to be encoded;
[0070] S120: Obtain a set of random parameter initial values;
[0071] S130: Substituting the initial value of the parameter into the variational quantum circuit as a training parameter to output a training quantum state after evolution of the variational quantum circuit;
[0072] S140: Calculate the fidelity of the normalized real vector to be encoded and the training quantum state to obtain a loss value, where the loss value is the negative value of the fidelity of the normalized real vector to be encoded and the training quantum state;
[0073] S150: constructing a quantum-classical hybrid neural network, and training and optimizing the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network by a classical optimizer until the training parameters or the loss value converge to a set threshold;
[0074] S160: In response to the training parameter or the loss value converging to a set threshold, a second quantum state after evolution of the variational quantum circuit is output; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
[0075] Specifically, by adopting the variational quantum circuit of the embodiment of the present invention, only two types of quantum gates, namely, a single-qubit uncontrolled RY gate and a double-qubit controlled RY gate, can be set in the variational quantum circuit, and each RY gate carries training parameters. The training parameters are iteratively optimized multiple times to obtain a target variational quantum circuit with optimized and fixed parameters, and then the target quantum state evolved by the target variational quantum circuit can be output to achieve The technical solution of the present invention combines classical optimization technology and quantum circuit algorithm, which can accurately map the real vector to be encoded to its corresponding amplitude coded quantum state, ensuring the integrity and accuracy of the information.
[0076] In some embodiments, step S110: normalizing the real vector to be encoded comprises the following specific steps:
[0077] S111: Determine whether the number of elements of the obtained real vector to be encoded satisfies 2 n ;
[0078] S112: If the number of elements of the real vector to be encoded does not satisfy 2 n , then zero padding is performed so that the number of elements of the real vector to be encoded satisfies 2 n ; Among them, the modulus length of the real vector to be encoded after normalization is 1.
[0079] Specifically, when the number of elements of the real vector to be encoded after normalization satisfies 2 n When the real vector to be encoded is , where T represents transpose, is a real number, and i=0,1,...N-1; the quantum state that can be prepared by amplitude coding is as follows:
[0080]
[0081] Among them, the modulus length of the real vector x to be encoded after normalization is 1, that is,
[0082]
[0083] It can be seen that all components of the real vector x to be encoded exist in quantum states middle The corresponding amplitude.
[0084] If the real vector to be encoded does not satisfy the normalization condition, it can be made to satisfy the normalization condition through a normalization operation, such as extracting a common factor.
[0085] In some embodiments, step S140: calculating the fidelity of the normalized real vector to be encoded and the training quantum state according to a preset loss function to obtain a loss value includes the following specific steps:
[0086] Add a minus sign before the loss value to reversely adjust the training parameters in the variational quantum circuit;
[0087] The loss value is calculated by the following conditional formula:
[0088]
[0089] In the formula, x is the real vector to be encoded, , where T represents transpose, is a real number, and i=0,1,...N-1; is the evolved quantum state; is the i-th element of the quantum state after evolution.
[0090] Among them, the above-mentioned loss function loss can be defined as the fidelity of the real vector to be encoded and the evolved training quantum state (i.e., the modulus square of the inner product), and adding a negative sign before the loss value can reversely adjust the training parameters in the variational quantum circuit; the negative sign is added to continuously reduce the loss value in the subsequent training process.
[0091] In some embodiments, step S150: constructing a quantum-classical hybrid neural network, training and optimizing the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network by a classical optimizer until the training parameters or the loss value converge to a set threshold, comprises the following specific steps:
[0092] S151: further training and optimizing the training parameters of the variational quantum circuit through a classical optimizer according to the calculated loss value, and returning a new set of training parameters after each iterative optimization;
[0093] S152: Substituting the new training parameters into the variational quantum circuit again to output the training quantum state after the variational quantum circuit has evolved again;
[0094] S153: When the training parameters of the variational quantum circuit are optimized through multiple iterations so that the training parameters or the loss value converge to a set threshold, the training is stopped to obtain the target variational quantum circuit.
[0095] Specifically, for example, the threshold of the loss value can be set to -1, which means that the fidelity of the quantum state obtained by training and the original real vector to be encoded is close to 1. After multiple iterative optimizations, the loss value may be equal to or close to -1, and the training is stopped. The training parameters are fixed to obtain the target variational quantum circuit; therefore, the quantum final state after the evolution of the target variational quantum circuit can be output to realize amplitude encoding of the normalized real vector to be encoded.
[0096] The implementation methods and advantages of the embodiments of the present invention are described above through multiple embodiments. The specific processing process of the embodiments of the present invention is described in detail below with reference to specific examples.
[0097] Another quantum state amplitude encoding method according to an embodiment of the present invention is based on the variational quantum circuit according to the embodiment of the present invention, and the method may include the following specific steps:
[0098] Step S1: Get a dimensional real vector x to be encoded, ,in Set to a real number. If the dimension of the real vector x to be encoded is not equal to , you can add appropriate 0 to make its dimension equal to 2 n If the real vector to be encoded does not meet the normalization condition, it can be normalized by performing a normalization operation, such as extracting a common factor, to make it meet the normalization condition.
[0099] For example, if there is The real vector x to be encoded of dimension is as follows:
[0100] Among them, the real vector x to be encoded is already a normalized vector, that is, n=5, and the modulus length of the real vector is 1.
[0101] Step S2: Construct a variational quantum circuit in the above embodiment. The variational quantum circuit may specifically include: n qubits arranged in order from low to high, n being greater than or equal to 2; a first operation column, which includes n-1 first uncontrolled RY gates; each first uncontrolled RY gate is respectively arranged on the second qubit to the nth qubit; a circuit module, which includes a plurality of second operation columns that can be repeatedly operated, each of which includes 1 second uncontrolled RY gate and n-1 controlled RY gates; the second uncontrolled RY gate is arranged on the first qubit; each controlled RY gate is respectively arranged on the second qubit to the nth qubit, and the control bit of the controlled RY gate is the previous low-order qubit adjacent to the controlled bit; a third operation column, which includes n third uncontrolled RY gates, which are respectively arranged on n qubits; wherein the circuit module is located between the first operation column and the third operation column, and each uncontrolled RY gate and controlled RY gate carry training parameters.
[0102] For example, according to the above obtained dimensional real vector x to be encoded, a variational quantum circuit ansatz containing 5 qubits can be constructed, such as Figure 3 As shown, the five quantum bits arranged from low to high can be recorded as q 0 ,q 1 ,q 2 ,q 3 ,q 4 , where the number of the second operation sequence P=6, the second operation sequence may include 1 second uncontrolled RY gate and n-1 controlled RY gates, and 1 second uncontrolled RY gate is set at the quantum bit q 0 On the qubit q, n-1 controlled RY gates are set correspondingly in sequence. 1 ,q 2 ,q 3 ,q 4 The training parameters carried by the second uncontrolled RY gate in the first second operation column can be expressed as alpha_d0_n0, and the training parameters carried by the controlled RY gate in the first second operation column can be expressed as theta_d0_n0, theta_d0_n1, theta_d0_n2, theta_d0_n3 in sequence; the training parameters carried by the second uncontrolled RY gate in the second second operation column can be expressed as theta_d1_n0, and the training parameters carried by the controlled RY gate in the second second operation column can be expressed as theta_d1_n0, theta_d1_n1, theta_d1_n2, theta_d1_n3 in sequence; starting from the second second operation column, the training parameters carried by the second uncontrolled RY gate are the same as those set on the quantum bit q 1 The training parameters carried by the controlled RY gates on the left are set to be the same; by analogy, the training parameters carried by each uncontrolled RY gate and controlled RY gate in the 3rd to 6th second operation columns can be obtained; the first operation column on the left may include n-1 first uncontrolled RY gates, which can correspond to the quantum bits q in turn. 1 ,q 2 ,q 3 ,q 4The training parameters it carries can be expressed as alpha_d0_n1, alpha_d0_n2, alpha_d0_n3, alpha_d0_n4 in sequence; the third operation column on the right may include n third uncontrolled RY gates, and the training parameters it carries can be expressed as gamma_d6_n0, gamma_d6_n1, gamma_d6_n2, gamma_d6_n3, gamma_d6_n4 in sequence; in this way, there are a total of 39 parameter-containing quantum gates in the variational quantum circuit ansatz, including only single-qubit RY gates and two-qubit controlled RY gates, and all 39 parameter-containing quantum gates carry training parameters. It is worth noting that Figure 3 and Figure 4 The thick solid line in does not belong to the structure of the variational quantum circuit in the embodiment of the present invention, and is only used to distinguish each second operation column.
[0103] Step S3: Obtain a set of random parameter initial values, and output the quantum state after the ansatz evolution of the variational quantum circuit , and its corresponding column vector is .
[0104] Step S4: Define the loss function loss as the fidelity of the real vector to be encoded and the quantum state after evolution (the modulus square of the inner product), that is In the formula, the negative sign is used to continuously reduce the loss value in the subsequent training process.
[0105] Step S5: Build a complete quantum-classical hybrid neural network. Use classical optimizers (such as Adam and BFGS) to train and optimize the parameters of the variational quantum circuit ansatz in the quantum neural network. After each iterative optimization, a new set of training parameters will be returned.
[0106] Step S6: Substitute this new set of training parameters into the variational quantum circuit ansatz, and repeat steps 3 to 5 until the training parameters or loss value converge to the set threshold. For example, the threshold of the loss value is set to -1, which means that the fidelity between the quantum state obtained by training and the original real vector to be encoded is close to 1. After multiple iterations of optimization, the loss value can be equal to or close to -1, and the training stops. Finally, the target variational quantum circuit ansatz_final with fixed parameters is obtained.
[0107] For example, the target variational quantum circuit ansatz_final is Figure 4 As shown, the final fixed parameters after training are as follows:
[0108] During the entire training process, a total of about 5,000 steps were trained. From the training process below, it can be seen that the fidelity (modulus square of the inner product) between the training quantum state and the original vector to be encoded is constantly approaching 1, and finally equal to 1, the negative sign can be ignored, and the training time is short (about 15 seconds). The changes in each training step and loss value during the training process are shown below:
[0109] Step S7: Output the quantum final state after ansatz_final evolution. At this time, the quantum final state is the quantum state corresponding to the amplitude encoding of the normalized real vector to be encoded. The dimensional real vector x to be encoded realizes amplitude encoding, and the final quantum state output is As shown below:
[0110]
[0111] It is not difficult to see from the above data that the technical solution of the present invention has been thoroughly simulated on the MindSpore Quantum quantum computing software platform. The experimental results show that the technical solution of the present invention successfully The 1-dimensional normalized real vector to be encoded is amplitude encoded, and its corresponding encoded quantum state can be accurately obtained with a fidelity of 1. In addition, the entire training process from parameter initialization to final convergence only takes about 15 seconds, which not only proves the accuracy and efficiency of the technical solution of the present invention in amplitude coding, but also provides strong technical support and practical reference for further research and application of quantum computing.
[0112] If the existing amplitude coding scheme is used to encode the dimension 2 in the above step S1 5 =32 to encode the real vector x to be encoded, we can get Figure 1 The quantum circuit shown in the figure contains 129 quantum gates, 31 of which are RY gates with parameters ( Figure 1 Parameters are not shown). If the angle tree algorithm in the existing amplitude coding method is used, the parameters of 31 RY gates can be obtained by calculating the real vector x to be coded. The specific parameter values are as follows:
[0113]
[0114] Among them, in each parameter of the original amplitude coding mentioned above, the right side indicates the parameter name and the left side indicates its corresponding value. Figure 1 The parameters of each RY gate in the quantum circuit shown are calculated using an existing algorithm that is computationally complex.
[0115] In addition, the technical solution of the present invention fully considers the feasibility of physical experiments in its design. Compared with the existing amplitude coding method, the technical solution of the present invention has made significant optimizations in the construction of quantum circuits. Specifically, for a 32-dimensional real vector to be encoded, the technical solution of the present invention successfully reduces the number of quantum gates required from 129 (such as Figure 1 The number of quantum gates in the variational quantum circuit of the present invention can be reduced to 39 (the quantum circuit shown in the figure). This improvement greatly simplifies the complexity of the quantum circuit. If the number of the second operation columns in the technical solution of the present invention is set to a smaller number, the total number of quantum gates in the variational quantum circuit of the technical solution of the present invention can be smaller. For example, when the number of the second operation columns is set to 3, the total number of quantum gates can be reduced to 24. Secondly, the variational quantum circuit of the technical solution of the present invention only relies on the operation of the single-qubit gate RY and the double-qubit gate CRY, completely avoiding the use of multi-qubit gates. This design not only reduces the burden on quantum hardware, but also reduces the error rate and complexity in the experiment, thereby improving the success rate of the experiment. This experimentally friendly design paves the way for experimental verification and practical application of quantum computing technology, and can further promote the pace of quantum information science towards practical application.
[0116] Based on this, the technical solution of the present invention can significantly improve the efficiency of amplitude coding of normalized real vectors and fully demonstrate the powerful potential of variational quantum algorithms; this not only provides a feasible new path for exploring quantum computing tasks based on amplitude coding, but also provides valuable inspiration and experience for applying variational quantum algorithms to solve other computing problems.
[0117] Corresponding to the method embodiment of the present invention, the present invention also provides a quantum state amplitude encoding device, based on the variational quantum circuit of the above embodiment of the present invention, such as Figure 6 As shown, specifically, it may include:
[0118] A normalization module 510, which is used to perform normalization processing on the real vector to be encoded;
[0119] An acquisition module 520, which is used to acquire a set of random parameter initial values;
[0120] A substitution module 530, which is used to substitute the initial value of the parameter as a training parameter into the variational quantum circuit to output a training quantum state after the evolution of the variational quantum circuit;
[0121] A calculation module 540, which is used to calculate a loss value between the normalized real vector to be encoded and the training quantum state, wherein the loss value is a negative value of the fidelity between the normalized real vector to be encoded and the training quantum state;
[0122] An optimization module 550 is used to construct a quantum-classical hybrid neural network, and train and optimize the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network through a classical optimizer until the training parameters or the loss value converge to a set threshold;
[0123] A response module 560 is used to output a second quantum state after evolution of the variational quantum circuit in response to a training parameter or a loss value converging to a set threshold; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
[0124] In another aspect, the present invention further provides an electronic device, see Figure 7 , Figure 7 1 is a block diagram of the structure principle of an electronic device according to an embodiment of the present invention. Figure 7 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 quantum state amplitude encoding method in the above-mentioned embodiment is implemented.
[0125] 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 amplitude encoding method in the embodiment of the present invention can be implemented.
[0126] In one example, Figure 7The 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.
[0127] 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.
[0128] On the other hand, an embodiment of 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 amplitude encoding method is implemented.
[0129] 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.
[0130] 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.
[0131] It should be noted that the present invention is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific implementation mode of the present invention. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be covered within the protection scope of the present invention.
Claims
1. A variational quantum circuit, characterized in that: include: n quantum bits arranged in order from low to high, where n is an integer greater than or equal to 2; A first operation column, comprising n-1 first uncontrolled RY gates; each first uncontrolled RY gate is respectively arranged on the second to nth quantum bits located at the second lowest position; A circuit module, comprising one or more second operation columns that can be repeatedly operated, each of which comprises one second uncontrolled RY gate and n-1 controlled RY gates; the second uncontrolled RY gate is arranged on the first qubit at the lowest position; each controlled RY gate is arranged on the second qubit to the nth qubit at the second lowest position, and the control bit of the controlled RY gate is the previous low-order qubit adjacent to the target qubit of the controlled RY gate; The third operation column includes n third uncontrolled RY gates, which are respectively set on n quantum bits; wherein, The line module is located between the first operation column and the third operation column, and each of the uncontrolled RY gates and the controlled RY gates carries training parameters.
2. The variational quantum circuit according to claim 1, characterized in that: The controlled RY gate is a two-qubit controlled RY gate; and / or, When the control bit of the controlled RY gate is |1>, the RY gate operation is performed on the target quantum bit of the controlled RY gate.
3. The variational quantum circuit according to claim 1, characterized in that: Two ends of the circuit module are respectively connected to one end of the first operation column and one end of the third operation column, the other end of the first operation column is connected to the input end of the variable component quantum circuit, and the other end of the third operation column is connected to the output end of the variable component quantum circuit.
4. The variational quantum circuit according to claim 1, characterized in that: The number of the second operation columns is determined by the fidelity between the real vector to be encoded and the training quantum state; wherein, The training quantum state is a first quantum state after evolution of the variational quantum circuit, which is output by substituting preset parameters as training parameters into the variational quantum circuit.
5. A quantum state amplitude encoding method, characterized in that: Based on the variational quantum circuit according to any one of claims 1 to 4, comprising: Normalize the real vector to be encoded; Get a set of random parameter initial values; Substituting the initial value of the parameter into the variational quantum circuit as a training parameter to output a training quantum state after evolution of the variational quantum circuit; Calculating a loss value between a normalized real vector to be encoded and a training quantum state; wherein the loss value is a negative value of the fidelity between the normalized real vector to be encoded and the training quantum state; Constructing a quantum-classical hybrid neural network, training and optimizing the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network by a classical optimizer until the training parameters or the loss value converge to a set threshold; In response to the training parameter or the loss value converging to a set threshold, a second quantum state evolved through the variational quantum circuit is output; wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
6. The quantum state amplitude encoding method according to claim 5, characterized in that: The normalizing the real vector to be encoded includes: Determine whether the number of elements of the real vector to be encoded satisfies 2 n ; If the number of elements of the real vector to be encoded does not satisfy 2 n , then zero padding is performed so that the number of elements of the real vector to be encoded satisfies 2 n ;in, The modulus length of the real vector to be encoded after normalization is 1.
7. The quantum state amplitude encoding method according to claim 5, characterized in that: The loss value is calculated by the following conditional formula: In the formula, x is the real vector to be encoded, , where T represents transpose, is a real number, and i=0,1,...N-1; is the evolved quantum state; is the i-th element of the quantum state after evolution.
8. A quantum state amplitude encoding device, characterized in that: Based on the variational quantum circuit according to any one of claims 1 to 4, comprising: A normalization module, which is used to normalize the real vector to be encoded; An acquisition module, which is used to obtain a set of random parameter initial values; A substitution module, which is used to substitute the initial value of the parameter as the training parameter into the variational quantum circuit to output the training quantum state after the evolution of the variational quantum circuit; A calculation module, which is used to calculate a loss value between a normalized real vector to be encoded and a training quantum state, wherein the loss value is a negative value of the fidelity between the normalized real vector to be encoded and the training quantum state; An optimization module, which is used to construct a quantum-classical hybrid neural network, train and optimize the training parameters of the variational quantum circuit in the quantum-classical hybrid neural network through a classical optimizer until the training parameters or loss value converge to a set threshold; A response module is used to output a second quantum state after evolution of the variational quantum circuit in response to a training parameter or a loss value converging to a set threshold, wherein the normalized real vector to be encoded is mapped to the amplitude of the second quantum state.
9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; when the electronic device executes the computer program instructions, the method according to any one of claims 5 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 a processor, the method according to any one of claims 5 to 7 is implemented.
Citation Information
Patent Citations
Implementation method of universal quantum comparison circuit
CN111310928A
Polynomial modular square arithmetic unit, arithmetic method and related device
CN117521833A