4
$\begingroup$

I'm experiencing an issue while using Qiskit where the counts from a job return vastly different values when ran in a loop or as an array of circuits as opposed to single experiments when run by themselves. This is an issue because I'm in the process of tracking decoherence time.

For instance, when I run the following code (where N is the number of qubits in a 20-qubit architecture and gates_list is an array containing the number of identity gates to be implemented in each iteration of a circuit), the counts for the last circuit in the array becomes worse as I increase the number of entries in the list prior to that particular circuit.

q = QuantumRegister(N, 'q')
c = ClassicalRegister(N, 'c')
qc = QuantumCircuit(q,c)
circuit=[]

for i in range(N):
    qc.x(q[i])
    qc.barrier()

measure = QuantumCircuit(q,c)
measure.measure(q[0:N], c[0:N])

for j in gates_list:
    i = 1
    while i < j+1:
        for k in range(N):
            qc.iden(q[k])
        qc.barrier()
        i += 1
    circuit.append(qc+measure)

for j in range(len(circuit)):
    print("Executing job", j+1, "of", len(circuit))
    s = "T2_Decoherence_i={}_t.csv".format(gates_list[j])

    qobj = assemble(circuit[j], shots=8192)
    job = backend.run(qobj)
    job_monitor(job)
    res = job.result().get_counts()

    ibmqf.Write_Data(s,res)

However, when I attempt to run each individual circuit by itself, I receive the expected output.

Any ideas as to what the issue might be?

$\endgroup$
6
  • $\begingroup$ Hi Brett, can you please clarify what you mean by "the counts for the last circuit in the array becomes worse". What does worse mean? $\endgroup$
    – eqb
    Jun 6 '19 at 12:06
  • $\begingroup$ Thanks for the question. What's you backend? $\endgroup$ Jun 6 '19 at 12:08
  • $\begingroup$ Sorry for the lack of clarification. I currently have my program set up to record the measured results from each circuit into their own csv files, which contains the number of shots recorded where the qubit state was measured as either a 1 or a 0. When I plot them, my expected values for a qubit in the 1 state (in an example where I use a 1-qubit register) have a significantly lower probability if I execute the circuit from within a list of circuits as opposed to running my code once per circuit without a for loop or circuit array. $\endgroup$ Jun 6 '19 at 12:53
  • $\begingroup$ Also, my backend is Poughkeepsie $\endgroup$ Jun 6 '19 at 12:53
  • 2
    $\begingroup$ Hi Brett, which for loop do you mean the code works better without? It looks like your first for loop doesn't create a new circuit each time, so all the identity gates added on in previous iterations will still be in the circuit. This means you will have a lot more identity gates than specified by the number in gates_list (unless this is how you meant for gates_list to work) which could be the reason the result are so much worse. $\endgroup$
    – met927
    Jun 10 '19 at 10:14

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.