QPanda3  0.1.0
Supported by OriginQ
Loading...
Searching...
No Matches
Quantum Cloud Service

Prev Tutorial: Quantum Profiling

Origin Quantum Cloud Service

In complex quantum circuit simulations, it is necessary to leverage high-performance computing clusters or real quantum computers. Using cloud computing to replace local computation reduces the computational costs for users and provides a better computing experience.

The Origin Quantum Cloud platform submits tasks to quantum computers or computing clusters deployed remotely via the Origin QPilot service, and receives the returned results. The process is shown in the diagram below.

Origin Quantum Cloud platform

pyqpanda3 wraps various quantum computing services, enabling the sending of computation instructions to Origin's computing server clusters or real quantum chips, and retrieving the computation results. For more details, see the diagram below.

Quantum Cloud Services

Users first need to register and access the latest Origin Quantum Cloud Computing website at Origin Quantum Cloud.

Quantum Origin

Next, click on the Workbench in the upper-right corner to enter the quantum computing access interface.

You will see various computing services, including virtual computing and real quantum computing. Then, you need to obtain the api_token and other related information. The api_token is an identifier for each user to access quantum cloud computing resources via the pyqpanda3 computing interface. You can obtain it from your personal account center.

Quantum Origin

The api_token is an important credential for accessing quantum computing resources. Please keep it safe.

In pyqpanda3, we use QCloudService to build the quantum cloud service and obtain the backend. The api_key of the user needs to be provided.

apikey = "XXXXXXXX"
service = QCloudService(apikey, test_url)

Retrieve all supported backends.

backends = service.backends()

Obtain the specific computation backend by backend name.Currently, the chip backend supports the latest origin's Wukong 72-bit chip.

backend = service.backend("origin_wukong")

High-Performance Computing Cluster Cloud Service

All virtual machines submit quantum computing tasks to the supercomputer via the run method with parameters, for full amplitude.

backend = service.backend("full_amplitude")
job = backend.run(prog, 1000)

All tasks support both synchronous and asynchronous submission methods, for synchronous...

result= job.result()
probs = result.get_probs()

Asynchronous method as above:

while True:
status = job.status()
if status == JobStatus.FINISHED:
break
sleep(5)

Real Quantum device

The interface usage for real chips is similar, and the computation backend is obtained based on the backend name.

backend = service.backend("origin_wukong")

The run method for submitting computation tasks supports batch tasks.

import os
import sys
sys.path.append(os.path.dirname(__file__))
from pyqpanda3.core import *
import pyqpanda3.qcloud as pq
import numpy as np
import time
circuit = QCircuit(3)
circuit << H(0)
circuit << RY(1, 0.3)
circuit << RY(2, 2.7)
circuit << RX(0, 1.5)
circuit << CNOT(0, 1)
circuit << CNOT(1, 2)
prog = QProg()
prog.append(circuit)
prog.append(measure(0, 0))
prog.append(measure(1, 1))
prog.append(measure(2, 2))
prog_array = [prog, prog]
api_key = "302e020a8648ce340075b8cac9311b97cac/10149";
service = pq.QCloudService(api_key, test_url)
backend = service.backend("origin_wukong")
options = pq.QCloudOptions()
job = backend.run(prog_array, 1000, options)
probs_list = batch_job.result().get_probs_list()
print(probs_list)
Definition core.py:1
Definition qcloud.py:1
[{'001': 1, '100': 462, '011': 476, '111': 23, '000': 21, '101': 8, '010': 9},
{'001': 2, '100': 459, '011': 479, '111': 20, '000': 24, '101': 10, '010': 7}]

QCloudOptions can be used to configure runtime options for computation tasks running on the chip, including whether to enable mapping, quantum circuit optimization, and result correction, among others.

options = QCloudOptions()
options.set_amend(true)
options.set_mapping(true)
options.set_optimization(true)
Note
The maximum number of tasks for a batch computation is 200. If this number is exceeded, the tasks need to be split into multiple submissions. Before using the service, ensure that the user has the necessary permissions and sufficient computing resources, or errors such as "no permission" or "insufficient computing resources" may occur. For more details, refer to https://qcloud.originqc.com.cn/zh/computerServices. If you encounter any issues while using the service, please submit a user feedback. We will address your concerns as soon as possible.