Configure noise management with Sampler
Package versions
The code on this page was developed using the following requirements. We recommend using these versions or newer.
qiskit-ibm-runtime~=0.47.0
There are several ways to manage noise, typically by using various error mitigation and error suppression techniques to avoid errors before they happen. These techniques usually cause pre-processing overhead. Therefore, it is important to achieve a balance between perfecting your results and ensuring that your job completes in a reasonable amount of time.
Sampler supports the following noise management techniques. See Error mitigation and suppression techniques for an explanation of each.
note
Not all options work together on all types of circuits. See the feature compatibility table guide for full details.
Example
# Added by doQumentation — installs the packages this notebook needs if they are missing
import importlib.util
_needed = {"qiskit_ibm_runtime": "qiskit-ibm-runtime"}
_missing = [pip for module, pip in _needed.items()
if importlib.util.find_spec(module) is None]
# One at a time, so a package that fails to install does not block the others
for _pip in _missing:
%pip install -q {_pip}
if not _missing:
print("\u2713 All required packages are installed")
from qiskit_ibm_runtime import QiskitRuntimeService
# Legacy server-side primitive before qiskit-ibm-runtime 0.50.0
# from qiskit_ibm_runtime import Sampler
# Client-side primitive introduced in qiskit-ibm-runtime 0.50.0
from qiskit_ibm_runtime.executor_sampler import Sampler
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
sampler = Sampler(backend)
# Turn on dynamical decoupling with sequence XpXm.
sampler.options.dynamical_decoupling.enable = True
sampler.options.dynamical_decoupling.sequence_type = "XpXm"
# Turn on gate twirling. Requires qiskit_ibm_runtime 0.23.0 or later.
sampler.options.twirling.enable_gates = True
print(
f">>> dynamical decoupling sequence to use: "
f"{sampler.options.dynamical_decoupling.sequence_type}"
)
print(
f">>> gate twirling is turned on: {sampler.options.twirling.enable_gates}"
)
>>> dynamical decoupling sequence to use: XpXm
>>> gate twirling is turned on: True
Next steps
Recommendations
- Learn more about error mitigation and error suppression techniques.
- Explore Sampler options.
- Decide what execution mode to run your job in.