CN115392471A - Data synchronization method of quantum circuit in cluster environment and quantum simulation system - Google Patents

Data synchronization method of quantum circuit in cluster environment and quantum simulation system Download PDF

Info

Publication number
CN115392471A
CN115392471A CN202211003989.2A CN202211003989A CN115392471A CN 115392471 A CN115392471 A CN 115392471A CN 202211003989 A CN202211003989 A CN 202211003989A CN 115392471 A CN115392471 A CN 115392471A
Authority
CN
China
Prior art keywords
quantum
operation data
data
initial process
vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211003989.2A
Other languages
Chinese (zh)
Inventor
刘利
邵伟
潘彦宽
刘波
周卓俊
韩琢
丘秉宜
罗乐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qike Quantum Technology Zhuhai Co ltd
Guokaike Quantum Technology Beijing Co Ltd
Original Assignee
Qike Quantum Technology Zhuhai Co ltd
Guokaike Quantum Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qike Quantum Technology Zhuhai Co ltd, Guokaike Quantum Technology Beijing Co Ltd filed Critical Qike Quantum Technology Zhuhai Co ltd
Priority to CN202211003989.2A priority Critical patent/CN115392471A/en
Publication of CN115392471A publication Critical patent/CN115392471A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/80Quantum programming, e.g. interfaces, languages or software-development kits for creating or handling programs capable of running on quantum computers; Platforms for simulating or accessing quantum computers, e.g. cloud-based quantum computing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Mathematical Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Data Mining & Analysis (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a data synchronization method of quantum lines in a cluster environment and a quantum simulation system in the cluster environment. The process is essentially divided into two stages. And the first stage is used for receiving the quantum operation data transmitted by the Qutrunk programming software through the No. 0 process and transmitting the quantum operation data to all non-No. 0 processes without errors. And in the second stage, after all the node processes receive the quantum operation data, all the node processes execute synchronous operation on the quantum operation data.

Description

Data synchronization method of quantum circuit in cluster environment and quantum simulation system
Technical Field
The present application relates to the field of quantum simulation technologies, and in particular, to a data transmission method and a data synchronization method for a quantum circuit in a cluster environment, and a quantum simulation system in a cluster environment.
Background
In the current research of quantum computing, quantum simulators are regarded by researchers in related fields, and become important tools for researching quantum technologies.
QuEST developed by oxford university is a general quantum simulator written in C language, which adopts multiple parallelization technologies such as OpenMP (Open Multi-Processing, multithreading), MPI (Message publishing Interface Specification), and CUDA (Unified computing Device Architecture) for optimization. The QuEST API (Application Programming Interface) provides gate-level operation on quantum wires, supports full-amplitude quantum simulation, and returns quantum states through measurements.
QuEST supports quantum line simulation in a cluster environment, and distributed quantum computation is achieved by distributing amplitudes to different nodes on a cluster, so that the problem of huge memory consumption required by quantum line simulation is solved. MPI (Message publishing Interface Specification) is a technical framework for realizing distributed quantum computing by a QuEST, and is a standardized and portable Message transmission system which is established by a group of researchers from academia and industry and designed in various parallel computing architectures, so as to realize the purpose of communication among different processes in a cluster. The QuTrunk is a quantum front-end programming framework that is used to generate quantum wire data and send the quantum wire data to a back-end quantum simulation platform.
When the quantum circuit runs in a QuEST MPI cluster simulation environment, it is necessary to ensure that each node has the same quantum circuit data, and therefore, the problem of data transmission of quantum circuit data and other operation data on different nodes on a cluster needs to be solved. In addition, since some quantum wires are not transmitted from the front-end to the analog back-end at once, and since the back-end is a cluster analog environment, only one process communicates with the qureturn front-end, it is necessary to design a system that allows the processes within the cluster to wait and execute quantum algorithms synchronously. However, the prior art does not provide a corresponding technical solution.
Disclosure of Invention
The embodiment of the invention provides a method for synchronizing data obtained by quantum lines in a cluster environment, which is used for solving the problems of data transmission and synchronous execution operation of the quantum lines of the conventional quantum simulator in the cluster environment.
The data synchronization method of the quantum circuit under the cluster environment provided by the embodiment of the invention comprises the following steps:
s11, setting a node process in the cluster environment as an initial process, and setting other node processes as non-initial processes; establishing the connection between the initial process and a quantum front-end programming frame, and establishing the connection between all non-initial processes and the initial process;
s12, calling a synchronous function after a non-initial process in the cluster environment is started;
s13, monitoring quantum operation data transmitted by the quantum front-end programming framework after the initial process is started, and calling a synchronous function when the quantum operation data is received;
s14, after all node processes call the synchronization function, all the node processes release the synchronization waiting operation;
s15, after receiving quantum operation data transmitted by a quantum front-end programming framework, the initial process packs the quantum operation data and transmits the packed quantum operation data to all non-initial processes;
s16, the non-initial process receives the packed quantum operation data and carries out unpacking operation to obtain the quantum operation data;
and S17, after all the node processes acquire the synchronous operation instruction, synchronously executing the same processing flow operation on the quantum operation data.
According to the data synchronization method of the quantum circuit in the cluster environment, when the initial process waits for the quantum operation data transmitted by the quantum front-end programming framework, all non-initial processes wait for the initial process at the same time by calling the synchronization function; when the initial process receives the quantum operation data from the quantum front-end programming framework, the synchronous function is called, the quantum operation data are transmitted to all the non-initial processes through packaging, the quantum operation data can be accurately transmitted to the non-initial processes by the initial process, and therefore all the node processes can obtain the same quantum operation data. After the initial process transmits the quantum operation data to all the non-initial processes, all the node processes ensure that all the processes in the cluster are executed simultaneously through synchronous operation in any one quantum data operation process, and corresponding operation is allowed to be carried out, so that all the quantum data operations are synchronously executed.
And when all the processing flows of the quantum operation data are executed by all the node processes, the initial flow executes the step S13 again, and the non-initial flow executes the step S12 again.
The step S15 is specifically that the quantum operation data is packed to a packbuf through packdata in the initial process, and the data length is packed to npacksize; the initial process firstly 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.
The non-initial process first receives a data length through the MPI _ Bcast and receives transmitted data according to the data length.
The packing of the quantum operation data in the initial process specifically comprises the following steps: the packed data types comprise quantum lines, single amplitude probabilities, single quantum bit state probabilities, all state value probabilities of specified multiple quantum bits, all amplitude probabilities, and multiple quantum algorithm operations.
The quantum wires include 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 comprises a command type and an amplitude index;
the single-qubit state probability comprises a command type, a qubit index and a quantum state test value; the state test value is 1 and 0;
all the state value probabilities of the appointed multiple quantum bits comprise command types and index arrays of the quantum bits; the state value is a state string consisting of 1 &0;
the all amplitude probabilities include a command type;
the quantum algorithm is operated for many times, wherein the operation times comprise command types.
The quantum operation data packing method specifically comprises the following steps:
s151, packaging basic data types, wherein the basic data types comprise string, int, vector < int >, and vector < double >;
s152, packing the data length to npacksize;
and S153, packing the quantum operation data to a packbuf.
The packing string specifically comprises the following steps: packing the length of string;
the unpacking specifically comprises the following steps: unpacking the length of string to size;
packaging int specifically includes: directly packaging pint;
the unpacking int specifically comprises: unpacking data directly to pint;
the packaging vector < int > is specifically as follows: size of packed vector; packaging each int element of vector;
the unpacking vector < int > is specifically as follows: unpacking the size of the vector; unpacking each element inside a vector by size;
the packing vector < double > is specifically: size of packed vector; packing each double element of the vector;
the unpacking vector is specifically as follows: size of unpacked vector; each element inside the vector is unpacked by size.
Based on the same inventive concept, the embodiment of the present invention provides a quantum simulation system in a cluster environment, including:
an initial process unit: the initial process unit is used for receiving quantum operation data and calling a synchronization function when receiving the quantum operation data, and is also used for releasing synchronization waiting operation after receiving the quantum operation data, packaging the quantum operation data and then broadcasting and sending the quantum operation data to all non-initial process units through a message transmission interface specification; the initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data;
non-initial process unit: the non-initial process unit is connected with the initial process unit, and calls a synchronous function when waiting for the initial process unit to send quantum operation data, and removes synchronous waiting when all process units call the synchronous function; the non-initial process unit is also used for receiving the quantum operation data sent by the initial process unit in a packaging mode, and carrying out unpacking operation to obtain the quantum operation data; and the non-initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data.
The system further comprises a front-end quantum programming framework, wherein the quantum programming framework is connected with the initial process unit and is used for generating quantum operation data and sending the quantum operation data to the initial process unit.
In the system, the initial process unit is further configured to pack the quantum operation data into a packbuf through packdata, and pack the data length into npacksize; the initial process firstly 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;
the non-initial process unit firstly receives the data length through the MPI _ Bcast and receives the transmitted data according to the data length.
Based on the same inventive concept, the embodiment of the present invention further provides a storage medium, where a computer program is stored on the storage medium, and the computer program, when running, may perform the data synchronization method of the quantum wires in the cluster environment.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a data synchronization method of quantum lines in a cluster environment according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a quantum wire junction process in a cluster environment according to an embodiment of the present disclosure;
fig. 3 is a schematic flow chart of an example of a quantum wire in the embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described in detail and completely through implementation by referring to the drawings in the examples of the present application, and it is obvious that the described examples are some examples of the present application, but not all examples. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
In the description of the present invention, the meaning of a plurality is one or more, the meaning of a plurality is two or more, and the above, below, exceeding, etc. are understood as excluding the present numbers, and the above, below, within, etc. are understood as including the present numbers. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless otherwise explicitly defined, terms such as set, etc. should be broadly construed, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present invention in combination with the detailed contents of the technical solutions.
In the description of the present invention, reference to the description of the terms "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples," etc., means that a particular feature or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The embodiment of the application provides a data synchronization method of quantum lines in a cluster environment, mainly provides a quantum operation data transmission method for a quantum simulator in the existing cluster environment, and ensures that all node processes can synchronously execute operation data.
The Quantum simulator in the embodiment of the present application will be described by taking QuEST (Quantum Exact Simulation Toolkit) developed by oxford university as an example. The QuEST is a high-performance quantum simulator and comprises a universal quantum circuit, a state vector, a density matrix and the like. QuEST adopts various parallelization technologies (OpenMP, MPI and CUDA) for optimization, provides gate-level operation on quantum lines, supports full-amplitude quantum simulation, and returns quantum states through measurement. QuEST supports quantum line simulation in a cluster environment, and distributed quantum computation is achieved by distributing amplitudes to different nodes on a cluster, so that the problem of huge memory consumption required by quantum line simulation is solved.
In the embodiments of the present application, reference may be made to related art publications, which are not specifically described in the related art.
The embodiment of the application provides a data synchronization method of quantum wires in a cluster environment, which is mainly divided into two stages. And the first stage realizes that the quantum operation data transmitted by the Qutrunk programming software is received through the process No. 0, and the quantum operation data is transmitted to all processes not being No. 0 without errors. And in the second stage, after all the node processes receive the quantum operation data, all the node processes execute synchronous operation on the quantum operation data. The synchronous operation includes the operation on the same quantum operation data, and also includes that in each flow of operating on the quantum operation data, all the node flows synchronously execute the same operation flow, and the operation is executed and completed, thereby ensuring that all the quantum operations can be executed synchronously.
Example 1
As shown in fig. 1, a data synchronization method of a quantum wire in a cluster environment provided by an embodiment of the present application includes the following steps:
s11, setting one node process in the cluster environment as an initial process, and setting the other node processes as non-initial processes; and establishing the connection between the initial process and the quantum front-end programming framework, and establishing the connection between all non-initial processes and the initial process.
Fig. 2 is a schematic diagram of a quantum circuit in a cluster environment in the embodiment of the present application.
QuTrunk is a quantum front-end programming framework used for generating quantum operation data and sending the quantum operation data to a back-end quantum simulation platform (i.e. QuEST). In the cluster environment, only one node process can communicate with the Qutrunk front end and receive quantum operation data sent from the front end. And defining the node process communicated with the Qutrunk front end as a No. 0 process, also called an initial process, and defining other node processes in the cluster environment as non-No. 0 processes, also called non-initial processes. The non-0 process is connected with the 0 process and used for receiving the quantum operation data sent by the 0 process and executing the processing of the quantum operation data together with the 0 process.
The node process in this embodiment may be executed by different processing cores in the same processor, or executed by different processors, or executed by different processing cores of different processors.
S12, calling a synchronous function after a non-initial process in the cluster environment is started;
s13, monitoring quantum operation data transmitted by the quantum front-end programming framework after the initial process is started, and calling a synchronous function when the quantum operation data is received;
as shown in fig. 3, for example, in the case of transmitting quantum wire data, all node processes need to wait for receiving quantum operation data after being started. The process No. 0 starts a remote call monitoring RPC for monitoring the QuTrunk or the quantum operation data generated by the QuTrunk and transmitted through other services (e.g., the slave in fig. 3), while the process No. 0 needs to wait for the quantum operation data transmitted by the process No. 0.
And when the process No. 0 receives the quantum operation data, the process No. 0 also calls the synchronization function MPI _ Barrier.
S14, after all node processes call the synchronization function, all the node processes remove the synchronization waiting operation;
s15, after receiving the quantum operation data transmitted by the quantum front-end programming framework, the initial process packs the quantum operation data and transmits the packed quantum operation data to all non-initial processes;
s16, the non-initial process receives the packed quantum operation data and carries out unpacking operation to obtain the quantum operation data;
after receiving the quantum operation data, the process 0 also calls a synchronization function MPI _ Barrier. That is, all node processes call the synchronization function, and all the processes are released from the synchronization waiting at this time. And after the No. 0 process packs the received quantum operation data, the same quantum operation data is transmitted to all non-No. 0 processes through the MPI _ Bcast, and all node processes are ensured to synchronously execute the next operation on the quantum operation data after receiving the data. And after the non-0 process is subjected to desynchronization waiting, receiving the quantum operation data sent from the 0 process.
And S17, after all the node processes acquire the synchronous operation instruction, synchronously executing the same processing flow operation on the quantum operation data.
In the embodiment of the application, the operation process of any quantum data is realized, and all node processes are synchronously executed. For example, the QuEST library improved by the technical scheme of the application can ensure that each quantum gate operation is synchronously executed in an MPI mode. For example, when an H gate is executed, all node processes in the MPI cluster must execute the H gate at the same time, and the H gate is executed.
And when all the node processes execute all the processing flows of the quantum operation data, the No. 0 flow continuously starts a remote call monitoring RPC, receives the quantum operation data sent from the Qutrunk front end, and calls a synchronization function MPI _ Barrier when receiving the quantum operation data. The non-0 process continues to wait for the quantum operation data transferred from process No. 0, and in the course of waiting, calls the synchronization function MPI _ Barrier.
In order to ensure that the process 0 can synchronously transmit a quantum operation data to all node processes, the embodiment of the application optimizes the quantum operation data transmitted to the non-0 process by the process 0. And packaging the received quantum operation data mainly through the No. 0 process, and transmitting the quantum operation data to the No. 0 process. Meanwhile, after receiving the packed quantum operation data, the non-0 process performs unpacking operation to obtain the quantum operation data.
In the above operation process, specifically, the quantum operation data is packed to packbuf through packdata in the process No. 0, and the data length is packed to npacksize; the initial process firstly transmits the data length to all non-0 processes through MPI _ Bcast, and then transmits the packed quantum operation data to all non-initial processes.
The non-0 process first receives the data length through the MPI _ Bcast and receives transmitted data according to the data length.
In the quantum operation data packed by the process No. 0 and unpacked by the process No. 0, the packed data types mainly include:
quantum wires: command types, types of each quantum gate, control bits, target bits, rotation angles, quantum gate descriptions and the like are included;
single amplitude probability: including command type, amplitude index;
single qubit state probability: the method comprises the steps of command type, quantum bit index and quantum state test value; the state test value is 1 and 0;
all state value probabilities of multiple quantum bits are specified: an index array comprising command types, qubits; the state value is a state string consisting of 1 &0;
all amplitude probabilities: including a command type;
the quantum algorithm is run for multiple times: including command type, number of runs.
The quantum operation data packing method specifically comprises the following steps:
s151, packaging basic data types, wherein the basic data types comprise string, int, vector < int >, and vector < double >;
s152, packing the data length to npacksize;
and S153, packing the quantum operation data to a packbuf.
The packing string specifically comprises the following steps:
a) The length of the packing string;
b) Packing the actual content of string;
the unpacking specifically comprises the following steps:
a) Unpacking the length of string to size;
b) Unpacking the actual content of the string by size;
one embodiment of the above packing and unpacking string is as follows:
Void NodeData::packstring(const std::string& str,char* packbuf,int& packsize)
{
Int size=str.size();
MPI_Pack(&size,1,MPI_INT,packbuf,PACKSIZE,&packsize,MPI_COMM_WORLD);
MPI_pack(str.c_str(),size,MPI_CHAR,packbuf,PACKSIZE,&packsize, MPI_COMM_WORLD);
}
Void NodeData::unpackstring(std::string& str,char* packbuf,int& packsize)
{
Int size=0;
MPI_Unpack(packbuf,packsize,&m_position,&size,1,MPI_INT,MPI_COMM_WORLD);
Std::unique_ptr<char[]> autostr(new char[size+1]{0});
MPI_Unpack(packbuf,packsize,&m_position,(void*)autostr.get(),size ,MPI_CHAR,MPI_COMM_WORLD);
Str=autostr.get();
}
packaging int specifically includes: directly packaging pint;
the unpacking int specifically comprises: unpacking data directly to pint;
one embodiment of the above int packaging and unpacking method is as follows:
Void NodeData::packint(const int& pint,char* packbuf,int& packsize)
{
MPI_Pack(&pint,1,MPI_INT,packbuf,PACKSIZE,&packsize,MPI_COMM_WORLD);
}
Void NodeData::unpackint(iny& pint,char* packbuf,int& packsize)
{
Int size=0;
MPI_Unpack(packbuf,packsize,&m_position,&pint,1,MPI_INT,MPI_COMM_WORLD);
}
the packaging vector < int > specifically comprises:
a) Size of packed vector;
b) Packaging each int element of vector;
the unpacking vector < int > is specifically as follows:
a) Size of unpacked vector;
b) Unpacking each element inside a vector by size;
one embodiment of the above packaging and unpacking vector < int > is as follows:
Void NodeData::packvectorint(const std::vector<int>&vec,char* packbuf,int& packsize)
{
Int size=vec.size();
MPI_Pack(&size,1,MPI_INT,packbuf,PACKSIZE,&packsize,MPI_COMM_WORLD);
For(auto i:vec)
MPI_pack(&i,1,MPI_INT,packbuf,PACKSIZE,&packsize, MPI_COMM_WORLD);
}
Void NodeData::unpackvectorint(std::vector<int>& vec,char* packbuf,int& packsize)
{
Int size=0;
MPI_Unpack(packbuf,packsize,&m_position,&size,1,MPI_INT,MPI_COMM_WORLD);
For(int i=0,i<size;i++)
{
Int cntrobit=0;
MPI_Unpack(packbuf,packsize,&m_position,&controlbit,1,MPI_INT,MPI_COMM_WORLD);
Vec.push_back(controlbit);
}
the packing vector < double > is specifically:
a) Size of packed vector;
b) Packing each double element of the vector;
the unpacking vector is specifically as follows:
a) Unpacking the size of the vector;
b) Each element inside the vector is unpacked by size.
One embodiment of the above packing and unpacking vector < double > is as follows:
Void NodeData::packvectordouble(const std::vector<double>&vec,char* packbuf,int& packsize)
{
Int size=vec.size();
MPI_Pack(&size,1,MPI_INT,packbuf,PACKSIZE,&packsize,MPI_COMM_WORLD);
For(auto i:vec)
MPI_pack(&i,1,MPI_DOUBLE,packbuf,PACKSIZE,&packsize, MPI_COMM_WORLD);
}
Void NodeData::unpackvectordouble(std::vector<double>& vec,char* packbuf,int& packsize)
{
Int size=0;
MPI_Unpack(packbuf,packsize,&m_position,&size,1,MPI_INT,MPI_COMM_WORLD);
For(int i=0,i<size;i++)
{
double rotationbit=0;
MPI_Unpack(packbuf,packsize,&m_position,&controlbit,1,MPI_DOUBLE,MPI_COMM_WORLD);
Vec.push_back(rotationbit);
}
as can be seen from the above, the packed unpack vector < int > and the packed unpack vector < DOUBLE > are similar, and only the position MPI _ packet needs to be specified when the data type is specified.
After the data type is packed, the quantum operation data needs to be packed and unpacked next step, in the embodiment of the present application, a quantum circuit is used for illustration:
packaging:
a) The packed quantum operation type is CMDTYPE _ CRUCUIT;
b) The number of quantum gates contained in the packed quantum wires;
c) The specific data for packing each quantum comprises a quantum gate type, a control bit, a target, a rotation angle and a quantum gate description;
unpacking:
a) Number of unpacked quantum gates;
b) The data for each quantum is unpacked separately and added to the m _ Cmds quantum wire.
One embodiment of the above packing and unpacking quantum wire is as follows:
Void NodeData::packcircuit(const std::vector<cmd>& cmds, const int & final,char* packbuf,int& packsize)
{
//pack command type
Packcmdtype(CMDTYPE_CRICUIT,packbuf,packsize);
//pack circuit
packint(cmds.size(),packbuf,packsize);
for(auto& cmd: cmds)
{
Packsrting(cmd.gate,packbuf,packsize);
Packvectorint(cmd.controls,packbuf,packsize);
Packvectorint(cmd.targets,packbuf,packsize);
Packdouble(cmd.rotation,packbuf,packsize);
Packsrting(cmd.desc,packbuf,packsize);
}
Void NodeData::unpackcircuit(char* packbuf,int& packsize)
{
//unpack circuit
Int cmdsize=0
unpackint(cmdsize. packbuf,packsize);
For(int i=0,i<cmdsize;i++)
{
Cmd cmd;
unpacksrting(cmd.gate,packbuf,packsize);
unpackvectorint(cmd.controls,packbuf,packsize);
unpackvectorint(cmd.targets,packbuf,packsize);
unpackdouble(cmd.rotation,packbuf,packsize);
unpacksrting(cmd.desc,packbuf,packsize);
m_cmds.push_back(cmc);
}
}
after quantum operation data is packaged by the process 0, the quantum operation data is transmitted to the process not being the process 0 through the MPI _ Bcast, and the specific implementation process is as follows:
if(SINGLETON(CQuESTIniter)->m_env.rank==0)
{
Packdata(cmdtype,packbuf,npacksize);
}
MPI_Bcast(&npacksize,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(packbuf,npacksize,MPI_PACKED, 0,MPI_COMM_WORLD);
If(SINGLETON(CQuESTIniter)->m_env.rank!==0)
{
NodeData nodedata;
Unpackdata(nodedata,packbuf,npacksize);
If(nodedata.m_cmdtype@=CMDTYPE_CANCEL)
{
Execute(nodedata);
Continue;
}
}
rank =0 represents a process No. 0, that is, a process communicating with the QuTrunk front end, and when the process No. 0 receives quantum operation data transmitted from the front end, the data needs to be packed and transmitted to other node processes; packing quantum operation data into packbuf through packdata, packing the data length into npacksize, and packing cmdtype is the type of the packed data; the process No. 0 firstly transmits the length of the packed data to other node processes through the MPI _ Bcast, and then transmits the packed data to other nodes;
the non-0 process firstly receives the transmitted data length through the MPI _ Bcast and then receives the transmitted data according to the data length; rank | =0 represents a non-0 process, which is also a process that receives quantum operation data, and the non-0 process unpacks the data through unpackdata after receiving the data, and the specific unpacking process refers to the above description of packing and unpacking of the data types, which is not described again.
As shown in fig. 3, the data transmission and synchronous execution process of quantum operations on different node processes in a cluster according to the embodiment of the present application will be described in detail below. Fig. 3 is a diagram illustrating quantum wire data as an example.
The process 0 represents a main process and receives front-end quantum data, the process not 0 represents other processes in the cluster, is also called the process not 0, and receives quantum operation data sent by the process 0.
After the node process is started, judging whether the node process is a process with the bit of 0, if the node process is a process with the bit of 0, starting remote monitoring RPC to monitor quantum operation data sent by a front end Qutrunk or quantum operation data sent by the front end Qutrunk and subjected to other services (the quantum operation data of the front end Qutrunk can pass through some other services in the midway, such as a slave in figure 3, but the slave does not influence the synchronization problem of cluster nodes), and after a process which is not 0 is started, calling an MPI _ Barrier synchronization function to wait;
when the No. 0 process receives quantum operation data from the Qutrunk front end, an MPI _ Barrier synchronization function is also called, when all processes in the cluster call the MPI _ Barrier synchronization function, all processes remove synchronization waiting and continue to execute codes downwards;
the No. 0 process continues to execute downwards, packs the quantum operation data and transmits the quantum operation data to the non-0 process through the MPI _ Bcast, and the non-0 process continues to execute downwards, calls the MPI _ Bcast to synchronously wait for the data transmitted by the No. 0 process;
when the process No. 0 successfully sends the data, the process enters a stage of executing quantum operation data, and after the process No. 0 receives the successfully received data, the process No. 0 also enters a stage of executing quantum operation data;
for any quantum data operation process, such as quantum gate operation, the QuEST library will ensure that each quantum gate operation is executed synchronously in the MPI mode, for example, when an H gate is executed, all processes in the MPI cluster must execute the H gate at the same time, and the H gate will be executed, so all quantum operations can be ensured to be executed synchronously;
after the quantum operation is executed, the No. 0 process continues to wait for the quantum operation data sent from the Qutrunk front end, and the non-0 process continues to call MPI _ Barrier to synchronously wait for the No. 0 process; the operation continues until the cancel instruction sent by the front-end QuTrunk cancels the quantum operation.
According to the data synchronization method of the quantum circuit in the cluster environment, when the No. 0 process waits for quantum operation data transmitted by a quantum front-end programming framework, all non-No. 0 processes wait for an initial process at the same time by calling a synchronization function; when the No. 0 process receives the quantum operation data from the quantum front-end programming frame, the synchronous function is called, the quantum operation data are transmitted to all the No. 0 processes through packaging, the No. 0 process is ensured to accurately transmit the quantum operation data to the No. 0 processes, the quantum operation data comprise quantum circuits, quantum amplitude obtaining operation, quantum bit measuring operation and the like, and therefore all the node processes are ensured to obtain the same quantum operation data. After the process 0 transmits the quantum operation data to all the processes not being the process 0, all the node processes ensure that all the processes in the cluster are executed simultaneously through synchronous operation in any one quantum data operation process, and corresponding operation is allowed to be carried out, so that all the quantum data operations are synchronously executed. After all the quantum operation data are executed, the No. 0 process continues to wait for the quantum operation data of the Qutrunk, the No. 0 process continues to wait for the No. 0 process, and the process continues until the front end sends a cancel instruction to cancel the operation of the quantum algorithm. By the method, the quantum algorithm can be run by multiple nodes on the same host or multiple hosts regardless of single nodes without changing the existing codes.
Example 2
The embodiment of the application provides a quantum simulation system under a cluster environment, which comprises:
an initial process unit: the initial process unit is used for receiving the quantum operation data and calling a synchronization function when receiving the quantum operation data, and is also used for releasing the synchronization waiting operation after receiving the quantum operation data, packaging the quantum operation data and then broadcasting the quantum operation data to all non-initial process units through a message transmission interface specification; the initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data;
non-initial process unit: the non-initial process unit is connected with the initial process unit, and calls a synchronous function when waiting for the initial process unit to send quantum operation data, and removes synchronous waiting when all process units call the synchronous function; the non-initial process unit is also used for receiving the quantum operation data sent by the initial process unit in a packaging mode, and carrying out unpacking operation to obtain the quantum operation data; and the non-initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data.
The system further comprises a front-end quantum programming framework, wherein the quantum programming framework is connected with the initial process unit and is used for generating quantum operation data and sending the quantum operation data to the initial process unit.
In the system, the initial process unit also packs the quantum operation data into a packbuf through packdata, and packs the data length into npacksize; the initial process firstly 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;
the non-initial process unit firstly receives the data length through the MPI _ Bcast and receives the transmitted data according to the data length.
The system provided by the embodiment of the invention is used for realizing the method provided by the embodiment 1. The detailed technology that is the same as that in embodiment 1 can participate in embodiment 1, which is not described herein again.
Example 3
Based on the same inventive concept, embodiments of the present application provide a storage medium having a computer program stored thereon, where the computer program can execute the data synchronization method of the quantum wire in the cluster environment provided in embodiment 1 above when running. This embodiment is not described, and the same detailed techniques as those in embodiment 1 may be used in embodiment 1, which is not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above may be implemented by a computer program, which may be stored in a computer readable storage medium and executed by a computer to implement the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
Various other modifications and changes may occur to those skilled in the art based on the foregoing teachings and concepts, and all such modifications and changes are intended to be included within the scope of the appended claims.

Claims (10)

1. A method of data synchronization of quantum wires in a cluster environment, comprising the steps of:
s11, setting one node process in the cluster environment as an initial process, and setting the other node processes as non-initial processes; establishing the connection between the initial process and a quantum front-end programming frame, and establishing the connection between all non-initial processes and the initial process;
s12, calling a synchronous function after a non-initial process in the cluster environment is started;
s13, monitoring quantum operation data transmitted by the quantum front-end programming framework after the initial process is started, and calling a synchronous function when the quantum operation data is received;
s14, after all node processes call the synchronization function, all the node processes release the synchronization waiting operation;
s15, after receiving quantum operation data transmitted by a quantum front-end programming framework, the initial process packs the quantum operation data and transmits the packed quantum operation data to all non-initial processes;
s16, the non-initial process receives the packed quantum operation data and carries out unpacking operation to obtain the quantum operation data;
and S17, after all the node processes acquire the synchronous operation instruction, synchronously executing the same processing flow operation on the quantum operation data.
2. The method according to claim 1, wherein the step S15, specifically the initial process packs the quantum operation data into a packbuf through packdata, and packs the data length into npacksize; the initial process firstly 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.
3. The method of claim 1, wherein the initial process packs quantum operation data, specifically: the packed data types comprise quantum lines, single amplitude probabilities, single quantum bit state probabilities, all state value probabilities of specified multiple quantum bits, all amplitude probabilities, and multiple quantum algorithm operations.
4. The method of claim 3, wherein:
the quantum wire comprises 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 comprises a command type and an amplitude index;
the single-qubit state probability comprises a command type, a qubit index and a quantum state test value; the state test value is 1 and 0;
all state value probabilities of the appointed multiple quantum bit positions comprise command types and index arrays of the quantum bit positions; the state value is a state string consisting of 1 &0;
the all amplitude probabilities include a command type;
the quantum algorithm is operated for many times, wherein the operation times comprise command types.
5. The method according to claim 3 or 4, wherein the packing of the quantum operation data specifically comprises the steps of:
s151, packaging basic data types, wherein the basic data types comprise string, int, vector < int >, and vector < double >;
s152, packing the data length to npacksize;
and S153, packing the quantum operation data to a packbuf.
6. The method of claim 5,
the packing string specifically comprises the following steps: packing the actual content of string;
unpacking and string are specifically as follows: unpacking the length of string to size;
packaging int specifically includes: directly packaging pint;
the unpacking int specifically comprises: unpacking the data to pint directly;
the packaging vector < int > is specifically as follows: size of packed vector; packaging each int element of a vector;
the unpacking vector < int > is specifically as follows: unpacking the size of the vector; unpacking each element inside a vector by size;
the packing vector < double > specifically comprises: size of packed vector; packing each double element of the vector;
the unpacking vector is specifically as follows: size of unpacked vector; each element inside the vector is unpacked by size.
7. A quantum simulation system in a clustered environment, comprising:
an initial process unit: the initial process unit is used for receiving the quantum operation data and calling a synchronization function when receiving the quantum operation data, and is also used for releasing the synchronization waiting operation after receiving the quantum operation data, packaging the quantum operation data and then broadcasting the quantum operation data to all non-initial process units through a message transmission interface specification; the initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data;
non-initial process unit: the non-initial process unit is connected with the initial process unit, calls a synchronous function when waiting for the initial process unit to send quantum operation data, and releases synchronous waiting when all process units call the synchronous function; the non-initial process unit is also used for receiving the quantum operation data sent by the initial process unit in a packaging mode, and carrying out unpacking operation to obtain the quantum operation data; and the non-initial process unit is also used for synchronously executing the same processing flow on the quantum operation data according to the synchronous operation instruction after all the process units obtain the same quantum operation data.
8. The quantum simulation system in a cluster environment of claim 7, further comprising a front-end quantum programming framework connected to the initial process unit, the front-end quantum programming framework configured to generate quantum operation data and send the quantum operation data to the initial process unit.
9. The quantum simulation system in a clustered environment of claim 8,
the initial process unit is further used for packing the quantum operation data into a packbuf through packdata, and packing the data length into npacksize; the initial process firstly 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;
the non-initial process unit firstly receives the data length through the MPI _ Bcast and receives the transmitted data according to the data length.
10. A storage medium having stored thereon a computer program which, when executed, performs a method of data synchronization of a quantum wire according to any of claims 1 to 6 in a cluster environment.
CN202211003989.2A 2022-08-22 2022-08-22 Data synchronization method of quantum circuit in cluster environment and quantum simulation system Pending CN115392471A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211003989.2A CN115392471A (en) 2022-08-22 2022-08-22 Data synchronization method of quantum circuit in cluster environment and quantum simulation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211003989.2A CN115392471A (en) 2022-08-22 2022-08-22 Data synchronization method of quantum circuit in cluster environment and quantum simulation system

Publications (1)

Publication Number Publication Date
CN115392471A true CN115392471A (en) 2022-11-25

Family

ID=84120563

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211003989.2A Pending CN115392471A (en) 2022-08-22 2022-08-22 Data synchronization method of quantum circuit in cluster environment and quantum simulation system

Country Status (1)

Country Link
CN (1) CN115392471A (en)

Similar Documents

Publication Publication Date Title
US11010681B2 (en) Distributed computing system, and data transmission method and apparatus in distributed computing system
US11893424B2 (en) Training a neural network using a non-homogenous set of reconfigurable processors
Pan et al. Multi-GPU graph analytics
US11847395B2 (en) Executing a neural network graph using a non-homogenous set of reconfigurable processors
CN104536937B (en) Big data all-in-one machine realization method based on CPU GPU isomeric groups
CN106776455B (en) Single-machine multi-GPU communication method and device
WO2023040197A1 (en) Cross-node communication method and apparatus, device, and readable storage medium
CN102760114B (en) Communication emulation method, engine and system for multi-processor system
CN104360962B (en) Be matched with multistage nested data transmission method and the system of high-performance computer structure
CN116501684B (en) Server system and communication method thereof
CN115392471A (en) Data synchronization method of quantum circuit in cluster environment and quantum simulation system
CN109358820B (en) Data access method and device, electronic equipment and computer readable storage medium
US20220269622A1 (en) Data processing methods, apparatuses, electronic devices and computer-readable storage media
CN115374052A (en) Task processing method and device for reconfigurable cipher array
CN113553279B (en) RDMA communication acceleration set communication method and system
CN115292044A (en) Data processing method and device, electronic equipment and storage medium
JP7298008B2 (en) Systems, methods and apparatus for developing smart contracts
CN113688352B (en) Data processing system, method and device
CN117573375B (en) Dynamic load balance parallel computing method oriented to self-adaptive decoupling equation
US20220391666A1 (en) Distributed Deep Learning System and Distributed Deep Learning Method
CN116662037B (en) Processing method and device for shared memory, electronic equipment and storage medium
CN107562686A (en) Information processing method and device
CN117648283A (en) Inter-core network communication method and device for multi-core heterogeneous and electronic equipment
US20240111694A1 (en) Node identification allocation in a multi-tile system with multiple derivatives
CN117857664A (en) Metadata-based method and system for developing low codes of communication protocol of edge equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination