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)
Get your real api token from https://account.originqc.com.cn/, then retrieve all supported backends.
backends = service.backends()
The following are some commonly used backends and their corresponding numbers of qubits. Backends with the "amplitude" suffix indicate that they simulate quantum computing using a supercomputing cluster. Other backend names represent real quantum chip backends.
+----------------------------------------------------------+
|Backend name |Backend type | max qubits
+----------------------------------------------------------+
|full_amplitude |Simulator | 33
+----------------------------------------------------------+
|single_amplitude |Simulator | 200
+----------------------------------------------------------+
|partial_amplitude |Simulator | 64
+----------------------------------------------------------+
|origin_wukong |Physical Quantum Chip | 72
-----------------------------------------------------------+
Note that the backends are updated periodically at irregular intervals.
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")
If an error occurs during task execution, you can choose to enable logging to view detailed information.
apikey = "XXXXXXXX"
service = QCloudService(apikey)
service.setup_logging(LogOutput.CONSOLE)
service.setup_logging(LogOutput.FILE,"test.log")
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.
from pyqpanda3.qcloud import QCloudService, QCloudOptions,QCloudJob,QCloudResult
prog = QProg()
prog << H(0) << CNOT(0, 1) << measure(0, 0) << measure(1, 1)
api_key = "XXXXXXXXXXXXXXX"
service = QCloudService(api_key=api_key)
backend = service.backend("full_amplitude")
job = backend.run(prog, 1000)
job.job_id can obtain the task ID
print("job id : ", job.job_id())
All tasks support both synchronous and asynchronous submission methods, for synchronous...
job.result will block and continuously poll for the task result until the task completes or fails.
result= job.result()
probs = result.get_probs()
Asynchronous method as above, job.status will query the task status once and return the current status of the task.
import time
while True:
status = job.status()
if status == JobStatus.FINISHED:
break
time.sleep(5)
Real Quantum device
The interface usage for real chips is similar, and the computation backend is obtained based on the backend name.
The run method for submitting computation tasks supports batch tasks.
prog = QProg()
prog << H(0) << CNOT(0, 1) << measure(0, 0) << measure(1, 1)
api_key = "302e020100301006d0202010104"
service = QCloudService(api_key=api_key)
backend = service.backend("origin_wukong")
options = QCloudOptions()
job = backend.run([prog, prog], 1000, options)
probs_list = job.result().get_probs_list()
for result in probs_list:
print(result)
The running result is as follows:
{'00': 0.3166741132736206, '01': 0.013481048867106438, '10': 0.06137626618146897, '11': 0.6084685921669006}
{'00': 0.35036635398864746, '01': 0.013929451815783978, '10': 0.06072771921753884, '11': 0.5749766230583191}
Asynchronous method as above:
prog = QProg()
prog << H(0) << measure(0, 0) << measure(1, 1)
api_key = "302e020100d8772eb9705e844394453a3c8a/6327"
service = QCloudService(api_key=api_key)
backend = service.backend("origin_wukong")
options = QCloudOptions()
job = backend.run([prog, prog], 1000, options)
import time
while True:
status = job.status()
if status == JobStatus.FINISHED:
break
time.sleep(5)
for result in job.result().get_probs_list():
print(result)
The running result is as follows:
{'00': 0.37110814452171326, '01': 0.1298290193080902, '10': 0.36970818042755127, '11': 0.12935470044612885}
{'00': 0.3805724084377289, '01': 0.12036558985710144, '10': 0.3791339993476868, '11': 0.11992792785167694}
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)
ChipInfo represents fidelity and other information for each single quantum logic gate and each set of double quantum logic gates
api_key = "302e020100301006072a8648ce3d020106052b8104001c0417"
service = QCloudService(api_key)
backend = service.backend("origin_wukong")
chip_info = backend.chip_info()
single_qubit_info_list = chip_info.single_qubit_info()
for qubit_info in single_qubit_info_list:
print(qubit_info)
double_qubits_info_list = chip_info.double_qubits_info()
for double_qubits in double_qubits_info_list:
print("double qubits ",double_qubits.get_qubits(),
"fidelity : ", double_qubits.get_fidelity())
Output is :
+---------------------------------------------------------------------------------------------------------------+
|Qubit ID |Single Gate Fidelity|Readout Fidelity |Frequency |T1 |T2
+----------------------------------------------------------------------------------------------------------------+
|0 |0.995 |0.9234 |4764 |9.254 |1.128
+----------------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------------------------+
|Qubit ID |Single Gate Fidelity|Readout Fidelity |Frequency |T1 |T2
+----------------------------------------------------------------------------------------------------------------+
|1 |0.9973 |0.9417 |4041 |17.436 |1.844
+----------------------------------------------------------------------------------------------------------------+
......
double qubits [38, 44] fidelity : 0.9831
double qubits [44, 50] fidelity : 0.0
double qubits [39, 45] fidelity : 0.0
double qubits [45, 46] fidelity : 0.9519
double qubits [45, 51] fidelity : 0.9589
double qubits [40, 46] fidelity : 0.0
double qubits [45, 46] fidelity : 0.9519
double qubits [46, 47] fidelity : 0.0
double qubits [41, 47] fidelity : 0.964
......
- Single-Gate fidelity represents the offset in the error of the result when a single-qubit operation is performed.
- Single-Gate readout error represents the offset in the error when reading the measurement result of the qubit.
- Frequency represents the frequency of single-qubit operations.
- T1 and T2 represent the coherence times, measured in microseconds.
- Two-qubit fidelity represents the offset in the error of the result when performing a two-qubit operation.
- Note
- 1.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.
2.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.
3.If you encounter any issues while using the service, please submit a user feedback. We will address your concerns as soon as possible.