-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhello_world.py
23 lines (20 loc) · 974 Bytes
/
hello_world.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime.accounts.exceptions import AccountNotFoundError
from qiskit_ibm_runtime.api.exceptions import RequestsApiError
if __name__ == "__main__":
channel = "ibm_quantum"
try:
service = QiskitRuntimeService(channel="ibm_quantum")
except AccountNotFoundError:
token = input("Please provide your IBM Quantum token: ").strip()
try:
service = QiskitRuntimeService(channel="ibm_quantum", token=token)
except RequestsApiError as ex:
if "Error code: 3446" in ex.message:
raise ValueError("Authentication failed. Make sure the "
"token you passed in is correct.") from None
raise
print("Doing quantum magic, please wait...")
options = {"backend_name": "ibmq_qasm_simulator"}
job = service.run(program_id="hello-world", inputs={}, options=options)
print(job.result())