A gradient calculation method and device for accelerating a variational quantum algorithm training process, a terminal and a medium
By constructing a trust region in the variable quantum algorithm and training a neural network to predict gradients, the problem of high gradient computation cost is solved, and efficient training of the variable quantum algorithm is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 粤港澳大湾区(广东)量子科学中心
- Filing Date
- 2025-12-31
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, the gradient computation cost of variational quantum algorithms scales linearly and consumes a lot of resources, which hinders the practical application of large-scale quantum algorithms.
Construct a trust region and sample parameter points within it, compute the true gradient labels, train a neural network to predict the gradient, update the parameters using the neural network only within the trust region, and switch to the quantum parameter translation rule when outside the region.
It significantly reduces the number of online quantum gradient evaluations, shortens the training time of the variable quantum algorithm, reduces clockwork time, and improves training speed.
Smart Images

Figure CN122114218A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum computing technology, and in particular to a gradient calculation method, apparatus, terminal, and medium for accelerating the training process of variable quantum algorithms. Background Technology
[0002] Current quantum computing is in the noisy mesoscale quantum era, limited by the number of qubits and noise levels, making it impossible to execute deep quantum error correction circuits. Against this backdrop, variational quantum algorithms have become the mainstream paradigm for realizing the potential of near-term quantum applications. By combining parameterized quantum circuits, classical optimizers, and quantum processing units, variational quantum algorithms are widely used in quantum machine learning, quantum chemical simulations (such as variational quantum eigenvalue solvers), and combinatorial optimization problems.
[0003] The core of the variational quantum algorithm is a hybrid optimization closed loop: a classical computer sends a set of parameters θ to a quantum computer; the quantum computer executes the corresponding parameterized quantum circuit and measures the expected value of the observables; the classical optimizer calculates the loss function and its gradient based on the measurement results and updates the parameters, repeating this process until convergence. Among these steps, gradient calculation is the key factor determining training efficiency.
[0004] Currently, the industry-standard method for obtaining gradients on real quantum hardware is the parameter shift rule. The parameter shift rule utilizes the mathematical structure of quantum gates to transform the partial derivative of a parameter into the difference between the expected values of two shifted quantum circuits. For a parameterized quantum circuit with P trainable parameters, calculating a complete gradient vector requires 2P independent quantum circuit evaluations. As the size of the quantum circuit increases (the number of qubits increases or the number of circuit layers deepens), the number of parameters P grows rapidly (typically hundreds or even thousands). Due to the slow serial processing speed of current quantum computers (requiring a large number of measurements), this linear complexity of O(P) results in an extremely long "wall-clock time" required to train a model, severely hindering the practical application of large-scale quantum algorithms.
[0005] There are other alternatives to the existing technique of parameter shifting rules, but they all have obvious limitations: although quantum natural gradient can accelerate convergence, each step requires calculating the quantum Fisher information matrix, with a computational complexity as high as O(P). 3 Instead, it exacerbates resource consumption; although the stochastic gradient method reduces the cost per step, it does not change the fact that the cost of gradient calculation scales linearly with the number of parameters; some methods require quantum gates to satisfy specific mathematical properties (such as commutativity), which limits the flexibility and expressiveness of circuit design and lacks universality.
[0006] Therefore, existing technologies have shortcomings and need to be improved and developed. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a gradient calculation method, device, terminal and medium for accelerating the training process of variable quantum algorithms, in view of the above-mentioned defects of the prior art. It aims to solve the problems of linear expansion of gradient calculation cost caused by parameter shifting rules in the prior art, as well as the high resource consumption or poor versatility of other alternative solutions.
[0008] The technical solution adopted by this invention to solve the technical problem is as follows: In a first aspect, the present invention discloses a gradient calculation method for accelerating the training process of a variational quantum algorithm, wherein the method includes: Determine the initial parameter vector of the current parameterized quantum circuit, and construct a trust region centered on the initial parameter vector; Multiple parameter points are uniformly sampled within the trust region, and the true gradient label corresponding to each parameter point is calculated; A training dataset is constructed based on each parameter point and its corresponding true gradient label, and a neural network is trained based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network. During the online optimization iteration of the variational quantum algorithm, it is determined whether the current parameter vector is located within the trust region; When the current parameter vector is within the trust region, the trained neural network outputs the predicted gradient corresponding to the current parameter vector to update the current parameter vector of the current parameterized quantum circuit.
[0009] Optionally, calculating the true gradient label corresponding to each parameter point includes: The true gradient label corresponding to each parameter point is calculated using a preset standard parameter translation rule or a preset finite difference method.
[0010] Optionally, after determining whether the current parameter vector is within the trust region, the method further includes: If the current parameter vector is not located within the trust region, the gradient corresponding to the current parameter vector is calculated using the preset standard parameter translation rule, and the trained neural network is fine-tuned.
[0011] Optionally, determining whether the current parameter vector is within the trust region includes: Calculate the distance between the current parameter vector and the initial parameter vector, and determine the comparison threshold based on the width of the trust region; The distance is compared with the comparison threshold to obtain the corresponding comparison result; Based on the comparison result, determine whether the current parameter vector is located within the trust region; Determining whether the current parameter vector is within the trust region based on the comparison result includes: If the comparison result indicates that the distance is less than the comparison threshold, then the current parameter vector is determined to be within the trust region. If the comparison result indicates that the distance is not less than the comparison threshold, then it is determined that the current parameter vector is not located within the trust region.
[0012] Optionally, the trust region is a geometrically shaped sampling region centered on the initial parameter vector.
[0013] Optionally, the geometric sampling region is a hypercube sampling region; the hypercube sampling region is: ; in, For the initial parameter vector, For the width of the trust region, The number of parameters in a parameterized quantum circuit.
[0014] Optionally, the neural network is a multilayer fully connected network, a recurrent neural network, or a one-dimensional convolutional neural network. The activation function in the neural network is a cosine activation function, Tanh, ReLU, or Sigmoid. The output layer of the neural network contains multiple neurons, each corresponding to the gradient values of multiple parameters. The input layer of the neural network is used to encode the input features according to a preset periodic encoding method to capture the periodic features of the quantum gate.
[0015] Secondly, the present invention also discloses a gradient calculation device for accelerating the training process of a variational quantum algorithm, wherein the device comprises: Trust region construction module is used to determine the initial parameter vector of the current parameterized quantum circuit and construct a trust region centered on the initial parameter vector; The true gradient label calculation module is used to uniformly sample multiple parameter points within the trust region and calculate the true gradient label corresponding to each parameter point. The neural network training module is used to construct a training dataset based on each parameter point and its corresponding true gradient label, and to train the neural network based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network. The judgment module is used to determine whether the current parameter vector is located within the trust region during the online optimization iteration of the variational quantum algorithm. The gradient prediction module is used to output the predicted gradient corresponding to the current parameter vector using the trained neural network when the current parameter vector is located within the trust region, so as to update the current parameter vector of the current parameterized quantum circuit.
[0016] Thirdly, the present invention discloses a terminal, comprising: a memory, a processor, and a gradient calculation program stored in the memory and executable on the processor for accelerating the training process of a variable quantum algorithm. When the gradient calculation program for accelerating the training process of the variable quantum algorithm is executed by the processor, it implements the steps of the gradient calculation method for accelerating the training process of the variable quantum algorithm as described above.
[0017] Fourthly, the present invention discloses a computer-readable storage medium storing a computer program that can be executed to implement the steps of the gradient calculation method for accelerating the training process of the variational quantum algorithm as described above.
[0018] This invention provides a gradient calculation method, apparatus, terminal, and medium for accelerating the training process of a variational quantum algorithm. The gradient calculation method for accelerating the training process of a variational quantum algorithm includes: determining an initial parameter vector of a current parameterized quantum circuit and constructing a trust region centered on the initial parameter vector; uniformly sampling multiple parameter points within the trust region and calculating the true gradient label corresponding to each parameter point; constructing a training dataset based on each parameter point and its corresponding true gradient label, and training a neural network based on the training dataset so that the neural network outputs a predicted value for the true gradient label within the trust region, thereby obtaining a trained neural network; during the online optimization iteration process of the variational quantum algorithm, determining whether the current parameter vector is located within the trust region; when the current parameter vector is located within the trust region, using the trained neural network to output the predicted gradient corresponding to the current parameter vector to update the current parameter vector of the current parameterized quantum circuit. Therefore, this invention constructs a trust region centered on the initial parameter vector, samples parameter points from it, calculates the true gradient labels corresponding to the sampled parameter points, and trains a neural network based on the sampled parameter points and their true gradient labels to output predicted values of the true gradient labels. Thus, during the online optimization iteration of the variational quantum algorithm, when the current parameter vector, which is the current optimization point, is located within the trust region, the trained neural network can directly predict the predicted gradient corresponding to the current parameter vector to update the current parameter vector, thereby reducing the quantum overhead of gradient calculation to zero. This decouples the online training time of the variational quantum algorithm from the number of parameters, significantly reducing the number of online quantum gradient evaluations and shortening the clock time of the variational quantum algorithm training. Attached Figure Description
[0019] Figure 1 This is a flowchart of a preferred embodiment of the gradient calculation method for accelerating the training process of the variable quantum algorithm in this invention; Figure 2 This is a schematic diagram illustrating a specific variable quantum algorithm disclosed in this invention and its application; Figure 3 This is a flowchart of a preferred embodiment of a gradient calculation method for accelerating the training process of a variable quantum algorithm disclosed in this invention; Figure 4 This is a schematic diagram comparing the complexity of variable global and local sampling as disclosed in this invention; Figure 5 This is a functional principle block diagram of a preferred embodiment of the gradient calculation device for accelerating the training process of the variable quantum algorithm in this invention; Figure 6 This is a functional principle block diagram of a preferred embodiment of the terminal in this invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0021] Current quantum computing is in the noisy mesoscale quantum era, limited by the number of qubits and noise levels, making it impossible to execute deep quantum error correction circuits. Against this backdrop, variational quantum algorithms have become the mainstream paradigm for realizing the potential of near-term quantum applications. By combining parameterized quantum circuits, classical optimizers, and quantum processing units, variational quantum algorithms are widely used in quantum machine learning, quantum chemical simulations (such as variational quantum eigenvalue solvers), and combinatorial optimization problems.
[0022] The core of the variational quantum algorithm is a hybrid optimization closed loop: a classical computer sends a set of parameters θ to a quantum computer; the quantum computer executes the corresponding parameterized quantum circuit and measures the expected value of the observables; the classical optimizer calculates the loss function and its gradient based on the measurement results and updates the parameters, repeating this process until convergence. Gradient calculation is the key step that determines training efficiency.
[0023] Currently, the industry-standard method for obtaining gradients on real quantum hardware is the parameter shift rule. The parameter shift rule utilizes the mathematical structure of quantum gates to transform the partial derivative of a parameter into the difference between the expected values of two shifted quantum circuits, i.e.: ; Therefore, in order to obtain the derivative of a certain parameter, the quantum circuit must be run twice more, which is the linear expansion cost caused by the parameter shifting rule.
[0024] For example, for a parameterized quantum circuit with P trainable parameters, computing a complete gradient vector requires 2P independent quantum circuit evaluations. As the size of the quantum circuit increases (the number of qubits increases or the number of circuit layers increases), the number of parameters P grows rapidly (typically to hundreds or even thousands). Because current quantum computers are slow to process sequentially (requiring a large number of measurements), this linear complexity of O(P) makes the "wall-clock time" required to train a model extremely long, severely hindering the practical application of large-scale quantum algorithms.
[0025] There are other alternatives to the existing technique of parameter shifting rules, but they all have obvious limitations: although quantum natural gradient can accelerate convergence, each step requires calculating the quantum Fisher information matrix, with a computational complexity as high as O(P). 3 Instead, it exacerbates resource consumption; although the stochastic gradient method reduces the cost per step, it does not change the fact that the cost of gradient calculation scales linearly with the number of parameters; some methods require quantum gates to satisfy specific mathematical properties (such as commutativity), which limits the flexibility and expressiveness of circuit design and lacks universality.
[0026] To this end, this application provides a gradient calculation scheme for accelerating the training process of the variable quantum algorithm, which can significantly reduce the number of online quantum gradient evaluations and shorten the training time of the variable quantum algorithm.
[0027] Please see Figure 1 , Figure 1 This is a flowchart of the gradient calculation method used in this invention to accelerate the training process of the variational quantum algorithm. For example... Figure 1 As shown in the embodiment of the present invention, the gradient calculation method for accelerating the training process of the variational quantum algorithm includes: Step S11: Determine the initial parameter vector of the current parameterized quantum circuit, and construct a trust region centered on the initial parameter vector.
[0028] In this embodiment, firstly, the current parameterized quantum circuit is initialized and the trust region is defined, that is, a local trust region is constructed with the initial parameters of the current parameterized quantum circuit as the center, wherein the trust region is a geometric sampling region centered on the initial parameter vector.
[0029] Furthermore, the geometric sampling region can be a hypercube sampling region, where the hypercube sampling region is: ; in, For the initial parameter vector, For the width of the trust region, The number of parameters in a parameterized quantum circuit.
[0030] Understandably, the initial parameter vector of the current parameterized quantum circuit (PQC) is... Constructing with hyperparameters As the width of the trust region, and in the initial parameter vector Uniform sampling is performed on the hypercube region centered on the sample.
[0031] Furthermore, the geometric sampling region can also be a hypersphere sampling region, and the sampling distribution can be a Gaussian distribution to give higher weight to the center point.
[0032] Step S12: Uniformly sample multiple parameter points within the trust region and calculate the true gradient label corresponding to each parameter point.
[0033] In this embodiment, multiple parameter points are uniformly sampled within the trust region. The number of parameter points is much smaller than that required for global approximation and is determined based on the error bound theory of local approximation. Specifically, multiple parameter points are uniformly sampled within the trust region using Latin hypercube sampling or low-difference sequence sampling to improve the representativeness of the samples. Then, the true gradient label corresponding to each parameter point is calculated. Specifically, the true gradient label corresponding to each parameter point is calculated using a preset standard parameter translation rule or a preset finite difference method. In low-noise environments or classic simulator environments, the finite difference method can be used to obtain the gradient label.
[0034] For example, uniform sampling is performed within a hypercube region around the optimized initial point. Parameter points For each sampling point, the true gradient is calculated using the standard parameter translation rule as a label, and its true gradient vector is computed on a quantum computer (or simulated on a classical computer). That is, the true gradient label.
[0035] Step S13: Construct a training dataset based on each parameter point and its corresponding true gradient label, and train a neural network based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network.
[0036] In this embodiment, after uniformly sampling multiple parameter points within the local trust region and calculating their corresponding true gradient labels, a local dataset for offline preprocessing can be constructed using each parameter point and its corresponding true gradient label, i.e., a training dataset can be built, such as... ;in, It refers to the loss function constructed from the expected value of the Pauli operator.
[0037] In this embodiment, a training dataset is constructed containing multiple parameter points sampled in the trust region and their corresponding true gradient labels. Then, this training dataset is used to train a neural network, enabling the neural network to output predicted values of the true gradient labels within the trust region, resulting in a well-trained neural network. It is understandable that training a classic neural network... To fit the gradient function, during training, mean squared error is used as the loss function on the training dataset. Training network weights .
[0038] For example, the training dataset can be used to train a local neural gradient estimator (LNGE), which outputs a predicted value of the true gradient label within the trust region.
[0039] The neural network can be a multi-layer fully connected network, a recurrent neural network, or a one-dimensional convolutional neural network. The activation function in the neural network can be a cosine activation function, Tanh, ReLU, or Sigmoid. For example, the network architecture of the neural network can be a multi-layer fully connected network, such as a 5-layer network. The activation function uses a cosine function to match the physical characteristics of quantum circuits.
[0040] Furthermore, the output layer of the neural network contains multiple neurons, each corresponding to the gradient values of multiple parameters, with the number of neurons being the same as the number of parameters. The input layer of the neural network is used to encode input features according to a preset periodic encoding method to capture the periodic features of the quantum gate.
[0041] It should be noted that the preset periodicity encoding method can be either trigonometric function encoding or Fourier feature mapping. That is, considering the periodicity of the quantum gate, trigonometric function encoding can be used (such as input...). As network input, trigonometric function feature encoding and cosine activation function are introduced into the neural network to adapt to the periodicity and functional characteristics of the gradient of the parameterized quantum circuit.
[0042] Step S14: During the online optimization iteration of the variable quantum algorithm, determine whether the current parameter vector is located within the trust region.
[0043] It should be noted that in the online optimization iteration process of the variational quantum algorithm, gradient-based optimization is an inherent local process, unlike global learning. LNGE only learns the gradient function of the parameterized quantum circuit within a local trust region around the current optimization point using classical neural networks.
[0044] After training the neural network offline, it is then executed online. During the online optimization iteration of the variational quantum algorithm, i.e., entering the main optimization loop of VQA (such as using SGD or Adam optimizer), gradient prediction is performed online. See [link to documentation]. Figure 2 As shown, it can be derived from the initial parameters. To begin the iteration, first determine whether the current parameter vector is within the trust region to decide whether to enable the neural network prediction mode or the quantum parameter translation mode.
[0045] Specifically, the distance between the current parameter vector and the initial parameter vector is calculated, and a comparison threshold is determined based on the width of the trust region. The distance is compared with the comparison threshold to obtain the corresponding comparison result. Based on the comparison result, it is determined whether the current parameter vector is within the trust region. If the comparison result shows that the distance is less than the comparison threshold, the current parameter vector is determined to be within the trust region; if the comparison result shows that the distance is not less than the comparison threshold, the current parameter vector is determined to be outside the trust region. It can be understood that the distance between the optimized parameters and the initial parameters can be monitored in real time, and once it exceeds the trust region, the system immediately switches from the neural network prediction mode back to the quantum parameter translation mode.
[0046] For example, to calculate the distance between the current parameter vector and the initial parameter vector, that is: If the distance is less than the comparison threshold Continue using the neural network to predict gradients; if the distance is greater than the comparison threshold... This indicates that the current parameter vector has drifted out of the reliable region of the neural network. Stop using the trained neural network to predict gradients and switch to quantum parameter translation mode to perform gradient calculation using standard parameter translation rules.
[0047] Step S15: When the current parameter vector is located within the trust region, the predicted gradient corresponding to the current parameter vector is output using the trained neural network to update the current parameter vector of the current parameterized quantum circuit.
[0048] In this embodiment, it is determined whether the current parameter vector is within the trust region. If the current parameter vector is within the trust region, the system switches to neural network prediction mode. The trained neural network outputs the predicted gradient corresponding to the current parameter vector to update the current parameter vector of the current parameterized quantum circuit, thereby accelerating the training speed of large-scale parameterized quantum circuits. It can be understood that classical neural networks are used to replace quantum parameter translation rules for gradient prediction within a local trust region. Furthermore, by utilizing the boundedness of parameter drift in the quantum optimization process, the gradient learning task is simplified from a global, full-space approximation to a low-dimensional approximation within a local trust region, making the neural network approximation computationally feasible and overcoming the curse of dimensionality through locality.
[0049] For example, for the current parameter vector The input is then fed into a trained neural network, and the predicted gradient is obtained through a single classical forward propagation. Using predicted gradients Update the quantum circuit parameters to obtain Apart from the evaluation required to calculate the loss function itself, this process does not require quantum circuit evaluation.
[0050] As can be seen, in this embodiment of the invention, by constructing a trust region centered on the initial parameter vector and sampling parameter points from it, calculating the true gradient labels corresponding to the sampled parameter points, and training a neural network based on the sampled parameter points and their true gradient labels to output predicted values of the true gradient labels, it is possible to directly use the trained neural network to predict the predicted gradient corresponding to the current parameter vector when the current parameter vector, which is the current optimization point, is located within the trust region during the online optimization iteration of the variable quantum algorithm. This prediction is then used to update the current parameter vector, thereby reducing the quantum overhead of gradient calculation to zero. This decouples the online training time of the variable quantum algorithm from the number of parameters, significantly reducing the number of online quantum gradient evaluations and shortening the clock time of training the variable quantum algorithm.
[0051] It should be noted that the specific gradient calculation scheme for accelerating the training process of the Variable Quantum Algorithm (VQA) disclosed in this embodiment of the invention mainly includes two stages: an offline preparation stage and an online hybrid optimization stage. In the offline preparation stage, a small amount of data is sampled within the effective local region (i.e., the trust region) around the initial parameter vector. The true gradient label can be calculated using a preset standard parameter shift rule, and a lightweight classical neural network is trained using the sampled data and its corresponding true gradient label. Furthermore, in the online hybrid optimization stage, a trust region management mechanism is introduced. If the current parameter vector update does not exceed the effective trust region of the neural network, the trained neural network is used to directly predict the gradient (requiring only one classical forward propagation), replacing the expensive quantum PSR (Parameter-Shift Rule) evaluation. If the current parameter vector update exceeds the effective trust region of the neural network, the standard PSR method is switched back. Here, forward propagation refers to one execution of the parameterized quantum circuit to obtain the expected value. The technical solution of this invention implements a specific workflow combining offline local training with online neural inference and hard switching of the trust region. This maximizes the proportion of classical computation replacing quantum computation while ensuring accuracy, thereby accelerating the training of the Variable Quantum Algorithm (VQA). Within the effective trust region of the neural network, the quantum overhead of gradient computation is reduced to zero (requiring only classical computation), decoupling the online training time of the quantum algorithm from the number of parameters P and breaking the linear dependence. Furthermore, compared to the standard PSR method, this embodiment achieves an order-of-magnitude acceleration in training time while maintaining comparable final model accuracy, significantly improving training speed. By utilizing optimized locality, the curse of dimensionality in global approximation is avoided, the required training sample size is within an acceptable range, and sample efficiency is high. This is a general gradient computation scheme that can be directly applied to various variable quantum eigenvalue solvers and quantum classification tasks, or to the training of quantum approximation optimization algorithms and quantum generative adversarial networks, without modifying the quantum circuit structure, exhibiting strong compatibility.
[0052] It should also be noted that although the preprocessing stage (sampling and training) has a certain time cost, the trained LNGE model has a certain transfer capability. For the same type of quantum circuit architecture, if only the Hamiltonian coefficients change slightly, the trained model can be used as a warm-start model, thereby further reducing the preprocessing cost of downstream tasks. Furthermore, the technical solution of this invention is a purely classical software-level optimization strategy, which does not depend on specific quantum hardware physical implementations. It is applicable to superconducting quantum computers as well as any gate-based quantum computing platform such as ion traps and optical quantum computing.
[0053] See Figure 3As shown, this embodiment of the invention discloses a specific gradient calculation method for accelerating the training process of a variable quantum algorithm. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution.
[0054] Step S21: Determine the initial parameter vector of the current parameterized quantum circuit, and construct a trust region centered on the initial parameter vector.
[0055] Step S22: Uniformly sample multiple parameter points within the trust region and calculate the true gradient label corresponding to each parameter point.
[0056] Step S23: Construct a training dataset based on each parameter point and its corresponding true gradient label, and train a neural network based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network.
[0057] Step S24: During the online optimization iteration of the variational quantum algorithm, determine whether the current parameter vector is located within the trust region.
[0058] Step S25: When the current parameter vector is located within the trust region, the predicted gradient corresponding to the current parameter vector is output using the trained neural network to update the current parameter vector of the current parameterized quantum circuit.
[0059] Step S26: When the current parameter vector is not located within the trust region, the gradient corresponding to the current parameter vector is calculated using the preset standard parameter translation rule, and the trained neural network is fine-tuned.
[0060] In this embodiment, it is determined whether the current parameter vector is within the trust region. If the current parameter vector is not within the trust region, the system switches to quantum parameter translation mode, calculates the gradient corresponding to the current parameter vector using preset standard parameter translation rules, and fine-tunes the trained neural network. It is understood that when the parameters are not within the trust region, the trained neural network is not completely abandoned. Instead, a small amount of data is resampled around the new optimization point (or recent historical data is used), and the trained neural network is fine-tuned or retrained using a moving window or online fine-tuning strategy. This allows the neural network to continue predicting gradients, further extending the acceleration effect.
[0061] For details regarding steps S21 to S25, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0062] As can be seen, in this embodiment of the invention, by constructing a trust region centered on the initial parameter vector and sampling parameter points from it, calculating the true gradient labels corresponding to the sampled parameter points, and training a neural network based on the sampled parameter points and their true gradient labels to output predicted values of the true gradient labels, it is possible to directly use the trained neural network to predict the predicted gradient corresponding to the current parameter vector when the current parameter vector, which is the current optimization point, is located within the trust region during the online optimization iteration of the variable quantum algorithm. This prediction is then used to update the current parameter vector, thereby reducing the quantum overhead of gradient calculation to zero. This decouples the online training time of the variable quantum algorithm from the number of parameters, significantly reducing the number of online quantum gradient evaluations and shortening the clock time of training the variable quantum algorithm.
[0063] During the online optimization iteration of the variational quantum algorithm, a total of [number] iterations were performed. This time, the part outside the trust region iterated for... Second-rate, The total number of quantum circuit evaluations is: .
[0064] Therefore, as long as and The cost is relatively small, and the technical solution of this invention can reduce the cost that originally increased linearly with the number of parameters. The transfer significantly reduces quantum resource calls during downstream hybrid training VQA by fixing the one-time preprocessing cost. Table 1 below shows the number of quantum circuit evaluations per optimization run, representing a comparison of the number of quantum circuit evaluations in a single optimization run.
[0065] Table 1
[0066] And see also Figure 4 As shown, the sample requirements of global approximation and local approximation are compared to achieve the same MSE accuracy. It is demonstrated that the global method increases exponentially with the number of parameters, while the local method of this invention has low and gradual sample requirements.
[0067] In one embodiment, such as Figure 5 As shown, based on the above-described gradient calculation method for accelerating the training process of the variational quantum algorithm, the present invention also provides a gradient calculation device for accelerating the training process of the variational quantum algorithm, comprising: Trust region construction module 11 is used to determine the initial parameter vector of the current parameterized quantum circuit and construct a trust region centered on the initial parameter vector. The true gradient label calculation module 12 is used to uniformly sample multiple parameter points within the trust region and calculate the true gradient label corresponding to each parameter point. The neural network training module 13 is used to construct a training dataset based on each parameter point and its corresponding true gradient label, and to train the neural network based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network. The judgment module 14 is used to determine whether the current parameter vector is located within the trust region during the online optimization iteration process of the variable quantum algorithm; The gradient prediction module 15 is used to output the predicted gradient corresponding to the current parameter vector using the trained neural network when the current parameter vector is located within the trust region, so as to update the current parameter vector of the current parameterized quantum circuit.
[0068] In some specific embodiments, the real gradient label calculation module 12 may specifically include: The real gradient label calculation unit is used to calculate the real gradient label corresponding to each parameter point using a preset standard parameter translation rule or a preset finite difference method.
[0069] In some specific embodiments, the gradient calculation device for accelerating the training process of the variational quantum algorithm using trigonometric function encoding may further include: The gradient calculation and network fine-tuning module is used to calculate the gradient corresponding to the current parameter vector using a preset standard parameter translation rule when the current parameter vector is not located within the trust region, and to fine-tune the trained neural network.
[0070] In some specific embodiments, the determination module may specifically include: A distance calculation unit is used to calculate the distance between the current parameter vector and the initial parameter vector; A threshold determination unit is used to determine a comparison threshold based on the width of the trust region; A comparison unit is used to compare the distance with the comparison threshold to obtain a corresponding comparison result; The judgment unit is used to determine whether the current parameter vector is located within the trust region based on the comparison result; In some specific embodiments, the determining unit may specifically include: The first determination unit is configured to determine that the current parameter vector is within the trust region when the comparison result indicates that the distance is less than the comparison threshold. The second determination unit is used to determine that the current parameter vector is not located within the trust region when the comparison result shows that the distance is not less than the comparison threshold.
[0071] In some specific embodiments, the trust region is a geometrically shaped sampling region centered on the initial parameter vector.
[0072] In some specific embodiments, the geometric sampling region is a hypercube sampling region; the hypercube sampling region is: ; in, For the initial parameter vector, For the width of the trust region, The number of parameters in a parameterized quantum circuit.
[0073] In some specific embodiments, the neural network is a multi-layer fully connected network, a recurrent neural network, or a one-dimensional convolutional neural network. The activation function in the neural network is a cosine activation function, Tanh, ReLU, or Sigmoid. The output layer of the neural network contains multiple neurons, each corresponding to the gradient values of multiple parameters. The input layer of the neural network is used to encode the input features according to a preset periodic encoding method to capture the periodic features of the quantum gate.
[0074] Furthermore, it is worth noting that the working process of the gradient calculation device for accelerating the training process of the variable quantum algorithm provided in this embodiment is the same as the working process of the gradient calculation method for accelerating the training process of the variable quantum algorithm described above. Therefore, it will not be repeated here. For details, please refer to the working process of the gradient calculation method for accelerating the training process of the variable quantum algorithm described above.
[0075] Figure 6 A schematic diagram of the structure of a terminal provided in an embodiment of this application. The terminal may include: The memory 501, the processor 502, and the computer program stored on the memory 501 and capable of running on the processor 502.
[0076] When the processor 502 executes the program, it implements the gradient calculation method provided in the above embodiments for accelerating the training process of the variable quantum algorithm.
[0077] Furthermore, the terminal also includes: Communication interface 503 is used for communication between memory 501 and processor 502.
[0078] The memory 501 is used to store computer programs that can run on the processor 502.
[0079] Memory 501 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0080] If the memory 501, processor 502, and communication interface 503 are implemented independently, they can be interconnected via a bus to communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one line is used in the diagram, but this does not imply that there is only one bus or one type of bus.
[0081] Optionally, in a specific implementation, if the memory 501, processor 502, and communication interface 503 are integrated on a single chip, then the memory 501, processor 502, and communication interface 503 can communicate with each other through an internal interface.
[0082] Processor 502 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0083] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the gradient calculation method described above for accelerating the training process of the variable quantum algorithm.
[0084] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the claims.
[0085] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0086] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can read and execute instructions from and from an instruction execution system, apparatus or device).
[0087] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0088] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A gradient calculation method for accelerating the training process of a variational quantum algorithm, characterized in that, The method includes: Determine the initial parameter vector of the current parameterized quantum circuit, and construct a trust region centered on the initial parameter vector; Multiple parameter points are uniformly sampled within the trust region, and the true gradient label corresponding to each parameter point is calculated; A training dataset is constructed based on each parameter point and its corresponding true gradient label, and a neural network is trained based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network. During the online optimization iteration of the variational quantum algorithm, it is determined whether the current parameter vector is located within the trust region; When the current parameter vector is within the trust region, the trained neural network outputs the predicted gradient corresponding to the current parameter vector to update the current parameter vector of the current parameterized quantum circuit.
2. The gradient calculation method for accelerating the training process of the variational quantum algorithm according to claim 1, characterized in that, The calculation of the true gradient label corresponding to each parameter point includes: The true gradient label corresponding to each parameter point is calculated using a preset standard parameter translation rule or a preset finite difference method.
3. The gradient calculation method for accelerating the training process of the variational quantum algorithm according to claim 1, characterized in that, After determining whether the current parameter vector is within the trust region, the method further includes: If the current parameter vector is not located within the trust region, the gradient corresponding to the current parameter vector is calculated using the preset standard parameter translation rule, and the trained neural network is fine-tuned.
4. The gradient calculation method for accelerating the training process of the variational quantum algorithm according to claim 1, characterized in that, The step of determining whether the current parameter vector is within the trust region includes: Calculate the distance between the current parameter vector and the initial parameter vector, and determine the comparison threshold based on the width of the trust region; The distance is compared with the comparison threshold to obtain the corresponding comparison result; Based on the comparison result, determine whether the current parameter vector is located within the trust region; Determining whether the current parameter vector is within the trust region based on the comparison result includes: If the comparison result indicates that the distance is less than the comparison threshold, then the current parameter vector is determined to be within the trust region. If the comparison result indicates that the distance is not less than the comparison threshold, then it is determined that the current parameter vector is not located within the trust region.
5. The gradient calculation method for accelerating the training process of the variational quantum algorithm according to claim 1, characterized in that, The trust region is a geometrically shaped sampling area centered on the initial parameter vector.
6. The gradient calculation method for accelerating the training process of the variational quantum algorithm according to claim 5, characterized in that, The geometric sampling region is a hypercube sampling region; the hypercube sampling region is: ; in, For the initial parameter vector, For the width of the trust region, The number of parameters in a parameterized quantum circuit.
7. The gradient calculation method for accelerating the training process of a variational quantum algorithm according to any one of claims 1 to 6, characterized in that, The neural network is a multi-layer fully connected network, a recurrent neural network, or a one-dimensional convolutional neural network. The activation function in the neural network is a cosine activation function, Tanh, ReLU, or Sigmoid. The output layer of the neural network contains multiple neurons, and each neuron corresponds to the gradient value of multiple parameters. The input layer of the neural network is used to encode the input features according to a preset periodic encoding method to capture the periodic features of the quantum gate.
8. A gradient calculation device for accelerating the training process of a variational quantum algorithm, characterized in that, The device includes: Trust region construction module is used to determine the initial parameter vector of the current parameterized quantum circuit and construct a trust region centered on the initial parameter vector; The true gradient label calculation module is used to uniformly sample multiple parameter points within the trust region and calculate the true gradient label corresponding to each parameter point. The neural network training module is used to construct a training dataset based on each parameter point and its corresponding true gradient label, and to train the neural network based on the training dataset so that the neural network outputs a predicted value of the true gradient label within the trust region, thereby obtaining a trained neural network. The judgment module is used to determine whether the current parameter vector is located within the trust region during the online optimization iteration of the variational quantum algorithm. The gradient prediction module is used to output the predicted gradient corresponding to the current parameter vector using the trained neural network when the current parameter vector is located within the trust region, so as to update the current parameter vector of the current parameterized quantum circuit.
9. A terminal, characterized in that, include: The system includes a memory, a processor, and a gradient calculation program stored in the memory and executable on the processor for accelerating the training process of a variable quantum algorithm. When the gradient calculation program for accelerating the training process of a variable quantum algorithm is executed by the processor, it implements the steps of the gradient calculation method for accelerating the training process of a variable quantum algorithm as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed to implement the steps of the gradient calculation method for accelerating the training process of the variational quantum algorithm as described in any one of claims 1 to 7.