Data Synchronization Method of Quantum Circuit in Cluster Environment and Quantum Simulation System

By setting the initial process and non-initial process in the cluster environment of the quantum simulator, synchronous transmission and processing of quantum operation data is solved, and the problem of data transmission and synchronous execution of quantum circuits in the cluster environment is ensured.

CN115392471BActive Publication Date: 2025-05-27QUDOOR TECH INC +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211003989.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-22
Publication Date
2025-05-27
Estimated Expiration
2042-08-22

AI Technical Summary

Technical Problem

The prior art has failed to effectively solve the problem of data transmission and synchronous execution of quantum lines in cluster environments, making it difficult for quantum simulators to achieve synchronous operation in cluster environments.

Method used

By setting one node process in the cluster environment as the initial process and the other node processes as non-initial processes, establishing the connection between the initial process and the quantum front-end programming framework, as well as the connection between all non-initial processes and the initial process, the synchronous transmission and processing of quantum operation data is realized.

Benefits of technology

Ensure that all node processes can obtain the same quantum operation data, and ensure that all processes in the cluster perform quantum operation data simultaneously through synchronous operations, solving the problem of data transmission and synchronous execution of quantum line data at different nodes on the cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115392471B_ABST
    Figure CN115392471B_ABST
Patent Text Reader

Abstract

The present invention discloses a data synchronization method for quantum circuits in a cluster environment and a quantum simulation system in a cluster environment. The method is mainly divided into two stages. In the first stage, the 0th process receives the quantum operation data transmitted by the QuTrunk programming software and accurately transmits the quantum operation data to all non-0th processes. In the second stage, after all node processes have received the quantum operation data, all node processes perform a synchronization operation on the quantum operation data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of quantum simulation technologies, and particularly to a data transmission method and a data synchronization method for quantum circuits in a cluster environment, as well as a quantum simulation system in a cluster environment. Background Art

[0002] In current quantum computing research, quantum simulators have received attention from researchers in related fields and have become an important tool for studying quantum technologies.

[0003] QuEST developed by the University of Oxford is a general-purpose quantum simulator written in C language, which is optimized by using various parallelization technologies such as OpenMP (Open Multi-Processing, multi-threading technology), MPI (Message Passing Interface Specification), and CUDA (Compute Unified Device Architecture). The QuEST API (Application Programming Interface) provides gate-level operations on quantum circuits, supports full-amplitude quantum simulation, and returns the quantum state through measurement.

[0004] QuEST supports quantum circuit simulation in a cluster environment. By allocating amplitudes to different nodes in the cluster, distributed quantum computing is achieved to solve the problem of huge memory consumption required for quantum circuit simulation. MPI (Message Passing Interface Specification) is the technical framework used by QuEST to implement distributed quantum computing. It is a standardized and portable message passing system established by a group of researchers from academia and industry based on various parallel computing architectures to achieve communication between different processes within the cluster. QuTrunk is a quantum front-end programming framework used to generate quantum circuit data and send the quantum circuit data to the back-end quantum simulation platform.

[0005] When a quantum circuit runs in a QuEST MPI cluster simulation environment, it is necessary to ensure that each node has the same copy of the quantum circuit data. Therefore, it is necessary to solve the problem of data transmission of quantum circuit data and other operation data between different nodes in the cluster. In addition, since some quantum circuits are not transmitted from the front-end to the simulation back-end at one time, and because the back-end is a cluster simulation environment and only one process communicates with the QuTrunk front-end, it is necessary to design a way for the processes within the cluster to wait and synchronize the execution of quantum algorithms. However, the prior art has not provided corresponding technical solutions. Summary of the Invention

[0006] The embodiment of the present invention provides a data synchronization method for a quantum circuit in a cluster environment, which is used to solve the problem of data transmission and synchronous execution operation of a quantum circuit of an existing quantum simulator in a cluster environment.

[0007] The data synchronization method of quantum circuits in a cluster environment provided by an embodiment of the present invention comprises the following steps:

[0008] S11. Set a node process in the cluster environment as the initial process, and set the remaining node processes as non-initial processes; establish a connection between the initial process and the quantum front-end programming framework, and establish connections between all non-initial processes and the initial process;

[0009] S12. Calling a synchronization function after the non-initial process in the cluster environment is started;

[0010] S13. After the initial process is started, the quantum operation data transmitted by the quantum front-end programming framework is monitored, and a synchronization function is called when the quantum operation data is received;

[0011] S14. When all node processes call the synchronization function, all node processes release the synchronization waiting operation;

[0012] S15. After receiving the quantum operation data transmitted by the quantum front-end programming framework, the initial process packages the quantum operation data and transmits the packaged quantum operation data to all non-initial processes;

[0013] S16. The non-initial process receives the packaged quantum operation data and performs an unpacking operation to obtain the quantum operation data;

[0014] S17. After all node processes obtain the synchronization operation instruction, they synchronously perform the same processing flow operation on the quantum operation data.

[0015] The data synchronization method of quantum circuits in a cluster environment provided by an embodiment of the present invention is that when the initial process is waiting for quantum operation data transmitted by the quantum front-end programming framework, all non-initial processes are waiting for the initial process by calling the synchronization function at the same time; when the initial process receives the quantum operation data from the quantum front-end programming framework, the synchronization function is also called, and the quantum operation data is transmitted to all non-initial processes by packaging, ensuring that the initial process can accurately transmit the quantum operation data to the non-initial process, thereby ensuring that all node processes can obtain the same quantum operation data. After the initial process transmits the quantum operation data to all non-initial processes, all node processes, in any quantum data operation process, ensure that all processes in the cluster are executed simultaneously through synchronization operations, and only then will the corresponding operations be allowed, thereby ensuring that all quantum data operations are executed synchronously.

[0016] After all node processes have executed all processing flows of the quantum operation data, the initial process re-executes step S13, and the non-initial process re-executes step S12.

[0017] Step S15 is specifically that the initial process packs the quantum operation data into packbuf through packdata, and packs the data length into npacksize; the initial process first transmits the data length to all non-initial processes through MPI_Bcast, and then transmits the packed quantum operation data to all non-initial processes.

[0018] The non-initial process first receives the data length through MPI_Bcast and receives the transmitted data according to the data length.

[0019] The initial process packs the quantum operation data, specifically: the packed data types include quantum circuits, single amplitude probabilities, single qubit state probabilities, all state value probabilities of specified multi-qubit bits, all amplitude probabilities, and multiple runs of quantum algorithms.

[0020] The quantum circuit includes command type, each quantum gate type, control bit, target bit, rotation angle, and quantum gate description;

[0021] The single amplitude probability includes command type and amplitude index;

[0022] The single qubit state probability includes command type, qubit index, and quantum state test value; the state test value is 1|0;

[0023] The all state value probabilities of the specified multi-qubit bits include command type and index array of qubit bits; the state values are state strings composed of 1&0;

[0024] The all amplitude probabilities include command type;

[0025] The multiple runs of the quantum algorithm include command type and number of runs.

[0026] The packing of the quantum operation data specifically includes the following steps:

[0027] S151. Pack basic data types, and the basic data types include string, int, vector <int>, vector <double>;

[0028] S152. Pack the data length into npacksize;

[0029] S153. Pack the quantum operation data into packbuf.

[0030] The specific method of packing a string is: pack the length of the string; pack the actual content of the string;

[0031] The specific method of unpacking a string is: unpack the length of the string into size; unpack the actual content of the string through size;

[0032] The specific method of packing an int is: directly pack pint;

[0033] The specific method of unpacking an int is: directly unpack the data into pint;

[0034] Pack a vector <int>Specifically: pack the size of the vector; pack each int element of the vector;

[0035] Unpack the vector <int>Specifically: unpack the size of the vector; unpack each element in the vector by the size;

[0036] Pack the vector <double>Specifically: Pack the size of the vector; Pack each double element of the vector;

[0037] Unpack the vector <double>Specifically: unpack the size of the vector; unpack each element in the vector by size.

[0038] Based on the same inventive concept, an embodiment of the present invention provides a quantum simulation system in a cluster environment, including:

[0039] Initial process unit: the initial process unit is used to receive quantum operation data and call the synchronization function when receiving the quantum operation data. The initial process unit is also used to release the synchronization waiting operation after receiving the quantum operation data, and to package the quantum operation data and broadcast it to all non-initial process units through the message passing interface specification. The initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data;

[0040] Non-initial process unit: the non-initial process unit is connected to the initial process unit, and calls a synchronization function while waiting for the initial process unit to send quantum operation data. When all process units call the synchronization function, the synchronization waiting is released; the non-initial process unit is also used to receive the quantum operation data packaged and sent by the initial process unit, and perform an unpacking operation to obtain the quantum operation data; the non-initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data.

[0041] The system also includes a front-end quantum programming framework, which is connected to the initial process unit and is used to generate quantum operation data and send the quantum operation data to the initial process unit.

[0042] In the system, the initial process unit is further used to pack the quantum operation data into packbuf through packdata, and pack the data length into npacksize; the initial process first transmits the data length to all non-initial processes through MPI_Bcast, and then transmits the packaged quantum operation data to all non-initial process units;

[0043] The non-initial process unit first receives the data length through MPI_Bcast, and receives the transmitted data according to the data length.

[0044] Based on the same inventive concept, an embodiment of the present invention further provides a storage medium, on which a computer program is stored, and when the computer program is run, the above-mentioned method for synchronizing quantum circuits in a cluster environment can be executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0046] Figure 1 Schematic flowchart of a data synchronization method for a quantum circuit in a cluster environment provided by an embodiment of the present application;

[0047] Figure 2 Schematic diagram of the process structure of a quantum circuit node in a cluster environment provided by an embodiment of the present application;

[0048] Figure 3 Schematic flowchart taking a quantum circuit as an example in an embodiment of the present application. Detailed implementation manners

[0049] To make the objectives, technical solutions, and advantages of the present application clearer, the following will, with reference to the drawings in the embodiments of the present application, clearly and completely describe the technical solutions of the present application through implementation manners. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present application.

[0050] In the description of the present invention, the meaning of several is more than one, the meaning of multiple is more than two, greater than, less than, exceeding, etc. are understood as not including the original number, and above, below, within, etc. are understood as including the original number. If there is a description of first and second, it is only for the purpose of distinguishing technical features and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features or implicitly indicating the sequence relationship of the indicated technical features.

[0051] In the description of the present invention, unless otherwise clearly defined, terms such as "set" should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meaning of the above terms in the present invention in combination with the specific content of the technical solution.

[0052] In the description of the present invention, the description with reference to terms such as "an embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples", or "some examples" means that the specific features or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0053] The embodiment of this application provides a data synchronization method for quantum circuits in a cluster environment, mainly providing a method for transmitting quantum operation data for quantum simulators in the existing cluster environment and ensuring that all node processes can synchronously execute operation data.

[0054] The quantum simulator in the embodiment of this application is illustrated by taking QuEST (Quantum Exact Simulation Toolkit) developed by the University of Oxford as an example. QuEST is a high-performance quantum simulator, including general quantum circuits, state vectors, density matrices, etc. QuEST is optimized by adopting a variety of parallelization technologies (OpenMP, MPI, CUDA), provides gate-level operations on quantum circuits, supports full-amplitude quantum simulation, and returns quantum states through measurement. QuEST supports quantum circuit simulation in a cluster environment, and realizes distributed quantum computing by allocating amplitudes to different nodes on the cluster, so as to solve the problem of huge memory consumption required for quantum circuit simulation.

[0055] For parts not specifically described in the related technologies in the embodiment of this application, relevant public technologies can be referred to.

[0056] The embodiment of this application provides a data synchronization method for quantum circuits in a cluster environment, which is mainly divided into two stages. In the first stage, the 0th process is used to receive the quantum operation data transmitted by the QuTrunk programming software, and the quantum operation data is accurately transmitted to all non-0th processes. In the second stage, after all node processes receive the quantum operation data, all node processes execute synchronous operations on the quantum operation data. The synchronous operations include operations on the same quantum operation data, and also include that in each process of operating on the quantum operation data, all node processes synchronously execute the same operation process, and the operation will be completed only then, so as to ensure that all quantum operations can be synchronously executed.

[0057] Embodiment 1

[0058] As Figure 1 shown, the data synchronization method for quantum circuits in a cluster environment provided by the embodiment of this application includes the following steps:

[0059] S11. Set a node process in the cluster environment as the initial process, and set the remaining node processes as non-initial processes; establish a connection between the initial process and the quantum front-end programming framework, and establish connections between all non-initial processes and the initial process.

[0060] As Figure 2 shown, it is a schematic diagram of a quantum circuit in a cluster environment in the embodiment of this application.

[0061] QuTrunk is a quantum front-end programming framework that is used to generate quantum operation data and send it to the back-end quantum simulation platform (QuEST). In a cluster environment, only one node process can communicate with the QuTrunk front-end and receive quantum operation data sent from the front-end. The node process that communicates with the QuTrunk front-end is defined as process 0, also called the initial process, and other node processes in the cluster environment are non-processes 0, also called non-initial processes. Non-processes 0 are connected to process 0 to receive quantum operation data sent from process 0 and perform processing of quantum operation data together with process 0.

[0062] The node processes in this embodiment may be executed by different processing cores in the same processor, or by different processors, or by different processing cores in different processors.

[0063] S12. Calling a synchronization function after the non-initial process in the cluster environment is started;

[0064] S13. After the initial process is started, the quantum operation data transmitted by the quantum front-end programming framework is monitored, and a synchronization function is called when the quantum operation data is received;

[0065] like Figure 3 The figure shows that when all node processes are started, they all need to wait to receive quantum operation data, taking the transmission of quantum circuit data as an example. Among them, process 0 starts the remote call listening RPC, which is used to listen to QuTrunk or generated by QuTrunk and passed through other services (such as Figure 3 The quantum operation data transmitted by the slave in the process, while the non-process No. 0 needs to wait for the quantum operation data transmitted by process No. 0.

[0066] Each non-0 process calls the synchronization function MPI_Barrier when waiting to receive quantum operation data after startup, and when process 0 receives quantum operation data, process 0 also calls the synchronization function MPI_Barrier.

[0067] S14. When all node processes call the synchronization function, all node processes release the synchronization waiting operation;

[0068] S15. After receiving the quantum operation data transmitted by the quantum front-end programming framework, the initial process packages the quantum operation data and transmits the packaged quantum operation data to all non-initial processes;

[0069] S16. The non-initial process receives the packaged quantum operation data and performs an unpacking operation to obtain the quantum operation data;

[0070] Among them, after receiving the quantum operation data, Process 0 also calls the synchronization function MPI_Barrier. That is, all node processes call the synchronization function. At this time, all processes are released from the synchronization wait. After packing the received quantum operation data, Process 0 transmits the same quantum operation data to all non-Process 0 processes through MPI_Bcast, and ensures that all node processes are synchronized after receiving the data before performing the next operation on the quantum operation data. After being released from the synchronization wait, non-Process 0 processes receive the quantum operation data sent from Process 0.

[0071] S17. After all node processes obtain the synchronization operation instruction, they synchronously perform the same processing flow operation on the quantum operation data.

[0072] In the embodiment of the present application, during the operation process of any quantum data, all node processes are synchronously executed. For example, in the case of quantum gate operations, the QuEST library improved by the technical solution of the present application will ensure that each quantum gate operation is synchronously executed in the MPI manner. For example, when executing an H gate, all node processes within the MPI cluster must execute the H gate simultaneously for the H gate to be completed. All quantum operations can be ensured to be synchronously executed.

[0073] After all node processes have executed all processing flows of the quantum operation data, Process 0 continues to start the remote call monitoring RPC, receives the quantum operation data sent from the QuTrunk front end, and calls the synchronization function MPI_Barrier when receiving the quantum operation data. Non-Process 0 continues to wait for the quantum operation data transmitted from Process 0, and during the waiting process, calls the synchronization function MPI_Barrier.

[0074] To ensure that Process 0 can synchronously transmit a copy of the quantum operation data to all node processes, the embodiment of the present application focuses on optimizing the transmission of the quantum operation data from Process 0 to non-Process 0. Mainly, Process 0 packs the received quantum operation data and transmits it to non-Process 0. At the same time, after receiving the packed quantum operation data, non-Process 0 performs an unpacking operation to obtain the quantum operation data.

[0075] The above operation process is specifically that Process 0 packs the quantum operation data into packbuf through packdata, and packs the data length into npacksize; the initial process first transmits the data length to all non-Process 0 processes through MPI_Bcast, and then transmits the packed quantum operation data to all non-initial processes.

[0076] The non-Process 0 process first receives the data length through MPI_Bcast, and receives the transmitted data according to the data length.

[0077] Among the quantum operation data packed by the 0th process and unpacked by non-0th processes, the types of the packed data mainly include:

[0078] Quantum circuit: including command type, type of each quantum gate, control bit, target bit, rotation angle, and quantum gate description, etc.;

[0079] Single amplitude probability: including command type, amplitude index;

[0080] Single qubit state probability: including command type, qubit index, quantum state test value; the state test value is 1|0;

[0081] Probability of all state values of specified multiple qubits: including command type, index array of qubits; the state value is a state string composed of 1&0;

[0082] All amplitude probabilities: including command type;

[0083] Multiple runs of quantum algorithms: including command type, number of runs.

[0084] The packing of the quantum operation data specifically includes the following steps:

[0085] S151. Pack basic data types, and the basic data types include string, int, vector <int>, vector <double>;

[0086] S152. Pack the data length into npacksize;

[0087] S153. Pack the quantum operation data into packbuf.

[0088] The specific packing of string is as follows:

[0089] a) Pack the length of the string;

[0090] b) Pack the actual content of the string;

[0091] The specific unpacking of string is as follows:

[0092] a) Unpack the length of the string into size;

[0093] b) Unpack the actual content of the string by size;

[0094] An implementation of the above string packing and unpacking is as follows:

[0095] Void NodeData::packstring(const std::string& str,char* packbuf,int&packsize)

[0096] {

[0097] Int size=str.size();

[0098] MPI_Pack(&size,1,MPI_INT,packbuf,PACKSIZE,&packsize,MPI_COMM_WORLD);

[0099] MPI_pack(str.c_str(),size,MPI_CHAR,packbuf,PACKSIZE,&packsize, MPI_COMM_WORLD);

[0100] }

[0101] Void NodeData::unpackstring(std::string& str,char* packbuf,int&packsize)

[0102] {

[0103] Int size=0;

[0104] MPI_Unpack(packbuf, packsize, &m_position, &size, 1, MPI_INT, MPI_COMM_WORLD);

[0105] Std::unique_ptr<char[]> autostr(new char[size + 1]{0});

[0106] MPI_Unpack(packbuf, packsize, &m_position, (void*)autostr.get(), size, MPI_CHAR, MPI_COMM_WORLD);

[0107] Str = autostr.get();

[0108] }

[0109] Packing an int specifically involves: directly packing pint;

[0110] Unpacking an int specifically involves: directly unpacking the data into pint;

[0111] One implementation of the above int packing and unpacking is as follows:

[0112] Void NodeData::packint(const int& pint, char* packbuf, int& packsize)

[0113] {

[0114] MPI_Pack(&pint, 1, MPI_INT, packbuf, PACKSIZE, &packsize, MPI_COMM_WORLD);

[0115] }

[0116] Void NodeData::unpackint(iny& pint, char* packbuf, int& packsize)

[0117] {

[0118] Int size = 0;

[0119] MPI_Unpack(packbuf, packsize, &m_position, &pint, 1, MPI_INT, MPI_COMM_WORLD);

[0120] }

[0121] Pack vector <int>Specifically:

[0122] a) Pack the size of the vector;

[0123] b) Pack each int element of the vector;

[0124] Unpack the vector <int>Specifically:

[0125] a) Unpack the size of the vector;

[0126] b) Unpack each element in the vector by the size;

[0127] The above-mentioned packing and unpacking of the vector <int>One embodiment is as follows:

[0128] Void NodeData::packvectorint(const std::vector <int>&vec, char* packbuf, int& packsize)

[0129] {

[0130] Int size = vec.size();

[0131] MPI_Pack(&size, 1, MPI_INT, packbuf, PACKSIZE, &packsize, MPI_COMM_WORLD);

[0132] For(auto i : vec)

[0133] MPI_pack(&i, 1, MPI_INT, packbuf, PACKSIZE, &packsize, MPI_COMM_WORLD);

[0134] }

[0135] Void NodeData::unpackvectorint(std::vector <int>&vec, char* packbuf, int& packsize)

[0136] {

[0137] Int size = 0;

[0138] MPI_Unpack(packbuf, packsize, &m_position, &size, 1, MPI_INT, MPI_COMM_WORLD);

[0139] For(int i = 0, i < size; i++)

[0140] {

[0141] Int cntrobit = 0;

[0142] MPI_Unpack(packbuf, packsize, &m_position, &controlbit, 1, MPI_INT, MPI_COMM_WORLD);

[0143] Vec.push_back(controlbit);

[0144] }

[0145] Pack the vector <double>Specifically:

[0146] a) Pack the size of the vector;

[0147] b) Pack each double element of the vector;

[0148] Unpack the vector <double>Specifically:

[0149] a) Unpack the size of the vector;

[0150] b) Unpack each element in the vector by the size.

[0151] The above-mentioned packing and unpacking of the vector <double>One embodiment is as follows:

[0152] Void NodeData::packvectordouble(const std::vector <double>&vec, char* packbuf, int& packsize)

[0153] {

[0154] Int size = vec.size();

[0155] MPI_Pack(&size, 1, MPI_INT, packbuf, PACKSIZE, &packsize, MPI_COMM_WORLD);

[0156] For(auto i : vec)

[0157] MPI_pack(&i, 1, MPI_DOUBLE, packbuf, PACKSIZE, &packsize, MPI_COMM_WORLD);

[0158] }

[0159] Void NodeData::unpackvectordouble(std::vector <double>&vec, char* packbuf, int& packsize)

[0160] {

[0161] Int size = 0;

[0162] MPI_Unpack(packbuf, packsize, &m_position, &size, 1, MPI_INT, MPI_COMM_WORLD);

[0163] For(int i = 0, i < size; i++)

[0164] {

[0165] double rotationbit = 0;

[0166] MPI_Unpack(packbuf, packsize, &m_position, &controlbit, 1, MPI_DOUBLE, MPI_COMM_WORLD);

[0167] Vec.push_back(rotationbit);

[0168] }

[0169] As can be seen from the above, pack and unpack vector <int>And packing and unpacking vectors <double>Similar, except that MPI_DOUBLE needs to be specified when specifying the data type.

[0170] After packing the data type, the next step is to pack and unpack the quantum operation data. This application example uses a quantum circuit for illustration:

[0171] Packing:

[0172] a) Pack the quantum operation type as CMDTYPE_CRICUIT;

[0173] b) Pack the number of quantum gates included in the quantum circuit;

[0174] c) Pack the specific data of each qubit, including the quantum gate type, control bit, target, rotation angle, and quantum gate description;

[0175] Unpacking:

[0176] a) Unpack the number of quantum gates;

[0177] b) Unpack the data of each qubit separately and add it to the m_Cmds quantum circuit.

[0178] One implementation of the above packing and unpacking of the quantum circuit is as follows:

[0179] Void NodeData::packcircuit(const std::vector <cmd>&cmds, const int& final, char* packbuf, int& packsize)

[0180] {

[0181] / / pack command type

[0182] Packcmdtype(CMDTYPE_CRICUIT, packbuf, packsize);

[0183] / / pack circuit

[0184] packint(cmds.size(), packbuf, packsize);

[0185] for (auto& cmd : cmds)

[0186] {

[0187] Packsrting(cmd.gate, packbuf, packsize);

[0188] Packvectorint(cmd.controls, packbuf, packsize);

[0189] Packvectorint(cmd.targets, packbuf, packsize);

[0190] Packdouble(cmd.rotation, packbuf, packsize);

[0191] Packsrting(cmd.desc, packbuf, packsize);

[0192] }

[0193] Void NodeData::unpackcircuit(char* packbuf, int& packsize)

[0194] {

[0195] / / unpack circuit

[0196] Int cmdsize = 0

[0197] unpackint(cmdsize, packbuf, packsize);

[0198] For(int i = 0; i < cmdsize; i++)

[0199] {

[0200] Cmd cmd;

[0201] unpacksrting(cmd.gate, packbuf, packsize);

[0202] unpackvectorint(cmd.controls, packbuf, packsize);

[0203] unpackvectorint(cmd.targets, packbuf, packsize);

[0204] unpackdouble(cmd.rotation, packbuf, packsize);

[0205] unpacksrting(cmd.desc, packbuf, packsize);

[0206] m_cmds.push_back(cmc);

[0207] }

[0208] }

[0209] After the 0th process packs the quantum operation data, the next step is to send it to non-0 processes through MPI_Bcast. The specific implementation process is as follows:

[0210] if (SINGLETON(CQuESTIniter)->m_env.rank == 0)

[0211] {

[0212] Packdata(cmdtype, packbuf, npacksize);

[0213] }

[0214] MPI_Bcast(&npacksize, 1, MPI_INT, 0, MPI_COMM_WORLD);

[0215] MPI_Bcast(packbuf, npacksize, MPI_PACKED, 0, MPI_COMM_WORLD);

[0216] If (SINGLETON(CQuESTIniter)->m_env.rank!==0)

[0217] {

[0218] NodeData nodedata;

[0219] Unpackdata(nodedata, packbuf, npacksize);

[0220] If (nodedata.m_cmdtype @= CMDTYPE_CANCEL)

[0221] {

[0222] Execute(nodedata);

[0223] Continue;

[0224] }

[0225] }

[0226] Among them, m_env.rank = 0 represents the 0th process, which is the process communicating with the QuTrunk front-end. When the 0th process receives the quantum operation data transmitted from the front-end, it needs to pack and transmit this data to other node processes; packdata packs the quantum operation data into packbuf and the data length into npacksize, and cmdtype is the packed data type mentioned above; the 0th process first transmits the packed data length to other node processes through MPI_Bcast, and then transmits the packed data to other nodes;

[0227] Non-0 processes first receive the transmitted data length through MPI_Bcast, and then receive the transmitted data according to the data length; m_env.rank!= 0 represents non-0 processes, which are also the processes receiving quantum operation data. After receiving the data, non-0 processes unpack the data through unpackdata. For the specific unpacking process, refer to the above description of packing and unpacking for each data type, which will not be elaborated here.

[0228] As shown in Figure 3, the data transmission and synchronous execution process of the quantum operation provided by the embodiment of the present application on different node processes in the cluster will be introduced in detail below. Figure 3 For example, taking quantum circuit data as an example for illustration.

[0229] The 0th process represents the main process, which receives the front-end quantum data. Non-0 processes represent other processes in the cluster, also called non-0 processes, which receive the quantum operation data sent by the 0th process.

[0230] After the node process starts, it determines whether it is the No. 0 process. If it is the No. 0 process, it starts a remote listening RPC to listen for quantum operation data sent by the front-end QuTrunk or quantum operation data sent by the front-end QuTrunk after passing through other services (the front-end quantum operation data of QuTrunk will pass through some other services in the middle, such as Figure 3 the slave in, but this does not affect the cluster node synchronization problem). After the non-0 process starts, it calls the MPI_Barrier synchronization function to wait;

[0231] After the No. 0 process receives the quantum operation data from the front-end QuTrunk, it also calls the MPI_Barrier synchronization function. When all processes in the cluster have called the MPI_Barrier synchronization function, all processes release the synchronization wait and continue to execute the code below;

[0232] The No. 0 process continues to execute and will pack the quantum operation data and send it to the non-0 processes through MPI_Bcast. The non-0 processes continue to execute and will call mpi_Bcast to synchronize and wait for the data sent by the No. 0 process;

[0233] After the No. 0 process successfully sends the data, it will enter the stage of executing the quantum operation data. After the non-0 processes successfully receive the data, they will also enter the stage of executing the quantum operation data;

[0234] In any quantum data operation process, such as a quantum gate operation, the QuEST library will ensure that each quantum gate operation is synchronously executed in the MPI mode. For example, when executing an H gate, all processes in the MPI cluster must execute the H gate simultaneously for the H gate to be completed. Therefore, all quantum operations can be ensured to be synchronously executed;

[0235] After executing the quantum operation, the No. 0 process continues to wait for the quantum operation data sent from the front-end QuTrunk, while the non-0 processes continue to call MPI_Barrier to synchronize and wait for the No. 0 process; it continues until the cancel instruction sent by the front-end QuTrunk comes to cancel the quantum operation.

[0236] The data synchronization method of quantum circuits in a cluster environment provided by an embodiment of the present invention, when process No. 0 is waiting for quantum operation data transmitted by the quantum front-end programming framework, all non-No. 0 processes are waiting for the initial process at the same time by calling the synchronization function; when process No. 0 receives quantum operation data from the quantum front-end programming framework, it also calls the synchronization function, and transmits the quantum operation data to all non-No. 0 processes by packaging, ensuring that process No. 0 can accurately transmit quantum operation data to non-No. 0 processes, including quantum circuits, quantum amplitude acquisition operations, quantum bit measurement operations, etc., so as to ensure that all node processes can obtain the same quantum operation data. After process No. 0 transmits quantum operation data to all non-No. 0 processes, all node processes, in any quantum data operation process, ensure that all processes in the cluster are executed simultaneously through synchronization operations, and only then will the corresponding operations be allowed, so as to ensure that all quantum data operations are executed synchronously. After all quantum operation data are executed, process No. 0 continues to wait for the quantum operation data of QuTrunk, and non-No. 0 processes continue to wait for process No. 0, and this process continues until the front end sends a cancel instruction to cancel the operation of the quantum algorithm. The method provided in this application can meet the requirements of running quantum algorithms on a single node, multiple nodes on the same host, or multiple nodes on multiple hosts without changing the existing code.

[0237] Example 2

[0238] The embodiment of the present application provides a quantum simulation system in a cluster environment, including:

[0239] Initial process unit: the initial process unit is used to receive quantum operation data and call the synchronization function when receiving the quantum operation data. The initial process unit is also used to release the synchronization waiting operation after receiving the quantum operation data, and to package the quantum operation data and broadcast it to all non-initial process units through the message passing interface specification. The initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data;

[0240] Non-initial process unit: the non-initial process unit is connected to the initial process unit, and calls a synchronization function while waiting for the initial process unit to send quantum operation data. When all process units call the synchronization function, the synchronization waiting is released; the non-initial process unit is also used to receive the quantum operation data packaged and sent by the initial process unit, and perform an unpacking operation to obtain the quantum operation data; the non-initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data.

[0241] The system further includes a front-end quantum programming framework, which is connected to the initial process unit. The front-end quantum programming framework is used to generate quantum operation data and send the quantum operation data to the initial process unit.

[0242] In the system, the initial process unit also has the function of packing the quantum operation data into packbuf through packdata, and packing the data length into npacksize; the initial process first transmits the data length to all non-initial processes through MPI_Bcast, and then transmits the packed quantum operation data to all non-initial process units;

[0243] The non-initial process unit first receives the data length through MPI_Bcast and receives the transmitted data according to the data length.

[0244] The system provided by the embodiment of the present invention is used to implement the method provided in Embodiment 1 above. Details that are not described in this embodiment and are the same as those in Embodiment 1 can refer to Embodiment 1 and will not be elaborated here.

[0245] Embodiment 3

[0246] Based on the same inventive concept, an embodiment of the present application provides a storage medium, on which a computer program is stored. The computer program can execute the data synchronization method of the quantum circuit provided in Embodiment 1 above when running. Details that are not described in this embodiment and are the same as those in Embodiment 1 can refer to Embodiment 1 and will not be elaborated here.

[0247] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0248] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0249] For those skilled in the art, according to the technical solutions and concepts described above, various corresponding changes and deformations can be made, and all these changes and deformations should fall within the protection scope of the claims of the present invention.< / cmd> < / double> < / int> < / double> It should be noted that there may be some issues with the original code as "Int" is likely a typo and should probably be "int". Also, "MPI_pack" should likely be "MPI_Pack" for proper case consistency in the MPI functions.< / double> < / double> < / double> < / double> It should be noted that there are some incorrect variable names in the original text (e.g., "Int" instead of "int", "cntrobit" which might be a misspelling, etc.). This translation is based on the provided text as is.< / int> It should be noted that there may be some errors or incomplete parts in the original code snippet, such as the incorrect capitalization of "Int" in line 6 which should probably be "int", and the incomplete function definition starting from line 21. But the translation is done strictly according to the requirements.< / int> < / int> < / int> < / int> < / double> < / int> < / double> < / double> < / int> < / int> < / double> < / int>

Claims

1. Data synchronization method of quantum circuits in cluster environment, It is characterized in that The following steps are involved: S11. Set a node process in the cluster environment as the initial process, and set the remaining node processes as non-initial processes; establish a connection between the initial process and the quantum front-end programming framework, and establish connections between all non-initial processes and the initial process; S12. Calling a synchronization function after the non-initial process in the cluster environment is started; S13. After the initial process is started, the quantum operation data transmitted by the quantum front-end programming framework is monitored, and a synchronization function is called when the quantum operation data is received; S14. When all node processes call the synchronization function, all node processes release the synchronization waiting operation; S15. After receiving the quantum operation data transmitted by the quantum front-end programming framework, the initial process packages the quantum operation data and transmits the packaged quantum operation data to all non-initial processes; S16. The non-initial process receives the packaged quantum operation data and performs an unpacking operation to obtain the quantum operation data; S17. After all node processes obtain the synchronization operation instruction, they synchronously perform the same processing flow operation on the quantum operation data.

2. The method according to claim 1, It is characterized in that The step S15 is specifically that the initial process packs the quantum operation data into packbuf through packdata, and packs the data length into npacksize; the initial process first transmits the data length to all non-initial processes through MPI_Bcast, and then transmits the packaged quantum operation data to all non-initial processes.

3. The method according to claim 1, It is characterized in that The initial process packages quantum operation data, specifically: the packaged data types include quantum circuits, single amplitude probabilities, single quantum bit state probabilities, all state value probabilities of specified multiple quantum bits, all amplitude probabilities, and multiple runs of quantum algorithms.

4. The method according to claim 3, Features: The quantum circuit includes a command type, each quantum gate type, a control bit, a target bit, a rotation angle, and a quantum gate description; The single amplitude probability includes a command type and an amplitude index; The single quantum bit state probability includes a command type, a quantum bit index, and a quantum state test value; the state test value is 1|0; The probability of all state values ​​of the specified multiple quantum bits includes a command type and an index array of the quantum bits; the state value is a state string consisting of 1&0; All amplitude probabilities include command types; The multiple runs of the quantum algorithm include command type and run times.

5. The method according to claim 3 or 4, It is characterized in that The packaging of quantum operation data specifically includes the following steps: S151. Pack basic data types, where the basic data types include string, int, vector <int>, vector <double> ;< / double> < / int> S152. Pack data length to npacksize; S153. Pack quantum operation data into packbuf.

6. The method according to claim 5, It is characterized in that The specific information of the packed string is: the length of the packed string; the actual content of the packed string; Unpacking a string is as follows: unpacking the length of the string to size; unpacking the actual content of the string through size; Packing int specifically: pack pint directly; Unpacking int is as follows: directly unpack the data to pint; Packaged vector <int> Specifically: pack the size of the vector; pack each int element of the vector;< / int> Unpack vector <int> Specifically: unpack the size of the vector; unpack each element in the vector by size;< / int> Packaged vector <double> Specifically: pack the size of the vector; pack each double element of the vector;< / double> Unpack vector <double> Specifically: unpack the size of the vector; unpack each element in the vector by size.< / double> 7. Quantum simulation system in cluster environment, It is characterized in that include: Initial process unit: the initial process unit is used to receive quantum operation data and call the synchronization function when receiving the quantum operation data. The initial process unit is also used to release the synchronization waiting operation after receiving the quantum operation data, and to package the quantum operation data and broadcast it to all non-initial process units through the message passing interface specification. The initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data; Non-initial process unit: the non-initial process unit is connected to the initial process unit, and calls a synchronization function while waiting for the initial process unit to send quantum operation data. When all process units call the synchronization function, the synchronization waiting is released; the non-initial process unit is also used to receive the quantum operation data packaged and sent by the initial process unit, and perform an unpacking operation to obtain the quantum operation data; the non-initial process unit is also used to synchronously execute the same processing flow on the quantum operation data according to the synchronization operation instruction after all process units have obtained the same quantum operation data.

8. The quantum simulation system in a cluster environment as claimed in claim 7, It is characterized in that It also includes a front-end quantum programming framework, which is connected to the initial process unit and is used to generate quantum operation data and send the quantum operation data to the initial process unit.

9. The quantum simulation system in a cluster environment as claimed in claim 8, It is characterized in that The initial process unit is further used to pack the quantum operation data into packbuf through packdata, and pack the data length into npacksize; the initial process first transmits the data length to all non-initial processes through MPI_Bcast, and then transmits the packaged quantum operation data to all non-initial process units; The non-initial process unit first receives the data length through MPI_Bcast, and receives the transmitted data according to the data length.

10. A storage medium, It is characterized in that A computer program is stored on the storage medium, and when the computer program runs, it can execute the data synchronization method of the quantum circuit according to any one of claims 1 to 6 in a cluster environment.

Citation Information

Patent Citations

  • Method for increasing calculation speed of SMP cluster system through MPI and OpenMP in hybrid parallel mode

    CN104461467A

  • A process communication method and device in a cluster system

    CN109002350A