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.
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$