Qiskit – Practical open source framework for quantum computing

Quantum Error Mitigation

Quantum error mitigation paves the way for commercial use of quantum computers, and it is an important technique for using today's quantum computers without fault-tolerant qubits. Qiskit supports quantum error mitigation through the use of a correction matrix to improve the quality of the results. A simple example of measurement error mitigation will illustrate this technique.

A simpler form of noise can be generated by the final measurement in the circuit (Listing 6). At this point, one of the possible bit strings is extracted; this is not an exact process due to the noise caused by the measurement, among other things. Again the GHZ circuit is used as an example. You have already seen the simulation of a noise-free result. When run on a real quantum computer, the noise is clearly seen in the broader distribution, which includes probabilities of the incorrect states (Figure 6).

Listing 6

Plotting the Results

from qiskit.visualization import plot_histogram
qdev = my_provider.get_backend( 'ibmq_lima' )
results = execute( qc, qdev, shots=10000 ).result()
noisy_counts = results.get_counts()
print( noisy_counts )
plot_histogram( noisy_counts )
Figure 6: A simpler form of noise can be generated by final measurement in the circuit.

In the simple case of an error-mitigation concept, the individual eight basic states resulting from the three qubits of the GHZ circuit are now traversed (Listing 7).

Listing 7

Traversing the Basic States

from qiskit.utils.mitigation import *
qr = QuantumRegister( 2 )
meas_calibs, state_labels = complete_meas_cal( qr=qr, circlabel='mcal' )
for circuit in meas_calibs:

As an example, Figure 7 shows three of the eight circuits. The correction matrix from Figure 8 can be calculated from the individual measurement results; this takes the deviations into account. This correction is then applied to the measurement results from the sample circuit (Listing 8). Figure 9 clearly shows that the measurement error mitigation method corrects the errors caused by noise in a very good way.

Listing 8

Create Correction Matrix

from qiskit.compiler import transpile, assemble
t_qc = transpile( meas_calibs, qdev )
qobj = assemble( t_qc, shots=10000 )
cal_results = qdev.run( qobj, shots=10000 ).result()
meas_fitter = CompleteMeasFitter( cal_results, state_labels, circlabel='mcal' )
array_to_latex( meas_fitter.cal_matrix )
# Get the filter object
meas_filter = meas_fitter.filter
# Results with mitigation
mitigated_results = meas_filter.apply( results )
mitigated_counts = mitigated_results.get_counts()
noisy_counts = results.get_counts()
plot_histogram( [ noisy_counts, mitigated_counts ], legend=[ 'noisy', 'mitigated' ] )
Figure 7: In the simple case of an error-avoidance concept, the eight individual basic states resulting from the three qubits of the GHZ circuit are now traversed. Here, three of the eight circuits are shown.
Figure 8: A correction matrix can be calculated from the individual measurement results, taking the deviations into account.
Figure 9: Measurement error mitigation by means of a correction matrix helps to correct the errors caused by noise.

Because the cost of additional measurements to determine the correction matrix grows exponentially with the number of qubits, this method has been further refined, resulting in effective error mitigation even if a larger number of qubits is used.

In Qiskit, this advanced method shows up in the output resulting from Sampler primitives (quasi-probabilities). Again using the simple circuit for the GHZ state, the calculation with Sampler on the non-noise free QASM simulator is shown in Listing 9. The almost uniform probability distribution of the two correct states is shown here in the quasi-probability distribution.

Listing 9

Refined Method

service = QiskitRuntimeService()
with Sampler( circuits=[qc], service=service, options={ "backend": "ibmq_qasm_simulator" } ) as sampler:
  result = sampler( circuits=[0], shots=10000 )
  print( result )
SamplerResult( quasi_dists=[{'000': 0.4944, '111': 0.5056}], metadata=['shots': 10000}] )

One focus of current research on quantum error mitigation is on more advanced, general-purpose methods. Zero-Noise Extrapolation (ZNE) and Probabilistic Error Cancellation (PEC) are both promising techniques. In ZNE, you work directly with noise amplification in the circuit; in PEC, you identify the noise using randomly selected instances of noisy circuits. A blog post by IBM Research on the utility value of these methods provides a more detailed overview [12].


Qiskit is the effort of a large community to make quantum computing technology understandable and applicable and get it ready for production. Community contributions, such as meetups or an annual summer school, are essential to the project's continued development. This article is intended as another example of how you can take your first steps in quantum computing.

The Author

Under the leadership of Dr. Stefan Kister, Jana Foehlisch, Daniel Kaulen, Konstantin Konson, Dr. Jan-Rainer Lahmann, Marcel Pfaffhauser, and Bengt Wegner from IBM worked together to present this article as a good example of contribution to the open source community around Qiskit. They also receive support from quantum technology students Catharina Broocks and Jakob Pforr.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Quantum Computing

    The peculiar world of quantum mechanics points the way to a whole new kind of computer. If you're wondering how quantum computers work, we'll give you an inside view.

  • Quantum Computing and Encryption

    The encryption methods we use today are no match for tomorrow's quantum computers. We'll show you why and what's ahead for cryptography in the post-quantum era.

  • Google and NASA Partner in Quantum Computing Project

    Vendor D-Wave scores big with a sale to NASA's Quantum Intelligence Lab.

  • Program Library for Quantum Simulation Leaps to Version 0.9.1

    If you'll pardon the pun, the Libquantum C library has now leaped from version 0.2.4 to 0.9.1 after three years of seeming inactivity. The new version includes a new API which gives users the ability to simulate quantum mechanics.

  • NEWS

    Kubernetes 1.8 announced, final Ubuntu Desktop 17.10 Beta arrives, Linus Torvalds invites attackers to join the kernel community, Oracle donates Java EE to the Eclipse Foundation, and Microsoft is building a programming language for quantum computers. 

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More