Configure noise management with Sampler
The code on this page was developed using the following requirements. We recommend using these versions or newer.
qiskit-ibm-runtime~=0.45.1
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.
Not all options work together on all types of circuits. See the feature compatibility table guide for full details.
Example
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime import SamplerV2 as 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: {sampler.options.dynamical_decoupling.sequence_type}"
)
print(
f">>> gate twirling is turned on: {sampler.options.twirling.enable_gates}"
)Output:
>>> dynamical decoupling sequence to use: XpXm
>>> gate twirling is turned on: True
Can't remember the right attributes? Try asking Qiskit Code Assistant.
# Enable dynamic decoupling for Sampler with the 'XpXm' sequence typeNew to the code assistant? See Qiskit Code Assistant for installation and usage. Note this is an experimental feature and only available to IBM Quantum Premium Plan users.
Next steps
- Learn more about error mitigation and error suppression techniques.
- Explore Sampler options.
- Decide what execution mode to run your job in.