A quantum compiling method, apparatus, device, storage medium, and program product

CN123014255APending Publication Date: 2026-10-30CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510542898.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]然而,发明人发现现有技术至少存在如下问题:在采用直接编译的方法进行量子编译时,首先对目标量子线路进行优化,通过识别目标量子线路中的冗余操作或通过模板匹配,实现量子逻辑门的合并简化或替换,再将优化后的量子线路中的逻辑门逐一翻译为基本量子逻辑门序列

Benefits of technology

[0045]与现有技术相比,本发明公开的量子编译方法、装置、设备、存储介质和程序产品,通过将单个目标量子线路编译为多个酉算子基的线性组合,并通过机器学习模型对所述线性组合进行求解,得到目标量子线路的量子编译结果,其中酉算子基可直接翻译为基本量子逻辑门序列,能够实现将编译深度压缩至线性复杂度,从而有效降低了量子编译的计算复杂度,且编译结果不会超出量子计算机的能力上限。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014255A_ABST
    Figure CN123014255A_ABST
Patent Text Reader

Abstract

The application discloses a quantum compiling method, device and equipment, a storage medium and a program product. The method comprises the following steps: obtaining a sequence of unitary operator bases including a plurality of unitary operator bases; expanding a target quantum circuit into a linear combination form under the sequence of unitary operator bases, wherein the linear combination form includes coefficients corresponding to the unitary operator bases to be solved; constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator bases according to the target quantum circuit and the sequence of unitary operator bases; inputting the plurality of unitary operator bases into the machine learning model for calculation, outputting the coefficients corresponding to each unitary operator base, and generating a compiling result of the target quantum circuit according to each unitary operator base and the corresponding coefficient. By compiling a single target quantum circuit into a linear combination of a plurality of basic quantum logic gate sequences, the compiling depth can be compressed to linear complexity, and the calculation complexity of quantum compiling is effectively 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 technology, and in particular to a quantum compilation method, apparatus, device, storage medium, and program product. Background Technology

[0002] Quantum computing is a technology that utilizes the principles of quantum mechanics, particularly quantum superposition and quantum entanglement, to process information. Theoretically, quantum computing's computational power far surpasses that of classical computers. However, due to limitations in decoherence time and quantum noise, quantum computers can only execute shallow quantum circuits, thus placing high demands on the performance of quantum compilers. The goal of a quantum compiler is to transform a target quantum circuit into a sequence of executable quantum operations on a quantum computer; these executable quantum operations are also known as basic quantum logic gates. Currently, various quantum compilation methods exist, such as direct compilation, search-based refactoring compilation, and methods based on quantum generative models.

[0003] However, the inventors discovered that existing technologies have at least the following problems: When using direct compilation for quantum compilation, the target quantum circuit is first optimized by identifying redundant operations or through template matching to merge, simplify, or replace quantum logic gates. Then, the optimized quantum circuit's logic gates are translated one by one into a sequence of basic quantum logic gates. However, this method is mostly a local optimization, and for highly complex quantum circuits, the resulting compiled sequence exceeds the capability limit of the NISQ (Noisy Intermediate-Scale Quantum) quantum computer. When using search-based reconstruction compilation or quantum generation model-based compilation, although compilation is performed globally, theoretically, the optimal compilation depth of the quantum circuit has an exponential complexity with respect to the number of qubits. Therefore, as the number of qubits increases, the computational complexity of these methods rises sharply, and the optimal compilation result far exceeds the capability limit of the NISQ quantum computer. Summary of the Invention

[0004] The purpose of this invention is to provide a quantum compilation method, apparatus, device, storage medium, and program product. By compiling a single target quantum circuit into a linear combination of multiple unitary operator bases, which can be directly translated into a sequence of basic quantum logic gates, the compilation depth can be compressed to linear complexity, effectively reducing the computational complexity of quantum compilation.

[0005] To achieve the above objectives, embodiments of the present invention provide a quantum compilation method, comprising:

[0006] Obtain a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases;

[0007] The target quantum circuit is expanded into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved;

[0008] Based on the target quantum circuit and the unitary operator basis sequence, a machine learning model for calculating the coefficients corresponding to the unitary operator basis is constructed and trained;

[0009] Several unitary operator bases are input into the machine learning model for calculation, and the coefficients corresponding to each unitary operator base output by the machine learning model are obtained. Based on each unitary operator base and the coefficients corresponding to the unitary operator bases, the compilation result of the target quantum circuit is generated.

[0010] In a preferred embodiment, the unitary operator basis is a complete unitary operator basis.

[0011] As an improvement to the above scheme, the step of constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence includes:

[0012] The target quantum circuit is represented by a machine learning model; wherein the input of the machine learning model is a unitary operator basis, and the output is the coefficients corresponding to the unitary operator basis;

[0013] A first sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a first set of unitary operator bases; wherein, the first set of unitary operator bases includes a target number of unitary operator bases;

[0014] The unitary operator basis in the first set of unitary operator basis is used as training data to train the machine learning model and obtain an approximate reconstruction of the target quantum circuit.

[0015] The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function;

[0016] Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

[0017] As an improvement to the above scheme, the step of inputting several unitary operator bases into the machine learning model for calculation, obtaining the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients, includes:

[0018] A second sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a second set of unitary operator bases; wherein, the second set of unitary operator bases includes a target number of unitary operator bases;

[0019] Using the unitary operator basis in the second set of unitary operator basis as the input of the machine learning model, the coefficients corresponding to each unitary operator basis are obtained;

[0020] The compilation result of the target quantum circuit is generated based on the unitary operator basis in the second unitary operator basis set and the coefficients corresponding to the unitary operator basis.

[0021] As an improvement to the above scheme, the unitary operator basis in the unitary operator basis sequence is subjected to a first sampling operation or a second sampling operation through the following steps:

[0022] The modulus square of the coefficients corresponding to the unitary operator basis is expressed as the product of conditional probabilities, and a preset unitary operator basis sampler is constructed.

[0023] The vectorized representation of the internal parameters of the target quantum circuit is used as the initial input of the unitary operator basis sampler, and the first probability distribution of the unitary operator basis is obtained as the output.

[0024] The first element of the unitary operator basis is obtained by sampling according to the first probability distribution;

[0025] The sampled elements of the unitary operator basis and the vectorized representation of the internal parameters of the target quantum circuit are concatenated and input into the unitary operator basis sampler, and the second probability distribution of the unitary operator basis is output.

[0026] The next element of the unitary operator basis is obtained by sampling according to the second probability distribution until all elements of the unitary operator basis are sampled to obtain a unitary operator basis;

[0027] Repeat the above steps until the target number of unitary operator bases are obtained through sampling.

[0028] In another preferred embodiment, the unitary operator basis is an incomplete unitary operator basis; wherein, the incomplete unitary operator basis is obtained by truncating a set of complete unitary operator bases.

[0029] As an improvement to the above scheme, the step of constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence includes:

[0030] The target quantum circuit is represented by a machine learning model; wherein the parameters of the machine learning model are the coefficients corresponding to each unitary operator basis.

[0031] Using each unitary operator basis in the unitary operator basis sequence as training data, the machine learning model is trained to obtain an approximate reconstruction of the target quantum circuit.

[0032] The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function;

[0033] Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

[0034] As an improvement to the above scheme, the step of inputting several unitary operator bases into the machine learning model for calculation, obtaining the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients, includes:

[0035] Each unitary operator basis in the unitary operator basis sequence is used as the input to the machine learning model to obtain the coefficients corresponding to each unitary operator basis;

[0036] The compilation result of the target quantum circuit is generated based on each unitary operator basis and its corresponding coefficient in the unitary operator basis sequence.

[0037] This invention also provides a quantum compiler device, comprising:

[0038] The unitary operator basis acquisition module is used to acquire a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases;

[0039] A linear combination representation module is used to expand the target quantum circuit into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved;

[0040] The learning model training module is used to construct and train a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence.

[0041] The compilation result acquisition module is used to input several unitary operator bases into the machine learning model for calculation, obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generate the compilation result of the target quantum circuit based on each unitary operator base and the coefficients corresponding to the unitary operator bases.

[0042] This invention also provides a quantum compilation device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the quantum compilation method as described in any of the preceding embodiments.

[0043] This invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the quantum compilation method as described in any of the preceding embodiments.

[0044] This invention also provides a computer program product, which includes a computer program or computer instructions, wherein the computer program or computer instructions, when executed by a processor, implement the quantum compilation method as described in any of the above embodiments.

[0045] Compared with existing technologies, the quantum compilation method, apparatus, device, storage medium, and program product disclosed in this invention compile a single target quantum circuit into a linear combination of multiple unitary operator bases, and solves the linear combination using a machine learning model to obtain the quantum compilation result of the target quantum circuit. The unitary operator bases can be directly translated into basic quantum logic gate sequences, which can compress the compilation depth to linear complexity, thereby effectively reducing the computational complexity of quantum compilation, and the compilation result will not exceed the capability limit of a quantum computer. Attached Figure Description

[0046] Figure 1 This is a flowchart illustrating a quantum compilation method provided in an embodiment of the present invention;

[0047] Figure 2 This is a schematic diagram of a preferred quantum compilation method according to an embodiment of the present invention;

[0048] Figure 3 This is a first schematic diagram of the target quantum circuit in a first implementation scenario of the present invention;

[0049] Figure 4 This is a second schematic diagram of the target quantum circuit in the first implementation scenario of this invention;

[0050] Figure 5 This is a third schematic diagram of the target quantum circuit in the first implementation scenario of this invention;

[0051] Figure 6 This is a first schematic diagram of the target quantum circuit in the second implementation scenario of this invention;

[0052] Figure 7This is a second schematic diagram of the target quantum circuit in the second implementation scenario of this invention;

[0053] Figure 8 This is a schematic diagram of the compilation result of the target quantum circuit in the second implementation scenario of the present invention;

[0054] Figure 9 This is a schematic diagram of the structure of a quantum compiler device provided in an embodiment of the present invention. Detailed Implementation

[0055] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0056] In the description of this application, it should be understood that the terms "center", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.

[0057] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0058] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.

[0059] See Figure 1 This is a flowchart illustrating a quantum compilation method provided by an embodiment of the present invention. The embodiment of the present invention provides a quantum compilation method, the method comprising steps S11 to S14:

[0060] S11. Obtain a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases;

[0061] S12. Expand the target quantum circuit into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved;

[0062] S13. Based on the target quantum circuit and the unitary operator basis sequence, construct and train a machine learning model for calculating the coefficients corresponding to the unitary operator basis;

[0063] S14. Input several unitary operator bases into the machine learning model for calculation, obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generate the compilation result of the target quantum circuit based on each unitary operator base and the coefficients corresponding to the unitary operator base.

[0064] In this embodiment of the invention, in order to solve the problem that the computational complexity of existing compilation methods for target quantum circuits is large, or that the optimal compilation result given exceeds the capability limit of quantum computers, this embodiment of the invention compresses the compilation depth to linear complexity by compiling a single target quantum circuit into a linear combination of multiple basic quantum logic gate sequences.

[0065] It should be noted that any quantum circuit can be linearly expanded under a set of unitary operator bases: Each unitary operator basis U i All of them can be directly translated into a linear-depth sequence of basic quantum logic gates. Therefore, the core issue is how to obtain each U through compilation techniques. i The corresponding coefficient α i .

[0066] Unitary operator bases include complete unitary operator bases and incomplete unitary operator bases; an incomplete unitary operator base is obtained by truncating a set of complete unitary operator bases. For a set of incomplete unitary operator bases, the coefficient α is... i It can be stored and solved, but since an incomplete unitary operator basis is obtained by truncating a complete unitary operator basis, its expressive power is limited, and the approximation effect of this scheme is limited for complex quantum circuits. A complete unitary operator basis can precisely express any quantum circuit, but a complete unitary operator basis generally contains an exponential number of (4^2) unitary operators. N (where N is the number of qubits), all coefficients α i They constitute an exponentially dimensional probability distribution, and their squared modulus |α i | 2Since the probability distribution is normalized, the probability distribution in the exponential dimension cannot be stored and solved precisely. Therefore, this embodiment of the invention uses a machine learning model to express this probability distribution in the exponential dimension, that is, compresses the probability distribution information in the parameters of the machine learning model, learns this probability distribution through training, and thus gives the compilation result.

[0067] Specifically, arbitrarily select a set of unitary operator bases {U i} i=0,…,n The unitary operator basis can be a complete unitary operator basis or an incomplete unitary operator basis. The target quantum circuit V(θ) is expanded under the unitary operator basis, i.e. Wherein, coefficient α i To be determined, θ is an internal parameter of V.

[0068] The target quantum circuit is represented by a machine learning model M(m). The unitary operator basis sequence is used as training data to train the machine learning model, thereby obtaining a machine learning model for calculating the coefficients corresponding to the unitary operator basis for the target quantum circuit.

[0069] It should be noted that the training here is for a target quantum circuit V(θ) with a specific structure, and only has a generalization effect on its internal parameters. That is, when θ changes but the structure of V(θ) remains unchanged, the trained M(w) can directly produce the compilation result. When the structure of V(θ) changes, the trained M(w) can no longer directly produce the compilation result and needs to be retrained. Therefore, this step of training can be regarded as variational optimization of a specific target V(θ).

[0070] After training is complete, the unitary operator basis U is calculated based on the machine learning model. i The corresponding coefficient α i Furthermore, based on the unitary operator basis U i and the corresponding coefficient α i The compilation result of the target quantum circuit V(θ) is obtained. When executed subsequently on a quantum computer, each U... i It can be directly translated into a sequence of basic quantum logic gates, then each gate is executed individually and the outputs are linearly combined; alternatively, it can be implemented using a unified quantum circuit. The compilation is now complete.

[0071] By employing the technical means of this invention, a single target quantum circuit is compiled into a linear combination of multiple unitary operator bases, and the linear combination is solved using a machine learning model to obtain the quantum compilation result of the target quantum circuit. The unitary operator bases can be directly translated into basic quantum logic gate sequences, which can compress the compilation depth to linear complexity, thereby effectively reducing the computational complexity of quantum compilation, and the compilation result will not exceed the capability limit of a quantum computer.

[0072] See Figure 2 This is a schematic diagram of a preferred quantum compilation method according to an embodiment of the present invention. The embodiments of the present invention will explain and describe two implementation methods using complete unitary operator bases and incomplete unitary operator bases respectively.

[0073] In one implementation, the unitary operator basis is a complete unitary operator basis.

[0074] Step S13, namely, constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence, includes:

[0075] The target quantum circuit is represented by a machine learning model; wherein the input of the machine learning model is a unitary operator basis, and the output is the coefficients corresponding to the unitary operator basis;

[0076] A first sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a first set of unitary operator bases; wherein, the first set of unitary operator bases includes a target number of unitary operator bases;

[0077] The unitary operator basis in the first set of unitary operator basis is used as training data to train the machine learning model and obtain an approximate reconstruction of the target quantum circuit.

[0078] The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function;

[0079] Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

[0080] Further, step S14, namely, inputting several unitary operator bases into the machine learning model for calculation to obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients, includes:

[0081] A second sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a second set of unitary operator bases; wherein, the second set of unitary operator bases includes a target number of unitary operator bases;

[0082] Using the unitary operator basis in the second set of unitary operator basis as the input of the machine learning model, the coefficients corresponding to each unitary operator basis are obtained;

[0083] The compilation result of the target quantum circuit is generated based on the coefficients corresponding to the unitary operators in the second set of unitary operator bases.

[0084] Specifically, in this embodiment of the invention, an arbitrary set of complete unitary operator bases {U} is selected. i} i=0,…,n Expanding the target quantum circuit V(θ) under unitary operator basis, i.e. coefficient α i To be determined. θ is an internal parameter of V.

[0085] For a complete unitary arithmetic base n=4 N -1 represents a size that a classical computer cannot store (N is the number of qubits). Therefore, a machine learning model M(w) is used to express V(θ), denoted as... Its inputs are θ and U i The output is the probability coefficient α. i The input requires a relationship between θ and U. i For vectorization, one-hot encoding can be used to process θ, assuming θ = (θ0,…,θ) K Then the encoding matrix is:

[0086]

[0087] Furthermore, the machine learning model M(w) is trained as follows:

[0088] Randomly initialize the parameters of M(w).

[0089] For a complete unitary operator basis, a batch of d U's are sampled through M(w). i This batch of training data will be used to obtain... It is an approximate reconstruction of V(θ). The difference between M(w) and V(θ) is used as the loss function and calculated. Since the complexity of simulation computation is exponential with respect to N, the loss function generally needs to be obtained by measurement on a quantum computer, which is essentially measuring each unitary operator basis of the input quantum state. The parameter w of M(w) is updated using an optimization algorithm.

[0090] Repeat the above steps until M(w) converges, and save the converged parameters w. The training process is now complete.

[0091] Furthermore, the compilation result of the target quantum route is given based on the trained machine learning module, as detailed below:

[0092] For a complete unitary operator basis, a batch of d unitary operator bases U are sampled based on the trained M(w). i .Will This is the compilation result of V(θ). For a complete unitary operator basis, in practice, multiple batches of U can be sampled. iCalculate separately and then take the mean or median of the results to reduce the variance of the results.

[0093] It should be noted that, Figure 2 In this context, the unitary operator basis sampler represents a machine learning model M(w) of complete unitary operators. LCU (Linear Combination of Unitaries) represents a linear combination of unitary operators.

[0094] Preferably, due to the output α of M(w) i Modulus squared|α i | 2 It is a probability distribution, therefore U can be... i Treat it as a random variable, |α i | 2 Let its probability distribution be given, and then M(w) be used to apply it to U. i Perform a sampling operation.

[0095] Based on this, the unitary operator basis in the unitary operator basis sequence is subjected to a first sampling operation or a second sampling operation through the following steps:

[0096] The modulus square of the coefficients corresponding to the unitary operator basis is expressed as the product of conditional probabilities, and a preset unitary operator basis sampler is constructed.

[0097] The vectorized representation of the internal parameters of the target quantum circuit is used as the initial input of the unitary operator basis sampler, and the first probability distribution of the unitary operator basis is obtained as the output.

[0098] The first element of the unitary operator basis is obtained by sampling according to the first probability distribution;

[0099] The sampled elements of the unitary operator basis and the vectorized representation of the internal parameters of the target quantum circuit are concatenated and input into the unitary operator basis sampler, and the second probability distribution of the unitary operator basis is output.

[0100] The next element of the unitary operator basis is obtained by sampling according to the second probability distribution until all elements of the unitary operator basis are sampled to obtain a unitary operator basis;

[0101] Repeat the above steps until the target number of unitary operator bases are obtained through sampling.

[0102] The following explanation illustrates the process of implementing quantum compilation using a complete unitary operator basis through a specific implementation scenario. Specifically, it demonstrates the data encoding circuitry and quantum neural network compilation during quantum machine learning using the MNIST dataset as an example. The MNIST dataset is a dataset of handwritten digits, containing 10 classes from 0 to 9. The training set contains 60,000 images, and the test set contains 10,000 images.

[0103] In the first implementation scenario, the task is to compile a quantum neural network. Classical data is encoded to obtain a quantum state, which is then used by the quantum neural network for feature extraction. The output result is obtained through measurement, or it may be further processed by other quantum algorithms before being measured again to obtain the output result. This means that the quantum neural network to be compiled will appear at the end or in the middle of the entire quantum machine learning circuit.

[0104] See Figure 3 This is a first schematic diagram of the target quantum circuit in the first implementation scenario of this invention, showing a schematic diagram of one layer of a quantum neural network V(θ). V(θ) contains a stack of 30 of these layers, with a qubit count N of 6. In this implementation scenario, a Pauli basis is selected as the unitary operator basis. Since V(θ) contains quantum entanglement gates, a long-range Pauli basis is required for expression; therefore, a complete Pauli basis is directly used here. θ contains the parameters of all Pauli rotation gates, including δ1,…,δ1…. N ,γ1,…,γ N ,β1,…,β N This quantum circuit has a CNOT gate, which enables quantum entanglement.

[0105] See Figure 4 This is a second schematic diagram of the target quantum circuit in the first implementation scenario of this invention. Figure 4 This represents the execution scheme in quantum hardware of the compiled result of the target quantum circuit V(θ) at the end of all quantum circuits. The left side shows the original complete quantum circuits, U(β) is the data encoding circuit, V(θ) is the quantum neural network to be compiled, and θ is its internal parameters. The quantity to be measured is shown. The right side shows a single quantum circuit compiled using this proposal.

[0106] For cases where measurements are performed directly after a quantum neural network, V(θ) is at the end of the circuit, such as... Figure 4 As shown in the left figure. The physical quantity to be measured is:

[0107]

[0108] Will Also unfolding under Paulige: at this time,

[0109]

[0110] Each of these can be passed Figure 4 The quantum circuit shown in the right figure is implemented, and then the whole system is implemented through LCU.

[0111] See Figure 5 This is a third schematic diagram of the target quantum circuit in the first implementation scenario of this invention. Figure 5 This represents the execution scheme of the compiled result of the target quantum circuit V(θ) in the middle of all quantum circuits in quantum hardware. The left side shows the original full set of quantum circuits, U(β) is the data encoding circuit, V(θ) is the quantum neural network to be compiled, θ is its internal parameters, and U′(γ) is the quantum circuit of the post-processing quantum algorithm. The quantity to be measured is shown. The right side shows a single quantum circuit compiled using this proposal, employing Hadamard detection technology.

[0112] For cases where there are other post-processing quantum algorithms following the quantum neural network, V(θ) is in the middle of the circuit, such as... Figure 5 As shown in the left figure. The physical quantity to be measured is:

[0113]

[0114] Will Also unfolding under Paulige: at this time

[0115]

[0116] Each of these can be passed Figure 5 The quantum circuit shown in the right figure is implemented, and then the whole system is implemented through LCU.

[0117] In this implementation scenario, the following settings are provided. The following are the specific steps:

[0118] Step 1: Select a complete Pauli basis as the unitary operator basis.

[0119] Step 2: Expand the target quantum circuit V(θ) in a complete Pauli scheme, with coefficients α i To be determined.

[0120] Step 3: Use a machine learning model M(w) to express V(θ), denoted as Specifically, M(w) consists of two parts: a feature extraction layer and a classification layer. The feature extraction layer is represented by a recurrent neural network (RNN), and its input is σ. iThe vectorized representation of i, i.e., the one-hot representation of the quaternary vector corresponding to i (in the form of (1,0,3,…,1,2), which represents XIZ…XY), is an N×4 matrix. For example, for (1,0,3,…,1,2), the matrix is:

[0121]

[0122] Therefore, the input dimension of an RNN is 4, and the corresponding output dimension is 32, containing 6 layers. Since... Since M(w) is a complex number, its classification layer consists of two parts: the logarithmic amplitude loga i and phase φ i Both methods employ linear layers with an input dimension of 32 and an output dimension of 4. The former uses a log_softmax function after the linear layer to output the logarithm of the normalized probability, while the latter uses softsign or tanh after the linear layer to constrain the result to between -1 and 1. The parameters to be optimized are the parameters in the RNN and the linear layer.

[0123] Step 4: Train M(w).

[0124] Step 4.1: Randomly initialize the parameters in M(w), including the RNN and the linear layer.

[0125] Step 4.2: Obtain 1000 σ values ​​through autoregressive sampling using M(w). i As training data.

[0126] The specific sampling process is as follows: Since M(w) adopts an autoregressive model architecture, efficient autoregressive sampling can be used. First, |α... i | 2 Represented as the product of conditional probabilities: The initial input is a vectorized representation of θ. For quantum circuits without parameters, θ can be replaced by a zero vector. The output is M(w). Right now Let I, X, Y, and Z be the probabilities, and then sample a value based on this probability distribution. Then θ and The vectorized representation of the input M(w) is a concatenated matrix, and the output is... Then sample according to this probability distribution. Subsequent steps follow the same pattern until samples are obtained. This completes the sampling of one σ. i .

[0127] Step 4.3: Obtain using training data It is an approximate reconstruction of V(θ).

[0128] Step 4.4: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require The mean squared error between V(θ) and V(θ) is used as the loss function and calculated as follows:

[0129]

[0130] in, σ is the actual expansion of V(θ) i The corresponding true coefficients are obtained by measuring them on a quantum computer.

[0131] Step 4.5: Calculate the gradient of parameter w in M(w) using the backpropagation algorithm, and then update the parameter using the gradient descent method.

[0132] Step 4.6: Repeat steps 4.2-4.5 until M(w) converges, and save the converged parameters w. The training process is now complete.

[0133] Step 5: The compilation results are presented below. A batch of 1000 σ values ​​is sampled based on the trained M(w). i .

[0134] Step Six: As an approximate reconstruction of V(θ), each σ is then executed separately on a quantum computer. i The results from each sample are then linearly combined to obtain the final result. In practice, multiple batches of σ can be sampled. i Calculate separately and then take the mean or median of the results to reduce the variance of the results. In practice, the approximation accuracy of this example can reach more than 99%.

[0135] In another implementation, the unitary operator basis is an incomplete unitary operator basis.

[0136] Step S13, namely, constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence, includes:

[0137] The target quantum circuit is represented by a machine learning model; wherein the parameters of the machine learning model are the coefficients corresponding to each unitary operator basis.

[0138] Using each unitary operator basis in the unitary operator basis sequence as training data, the machine learning model is trained to obtain an approximate reconstruction of the target quantum circuit.

[0139] The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function;

[0140] Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

[0141] Further, step S14, namely, inputting several unitary operator bases into the machine learning model for calculation to obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients, includes:

[0142] Each unitary operator basis in the unitary operator basis sequence is used as the input to the machine learning model to obtain the coefficients corresponding to each unitary operator basis;

[0143] The compilation result of the target quantum circuit is generated based on each unitary operator basis and its corresponding coefficient in the unitary operator basis sequence.

[0144] Specifically, in this embodiment of the invention, an incomplete set of unitary operator bases {U} is arbitrarily selected. i} i=0,…,n Expanding the target quantum circuit V(θ) under unitary operator basis, i.e. coefficient α i To be determined. θ is an internal parameter of V.

[0145] For incomplete unitary operator basis {U i} i=0,…,n , where n is the storage size of a classical computer, therefore the coefficient α i This refers to the direct object of optimization, which is denoted as the parameter of the generalized machine learning model M(w), where w represents all the coefficients α. i .

[0146] Furthermore, the machine learning model M(w) is trained as follows:

[0147] Randomly initialize the parameters of M(w).

[0148] For incomplete unitary operator bases, directly use all d Ud. i Package it into training data; use this batch of training data to obtain... It is an approximate reconstruction of V(θ). The difference between M(w) and V(θ) is used as the loss function and calculated. Since the complexity of simulation computation is exponential with respect to N, the loss function generally needs to be obtained by measurement on a quantum computer, which is essentially measuring each unitary operator basis of the input quantum state. The parameter w of M(w) is updated using an optimization algorithm.

[0149] Repeat the above steps until M(w) converges, and save the converged parameters w. The training process is now complete.

[0150] Furthermore, the compilation result of the target quantum route is given based on the trained machine learning module, as detailed below:

[0151] For incomplete unitary operator bases, all d unitary operator bases U are directly used. i .Will This is the result of compiling V(θ).

[0152] It should be noted that, in Figure 2 In this case, for incomplete unitary operator bases, the unitary operator base sampler module can be directly replaced with all unitary operator bases.

[0153] The following describes the process of implementing quantum compilation using incomplete unitary operator bases through a specific implementation scenario.

[0154] In the second implementation scenario, the data encoding circuitry for quantum machine learning is compiled. A crucial task in quantum machine learning is encoding classical data into quantum states, because quantum machine learning models can only process quantum states and cannot directly process classical data.

[0155] See Figure 6 This is a first schematic diagram of the target quantum circuit in the second implementation scenario of this invention. Figure 6 This paper demonstrates a single layer of a quantum circuit that encodes classical data into the angles of a Pauli rotation gate. The original image size of each image in the MNIST dataset is 28×28, which cannot be directly input into a quantum computer in the NISQ era. Therefore, max-pooling is used to downsample it to a size of 6×6, and the pixel values ​​are compressed to the range [0, 2π). Thus, three layers are required. Figure 6 The circuit in the image is denoted as V(θ). It is a circuit with 6 qubits and a layer depth of 6, containing 6 × 6 = 36 parameters, consistent with the number of pixels in the downsampled image. Each processed pixel value is sequentially deployed onto these 36 parameters in the quantum hardware via microwave or laser. θ contains all the parameters of the Pauli rotation gate, including δ1,…,δ N ,γ1,…,γ N This quantum circuit does not contain a quantum entanglement gate.

[0156] In this implementation scenario, choosing the Pauli basis as the unitary operator basis allows for a rigorous expansion of V(θ): in Let i be the i-th polity, with length N, and there are a total of 4. N indivual. It is one of the identity operator and the Pauli operator, both of which are fundamental quantum logic gates.

[0157]

[0158] Where i is the imaginary unit. Since V(θ) does not contain entanglement gates, only short-range Paulibes need to be chosen. Here, for σ... i Truncate it to 2 to degenerate it into a set of incomplete unitary operator bases, i.e., select only those containing two... Pauliets that are not the unit operator I have a total of Therefore, the parameters to be optimized are these 135 σ values. i Corresponding α i .

[0159] See Figure 7 This is a second schematic diagram of the target quantum circuit in the second implementation scenario of this invention. Figure 7 This represents the execution scheme in quantum hardware of the compiled result of the target quantum circuit V(θ) at the beginning of all quantum circuits. The left side shows the original all quantum circuits, V(θ) is the data encoding circuit to be compiled, θ is its internal parameters, and U(β) is the quantum neural network and other post-processing quantum algorithms. The quantity to be measured is shown. The right side shows a single quantum circuit compiled using this proposal, employing Hadamard detection technology.

[0160] The data encoding circuit V(θ) is located at the beginning of all quantum circuits, followed by quantum neural networks and other post-processing quantum algorithms, denoted by U(β), such as... Figure 7 As shown in the left figure. The physical quantity to be measured is:

[0161]

[0162] Will Also unfolding under Paulige: at this time,

[0163]

[0164] Each of these can be passed Figure 7 The quantum circuit shown in the right figure is implemented, and then the whole system is implemented through LCU.

[0165] In this implementation scenario, the following settings are provided. The following is a description of the specific compilation steps:

[0166] Step 1: Select the 135 truncated Pauli bases as unitary operator bases.

[0167] Step 2: Place the target quantum circuit V(θ) in this 135 σ... i Expand downwards, coefficient α i To be determined.

[0168] Step 3: The parameters to be optimized are these 135 α values. i .

[0169] Step 4: Optimize these 135 parameters α i .

[0170] Step 4.1: Randomly initialize these 135 α values. i .

[0171] Step 4.2: These 135 σ i Package it into training data.

[0172] Step 4.3: Obtain using training data It is an approximate reconstruction of V(θ).

[0173] Step 4.4: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require The mean squared error between V(θ) and V(θ) is used as the loss function and calculated as follows:

[0174]

[0175] in σ is the actual expansion of V(θ) i The corresponding true coefficients are obtained through measurement on a quantum computer. In quantum hardware, V(θ) is the realized target quantum circuit, and the measurement is essentially a measurement of the output quantum state of V(θ), which can be achieved through optical snapshot (fluorescence collection). During the measurement, σ is first... i The information is sent to the optical camera module in the measurement and control system, and σ is obtained from each optical snapshot. i An eigenvalue can be obtained by taking multiple optical snapshots and averaging the results to obtain the expected value Tr(V(θ)σ). i ).

[0176] Step 4.5: Calculate each parameter α using the backpropagation algorithm. i The gradient is calculated, and then α is updated using gradient descent. i .

[0177] Step 4.6: Repeat steps 4.2-4.5 until parameter α is reached. i The training process concludes upon convergence, and the converged parameters are saved.

[0178] Step 5: The compilation results are shown below. All 135 σ values ​​are used directly. i .

[0179] Step Six: As a result of compiling V(θ). See also Figure 8 This is a schematic diagram of the compilation result of the target quantum circuit in the second implementation scenario of this invention. Figure 8 This represents the quantum circuit implementation scheme of the LCU. |ψ> represents the input quantum state, U0,…,U d-1This represents a single unitary operator (quantum circuit). The bottom row contains auxiliary bits, and the numbers in the circles indicate the number of control bits. V and W represent wave splitting and combining operations, respectively. Figure 8 Quantum circuits are executed on quantum computers, and each σ i That is Figure 8 U in i .

[0180] This invention utilizes the technical means of embodiments of the present invention to compile quantum circuits using LCU technology, and provides solutions under complete and incomplete unitary operator bases, theoretically yielding superior compilation results. For the trivial implementation scheme of LCU, the compiled quantum circuit depth is O(N), and for the quantum circuit implementation scheme of LCU, the compiled quantum circuit depth is O(dN), where d is the number of unitary operator bases. Both are linear compilation depths, far superior to the exponential compilation depth in traditional schemes. Furthermore, this invention can reconstruct and compile unknown target quantum circuits, and it can compile the entire quantum circuit or a portion of it separately, exhibiting superior quantum compilation performance.

[0181] See Figure 9 This is a schematic diagram of the structure of a quantum compiler device provided in an embodiment of the present invention. The embodiment of the present invention provides a quantum compiler device 10, comprising:

[0182] The unitary operator basis acquisition module 11 is used to acquire a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases;

[0183] The linear combination representation module 12 is used to expand the target quantum circuit into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved;

[0184] The learning model training module 13 is used to construct and train a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence.

[0185] The compilation result acquisition module 14 is used to input several unitary operator bases into the machine learning model for calculation, obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generate the compilation result of the target quantum circuit based on each unitary operator base and the coefficients corresponding to the unitary operator bases.

[0186] It should be noted that the quantum compiler device provided in this embodiment of the invention is used to execute all the process steps of the quantum compiler method in the above embodiment. The working principle and beneficial effects of the two are one-to-one, so they will not be described again.

[0187] This invention also provides a quantum compilation device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the quantum compilation method as described in any of the above embodiments.

[0188] This invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when running, controls the device containing the computer-readable storage medium to execute the quantum compilation method as described in any of the above embodiments.

[0189] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the quantum compilation method as described in any of the above embodiments.

[0190] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0191] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A quantum compilation method, characterized in that, include: Obtain a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases; The target quantum circuit is expanded into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved; Based on the target quantum circuit and the unitary operator basis sequence, a machine learning model for calculating the coefficients corresponding to the unitary operator basis is constructed and trained; Several unitary operator bases are input into the machine learning model for calculation, and the coefficients corresponding to each unitary operator base output by the machine learning model are obtained. Based on each unitary operator base and the coefficients corresponding to the unitary operator bases, the compilation result of the target quantum circuit is generated.

2. The quantum compilation method as described in claim 1, characterized in that, The unitary operator basis is a complete unitary operator basis; The step of constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence includes: The target quantum circuit is represented by a machine learning model; wherein the input of the machine learning model is a unitary operator basis, and the output is the coefficients corresponding to the unitary operator basis; A first sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a first set of unitary operator bases; wherein, the first set of unitary operator bases includes a target number of unitary operator bases; The unitary operator basis in the first set of unitary operator basis is used as training data to train the machine learning model and obtain an approximate reconstruction of the target quantum circuit. The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function; Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

3. The quantum compilation method as described in claim 2, characterized in that, The step of inputting several unitary operator bases into the machine learning model for calculation, obtaining the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients includes: A second sampling operation is performed on the unitary operator bases in the unitary operator base sequence to obtain a second set of unitary operator bases; wherein, the second set of unitary operator bases includes a target number of unitary operator bases; Using the unitary operator basis in the second set of unitary operator basis as the input of the machine learning model, the coefficients corresponding to each unitary operator basis are obtained; The compilation result of the target quantum circuit is generated based on the unitary operator basis in the second unitary operator basis set and the coefficients corresponding to the unitary operator basis.

4. The quantum compilation method as described in claim 2 or 3, characterized in that, The unitary operator basis in the unitary operator basis sequence is subjected to a first sampling operation or a second sampling operation through the following steps: The modulus square of the coefficients corresponding to the unitary operator basis is expressed as the product of conditional probabilities, and a preset unitary operator basis sampler is constructed. The vectorized representation of the internal parameters of the target quantum circuit is used as the initial input of the unitary operator basis sampler, and the first probability distribution of the unitary operator basis is obtained as the output. The first element of the unitary operator basis is obtained by sampling according to the first probability distribution; The sampled elements of the unitary operator basis and the vectorized representation of the internal parameters of the target quantum circuit are input into the unitary operator basis sampler, and the second probability distribution of the unitary operator basis is output. The next element of the unitary operator basis is obtained by sampling according to the second probability distribution until all elements of the unitary operator basis are sampled to obtain a unitary operator basis; Repeat the above steps until the target number of unitary operator bases are obtained through sampling.

5. The quantum compilation method as described in claim 1, characterized in that, The unitary operator basis is an incomplete unitary operator basis; wherein, an incomplete unitary operator basis is obtained by truncating a set of complete unitary operator bases; The step of constructing and training a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence includes: The target quantum circuit is represented by a machine learning model; wherein the parameters of the machine learning model are the coefficients corresponding to each unitary operator basis. Using each unitary operator basis in the unitary operator basis sequence as training data, the machine learning model is trained to obtain an approximate reconstruction of the target quantum circuit. The difference between the target quantum circuit and the approximate reconstruction is calculated as a loss function; Based on the loss function, the parameters of the machine learning model are updated using a preset optimization algorithm until the machine learning model converges, resulting in a fully trained machine learning model.

6. The quantum compilation method as described in claim 5, characterized in that, The step of inputting several unitary operator bases into the machine learning model for calculation, obtaining the coefficients corresponding to each unitary operator base output by the machine learning model, and generating the compilation result of the target quantum circuit based on each unitary operator base and its corresponding coefficients includes: Each of the unitary operator bases in the unitary operator base sequence is used as input to the machine learning model to obtain the coefficients corresponding to each unitary operator base. The compilation result of the target quantum circuit is generated based on each unitary operator basis and its corresponding coefficient in the unitary operator basis sequence.

7. A quantum compiler device, characterized in that, include: The unitary operator basis acquisition module is used to acquire a set of unitary operator basis sequences; wherein, the unitary operator basis sequence includes several unitary operator bases; A linear combination representation module is used to expand the target quantum circuit into a linear combination form under the unitary operator basis sequence, wherein the linear combination form includes the coefficients corresponding to each of the unitary operator basis to be solved; The learning model training module is used to construct and train a machine learning model for calculating the coefficients corresponding to the unitary operator basis based on the target quantum circuit and the unitary operator basis sequence. The compilation result acquisition module is used to input several unitary operator bases into the machine learning model for calculation, obtain the coefficients corresponding to each unitary operator base output by the machine learning model, and generate the compilation result of the target quantum circuit based on each unitary operator base and the coefficients corresponding to the unitary operator bases.

8. A quantum compiler device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the quantum compilation method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the quantum compilation method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the quantum compilation method as described in any one of claims 1 to 6.