Skip to main contentIBM Quantum Documentation Mirror

Configure error mitigation

Error mitigation techniques allow users to mitigate circuit errors by modeling the device noise at the time of execution. This typically results in quantum pre-processing overhead related to model training and classical post-processing overhead to mitigate errors in the raw results by using the generated model.

Primitives support several error mitigation techniques, including TREX, ZNE, PEC, and PEA. See Error mitigation and suppression techniques for an explanation of each. When using primitives, you can turn on or off individual methods. See the Custom error settings section for details.

Estimator also supports resilience_level. The resilience level specifies how much resilience to build against errors. Higher levels generate more accurate results, at the expense of longer processing times. Resilience levels can be used to configure the cost/accuracy trade-off when applying error mitigation to your primitive query. Error mitigation reduces errors (bias) in results by processing the outputs from a collection, or ensemble, of related circuits. The degree of error reduction depends on the method applied. The resilience level abstracts the detailed choice of error mitigation method to allow users to reason about the cost/accuracy trade that is appropriate to their application.

Given this, each level corresponds to a method or methods with increasing level of quantum sampling overhead to enable you experiment with different time-accuracy tradeoffs. The following table shows you which levels and corresponding methods are available for each of the primitives.

Attention

Error mitigation is task-specific, so the techniques you can apply vary based whether you are sampling a distribution or generating expectation values.

Estimator supports the following resilience levels. Sampler does not support resilience levels.

Resilience LevelDefinitionTechnique
0No mitigationNone
1 [Default]Minimal mitigation costs: Mitigate error associated with readout errorsTwirled Readout Error eXtinction (TREX) measurement twirling
2Medium mitigation costs. Typically reduces bias in estimators, but is not guaranteed to be zero-bias.Level 1 + Zero Noise Extrapolation (ZNE) and gate twirling
Attention

Resilience levels are currently in beta so sampling overhead and solution quality will vary from circuit to circuit. New features, advanced options, and management tools will be released on a rolling basis. Specific error mitigation methods are not guaranteed to be applied at each resilience level.

Note

If using an IBM Cloud® Qiskit Runtime service instance with Q-CTRL performance management enabled, do not specify runtime optimization or resilience levels, as the strategy includes an automatic preset.

Setting optimization_level or resilience_level equal to 0 will result in an execution error. Levels 1, 2, and 3 are permitted but will not impact performance. Setting other options will likewise not impact performance, and it may result in a runtime warning. For more information visit the Q-CTRL documentation(opens in a new tab).


Configure Estimator with resilience levels

You can use resilience levels to specify error mitigation techniques, or you can set custom techniques individually as described in Custom error settings. You cannot specify resilience levels in Sampler. However, you can set custom techniques individually.

Resilience Level 0

No error mitigation is applied to the user program.

Resilience Level 1

Level 1 applies readout error mitigation and measurement twirling by applying a model-free technique known as Twirled Readout Error eXtinction (TREX). It reduces measurement error by diagonalizing the noise channel associated with measurement by randomly flipping qubits through X gates immediately before measurement. A rescaling term from the diagonal noise channel is learned by benchmarking random circuits initialized in the zero state. This allows the service to remove bias from expectation values that result from readout noise. This approach is described further in Model-free readout-error mitigation for quantum expectation values(opens in a new tab).

Resilience Level 2

Level 2 applies the error mitigation techniques included in level 1 and also applies gate twirling and uses the Zero Noise Extrapolation method (ZNE). ZNE computes an expectation value of the observable for different noise factors (amplification stage) and then uses the measured expectation values to infer the ideal expectation value at the zero-noise limit (extrapolation stage). This approach tends to reduce errors in expectation values, but is not guaranteed to produce an unbiased result.

This image shows a graph.  The x-axis is labeled Noise amplification factor.  The y-axis is labeled Expectation value.  An upward sloping line is labeled Mitigated value.  Points near the line are noise-amplified values.  There is a horizontal line just above the X-axis labeled Exact value.
Illustration of the ZNE method

The overhead of this method scales with the number of noise factors. The default settings sample the expectation value at three noise factors, leading to a roughly 3x overhead when employing this resilience level.

In Level 2, the TREX method randomly flips qubits through X gates immediately before measurement, and flips the corresponding measured bit if an X gate was applied. This approach is described further in Model-free readout-error mitigation for quantum expectation values(opens in a new tab).

Example

The EstimatorV2 interface lets users seamlessly work with the variety of error mitigation methods to reduce error in expectation values of observables. The following code uses Zero Noise Extrapolation and readout error mitigation by simply setting resilience_level 2.

from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime import EstimatorV2 as Estimator
 
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
 
# Setting options during primitive initialization
estimator = Estimator(backend, options={"resilience_level": 2})

Custom error settings

You can turn on and off individual error mitigation and suppression methods, including dynamical decoupling, gate and measurement twirling, measurement error mitigation, PEC, and ZNE. See Error mitigation and suppression techniques for an explanation of each.

Notes
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime import EstimatorV2 as Estimator
 
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
 
estimator = Estimator(backend)
options = estimator.options
# Turn on gate twirling.
options.twirling.enable_gates = True
# Turn on measurement error mitigation.
options.resilience.measure_mitigation = True
 
print(f">>> gate twirling is turned on: {estimator.options.twirling.enable_gates}")
print(f">>> measurement error mitigation is turned on: {estimator.options.resilience.measure_mitigation}")

Turn off all error mitigation

For instructions to turn off all error mitigation, see the Turn off all error suppression and mitigation section.


Next steps

Recommendations