4
$\begingroup$

I have run this program -

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

# Set your API Token.
# You can get it from https://quantumexperience.ng.bluemix.net/qx/account,
# looking for "Personal Access Token" section.
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?

$\endgroup$

3 Answers 3

7
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Do you know any reference for figuring out exactly how long the "your circuit" part takes? $\endgroup$
    – Max
    Apr 28, 2020 at 20:16
1
$\begingroup$

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.

$\endgroup$
-1
$\begingroup$

t_measure = t_queue + t_transpile + t_run. As can be seen in the equation above, t_run can be calculated by the subtraction of t_measure from t_queue and t_transpile.

you can also use this:

from qiskit import IBMQ

IBMQ.load_account() provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main') backend = provider.get_backend('ibmq_device')

job_id = backend.jobs()[0].job_id() print(f'JOBID: {job_id}')

job = backend.retrieve_job(job_id)

result = job.result() counts = result.get_counts() execution_time = result.time_taken

gets the execution time.

$\endgroup$

Your Answer

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

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