Method and device for optimizing quantum circuit in quantum machine learning model

By optimizing the unitary matrix parameters in the quantum machine learning model, using the Hessian matrix to determine the target parameters and setting them to zero, a new quantum circuit is generated, which solves the problem of high complexity caused by high-dimensional non-unitary matrices and improves the model performance.

CN121787601APending Publication Date: 2026-04-03ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

The unitary matrix obtained after approximate block encoding of a high-dimensional non-unitary matrix has many parameters, which leads to high complexity in encoding the unitary matrix into quantum logic gates and affects the performance of quantum machine learning models.

Method used

By calculating the Hessian matrix of the loss function relative to the unitary matrix parameters, the parameter that minimizes the perturbation function value of the loss function is determined as the target parameter. The parameter is then set to zero before exceeding a preset perturbation threshold, generating a new quantum circuit. The quantum circuit is then optimized using a fast approximation block coding algorithm.

Benefits of technology

This reduces the complexity and computational complexity of encoding unitary matrices into quantum logic gates, thereby improving the performance of quantum machine learning models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121787601A_ABST
    Figure CN121787601A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of quantum computers, in particular to an optimization method and device for a quantum circuit in a quantum machine learning model. Comprising the following steps: acquiring an initial quantum circuit used by a quantum machine learning model for coding a non-unitary matrix in a convergence state, unitary matrix parameters of the initial quantum circuit, and a loss function of the quantum machine learning model; calculating a Hessian matrix of the loss function relative to the unitary matrix parameters, and according to the Hessian matrix, determining a parameter which enables the value of a disturbance function of the loss function to be minimum in the unitary matrix parameters as a target parameter; when the value of the perturbation function does not exceed a preset perturbation threshold value, zero setting is carried out on the target parameter to obtain an updated unitary matrix parameter so as to generate a new quantum circuit. According to the method, through the Hessian matrix of the block coding parameter used in the quantum machine learning model, the perturbation quantity of parameter zero setting on a loss function in fast approximation block coding is minimized, and the accuracy of the quantum circuit is improved. Quantum logic gates corresponding to sparse parameters are deleted in a quantum machine learning model, and the complexity and calculation complexity of unitary matrix coding as the quantum logic gates are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantum computing, and more particularly to a method and apparatus for optimizing quantum circuits in a quantum machine learning model. Background Technology

[0002] Block coding can simulate and fit non-unitary matrix transformations, and can be used to build quantum machine learning models in quantum neural networks. Most of the neural network operations in classical neural networks are non-unitary matrix operations, while the circuits constructed by variable quantum circuits are necessarily unitary matrix transformations. They can fit and simulate more classical neural network functions and are more likely to combine the parallel computing advantages of quantum computing to optimize the loss function of classical neural networks.

[0003] Currently, the complexity of block encoding is highly correlated with the dimension of the input classical non-unitary matrix. For high-dimensional non-unitary matrices in neural networks, the unitary matrix obtained after approximate block encoding of the high-dimensional non-unitary matrix will have more parameters, resulting in high complexity of encoding the unitary matrix into quantum logic gates, thus affecting the performance of quantum machine learning models. Summary of the Invention

[0004] This invention provides a method and apparatus for optimizing quantum circuits in quantum machine learning models, which addresses the problem that high-dimensional non-unitary matrices, after approximate block encoding, result in unitary matrices with numerous parameters, leading to high complexity in encoding unitary matrices into quantum logic gates and thus affecting the performance of quantum machine learning models.

[0005] This specification provides an embodiment of a method for optimizing quantum circuits in a quantum machine learning model, including:

[0006] Obtain the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in the convergence state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model;

[0007] Calculate the Hessian matrix of the loss function relative to the unitary matrix parameters, and determine the parameter that minimizes the value of the perturbation function of the loss function based on the Hessian matrix among the unitary matrix parameters as the target parameter; the perturbation function of the loss function is the amount of perturbation to the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters;

[0008] When the value of the perturbation function does not exceed the preset perturbation threshold, the target parameter is set to zero to obtain the updated unitary matrix parameter to generate a new quantum circuit.

[0009] Optionally, obtaining the updated unitary matrix parameters to generate a new quantum circuit includes:

[0010] Update the unitary matrix parameters after setting the target parameters to zero according to the preset parameter change function; return to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the value of the perturbation function exceeds the preset perturbation threshold, and stop, and withdraw the current target parameter zeroing operation; the preset parameter change function represents the amount of change of non-zero parameters in the unitary matrix parameters when the value of the perturbation function is minimum;

[0011] A new quantum circuit is generated based on the updated unitary matrix parameters using a fast approximation block coding algorithm.

[0012] Optionally, after generating the new quantum circuit, the method further includes:

[0013] The initial quantum circuit used in the quantum machine learning model is replaced with a new quantum circuit to encode a non-unitary matrix.

[0014] Optionally, after generating the new quantum circuit, the method further includes:

[0015] Obtain the validation set data and the first model accuracy value of the quantum machine learning model; the first model accuracy value is the accuracy value of the quantum machine learning model using the initial quantum circuit and in a convergent state.

[0016] The second model accuracy value of the quantum machine learning model is determined using validation set data; the second model accuracy value is the accuracy value of the quantum machine learning model when using a new quantum circuit.

[0017] When the second precision value is less than the first precision value, the preset perturbation threshold is updated, and the process returns to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the second precision value is not less than the first precision value.

[0018] Optionally, the perturbation function is shown in the following equation:

[0019]

[0020] Where L is the value of the perturbation function, [H -1 ] qq w is the element in the q-th row and q-th column of the inverse of the Hessian matrix. q It is the q-th parameter in the unitary matrix parameters.

[0021] Optionally, determining the target parameter as the parameter that minimizes the value of the perturbation function of the loss function from the unitary matrix parameters based on the Hessian matrix includes:

[0022] Iterate through each parameter in the unitary matrix parameters and substitute each parameter into the perturbation function of the loss function one by one to calculate the value of the perturbation function corresponding to each parameter;

[0023] By comparing the values ​​of the perturbation functions corresponding to each parameter, the parameter corresponding to the smallest perturbation function value is taken as the target parameter.

[0024] Optionally, the preset parameter variation function is shown in the following formula:

[0025]

[0026] Where δw is the change in the non-zero parameter of the unitary matrix when the value of the perturbation function is minimized, w q H is the q-th parameter in the unitary matrix parameters. -1 Let e ​​be the inverse of the Hessian matrix. q The parameters of the unitary matrix correspond to w q A unit vector, [H -1 ] qq Let be the element in the q-th row and q-th column of the inverse of the Hessian matrix.

[0027] Optionally, updating the preset perturbation threshold includes:

[0028] The preset perturbation threshold is updated by reducing the preset perturbation threshold by a preset percentage.

[0029] This specification also provides an optimization device for quantum circuits in a quantum machine learning model, comprising:

[0030] The information acquisition module is used to acquire the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in the convergence state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model.

[0031] The target parameter determination module is used to calculate the Hessian matrix of the loss function relative to the unitary matrix parameters, and determine the parameter that minimizes the value of the perturbation function of the loss function based on the Hessian matrix among the unitary matrix parameters as the target parameter; the perturbation function of the loss function is the perturbation amount of the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters.

[0032] The unitary matrix parameter update module is used to set the target parameter to zero to obtain updated unitary matrix parameters in order to generate a new quantum circuit when the value of the perturbation function does not exceed a preset perturbation threshold.

[0033] An electronic device includes a memory and a processor, the memory storing computer instructions, and the processor being configured to execute the computer instructions to perform the method described above.

[0034] A storage medium, characterized in that the storage medium stores computer instructions, the computer instructions being configured to execute the method described above at runtime.

[0035] Its beneficial effects are as follows: This application minimizes the perturbation of the loss function by parameter sparsification (parameter values ​​set to zero) in fast approximation block encoding by the Hessian matrix of the block encoding parameters used in the quantum machine learning model, thereby realizing the removal of the quantum logic gate corresponding to the sparsified parameters in the quantum machine learning model, reducing the complexity and computational complexity of unitary matrix encoding into quantum logic gates, and improving the performance of the quantum machine learning model. Attached Figure Description

[0036] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0037] Figure 1 This specification provides a flowchart of an optimization method for quantum circuits in a quantum machine learning model, as illustrated in the embodiments.

[0038] Figure 2 Flowchart of another quantum machine learning model quantum circuit optimization method provided in the embodiments of this specification;

[0039] Figure 3 A flowchart illustrating the replacement of quantum circuits in another quantum machine learning model provided in the embodiments of the specification;

[0040] Figure 4 A schematic diagram of an optimization device for a quantum circuit in a quantum machine learning model provided in an embodiment of this specification;

[0041] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification;

[0042] Figure 6 This is a schematic diagram of a computer-readable medium provided for embodiments of this specification. Detailed Implementation

[0043] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0044] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0045] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps described in these embodiments do not limit the scope of the invention.

[0046] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.

[0047] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0048] In all the examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0049] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0050] Reference Figure 1 This specification provides a schematic diagram of the principle of an optimization method for quantum circuits in a quantum machine learning model, comprising: S101: obtaining the initial quantum circuit used by the quantum machine learning model for encoding a non-unitary matrix in a convergent state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model; S102: calculating the Hessian matrix of the loss function relative to the unitary matrix parameters, and determining the parameter that minimizes the value of the perturbation function of the loss function among the unitary matrix parameters based on the Hessian matrix; the perturbation function of the loss function is the perturbation amount of the loss function by deleting a quantum logic gate corresponding to a certain parameter in the unitary matrix parameters; S103: when the value of the perturbation function does not exceed a preset perturbation threshold, setting the target parameter to zero to obtain updated unitary matrix parameters to generate a new quantum circuit.

[0051] In one optional embodiment, a quantum machine learning model in a converged state is first obtained. This model encodes non-unitary matrices, enabling the conversion from non-unitary to unitary matrices. Since the converged model is a trained model, it includes an initial quantum circuit, unitary matrix parameters of the initial quantum circuit, and a loss function. To reduce the complexity and computational complexity of the quantum logic gates on the initial quantum circuit in the quantum machine learning model, the quantum logic gates need to be simplified. This application first calculates the Hessian matrix of the loss function relative to the unitary matrix parameters, and then determines the target parameter based on the Hessian matrix among the unitary matrix parameters that minimizes the value of the perturbation function of the loss function. The perturbation function is shown in the following equation:

[0052]

[0053] Where L is the value of the perturbation function, [H -1 ] qq w is the element in the q-th row and q-th column of the inverse of the Hessian matrix. q It is the q-th parameter in the unitary matrix parameters.

[0054] The target parameter w is achieved through the above formula (1). q The value of the perturbation function is then compared with a preset perturbation threshold. If the value of the perturbation function does not exceed the preset perturbation threshold, the target parameter w is set. q The updated unitary matrix parameters are obtained by setting them to zero. Finally, a new quantum circuit is generated based on the updated unitary matrix parameters. This application minimizes the perturbation of the loss function caused by parameter sparsification (setting parameter values ​​to zero) in fast approximation block encoding by using the Hessian matrix of the block encoding parameters used in the quantum machine learning model. This achieves the removal of the quantum logic gates corresponding to the sparsified parameters in the quantum machine learning model, reducing the complexity and computational complexity of encoding the unitary matrix into quantum logic gates. The perturbation function of the loss function is the perturbation of the loss function caused by removing the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters.

[0055] Optionally, obtaining the updated unitary matrix parameters to generate a new quantum circuit includes: updating the unitary matrix parameters after the target parameters are set to zero according to a preset parameter change function; returning to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the value of the perturbation function exceeds the preset perturbation threshold, and then withdrawing the current target parameter zeroing operation; the preset parameter change function characterizes the amount of change of non-zero parameters in the unitary matrix parameters when the value of the perturbation function is minimized; and generating a new quantum circuit based on the updated unitary matrix parameters and a fast approximation block coding algorithm.

[0056] In one alternative embodiment, such as Figure 2 As shown, the unitary matrix parameters after the target parameter is set to zero are updated according to the preset parameter change function, which is as follows:

[0057]

[0058] Where δw is the change in the non-zero parameter of the unitary matrix when the value of the perturbation function is minimized, W q H is the q-th parameter in the unitary matrix parameters. -1 Let e ​​be the inverse of the Hessian matrix. q The parameters of the unitary matrix correspond to w q A unit vector, [H -1 ] qq Let be the element in the q-th row and q-th column of the inverse of the Hessian matrix.

[0059] Using the above formula (2), the change value of the non-zero parameter in the unitary matrix parameter is calculated when the value of the perturbation function is minimized. Then, the unitary matrix parameter after the target parameter is set to zero is updated according to the change value to prepare for finding the next parameter that can be set to zero. The step of calculating the loss function relative to the Hessian matrix of the unitary matrix parameter is returned until the value of the perturbation function exceeds the preset perturbation threshold. At this time, it is shown that setting any parameter in the updated unitary matrix parameter to zero will cause a significant increase in the loss function and will greatly reduce the performance of the quantum machine learning model. Therefore, the loop is stopped when the value of the perturbation function exceeds the preset perturbation threshold, and the current target parameter zeroing operation is withdrawn. The unitary matrix parameter at this time is taken as the final update result. Finally, a new quantum circuit is generated according to the finally updated unitary matrix parameter and the fast approximate block coding algorithm. The initial quantum circuit used by the quantum machine learning model is replaced with the new quantum circuit to encode the non-unitary matrix, thereby realizing the optimization of the quantum circuit in the quantum machine learning model, realizing the removal of the quantum logic gate corresponding to the sparse parameter in the quantum machine learning model, reducing the complexity of encoding the unitary matrix into a quantum logic gate, and improving the performance of the quantum machine learning model.

[0060] Optionally, after generating a new quantum circuit, the method further includes: acquiring validation set data and a first model accuracy value of the quantum machine learning model; the first model accuracy value is the accuracy value of the quantum machine learning model when using the initial quantum circuit and in a convergent state; determining a second model accuracy value of the quantum machine learning model using the validation set data; the second model accuracy value is the accuracy value of the quantum machine learning model when using the new quantum circuit; when the second accuracy value is less than the first accuracy value, updating the preset perturbation threshold, and returning to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the second accuracy value is not less than the first accuracy value.

[0061] In one alternative embodiment, such as Figure 3 As shown, the accuracy value of the quantum machine learning model using the initial quantum circuit and in a convergent state is obtained, along with the validation set data of the quantum machine learning model. Then, the accuracy value of the quantum machine learning model when using a new quantum circuit is determined using the validation set data. When the second accuracy value is less than the first accuracy value, it indicates that the current preset perturbation threshold setting will cause the accuracy value of the quantum machine learning model to decrease, affecting the performance of the quantum machine learning model. Therefore, at this time, the preset perturbation threshold can be reduced by a preset percentage to update the preset perturbation threshold, and the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters is returned. This process continues until the accuracy value of the quantum machine learning model using the initial quantum circuit and in a convergent state is not less than the accuracy value of the quantum machine learning model using the latest quantum circuit, thereby avoiding a decrease in the accuracy value of the quantum machine learning model when using a new quantum circuit.

[0062] Optionally, determining the target parameter based on the Hessian matrix among the unitary matrix parameters to minimize the value of the perturbation function of the loss function includes: traversing each parameter in the unitary matrix parameters and substituting each parameter into the perturbation function of the loss function one by one to calculate the value of the perturbation function corresponding to each parameter; comparing the values ​​of the perturbation functions corresponding to each parameter, and taking the parameter corresponding to the smallest perturbation function value as the target parameter.

[0063] In one alternative embodiment, each parameter in the unitary matrix is ​​substituted into formula (1) one by one to calculate the value of the perturbation function corresponding to each parameter. Then, the values ​​of the perturbation functions corresponding to each parameter are compared, and the parameter corresponding to the smallest perturbation function value is determined as the target parameter. That is, the parameter that can be set to zero in the unitary matrix is ​​found, thereby minimizing the perturbation of the loss function by parameter sparsification (parameter value set to zero) in the fast approximation block encoding. This realizes the removal of the quantum logic gate corresponding to the sparsified parameter in the quantum machine learning model, reduces the complexity of encoding the unitary matrix into a quantum logic gate, and improves the performance of the quantum machine learning model.

[0064] Optionally, updating the preset perturbation threshold includes:

[0065] The preset perturbation threshold is updated by reducing the preset perturbation threshold by a preset percentage.

[0066] In one optional embodiment, a larger preset perturbation threshold results in more parameters in the unitary matrix being set to zero, which may affect the accuracy of the quantum machine learning model. Therefore, the preset perturbation threshold can be set to a small value, such as 0.1. When the second accuracy value is less than the first accuracy value, the preset perturbation threshold is reduced by 10% to obtain the updated preset perturbation threshold, i.e., the updated preset perturbation threshold is 0.09. This process continues until the preset perturbation threshold no longer reduces the accuracy of the quantum machine learning model. This method ensures the accuracy of the quantum machine learning model and avoids any reduction in its accuracy.

[0067] This application first obtains the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in a convergent state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model; calculates the Hessian matrix of the loss function relative to the unitary matrix parameters, and determines the parameter that minimizes the value of the perturbation function of the loss function among the unitary matrix parameters based on the Hessian matrix as the target parameter; the perturbation function of the loss function is the amount of perturbation to the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters; when the value of the perturbation function does not exceed a preset perturbation threshold, the target parameter is set to zero to obtain updated unitary matrix parameters to generate a new quantum circuit. This application achieves the deletion of the quantum logic gate corresponding to the sparse parameters in the quantum machine learning model by minimizing the perturbation of the loss function by setting the parameter to zero in the fast approximation block encoding through the Hessian matrix of the block encoding parameters used in the quantum machine learning model, thereby reducing the complexity and computational complexity of encoding unitary matrices into quantum logic gates.

[0068] Reference Figure 4 This specification also provides an optimization device for quantum circuits in a quantum machine learning model, comprising:

[0069] The information acquisition module 201 is used to acquire the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in the convergence state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model.

[0070] The target parameter determination module 202 is used to calculate the Hessian matrix of the loss function relative to the unitary matrix parameters, and determine the parameter that minimizes the value of the perturbation function of the loss function in the unitary matrix parameters based on the Hessian matrix; the perturbation function of the loss function is the perturbation amount of the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters.

[0071] The unitary matrix parameter update module 203 is used to set the target parameter to zero to obtain updated unitary matrix parameters in order to generate a new quantum circuit when the value of the perturbation function does not exceed the preset perturbation threshold.

[0072] Optionally, the unitary matrix parameter update module 203 includes:

[0073] The unitary matrix parameter update unit is used to update the unitary matrix parameters after the target parameters are set to zero according to a preset parameter change function; it returns to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the value of the perturbation function exceeds the preset perturbation threshold, and then stops and withdraws the current target parameter zeroing operation; the preset parameter change function represents the amount of change of non-zero parameters in the unitary matrix parameters when the value of the perturbation function is minimized;

[0074] The quantum circuit generation unit is used to generate new quantum circuits based on the updated unitary matrix parameters and using a fast approximation block coding algorithm.

[0075] Optionally, the device further includes:

[0076] A quantum circuit replacement module is used to replace the initial quantum circuit used by the quantum machine learning model with a new quantum circuit to encode a non-unitary matrix.

[0077] Optionally, the device further includes:

[0078] The data acquisition module is used to acquire the validation set data and the first model accuracy value of the quantum machine learning model; the first model accuracy value is the accuracy value of the quantum machine learning model using the initial quantum circuit and in the convergence state.

[0079] The accuracy value determination module is used to determine the second model accuracy value of the quantum machine learning model using validation set data; the second model accuracy value is the accuracy value of the quantum machine learning model when the quantum machine learning model uses the new quantum circuit.

[0080] The determination module is used to update the preset perturbation threshold when the second precision value is less than the first precision value, and return to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the second precision value is not less than the first precision value.

[0081] Optionally, the perturbation function is shown in the following equation:

[0082]

[0083] Where L is the value of the perturbation function, [H -1 ] qq w is the element in the q-th row and q-th column of the inverse of the Hessian matrix.q It is the q-th parameter in the unitary matrix parameters.

[0084] Optionally, the target parameter determination module 202 includes:

[0085] The parameter traversal unit is used to traverse each parameter in the unitary matrix parameters and substitute each parameter into the perturbation function of the loss function one by one to calculate the value of the perturbation function corresponding to each parameter;

[0086] The target parameter determination unit is used to compare the values ​​of the perturbation functions corresponding to each parameter and take the parameter corresponding to the smallest perturbation function value as the target parameter.

[0087] Optionally, the preset parameter variation function is shown in the following formula:

[0088]

[0089] Where δw is the change in the non-zero parameter of the unitary matrix when the value of the perturbation function is minimized, w q H is the q-th parameter in the unitary matrix parameters. -1 Let e ​​be the inverse of the Hessian matrix. q The parameters of the unitary matrix correspond to w q A unit vector, [H -1 ] qq Let be the element in the q-th row and q-th column of the inverse of the Hessian matrix.

[0090] Optionally, the determination module includes:

[0091] A preset perturbation threshold update unit is used to reduce the preset perturbation threshold by a preset percentage to update the preset perturbation threshold.

[0092] Regarding the apparatus in the above embodiments, the process of performing each step has been described in detail in the embodiments of the method, and will not be elaborated here.

[0093] Based on the same inventive concept, embodiments of this specification also provide an electronic device.

[0094] The following describes embodiments of the electronic device of the present invention, which can be considered as specific implementations of the methods and apparatus embodiments of the present invention described above. Details described in the embodiments of the electronic device of the present invention should be considered as supplements to the methods or apparatus embodiments described above; details not disclosed in the embodiments of the electronic device of the present invention can be implemented with reference to the methods or apparatus embodiments described above.

[0095] Reference Figure 5 This is a schematic diagram of an electronic device provided as an embodiment of this specification. Refer to the following... Figure 5The electronic device 300 according to this embodiment of the present invention will be described. Figure 5 The electronic device 300 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0096] like Figure 5 As shown, the electronic device 300 is presented in the form of a general-purpose computing device. The components of the electronic device 300 may include, but are not limited to: at least one processing unit 310, at least one storage unit 320, a bus 330 connecting different device components (including storage unit 320 and processing unit 310), a display unit 340, etc.

[0097] The storage unit stores program code that can be executed by the processing unit 310, causing the processing unit 310 to perform the steps described in the processing method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 310 can perform, for example... Figure 1 The steps are shown.

[0098] The storage unit 320 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 3201 and / or a cache storage unit 3202, and may further include a read-only memory unit (ROM) 3203.

[0099] The storage unit 320 may also include a program / utility 3204 having a set (at least one) of program modules 3205, such program modules 3205 including but not limited to: operating devices, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0100] Bus 330 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0101] Electronic device 300 can also communicate with one or more external devices 400 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with the electronic device 300, and / or with any device that enables the electronic device 300 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 350. Furthermore, electronic device 300 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 360. Network adapter 360 can communicate with other modules of electronic device 300 via bus 330. It should be understood that, although... Figure 5 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 300, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID devices, tape drives, and data backup storage devices.

[0102] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described in this invention can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the method described above according to this invention. When the computer instructions are executed by a data processing device, the computer-readable medium is able to implement the method described above, i.e., as follows: Figure 1 The method shown.

[0103] Reference Figure 6 This is a schematic diagram of a computer-readable medium provided for embodiments of this specification.

[0104] accomplish Figure 1The computer instructions of the method shown can be stored on one or more computer-readable media. A computer-readable medium can be a readable signal medium or a readable storage medium. A readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0105] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution device, apparatus, or apparatus. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0106] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0107] In summary, this invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that in practice, general-purpose data processing devices such as microprocessors or digital signal processors (DSPs) can be used to implement some or all of the functions of some or all of the components according to the embodiments of the invention. The invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the invention can be stored on a computer-readable medium or can take the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0108] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the present invention is not inherently related to any specific computer, virtual device, or electronic device, and various general-purpose devices can also implement the present invention. The above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0109] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0110] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for optimizing quantum circuits in a quantum machine learning model, characterized in that, include: Obtain the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in the convergence state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model; Calculate the Hessian matrix of the loss function relative to the unitary matrix parameters, and determine the parameter that minimizes the value of the perturbation function of the loss function based on the Hessian matrix among the unitary matrix parameters as the target parameter; the perturbation function of the loss function is the amount of perturbation to the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters; When the value of the perturbation function does not exceed the preset perturbation threshold, the target parameter is set to zero to obtain the updated unitary matrix parameter to generate a new quantum circuit.

2. The method as described in claim 1, characterized in that, The process of obtaining updated unitary matrix parameters to generate new quantum circuits includes: Update the unitary matrix parameters after setting the target parameters to zero according to the preset parameter change function; return to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the value of the perturbation function exceeds the preset perturbation threshold, and stop, and withdraw the current target parameter zeroing operation; the preset parameter change function represents the amount of change of non-zero parameters in the unitary matrix parameters when the value of the perturbation function is minimum; A new quantum circuit is generated based on the updated unitary matrix parameters using a fast approximation block coding algorithm.

3. The method as described in claim 1, characterized in that, After generating the new quantum circuit, the method further includes: The initial quantum circuit used in the quantum machine learning model is replaced with a new quantum circuit to encode a non-unitary matrix.

4. The method as described in claim 1, characterized in that, After generating the new quantum circuit, the method further includes: Obtain the validation set data and the first model accuracy value of the quantum machine learning model; the first model accuracy value is the accuracy value of the quantum machine learning model using the initial quantum circuit and in a convergent state. The second model accuracy value of the quantum machine learning model is determined using validation set data; the second model accuracy value is the accuracy value of the quantum machine learning model when using a new quantum circuit. When the second precision value is less than the first precision value, the preset perturbation threshold is updated, and the process returns to the step of calculating the Hessian matrix of the loss function relative to the unitary matrix parameters until the second precision value is not less than the first precision value.

5. The method as described in claim 1, characterized in that, The disturbance function is shown in the following equation: Where L is the value of the perturbation function, [H -1 ] qq w is the element in the q-th row and q-th column of the inverse of the Hessian matrix. q It is the q-th parameter in the unitary matrix parameters.

6. The method as described in claim 1, characterized in that, The step of determining the target parameters based on the Hessian matrix among the unitary matrix parameters to minimize the value of the perturbation function of the loss function includes: Iterate through each parameter in the unitary matrix parameters and substitute each parameter into the perturbation function of the loss function one by one to calculate the value of the perturbation function corresponding to each parameter; By comparing the values ​​of the perturbation functions corresponding to each parameter, the parameter corresponding to the smallest perturbation function value is taken as the target parameter.

7. The method as described in claim 2, characterized in that, The preset parameter variation function is shown in the following formula: Where δw is the change in the non-zero parameter of the unitary matrix when the value of the perturbation function is minimized, w q H is the q-th parameter in the unitary matrix parameters. -1 Let e ​​be the inverse of the Hessian matrix. q The parameters of the unitary matrix correspond to w q A unit vector, [H -1 ] qq Let be the element in the q-th row and q-th column of the inverse of the Hessian matrix.

8. The method as described in claim 3, characterized in that, Updating the preset perturbation threshold includes: The preset perturbation threshold is updated by reducing the preset perturbation threshold by a preset percentage.

9. An optimization device for quantum circuits in a quantum machine learning model, characterized in that... ,include: The information acquisition module is used to acquire the initial quantum circuit used by the quantum machine learning model for encoding non-unitary matrices in the convergence state, the unitary matrix parameters of the initial quantum circuit, and the loss function of the quantum machine learning model. The target parameter determination module is used to calculate the Hessian matrix of the loss function relative to the unitary matrix parameters, and determine the parameter that minimizes the value of the perturbation function of the loss function based on the Hessian matrix among the unitary matrix parameters as the target parameter; the perturbation function of the loss function is the perturbation amount of the loss function by deleting the quantum logic gate corresponding to a certain parameter in the unitary matrix parameters. The unitary matrix parameter update module is used to set the target parameter to zero to obtain updated unitary matrix parameters in order to generate a new quantum circuit when the value of the perturbation function does not exceed a preset perturbation threshold.

10. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer instructions and the processor is configured to execute the computer instructions to perform the method according to any one of claims 1 to 8.

11. A storage medium, characterized in that, The storage medium stores computer instructions that are configured to execute the method described in any one of claims 1 to 8 when run.