Quantum circuit simulation method, device, equipment, storage medium and program product

Through vector parallelization technology, the parallel input parameters in quantum circuit simulation are integrated into tensors, and GPU hardware is used to achieve efficient execution of the quantum circuit simulation process, which solves the problem of low efficiency in the existing technology and significantly improves the calculation speed.

CN116523053BActive Publication Date: 2024-09-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202210077584.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-24
Publication Date
2024-09-10
Estimated Expiration
2042-01-24

AI Technical Summary

Technical Problem

Existing quantum circuit simulations are not efficient, especially when processing dimensions that require parallelization. Traditional multi-process or multi-thread technology is limited by hardware architecture and operating systems, resulting in low computational efficiency.

Method used

The idea of ​​vector parallelization is introduced to convert the original function into an objective function. Through the tensor integration of parallelized input parameters and the batch parallel capabilities of hardware such as GPU, the efficient execution of the quantum circuit simulation process is achieved.

Benefits of technology

Parallelizing the process that originally required multiple calculations into one calculation significantly improves the efficiency of quantum circuit simulation, especially in large-scale quantum simulations. The calculation speed is greatly improved, and the design interface is friendly and development is convenient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116523053B
    Figure CN116523053B
Patent Text Reader

Abstract

The present application discloses a quantum circuit simulation method, device, equipment, storage medium and program product, which belongs to the field of quantum technology. The method includes: obtaining the original function involved in the quantum circuit simulation, and determining the first input parameter that needs to be parallelized in the original function; wherein the original function is used to implement the target step in the quantum circuit simulation; according to the original function and the first input parameter, the original function is converted into a target function; wherein the input parameter of the target function includes the converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is the integration result of multiple parallelized tensors corresponding to the first input parameter; executing the target function to obtain the execution result corresponding to the target function; based on the execution result corresponding to the target function, executing the process of quantum circuit simulation. The present application introduces the idea of ​​vector parallelization into quantum circuit simulation, which improves the efficiency of quantum circuit simulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of quantum technology, and in particular to a quantum circuit simulation method, device, equipment, storage medium and program product. Background Art

[0002] Quantum circuit simulation refers to the simulation and approximation of the behavior of quantum computers through classical computers and numerical calculations.

[0003] Currently, the efficiency of quantum circuit simulation is not very high. Summary of the invention

[0004] The embodiments of the present application provide a quantum circuit simulation method, device, equipment, storage medium and program product. The technical solution is as follows:

[0005] According to one aspect of an embodiment of the present application, a quantum circuit simulation method is provided, the method comprising:

[0006] Acquire a primitive function involved in quantum circuit simulation, and determine a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation;

[0007] According to the original function and the first input parameter, the original function is converted into an objective function; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter;

[0008] Executing the objective function to obtain an execution result corresponding to the objective function;

[0009] Based on the execution result corresponding to the objective function, the process of quantum circuit simulation is executed.

[0010] According to one aspect of an embodiment of the present application, a quantum circuit simulation device is provided, the device comprising:

[0011] A function acquisition module, used to acquire a primitive function involved in the quantum circuit simulation, and to determine a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation;

[0012] A function conversion module, configured to convert the original function into an objective function according to the original function and the first input parameter; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and a tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter;

[0013] A function execution module, used to execute the target function and obtain an execution result corresponding to the target function;

[0014] The circuit simulation module is used to execute the quantum circuit simulation process based on the execution result corresponding to the objective function.

[0015] According to one aspect of an embodiment of the present application, a computer device is provided, comprising a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the above-mentioned quantum circuit simulation method.

[0016] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned quantum circuit simulation method.

[0017] According to one aspect of an embodiment of the present application, a computer program product or a computer program is provided, wherein the computer program product or the computer program includes computer instructions, wherein the computer instructions are stored in a computer-readable storage medium, and a processor reads and executes the computer instructions from the computer-readable storage medium to implement the above-mentioned quantum circuit simulation method.

[0018] The technical solution provided in the embodiments of the present application can bring the following beneficial effects:

[0019] By introducing the idea of ​​vector parallelization into quantum circuit simulation, and converting the original function into an objective function, the input parameter of the objective function includes the converted first input parameter corresponding to the first input parameter to be parallelized, and the tensor corresponding to the converted first input parameter is the integration result of multiple parallelized tensors corresponding to the first input parameter. By executing the objective function, the calculation process that originally needed to be executed multiple times can be parallelized into one calculation process for execution, so that it can be completed in the same time as a single calculation, which fully improves the efficiency of quantum circuit simulation. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0021] Figure 1 is a flow chart of a quantum circuit simulation method provided by an embodiment of the present application;

[0022] Figure 2 It is a functional schematic diagram of a vmap interface provided by an embodiment of the present application;

[0023] Figure 3 is a flow chart of a quantum circuit simulation method provided by another embodiment of the present application;

[0024] Figure 4 is a schematic diagram of a numerical simulation of a target quantum circuit provided by an embodiment of the present application;

[0025] Figure 5 is a schematic diagram of processing an input wave function in parallel provided by an embodiment of the present application;

[0026] Figure 6 is a schematic diagram of optimizing line variation parameters in parallel according to an embodiment of the present application;

[0027] Figure 7 is a schematic diagram of a tensor network including parameterized structural information provided by an embodiment of the present application;

[0028] Figure 8 is a schematic diagram of generating a circuit structure in parallel provided by an embodiment of the present application;

[0029] Fig. 9 is a schematic diagram of experimental results provided by an embodiment of the present application;

[0030] Fig.10 is a block diagram of a quantum circuit simulation device provided by an embodiment of the present application;

[0031] Fig.11 It is a schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0033] Before introducing the technical solution of the present application, some key terms involved in the present application are explained.

[0034] 1. Quantum computing: A computing method based on quantum logic. The basic unit of data storage is the quantum bit (qubit).

[0035] 2. Quantum bit: the basic unit of quantum computing. Traditional computers use 0 and 1 as the basic units of binary. The difference is that quantum computing can process 0 and 1 at the same time, and the system can be in a linear superposition state of 0 and 1: |ψ>=α|0>+β|1>, where α and β represent the complex probability amplitude of the system at 0 and 1. Their squared modulus |α| 2 ,|β| 2 represent the probabilities of being 0 and 1 respectively.

[0036] 3. Quantum circuit: A representation of a quantum universal computer, representing the hardware implementation of the corresponding quantum algorithm / program under the quantum gate model. If the quantum circuit contains adjustable parameters for controlling quantum gates, it is called a parameterized quantum circuit (PQC) or a variational quantum circuit (VQC), which are the same concept.

[0037] 4. Hamiltonian: A Hermitian conjugate matrix that describes the total energy of a quantum system. Hamiltonian is a physical term, an operator that describes the total energy of a system, usually represented by H.

[0038] 5. Eigenstate: For a Hamiltonian matrix H, the solution that satisfies the equation: H|ψ>=E|ψ> is called the eigenstate |ψ> of H, with eigenenergy E. The ground state corresponds to the lowest energy eigenstate of the quantum system.

[0039] 6. Quantum-classical hybrid computing: A computing paradigm that uses quantum circuits (such as PQC) to calculate the corresponding physical quantity or loss function, and uses traditional classical optimizers to adjust the variational parameters of quantum circuits. This can maximize the advantages of quantum computing and is believed to be one of the important directions with the potential to prove quantum advantage. Generally, we also call this quantum-classical hybrid computing paradigm a variational quantum algorithm.

[0040] 7. NISQ (Noisy Intermediate-Scale Quantum): The recent medium-scale noisy quantum hardware is the current stage of quantum computing development and the focus of research. At this stage, quantum computing cannot be used as a general computing engine due to the limitations of scale and noise, but on some problems, it can achieve results that surpass the most powerful classical computers, which is usually called quantum hegemony or quantum advantage.

[0041] 8. Variational Quantum Eigensolver (VQE): It estimates the ground state energy of a specific quantum system through variational circuits (i.e. PQC / VQC). It is a typical quantum-classical hybrid computing paradigm and has wide applications in the field of quantum chemistry.

[0042] 9. Pauli string: A term consisting of the direct product of multiple Pauli matrices at different lattice points. The general Hamiltonian can usually be decomposed into the sum of a set of Pauli strings. The measurement of VQE is also generally measured item by item according to the decomposition of the Pauli string. The expected value of each Pauli string can be estimated by averaging multiple measurements on the quantum circuit.

[0043] 10. Bit string (or classical bit string): a string of 0s and 1s. The classical result of each measurement of a quantum circuit can be represented by 0s and 1s, respectively, according to the spin configuration on the measurement basis, so that the total measurement result corresponds to a bit string. The measured value of each Pauli string is given by the bit string calculation.

[0044] 11. Quantum circuit software simulation: Use classical computers and numerical calculations to simulate and approximate the behavior of quantum computers. Quantum circuit software simulation is referred to as "quantum circuit simulation".

[0045] 12. Vector parallelization: Vector parallelization achieves high-speed parallelization of high-level functions by implementing hardware-supported vectorization of each operator of the original function one by one. This implementation is usually performed together with static graph compilation. For example, for the function f(x) = 2×x, we return 2 when the input is 1, that is, f(1) = 2. The vector parallelized version fv(x) can achieve fv([1,2]) = [2,4]. This process is not calculated sequentially, but can be calculated simultaneously using the vector instruction set (or vectorized instruction set) on the hardware. Therefore, the time to calculate fv([1,2]) is almost the same as f(1), which is half the time of calculating f(1) and f(2) sequentially. If the size of the vector dimension (parallel dimension / batch dimension) is further increased, the acceleration will be more obvious. In this example, f(x) is the original function, and multiplication is the only operator that appears. The vectorization support of this calculation depends on the hardware, such as the vector instruction set on the CPU (Central Processing Unit) or GPU (Graphics Processing Unit). The high-level function refers to f here. We do not need to consider the hardware details and the underlying implementation of f. We can use the interface encapsulated by the modern machine learning framework to realize its vector parallelization. The static graph compilation process is the process provided by the modern machine learning framework to compile and integrate the high-level computing API (Application Programming Interface) into the underlying hardware operations, which can accelerate numerical calculations.

[0046] 13. Pauli operator: also known as Pauli matrix, is a set of three 2×2 unitary Hermitian complex matrices (also known as unitary matrices), generally represented by the Greek letter σ (sigma). Among them, the Pauli X operator is The Pauli Y operator is The Pauli Z operator is

[0047] 14. Differentiable Architecture Search (DARTS): A popular NAS (Neural Architecture Search) solution that allows multiple operation layers between different nodes to be added according to weights, so that end-to-end differential calculations and gradient descent searches can be performed in the super network, greatly improving the speed of neural network structure search. DARTS does not search for discrete candidate structures, but makes the search space continuous, so that the network structure can be optimized according to the performance of the validation set through gradient descent. The gradient-based optimization algorithm allows DARTS to match the current top performance compared to inefficient black-box search, while reducing calculations by several orders of magnitude.

[0048] 15. Quantum Architecture Search (QAS): A general term for a series of tasks and solutions that attempt to automate and programmatically search for the structure, pattern, and arrangement of quantum circuits. Traditionally, quantum architecture search usually uses greedy algorithms, reinforcement learning, or genetic algorithms as its core technology. The newer differentiable quantum architecture search technology can iteratively evaluate the quality of quantum circuit structures in batches with high throughput.

[0049] 16. Tensor network: It is a series of tensors and the information of their connections. It can represent high-dimensional tensors with less information. At the same time, each quantum circuit can be mapped into a tensor network, so quantum circuits can be simulated by shrinking and merging tensor networks.

[0050] In the application scenario of quantum circuit simulation, for some dimensions that need to be parallelized, simple serial loop calculations are usually performed, that is, simple for loops are used to implement the corresponding multiple calculations. The parallelism of this method is 0. Therefore, if the size of the parallel dimension is 1000, it takes 1000 times the time of a single calculation to implement software simulation.

[0051] A slightly optimized solution is to use multi-process or multi-thread technology to accelerate the parallel computing part, so that different computations that require parallel dimensions are distributed on different processes and computed simultaneously. However, this solution is usually limited by the hardware architecture and operating system, and needs to be implemented separately for different hardware. The reason is that the high-level program interface implemented by multi-process and multi-threading is heavily dependent on hardware details and operating system. Therefore, when running on different software and hardware, the code needs to be rewritten, resulting in low code reusability. This will increase a lot of development and use costs. At the same time, heterogeneous hardware such as GPU and TPU (Tensor Processing Unit) are not friendly to multi-process and multi-threading. In the case of multi-process, each task is only calculated on a single process, and the vector operation set (that is, the native vector operation set support of the hardware) cannot be fully utilized, which also has a negative impact on the time of each calculation. In addition, this multi-process parallelism is limited by the number of CPU cores. A single CPU can usually only realize the simultaneous operation of several or dozens of computing modules. For the case where the parallel dimension is 1000, it still takes dozens of times or more time for a single calculation to complete.

[0052] This application proposes to introduce the idea of ​​vector parallelization into quantum circuit simulation. The vector parallelization in this application essentially regards the parallel dimension as an additional dimension of linear algebra, and directly realizes batch parallelism from the underlying operator, which can give full play to the advantages of hardware such as GPU. For example, for the case where the parallel dimension size is 1000, it generally only takes the same time as a single calculation. Therefore, the efficiency of large-scale quantum simulation is much higher than the previous solution. At the same time, the solution has a good design interface and is independent of the details of the back-end hardware and system, which is extremely convenient for use and development.

[0053] In the quantum circuit simulation method provided in the embodiment of the present application, the execution subject of each step can be a classical computer, such as a PC (Personal Computer), for example, the method is implemented by executing a corresponding computer program on a classical computer. In the following method embodiment, for ease of description, only the execution subject of each step is introduced as a computer device.

[0054] Figure 1 This is a flow chart of a quantum circuit simulation method provided by an embodiment of the present application. The execution subject of each step of the method may be a computer device, such as a classical computer. The method may include the following steps (110-140):

[0055] Step 110, obtaining a primitive function involved in the quantum circuit simulation, and determining a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation.

[0056] The process of quantum circuit simulation may involve one or more of the steps of processing input wave functions, optimizing circuit variation parameters, generating circuit noise, generating circuit structure, and performing circuit measurement. Optionally, the primitive function is used to implement the target step in quantum circuit simulation, which target step includes but is not limited to any of the following: processing input wave functions, optimizing circuit variation parameters, generating circuit noise, generating circuit structure, and performing circuit measurement. Taking the primitive function for processing input wave functions as an example, the primitive function is used to calculate the input wave function of the target quantum circuit to obtain the corresponding calculation results. Taking the primitive function for optimizing circuit variation parameters as an example, the primitive function is used to optimize the circuit variation parameters of the target quantum circuit to obtain the optimized circuit variation parameters.

[0057] The number of input parameters of the original function can be one or more. The above-mentioned first input parameter refers to the input parameter that needs to be parallelized in the original function. The number of the first input parameters can be one or more. Exemplarily, the original function f is recorded as f(x, y, w), which means that the original function f has 3 input parameters, including 3 input parameters x, y and w. Assuming that among the 3 input parameters of the original function f, the input parameter that needs to be parallelized is x, then the above-mentioned first input parameter is x, and the other two parameters y and w do not need to be parallelized. Alternatively, assuming that among the 3 input parameters of the original function f, the input parameters that need to be parallelized are x and y, then the above-mentioned first input parameter is x and y, and the other parameter w does not need to be parallelized.

[0058] For different primitive functions, their input parameters may be different, and accordingly, their first input parameters that need to be parallelized may also be different. In practical applications, after the primitive function is determined, its input parameters are also determined. We can select one or more input parameters suitable for parallel processing as the first input parameter according to the actual situation.

[0059] Step 120, converting the original function into an objective function according to the original function and the first input parameter; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter.

[0060] The input parameters of the objective function include the converted first input parameter corresponding to the first input parameter that needs to be parallelized. Optionally, if the input parameters of the original function include a target input parameter that does not need to be parallelized in addition to the first input parameter that needs to be parallelized, then the input parameters of the objective function include the converted first input parameter corresponding to the first input parameter and the above-mentioned target input parameter that does not need to be parallelized. Exemplarily, the original function f is recorded as f(x, y, w). Assuming that among the three input parameters of the original function f, x and y need to be parallelized, and w does not need to be parallelized, then the objective function f′ can be recorded as f′(xs, ys, w), where xs represents the converted x corresponding to the input parameter x, ys represents the converted y corresponding to the input parameter y, and the input parameter w does not need to be parallelized so it does not need to be converted.

[0061] Optionally, if the parallelization size (or called "batch size") corresponding to the first input parameter is n, where n is an integer greater than 1, indicating that the n tensors corresponding to the first input parameter are processed in parallel, then the tensor corresponding to the first input parameter after conversion is the integration result of the above n tensors.

[0062] Optionally, multiple parallelized tensors corresponding to the first input parameter are concatenated in the target dimension to obtain a tensor corresponding to the first input parameter after conversion; wherein the size of the tensor corresponding to the first input parameter after conversion in the target dimension corresponds to the number of parallelized tensors corresponding to the first input parameter.

[0063] For example, Figure 2 As shown, for the input parameter x that needs to be parallelized in the original function f(x,y,w), assuming that its corresponding parallelization size is n, then the n tensors corresponding to the input parameter x are spliced ​​in the target dimension, and the spliced ​​tensor is the tensor corresponding to xs. Optionally, the value of n can be 2, 10, 50, 100, 200, 500, 1000, etc., which can be set according to actual needs, and this application does not limit this.

[0064] Step 130, execute the target function to obtain the execution result corresponding to the target function.

[0065] After converting the original function into the target function, the target function is executed to obtain the corresponding execution result. Optionally, the target function is executed in a vector parallelization manner to obtain the execution result corresponding to the target function. In an embodiment of the present application, the idea of ​​vector parallelization is introduced into quantum circuit simulation. Since the input parameter of the target function includes the first input parameter after conversion, the tensor corresponding to the first input parameter after conversion can be processed in a vector parallelization manner, and the execution result corresponding to the target function can be directly calculated in one step.

[0066] Assuming that the execution time of the original function is t, for the case where the parallelization size is n, if a simple loop is used to execute the original function n times, the total time required will be n×t. After converting the original function into the target function, the time required to execute the target function using vector parallelization is theoretically t, which is greatly reduced compared to n×t, and as n increases, the reduction effect will become more significant.

[0067] Step 140, executing a quantum circuit simulation process based on the execution result corresponding to the objective function.

[0068] After obtaining the execution result corresponding to the objective function, the process of quantum circuit simulation can be executed. Taking the original function used to process the input wave function as an example, the execution result corresponding to the corresponding objective function includes the processing results corresponding to multiple input wave functions, and then the optimization of circuit variation parameters and other steps can be performed based on the processing results corresponding to the multiple input wave functions. Taking the original function used to optimize the circuit variation parameters as an example, the execution result corresponding to the corresponding objective function includes the optimization results corresponding to multiple groups of circuit variation parameters, and then the optimal group of circuit variation parameters can be selected as the final target quantum circuit based on the optimization results corresponding to the multiple groups of circuit variation parameters.

[0069] The technical solution provided by the present application introduces the idea of ​​vector parallelization into quantum circuit simulation, and converts the original function into an objective function, wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter to be parallelized, and the tensor corresponding to the converted first input parameter is the integration result of multiple parallelized tensors corresponding to the first input parameter. By executing the objective function, the calculation process that originally needs to be executed multiple times can be parallelized into a single calculation process for execution, so that it can be completed in the same time as a single calculation, thereby fully improving the efficiency of quantum circuit simulation.

[0070] Figure 3 This is a flow chart of a quantum circuit simulation method provided by another embodiment of the present application. The execution subject of each step of the method may be a computer device, such as a classical computer. The method may include the following steps (310-350):

[0071] Step 310, obtaining a primitive function involved in the quantum circuit simulation, and determining a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation.

[0072] Step 310 and Figure 1 Step 110 in the embodiment shown is the same, and can be seen in detail in Figure 1 The description in the embodiments is omitted here.

[0073] Step 320: calling the function conversion interface, and passing the original function and first information to the function conversion interface, where the first information is used to indicate a first input parameter in the original function that needs to be parallelized.

[0074] The function conversion interface is used to realize the function of converting the original function into the target function. The function conversion interface can be a user-oriented interface, such as an API (Application Programming Interface).

[0075] The first information is used to indicate the first input parameter that needs to be parallelized in the original function. Optionally, the first information is used to indicate the position of the first input parameter that needs to be parallelized in the original function. For example, the position numbers of the input parameters x, y, and w in the original function f(x, y, w) are 0, 1, and 2, respectively. Assuming that the input parameter that needs to be parallelized is x, then the first information is 0; or, assuming that the input parameters that need to be parallelized are x and y, then the first information is 0 and 1. Indicating the first input parameter that needs to be parallelized in the original function by position can achieve accurate and concise indication.

[0076] Step 330, converting the original function into the target function according to the first information through the function conversion interface; wherein the input parameter of the target function includes the converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is the integration result of multiple parallelized tensors corresponding to the first input parameter.

[0077] The function conversion interface determines the first input parameter that needs to be parallelized in the original function according to the first information, and then converts the original function into the target function based on the first input parameter. For example, for the first input parameter that needs to be parallelized in the original function, multiple parallelized tensors corresponding to the first input parameter are spliced ​​in the target dimension to obtain the tensor corresponding to the first input parameter after conversion; for the target input parameter that does not need to be parallelized in the original function, the target input parameter is directly retained as the input parameter of the target function. In this way, the input parameters of the target function include the first input parameter after conversion, and optionally also include the target input parameter. The function conversion interface supports vector parallelization function. After the above conversion of the function conversion interface, the target function can be used to output the results of parallel calculation of multiple original functions.

[0078] Optionally, in addition to supporting the vector parallelization function, the function conversion interface also supports the automatic differentiation function. The converted target function is used to output the result of parallel computing multiple times of the original function, and is also used to output the derivative information of the original function relative to the second input parameter, where the second input parameter refers to the input parameter of the original function that needs to be derived. The number of second input parameters can be one or more. In addition, the second input parameter and the first input parameter may be the same or different. For example, the input parameters of the original function f(x, y, w) are x, y, and w, and the first input parameter to be parallelized is x, and the second input parameter to be derived is also x; or, the first input parameters to be parallelized are x and y, and the second input parameter to be derived is x; or, the first input parameter to be parallelized is w, and the second input parameter to be derived is y, and so on.

[0079] Optionally, when calling the function conversion interface, the original function, the first information and the second information are passed to the function conversion interface, and the second information is used to indicate the second input parameter that needs to be differentiated in the original function. Optionally, the second information is used to indicate the position of the second input parameter that needs to be differentiated in the original function. For example, the position numbers of the input parameters x, y, and w in the original function f(x, y, w) are 0, 1, and 2 respectively. Assuming that the first input parameters that need to be parallelized are x and y, and the second input parameter that needs to be differentiated is x, then the first information is 0 and 1, and the second information is 0. Correspondingly, the original function is converted into an objective function according to the first information and the second information through the function conversion interface. The objective function is used to output the result of parallel calculation of multiple original functions, and is also used to output the derivative information of the original function relative to the second input parameter.

[0080] In some embodiments, the function conversion interface includes a first interface and a second interface; wherein the first interface is used to convert the original function into the target function according to the first information; and the second interface is used to convert the original function into the target function according to the first information and the second information. That is, the first interface is a function conversion interface that supports the vector parallelization function, or the first interface is a function conversion interface that only supports the vector parallelization function. The second interface is a function conversion interface that supports the vector parallelization function and the automatic differentiation function.

[0081] Exemplarily, the first interface is a vmap interface, and the function signature of the vmap interface is exemplarily as follows: vmap(f:Callable[...,Any],vectorized_argnums:Union[int,Sequence[int]]=0)→Callable[…,Any]. Among them, f represents the original function to be parallelized, and vectorized_argnums is used to indicate the first input parameter to be parallelized, such as used to indicate the position of the first input parameter to be parallelized. In the function signature of the above vmap interface, f:Callable[...,Any] indicates that the original function f can be any function whose input and output are both tensors; vectorized_argnums:Union[int,Sequence[int]]=0 indicates that vectorized_argnums can be a numerical value (such as 0 or 1 or 2 or 3, etc.) or a string of numerical values ​​(such as 0,1 or 0,1,2 or 1,2, etc.), and the default value of vectorized_argnums is 0. The output is defined as Callable[…,Any].

[0082] like Figure 2 As shown, it exemplarily shows a functional diagram of the vmap interface. For any primitive function f (such as any primitive function whose input and output are tensors), after function conversion by the vmap interface, another target function f′ will be output. f′=vmap(f,vectorized_argnums=(0,1)), wherein vectorized_argnums=(0,1) indicates that the position numbers of the first input parameters that need to be parallelized in the original function f are 0 and 1, that is, x and y need to be parallelized, but w does not need to be parallelized. The input format of the target function f′ (that is, the type and shape of the input parameters) is the same as that of the original function f, except that the input parameters at the position indicated by vectorized_argnums have a corresponding tensor shape with one more dimension than the corresponding input tensor of the original function f (that is, Figure 2 The vertical dimension in the original function f does not exist), let the size of this dimension be n, n is an integer greater than 1, and n can also be called the batch size. The target function f′ obtained by vmap interface conversion has the final calculation effect equivalent to calculating the original function f n times, and each time the input of the original function f is the parameter of the non-vectorized_argnums position and a low-dimensional slice of the parameter of the vectorized_argnums position. Figure 2 A tensor of the same color in is a slice, such as Figure 2The dashed box in the middle shows a slice. However, these n calls to the original function f can be fused into a unified operator at the bottom layer and calculated in parallel.

[0083] Exemplarily, the second interface is a vectorized_value_and_grad interface, which can be abbreviated as a vvag interface. The function signature of the vvag interface is exemplarily as follows: vectorized_value_and_grad(f:Callable[...,Any],argnums:Union[int,Sequence[int]]=0,vectorized_argnums:Union[int,Sequence[int]]=0)→Callable[...,Tuple[Tensor,Tensor]]. Wherein, f represents the original function to be parallelized, vectorized_argnums is used to indicate the first input parameter to be parallelized, such as the position of the first input parameter to be parallelized, and argnums is used to indicate the second input parameter to be differentiated, such as the position of the second input parameter to be differentiated. In the function signature of the above vvag interface, f:Callable[...,Any] means that the original function f can be any function whose input and output are both tensors; vectorized_argnums:Union[int,Sequence[int]]=0 means that vectorized_argnums can be a single value (such as 0 or 1 or 2 or 3, etc.) or a sequence of values ​​(such as 0,1 or 0,1,2 or 1,2, etc.), and the default value of vectorized_argnums is 0; argnums:Union[int,Sequence[int]]=0 means that argnums can be a single value (such as 0 or 1 or 2 or 3, etc.) or a sequence of values ​​(such as 0,1 or 0,1,2 or 1,2, etc.), and the default value of argnums is 0. The output is defined as Callable[...,Tuple[Tensor,Tensor]], which means that the output contains 2 tensors, one of which is the result of computing the original function f multiple times in parallel, and the other is the derivative information of the original function f relative to the input parameters at the position indicated by argnums.

[0084] For any primitive function f (such as any primitive function whose input and output are tensors), after function conversion through the vvag interface, another target function f′ will be output. The input parameter of the target function f′ at the position indicated by vectorized_argnums has one more dimension in shape than the corresponding input tensor of the primitive function f, which is the same as the function of the vmap interface. At the same time, the return of the target function f′ converted through the vvag interface, in addition to returning the result of parallel calculation of the primitive function f multiple times, also returns the derivative information of the input parameter of the primitive function f relative to the position indicated by argnums.

[0085] Exemplarily, the mathematical expression corresponding to the vvag interface is as follows, the original function is f, and the target function obtained by converting the original function f through the vvag interface is f′:

[0086] f′=vvag(f,argnums=k,vectorized_argnums=p)

[0087] f′(arg[0],…,arg[p],…,arg[k],…)=(v,g)

[0088] vi=f(arg[0],…,arg[p][i],…,arg[k],…)

[0089]

[0090]

[0091] Among them, argnums=k means that among the input parameters of the original function f, the input parameter with position number k is the input parameter that needs to be differentiated. vectorized_argnums=p means that among the input parameters of the original function f, the input parameter with position number p is the input parameter that needs to be parallelized. arg[0],…,arg[p],…,arg[k],… represent the input parameters of the objective function f′, and its output is two tensors v and g, where v represents the result of parallel calculation of the original function f multiple times, and g represents the derivative information of the original function f relative to the input parameter at the position indicated by argnums. arg[p][i] represents the i-th slice in the tensor corresponding to the input parameter with position number p after conversion. If the parallelization size is n, the value of i is an integer in the interval [0,n-1]. When p≠k, When p = k,

[0092] It should be noted that in the above embodiment, only the first interface is a vmap interface and the second interface is a vvag interface as an example to introduce and illustrate the above two interfaces with different functions provided by the present application. The present embodiment does not limit the names of the above two interfaces, which can be set by the developer.

[0093] Optionally, the function conversion interface is an API encapsulated on a machine learning library, which provides a vector instruction set for executing the target function. For example, the underlying machine learning library may be a machine learning library such as tensorflow, jax, etc., which provides a vector instruction set for executing the target function. The function conversion interface is encapsulated on the machine learning library, thereby ensuring that the implementation of vector parallelization is independent of the underlying framework, and the function of vector parallelization can be implemented by simply calling the function conversion interface.

[0094] Step 340 , using a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion, to obtain an execution result corresponding to the objective function.

[0095] After converting the original function into the target function through the function conversion interface, the vector instruction set provided by the underlying machine learning library can be further called, and the vector instruction set can be executed on hardware such as CPU, GPU or TPU to perform vector parallel processing of the tensor corresponding to the first input parameter after conversion, and obtain the execution result corresponding to the target function. The above-mentioned vector instruction set provides executable instructions that can be executed by processors such as CPU, GPU or TPU. These executable instructions can implement the functions of underlying operators such as addition and multiplication. In this embodiment, vector parallel processing is implemented by executing the vector instruction set on processors such as CPU, GPU or TPU. Compared with executing multiple processes or multiple threads on the operating system, it can overcome the bottleneck of the number of parallel operations and fully improve the parallelization size.

[0096] Step 350, executing the quantum circuit simulation process based on the execution result corresponding to the objective function.

[0097] After obtaining the execution result corresponding to the objective function, the quantum circuit simulation process can be performed. Step 350 and Figure 1 Step 140 in the embodiment shown is the same, and can be seen in detail in Figure 1 The description in the embodiments is omitted here.

[0098] The technical solution provided by the present application, by calling a function conversion interface, passing an original function and first information indicating a first input parameter in the original function that needs to be parallelized into the function conversion interface, thereby being able to convert the original function into a target function through the function conversion interface, and realizing vector parallel processing, so as to improve the computational efficiency of the original function, and further improve the efficiency of quantum circuit simulation.

[0099] In addition, in some embodiments, the function conversion interface supports not only vector parallelization but also automatic differentiation, so that the converted target function can output not only the result of calculating the original function in parallel multiple times, but also the derivative information of the original function with respect to the second input parameter. This is particularly suitable for the scenario of variational quantum algorithms, thereby facilitating the development and research of variational quantum algorithms.

[0100] Below, the application scenarios of vector parallelization in quantum circuit simulation are introduced and explained. In the embodiments of the present application, vector parallelization can be applied to the steps of processing input wave functions, optimizing circuit variation parameters, generating circuit noise, generating circuit structure, and performing circuit measurement in quantum circuit simulation. The following will introduce and explain these application scenarios through several embodiments.

[0101] Figure 4 The schematic diagram of the numerical simulation of a target quantum circuit is shown as an example. The target quantum circuit can realize the numerical simulation of the variational quantum algorithm. By adopting the technical solution provided by the present application, all the main components of the simulation can cleverly support vector parallelization, thereby significantly accelerating quantum simulation in different application scenarios. Figure 4 As shown in the figure, we need to simulate the calculation process, that is, input a specified quantum state (which can be in the form of a matrix product state or a vector), and then measure the output state on different bases in the form of a given Pauli string through a quantum circuit containing parameters and possibly noise, so as to obtain the optimization function value and the gradient with respect to the weight for optimization iteration.

[0102] exist Figure 4 In the example, the input quantum state of the target quantum circuit is represented by |ψ0>, and the circuit parameter of the target quantum circuit is represented by U θ The measurement results are expressed as Optimizing functions in represents the i-th measurement result, i is an integer, Indicates U θ The conjugate transpose of .

[0103] 1. Parallel processing of input wave functions

[0104] In this example, the primitive function is used to implement a target step in a quantum circuit simulation, the target step comprising processing an input wave function, and the first input parameter comprises the input wave function of the target quantum circuit.

[0105] Optionally, a tensor corresponding to the first input parameter after conversion is obtained, and the tensor corresponding to the first input parameter after conversion is an integration result of multiple input wave functions of the target quantum circuit; a vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the target function; wherein the execution result corresponding to the target function includes processing results corresponding to multiple input wave functions respectively.

[0106] Taking variational quantum circuit simulation as an example, variational quantum circuit simulation consists of three parts: input wave function, circuit unitary matrix and circuit measurement. In many tasks, the input wave function of the circuit is a direct product state of all zeros, and there is no need to specify the input wave function. However, in some tasks, the same circuit structure may be required to accept different input wave functions for processing and output. In this case, it is very suitable to simulate the input wave function parameter by vector parallelization.

[0107] For example, in quantum machine learning tasks, we need to batch process the input data set, and each time we need to calculate the results of a batch of input data at the same time. This batch of input data is encoded into the wave function and enters the quantum machine learning model in the form of input wave functions. Therefore, parallel processing of input wave functions can easily process batch inputs of quantum machine learning and achieve acceleration under large batch sizes. Numerical experiments show that on the GPU, the calculation time required for batch size = 512 and batch size = 1 is almost the same. This is due to the optimization of the underlying architecture of vector parallelization, which is equivalent to directly accelerating the simulation by batch size times.

[0108] Figure 5 A schematic diagram of processing input wave functions in parallel is shown as an example. Taking the vvag interface introduced above as an example, the objective function f′=vvag(f, vectorized_argnums=0, argnums=1), where f is the original function, vectorized_argnums=0 indicates that the input parameter to be parallelized is the input wave function of the target quantum circuit, and argnums=1 indicates that the input parameter to be derived is the weight of the target quantum circuit. The input parameters of the objective function f′ include the weight 51 of the target quantum circuit, and the integrated result 52 of multiple input wave functions of the target quantum circuit. The objective function f′ is executed in a vector parallel manner to obtain the processing results 53 corresponding to the multiple input wave functions, and the derivative information 54 of the weight.

[0109] In this example, by processing the input wave function in parallel, the batch processing efficiency of the input wave function in the quantum circuit simulation process is fully improved.

[0110] 2. Parallel optimization of line variation parameters

[0111] In this example, the primitive function is used to implement a target step in a quantum circuit simulation, the target step including optimizing a circuit variation parameter, and the first input parameter includes the circuit variation parameter of the target quantum circuit.

[0112] Optionally, a tensor corresponding to the first input parameter after conversion is obtained, and the tensor corresponding to the first input parameter after conversion is an integration result of multiple groups of circuit variation parameters of the target quantum circuit; a vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes optimization results corresponding to multiple groups of circuit variation parameters respectively.

[0113] For variational quantum optimization problems, the parameters of gradient descent often stay at local minima. This requires us to start from different initial parameters, perform multiple independent optimizations on the same problem, and select a set of corresponding parameters that make the optimization function optimal. These multiple independent optimization attempts will increase the time consumption by times the number of optimizations under a simple loop solution. At this point, we can vectorize and parallelize the variables corresponding to the line variation parameters.

[0114] The embodiment of the present application proposes to use parallel acceleration for multiple independent optimizations. In particular, for algorithms such as VQE, which are easily stuck in local minima, we perform parallel multi-path optimizations at the same time to select the most appropriate convergence parameters in the end. In this way, the time for multiple optimizations is almost exactly the same as the time for a single optimization. We call this optimization scheme batched VQE optimization. That is, it can be achieved from the underlying operator to run multiple independent optimizations in parallel.

[0115] Figure 6A schematic diagram of optimizing circuit variation parameters in parallel is shown as an example. Taking the vvag interface introduced above as an example, the objective function f′=vvag(f, vectorized_argnums=0, argnums=0), where f is the original function, vectorized_argnums=0 indicates that the input parameter to be parallelized is the circuit variation parameter (such as weight) of the target quantum circuit, and argnums=0 indicates that the input parameter to be derived is also the circuit variation parameter (such as weight) of the target quantum circuit. The input parameters of the objective function f′ include the integrated results 61 of multiple groups of circuit variation parameters of the target quantum circuit. The objective function f′ is executed in a vector parallel manner to obtain the optimization results 62 corresponding to the multiple groups of circuit variation parameters, as well as the derivative information 63 of the circuit variation parameters.

[0116] In this example, the optimization efficiency of the circuit variational parameters in the quantum circuit simulation process is fully improved by optimizing the circuit variational parameters in parallel.

[0117] 3. Generate line noise in parallel

[0118] In this example, the primitive function is used to implement a target step in a quantum circuit simulation, the target step including generating circuit noise, and the first input parameter includes a random number used to generate the circuit noise of the target quantum circuit.

[0119] Optionally, a tensor corresponding to the first input parameter after conversion is obtained, and the tensor corresponding to the first input parameter after conversion is an integration result of multiple groups of random numbers used to generate line noise of a target quantum circuit; a vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes noise simulation results corresponding to the multiple groups of random numbers.

[0120] In the scenario of the Monte Carlo trajectory simulator, different random numbers are used to simulate the behavior of different probability distributions of noise. Since the Monte Carlo trajectory simulator evaluates the observed quantity, a large number of observed quantity results with different random number configurations need to be averaged. Naturally, we can vectorize the random number parameter to parallelize it, so as to simulate dozens or even hundreds of random configurations at the same time. Therefore, the present application scheme can be used to accelerate the Monte Carlo simulation of quantum noise, parallelize different random number inputs, and thus vectorize the Monte Carlo simulation of parallel noise. Here, the random number as a parallel dimension behaves similarly to the input wave function as a parallel dimension, and the schematic diagram is no longer shown separately.

[0121] In this example, the efficiency of generating line noise during quantum circuit simulation is greatly improved by generating line noise in parallel.

[0122] In the above three cases, there is no need to do any special processing on the implemented functions. You can directly call the vmap or vvag interface and specify the position of the input parameters that need to be parallelized. As the vectorized_argnums parameter in the API, it can be converted into an efficient simulation that supports vector parallelization.

[0123] In the following two cases, it is necessary to realize the effect of parameterized summation of some tensors based on the circuit simulator based on the tensor network, so that when the input parameters are different, the corresponding reduced tensor network structure is different. This idea of ​​parameterizing the summation of local tensors and keeping the same local tensor shape to embed the overall tensor network to realize the parameterized control of the simulation of different tensor network structures (or quantum circuit structures), such as Figure 7 shown. Figure 7 shows a fragment of a tensor network containing parameterized structural information, where This is the structural parameter. Different one-hot vectors are used as When , we can realize that the local part of the tensor network we are concerned about is the CNOT (controlled NOT) gate Or single bit revolving door direct product For parameterized structural simulations of more sub-blocks, we only need to introduce an independent The parameterization of the measurement is similar. We only need to select the local tensor at the measurement position as Then, where λ i represents a set of four-dimensional vectors corresponding to the i-th quantum bit, σ0=I (I operator is ), σ1, σ2, and σ3 correspond to the Pauli matrices X, Y, and Z. Then at this time, we pass in a set of parameter tensors of shape [qubit,4] to directly control the Pauli string corresponding to the final measurement. All calculation processes and calculation graphs created by just-in-time compilation are exactly the same and can be reused. For example, the measurement parameters [[1,0,0,0], [0,1,0,0], [0,0,0,1]] indicate that the expected Pauli string to be measured is I0X1Z2, which is simplified to X1Z2. More importantly, the above scheme does not change the overall static structure of the tensor network, so it can still perfectly support just-in-time compilation and early optimization search of tensor contraction paths.

[0124] 4. Generate circuit structure in parallel

[0125] In this example, the primitive function is used to implement a target step in a quantum circuit simulation, which target step includes generating a circuit structure. The first input parameter includes a control parameter for generating the circuit structure of the target quantum circuit, and different control parameters are used to generate different circuit structures.

[0126] Optionally, a tensor corresponding to the first input parameter after conversion is obtained, and the tensor corresponding to the first input parameter after conversion is an integration result of multiple groups of control parameters used to generate a circuit structure of a target quantum circuit; a vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes circuit structure generation results corresponding to the multiple groups of control parameters respectively.

[0127] In order to achieve parallelization of different circuit structures, it is necessary to make full use of the characteristics of the underlying simulator as a simulator based on tensor networks. For the circuit parts that can take different structures, the parameterized summation of tensors representing different structures is performed, that is, these parameters can control the circuit structure while still meeting the constraints of just-in-time compilation. This is because even if the circuit structure changes, the super network represented by the most generalized parameterized summation has already summarized all possibilities with a fixed tensor shape, so just-in-time compilation can still be implemented normally.

[0128] Differentiable quantum structure search inspired by DARTS includes the task of evaluating the target optimization function corresponding to a large number of different circuit structures in a batch, which perfectly fits the scenario of parallelized circuit structure. Therefore, quantum software with vector parallelization will significantly improve the efficiency of differentiable quantum structure search, that is, variational circuit automation design. This is a parallel paradigm that is unique to tensor simulators and difficult to achieve with state simulators.

[0129] Figure 8 A schematic diagram of generating a circuit structure in parallel is shown as an example. Taking the vvag interface introduced above as an example, the objective function f′=vvag(f, vectorized_argnums=0, argnums=1), where f is the original function, vectorized_argnums=0 indicates that the input parameter to be parallelized is the control parameter of the circuit structure of the target quantum circuit, and argnums=1 indicates that the input parameter to be derived is the weight of the target quantum circuit. The input parameters of the objective function f′ include the weight 81 of the target quantum circuit, and the integrated results 82 of multiple groups of control parameters of the circuit structure of the target quantum circuit. The objective function f′ is executed in a vector parallel manner to obtain circuit structure generation results corresponding to multiple groups of control parameters. Based on the multiple groups of circuit structure generation results, we can obtain multiple groups of measurement results 83 and derivative information 84 of the measurement results relative to the weight.

[0130] In this example, by generating the circuit structure in parallel, the generation efficiency of the circuit structure in the quantum circuit simulation process is fully improved.

[0131] 5. Perform line measurements in parallel

[0132] In this example, the primitive function is used to implement a target step in a quantum circuit simulation, which includes performing circuit measurement. The first input parameter includes a measurement parameter for performing circuit measurement on a target quantum circuit. Different measurement parameters are used to generate different measurement results.

[0133] Optionally, a tensor corresponding to the first input parameter after conversion is obtained, where the tensor corresponding to the first input parameter after conversion is an integrated result of multiple groups of measurement parameters used to perform circuit measurement on a target quantum circuit; a vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes measurement results corresponding to the multiple groups of measurement parameters respectively.

[0134] For small-sized systems, numerical simulation can completely preserve the wave function information of the final state output of the quantum circuit. At this time, there are many different schemes for numerical simulation of the measurement results. Including reusing the wave function information and finding the expectations of different Pauli string operators on the wave function, and when the smaller system can fully represent the matrix form of the Hamiltonian operator in memory, we can also directly merge the sum of the Pauli strings into an independent Hamiltonian matrix to calculate the expectation, which is often more efficient.

[0135] However, for large-scale systems that can only be supported by tensor network simulators, the final state wave function cannot be reused for the expectation of different Pauli strings (there is not enough space to store in the memory). And when the tensor network is shrunk in sequence to solve the expectations of different operators, it is necessary to re-find the shrunk path and perform real-time compilation, which wastes a lot of time. Therefore, the parameterized line measurement summation can be implemented in accordance with the scheme of parameterized line structure summation, so that the Pauli string of the corresponding measurement operator can be controlled by the one-hot vector of the input parameter. At this time, we only need one real-time compilation to support the expectation solution of all different Pauli strings. Combined with the vector parallelization of the structural parameters in the measurement, we can realize the efficient calculation of the expectations of multiple Pauli strings at the same time, and there is no need to re-compile (real-time) for each different measurement operator.

[0136] In this example, vector parallelization of parameterized circuit measurements enables efficient large-system circuit simulations in situations where the full wave function cannot be stored in memory and thus cannot be fully reused to evaluate different Pauli strings.

[0137] The application scenarios of the technical solution of this application and the corresponding acceleration effects have been described above. Generally speaking, on hardware such as GPU, vector parallelization can basically achieve an acceleration consistent with the size of the parallel batch dimension. In common scenarios, this can achieve efficiency improvements ranging from dozens to hundreds of times compared to simple loop calculations, and the additional development costs required are negligible and user-friendly. Below we use some simple quantitative results to emphasize the importance of this efficiency improvement.

[0138] 1. Acceleration of quantum machine learning tasks.

[0139] As mentioned above, in machine learning tasks, we often need to batch process the input data. Therefore, vectorizing the input wave function parameters can significantly improve the computational efficiency of quantum machine learning. Different mainstream quantum software simulates the same parameterized circuit to solve the MNIST discrimination problem. The time consumed by a single step varies with the batch size. Fig. 9 As shown. Among them, line 91 shows the change of the execution time of the vector parallelization solution proposed in this application on the GPU with the batch size, line 92 shows the change of the execution time of the vector parallelization solution proposed in this application on the CPU with the batch size, line 93 shows the change of the execution time of the pennylane solution with the batch size, and line 94 shows the change of the execution time of the tensorflow-quantum solution with the batch size. It can be seen that the vector parallelization technology proposed in this application can achieve more than 100 times acceleration of the calculation on the GPU compared with other mainstream software when the batch size is large.

[0140] 2. Measurement parallelization enables efficient simulation of extremely large quantum systems.

[0141] By using vector parallelization technology to reuse different Pauli string measurement calculation graphs when wave functions cannot be reused, we can simulate quantum chemical ground state simulation VQE problems with more than 100 bits on a single V100. It is the first time in the world to demonstrate and simulate the entire process of the variational quantum algorithm in such a large system. The corresponding simulation convergence results of the one-dimensional transverse field Ising model phase transition point and the one-dimensional isotropic Heisenberg model at 100 grid points are shown in Table 1. For large-scale problems such as 100-grid VQE, the time required for a single optimization iteration is only on the order of seconds, and this simulation task is simply impossible for mainstream quantum state-based simulators due to memory exponential divergence.

[0142] Table 1

[0143]

[0144] The solution described in this application is based on the self-developed TensorCircuit quantum simulation framework. TensorCircuit is a new generation of quantum computing simulation software based on a modern machine learning framework that supports multiple hardware platforms and multiple software backends, while supporting automatic differentiation, just-in-time compilation, vector parallelization, and heterogeneous hardware acceleration. It is particularly suitable for the design, research, and development of algorithms in the NISQ era, and perfectly supports the simulation of quantum-classical hybrid computing paradigms. It is written entirely in pure Python, with tensor networks as the core engine in the algorithm. While maintaining user-friendliness, it has an operating efficiency that exceeds that of optimized C++ code. The solution demonstrated in this application has been fully implemented in the TensorCircuit framework, can be used directly, and has achieved efficiency far beyond similar software.

[0145] The solution and TensorCircuit platform of this application can significantly accelerate and enhance the verification and development of quantum hardware and the design and testing of quantum software and algorithms in the NISQ era. This solution lays the foundation for demonstrating effective quantum advantages on NISQ hardware and verifying related issues of large-scale variational quantum computing, accelerating the possibility of landing quantum computers and quantum-inspired commercial applications.

[0146] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0147] Fig.10 1000 is a block diagram of a quantum circuit simulation device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned quantum circuit simulation method, and the function can be implemented by hardware or by hardware executing corresponding software. The device can be a computer device or can be set in a computer device. The device 1000 may include: a function acquisition module 1010, a function conversion module 1020, a function execution module 1030 and a circuit simulation module 1040.

[0148] The function acquisition module 1010 is used to acquire the primitive function involved in the quantum circuit simulation and determine the first input parameter that needs to be parallelized in the primitive function; wherein the primitive function is used to implement the target step in the quantum circuit simulation.

[0149] The function conversion module 1020 is used to convert the original function into an objective function based on the original function and the first input parameter; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter.

[0150] The function execution module 1030 is used to execute the target function and obtain the execution result corresponding to the target function.

[0151] The circuit simulation module 1040 is used to execute the quantum circuit simulation process based on the execution result corresponding to the objective function.

[0152] In an exemplary embodiment, the function execution module 1030 is used to execute the target function in a vector parallel manner to obtain an execution result corresponding to the target function.

[0153] In an exemplary embodiment, the function execution module 1030 is used to use a vector instruction set to perform vector parallel processing on the tensor corresponding to the converted first input parameter to obtain an execution result corresponding to the objective function.

[0154] Optionally, the target step includes processing an input wave function, and the first input parameter includes an input wave function of a target quantum circuit. The function execution module 1030 is used to obtain a tensor corresponding to the first input parameter after conversion, and the tensor corresponding to the first input parameter after conversion is an integration result of multiple input wave functions of the target quantum circuit; the vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain an execution result corresponding to the target function; wherein the execution result corresponding to the target function includes processing results corresponding to the multiple input wave functions respectively.

[0155] Optionally, the target step includes optimizing circuit variation parameters, and the first input parameter includes the circuit variation parameters of the target quantum circuit. The function execution module 1030 is used to obtain the tensor corresponding to the first input parameter after the conversion, and the tensor corresponding to the first input parameter after the conversion is the integration result of multiple groups of circuit variation parameters of the target quantum circuit; the vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain the execution result corresponding to the target function; wherein the execution result corresponding to the target function includes the optimization results corresponding to the multiple groups of circuit variation parameters respectively.

[0156] Optionally, the target step includes generating line noise, and the first input parameter includes a random number used to generate the line noise of the target quantum circuit. The function execution module 1030 is used to obtain the tensor corresponding to the first input parameter after the conversion, and the tensor corresponding to the first input parameter after the conversion is the integration result of multiple groups of random numbers used to generate the line noise of the target quantum circuit; the vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain the execution result corresponding to the target function; wherein the execution result corresponding to the target function includes the noise simulation results corresponding to the multiple groups of random numbers.

[0157] Optionally, the target step includes generating a circuit structure, and the first input parameter includes a control parameter for generating a circuit structure of a target quantum circuit, and different control parameters are used to generate different circuit structures. The function execution module 1030 is used to obtain a tensor corresponding to the first input parameter after conversion, and the tensor corresponding to the first input parameter after conversion is an integrated result of multiple groups of control parameters used to generate the circuit structure of the target quantum circuit; the vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after conversion to obtain the execution result corresponding to the target function; wherein the execution result corresponding to the target function includes the circuit structure generation results corresponding to the multiple groups of control parameters.

[0158] Optionally, the target step includes performing circuit measurement, the first input parameter includes a measurement parameter for performing circuit measurement for the target quantum circuit, and different measurement parameters are used to generate different measurement results. The function execution module 1030 is used to obtain a tensor corresponding to the first input parameter after conversion, and the tensor corresponding to the first input parameter after conversion is an integrated result of multiple groups of measurement parameters for performing circuit measurement for the target quantum circuit; the vector instruction set is used to perform vector parallel processing of the tensor corresponding to the first input parameter after conversion to obtain the execution result corresponding to the target function; wherein the execution result corresponding to the target function includes the measurement results corresponding to the multiple groups of measurement parameters.

[0159] In an exemplary embodiment, the function conversion module 1020 is used to call a function conversion interface, pass the original function and first information to the function conversion interface, and the first information is used to indicate the first input parameter that needs to be parallelized in the original function; and convert the original function into the target function according to the first information through the function conversion interface.

[0160] Optionally, the function conversion module 1020 is also used to pass second information to the function conversion interface, where the second information is used to indicate a second input parameter in the original function that needs to be differentiated; through the function conversion interface, the original function is converted into the target function based on the first information and the second information, and the target function is also used to output the derivative information of the original function with respect to the second input parameter.

[0161] Optionally, the function conversion interface includes a first interface and a second interface; wherein the first interface is used to convert the original function into the target function according to the first information; and the second interface is used to convert the original function into the target function according to the first information and the second information.

[0162] Optionally, the function conversion interface is an API encapsulated on a machine learning library, and the machine learning library provides a vector instruction set for executing the target function.

[0163] In an exemplary embodiment, multiple parallelized tensors corresponding to the first input parameter are concatenated in a target dimension to obtain a tensor corresponding to the first input parameter after conversion; wherein the size of the tensor corresponding to the first input parameter after conversion in the target dimension corresponds to the number of parallelized tensors corresponding to the first input parameter.

[0164] The technical solution provided by the present application introduces the idea of ​​vector parallelization into quantum circuit simulation, and converts the original function into an objective function, wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter to be parallelized, and the tensor corresponding to the converted first input parameter is the integration result of multiple parallelized tensors corresponding to the first input parameter. By executing the objective function, the calculation process that originally needs to be executed multiple times can be parallelized into a single calculation process for execution, so that it can be completed in the same time as a single calculation, thereby fully improving the efficiency of quantum circuit simulation.

[0165] It should be noted that the device provided in the above embodiment, when implementing its functions, only uses the division of the above functional modules as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device provided in the above embodiment belongs to the same concept as the method embodiment, and its specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0166] Please refer to Fig.11, which shows a schematic diagram of the structure of a computer device provided in one embodiment of the present application. The computer device may be a classical computer. The computer device may be used to implement the quantum circuit simulation method provided in the above embodiment. Specifically:

[0167] The computer device 1100 includes a central processing unit (such as a CPU (Central Processing Unit), a GPU (Graphics Processing Unit) and an FPGA (Field Programmable Gate Array)) 1101, a system memory 1104 including a RAM (Random-Access Memory) 1102 and a ROM (Read-Only Memory) 1103, and a system bus 1105 connecting the system memory 1104 and the central processing unit 1101. The computer device 1100 also includes a basic input / output system (Input Output System, I / O system) 1106 for helping various devices in the server to transmit information, and a large-capacity storage device 1107 for storing an operating system 1113, application programs 1114 and other program modules 1115.

[0168] Optionally, the basic input / output system 1106 includes a display 1108 for displaying information and an input device 1109 such as a mouse and a keyboard for user inputting information. The display 1108 and the input device 1109 are connected to the central processing unit 1101 via an input / output controller 1110 connected to the system bus 1105. The basic input / output system 1106 may also include an input / output controller 1110 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1110 also provides output to a display screen, a printer, or other types of output devices.

[0169] Optionally, the mass storage device 1107 is connected to the central processing unit 1101 via a mass storage controller (not shown) connected to the system bus 1105. The mass storage device 1107 and its associated computer readable medium provide non-volatile storage for the computer device 1100. That is, the mass storage device 1107 may include a computer readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0170] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technology, CD-ROM, DVD (Digital Video Disc) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 1104 and mass storage device 1107 can be collectively referred to as memory.

[0171] According to the embodiment of the present application, the computer device 1100 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 1100 can be connected to the network 1112 through the network interface unit 1111 connected to the system bus 1105, or the network interface unit 1116 can be used to connect to other types of networks or remote computer systems (not shown).

[0172] The memory also includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above-mentioned quantum circuit simulation method.

[0173] In an exemplary embodiment, a computer device is also provided, wherein the computer device is used to implement the above-mentioned quantum circuit simulation method. Optionally, the computer device is a classical computer.

[0174] In an exemplary embodiment, a computer-readable storage medium is also provided, in which a computer program is stored. When the computer program is executed by a processor of a computer device, the quantum circuit simulation method described above is implemented.

[0175] Optionally, the computer readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives) or optical disks, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0176] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned quantum circuit simulation method.

[0177] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.

[0178] The above are merely exemplary embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A quantum circuit simulation method, characterized in that: The method comprises: Acquire a primitive function involved in quantum circuit simulation, and determine a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation; Calling a function conversion interface, and passing the original function and first information to the function conversion interface, where the first information is used to indicate the first input parameter in the original function that needs to be parallelized; The original function is converted into an objective function according to the first information through the function conversion interface; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter; Executing the objective function to obtain an execution result corresponding to the objective function; Based on the execution result corresponding to the objective function, the process of quantum circuit simulation is executed.

2. The method according to claim 1, characterized in that The executing the objective function to obtain an execution result corresponding to the objective function includes: The objective function is executed in a vector parallel manner to obtain an execution result corresponding to the objective function.

3. The method according to claim 2, characterized in that The step of executing the objective function in a vector parallel manner to obtain an execution result corresponding to the objective function includes: A vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function.

4. The method according to claim 3, characterized in that The target step includes processing an input wave function, wherein the first input parameter includes an input wave function of a target quantum circuit; The using of a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function includes: Acquire a tensor corresponding to the first input parameter after the conversion, wherein the tensor corresponding to the first input parameter after the conversion is an integration result of multiple input wave functions of the target quantum circuit; The vector instruction set is used to perform vector parallel processing of the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes the processing results corresponding to the multiple input wave functions respectively.

5. The method according to claim 3, characterized in that: The target step includes optimizing circuit variation parameters, and the first input parameter includes the circuit variation parameters of the target quantum circuit; The using of a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function includes: Acquire a tensor corresponding to the first input parameter after the conversion, wherein the tensor corresponding to the first input parameter after the conversion is an integration result of multiple groups of circuit variational parameters of the target quantum circuit; The vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion, so as to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes optimization results corresponding to the multiple groups of line variation parameters respectively.

6. The method according to claim 3, characterized in that: The target step includes generating line noise, and the first input parameter includes a random number used to generate line noise of the target quantum circuit; The using of a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function includes: Acquire a tensor corresponding to the first input parameter after the conversion, wherein the tensor corresponding to the first input parameter after the conversion is an integration result of multiple groups of random numbers used to generate line noise of the target quantum circuit; The vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion, so as to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes noise simulation results corresponding to the multiple groups of random numbers respectively.

7. The method according to claim 3, characterized in that The target step includes generating a circuit structure, the first input parameter includes a control parameter for generating the circuit structure of the target quantum circuit, and different control parameters are used to generate different circuit structures; The using of a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function includes: Acquire a tensor corresponding to the first input parameter after the conversion, wherein the tensor corresponding to the first input parameter after the conversion is an integration result of multiple groups of control parameters used to generate a circuit structure of the target quantum circuit; The vector instruction set is used to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes the circuit structure generation results corresponding to the multiple groups of control parameters respectively.

8. The method according to claim 3, characterized in that The target step includes performing circuit measurement, the first input parameter includes a measurement parameter for performing circuit measurement on a target quantum circuit, and different measurement parameters are used to generate different measurement results; The using of a vector instruction set to perform vector parallel processing on the tensor corresponding to the first input parameter after the conversion to obtain an execution result corresponding to the objective function includes: Acquire a tensor corresponding to the first input parameter after the conversion, where the tensor corresponding to the first input parameter after the conversion is an integrated result of multiple groups of measurement parameters used to perform circuit measurement on the target quantum circuit; The vector instruction set is used to perform vector parallel processing on the tensor corresponding to the converted first input parameter to obtain an execution result corresponding to the objective function; wherein the execution result corresponding to the objective function includes measurement results corresponding to the multiple groups of measurement parameters respectively.

9. The method according to claim 1, characterized in that: The method further comprises: Passing second information to the function conversion interface, where the second information is used to indicate a second input parameter in the original function that needs to be derived; The converting the original function into the target function according to the first information through the function conversion interface includes: The original function is converted into the target function according to the first information and the second information through the function conversion interface, and the target function is also used to output the derivative information of the original function with respect to the second input parameter.

10. The method according to claim 9, characterized in that The function conversion interface includes a first interface and a second interface; wherein, The first interface is used to convert the original function into the target function according to the first information; The second interface is used to convert the original function into the target function according to the first information and the second information.

11. The method according to claim 1, characterized in that: The function conversion interface is an application programming interface API encapsulated on a machine learning library, and the machine learning library provides a vector instruction set for executing the target function.

12. The method according to any one of claims 1 to 11, characterized in that: The multiple parallelized tensors corresponding to the first input parameter are concatenated in the target dimension to obtain the tensor corresponding to the first input parameter after conversion; wherein the size of the tensor corresponding to the first input parameter after conversion in the target dimension corresponds to the number of parallelized tensors corresponding to the first input parameter.

13. A quantum circuit simulation device, characterized in that: The device comprises: A function acquisition module, used to acquire a primitive function involved in the quantum circuit simulation, and to determine a first input parameter in the primitive function that needs to be parallelized; wherein the primitive function is used to implement a target step in the quantum circuit simulation; A function conversion module, used for calling a function conversion interface, and passing the original function and first information to the function conversion interface, wherein the first information is used for indicating the first input parameter in the original function that needs to be parallelized; The function conversion module is further used to convert the original function into an objective function according to the first information through the function conversion interface; wherein the input parameter of the objective function includes a converted first input parameter corresponding to the first input parameter, and the tensor corresponding to the converted first input parameter is an integration result of multiple parallelized tensors corresponding to the first input parameter; A function execution module, used to execute the target function and obtain an execution result corresponding to the target function; The circuit simulation module is used to execute the quantum circuit simulation process based on the execution result corresponding to the objective function.

14. A computer device, characterized in that: The computer device comprises a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the method according to any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, which is loaded and executed by a processor to implement the method according to any one of claims 1 to 12.

16. A computer program product, characterized in that The computer program product comprises computer instructions, which are stored in a computer-readable storage medium. A processor reads and executes the computer instructions from the computer-readable storage medium to implement the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Model processing method and device, equipment, storage medium and product

    CN112561069A

  • Control pulse generation method, device, system and equipment and storage medium

    CN112819170A

  • Decision variable determination method and device, electronic equipment and medium

    CN113705793A

  • Quantum processor based systems and methods that minimize a continuous variable objective function

    US20140344322A1

  • Increasing representation accuracy of quantum simulations without additional quantum resources

    US20220019931A1