2
$\begingroup$

I am working on calculating the exact runtime of a quantum circuit on the ibmq_16_melbourne device. I am using the API result.time_taken to calculate the run time.

result = execute(circuit, backend, shots=8000).result()
counts = result.get_counts(circuit)
print(counts)
print("Time taken: ", result.time_taken)

I executed by python code on ibm quantum lab (which is a Jupyter notebook) and also using Pycharm on my laptop. I get huge variations in the results. So, I concluded that result.time_taken does not provide the run time correctly. I am going through the documentation, but still could not find the solution.

Please provide some solution to calculate exact runtime.

$\endgroup$
7
  • $\begingroup$ Do you know if time_taken considers the queue time? If so, that probably makes up for the variations you are seeing. $\endgroup$
    – epelaaez
    Jun 21 at 1:15
  • 1
    $\begingroup$ No, time_taken doesnot include the queue time. $\endgroup$ Jun 21 at 3:10
  • $\begingroup$ See this: quantumcomputing.stackexchange.com/q/17768/9858 $\endgroup$
    – KAJ226
    Jun 21 at 3:11
  • 1
    $\begingroup$ @ManuChaudhary ok. You can do this theoretically. This might help: quantumcomputing.stackexchange.com/a/17304/9858 You can at least write a function that approximate the time your circuit takes per shot... then multiply that by however number of shots you used. If you use more than 8192 shots then you have to load another circuit, which has an overhead of about 15 seconds. $\endgroup$
    – KAJ226
    Jun 21 at 4:17
  • 1
    $\begingroup$ The measurement steps are the most expensive so you want to take that into account. The gate with the longest time is the CX gate... which ranges from 400 ns to 1000 ns. The RZ gate, which equivalent to U1 gate qiskit.org/documentation/stubs/… within an overall phase factor, is performed using a frame change so it is essentially free. See his paper: arxiv.org/pdf/1612.00858.pdf $\endgroup$
    – KAJ226
    Jun 22 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.