Quantum state amplitude encoding method, device, equipment and medium
By constructing variable component quantum circuits and using classical optimizers to train parameters, the problem of low amplitude coding efficiency is solved, and efficient amplitude coding of normalized real vectors to be encoded is achieved.
Patent Information
- Application Number
- CN202510034698.7
- 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 coding is less efficient in quantum machine learning, and has become a bottleneck in improving the performance of quantum algorithms.
By constructing variable component quantum circuits, encode them using single-qubit gates and dual-qubit gates, and training parameters through classical optimizers, Hamiltonians are set to optimize the expected value.
The amplitude coding efficiency of the normalized real vector to be encoded is improved, the quantum circuit structure is simplified, the depth of the quantum circuit is reduced, and the encoding execution efficiency is improved.
Smart Images

Figure CN119416906B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computers and quantum algorithms, and in particular to a quantum state amplitude encoding method, device, equipment and medium. Background Art
[0002] Quantum algorithms, as an advanced computing method based on the principles of quantum mechanics, use quantum bits (Qubit) as the basic unit of information, and use unique properties such as quantum superposition and quantum entanglement to perform computing tasks. On specific problems, quantum algorithms have shown superior performance compared to classical algorithms. For example, Shor's algorithm has an exponential acceleration advantage over classical algorithms when dealing with the problem of prime factorization of large numbers. At the same time, Grover's algorithm also shows a quadratic acceleration effect over classical algorithms in the problem of searching unordered databases. These achievements not only demonstrate the huge potential of quantum algorithms in solving complex problems, but also lay a broad foundation for the development of quantum computing.
[0003] In the context of the noisy intermediate-scale quantum (NISQ) era, variational quantum algorithms (VQA) have attracted widespread attention. As a quantum-classical hybrid algorithm, VQA optimizes the parameters in parameterized quantum circuits through classical optimizers, aiming to find the optimal solution or approximate optimal solution to the problem. Among them, common VQAs include variational quantum eigensolvers (VQEs), which are used to calculate the ground state energy of molecules; quantum approximate optimization algorithms (QAOA), which are used to solve combinatorial optimization problems; and quantum neural networks (QNNs). VQA is applicable to a variety of different problems and provides researchers with effective solutions.
[0004] In the field of quantum machine learning, in order for quantum algorithms to effectively process classical data, it is usually necessary to encode the classical data into the corresponding quantum state. Amplitude coding is a widely used coding scheme that cleverly uses the amplitude characteristics of quantum states to characterize data. Since this coding method can efficiently use the multi-dimensional characteristics of quantum superposition states, even small quantum systems can process large data sets. However, the efficiency of amplitude coding is often a bottleneck that restricts the performance improvement of many quantum machine learning algorithms. Summary of the invention
[0005] The purpose of the present invention is to provide a quantum state amplitude encoding method, device, equipment and medium.
[0006] An embodiment of the present invention provides a quantum state amplitude encoding method, comprising:
[0007] Normalize the real vector to be encoded;
[0008] Setting a Hamiltonian, wherein the Hamiltonian is the negative value of the outer product of the normalized real vector to be encoded and itself;
[0009] A variational quantum circuit is constructed according to the normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of repeatedly operable pseudo-layers and operation columns, each pseudo-layer includes a first single-qubit gate and a double-qubit gate capable of generating quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last pseudo-layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter;
[0010] Substituting preset parameter values as training parameters into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit;
[0011] Measuring the expectation value of the training quantum state after evolution of the variational quantum circuit with respect to the Hamiltonian;
[0012] Training the training parameters of the variational quantum circuit by a classical optimizer;
[0013] In response to the training parameter or expected value converging to a set threshold, the training quantum state after evolution of the variational quantum circuit is determined as the target quantum state; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
[0014] Further, the first single-qubit gate includes one or more of the following: an RX gate, an RY gate, and an RZ gate;
[0015] The two-qubit gate includes a CNOT gate, a CZ gate or a CY gate;
[0016] The first single-qubit gate and the second single-qubit gate are set to be the same quantum gate.
[0017] Furthermore, the normalizing the real vector to be encoded includes:
[0018] Determine whether the number of elements of the real vector to be encoded satisfies 2 n , n is an integer greater than or equal to 1;
[0019] 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,
[0020] The modulus length of the real vector to be encoded after normalization is 1.
[0021] Furthermore, constructing a variational quantum circuit according to the normalized real vector to be encoded includes:
[0022] Initialize the variational quantum circuit so that the n quantum bits in the variational quantum circuit are arranged in order from low to high;
[0023] Setting each of the first single-qubit gate and the second single-qubit gate on n qubits;
[0024] The target bit of each of the two-qubit gates is set on the second to nth qubits located at the second lowest position, and the control bit of the two-qubit gate is the previous low-position qubit adjacent to the target qubit of the two-qubit gate.
[0025] Furthermore, the method further includes: in response to the training parameters or expected values not converging to the set threshold, substituting the new training parameters obtained through training into the variational quantum circuit again, and repeating the measuring step and the training step until the new training parameters or expected values converge to the set threshold.
[0026] Furthermore, the expected value is set to -1.
[0027] An embodiment of the present invention provides a quantum state amplitude encoding device, comprising:
[0028] A normalization module, which is used to normalize the real vector to be encoded;
[0029] A setting module, which is used to set a Hamiltonian, where the Hamiltonian is the negative value of the outer product of a normalized real vector to be encoded and itself;
[0030] A construction module, which is used to construct a variational quantum circuit according to a normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of assumed layers and operation columns that can be repeatedly operated, each assumed layer includes a first single-qubit gate and a double-qubit gate that can generate quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last assumed layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter;
[0031] A substitution module, which is used to substitute a preset parameter value as a training parameter into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit;
[0032] A measurement module, which is used to measure the expected value of the training quantum state after evolution of the variational quantum circuit with respect to the Hamiltonian;
[0033] A training module, which is used to train the training parameters of the variational quantum circuit by a classical optimizer;
[0034] A first response module is used to determine the quantum state after evolution of the variational quantum circuit as a target quantum state in response to the training parameter or expected value converging to a set threshold; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
[0035] Furthermore, the device also includes: a second response module, which is used to substitute new training parameters obtained through training into the variational quantum circuit again in response to the training parameters or expected values not converging to the set threshold, and repeat the measurement module and the training module until the new training parameters or expected values converge to the set threshold.
[0036] 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.
[0037] 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.
[0038] The above technical solution of the present invention has the following beneficial technical effects:
[0039] 1. In the embodiment of the present invention, only two types of quantum gates, namely, single-qubit gates and double-qubit gates capable of generating quantum entanglement, can be set in the constructed variational quantum circuit, and each single-qubit gate carries training parameters. By setting the Hamiltonian to a negative value, the expected value is continuously reduced during the training process, and the gradient descent algorithm can be used to minimize the expected value. The training parameters are optimized iteratively for multiple times to obtain a target variational quantum circuit with optimized and fixed training parameters, and then the target quantum state evolved by the target variational quantum circuit can be output to achieve N=2 n 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; and avoids the use of multi-qubit gates, so that the structure of the variational quantum circuit is simplified and the depth of the quantum circuit is reduced, thereby further improving the execution efficiency of the amplitude coding.
[0040] 2. The technical solution of the present invention significantly improves the amplitude coding efficiency of the normalized real vector to be encoded, and fully demonstrates the powerful potential of the variational quantum algorithm; this not only provides a feasible new path for the exploration of quantum computing tasks based on amplitude coding, but also provides valuable inspiration and experience for using variational quantum algorithms to solve other computing problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings in the embodiment of the present invention are briefly introduced below.
[0042] Figure 1 This is a schematic diagram of the structure of an existing amplitude-coded quantum circuit.
[0043] Figure 2 It is a flowchart of a quantum state amplitude encoding method according to an embodiment of the present invention.
[0044] Figure 3 It is a structural schematic diagram of a variational quantum circuit according to an embodiment of the present invention.
[0045] Figure 4 It is a schematic diagram of the structure of another variational quantum circuit according to an embodiment of the present invention.
[0046] Figure 5 It is a schematic diagram of the structure of a target variation quantum circuit according to an embodiment of the present invention.
[0047] Figure 6 It is a structural block diagram of a quantum state amplitude encoding device according to an embodiment of the present invention.
[0048] 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
[0049] 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.
[0050] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a quantum state amplitude encoding method, device, electronic device, and 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.
[0051] 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.
[0052] 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.
[0053] If we use the existing Top-down amplitude coding scheme to encode a set of dimensions of 2 4 =16 elements of the real vector x to be encoded, we can get Figure 1 The quantum circuit shown in the figure contains 49 quantum gates, 15 of which are RY gates with parameters, and multiple multi-qubit gates such as 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^3RY gates represent multi-qubit RY gates with 3 control bits, and C^2RY gates represent multi-qubit RY gates with 2 control bits. In addition, one or more X gates are included between adjacent controlled Ry gates, which complicates the quantum circuit and reduces the execution efficiency of amplitude coding.
[0054] Based on this, the present invention proposes a quantum state amplitude coding method, which uses a variational quantum algorithm to achieve a more efficient amplitude coding method using fewer quantum gates.
[0055] Figure 2 A schematic flow chart of a quantum state amplitude encoding method according to an embodiment of the present invention is shown, and the method comprises the following steps:
[0056] S110: Normalize the real vector to be encoded.
[0057] Specifically, the obtained real vector to be encoded is normalized to achieve the purpose of encoding the input classical data into the amplitude of the quantum state, and it is determined whether the number of elements of the real vector to be encoded is N=2. n , if the number of elements does not meet 2 n , it needs to be padded with zeros to make the number of elements reach 2 n , to meet the coding conditions of amplitude coding; where n is a positive integer.
[0058] S120: Setting a Hamiltonian, where the Hamiltonian is the negative value of the outer product of the normalized real vector to be encoded and itself; wherein the Hamiltonian is a Hermitian matrix.
[0059] Specifically, when amplitude coding is performed on the normalized real vector to be encoded, the corresponding Hamiltonian needs to be set; for example, each element in the column vector matrix and the row vector matrix of the normalized real vector to be encoded is multiplied two by two to obtain the corresponding product, and each product is negatively valued to form a corresponding Hermitian matrix, thereby obtaining the Hamiltonian. By setting the Hamiltonian to a negative value, the expected value is continuously reduced during the training process. For example, the gradient descent algorithm can be used to minimize the expected value, so that the training parameters carried by the quantum gate in the variational quantum circuit are obtained as the optimal parameters.
[0060] S130: Construct a variational quantum circuit according to the normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of hypothetical layers and operation columns that can be repeatedly operated, each hypothetical layer includes a first single-qubit gate and a two-qubit gate that can generate quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last hypothetical layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter.
[0061] Specifically, a variational quantum circuit can be constructed based on the hardware efficient analogy (HEA), according to the normalized real vector to be encoded N = 2 n , the constructed variational quantum circuit can contain n quantum bits; it is assumed that the layers and operation columns can be arranged in order 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 3 , 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 order 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 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 3The hypothetical layers in the dotted box shown in the figure can be set to P, or defined as P layers, for example, P=3, and multiple hypothetical layers can be arranged in sequence from left to right, that is, the hypothetical layers can be repeatedly operated P times; wherein each hypothetical layer can include two different operation columns, one of which is provided with a first single-qubit gate, and the other operation column is provided with a multi-qubit gate that can generate quantum entanglement. Preferably, the multi-qubit gate is set as a double-qubit gate that can generate quantum entanglement, such as a CNOT gate; the first single-qubit gate is, for example, an RY gate, and the training parameter carried is, for example, a rotation angle; the operation column at the output end includes a second single-qubit gate carrying the training parameters, and similarly, the second single-qubit gate can also be set to, for example, an RY gate, and the training parameter carried is, for example, a rotation angle; thus, a variational quantum circuit ansatz to be trained can be constructed based on HEA, in which only the operations of the single-qubit gate and the double-qubit gate need to be performed. Since only two types of quantum gates, single-qubit gates and double-qubit gates, are provided in the variational quantum circuit provided by the embodiment of the present invention, the use of multi-qubit gates is avoided, the structure of the variational quantum circuit is simplified, and the depth of the quantum circuit is reduced, thereby further improving the execution efficiency of amplitude coding and reducing the use of quantum gates.
[0062] S140: Substituting a preset parameter value as a training parameter into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit.
[0063] S150: Measuring the expectation value of the training quantum state after evolution of the variational quantum circuit with respect to the Hamiltonian.
[0064] S160: Training the training parameters of the variational quantum circuit by using a classical optimizer.
[0065] Specifically, a quantum-classical hybrid neural network may be constructed first. The quantum-classical hybrid neural network may include the variational quantum circuit constructed in step S130. The classical optimizer may be, for example, Adam or BFGS. The training parameters of the variational quantum circuit in the quantum-classical hybrid neural network are trained and optimized by the classical optimizer. Each iterative optimization will return a new set of parameters for optimizing the performance of the quantum-classical hybrid neural network that implements amplitude coding.
[0066] S180: In response to the training parameter or the expected value converging to a set threshold, the training quantum state after evolution of the variational quantum circuit is determined as a target quantum state; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
[0067] In the embodiment of the present invention, only two types of quantum gates, namely, single-qubit gates and double-qubit gates capable of generating quantum entanglement, may be set in the constructed variational quantum circuit, and each single-qubit gate carries training parameters, and the Hamiltonian may be set to a negative value so that the expected value is continuously reduced during the training process. The gradient descent algorithm may be used to minimize the expected value, and the training parameters may be iteratively optimized multiple times to obtain a target variational quantum circuit with optimized and fixed training parameters, and then the target quantum state evolved by the target variational quantum circuit may be output to achieve the goal of N=2 n 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; and avoids the use of multi-qubit gates, so that the structure of the variational quantum circuit is simplified and the depth of the quantum circuit is reduced, thereby further improving the execution efficiency of the amplitude coding.
[0068] In an exemplary embodiment, the first single-qubit gate includes one or more of the following: an RX gate, an RY gate, and an RZ gate;
[0069] The two-qubit gate includes a CNOT gate, a CZ gate or a CY gate;
[0070] The first single-qubit gate and the second single-qubit gate are set to be the same quantum gate.
[0071] Among them, compared with multi-qubit gates such as C^4RY gate, C^3RY gate and C^2RY gate, the CRY gate is easier to implement in specific physical experiments; the first single-qubit gate and the second single-qubit gate are set to be the same quantum gate, which can simplify the structure of the variational quantum circuit and facilitate the operation.
[0072] In some embodiments, step S110: normalizing the real vector to be encoded may include the following specific steps (not shown in the figure):
[0073] S111: Determine whether the number of elements of the real vector to be encoded satisfies 2 n , n is an integer greater than or equal to 1;
[0074] 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.
[0075] 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:
[0076]
[0077] Among them, the modulus length of the real vector x to be encoded after normalization is 1, that is,
[0078]
[0079] It can be seen that all components of the real vector x to be encoded exist in quantum states middle The corresponding amplitude.
[0080] 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.
[0081] In some embodiments, step S130: constructing a variational quantum circuit according to the normalized real vector to be encoded may include the following specific steps (not shown in the figure):
[0082] S131: Initializing a variational quantum circuit; wherein the initialized variational quantum circuit includes n quantum bits arranged in order from low to high;
[0083] S132: setting each of the first single-qubit gate and the second single-qubit gate on n qubits;
[0084] S133: setting the target bit of each of the two-qubit gates on the second to nth qubits located at the second lowest position, respectively, and the control bit of the two-qubit gate is the previous low-position qubit adjacent to the target qubit of the two-qubit gate.
[0085] Specifically, if the dimension of the normalized real vector to be encoded is N=2 n The initialized variational quantum circuit may include n quantum bits arranged in order from low to high, which can be recorded as q0, q1, q2…q n ; The number of layers of the proposed layer can be set as needed. The more the number of the proposed layers is set, the more accurate the calculation result can be. However, when the number is set too much, the calculation result will not necessarily be more accurate. The first single-qubit gate in the proposed layer can be set as an uncontrolled RY gate, and the training parameters it carries can be expressed as , The second single-qubit gate in the operation column can be set as an uncontrolled RY gate, and the training parameters it carries can be expressed as θ1, θ2, ... θ n; The training parameters carried by each RY gate are set to be different; the operation column where the first single-qubit gate and the operation column where the double-qubit gate are located in the proposed layer can be repeatedly arranged from left to right in P layers, and the two ends of the operation column where the second single-qubit gate is located are respectively connected to the operation column and the output end where the last double-qubit gate is located.
[0086] In some embodiments, the method may further include the following specific steps (not shown in the figure):
[0087] S170: In response to the training parameters or expected values not converging to the set threshold, the new training parameters obtained through training are again substituted into the variational quantum circuit, and the measurement step S150 and the training step S160 are repeated until the new training parameters or expected values converge to the set threshold.
[0088] In an exemplary embodiment, step S170: in response to the training parameter or expected value not converging to the set threshold, the new training parameter obtained through training is again substituted into the variational quantum circuit, and the measurement step S150 and the training step S160 are repeated until the new training parameter or expected value converges to the set threshold, which may include the following specific steps (not shown in the figure):
[0089] S171: further training and optimizing the training parameters of the variational quantum circuit by a classical optimizer according to the measured expected value of the training quantum state with respect to the Hamiltonian, and returning a new set of training parameters after each iterative optimization;
[0090] S172: 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;
[0091] S173: When the training parameters of the variational quantum circuit are optimized through multiple iterations so that the training parameters or expected values converge to a set threshold, the training is stopped.
[0092] Specifically, in the deep learning of the machine, the gradient descent algorithm is used to minimize the loss function, that is, the loss value calculated by the loss function is minimized to obtain the optimal training parameters. In the embodiment of the present invention, the significant characteristics of the ground state of the quantum system may include, but are not limited to, the energy of the Hamiltonian in the ground state can be minimized. In order to obtain the ground state of the quantum system, the energy expectation value of the training quantum state with respect to the Hamiltonian can be regarded as the loss function to be optimized, for example, the rotation angle of each single quantum bit gate (such as the RY gate) in the variational quantum circuit is adjusted using the gradient descent method, so as to optimize the energy expectation value of the training quantum state with respect to the Hamiltonian. By setting the Hamiltonian to a negative value so that the expected value is continuously reduced during the training process, the gradient descent algorithm can be used to minimize the expected value, that is, the expected value can approach -1, so as to obtain the optimal training parameters. Substitute the returned new training parameters into the variational quantum circuit to output the training quantum state after the variational quantum circuit evolves again, measure the variational quantum circuit to obtain the expected value of the training quantum state with respect to the Hamiltonian, and use the result obtained from this measurement for further training, and reversely adjust the training parameters in the variational quantum circuit; when the expected value obtained by measurement is the smallest, that is, it approaches -1, stop training, and obtain the optimal training parameters; at this time, fix the training parameters to obtain the target variational quantum circuit.
[0093] In some embodiments, the method may further include the following specific steps:
[0094] The expected value is set equal to -1 or close to -1 to stop training the training parameters in the variational quantum circuit; thus, the fidelity between the target quantum state after evolution of the variational quantum circuit and the real vector to be encoded is close to 1.
[0095] 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.
[0096] Another quantum state amplitude encoding method provided by an embodiment of the present invention may include the following specific steps (not shown in the figure):
[0097] Step S1: Get an N=2 n The normalized real vector to be encoded , where the modulus of the vector x to be encoded after normalization preprocessing is 1, T represents transposition, and x i is a real number, and i=0,1,2,...,N-1. If the dimension of the vector to be encoded x is not equal to 2 n , you can add appropriate 0 to make its dimension equal to 2 n .
[0098] For example, suppose N=16=24 The real vector x to be encoded of dimension is as follows:
[0099] x=[0.21042948 0.38521102 0.31137822 0.11487464 0.08991813 0.279145460.06798987 0.15964005 0.25141497 0.16756735 0.00100268 0.35961181 0.359984160.12220242 0.23983358 0.39801026]^T,
[0100] Among them, the real vector x to be encoded is already a normalized vector, that is, n=4, and the modulus length of the real vector is 1.
[0101] Step S2: Set the corresponding Hamiltonian according to the normalized real vector to be encoded. Thus, the Hamiltonian can be set to Ham=-outer(x, x), where outer represents the outer product between the vectors to be encoded. At this time, the Hamiltonian Ham is an Hermitian matrix, that is, it satisfies Ham^{dagger}=Ham, where dagger represents the conjugate transpose. The reason why the Hamiltonian Ham is negative is to continuously reduce the expected value in the subsequent training process.
[0102] For example, for N=16=2 in the above steps 4 The Hamiltonian Ham is calculated by using the real vector x to be encoded.
[0103] <h2 style=";text-align:left;direction:ltr">[[-4.42805642e-02 -8.10597524e-02 -6.55231562e-02 -2.41730108e-02 -1.89214256e-02 -5.87404319e-02 -1.43070723e-02 -3.35929730e-02 -5.29051201e-02 -3.52611089e-02 -2.10993189e-04 -7.56729247e-02 -7.57512790e-02 -2.57149912e-02 -5.04680542e-02 -8.37530894e-02] [-8.10597524e-02 -1.48387528e-01 -1.19946322e-01 -4.42509779e-02 -3.46374555e-02 -1.07529905e-01 -2.61904463e-02 -6.14951079e-02 -9.68478160e-02 -6.45487882e-02 -3.86242949e-04 -1.38526431e-01 -1.38669866e-01 -4.70737187e-02 -9.23865369e-02 -1.53317936e-01] [-6.55231562e-02 -1.19946322e-01 -9.69563977e-02 -3.57694620e-02 -2.79985485e-02 -8.69198160e-02 -2.11705643e-02 -4.97084365e-02 -7.82851462e-02 -5.21768227e-02 -3.12212365e-04 -1.11975287e-01 -1.12091229e-01 -3.80511725e-02 -7.46789536e-02 -1.23931726e-01] [-2.41730108e-02 -4.42509779e-02 -3.57694620e-02 -1.31961834e-02 -1.03293134e-02 -3.20667344e-02 -7.81031178e-03 -1.83385942e-02 -2.88812046e-02 -1.92492390e-02 -1.15182377e-04 -4.13102781e-02 -4.13530521e-02 -1.<h2 style=";text-align:left;direction:ltr">40379593e-02 -2.75507966e-02 -4.57212857e-02] [-1.89214256e-02 -3.46374555e-02 -2.79985485e-02 -1.03293134e-02 -8.08527063e-03 -2.51002382e-02 -6.11352200e-03 -1.43545357e-02 -2.26067646e-02 -1.50673430e-02 -9.01590121e-05 -3.23356226e-02 -3.23691040e-02 -1.09882135e-02 -2.15653876e-02 -3.57883391e-02] [-5.87404319e-02 -1.07529905e-01 -8.69198160e-02 -3.20667344e-02 -2.51002382e-02 -7.79221855e-02 -1.89790627e-02 -4.45627958e-02 -7.01813461e-02 -4.67756634e-02 -2.79893251e-04 -1.00384003e-01 -1.00487944e-01 -3.41122503e-02 -6.69484537e-02 -1.11102754e-01] [-1.43070723e-02 -2.61904463e-02 -2.11705643e-02 -7.81031178e-03 -6.11352200e-03 -1.89790627e-02 -4.62262216e-03 -1.08539063e-02 -1.70936706e-02 -1.13928818e-02 -6.81720042e-05 -2.44499596e-02 -2.44752758e-02 -8.30852643e-03 -1.63062534e-02 -2.70606648e-02] [-3.35929730e-02 -6.14951079e-02 -4.97084365e-02 -1.83385942e-02 -1.43545357e-02 -4.45627958e-02 -1.08539063e-02 -2.54849471e-02 -4.01358994e-02 -2.67504604e-02 -1.60067710e-04 -5.<h2 style=";text-align:left;direction:ltr">74084491e-02 -5.74678917e-02 -1.95084011e-02 -3.82870456e-02 -6.35383789e-02] [-5.29051201e-02 -9.68478160e-02 -7.82851462e-02 -2.88812046e-02 -2.26067646e-02 -7.01813461e-02 -1.70936706e-02 -4.01358994e-02 -6.32094866e-02 -4.21289393e-02 -2.52088477e-04 -9.04117922e-02 -9.05054075e-02 -3.07235177e-02 -6.02977517e-02 -1.00065736e-01] [-3.52611089e-02 -6.45487882e-02 -5.21768227e-02 -1.92492390e-02 -1.50673430e-02 -4.67756634e-02 -1.13928818e-02 -2.67504604e-02 -4.21289393e-02 -2.80788157e-02 -1.68016238e-04 -6.02591970e-02 -6.03215913e-02 -2.04771353e-02 -4.01882765e-02 -6.66935225e-02] [-2.10993189e-04 -3.86242949e-04 -3.12212365e-04 -1.15182377e-04 -9.01590121e-05 -2.79893251e-04 -6.81720042e-05 -1.60067710e-04 -2.52088477e-04 -1.68016238e-04 -1.00536492e-06 -3.60575165e-04 -3.60948516e-04 -1.22529785e-04 -2.40476062e-04 -3.99076474e-04] [-7.56729247e-02 -1.38526431e-01 -1.11975287e-01 -4.13102781e-02 -3.23356226e-02 -1.00384003e-01 -2.44499596e-02 -5.74084491e-02 -9.04117922e-02 -6.<h2 style=";text-align:left;direction:ltr">02591970e-02 -3.60575165e-04 -1.29320654e-01 -1.29454557e-01 -4.39454336e-02 -8.62469875e-02 -1.43129189e-01] [-7.57512790e-02 -1.38669866e-01 -1.12091229e-01 -4.13530521e-02 -3.23691040e-02 -1.00487944e-01 -2.44752758e-02 -5.74678917e-02 -9.05054075e-02 -6.03215913e-02 -3.60948516e-04 -1.29454557e-01 -1.29588599e-01 -4.39909362e-02 -8.63362905e-02 -1.43277389e-01] [-2.57149912e-02 -4.70737187e-02 -3.80511725e-02 -1.40379593e-02 -1.09882135e-02 -3.41122503e-02 -8.30852643e-03 -1.95084011e-02 -3.07235177e-02 -2.04771353e-02 -1.22529785e-04 -4.39454336e-02 -4.39909362e-02 -1.49334315e-02 -2.93082438e-02 -4.86378165e-02] [-5.04680542e-02 -9.23865369e-02 -7.46789536e-02 -2.75507966e-02 -2.15653876e-02 -6.69484537e-02 -1.63062534e-02 -3.82870456e-02 -6.02977517e-02 -4.01882765e-02 -2.40476062e-04 -8.62469875e-02 -8.63362905e-02 -2.93082438e-02 -5.75201455e-02 -9.54562240e-02] [-8.37530894e-02 -1.53317936e-01 -1.23931726e-01 -4.57212857e-02 -3.57883391e-02 -1.11102754e-01 -2.70606648e-02 -6.35383789e-02 -1.00065736e-01 -6.66935225e-02 -3.99076474e-04 -1.43129189e-01 -1.43277389e-01 -4.86378165e-02 -9.54562240e-02 -1.58412163e-01]].
[0104] At this time, the Hamiltonian Ham is a 16×16 Hermitian matrix.
[0105] Step S3: Construct a variational quantum circuit ansatz containing n qubits to be trained based on the hardware efficient anatomy (HEA quantum circuit). Each anatomy layer can contain two main parts:
[0106] 1. Any single-qubit gate operation, such as RX gate, RY gate and / or RZ gate;
[0107] 2. Two-qubit gate operations that can generate quantum entanglement, such as CNOT gates, CZ gates, or CY gates.
[0108] Therefore, an effective variational quantum circuit ansatz can be constructed as Figure 4 As shown, in this variational quantum circuit, the RY gate carries a training parameter, which is the parameter value of the rotation angle and is a parameter that needs to be trained.
[0109] For example, according to the above steps, N=16=2 4 dimensional real vector x to be encoded, a variational quantum circuit ansatz containing 4 qubits can be constructed, such as Figure 4 As shown, the number of layers of the proposed layer is set to p=3; among them, the four quantum bits arranged from low to high can be recorded as q0, q1, q2, and q3, and each proposed layer includes four RY gates and three CNOT gates, and the four RY gates are respectively set on quantum bits q0, q1, q2, and q3; the target bits of the three CNOT gates are quantum bits q1, q2, and q3, and the control bits are respectively quantum bits q0, q1, and q2; the operation column at the output end may include four RY gates, which are also respectively set on quantum bits q0, q1, q2, and q3; there are a total of 16 RY gates carrying training parameters, di_nj represents the training parameters, and i, j both belong to {0,1,2,3}; it can be seen that the variational quantum circuit uses a total of 25 quantum gates.
[0110] Step S4: the quantum state after the evolution of the variational quantum circuit ansatz is |Ψ>, and the expectation value exp of the quantum state |Ψ> with respect to the Hamiltonian Ham is measured, that is, the expectation value exp=<Ψ|Ham|Ψ>.
[0111] Step S5: Build a complete quantum-classical hybrid neural network. Use classical optimizers (such as Adam, BFGS, etc.) to train and optimize the training parameters of the ansatz in the quantum-classical hybrid neural network. Each iterative optimization returns a new set of training parameters for optimizing the performance of the quantum-classical hybrid neural network that implements amplitude coding.
[0112] Step S6: Substitute the new training parameters into ansatz, and repeat steps S4-S5 until the training parameters or expected values converge to the set threshold. For example, setting the threshold of the expected value exp to -1 means that the fidelity between the quantum state obtained through training and the original real vector x is close to 1. By setting the threshold of the expected value exp to -1, the training parameters di_nj in the variational quantum circuit ansatz can be adjusted in reverse. After multiple iterations of optimization, the expected value exp can be equal to -1 or as close to -1 as possible, and the training stops. Finally, the target quantum circuit ansatz_final with fixed parameters is obtained.
[0113] For example, the target variational quantum circuit ansatz_final is Figure 5 As shown, the final fixed parameters after training are as follows:
[0114] [-0.44423056 -0.25118572 -0.06354025 -0.00930746 1.1972257 0.025820241.0455806 0.52918625 1.8388337 1.1658182 0.9188692 0.5229698 0.126079870.9351992 -0.48465225 1.0493081 ]
[0115] During the entire training process, a total of about 990 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 1.295602 seconds). The changes in each training step and expected value during the training process are as follows:
[0116] None
[0117] 0 : [-0.04255519]
[0118] 10 : [-0.6775894]
[0119] 20 : [-0.86930984]
[0120] 30 : [-0.95029]
[0121] 40 : [-0.96759975]
[0122] 50 : [-0.98247015]
[0123] 60 : [-0.98882717]
[0124] 70 : [-0.9901503]
[0125] 80 : [-0.99076074]
[0126] 90 : [-0.99089575]
[0127] 100 : [-0.99104005]
[0128] 110 : [-0.9911602]
[0129] 120 : [-0.99123764]
[0130] 130 : [-0.9912885]
[0131] 140 : [-0.99133205]
[0132] 150 : [-0.9913709]
[0133] 160 : [-0.9914081]
[0134] 170 : [-0.99144703]
[0135] 180 : [-0.99148995]
[0136] 190 : [-0.9915388]
[0137] 200 : [-0.9915955]
[0138] 210 : [-0.9916618]
[0139] 220 : [-0.99173987]
[0140] 230 : [-0.9918321]
[0141] ……
[0142] 970 : [-1.]
[0143] 980 : [-1.]
[0144] 990 : [-1.] 0:00:01.295602
[0146] Step S7: Output the quantum state |x_final> after the ansatz_final evolution. At this time, the quantum state |x_final> is the quantum state corresponding to the amplitude encoding of the normalized real vector to be encoded. For example, for the above-obtained N=16=2 4 The amplitude coding is realized by using the real vector x to be encoded. The final output quantum state |x_final> is as follows: 0.21046750068442527¦0000>
[0147] 0.38517577287474386¦0001>
[0148] 0.3114179248057258¦0010>
[0149] 0.11486494677428552¦0011>
[0150] 0.08990017715608153¦0100>
[0151] 0.2791375100868563¦0101>
[0152] 0.06797395632102034¦0110>
[0153] 0.15966822558535612¦0111>
[0154] 0.25139158880323353¦1000>
[0155] 0.1675720229278468¦1001>
[0156] 0.0009939301216072005¦1010>
[0157] 0.35962436595951475¦1011>
[0158] 0.35995353593510115¦1100>
[0159] 0.12222505277059573¦1101>
[0160] 0.239829890603705¦1110>
[0161] 0.39802149264403036¦1111>>
[0162] It can be seen that the quantum state has a total of 16 amplitudes, which correspond to the 16 elements of the real vector to be encoded x=[0.210429480.38521102 0.31137822 0.11487464 0.08991813 0.27914546 0.06798987 0.159640050.25141497 0.16756735 0.00100268 0.35961181 0.35998416 0.12220242 0.239833580.39801026], so the method steps provided in the embodiment of the present invention can be used to successfully encode classical data accurately into the quantum state amplitude, and accurately map the real vector to be encoded to its corresponding amplitude-encoded quantum state.
[0163] It is not difficult to see from the above data that the simulation experiment was carried out in the MindSpore Quantum quantum computing software. The experimental results show that the technical solution of the present invention successfully realizes the amplitude encoding of the normalized real vector x to be encoded, and obtains its corresponding encoded quantum state |x_final>, and the fidelity can reach 1. This result fully proves the accuracy of the technical solution of the present invention in amplitude encoding. In addition, the training time is about 1.295602 seconds, showing extremely high efficiency.
[0164] In other words, the variational quantum algorithm proposed by the technical solution of the present invention efficiently realizes the amplitude encoding of the normalized real vector x to be encoded. This variational quantum algorithm is not only efficient, but also can accurately output the amplitude-encoded quantum state corresponding to the normalized real vector x to be encoded. Based on this result, various computational tasks of further quantum algorithms can be performed.
[0165] If the existing Top-down amplitude coding scheme is used to encode the dimension 2 in the above step S1 4 =16 to encode the real vector x to be encoded, we can get Figure 1 The quantum circuit shown contains a total of 49 quantum gates, of which 15 are RY gates with parameters, and multiple C^3RY gates and C^2RY gates need to be executed multiple times. If the angle tree algorithm in the existing amplitude coding method is used, the parameters of the 15 RY gates can be obtained by calculating the real vector x to be encoded. The specific parameter values are as follows:
[0166] ParameterResolver(dtype: float64,
[0167] data: [
[0168] alpha0: 1.733644,
[0169] alpha1: 1.108878,
[0170] alpha10: 2.336336,
[0171] alpha11: 1.175770,
[0172] alpha12: 3.136016,
[0173] alpha13: 0.654520,
[0174] alpha14: 2.056962,
[0175] alpha2: 1.813852,
[0176] alpha3: 1.294817,
[0177] alpha4: 1.068524,
[0178] alpha5: 1.744063,
[0179] alpha6: 1.770228,
[0180] alpha7: 2.141642,
[0181] alpha8: 0.706865,
[0182] alpha9: 2.518344
[0183] ],
[0184] const: 0.000000 )
[0186] Among them, in each parameter of the above original amplitude coding, the left side indicates the parameter name and the right 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.
[0187] 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 16-dimensional real vector to be encoded, the technical solution of the present invention successfully reduces the number of quantum gates required from 49 (such as Figure 1The number of quantum circuits is reduced from 2 to 25, and the depth of quantum circuits is reduced from 34 (as shown in Figure 1 The quantum circuit shown in the figure is reduced to 13, which greatly simplifies the complexity of the quantum circuit. Secondly, the variational quantum circuit of the technical solution of the present invention only relies on the operation of single-qubit gates and double-qubit gates, without the need to perform multi-qubit gates. This makes the technical invention solution more likely to be implemented in physical experiments.
[0188] Corresponding to the method embodiment of the present invention, the present invention also provides a quantum state amplitude encoding device, such as Figure 6 As shown, specifically, it may include:
[0189] A normalization module 510, which is used to perform normalization processing on the real vector to be encoded;
[0190] A setting module 520, which is used to set a Hamiltonian, where the Hamiltonian is the negative value of the outer product of the normalized real vector to be encoded and itself;
[0191] A construction module 530, which is used to construct a variational quantum circuit according to the normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of assumed layers and operation columns that can be repeatedly operated, each assumed layer includes a first single-qubit gate and a two-qubit gate that can generate quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last assumed layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter;
[0192] A substitution module 540, which is used to substitute a preset parameter value as a training parameter into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit;
[0193] A measurement module 550, which is used to measure the expected value of the training quantum state after the evolution of the variational quantum circuit with respect to the Hamiltonian;
[0194] A training module 560, which is used to train the training parameters of the variational quantum circuit by a classical optimizer;
[0195] The first response module 570 is used to determine the quantum state after the evolution of the variational quantum circuit as the target quantum state in response to the training parameter or the expected value converging to the set threshold; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
[0196] In some embodiments, the above-mentioned device also includes: a second response module, which is used to substitute the new training parameters obtained through training into the variational quantum circuit again in response to the training parameters or expected values not converging to the set threshold, and repeat the measurement module and the training module until the new training parameters or expected values converge to the set threshold.
[0197] 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.
[0198] 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.
[0199] In one example, Figure 7 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.
[0200] 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.
[0201] 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.
[0202] 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.
[0203] 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.
[0204] 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 quantum state amplitude encoding method, characterized in that: include: Normalize the real vector to be encoded; Setting a Hamiltonian, wherein the Hamiltonian is the negative value of the outer product of the normalized real vector to be encoded and itself; A variational quantum circuit is constructed according to the normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of repeatedly operable pseudo-layers and operation columns, each pseudo-layer includes a first single-qubit gate and a double-qubit gate capable of generating quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last pseudo-layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter; Substituting preset parameter values as training parameters into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit; Measuring the expectation value of the training quantum state after evolution of the variational quantum circuit with respect to the Hamiltonian; Training the training parameters of the variational quantum circuit by a classical optimizer; In response to the training parameter or expected value converging to a set threshold, the training quantum state after evolution of the variational quantum circuit is determined as the target quantum state; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
2. The method according to claim 1, characterized in that: The first single-qubit gate includes one or more of the following: an RX gate, an RY gate, and an RZ gate; The two-qubit gate includes a CNOT gate, a CZ gate or a CY gate; The first single-qubit gate and the second single-qubit gate are set to be the same quantum gate.
3. The method according to claim 1, 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 , n is an integer greater than or equal to 1; 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.
4. The method according to claim 3, characterized in that The step of constructing a variational quantum circuit according to the normalized real vector to be encoded includes: Initialize the variational quantum circuit so that the n quantum bits in the variational quantum circuit are arranged in order from low to high; Setting each of the first single-qubit gate and the second single-qubit gate on n qubits; The target bit of each of the two-qubit gates is set on the second to nth qubits located at the second lowest position, and the control bit of the two-qubit gate is the previous low-position qubit adjacent to the target qubit of the two-qubit gate.
5. The method according to claim 1, characterized in that Also includes: In response to the training parameters or expected values not converging to the set threshold, the new training parameters obtained through training are again substituted into the variational quantum circuit, and the measuring step and the training step are repeated until the new training parameters or expected values converge to the set threshold.
6. The method according to any one of claims 1 to 5, characterized in that: The expected value is set to -1.
7. A quantum state amplitude encoding device, characterized in that: include: A normalization module, which is used to normalize the real vector to be encoded; A setting module, which is used to set a Hamiltonian, where the Hamiltonian is the negative value of the outer product of a normalized real vector to be encoded and itself; A construction module, which is used to construct a variational quantum circuit according to a normalized real vector to be encoded; wherein the variational quantum circuit includes a plurality of assumed layers and operation columns that can be repeatedly operated, each assumed layer includes a first single-qubit gate and a double-qubit gate that can generate quantum entanglement, and each first single-qubit gate carries a training parameter; the operation column is located between the last assumed layer and the output end of the variational quantum circuit, and the operation column includes a second single-qubit gate carrying the training parameter; A substitution module, which is used to substitute a preset parameter value as a training parameter into the variational quantum circuit to output a training quantum state after evolution of the variational quantum circuit; A measurement module, which is used to measure the expected value of the training quantum state after evolution of the variational quantum circuit with respect to the Hamiltonian; A training module, which is used to train the training parameters of the variational quantum circuit by a classical optimizer; A first response module is used to determine the quantum state evolved through the variational quantum circuit as a target quantum state in response to the training parameter or expected value converging to a set threshold; wherein the normalized real vector to be encoded is mapped to the amplitude of the target quantum state.
8. The device according to claim 7, characterized in that Also includes: The second response module is used to substitute the new training parameters obtained through training into the variational quantum circuit again in response to the training parameters or expected values not converging to the set threshold, and repeat the measurement module and the training module until the new training parameters or expected values converge to the set threshold.
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 1 to 6 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 1 to 6 is implemented.
Citation Information
Patent Citations
Method for solving Hamiltonian expected value of preset quantum circuit and related device
CN118504697A
Construction method and device of variable component sub-circuit, medium and electronic device
CN118863078A