2
$\begingroup$

The same 4 qubits circuit yields different results whether it runs on a simulator or on a real system and I would appreciate if you could help me in understanding the reason of this difference or point me in the right direction.

The purpose of the experiment is to eliminate (almost) all probabilities for measuring state |0000> (or more exactly state |000> as qbit 3 has an ancilliary role). I observe that this works on a simulator (even though I haven't yet suceeded in reshufling probabilities evenly) but state |0000> is still alive an well with the real backend.

Below are the two extract of the code differing only by the instructions relative to the backend. The attached picture show the output of both cases.

image

In the two documented cases the backend is Ibmq_Bogota, Qiskit version 1.6.20

Extract 1.1 : simulator

simulator = Aer.get_backend('aer_simulator')

#Circuit definition
qcMq = QuantumRegister(3,'qcMq')
qcMa = QuantumRegister(1,'qcMa')
qcMc = ClassicalRegister(4, 'qcMc')
qcM = QuantumCircuit(qcMq, qcMa, qcMc)

#Init
qcM.reset(qcMq)
qcM.reset(qcMa)
qcM.x(0)
qcM.h(0)
qcM.h(1)
qcM.h(2)
#qcM.h(1)

qcM.x(1)
qcM.x(2)
#qcM.h(2)

#swap test
qcM.h(qcMa[0])
qcM.cswap(qcMa[0], qcMq[1], qcMq[2],ctrl_state='1')
qcM.h(qcMa[0])
qcM.x(qcMa[0])
qcM.barrier()

#H on qubit 0 if all other qubits in state |1>
qcMz = MCMT('h', num_ctrl_qubits=3, num_target_qubits=1) #ok
qcMf = qcM.compose(qcMz,qubits=[3,2,1,0])
qcMf.barrier()

qcMf.x(1)
qcMf.x(2)
qcMf.barrier()

# Hadamard on qbit 1 et 2 if result swap test = 1 and qbubit 0 = 1
qcMy = MCMT('h', num_ctrl_qubits=2, num_target_qubits=2) #ok
qcMr = qcMf.compose(qcMy,qubits=[3,0,1,2]) #ok 
qcMr.barrier()

#qcMr.cx(2,1)

#Statevector du circuit décrit =============
st1 = Statevector.from_instruction(qcMr)
D=st1.draw(output='bloch')
show_figure(D)
print('')
print(st1)

D=plot_state_qsphere(st1)
show_figure(D)
#==========================
qcMr.reset(3)
#measure 
qcMr.measure([0,1,2],[0,1,2])

#Print circuit ; print(qcM) also works
qcMP = qcMr.draw(output='mpl')  
show_figure(qcMP)

#If simulator 
simulator = Aer.get_backend('aer_simulator')
qcMr = transpile(qcMr, simulator)
``` end of extract 1.1
Extract 1.2 - simulator 
# if simulator
result = simulator.run(qcMr, memory = True).result()
counts = result.get_counts(qcMf)
mem=result.get_memory()
plot_histogram(counts, title='test')

``` Extract 2.2 - real backend 
#Circuit definition
qcMq = QuantumRegister(3,'qcMq')
qcMa = QuantumRegister(1,'qcMa')
qcMc = ClassicalRegister(4, 'qcMc')
qcM = QuantumCircuit(qcMq, qcMa, qcMc)

#Init
qcM.reset(qcMq)
qcM.reset(qcMa)
qcM.x(0)
qcM.h(0)
qcM.h(1)
qcM.h(2)
#qcM.h(1)

qcM.x(1)
qcM.x(2)
#qcM.h(2)

#swap test
qcM.h(qcMa[0])
qcM.cswap(qcMa[0], qcMq[1], qcMq[2],ctrl_state='1')
qcM.h(qcMa[0])
qcM.x(qcMa[0])
qcM.barrier()

#H on qubit 0 if all other qubits in state |1>
qcMz = MCMT('h', num_ctrl_qubits=3, num_target_qubits=1) #ok
qcMf = qcM.compose(qcMz,qubits=[3,2,1,0])
qcMf.barrier()

qcMf.x(1)
qcMf.x(2)
qcMf.barrier()

##Hadamard on qhbit 1 et 2 if result swap test = 1 and qbubit 0 = 1
qcMy = MCMT('h', num_ctrl_qubits=2, num_target_qubits=2) #ok
qcMr = qcMf.compose(qcMy,qubits=[3,0,1,2]) #ok 
qcMr.barrier()

#qcMr.cx(2,1)

#Statevector from the declared circuit 
st1 = Statevector.from_instruction(qcMr)
D=st1.draw(output='bloch')
show_figure(D)
print('')
print(st1)

D=plot_state_qsphere(st1)
show_figure(D)
#=== 
qcMr.reset(3)
#mesure 
qcMr.measure([0,1,2],[0,1,2])
``` End of extract 2.1 - real backend 

``` Extract 2.2 - real backend 
 
    #If real system *******
    job_exp = execute(qcMr, backend, shots=nbshots, max_credits=max_credits, memory=True)
    job_monitor(job_exp)
    result = job_exp.result()
    counts = result.get_counts()
    mem = result.get_memory()
``` End of extract 2.2 - real backend 
END OF QUESTION


  [1]: https://i.stack.imgur.com/FaE2X.png
$\endgroup$
2
  • $\begingroup$ Try running a circuit with says 5 qubit and apply an $X$ gate to each of the 5 qubits. Theoretically, you should always observe the state $|11111\rangle$. Run this on the hardware and see what you get. What I am trying to say is what you expect to get is not always what you get on the hardware due to noise. $\endgroup$
    – KAJ226
    Feb 21, 2022 at 0:17
  • $\begingroup$ Thanks a lot Graig. I'll try this to realize the gap you mention. $\endgroup$
    – BCayzac
    Feb 21, 2022 at 10:58

2 Answers 2

1
$\begingroup$

The issue is probably that your circuit is so large that you're being overwhelmed by noise on the real system. You're doing dozens of two qubit gates (it's hard to give an exact number since you're relying on whatever automatic decomposition is happening behind the scenes), and each has error rates around 1-2%...

It's also noteworthy that it looks like the outputs that decreased have more 1s than 0s, which is consistent with decay to the ground state being an issue.

You should try running something smaller and simpler, then slowly build up.

$\endgroup$
0
$\begingroup$

Indeed, what you’re seeing here is amplitude damping (T1 decay) which is a major source of error, and is biased towards the ground state. I’m not sure what’s the noise model in the Aer simulator, but if it’s a depolarizing channel or other Pauli-error based simulator, it won’t show this effect, since Pauli errors are not conditioned on the state whereas amplitude damping is.

As Craig Gidney suggested once, you can negate the effect of amplitude damping to some extent by adding X gates in various locations, but you need make sure that you take their effect into account by commuting them out of the circuit.

$\endgroup$
1
  • $\begingroup$ Thanks a lot Lior, I was suspecting some effect of this type but I'm glad to get a confirmation that the problem is there and not in a misconception (even though the circuit is probably cumbersome and ineffective:). Thanks for the paper too, I'll have a close look at it. KR, Bertrand $\endgroup$
    – BCayzac
    Feb 21, 2022 at 11:09

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.