2
$\begingroup$

I'm using Qiskit and I have a Quantum Circuit (say, circuit) that gives reasonable results when using the simulator, namely

sim_backend = provider.get_backend('qasm_simulator')
job = execute(circuit, sim_backend, shots=shots)

However, when switching to the true machine, namely

sim_backend = provider.get_backend('ibmq_16_melbourne')

I'm experiencing very noisy, meaningless results.

From my understanding, this is normal and, in these cases, error mitigation is performed by measuring the noise of the quantum circuit and then operating with this knowledge.

Could someone tell me which Qiskit routine I could use to mitigate noise and how?

EDIT

Following the comment by Davit Khachatryan and the answer by Martin Vesely, I have prepared the code below.

# --- Standard imports

%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()

# --- Imports
from qiskit import QuantumCircuit, execute, BasicAer
from qiskit.tools.monitor import job_monitor

import math
from numpy import linalg as LA
import numpy as np
#%config jupy = 'svg' # Makes the images look nice

import time

import matplotlib.pyplot as plt

nBits    = 2

shots    = 8192

# --- Computation of the calibration matrix

from qiskit.ignis.mitigation.measurement import (complete_meas_cal,CompleteMeasFitter)
from qiskit import *

qr = QuantumRegister(2)
meas_calibs, state_labels = complete_meas_cal(qr=qr, circlabel='mcal')
backend = provider.get_backend('ibmq_16_melbourne')
job = execute(meas_calibs, backend=backend, shots=1000)
job_monitor(job, interval = 3)
cal_results = job.result()

meas_fitter = CompleteMeasFitter(cal_results, state_labels, circlabel='mcal')
print(meas_fitter.cal_matrix)

# --- Execution of the noisy quantum circuit

qc = QuantumCircuit(nBits, nBits)
qc.x(1)

qc.measure(qc.qregs[0], qc.cregs[0])
job = execute(qc, provider.get_backend('ibmq_16_melbourne'), shots = shots)
#job = execute(qc, BasicAer.get_backend('qasm_simulator'), shots = shots)
job_monitor(job, interval = 3)
result = job.result()
print(result.get_counts())

# --- Error correction

# Get the filter object
meas_filter = meas_fitter.filter

# Results with mitigation
mitigated_results = meas_filter.apply(result)
mitigated_counts = mitigated_results.get_counts(0)

print(mitigated_counts)

The noisy quantum circuit returns:

{'00': 661, '11': 34, '10': 7494, '01': 3}

The error mitigated noise circuit returns:

{'00': 132.05699755089069, '11': 29.711709316932044, '01': 0.4405790117450936, '10': 8029.790714120432}

Is that what I should expect?

$\endgroup$
  • 2
    $\begingroup$ Hi, @JackOLantern :). Qiskit textbook has a nice tutorial about measurement error mitigation qiskit.org/textbook/ch-quantum-hardware/…. $\endgroup$ – Davit Khachatryan Mar 10 at 17:36
  • 1
    $\begingroup$ @DavitKhachatryan Following your comment and the answer by Martin Vesely, I have prepared the code in the question edit. Is the achieved result what I should expect in practice? $\endgroup$ – JackOLantern Mar 13 at 12:22
  • 2
    $\begingroup$ I think you obtained good improvements. If you want to know more about error mitigation (EM) techniques I recommend these two papers: 10.1103/PhysRevLett.119.180509 and doi.org/10.1038/s41586-019-1040-7, where you can find two EM techniques that don't need additional qubit/gate resources like other error correction techniques. Also, notice, that these techniques are limited, so after some gate number (depth) these techniques are starting to fail to fight the noise. $\endgroup$ – Davit Khachatryan Mar 13 at 14:13
  • 1
    $\begingroup$ @DavitKhachatryan Thank you so much for your comment. Would you transform it as an answer? I would upvote. $\endgroup$ – JackOLantern Mar 13 at 16:43
2
$\begingroup$

I will provide some general comments concerning noise in quantum computers.

Noise in quantum systems is normal phenomena as these systems are probabilistic by nature. Under current state of development, quantum computers unfortunately does not allow to build complex deep circuits.

You can of course use additional qubits to introduce error correction which can be almost perfect with sufficient number of qubits (so-called threshold theorem). But adding qubits and gates introduces another source of noise, so again depth of circuits is constrained.

When quantum computers are in higher state of development, error correction will also be able to mitigate noise more effectively than nowadays.

Concerning the backend you use - Melbourne. My experience is that this processor is very noisy in comparison with others provided in IBM Q. It seems that this is caused by higher number of qubits, so qubits influence each other increasing noise level.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Following your answer and the comment by @DavitKhachatryan, I have prepared the code in the question edit. Is the achieved result what I should expect in practice? $\endgroup$ – JackOLantern Mar 13 at 12:23
  • $\begingroup$ If I understood it correctly, you put $X$ on qubit $q_1$. If there is no noise, the result should be $10$ always. Accroding to results you posted, it seems that after error correction probability of measuring $10$ increased. Probability of measuring $00$ which is result of spontaneus relaxation from state $10$ decreased significantly. So you are on good way to correct for noise. Of course, you are not able to eliminate noise completely but this is OK as quantum systems are probabilistic. $\endgroup$ – Martin Vesely Mar 13 at 13:28
  • 1
    $\begingroup$ Thank you so much. I accepted your answer :-) $\endgroup$ – JackOLantern Mar 13 at 13:46
1
$\begingroup$

As Martin Vesley has mentioned in his answer, there are some error correction techniques that require additional qubits and gates resources, and how we know the resources of nowadays QCs are limited, and that's why those techniques are not so useful today. But in 2017 new error correction techniques were proposed that don't require additional gates/qubits. As stated in the abstract of S. Endo et al [1] paper: two quantum error mitigation (QEM) techniques have been introduced recently, namely, error extrapolation (proposed by Y. Li and S. C. Benjamin [2] and K. Temme et al [3]) and quasiprobability decomposition (proposed by K. Temme et al [3]). How I understand, this Qiskit tutorial is an implementation of the second technique. The tutorial is written very nicely and intuitively, so I highly recommend it.

Here I will try to explain the first technique: error extrapolation. We want to estimate something from our circuit, let's call it $E^*$ (can be the expectation value of Hamiltonian or something else). Because of noise we always obtain a different value than $E^*$. Suppose we have a $\lambda$ parameter (in this experimental paper [4] they used pulse duration as a parameter: the gates are implemented via microwave pulses) that we can change and run different experiments with given values of $\lambda$. This give us different values for $E(\lambda)$ from which we will be able to construct the following system of equations:

\begin{cases} E(\lambda_1) = E^* + Noise(\lambda_1) \\ E(\lambda_2) = E^* + Noise(\lambda_2) \\ E(\lambda_3) = E^* + Noise(\lambda_3) \\ ... \end{cases}

By expressing the $Noise(\lambda)$ with some suitable function (e.g. a polynomial function) one can solve the system of equation and find the desired $E^*$ value "without" noise. In some cases, it works XD. I mean there should be the satisfaction of some conditions (e.g good fitting of chosen function to the actual noise).

These techniques are increasing the circuit depth that can be used, but that increment, of course, is not limitless (more insights can be gained from the Fig.2 from the [4] paper).

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