2
$\begingroup$

I'm performing QFT using the following code:

# Importing standard Qiskit libraries and configuring account
from qiskit import *
from qiskit.tools.monitor import job_monitor
provider = IBMQ.load_account()

# --- Imports
from numpy import linalg as LA
import numpy as np


def qftA(circ, n):
    """n-qubit QFT on the qubits in circ."""
    for k in range(n):
        j = n - k
        circ.h(j - 1)
        for i in reversed(range(j - 1)):
            circ.cu1(2 * pi / 2**(j - i), i, j - 1)
    for i in range(n//2):
        circuit.swap(i, n - i - 1)

# --- Parameters
nBits    = 2
shots    = 8192
pi       = np.pi

# --- Input data

# --- Defining the array coefficients
coefficients = [0., 1., 3., 1.]
coefficients = coefficients / LA.norm(coefficients)

# --- Defining the quantum circuit
circuit = QuantumCircuit(nBits, nBits, name = "Quantum circuit")

# --- Quantum circuit initialization
circuit.initialize(coefficients, range(nBits))

# next, do a qft
qftA(circuit, nBits)
circuit.measure(range(nBits), range(nBits))

#sim_backend = provider.get_backend('ibmq_16_melbourne')
#sim_backend = provider.get_backend('ibmq_vigo')
#sim_backend = provider.get_backend('ibmq_essex')
sim_backend = BasicAer.get_backend('qasm_simulator')

job = execute(circuit, sim_backend, shots=shots)
job_monitor(job, interval = 3)
result = job.result().get_counts()

print(result)

I have performed a comparison between the simulator and machine results:

QASM SIMULATOR
{'00': 4648, '01': 1680, '10': 169, '11': 1695}

MELBOURNE
{'00': 3850, '01': 2180, '10': 508, '11': 1654}

VIGO
{'00': 4757, '01': 1937, '10': 308, '11': 1190}

ESSEX
{'00': 4251, '01': 1495, '10': 883, 11': 1563}

LONDON
{'00': 4280, '01': 1332, '10': 608, '11': 1972}

BURLINGTON
{'00': 2880, '01': 1638, '10': 1745, '11': 1929}

IBMQX2
{'00': 4425, '01': 1381, '10': 763, '11': 1623}

OURENSE
{'00': 4922, '01': 1766, '10': 353, '11': 1151}


ARMONK
single qubit

So, depending on what I use I obtain different results. Could someone tell me why and suggest remedies?

EDIT I have removed the swap at the end of the circuit, as suggested by Davit Khachatrya, and these are the results I achieve

qasm_simulator
{'00': 4639, '10': 1651, '01': 201, '11': 1701}

ibmq_16_melbourne
{'00': 4210, '10': 1828, '01': 531, '11': 1623}

ibmq_vigo
{'00': 4676, '10': 1697, '01': 406, '11': 1413}

ibmq_essex
{'00': 4013, '10': 1462, '01': 1010, '11': 1707}

ibmq_london
{'00': 4341, '10': 1565, '01': 678, '11': 1608}

ibmq_burlington
{'00': 3798, '10': 1376, '01': 1770, '11': 1248}

ibmqx2
{'00': 4281, '10': 1481, '01': 621, '11': 1809}

ibmq_ourense
{'00': 4533, '10': 2037, '01': 293, '11': 1329}

My feeling is that I have now less noisy results.

$\endgroup$
  • 4
    $\begingroup$ Does this answer your question? Why IBM Quantum Experience is giving different results under ibmq_qasm_simulator and ibmq_16_melbourne? $\endgroup$ – Martin Vesely Mar 13 at 22:26
  • 2
    $\begingroup$ This can also be helpful: quantumcomputing.stackexchange.com/questions/10152/… $\endgroup$ – Martin Vesely Mar 13 at 22:27
  • $\begingroup$ Thank you very much for your comments. I have edited the question hosting a comparison between simulator and machine results. It seems that, even for the case of 2 qubits, the results different considerably. Could you point me to some error correction techniques, something similar to the classical parity bit? Or do you think that the noise filtering of my previous question you linked in the second comment would be the best possible remedy? $\endgroup$ – JackOLantern Mar 14 at 8:06
  • $\begingroup$ @JackOLantern Just info: if you will add at the end these two lines your results will be in a slightly more readable format :) answer = result.get_counts() print(answer) $\endgroup$ – Davit Khachatryan Mar 14 at 8:12
  • $\begingroup$ @DavitKhachatryan Sorry, I will fix the issue. $\endgroup$ – JackOLantern Mar 14 at 8:18
1
$\begingroup$

What I have obtained by running 4 times the same code on "qasm_simulator":

{'00': 4656, '01': 1613, '10': 185, '11': 1642}
{'00': 4564, '01': 1735, '10': 179, '11': 1618}
{'00': 4581, '01': 1646, '10': 184, '11': 1685}
{'00': 4602, '01': 1684, '10': 181, '11': 1629}

Here we don't have noise, but still, the results are different. So, one can expect some variance between the results. In your results, the noisiest result was from Burlington, then from Melbourne (for Melbourne the reason can be found in this answer). The rest QCs weren't performing comparably bad. You can try to apply the technique that you have used in this question or look to this tutorial for repetition codes. Still, their performance will depend on the circuit depth that you have.

Other suggestions

The noise crucially depends on the depth of your circuit. When I tried to run the code on Essex I saw that the gate number was 14 (7 CNOTs that contribute to the noise more than single-qubit gates). We always should try to minimize the gate number. For example, there were three CNOTs at the end of the circuit that implements the swap gate from QFT and they can be deleted, because specifically, for this case, they just swap the output results that can be done by post-processing by a classical computer.

Also, there can be errors that can be tolerated depending on the algorithm that you use, and in those cases, one even shouldn't worry about the noise.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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