1
$\begingroup$

I am trying to execute qiskit runtime jobs on simulators and real machines and I would like to extract information about the time taken to execute each runtime job. Since using python time.time() method will include also queueing time, which I would like to exclude, I thought about checking on time_taken attribute of the RuntimeJob. To this end, I found this code:

job = provider.runtime.run(program_id='...', inputs=inputs, options=options)
job_id = job.job_id()
job_info = backend.retrieve_job(job_id)

And my plan was to use the time_taken attribute, as I have seen in many other threads. However, I get the following error:

File "/usr/local/lib/python3.9/dist-packages/qiskit/providers/ibmq/ibmqbackendservice.py", line 484, in retrieve_job
    raise IBMQBackendApiError('Failed to get job {}: {}'
qiskit.providers.ibmq.exceptions.IBMQBackendApiError: "Failed to get job c8s4h14o112vg1vn8ed0: '404 Client Error: Not Found for url: https://api-qcon.quantum-computing.ibm.com/api/Network/.../main/Jobs/c8s4h14o112vg1vn8ed0/v/1. Job not found., Error code: 3250.'

I checked the id in the IBM quantum service web interface, and the job_id is the same. I do not understand what I am doing wrong. Is there something I am missing?

Until now, that's the best I could do, but I am sure there is a better way:

job = provider.runtime.run(program_id='x', inputs=inputs, options=options)
while job.status() != JobStatus.RUNNING:
    pass
start = time.time()
res = job.result()
end = time.time()

Thanks a lot for your attention and Best Regards!

$\endgroup$
1
  • $\begingroup$ I think the problem you are facing is due to the difference of retrieving jobs for normal circuit job vs runtime job. For runtime job, you should use this code job = provider.runtime.job('JOB_ID') See more details here: quantumcomputing.stackexchange.com/questions/23637/… $\endgroup$ Commented Apr 1, 2022 at 10:01

1 Answer 1

3
$\begingroup$

First of all, I just have a question : since your job is already stocked in the variable job when you call job = provider.runtime.run(program_id='...', inputs=inputs, options=options), then why try to retrieve it right after? It is not necessary here since you run it right before.

Now, to retrieve a runtime job, you have to do this :

job_id='your_jobid'
job = provider.runtime.job(job_id)

Btw, the time taken by the job might have another name based on the program you run. For example it will still be time_taken for circuit_runner, but for QAOA or VQE it will be called optimizer_time.

$\endgroup$
1
  • 1
    $\begingroup$ And optimizer time can be extracted from the result using job.result()['optimizer_time'] $\endgroup$ Commented Apr 1, 2022 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.