DEV Community

YUE GUO for AWS

Posted on

Efficient! QuSprout integrates with AWS HPC

KY1, Bertran Shao2, Adam Sun3

1.Amazon HERO; 2.Developer ecology leader; 3.Solutions Architect

On November 17, 2022, QuDoor officially open sourced QuSprout, a quantum circuit simulator which developed by its own team. It can work with QuTrunk, the quantum programming framework of QuDoor, and developers can implement quantum programming based on this quantum computing platform. As we all know, AWS is a world-renowned cloud computing service provider and provides a rich hardware platform. Therefore, how to integrate QuSprout and AWS high-performance services will be very meaningful. Today we will deploy QuSprout on the AWS High Performance Computing (HPC) platform, and analyze the computing result of QuSprout on both CPU and GPU platforms.

1. Introduction to QuSprout

QuSprout is a free and open source quantum computing simulation backend. The quantum circuits will be generated by QuTrunk and then it will connect to the QuSprout backend to perform the simulation.

Image description

QuSprout supports task management of multiple quantum circuits and MPI multi-process parallel computing. It currently supports Kylin, Ubuntu, and CentOS operating systems, and supports compiling and deploying both on x86 and arm64 architecture systems. (KylinV10, Ubuntu22.04, and CentOS7.9 are recommended)

QuSprout and QuTrunk connect via RPC. It uses C++ as the development language, and it has implemented more than 40 quantum gates, including H, CH, P, CP, R, CR, Rx, Ry, Rz, etc. It provides higher performance and greater flexibility for quantum circuits computation.

QuSprout has already supported both CPU and GPU platforms. The current open sourced version is for the CPU, and the GPU version is still in testing, and I believe it will be published soon.

2. About the AWS HPC platform

P3 instance:
Amazon EC2 P3 instances are based on NVIDIA Tesla V100 Tensor Core GPUs and support up to 8 GPUs. They provide users with a high-performance computing platform and support CUDA-based programs. They are usually used in scenarios such as HPC programs and machine learning.

Image description

In this article, I will use the p3.2xlarge instance as the GPU platform for QuSprout. It is a single-GPU instance based on NVIDIA Tesla V100-SXM2. It has 640 Tensor Cores and 5120 CUDA Cores. Its computing performance can reach up to 7TFLOPS for FP64, and up to 14TFLOPS for FP32. The detailed parameters of the instance are shown in the following table:

Image description

M5 instance:
M5 instances offer a balance of compute, memory, and networking resources for a broad range of workloads. This includes web and application servers,, cluster computing, gaming servers, etc.. It provides
Intel Xeon Platinum 8000 and AMD EPYC 7000 series CPUs

Image description

In this article, the m5.8xlarge type instance will be used as CPU platform for QuSprout. Its CPU type is Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz. The detailed parameters of the specific instance are shown in the following table:

Image description

3. Deployment

First, apply to create m5.8xlarge and p3.2xlarge instances in AWS. After the instances are successfully initialized, you can connect to the EC2 instances via SSH remotely.

Then pull the latest QuSprout (https://github.com/qudoor/qusprout) code from Github, install the QuSprout following the document. The whole process of compiling and installing is executed by script. It is really simple and convenient.

Finally, install QuTrunk. It’s used to write quantum circuit programs. You need to pull the latest QuTrunk (https://github.com/qudoor/qutrunk) code from Github, and install it following the document.

Note: In this test, in order to avoid the impact of network bandwidth, I chose to deploy QuTrunk and QuSprout on the same EC2 instance. You just need to configure the IP and port of QuSprout service, then the two can communicate with each other.

4. Test QuSprout

Now, you can develop quantum programs. Here we take the grover search algorithm as an example. I will increase the number of qubits gradually, and save the records of QuSprout computing on both platforms: m5.8xlarge (CPU) and p3.2xlarge (GPU). The specific code and result are as follows:

4.1 Grover’s code:

1.  """Grover's search algorithm."""  
2.    
3.  import math  
4.  import random  
5.    
6.  from numpy import pi  
7.    
8.  from qutrunk.circuit import QCircuit  
9.  from qutrunk.circuit.gates import Measure, All  
10. from qutrunk.circuit.ops import PLUS, QAA  
11.   
12.   
13. def run_grover(qubits=10, backend=None):  
14.     # Quantum qubits  
15.     num_qubits = qubits  
16.   
17.     # Number of amplitudes  
18.     num_elems = 2**num_qubits  
19.   
20.     # Count of iteration  
21.     num_reps = math.ceil(pi / 4 * math.sqrt(num_elems))  
22.     print("num_qubits:", num_qubits, "num_elems:", num_elems, "num_reps:", num_reps)  
23.   
24.     # Choose target state randomly  
25.     sol_elem = random.randint(0, num_elems - 1)  
26.     print(f"target state: |{str(sol_elem)}>")  
27.   
28.     # Create quantum circuit with local python simulator  
29.     circuit = QCircuit(backend=backend, resource=True)  
30.   
31.     # Allocate quantum qubits  
32.     qureg = circuit.allocate(num_qubits)  
33.   
34.     # Set inital amplitudes to plus state  
35.     PLUS * qureg  
36.   
37.     # Apply quantum operator(gates)  
38.     QAA(num_reps, sol_elem) * qureg  
39.   
40.     # Measure for all qubits  
41.     All(Measure) * qureg  
42.   
43.     # Run circuit in local simulator  
44.     res = circuit.run()  
45.   
46.     # Get measure result and print as int  
47.     out = res.get_outcome()  
48.     print("measure result: " + str(int(out, base=2)))  
49.   
50.     # Print quantum circuit resource information  
51.     circuit.show_resource()  
52.   
53.     # Print quantum circuit execution information  
54.     print(res.excute_info())  
55.   
56.     return circuit  
57.   
58.   
59. if __name__ == "__main__":  
60.     # Run locally  
61.     circuit = run_grover()  
Enter fullscreen mode Exit fullscreen mode

4.2 Result:

Table_1 CPU:(Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
Image description

Tabel_2 GPU: (NVIDIA Tesla V100-SXM2):

Image description

Extracting the time and qubits from Table 1 and Table 2, and draw the following figure:

Image description

It can be seen from the chart that the computing on the GPU platform is 6-8 times faster than that on the CPU platform. Of course, the prices of different instances are also different. So in order to make full use of resources, developers should choose the appropriate instance type according to the task requirements.

4. One-click deployment

An Amazon Machine Image (AMI) is a supported and maintained image provided by AWS that provides the information required to launch an instance. You must specify an AMI when you launch an instance. You can launch multiple instances from a single AMI when you require multiple instances with the same configuration.

After you create and register an AMI, you can use it to launch new instances. You can copy an AMI within the same AWS Region or to different AWS Regions. When you no longer require an AMI, you can deregister it.

Image description

In the future, QuSprout and other related tools can be made into AMI and put into the Marketplace, so that quantum developers can deploy QuDoor’s Quantum computing development environment more conveniently and quickly on AWS. It can provide developers with a more friendly development experience, and make the quantum programming more practical.

About the Authors:

Image description
Keith Yan(丘秉宜)The First Community Hero of China

Image description
Bertran Shao(邵伟),Quantum Developer Relations Leader, the initiator of the first open source quantum computing community in China

Image description
Adam Sun(孙海洋),QuDoor Quantum Solution Architect, Project Leader of GPU Quantum Circuit Simulation

Top comments (0)