A method and apparatus for multi-gpu analog quantum computing
Patent Information
- Application Number
- CN202210721076.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2042-06-23
AI Technical Summary
但物理量子计算机的实际制造难度大、制造成本高,并且现有量子计算机资源有限,难以满足实际的社会需求,因此根据量子计算原理采用GPU对量子计算机的实际计算过程进行模拟,用以解决量子计算机的需求难题,成为正在研究的一项关键技术
[0057]与现有技术相比,本发明首先接收终端服务器发送的待模拟量子线路,并确定待模拟量子线路的线路信息,根据线路信息、多个GPU的硬件参数信息以及初始化多个GPU的状态信息,确定待模拟量子线路的GPU内存分配方案,基于GPU内存分配方案,执行待模拟量子线路的计算,并发送模拟计算结果至终端服务器,它能够利用多GPU模拟量子计算,提供一种结合GPU间数据传输性能动态规划量子态内存存储方案,以实现量子计算的模拟。
Smart Images

Figure CN117331680B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quantum computing technology, and in particular to a method and apparatus for simulating quantum computing using multiple GPUs. Background Technology
[0002] In the field of quantum computing, as the complexity of research problems gradually increases, the demand for quantum computers is also growing. However, the actual manufacturing of physical quantum computers is difficult and costly, and existing quantum computer resources are limited, making it difficult to meet practical social needs. Therefore, using GPUs to simulate the actual computation process of quantum computers based on the principles of quantum computing to address the challenges of meeting the demand for quantum computers has become a key technology under research.
[0003] However, in quantum computing, as the number of qubits increases, the number of superimposed quantum states grows exponentially. Therefore, when using GPUs for simulation, the number of quantum states that need to be stored and the number of operations that need to be performed also grow exponentially. However, the number of threads that can run in parallel on each GPU at the same time and the memory of the GPU are limited, which limits the number of qubits that the GPU can simulate and affects the simulation efficiency. How to use multiple GPUs to simulate quantum computing is an urgent problem to be solved. Summary of the Invention
[0004] The purpose of this invention is to provide a method and apparatus for simulating quantum computing using multiple GPUs, in order to overcome the shortcomings of the prior art. It can provide a dynamic planning quantum state storage scheme that combines the data transfer performance between GPUs, thereby improving the computing performance of complex quantum circuits.
[0005] One embodiment of this application provides a method for simulating quantum computing using multiple GPUs, applied to a distributed computing cluster, the computing cluster including a terminal server and multiple GPUs communicatively connected to the terminal server, the method comprising:
[0006] Receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated;
[0007] Based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs, the GPU memory allocation scheme for the quantum circuit to be simulated is determined.
[0008] Based on the GPU memory allocation scheme, the calculation of the quantum circuit to be simulated is performed, and the simulation calculation results are sent to the terminal server.
[0009] Optionally, receiving the quantum circuit to be simulated sent by the terminal server and determining the circuit information of the quantum circuit to be simulated includes:
[0010] Based on the quantum circuit to be simulated, obtain the number of qubits;
[0011] Based on the number of qubits, calculate the number of quantum states to be simulated and the maximum number of quantum state operands required using a preset method. The preset method includes one of the following: full-amplitude simulation calculation method, partial-amplitude simulation calculation method, and single-amplitude simulation calculation method.
[0012] Optionally, the initialization of the state information of multiple GPUs includes:
[0013] Obtain the number of nodes of the multiple GPUs, the number of GPUs per node, the number of cores per GPU, and the maximum number of parallel threads per GPU;
[0014] The system communicates with each GPU and obtains the current free memory of each GPU as well as the data transfer rate between the GPUs.
[0015] Optionally, determining the GPU memory allocation scheme for the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization state information of multiple GPUs includes:
[0016] Determine whether a target GPU exists, wherein the maximum number of parallel threads of the target GPU is not less than the maximum number of quantum state operations;
[0017] If not, then it is further determined whether the current free memory of multiple GPUs in the computing cluster can realize all quantum state simulations;
[0018] If the current free memory of multiple GPUs in the computing cluster can realize the simulation of all quantum states, then calculate the first execution time when all quantum states are evenly distributed in the free memory of each GPU and the second execution time when all quantum states first occupy the free memory of a single GPU and then occupy the free memory of other GPUs. The first execution time and the second execution time are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information, and the number of quantum states.
[0019] Based on the first execution time and the second execution time, a GPU memory allocation scheme for the quantum circuit to be simulated is determined.
[0020] Optionally, the method further includes:
[0021] If the target GPU exists, determine whether the current free memory of the target GPU can realize all the quantum state simulations;
[0022] If so, all quantum states are stored in the free memory of the target GPU to achieve multi-GPU simulated quantum computing.
[0023] Optionally, the method further includes:
[0024] If the current free memory of the target GPU is insufficient to simulate all quantum states, then the step of further determining whether the current free memory of multiple GPUs in the computing cluster can simulate all quantum states continues.
[0025] Optionally, the method further includes:
[0026] If the current free memory of multiple GPUs in the computing cluster is insufficient to simulate all quantum states, an error message will be output and displayed.
[0027] Optionally, determining the GPU memory allocation scheme for the quantum circuit to be simulated based on the first execution time and the second execution time includes:
[0028] If the first execution time is not greater than the second execution time, then all quantum states are evenly distributed among the current free memory of multiple GPUs in the computing cluster;
[0029] If the first execution time is greater than the second execution time, then all quantum states will be used to fill the free memory of a single GPU before using other GPUs.
[0030] Another embodiment of this application provides a device for simulating quantum computing using multiple GPUs, applied to a distributed computing cluster. The computing cluster includes a terminal server and multiple GPUs communicatively connected to the terminal server. The device includes:
[0031] A receiving module is used to receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated, wherein the circuit information includes the maximum number of quantum state operands.
[0032] The determination module is used to determine the GPU memory allocation scheme of the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs.
[0033] The sending module is used to perform calculations on the quantum circuit to be simulated based on the GPU memory allocation scheme, and send the simulation calculation results to the terminal server.
[0034] Optionally, the receiving module includes:
[0035] The first acquisition unit is used to obtain the number of qubits based on the quantum circuit to be simulated;
[0036] The first computing unit is used to calculate the number of quantum states to be simulated and the maximum number of quantum state operands to be simulated using a preset method, based on the quantum bit number information. The preset method includes one of the following: full amplitude simulation calculation method, partial amplitude simulation calculation method and single amplitude simulation calculation method.
[0037] Optionally, the determining module includes:
[0038] The second obtaining unit is used to obtain the number of nodes of the multiple GPUs, the number of GPUs in each node, the number of cores in each GPU, and the maximum number of parallel threads in each GPU;
[0039] The third acquisition unit is used to communicate with each GPU and obtain the current free memory of each GPU and the data transfer rate between the GPUs.
[0040] Optionally, the determining module includes:
[0041] The first judgment unit is used to determine whether a target GPU exists, wherein the maximum number of parallel threads of the target GPU is not less than the maximum number of quantum state operations;
[0042] The second judgment unit is used to further determine whether the current free memory of multiple GPUs in the computing cluster can realize all quantum state simulations if not.
[0043] The second computing unit is configured to calculate, if the current free memory of multiple GPUs in the computing cluster can realize the simulation of all quantum states, a first execution time in which all quantum states are evenly distributed across the free memory of each GPU and a second execution time in which all quantum states first occupy the free memory of a single GPU and then occupy the free memory of other GPUs, wherein the first execution time and the second execution time are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information, and the number of quantum states;
[0044] The first determining unit is configured to determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the first execution time and the second execution time.
[0045] Optionally, the determining module further includes:
[0046] The third judgment unit is used to determine whether the current free memory of the target GPU can realize all the quantum state simulations if the target GPU exists.
[0047] The first storage unit is used to store all the quantum states in the free memory of the target GPU if the conditions are met, so as to realize multi-GPU simulated quantum computing.
[0048] Optionally, the determining module further includes:
[0049] The return unit is used to continue executing the step of further determining whether the current free memory of multiple GPUs in the computing cluster can realize all quantum state simulations if the current free memory of the target GPU cannot realize all quantum state simulations.
[0050] Optionally, the determining module further includes:
[0051] The output unit is used to output and display an error message if the current free memory of multiple GPUs in the computing cluster is insufficient to simulate all quantum states.
[0052] Optionally, the first determining unit includes:
[0053] The averaging unit is used to evenly distribute all quantum states across the current free memory of multiple GPUs in the computing cluster if the first execution time is not greater than the second execution time.
[0054] The sub-unit is prioritized to be fully occupied. If the first execution time is greater than the second execution time, all quantum states will be prioritized to fill the free memory of a single GPU before occupying other GPUs.
[0055] Another embodiment of this application provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.
[0056] Another embodiment of this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in any of the preceding claims.
[0057] Compared with existing technologies, this invention first receives the quantum circuit to be simulated sent by the terminal server and determines the circuit information of the quantum circuit to be simulated. Based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization state information of multiple GPUs, it determines the GPU memory allocation scheme of the quantum circuit to be simulated. Based on the GPU memory allocation scheme, it executes the calculation of the quantum circuit to be simulated and sends the simulation calculation result to the terminal server. It can use multiple GPUs to simulate quantum computing and provides a quantum state memory storage scheme that combines the data transmission performance between GPUs to achieve the simulation of quantum computing. Attached Figure Description
[0058] Figure 1 This is a hardware structure block diagram of a computer terminal for a multi-GPU simulated quantum computing method provided in an embodiment of the present invention;
[0059] Figure 2 This is a flowchart illustrating a method for simulating quantum computing using multiple GPUs, provided in an embodiment of the present invention.
[0060] Figure 3 A schematic diagram of the overall framework of a multi-GPU simulated quantum computing method provided in an embodiment of the present invention;
[0061] Figure 4 This is a schematic diagram of the structure of a multi-GPU simulated quantum computing device provided in an embodiment of the present invention. Detailed Implementation
[0062] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0063] This invention first provides a method for simulating quantum computing using multiple GPUs. This method can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
[0064] The following detailed explanation uses a computer terminal as an example. Figure 1 This is a hardware structure block diagram of a computer terminal for a multi-GPU simulated quantum computing method provided in an embodiment of the present invention. Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0065] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / modules corresponding to the implementation of a multi-GPU simulated quantum computing method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0066] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0067] It's important to note that a true quantum computer has a hybrid structure, comprising two main parts: a classical computer responsible for performing classical computations and control, and a quantum device responsible for running quantum programs to achieve quantum computation. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can run on a quantum computer, supporting operations on quantum logic gates and ultimately enabling quantum computing. Specifically, a quantum program is a sequence of instructions that operates on quantum logic gates according to a specific timing order.
[0068] In practical applications, due to limitations in the development of quantum device hardware, quantum computing simulations are often required to verify quantum algorithms, quantum applications, and so on. Quantum computing simulation is the process of simulating the execution of a quantum program corresponding to a specific problem using a virtual architecture (i.e., a quantum virtual machine) built with the resources of a regular computer. Typically, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program referred to in this embodiment of the invention is a program written in a classical language that represents qubits and their evolution, wherein qubits, quantum logic gates, etc., related to quantum computing all have corresponding classical code representations.
[0069] Quantum circuits, also known as quantum logic circuits, are a common manifestation of quantum programming and are the most widely used general-purpose quantum computing model. They represent circuits that operate on qubits under an abstract concept. They consist of qubits, circuits (timelines), and various quantum logic gates. Finally, the results are often read out through quantum measurement operations.
[0070] Unlike traditional circuits that use metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as being connected by time. That is, the state of a quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
[0071] A quantum program corresponds to a single quantum circuit. The quantum program described in this invention refers to this single quantum circuit, where the total number of qubits in the single quantum circuit is the same as the total number of qubits in the quantum program. This can be understood as follows: a quantum program can consist of a quantum circuit, measurement operations on the qubits within the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A single quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution of a quantum program is the process of executing all the quantum logic gates in a specific timing order. It should be noted that the timing order refers to the chronological sequence in which individual quantum logic gates are executed.
[0072] It's important to note that in classical computing, the most basic unit is the bit, and the most fundamental control mode is the logic gate. Circuit control can be achieved through combinations of logic gates. Similarly, the way to process qubits is through quantum logic gates. Quantum logic gates enable the evolution of quantum states and are the foundation of quantum circuits. Quantum logic gates include single-qubit gates, such as Hadamard gates (H-gates), Pauli-X gates (X-gates), Pauli-Y gates (Y-gates), Pauli-Z gates (Z-gates), RX gates, RY gates, RZ gates, etc.; and multi-qubit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, Tofoli gates, etc. Quantum logic gates are generally represented using unitary matrices, which are not only matrix forms but also operations and transformations. The effect of a quantum logic gate on a quantum state is generally calculated by left-multiplying the unitary matrix by the matrix corresponding to the right vector of the quantum state.
[0073] As those skilled in the art will understand, in classical computers, the basic unit of information is the bit, which has two states: 0 and 1. The most common physical implementation uses high and low voltage levels to represent these states. In quantum computing, the basic unit of information is the qubit, which also has two states: 0 and 1, denoted as |0> and |1>. However, it can exist in a superposition of these two states, which can be represented as... Here, a and b are complex numbers representing the amplitudes (probability amplitudes) of the |0> and |1> states, respectively, which is not present in classical bits. After measurement, the state of a quantum bit collapses to a definite state (eigenstate, here |0> and |1>), where the probability of collapsing to |0> is |a|. 2 The probability of collapsing to |1> is |b|. 2 , |a| 2 +|b| 2 =1, |> is the Dirac notation.
[0074] A quantum state refers to the state of a qubit (or quantum bit). Its eigenstates are represented in binary form in quantum algorithms (or quantum programs). For example, a set of qubits q0, q1, and q2, representing the 0th, 1st, and 2nd qubits respectively, ordered from most significant bit to least significant bit as q2q1q0, has a quantum state of 2q1q ... 3 A quantum state is a superposition of 8 eigenstates. The 8 eigenstates (definite states) are: |000>, |001>, |010>, |011>, |100>, |101>, |110>, and |111>. Each eigenstate corresponds to a qubit. For example, in the |000> state, 000 corresponds to q2q1q0 from the highest to the lowest bit. In short, a quantum state is a superposition of eigenstates. When the probability amplitude of other states is 0, the state is in one of the definite eigenstates.
[0075] In quantum computing, the number of superimposed quantum states increases exponentially with the increase of qubits. Current technologies employ memory allocation schemes using CPUs, single GPUs, or evenly distributed quantum states across multiple GPUs. When using a CPU for simulation, the limited parallel computing capability of the CPU results in low performance for simulating large numbers of qubits. Using a single GPU, the parallel computing capability and memory size of the GPU limit the size of the qubits that can be simulated and the computation time. When evenly distributing quantum states across multiple GPUs, the quantum states are stored evenly across the global memory of multiple GPUs. For multi-quantum gate operations, frequent data transfers across GPUs are required, which can severely degrade computational performance when hardware performance is insufficient.
[0076] This application combines quantum computing principles, GPU parallel computing, and communication technology to realize a method for multi-GPU simulated quantum computing, which expands the qubit size of GPU simulated computing and improves the computing speed. It has important practical significance for solving the demand problems of quantum computers.
[0077] See Figure 2 , Figure 2 A flowchart illustrating a method for simulating quantum computing using multiple GPUs, provided in an embodiment of the present invention, may include the following steps:
[0078] S201: Receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated.
[0079] Specifically, a method for simulating quantum computing using multiple GPUs is applied to a distributed computing cluster. The cluster can include a terminal server and multiple GPUs communicating with it. The terminal server can be a CPU server that receives quantum programs from clients. The CPU server itself may or may not have GPUs. It connects to other GPU hosts, and each host can have one or more GPUs. Each host connected to the terminal server can be considered a node. Each node needs a CPU for control, and can have multiple GPUs or only one GPU. The GPUs themselves cannot perform data interaction or forwarding. The distributed computing cluster can support multi-node and single-node (only one host, which can have one or more GPUs) configurations. The overall hardware structure can be a variety of selectable combinations, such as including one or more nodes, and / or each node containing one or more GPUs.
[0080] Specifically, receiving the quantum circuit to be simulated sent by the terminal server and determining the circuit information of the quantum circuit to be simulated may include:
[0081] Step 1: Obtain the number of qubits based on the quantum circuit to be simulated.
[0082] Step 2: Based on the number of qubits, calculate the number of quantum states to be simulated and the maximum number of quantum state operands required using a preset method. The preset method includes one of the following: full-amplitude simulation calculation method, partial-amplitude simulation calculation method, and single-amplitude simulation calculation method.
[0083] Specifically, by determining the number of qubits in the quantum circuit to be simulated, the number of quantum states can be determined. For example, if the quantum circuit to be simulated contains 10 qubits, then the number of quantum states is 2^32. 10 The maximum number of quantum state operands is the number of quantum states divided by 2.
[0084] The preset calculation method includes one of the following: full amplitude simulation calculation method, partial amplitude simulation calculation method, and single amplitude simulation calculation method.
[0085] For example, in full-amplitude simulation computing, the memory required increases exponentially with the number of qubits; configuring 10 qubits requires 16Kbytes of memory. Furthermore, full-amplitude simulation quantum computing can employ a serial computing method, such as breaking down a large computational task and distributing it evenly across multiple computing nodes, with each node performing serial computation simultaneously. The full-amplitude simulation computing method can include: obtaining the quantum program to be simulated to each computing node, where the quantum program can be stored in a linked list; configuring and initializing the quantum states stored on each computing node based on the number of qubits required to execute the quantum program and the number of computing nodes; traversing the linked list of the quantum program within each computing node; and executing the quantum operation instructions stored in the current node for each traversed quantum program node, until all nodes in the linked list have been traversed, thus completing the full-amplitude quantum computing simulation.
[0086] S202: Based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs, determine the GPU memory allocation scheme for the quantum circuit to be simulated.
[0087] Specifically, the hardware parameters of the computing cluster, such as GPU memory frequency and memory bus width, are obtained. The bandwidth can then be calculated by multiplying the GPU memory frequency by the memory bus width, where the bus width represents the number of data bits transmitted at a time, and the bandwidth represents the number of data bits transmitted per second. Initializing the state information of multiple GPUs may include:
[0088] 1. Obtain the number of nodes of the multiple GPUs, the number of GPUs in each node, the number of cores in each GPU, and the maximum number of parallel threads in each GPU.
[0089] 2. Establish communication connections between the GPUs and obtain the current free memory of each GPU and the data transfer rate between the GPUs.
[0090] The number of nodes is the core of a multi-node cluster, while the number of GPUs and cores are the core of multi-GPU allocation. Multi-GPU allocation is based on the amount of data to be allocated and the number of GPUs. A GPU can have multiple processors, typically 82 to 128. Each processor supports a series of parallel threads, which are logically divided into GPU cores. For example, the RTX 3090 has over 10,000. Logically, each core can handle 32 parallel threads simultaneously. The computing performance of each GPU is determined by the number of GPU cores, the number of parallel threads per core, the base frequency, memory frequency, memory bandwidth, and memory size. The maximum number of parallel threads for a GPU is the number of cores (i.e., hardware-level SMs; software-level Cores are 64 to 512 times the number of hardware-level cores) multiplied by the number of threads allowed per core. However, this total number of threads is not executed simultaneously but in batches. Typically, each software core has 32 threads in a batch (represented by `wrap`), but in actual execution, 16 threads may be executed at a time, followed by the remaining 16. The maximum number of parallel threads and the actual number of parallel threads are not the same. The maximum is what is allowed and can be handled at the logical level, but in actual execution, the maximum number of parallel threads needs to be executed step by step. For example, a SM may logically allow a maximum number of parallel threads of more than 1,500, and there are 82 SMs, each with 128 logical cores, for a total of more than 10,000 logical cores. Each logical core can run 32 threads in parallel (wrap), but in reality, only 16 threads are executed at the same time.
[0091] GPUs can be directly connected, or existing connections can be established. Peer-to-Peer technology enables direct communication between GPUs. While individual GPUs can communicate directly, for example via CPU, PCIe, or network interface card (NIC), not every two GPUs can communicate directly. This is because direct communication requires the same memory address allocation method. Peer-to-Peer technology enables unified addressing and provides directionality, allowing for collaborative computation between GPUs. By connecting the GPUs, Peer-to-Peer communication can be achieved between any two GPUs (when there are more than one GPU), and the data transfer rate between GPUs can be obtained (or calculated) (or not, as the default cross-GPU data transfer rate is within an acceptable range).
[0092] Specifically, determining the GPU memory allocation scheme for the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization state information of multiple GPUs may include:
[0093] a. Determine whether a target GPU exists, wherein the maximum number of parallel threads of the target GPU is not less than the maximum number of quantum state operations;
[0094] b. If not, then further determine whether the current free memory of the multiple GPUs in the computing cluster can realize all quantum state simulations.
[0095] c. If the current free memory of multiple GPUs in the computing cluster can realize the simulation of all quantum states, then calculate the first execution time when all quantum states are evenly distributed in the free memory of each GPU and the second execution time when all quantum states first occupy the free memory of a single GPU and then occupy the free memory of other GPUs, wherein the first execution time and the second execution time are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information and the number of quantum states.
[0096] d. Determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the first execution time and the second execution time.
[0097] For details, see Figure 3 , Figure 3 This is a schematic diagram of the overall framework of a multi-GPU quantum computing simulation method provided by an embodiment of the present invention. The GPU memory allocation scheme of the quantum program to be simulated can be determined based on hardware parameter information, GPU state information, number of quantum states and maximum number of quantum state operations.
[0098] Specifically, determining the GPU memory allocation scheme for the quantum circuit to be simulated based on the first execution time and the second execution time may include:
[0099] If the first execution time is not greater than the second execution time, then all quantum states are evenly distributed among the current free memory of multiple GPUs in the computing cluster;
[0100] If the first execution time is greater than the second execution time, then all quantum states will be used to fill the free memory of a single GPU before using other GPUs.
[0101] Specifically, if the first execution time is not greater than the second execution time, then all quantum states are evenly distributed across the current free memory of all GPUs in the computing cluster;
[0102] If the first execution time is greater than the second execution time, then all quantum states will be used to fill the free memory of a single GPU before using other GPUs.
[0103] It should be noted that execution time can fluctuate even for the same program, depending on GPU hardware parameters, inter-GPU data transfer rate, and the number of quantum states (or maximum quantum state operands). Analyzing the GPU's memory frequency and bandwidth helps determine the speed of cross-GPU data transfer. This analysis should also consider the total number of threads, distributing threads across multiple GPUs to reduce time and increase cross-GPU read time (while also taking into account the reduction in data read). Key factors include GPU memory frequency, memory bandwidth, inter-GPU data transfer rate, total number of quantum states (or maximum quantum state operands), and the number of GPUs allocated (the more GPUs N allocated to the total data, the more data needs to be read across GPUs; on average, (N-1) / N data needs to be read).
[0104] If the target GPU exists, it is determined whether the current free memory of the target GPU can realize the simulation of all quantum states. If so, all quantum states are stored in the free memory of the target GPU to realize multi-GPU simulated quantum computing.
[0105] If the current free memory of the target GPU is insufficient to simulate all quantum states, then the step of further determining whether the current free memory of multiple GPUs in the computing cluster can simulate all quantum states continues.
[0106] If the current free memory of multiple GPUs in the computing cluster is insufficient to simulate all quantum states, an error message will be output and displayed.
[0107] For example, based on the size of the qubits, the system analyzes the amount of data required to store the full-amplitude quantum states and checks whether the available memory on the currently idle GPUs meets the memory allocation scheme. If the number of quantum states is less than the number of GPU parallel operation threads, the data is directly allocated to a single GPU. Otherwise, the system analyzes whether the computational performance of evenly distributing the quantum states across multiple GPUs is higher than that of prioritizing full GPU memory, considering memory copy speed, and selects the scheme with the optimal computational performance. For the case where the quantum states are distributed across multiple GPUs, the system further analyzes whether copying the data to the GPU performing the operation beforehand is better than the default operation method, considering inter-GPU data transfer performance and the waiting time during thread parallelism, and selects the optimal method. After the quantum logic gate operation is completed, the system returns the processing result to the caller and releases the GPU resources occupied.
[0108] For example, if the number of qubits is b, the memory required to store one quantum state is m, the number of GPU cores is core, the number of parallel threads is w, the memory frequency is r, the bandwidth is width, the available free memory per GPU is f, the total available free memory is F, the number of GPUs used across GPUs is count, and the data transfer rate between GPUs is v, then the overall memory allocation rules are as follows:
[0109] First, determine if condition 2 is met. b-1 If the value is less than or equal to (core × w) ÷ 2, then further check if the condition 2 is met. b If ×m≤f, then all quantum states are stored on a single GPU. If 2 b-1 If the value is greater than (core × w) ÷ 2, then further determine whether the condition 2 is met. b If ×m≤F, it indicates insufficient memory, and the process exits immediately. If it is satisfied, further check if (count-1)×(r×width)÷(count) is satisfied. 2 ×v 2 If ≥ 1, then all quantum states will first occupy the free memory of a single GPU before occupying other GPUs; otherwise, all quantum states will be evenly distributed among the current free memory of all GPUs in the computing cluster. b If ×m>f, then proceed to further determine whether condition 2 is satisfied. b The steps for ×m≤F.
[0110] As can be seen, the present invention first receives the quantum circuit to be simulated sent by the terminal server and determines the circuit information of the quantum circuit to be simulated. Based on the circuit information, the hardware parameter information of multiple GPUs and the initialization state information of multiple GPUs, the GPU memory allocation scheme of the quantum circuit to be simulated is determined. Based on the GPU memory allocation scheme, the calculation of the quantum circuit to be simulated is executed, and the simulation calculation result is sent to the terminal server. It can use multiple GPUs to simulate quantum computing and provides a quantum state memory storage scheme that combines the data transmission performance between GPUs to achieve the simulation of quantum computing.
[0111] See Figure 4 , Figure 4 This is a schematic diagram of the structure of a multi-GPU simulated quantum computing device provided in an embodiment of the present invention. Figure 2 The process shown can include:
[0112] The receiving module 401 is used to receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated, wherein the circuit information includes the maximum number of quantum state operands.
[0113] The determining module 402 is used to determine the GPU memory allocation scheme of the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs.
[0114] The sending module 403 is used to perform calculations on the quantum circuit to be simulated based on the GPU memory allocation scheme, and send the simulation calculation results to the terminal server.
[0115] Specifically, the receiving module includes:
[0116] The first acquisition unit is used to obtain the number of qubits based on the quantum circuit to be simulated;
[0117] The first computing unit is used to calculate the number of quantum states to be simulated and the maximum number of quantum state operands to be simulated using a preset method, based on the quantum bit number information. The preset method includes one of the following: full amplitude simulation calculation method, partial amplitude simulation calculation method and single amplitude simulation calculation method.
[0118] Specifically, the determining module includes:
[0119] The second obtaining unit is used to obtain the number of nodes of the multiple GPUs, the number of GPUs in each node, the number of cores in each GPU, and the maximum number of parallel threads in each GPU;
[0120] The third acquisition unit is used to communicate with each GPU and obtain the current free memory of each GPU and the data transfer rate between the GPUs.
[0121] Specifically, the determining module includes:
[0122] The first judgment unit is used to determine whether a target GPU exists, wherein the maximum number of parallel threads of the target GPU is not less than the maximum number of quantum state operations;
[0123] The second judgment unit is used to further determine whether the current free memory of multiple GPUs in the computing cluster can realize all quantum state simulations if not.
[0124] The second computing unit is configured to calculate, if the current free memory of multiple GPUs in the computing cluster can realize the simulation of all quantum states, a first execution time in which all quantum states are evenly distributed across the free memory of each GPU and a second execution time in which all quantum states first occupy the free memory of a single GPU and then occupy the free memory of other GPUs, wherein the first execution time and the second execution time are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information, and the number of quantum states;
[0125] The first determining unit is configured to determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the first execution time and the second execution time.
[0126] Specifically, the determining module further includes:
[0127] The third judgment unit is used to determine whether the current free memory of the target GPU can realize all the quantum state simulations if the target GPU exists.
[0128] The first storage unit is used to store all the quantum states in the free memory of the target GPU if the conditions are met, so as to realize multi-GPU simulated quantum computing.
[0129] Specifically, the determining module further includes:
[0130] The return unit is used to continue executing the step of further determining whether the current free memory of multiple GPUs in the computing cluster can realize all quantum state simulations if the current free memory of the target GPU cannot realize all quantum state simulations.
[0131] Specifically, the determining module further includes:
[0132] The output unit is used to output and display an error message if the current free memory of multiple GPUs in the computing cluster is insufficient to simulate all quantum states.
[0133] Specifically, the first determining unit includes:
[0134] The averaging unit is used to evenly distribute all quantum states across the current free memory of multiple GPUs in the computing cluster if the first execution time is not greater than the second execution time.
[0135] The sub-unit is prioritized to be fully occupied. If the first execution time is greater than the second execution time, all quantum states will be prioritized to fill the free memory of a single GPU before occupying other GPUs.
[0136] Compared with existing technologies, this invention first receives the quantum circuit to be simulated sent by the terminal server and determines the circuit information of the quantum circuit to be simulated. Based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization state information of multiple GPUs, it determines the GPU memory allocation scheme of the quantum circuit to be simulated. Based on the GPU memory allocation scheme, it executes the calculation of the quantum circuit to be simulated and sends the simulation calculation result to the terminal server. It can use multiple GPUs to simulate quantum computing and provides a quantum state memory storage scheme that combines the data transmission performance between GPUs to achieve the simulation of quantum computing.
[0137] This invention also provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the method embodiments described above when running.
[0138] Specifically, in this embodiment, the storage medium can be configured to store a computer program for performing the following steps:
[0139] S201: Receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated;
[0140] S202: Determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs;
[0141] S203: Based on the GPU memory allocation scheme, perform the calculation of the quantum circuit to be simulated, and send the simulation calculation results to the terminal server.
[0142] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0143] This invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the method embodiments described above.
[0144] Specifically, the aforementioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the aforementioned processor, and the input / output device is connected to the aforementioned processor.
[0145] Specifically, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0146] S201: Receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated;
[0147] S202: Determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the circuit information, the hardware parameter information of multiple GPUs, and the initialization status information of multiple GPUs;
[0148] S203: Based on the GPU memory allocation scheme, perform the calculation of the quantum circuit to be simulated, and send the simulation calculation results to the terminal server.
[0149] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.
Claims
1. A method for simulating quantum computing using multiple GPUs, characterized in that, Applied to a distributed computing cluster, the computing cluster including a terminal server and multiple GPUs communicatively connected to the terminal server, the method includes: The system receives the quantum circuit to be simulated from the terminal server and determines the circuit information of the quantum circuit to be simulated; wherein, the circuit information includes the maximum number of quantum state operands. Based on the circuit information, hardware parameter information of multiple GPUs, and initialization status information of multiple GPUs, a GPU memory allocation scheme for the quantum circuit to be simulated is determined. This includes calculating, under the condition that there is no target GPU with a maximum number of parallel threads not less than the maximum number of quantum state operations, and the current free memory of multiple GPUs in the computing cluster can realize the simulation of all quantum states, a first execution time for all quantum states to be evenly distributed among the free memory of each GPU and a second execution time for all quantum states to first fill the free memory of a single GPU before occupying the free memory of other GPUs. The first execution time and the second execution time are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information, and the number of quantum states. If the first execution time is not greater than the second execution time, then all quantum states are evenly distributed among the current free memory of multiple GPUs in the computing cluster. If the first execution time is greater than the second execution time, then all quantum states are first filled into the free memory of a single GPU before occupying the free memory of other GPUs. Based on the GPU memory allocation scheme, the calculation of the quantum circuit to be simulated is performed, and the simulation calculation results are sent to the terminal server.
2. The method according to claim 1, characterized in that, The receiving terminal server sends the quantum circuit to be simulated, and determines the circuit information of the quantum circuit to be simulated, including: Based on the quantum circuit to be simulated, obtain the number of qubits; Based on the number of qubits, calculate the number of quantum states to be simulated and the maximum number of quantum state operands required using a preset method. The preset method includes one of the following: full-amplitude simulation calculation method, partial-amplitude simulation calculation method, and single-amplitude simulation calculation method.
3. The method according to claim 1, characterized in that, The initialization of the state information of multiple GPUs includes: Obtain the number of nodes of the multiple GPUs, the number of GPUs per node, the number of cores per GPU, and the maximum number of parallel threads per GPU; The system communicates with each GPU and obtains the current free memory of each GPU as well as the data transfer rate between the GPUs.
4. The method according to claim 1, characterized in that, The method further includes: If the target GPU exists, determine whether the current free memory of the target GPU can realize all the quantum state simulations; If so, all quantum states are stored in the free memory of the target GPU to achieve multi-GPU simulated quantum computing.
5. The method according to claim 1, characterized in that, The method further includes: If the current free memory of the target GPU cannot realize all the quantum state simulations, then it is determined whether the current free memory of multiple GPUs in the computing cluster can realize all the quantum state simulations.
6. The method according to claim 5, characterized in that, The method further includes: If the current free memory of multiple GPUs in the computing cluster is insufficient to simulate all quantum states, an error message will be output and displayed.
7. A device for simulating quantum computing using multiple GPUs, characterized in that, The device is applied to a distributed computing cluster, the computing cluster including a terminal server and multiple GPUs communicatively connected to the terminal server, and includes: A receiving module is used to receive the quantum circuit to be simulated sent by the terminal server and determine the circuit information of the quantum circuit to be simulated, wherein the circuit information includes the maximum number of quantum state operands. A determination module is used to determine the GPU memory allocation scheme for the quantum circuit to be simulated based on the circuit information, hardware parameter information of multiple GPUs, and initialization state information of multiple GPUs. This includes calculating, under the conditions that there is no target GPU with a maximum number of parallel threads not less than the maximum number of quantum state operations, and that the current free memory of the multiple GPUs in the computing cluster can realize the simulation of all quantum states, a first execution time for all quantum states to be evenly allocated to each GPU's free memory and a second execution time for all quantum states to first fill the free memory of a single GPU before occupying the free memory of other GPUs. The first and second execution times are determined based on the data transfer rate between the GPUs, the maximum number of parallel threads, the hardware parameter information, and the number of quantum states. If the first execution time is not greater than the second execution time, then all quantum states are evenly allocated to the current free memory of the multiple GPUs in the computing cluster; if the first execution time is greater than the second execution time, then all quantum states are first filled to the free memory of a single GPU before occupying the free memory of other GPUs. The sending module is used to perform calculations on the quantum circuit to be simulated based on the GPU memory allocation scheme, and send the simulation calculation results to the terminal server.
8. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 6 when it is run.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for estimating resources required by analog quantum computing
CN111160560A
Quantum computer simulator characterization
US20190340532A1