Comparing run times on IBM Quantum Experience

I have run this program -

# Import the QISKit SDK
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute, register

# You can get it from https://quantumexperience.ng.bluemix.net/qx/account,
QX_TOKEN = "...."
QX_URL = "https://quantumexperience.ng.bluemix.net/api"

# Authenticate with the IBM Q API in order to use online devices.
# You need the API Token and the QX URL.
register(QX_TOKEN, QX_URL)

# Create a Quantum Register with 2 qubits.
q = QuantumRegister(2)
# Create a Classical Register with 2 bits.
c = ClassicalRegister(2)
# Create a Quantum Circuit
qc = QuantumCircuit(q, c)

# Add a H gate on qubit 0, putting this qubit in superposition.
qc.h(q[0])
# Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting
# the qubits in a Bell state.
qc.cx(q[0], q[1])
# Add a Measure gate to see the state.
qc.measure(q, c)

# Compile and run the Quantum Program on a real device backend
job_exp = execute(qc, 'ibmqx4', shots=1024, max_credits=10)
result = job_exp.result()

# Show the results
print(result)
print(result.get_data())


Output -

COMPLETED {'time': 19.799431085586548, 'counts': {'00': 445, '01': 62, '10': 67, '11': 450}, 'date': '2018-07-30T14:56:23.330Z'}

But when I was running this, it was no very fast. Is this due to queuing on the machine?

The time that you see in the result data structure is recorded by the device itself, so it is the running time of your experiment. It does not include the time spent processing your circuit in Qiskit, or the time spent by your job in the queue.

That being said, here is a rough breakdown of this time (ballpark durations):

• 1) Loading the experiment into the instruments that create the pulses (~ 15s)
• 2) 1024 repetitions (shots) of running calibration pulses & your circuit (~ 5s)
• a) Reset qubits (relaxation) + calibration: ~ 4ms
• b) Reset qubits (relaxation) + your circuit: ~ 1ms

Which adds up to the total experiment time you are seeing.

• Do you know any reference for figuring out exactly how long the "your circuit" part takes? – Max Apr 28 '20 at 20:16

The time given in the results is the execution time on the backend. In your example, your quantum circuit took nearly 20 seconds to execute 1024 times (which seems huge for such a short circuit).

Before these nearly 20 seconds of execution, it is likely that your job had to wait for a few seconds (maybe up to several hours) in the backend queue, where all the jobs submitted but not executed are kept.

What you can do to estimate the waiting time is to ask to the backend how many jobs there are in queue, but you can't estimate precisely the time your job will need to wait in the queue as you don't know the content of the other jobs before you.

You can count the number of single and two qubit gates of your quantum circuit. All you need to do after that is to multiply number of single qubit gates with T1 and number of two qubit gates with T2 and then find an average running time for the whole circuit. Transpiling and being in queue aren't part of running time.