2
$\begingroup$

I am designing quantum algorithms where the quantum circuit uses CSWAP gates a lot. The result is very noisy on the quantum hardwares. So I designed really simple circuits to test whether it is indeed the CSWAP that are causing the problems.

This is a simple circuit to calculate the square sum of diagonal terms of the density matrix.

qubits = 2
qc = QuantumCircuit(4*qubits+2,1)

qc.h([0,0+qubits])
qc.cx([0,0+qubits],[1,1+qubits])
    
for i in range(2*qubits):    
    qc.cx(i,-i-2)

qc.h(-1)

for i in range(qubits):
    qc.cswap(-1,i,i+qubits)
    
qc.h(-1)
qc.measure(-1,0)

And it looks like this:

enter image description here

The difference of the probability of measuring 0 and 1 should be 0.5 ({1: 0.23828125, 0: 0.76171875}), since we are calculating the square of the diagonal terms of the density matrix of simple bell state. which is exactly what the simulator gives. However, on the real hardware, there is no difference in the probability.

So I further simplified the circuit to:

qubits = 1
qc = QuantumCircuit(4*qubits+1,1)
qc.h([0,0+qubits])


for i in range(2*qubits):

    qc.cx(i,-i-2)

qc.h(-1)

for i in range(qubits):
    qc.cswap(-1,i,i+qubits)

qc.h(-1)
qc.measure(-1,0)

which looks like this: enter image description here

The simulator gives the correct result again. But the hardware shows even possibility of 0 and 1, again.

Does this mean that the real hardware cannot handle control swap gate at all? I know it has to do with the underlying topology of the hardware. But is 1 simple control swap too many? Or did I made mistakes? Please share some ideas.

$\endgroup$
2
  • $\begingroup$ Can you share which quantum machine you're using? $\endgroup$
    – Tristan Nemoz
    Commented Jul 10 at 9:56
  • 1
    $\begingroup$ I have been using ibm_kyoto and ibm_sherbrooke. Both are giving me these bad results. $\endgroup$
    – Deren Liu
    Commented Jul 10 at 17:03

1 Answer 1

6
$\begingroup$

This is the transpiled circuit of a single $\text{CSWAP}$ gate onto one of IBM's QPUs:

enter image description here

It is a very deep circuit, so it is not surprising your results are just noise.

Looking at the paper Shallow unitary decompositions of quantum Fredkin and Toffoli gates for connectivity-aware equivalent circuit averaging, this decomposition does not seem terribly surprising but you could perhaps optimize it a little bit if you manually replace your $\text{CSWAP}$ gates for what is shown if figure 1d. Won't help much with the hardware results though because the decomposition of a $\text{CCX}$ gate is also deep.

$\endgroup$

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