2. The First Quantum Program Submission Based on isQ¶
If you need to submit experiments using other quantum languages on the cloud platform's quantum computer, you can follow this approach: first, use your chosen programming language to locally call the language compiler and compile/output the circuit in QCIS language. Then, submit the experiment according to the QCIS language.
The cloud platform's JupyterLab environment is pre-equipped with various language environments and does not require additional installations. If you have other requirements, you can contact customer support.)
2.1 Write quantum programs in isQ¶
Write quantum programs in isQ according to isQ syntax rules.
For isQ programming tutorials, please refer tohttps://www.arclightquantum.com/isq-core/index.html
isq_code = '''
qbit q[66];
H<q[0]>;
CNOT<q[0], q[6]>;
M<q[0]>;
M<q[6]>;
'''
; CNOT; M; M; '''
2.2 Compile the program and output QCIS circuits¶
isQ compiles and runs programs through the Device class. isQ provides two types of Device: LocalDevice and QcisDevice. For specific usage, please refer to the isQ documentation。
First, users need to define a Device instance
from isq import LocalDevice
ld = LocalDevice()
Then, compile to obtain QCIS circuits using the compile_to_ir function.
ir = ld.compile_to_ir(isq_code, target = "qcis")
print(ir)
H Q1 Y2P Q7 CZ Q1 Q7 Y2M Q7 M Q1 M Q7
2.3 Submit the program to the Quantum Computing Cloud Platform (Same QCIS process)¶
Submit the compiled QCIS circuits to the Quantum Computing Cloud Platform
isq_qcis=ir
from ezQgd import *
account = Account(login_key='opecT+SO+QFjLXREUU2f8paSJNtTytPPV8Dbbd2T8Zg=', machine_name='gd_qc1')
#Set up the user's SDK key, select a quantum computer, and create an instance.
query_id_isQ = account.submit_job(circuit=isq_qcis,version="Bell_state_isQ",num_shots=1000)
#Submit the quantum circuit to the cloud-based quantum computer.
Wait for the code to complete on the quantum computer and then read, process, and save the experimental results.
if query_id_isQ:
result=account.query_experiment(query_id_isQ, max_wait_time=360000)
#The maximum waiting time is in seconds, with a default of 30 seconds if not specified. Quantum programs may experience queueing, and quantum computers have their own automatic calibration times. To ensure fully automated program execution, it's advisable to set a waiting time greater than the sum of these durations.
print(result)
#Subsequent data applications are to be implemented.