Can I run circuits on real hardware as offline? I mean that a job with 100 circuits may take a long time and I want to shot down my laptop in running time. In the meantime, can the real hardware run all of the circuits in the job, and in another time I can obtain my results? Or is it necessary my laptop to be turned on till I receive the last result? If I need any code for this issue, I would be very grateful anyone can provide it.
2 Answers
All jobs sent to IBMQ backends are asynchronous. You just need to save the job ID and use the ID retrieve it later. For example:
provider = IBMQ.load_account()
backend = provider.get_backend('ibmq_vigo')
job = execute(circuits, backend)
print(job.job_id())
Once the job is submitted, you can turn off your laptop. Then when you're ready to get the results, do
result = backend.retrieve_job(job_id).result()
If you forget to write down the job ID, you can always find it on the IQX dashboard or use backend.jobs()
to query for it.
-
$\begingroup$ Thanks a lot for your response $\endgroup$ Commented Oct 10, 2020 at 9:31
To answer your question, you do not have to be on online the whole time in order for your job to run on the real hardware. If you create a job with 100 circuits and get the job_id with the command
job.job_id()
you can leave the IBM Quantum Experience website or shut down your computer and when you come back, you can do the following in the same or different notebook:
from qiskit import *
provider = IBMQ.load_account() #or you can specify the provider with IBMQ.get_provider(hub=..., group=..., project=...)
backend = provider.backends.<backend_name>
job = backend.retrieve_job(<job_id>)
job.status()
And you will have your job stored in the variable job
. The command job.status()
helps you see what stage your job is in. If the output is DONE, then you can retrieve your results.
-
$\begingroup$ Thanks a lot for your helping! $\endgroup$ Commented Oct 10, 2020 at 9:30