1
$\begingroup$

I wish to run a very simple circuit on the qasm_simulator backend. My circuit is

    circuit2 = QuantumCircuit(2,2);
    circuit2.u3(pi/2,pi,3*pi/4,1)
    circuit2.u3(pi/2,pi,7*pi/4,0)
    #u2
    circuit2.cx(0,1)
    #u3
    circuit2.rz(3*pi/4,1)
    #u4
    circuit2.cx(1,0)
    #u5
    circuit2.ry(pi/2,0)
    #u6
    circuit2.cx(0,1)
    #u7
    circuit2.u3(0,pi*0.8252172,-pi*0.4247820,1)
    circuit2.u3(pi/2,0,pi/2,0)
    circuit2.measure(0,0);
    circuit2.measure(1,1);

The circuit works as I expect and generates the output I expect but I have a question about the workings of the simulator. When I run the following code:

backend = BasicAer.get_backend('qasm_simulator')

for x in range(10):
    Cfin=circuit2;
    job = execute(Cfin, backend, shots=1000)
    res=job.result().get_counts(Cfin)
    print(res)

I get a series of results that look something like this

{'11': 274, '10': 256, '01': 229, '00': 241}
{'11': 274, '10': 256, '01': 229, '00': 241}
{'11': 274, '10': 256, '01': 229, '00': 241}
{'11': 274, '10': 256, '01': 229, '00': 241}
{'11': 274, '10': 256, '01': 229, '00': 241}
{'11': 274, '10': 256, '01': 229, '00': 241}
{'10': 241, '01': 224, '00': 286, '11': 249}
{'11': 240, '01': 246, '10': 233, '00': 281}
{'11': 240, '01': 246, '10': 233, '00': 281}
{'11': 240, '01': 246, '10': 233, '00': 281}

I am curious as to why the simulator returns identical results for a few runs in a row. This happens regularly. The simulator appears to get stuck on one particular result for a while. Does anyone know what is the cause of this? Will there be a similar issue if I try to run this code on one of the real quantum computers?

$\endgroup$
3
  • 1
    $\begingroup$ Does this happen every time you go through that loop? I tried your code as well (I assumed pi was np.pi) and all of my results seem different from each other. I'm curious if you always experience this behavior. $\endgroup$ Oct 2 '20 at 13:43
  • 1
    $\begingroup$ I was unable to reproduce this issue on MacOS with Python 3.7.8. Can we have more information about your setting? The simulator is an ideal quantum computer and you will have other sources of noise in a real qc. $\endgroup$
    – luciano
    Oct 2 '20 at 14:19
  • $\begingroup$ I am running MacOS, but I am using Jupyter notebook. I use the following initslisation code: import numpy as np; from math import pi; from qiskit import QuantumCircuit, execute, Aer, IBMQ; provider = IBMQ.load_account(); $\endgroup$
    – LOC
    Oct 4 '20 at 23:39

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.