Similarity comparison method and related device
By constructing a first circuit and a second circuit to generate the target quantum circuit, and utilizing the inner product norm and error mitigation techniques, the accuracy problem of data similarity comparison under noisy medium-scale quantum devices is solved, expanding the application of high-dimensional data comparison and achieving more efficient similarity comparison.
Patent Information
- Application Number
- CN202510545410.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2026-03-03
AI Technical Summary
In noisy, medium-scale quantum devices, quantum computers struggle to accurately compare data similarity, especially in high-dimensional feature data scenarios, where existing technologies cannot effectively utilize quantum computers for similarity comparison.
By constructing a first circuit and a second circuit, a target quantum circuit is generated. The inner product norm of the first quantum state and the second quantum state is determined by the action qubits of the target quantum circuit. By combining symmetry parameters and fitting parameters, error mitigation is achieved, thus enabling more accurate acquisition of similarity information.
It improves the accuracy and efficiency of quantum computers in data similarity comparison, and expands the application scenarios of high-dimensional data comparison, such as face recognition and geological exploration classification.
Smart Images

Figure CN121598097A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum circuit design technology, and in particular to a similarity comparison method and related apparatus. Background Technology
[0002] With the continuous development of quantum computing technology, more and more computational tasks can be performed by quantum computers. The emergence of Noisy Intermediate-Scale Quantum (NISQ) devices has made it possible to experiment with quantum algorithms on real hardware.
[0003] In the era of Noisy Intermediate-Scale Quantum (NISQ), due to the limited number of qubits, high noise levels, and short coherence time, Noisy Intermediate-Scale Quantum (NISQ) devices may be more widely used in hybrid algorithms (a combination of quantum and classical algorithms).
[0004] Therefore, it is of great significance to then apply quantum computers to hybrid algorithms. Summary of the Invention
[0005] This application provides a similarity comparison method and related apparatus. By setting up a first circuit and a second circuit, a first inner product norm of the first quantum state and the second quantum state is constructed, and the first inner product norm is used to characterize the similarity of the first data and the second data, thereby realizing the application of the kernel method on a quantum chip.
[0006] Meanwhile, in the process of determining similarity information, multiple first circuits and multiple second circuits are used to generate the target quantum circuit. The first result output by the target quantum circuit is obtained by averaging multiple results output by multiple first circuits and second circuits. Therefore, this method can make the final similarity information more accurate.
[0007] Furthermore, the first inner product norm can be updated using symmetry parameters and / or fitting parameters. This approach can also eliminate errors caused by hardware problems of the quantum computer itself to a certain extent, thus mitigating errors and making the final similarity information more accurate.
[0008] In other words, the method disclosed herein can obtain more accurate similarity information, which is beneficial for subsequent classical computer applications of this similarity information for data classification and other operations.
[0009] The first aspect of this application provides a quantum circuit generation method for similarity comparison, including:
[0010] A target quantum circuit is generated based on the first circuit and the second circuit, wherein the first circuit is used to encode the first data into the first quantum state, and the conjugate circuit corresponding to the second circuit is used to encode the second data into the second quantum state.
[0011] Using the target quantum circuit described above, at least one set of qubits is used to obtain a first result, and based on the first result, the first inner product norm of the first quantum state and the second quantum state is determined.
[0012] Based on the aforementioned first inner product norm, the similarity information between the aforementioned first data and the aforementioned second data is determined.
[0013] Optionally, the initial state of the qubits in at least one set of qubits is the |0> state, and the determination of the first inner product norm of the first quantum state and the second quantum state based on the first result includes:
[0014] Based on the probability value of the all-zero state |00> in the first result, the first inner product norm of the first quantum state and the second quantum state is determined.
[0015] Optionally, the generation of the target quantum circuit based on the first circuit and the second circuit includes:
[0016] The target quantum circuit is generated by using multiple first circuits and multiple second circuits, wherein the first circuits and the second circuits correspond one-to-one.
[0017] The above-mentioned first circuits have the same operating timing, and correspondingly, the above-mentioned second circuits also have the same operating timing.
[0018] In the aforementioned plurality of first circuits, each first circuit is connected to at least another first circuit via a double gate; correspondingly, in the aforementioned plurality of second circuits, each second circuit is connected to at least another second circuit via a double gate.
[0019] Optionally, obtaining the first result by utilizing at least one set of qubits through the target quantum circuit includes:
[0020] A predefined number of qubits are selected from each group of qubits for measurement to obtain the measurement results;
[0021] Based on the measurement results of each group, the above first result was determined.
[0022] Optionally, after determining the first inner product norm of the first quantum state and the second quantum state based on the first result, the method further includes:
[0023] Update the first inner product norm as described above.
[0024] Optionally, the above update of the first inner product norm includes:
[0025] The first inner product norm is updated using symmetry parameters and / or fitting parameters;
[0026] The aforementioned symmetry parameters are determined as follows:
[0027] The logic gate parameters in the second circuit are updated using the first data, and the logic gate parameters in the first circuit are updated using the second data; wherein the updated second circuit is used to encode the first data into a third quantum state, and the updated first circuit is used to encode the second data into a fourth quantum state.
[0028] A second result is obtained based on the action of at least one set of qubits on the updated target quantum circuit, and the second inner product norm of the third quantum state and the fourth quantum state is determined based on the second result.
[0029] Based on the first inner product norm and the second inner product norm, the symmetry parameter is determined; wherein, the interaction between the first inner product norm and the symmetry parameter is equal to the average of the second inner product norm and the first inner product norm.
[0030] The fitting parameters mentioned above are determined in the following way:
[0031] The logic gate parameters in the first circuit and the second circuit described above are determined using the target data.
[0032] By using the aforementioned target quantum circuit to act on at least one set of qubits, a third result is obtained;
[0033] Based on the measurement state and initial state of each qubit in at least one set of qubits indicated by the third result above, the above fitting parameters are determined.
[0034] Optionally, when the first number is greater than the second number, the above predefined number is 1;
[0035] Wherein, the first number is used to indicate the number of groups of the at least one group;
[0036] The second number mentioned above is used to indicate the number of qubits in a set.
[0037] A third aspect of this application provides a similarity comparison device, comprising:
[0038] A generation unit is used to generate a target quantum circuit according to a first circuit and a second circuit, wherein the first circuit is used to encode first data into a first quantum state, and the conjugate circuit corresponding to the second circuit is used to encode the second data into a second quantum state.
[0039] An action unit is used to act on at least one set of qubits using the target quantum circuit to obtain a first result, and to determine the first inner product norm of the first quantum state and the second quantum state based on the first result.
[0040] The determining unit is used to determine the similarity information between the first data and the second data based on the first inner product norm.
[0041] A third aspect of this application provides an electronic device, including: a processor and a memory;
[0042] The processor is connected to a memory, wherein the memory is used to store computer programs and the processor is used to invoke the computer programs to execute the methods as described in the first aspect of the embodiments of this application.
[0043] A fourth aspect of this application provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, perform the method as described in the first aspect of this application.
[0044] This application provides a similarity comparison method, a quantum circuit generation method, and related apparatus. By constructing a first circuit and a second circuit, where the first circuit encodes first data into a first quantum state, and the conjugate circuit of the second circuit encodes second data into a second quantum state, the second circuit can be used to encode the second quantum state into an initial state. Therefore, by combining the first and second circuits, a target quantum circuit can be obtained, which can be used to determine the first inner product norm of the first and second quantum states. The first inner product norm reflects the degree of similarity between the first and second quantum states, and thus also reflects the degree of similarity between the first and second data. This approach allows the similarity comparison process for data to be performed using quantum circuits. This method also enables similarity comparison of high-dimensional feature data that is difficult to perform classically, thereby expanding the application scenarios for data similarity comparison. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 An example system block diagram of a similarity comparison method provided in one embodiment of this application is shown;
[0047] Figure 2 A flowchart illustrating a similarity comparison method provided in one embodiment of this application is shown;
[0048] Figure 3 A schematic diagram of a target quantum circuit provided in one embodiment of this application is shown;
[0049] Figure 4 A schematic diagram of a quantum circuit provided in one embodiment of this application is shown;
[0050] Figure 5A , 5B Figure 5C shows a schematic diagram illustrating the similarity comparison results provided in one embodiment of this application;
[0051] Figure 6 A schematic diagram of the structure of a similarity comparison device provided in one embodiment of this application is shown;
[0052] Figure 7 A schematic diagram of the structure of a computer device provided in one embodiment of this application is shown. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0054] Classical computers use transistors to encode information in binary data, such as bits, where each bit can represent a value of 1 or 0. These 1s and 0s act as switches to drive the functions of a classical computer. If there are n bits of data, then there are 2... n Possible classical states, and represent one state at a time.
[0055] Quantum computers use quantum processors that operate on data represented by qubits, also known as quantum bits. A single qubit can represent the classical binary states "0" or "1", or a superposition of "0" and "1". Because it can represent a superposition of "0" and "1", a qubit can represent both "0" and "1" states simultaneously. For example, if there are n bits of data, then 2^n qubits can represent n bits of data. n A quantum state can be represented simultaneously. Furthermore, qubits in a superposition can be correlated with each other, a phenomenon known as entanglement, where the state of one qubit (whether 1, 0, or both) depends on the state of another qubit, and more information can be encoded within two entangled qubits. Based on the principles of superposition and entanglement, qubits enable quantum computers to perform functions that might be relatively complex and time-consuming for classical computers.
[0056] Please refer to Figure 1 This illustrates an example system block diagram of an application similarity comparison method provided in one embodiment of this application. System 100 may be a hybrid computing system comprising a combination of one or more quantum computers, quantum systems, and / or classical computers. Figure 1 In the example shown, system 100 may include a quantum system 110 and a classical computer 120. In one implementation, the quantum system 110 and the classical computer 120 may be configured to communicate via one or more wired and / or wireless connections (e.g., wireless networks). The quantum system 110 may include a quantum chipset consisting of one or more quantum chips, comprising various hardware components for processing data encoded in qubits. The quantum chipset may be a quantum computing core surrounded by infrastructure to protect the quantum chips from electromagnetic noise sources, mechanical vibration sources, heat sources, and other noise sources that can degrade the performance of the quantum chips. The classical computer 120 may be electronically integrated with the quantum system 110 via any suitable wired and / or wireless electronic connection.
[0057] exist Figure 1 In the example shown, quantum system 110 can be any suitable set of components capable of performing quantum operations on a physical system. Quantum operations, such as quantum gate operations, manipulate the quantum states of qubits to evolve and / or become entangled. Figure 1In the illustrated example embodiment, the quantum system 110 may include a measurement and control unit 111, an interface 112, and a quantum chip 113. In some embodiments, all or part of each of the measurement and control unit 111, interface 112, and quantum chip 113 may be located in a cryogenic environment to facilitate the performance of quantum operations. The quantum chip 113 may be any hardware capable of processing information using quantum states. This hardware may include multiple qubits and means for coupling or entanglement of the qubits to process information using quantum states. Qubits may include, but are not limited to, charge qubits, flux qubits, phase qubits, spin qubits, and ion qubits. The quantum chip may include a set of quantum logic gates configured to perform quantum logic operations on the qubits stored in a quantum register. The quantum gates may include one or more single-qubit gates, two-qubit gates, and / or other multi-qubit gates.
[0058] The measurement and control unit 111 can be any combination of digital computing devices capable of performing quantum computing (e.g., executing quantum circuits) in conjunction with interface 112. This digital computing device may include a digital processor and memory for storing and executing quantum instructions using interface 112. The digital computing device may also include a communication protocol device for receiving instructions and sending the results of the performed quantum computing to a classical computer. Additionally, the digital computing device may include a communication interface having interface 112. In one embodiment, the measurement and control unit 111 may be configured to receive classical instructions (e.g., from classical computer 120) and convert these classical instructions into measurement and control instructions for interface 112. The measurement and control instructions provided by the measurement and control unit 111 to interface 112 may be, for example, digital signals indicating which quantum gates in a quantum gate array need to be applied to the qubits to perform a specific function. Interface 112 may be configured to convert these digital signals into analog signals (e.g., analog pulses of microwave pulses), which can be used to apply quantum gates to the qubits to manipulate the interactions between the qubits.
[0059] Interface 112 may be a classical-quantum interface, comprising a combination of devices capable of receiving instructions from the integrated measurement and control unit 111 and converting those instructions into a means for implementing quantum operations. In one embodiment, interface 112 may convert instructions from the integrated measurement and control unit 111 into drive signals capable of driving or manipulating qubits, and / or applying quantum gates to qubits. Additionally, interface 112 may be configured to convert signals received from the quantum chip 113 into digital signals capable of being processed and transmitted by the integrated measurement and control unit 111. Devices included in interface 112 may include, but are not limited to, digital-to-analog converters, analog-to-digital converters, waveform generators, attenuators, amplifiers, optical fibers, lasers, and filters. Interface 112 may further include circuitry configured to measure multiple qubits after the application of quantum gates, wherein the measurements may produce results represented in classical bits. Each measurement performed by interface 112 may be read out to a device connected to the quantum system 110, such as a classical computer 120. The multiple measurement results provided by interface 112 may represent probabilistic results.
[0060] The classical computer 120 can include hardware components such as a processor and storage devices (e.g., including memory devices and classical registers) for processing data encoded in classical bits. In one embodiment, the classical computer 120 can be configured to provide the quantum system 110 with various control signals, instructions, and data encoded in classical bits. Further, quantum states measured by the quantum system 110 can be read out by the classical computer 120, and the classical computer 120 can store the measured quantum states as classical bits in classical registers. In one embodiment, the classical computer 120 can be any suitable combination of computer-executable hardware and / or computer-executable software capable of executing the preparation module 121 to perform quantum computation using data stored in the data storage module 122 as part of the construction and computation. The data storage module 122 can be a repository for data to be analyzed using quantum computing algorithms and the results of that analysis. The preparation module 121 can be a program or module capable of preparing classical data from the data storage module 122 as part of a quantum circuit implementation. Preparation module 121 can be instantiated as part of a larger algorithm, such as an application programming interface (API) function call, or by resolving hybrid classical-quantum computing into aspects of quantum and classical computing. For example, preparation module 121 can generate instructions for creating quantum circuits using quantum gates. In an embodiment, such instructions can be stored by the measurement and control unit 111 and can be instantiated by components of interface 112 to execute, enabling quantum operations of quantum gates to be performed on quantum chip 113.
[0061] The classic computer 120 may be a laptop computer, desktop computer, vehicle-integrated computer, smart mobile device, tablet device, and / or any other suitable classic computing device. Additionally or alternatively, the classic computer 120 may also operate as part of a cloud computing service model, such as Software as a Service (SaaS), Platform as a Service (PaaS), or Infrastructure as a Service (IaaS). The classic computer 120 may also reside in a cloud computing deployment model, such as a private cloud, community cloud, public cloud, or hybrid cloud.
[0062] Based on the aforementioned background information, it is clear that combining quantum and classical algorithms allows quantum computers to participate in more scenarios and address practical problems in the NISQ era. However, how to effectively integrate quantum computers into the actual problem-solving process remains a challenge.
[0063] In this disclosure, by combining a first circuit and a second circuit into a target quantum circuit, the first circuit can encode first data into a first quantum state, and the conjugate circuit of the second circuit can encode second data into a second quantum state. Therefore, if the first data and the second data are the same, the first circuit can encode the first data into the first quantum state, and the second circuit can convert the first quantum state into an initial state. Thus, the similarity information between the first data and the second data can be determined based on the first result of the target quantum circuit acting on at least one set of qubits. That is, this method of constructing a first inner product norm for the first and second quantum states by setting the first and second circuits can achieve the determination of the similarity between the first data and the second data.
[0064] Furthermore, this approach facilitates high-dimensional data comparison and enables its application in more high-dimensional scenarios. For example, in scenarios requiring dimensional similarity comparisons, such as facial recognition and geological survey classification, data comparison may need to be performed across multiple dimensions. Since this approach utilizes quantum chips for similarity comparison, information from multiple feature dimensions can be encoded into corresponding qubits, thus facilitating efficient comparison of such data. In other words, this method not only allows for a better integration of quantum computing and classical computing but also enables its application in more scenarios, offering more efficient and accurate technical results in some high-dimensional environments.
[0065] For example, in a face recognition scenario, the first data and the second data can be understood as image data. In the process of comparing the first data and the second data, it may be necessary to compare geometric features (including but not limited to extracting information such as the position and proportion of facial organs, such as the position, distance, angle and outline shape of the eyes, nose and mouth); shape features (including but not limited to the distance between the eyes, the height of the bridge of the nose, the outline of the face); pixel intensity features (such as the pixel intensity of a grayscale image reflects the brightness and darkness of the image, and the pixel intensity of each channel (such as RGB) of a color image); texture features, etc.
[0066] For example, for an M×N grayscale face image, its pixel data can be considered as an M×N dimensional vector; for a color image, each pixel has three channels (RGB), which is a 3×M×N dimensional vector. For instance, a 64×64 grayscale image has 4096 dimensions, while a color image has 12288 dimensions. This type of data has high dimensionality and redundancy, and is easily affected by lighting and noise, so dimensionality reduction processing is usually required.
[0067] However, after dimensionality reduction, some features may lack strong representation capabilities. In this disclosure, features can be encoded into specific quantum states, and through quantum entanglement and other methods, the representation capability for those features can be increased to a certain extent. Furthermore, this method can encode features from multiple dimensions onto a single qubit, which is beneficial for processing higher-dimensional data with fewer bits.
[0068] Please refer to Figure 2 This document illustrates a flowchart of a similarity comparison method provided in an embodiment of this application. This method can be applied to computer devices, which refer to electronic devices capable of data computation and processing. The method may include the following steps:
[0069] Step 201: Generate the target quantum circuit based on the first circuit and the second circuit.
[0070] Here, the first circuit is used to encode the first data into the first quantum state, and the conjugate circuit corresponding to the second circuit is used to encode the second data into the second quantum state.
[0071] As an example, in practical applications, the first circuit and the second circuit can be combined to generate the target quantum circuit. For instance, the first circuit can operate before the second circuit, thus obtaining the target quantum circuit. Alternatively, the first circuit can operate before the second circuit.
[0072] To make it easier to understand, you can combine... Figure 3 To explain, Figure 3This can be understood as a schematic diagram of a possible target quantum circuit provided in this disclosure. As can be seen, the target quantum circuit can be divided into two parts, one of which can be understood as the first circuit, and correspondingly, the other part can be understood as the second circuit. For example, Figure 3 unitary operator U(x) i When the circuit corresponding to ) is the first circuit, then the unitary operator The corresponding circuit is the second circuit. Of course, when the unitary operator U(x) i When the corresponding circuit is the second circuit, then the unitary operator... The corresponding circuit is the first circuit.
[0073] Step 202: Use the target quantum circuit to act on at least one set of qubits to obtain a first result, and determine the first inner product norm of the first quantum state and the second quantum state based on the first result.
[0074] As an example, if the first quantum state and the second quantum state are the same, then the first inner product norm of the first quantum state and the second quantum state can be equal to a specific value. That is, the further the first inner product norm is from this specific value, the greater the difference between the first quantum state and the second quantum state.
[0075] It should be understood that the first inner product norm at this time can be used to indicate the similarity between the initial state and the final state. For example, if the first quantum state and the second quantum state are the same, then the first inner product norm of the first quantum state and the second quantum state can be equal to 1. At this time, it can be characterized that the first data and the second data are completely the same. That is, through the combined action of the first circuit and the second circuit, the state of the qubit can be returned to the initial state.
[0076] Therefore, it can also be understood that the greater the difference between the final state and the initial state indicated by the first result, the greater the difference between the first quantum state and the second quantum state, and the smaller the similarity between the first data and the second data.
[0077] Step 203: Based on the first inner product norm, determine the similarity information between the first data and the second data.
[0078] As an example, the first inner product norm can reflect the difference between the first quantum state and the second quantum state, while the difference between the first quantum state and the second quantum state can reflect the difference between the first data and the second data. Therefore, the similarity information between the first data and the second data can be determined based on the first inner product norm.
[0079] As can be seen, in this disclosure, by constructing a first circuit and a second circuit, where the first circuit encodes first data into a first quantum state, and the conjugate circuit of the second circuit encodes second data into a second quantum state, and the second circuit can be used to encode the second quantum state into an initial state, a target quantum circuit can be obtained by combining the first circuit and the second circuit. This target quantum circuit can then be used to determine the first inner product norm of the first quantum state and the second quantum state. The first inner product norm reflects the similarity between the first quantum state and the second quantum state, and thus also reflects the similarity between the first data and the second data. This approach allows for the comparison of data similarity using quantum circuits. This method also enables the comparison of high-dimensional feature data that is difficult to compare classically, thereby expanding the application scenarios for data similarity comparison.
[0080] In other words, this approach combines quantum computing with classical computing. For example, classical computers can further classify data based on similarity information.
[0081] In some embodiments, the initial state of the qubits in at least one set of qubits is the |0> state, and the determination of the first inner product norm of the first quantum state and the second quantum state based on the first result may specifically include:
[0082] Based on the probability value of the all-zero state |00> in the first result, determine the first inner product norm of the first quantum state and the second quantum state.
[0083] As an example, the initial state of at least one set of qubits is |0>, which allows for better utilization of the first or second circuit to encode them into a specific first or second quantum state. Correspondingly, it also facilitates the determination of the first inner product norm based on the first result.
[0084] That is, in this disclosure, when the initial state of the qubits in at least one set of qubits is the |0> state, if the first data and the second data are the same, then the first quantum state and the second quantum state should be the same, and the final state indicated by the first result should also be the |0> state. Therefore, the first inner product norm of the first quantum state and the second quantum state can be characterized by the probability value of the all-zero state |00> in the first result.
[0085] To make it easier to understand, further examples will be provided:
[0086] Suppose we have two sets of data, x1 and x2 (where x1 can be understood as the first set of data and x2 as the second set of data). We can construct the distance between these two sets of data, which can also be understood as determining the similarity between them. Specifically, we can first construct a chip-friendly quantum circuit |ψ(θ1)>=U(θ1)|0>, where the quantum gate can directly encode the information of the data using direct angle encoding. Thus, we can directly encode x1, thereby completing the data mapping to an exponential Hilbert space. Then, we encode x2, similarly obtaining |ψ(θ2)>=U(θ2)|0>.
[0087] Finally, by measuring the probability of the all-0> state, we can obtain d(x1,x2)=||ψ(θ1)|ψ(θ2)>|| 2 The value of d(x1,x2) can, to some extent, measure the distance between two data points. When x1 = x2, then d(x1,x2) = 1. The greater the difference between x1 and x2, the further d(x1,x2) is from 1. Thus, another way of measuring distance can be achieved based on this.
[0088] This approach can also be understood as applying kernel methods to quantum computers. Kernel methods are a class of techniques widely used in machine learning and statistics, primarily utilizing kernel tricks to handle nonlinear problems. The core idea is to map the input data x from a low-dimensional space to a high-dimensional space through a nonlinear mapping φ(x), thus transforming the nonlinear problem of the sample input space into a linear problem of the feature space. Using the method disclosed herein, it is possible to effectively map n data points into an exponential kernel space, achieving a significant speedup compared to classical kernel computation methods. This approach can also be applied to scenarios such as anomaly detection and object classification, and used for data similarity judgment in these scenarios.
[0089] It should be noted here that, since the first and second data need to be encoded into quantities, they can be preprocessed before encoding. This preprocessing can be understood as shrinking the first and second data to the range [0-1]. Of course, the specific scaling method can be limited according to the actual situation, and no limitation is made on the scaling method here.
[0090] In some embodiments, step 201 (generating the target quantum circuit based on the first circuit and the second circuit) may specifically include:
[0091] The target quantum circuit is generated by using multiple first circuits and multiple second circuits.
[0092] Here, the first circuit corresponds one-to-one with the second circuit;
[0093] If multiple first circuits operate with the same timing sequence, then correspondingly, multiple second circuits also operate with the same timing sequence.
[0094] In the plurality of first circuits, each first circuit is connected to at least another first circuit via a double gate; correspondingly, in the plurality of second circuits, each second circuit is connected to at least another second circuit via a double gate.
[0095] As an example, one first circuit can correspond to one second circuit; and setting up multiple first circuits helps to construct a target quantum circuit with higher accuracy. The idea can be understood as: by combining multiple relatively weak models (weak learners) to build a stronger model (strong learner); this approach can be used to improve the performance of quantum algorithms, thereby enhancing the entanglement of quantum states or improving the accuracy of quantum computing.
[0096] In this disclosure, by setting up multiple first circuits, it is helpful to make the qubits in each first circuit entangled with each other, thereby helping to make the final first result more accurate.
[0097] In some embodiments, step 202, "obtaining a first result by utilizing the target quantum circuit to act on at least one set of qubits," may specifically include:
[0098] A predefined number of qubits are selected from each group of qubits for measurement to obtain the measurement results;
[0099] Based on the measurement results of each group, the first result is determined.
[0100] As an example, when there are many qubits in a group, or at least many groups of qubits, the total number of qubits may be large. Since the total number of qubits is large, measuring the state of all qubits could consume a lot of resources and time. Therefore, a certain number of qubits in each group can be selected for measurement, and the measurement results of the selected qubits can be used to characterize the measurement results of all qubits, thus obtaining the first result of the target quantum circuit for at least one group of qubits.
[0101] This approach allows for the addition of multiple sets of first circuits to make the first result more accurate without excessively increasing the measurement time and resource consumption of the first result (the first result of the target quantum circuit) for this combined circuit.
[0102] It can also be understood that in practical applications, the number of qubits that can be used may be greater than the number of qubits required by a first circuit. Therefore, the method disclosed herein can be used to apply these qubits to form multiple sets of qubits and to improve computation using multiple sets of qubits.
[0103] To make it easier to understand, examples can be given:
[0104] Assuming there is data with 4 dimensions, it can be processed on 20 bits, and can be encoded as follows:
[0105] Bit identifier number Single-door coding Dual-gate encoding Single-door coding Dual-gate encoding Single-door coding 1,2,3,4 RY CX RX CZ RZ 5,6,7,8 RX CZ RY CX RZ 9,10,11,12 RY CX RZ CZ RX 13,14,15,16 RX CZ RZ CX RY 17,18,19,20 RY CX RX CZ RZ
[0106] As can be seen, each quantum core (either the first circuit or the second circuit can be considered a quantum core) uses a hybrid encoding method. When executing two gates, each bit can also be entangled, thus completing a natural boosting scheme on a quantum computer (Boosting can be understood as an ensemble learning method that combines multiple weak learners to build a strong learner. In the field of quantum computing, the boosting scheme can refer to using quantum circuit design to enhance the entanglement of quantum states or improve the accuracy of quantum computing, thereby improving the performance of the model). Of course, after applying the above circuit, a dagger (which can be understood as the conjugate transpose of a quantum operator) is also needed. That is, if a quantum core can be the first circuit, then a second circuit also needs to be applied to complete the target quantum circuit. After that, the probability of all zero states can be measured and used as similarity information.
[0107] In this process, performing full measurements of all 20 qubits could be wasteful of resources. In such cases, sparse measurements can be used. For example, only one qubit in each set of qubits is measured, so only 5 qubits need to be measured, thus saving measurement resources.
[0108] To illustrate further, consider a scenario where at least one set of qubits contains 5 qubits, and each set contains 4 qubits. If all qubits are measured, it would be necessary to measure the states of 20 qubits. However, one qubit can be selected from a set for measurement, thus requiring only the measurement of the states of 5 qubits. The states of these 5 selected qubits can then be used to represent the states of all 20 qubits.
[0109] For example, if all 5 measured qubits are in the |0> state, then all 20 qubits are in the |0> state. If one of the 5 measured qubits is in a non-|0> state, then it can be indicated that 4 of the 20 qubits may be in a non-|0> state. In this case, the first inner product norm value may be 0.8, indicating that the two data points being compared have a high degree of similarity.
[0110] In some embodiments, when the first number is greater than the second number, the predefined number can be 1;
[0111] Here, the first number can be used to indicate the number of groups of at least one set; the second number can be used to indicate the number of qubits in a set.
[0112] As an example, when the first number is greater than the second number, it indicates that there are more groups. In this case, only one qubit can be selected for measurement in each group, thus saving measurement resources. Data verification shows that this selection method can achieve accuracy comparable to full measurement. Therefore, this method not only saves measurement resources but also ensures the accuracy of the first result.
[0113] In some embodiments, after "determining the first inner product norm of the first quantum state and the second quantum state based on the first result" in step 202, the above method may further include:
[0114] Update the first inner product norm.
[0115] As an example, updating the first inner product norm helps to make the final similarity information more accurate. That is, "determining the similarity information of the first data and the second data based on the first inner product norm" in step 203 can be understood as determining the similarity between the first data and the second data based on the updated first inner product norm.
[0116] In some embodiments, the first inner product norm can be updated using symmetry parameters and / or fitting parameters.
[0117] Here, the symmetry parameter can be determined as follows:
[0118] The logic gate parameters in the second circuit are updated using the first data, and the logic gate parameters in the first circuit are updated using the second data; wherein the updated second circuit is used to encode the first data into a third quantum state, and the updated first circuit is used to encode the second data into a fourth quantum state;
[0119] Based on the updated target quantum circuit, at least one set of qubits is used to obtain a second result, and based on the second result, the second inner product norm of the third and fourth quantum states is determined.
[0120] Based on the first inner product norm and the second inner product norm, the symmetry parameter is determined; wherein the interaction between the first inner product norm and the symmetry parameter is equal to the average of the second inner product norm and the first inner product norm.
[0121] In this disclosure, on a quantum computer, it may be necessary to compute d(x2,x1)=||<ψ(θ2)|ψ(θ1)>|| 2 The first result is averaged with d(x1,x2) to cancel out errors. Although theoretically these two data points are the same, noise and other hardware limitations of quantum computers can lead to inaccuracies in the calculations, necessitating error mitigation. This can be understood as: using the first circuit to encode the second data, and using the second circuit to encode the first circuit, a second result can be obtained. Since the first and second results should be identical, they can be averaged to determine the symmetry parameter. After applying the symmetry parameter, the first inner product norm can be equal to the average of the first and second inner product norms.
[0122] Of course, in specific application scenarios, the symmetry parameters of the second inner product norm can also be determined. The principle is the same as that for determining the first inner product norm, and will not be elaborated here. Furthermore, for any inner product norm, the symmetry parameters can be determined using the above method.
[0123] Here, the fitting parameters can be determined as follows:
[0124] Use the target data to determine the logic gate parameters in the first and second circuits;
[0125] By using the target quantum circuit to act on at least one set of qubits, a first result can be obtained;
[0126] Based on the measurement state and initial state of each qubit in at least one set of qubits indicated by the first result, the fitting parameters are determined.
[0127] It should be understood that in practice, the measured state may not be equal to the initial state due to factors such as noise and bit quality. Therefore, the fitting parameters can be determined based on the difference between the measured state and the initial state. By applying the fitting parameters to the measured state, the measured state can be updated to be equal to the initial state. The fitting parameters can be applied to various data that need to be compared, thereby optimizing the errors caused by external factors such as noise.
[0128] It should be understood that in this disclosure, when operating on a dataset, the dataset can be labeled, and the first and second data points can be selected from within the dataset. For example, when the first and second data points are selected and compared sequentially, such as having N data points labeled 1, 2, 3, 4...N, after selecting the data point labeled 1 as the first data point, the second data point is selected sequentially from the data point labeled 1 to the data point labeled N, thus obtaining N first results; and so on, until the first data point is selected from the data point labeled N, again obtaining N first results. In this way, N times N first results can be obtained, which can form a matrix, and this matrix can also be understood as a kernel matrix.
[0129] The elements K of the kernel matrix K ij =d(x i ,x j After the calculation is completed, the rows and columns need to be enlarged based on the property that the theoretical value of the diagonal elements is 1, so as to normalize the diagonal elements.
[0130] In other words, in this disclosure, based on the property that the theoretical value of the diagonal elements is 1, the kernel matrix K is first transformed into a diagonal matrix. Furthermore, based on this property, fitting parameters are determined, thereby correcting the elements in the kernel matrix K and helping to make the obtained kernel matrix more accurate. This process can also be understood as updating the first inner product norm using symmetry parameters and / or fitting parameters, where the first inner product norm can be understood as any element in the kernel matrix.
[0131] In some embodiments, the first data and the second data can be of the same type. Based on the dimension information corresponding to the first data, the number of bits in a set of qubits can be determined.
[0132] As an example, feature data from one dimension can correspond to one qubit, or feature data from several related dimensions can correspond to one qubit, and the specific selection can be limited according to the actual situation. However, the number of qubits in a group is related to the dimensional information; when there is more dimensional information, the number of qubits in a group is usually larger.
[0133] It should be understood that the first circuit and the second circuit are used to compare the similarity of the first data and the second data, respectively, and the first data and the second data are similar in dimension and type. Therefore, the first circuit and the second circuit may be quite similar, and in some cases (e.g., when the first data and the second data are the same), the first circuit and the second circuit may constitute a conjugate circuit (that is, the target quantum circuit may be a conjugate circuit); in this case, after acting on at least one set of qubits, the measured state should be the same as the initial state.
[0134] To facilitate understanding of the fitting concept in this disclosure, it can be combined with... Figure 4 , Figure 5A , 5B 5C will be explained. Figure 4 This can be understood as a schematic diagram of a possible quantum circuit. Figure 5A , 5B 5C can be understood as a schematic diagram showing the results of similarity comparison.
[0135] exist Figure 4 In this context, the quantum circuit U(x) can be understood as the first circuit, and correspondingly, This can be understood as a second circuit. The verification dataset used for this quantum circuit can be the Iris dataset, which can be completed by selecting 100 data points. Figure 4 The quantum circuit shown measures and stores all occurrences of |0>. n The probability values of the states are obtained, resulting in a dataset of 100*100 data points as shown below. Arranging these 100 data points in a 50:50 ratio of positive to negative values yields the following results. Figure 5A The situation is illustrated; then the data can be calibrated using the conjugate summation method, transforming it into a symmetric matrix while also offsetting errors introduced by the quantum computer, thus obtaining... Figure 5B The situation is shown below. Then, based on the natural property that the diagonal elements are always 1, the natural properties of the 100 diagonal elements can be determined, completing the full calibration of the entire 100*100 data, thus obtaining... Figure 5C The situation shown.
[0136] It should be understood that, Figures 5A-5C In this diagram, both the horizontal and vertical axes can be understood as labels for the data. For example, the horizontal axis can be understood as the first data point, and the specific value of the first data point can be determined based on the label. Similarly, the vertical axis can be understood as the second data point, and the specific value of the second data point can also be determined based on the label (since the 100 data points have been pre-labeled, the first and second data points can be determined based on the labels). The intensity of the color represents the degree of similarity; the darker the color, the more similar the data.
[0137] Furthermore, from Figures 5A-5B The process can be understood as calibration using the conjugate summation method. That is, since the data is selected based on labels, the colors in the obtained similarity comparison result image should be diagonally symmetrical. Based on this principle, the conjugate summation method can be used for calibration. Figures 5B-5C The process can be understood as the process of finding the shortcomings of the fitting parameters. That is, the first inner product norm value on the diagonal should be 1. Based on this, the fitting parameters can be determined, and then each inner product norm (optimizing each element in the kernel matrix) can be optimized based on the determined fitting parameters.
[0138] Figure 6 A schematic diagram of the structure of a similarity comparison device 600 provided in one embodiment of this application is shown.
[0139] The device 600 includes:
[0140] The generation unit 601 is used to generate a target quantum circuit according to the first circuit and the second circuit, wherein the first circuit is used to encode the first data into a first quantum state, and the conjugate circuit corresponding to the second circuit is used to encode the second data into a second quantum state.
[0141] The action unit 602 is used to act on at least one set of qubits using the target quantum circuit to obtain a first result, and to determine the first inner product norm of the first quantum state and the second quantum state based on the first result.
[0142] The determining unit 603 is used to determine the similarity information between the first data and the second data based on the first inner product norm.
[0143] In some embodiments, the initial state of the qubits in the at least one set of qubits is the |0> state, and the action unit 602 is further configured to: determine the first inner product norm of the first quantum state and the second quantum state based on the probability value of the all-zero state |00> in the first result.
[0144] In some embodiments, the action unit 602 is further configured to: generate the target quantum circuit using a plurality of first circuits and a plurality of second circuits, wherein the first circuits correspond one-to-one with the second circuits;
[0145] The above-mentioned first circuits have the same operating timing, and correspondingly, the above-mentioned second circuits also have the same operating timing.
[0146] In the aforementioned plurality of first circuits, each first circuit is connected to at least another first circuit via a double gate; correspondingly, in the aforementioned plurality of second circuits, each second circuit is connected to at least another second circuit via a double gate.
[0147] In some embodiments, the action unit 602 is further configured to: select a predefined number of qubits from each group of qubits for measurement, and obtain measurement results;
[0148] Based on the measurement results of each group, the above first result was determined.
[0149] In some embodiments, the similarity comparison device 600 is further configured to update the first inner product norm.
[0150] In some embodiments, the similarity comparison device 600 is further configured to: update the first inner product norm using symmetry parameters and / or fitting parameters;
[0151] The aforementioned symmetry parameters are determined as follows:
[0152] The logic gate parameters in the second circuit are updated using the first data, and the logic gate parameters in the first circuit are updated using the second data; wherein the updated second circuit is used to encode the first data into a third quantum state, and the updated first circuit is used to encode the second data into a fourth quantum state.
[0153] A second result is obtained based on the action of at least one set of qubits on the updated target quantum circuit, and the second inner product norm of the third quantum state and the fourth quantum state is determined based on the second result.
[0154] Based on the first inner product norm and the second inner product norm, the symmetry parameter is determined; wherein, the interaction between the first inner product norm and the symmetry parameter is equal to the average of the second inner product norm and the first inner product norm.
[0155] The fitting parameters mentioned above are determined in the following way:
[0156] The logic gate parameters in the first circuit and the second circuit described above are determined using the target data.
[0157] By using the aforementioned target quantum circuit to act on at least one set of qubits, a third result is obtained;
[0158] Based on the measurement state and initial state of each qubit in at least one set of qubits indicated by the third result above, the above fitting parameters are determined.
[0159] In some embodiments, when the first number is greater than the second number, the predefined number is 1;
[0160] Wherein, the first number is used to indicate the number of groups of the at least one group;
[0161] The second number mentioned above is used to indicate the number of qubits in a set.
[0162] Figure 7 A schematic diagram of the structure of a computer device provided in one embodiment of this application is shown, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the functions of the computer system for determining fitting parameters or a method for determining fitting parameters for quantum error mitigation in any of the above embodiments.
[0163] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, causes the computer to perform the functions of the computer system for determining fitting parameters or a method for determining fitting parameters for quantum error mitigation in any of the above embodiments.
[0164] This application also provides a computer program product containing instructions that, when executed by a computer, cause the computer to perform the functions of the computer system for determining fitting parameters or fitting parameter determination methods for quantum error mitigation in any of the above embodiments.
[0165] It is understood that the specific examples in this application are only intended to help those skilled in the art better understand the implementation methods of this application, and are not intended to limit the scope of the invention.
[0166] It is understood that in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiments of this application in any way.
[0167] It is understood that the various implementation methods described in this application can be implemented individually or in combination, and the implementation methods in this application are not limited in this respect.
[0168] Unless otherwise stated, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items. The singular forms "a," "the," and "the" as used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0169] It is understood that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0170] It is understood that the memory in the embodiments of this application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Specifically, non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM). It should be noted that the memory in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0171] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0172] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the aforementioned method implementations, and will not be repeated here.
[0173] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0174] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0175] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0176] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0177] The above are merely specific embodiments of this application, but the scope of protection of this invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this invention should be determined by the scope of the claims.
Claims
1. A similarity comparison method, characterized in that, include: A target quantum circuit is generated based on the first circuit and the second circuit, wherein the first circuit is used to encode the first data into a first quantum state, and the conjugate circuit corresponding to the second circuit is used to encode the second data into a second quantum state; The first result is obtained by using the target quantum circuit to act on at least one set of qubits, and the first inner product norm of the first quantum state and the second quantum state is determined based on the first result; Based on the first inner product norm, the similarity information between the first data and the second data is determined.
2. The method according to claim 1, characterized in that, The initial state of the qubits in the at least one set of qubits is the |0> state, and the determination of the first inner product norm of the first quantum state and the second quantum state based on the first result includes: Based on the probability value of the all-zero state |00> in the first result, determine the first inner product norm of the first quantum state and the second quantum state.
3. The method according to claim 1, characterized in that, The generation of the target quantum circuit based on the first circuit and the second circuit includes: The target quantum circuit is generated using multiple first circuits and multiple second circuits, wherein the first circuits correspond one-to-one with the second circuits. The multiple first circuits operate with the same timing sequence, and correspondingly, the multiple second circuits also operate with the same timing sequence. In the plurality of first circuits, each first circuit is connected to at least another first circuit via a double gate; correspondingly, in the plurality of second circuits, each second circuit is connected to at least another second circuit via a double gate.
4. The method according to claim 3, characterized in that, The process of obtaining a first result by utilizing the target quantum circuit to act on at least one set of qubits includes: A predefined number of qubits are selected from each group of qubits for measurement to obtain the measurement results; The first result is determined based on the measurement results of each group.
5. The method according to claim 1, characterized in that, After determining the first inner product norm of the first quantum state and the second quantum state based on the first result, the method further includes: Update the first inner product norm.
6. The method according to claim 5, characterized in that, The update of the first inner product norm includes: The first inner product norm is updated using symmetry parameters and / or fitting parameters; The symmetry parameter is determined in the following way: The logic gate parameters in the second circuit are updated using the first data, and the logic gate parameters in the first circuit are updated using the second data; wherein the updated second circuit is used to encode the first data into a third quantum state, and the updated first circuit is used to encode the second data into a fourth quantum state; A second result is obtained based on the action of at least one set of qubits on the updated target quantum circuit, and the second inner product norm of the third quantum state and the fourth quantum state is determined based on the second result; The symmetry parameter is determined based on the first inner product norm and the second inner product norm; wherein the interaction between the first inner product norm and the symmetry parameter is equal to the average of the second inner product norm and the first inner product norm. The fitting parameters are determined in the following manner: The logic gate parameters in the first and second circuits are determined using the target data; By utilizing the target quantum circuit to act on at least one set of qubits, a third result is obtained; The fitting parameters are determined based on the measurement state and initial state of each qubit in at least one set of qubits indicated by the third result.
7. The method according to claim 4, characterized in that, When the first number is greater than the second number, the predefined number is 1; Wherein, the first number is used to indicate the number of groups of the at least one group; The second number is used to indicate the number of qubits in a set.
8. A similarity comparison device, characterized in that, include: A generation unit is configured to generate a target quantum circuit based on a first circuit and a second circuit, wherein the first circuit is configured to encode first data into a first quantum state, and the conjugate circuit corresponding to the second circuit is configured to encode the second data into a second quantum state; An action unit is used to act on at least one set of qubits using the target quantum circuit to obtain a first result, and to determine the first inner product norm of the first quantum state and the second quantum state based on the first result; The determining unit is configured to determine the similarity information between the first data and the second data based on the first inner product norm.
9. An electronic device, characterized in that, include: Processor and memory; The processor is connected to a memory, wherein the memory is used to store a computer program, and the processor is used to invoke the computer program to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, perform the method as described in any one of claims 1-7.