Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced resilience options #603

Merged
merged 8 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions qiskit_ibm_runtime/options/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .execution_options import ExecutionOptions
from .simulator_options import SimulatorOptions
from .transpilation_options import TranspilationOptions
from .resilience_options import ResilienceOptions
from ..runtime_options import RuntimeOptions


Expand Down Expand Up @@ -73,6 +74,9 @@ class Options:
transpilation: Union[TranspilationOptions, Dict] = field(
default_factory=TranspilationOptions
)
resilience: Union[ResilienceOptions, Dict] = field(
default_factory=ResilienceOptions
)
execution: Union[ExecutionOptions, Dict] = field(default_factory=ExecutionOptions)
environment: Union[EnvironmentOptions, Dict] = field(
default_factory=EnvironmentOptions
Expand Down
51 changes: 51 additions & 0 deletions qiskit_ibm_runtime/options/resilience_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Resilience options."""

from typing import Optional, Sequence
from dataclasses import dataclass
from typing_extensions import Literal

from .utils import _flexible

NoiseAmplifierType = Literal[
"TwoQubitAmplifier",
"GlobalFoldingAmplifier",
"LocalFoldingAmplifier",
"CxAmplifier",
]
ExtrapolatorType = Literal[
"LinearExtrapolator",
"QuadraticExtrapolator",
"CubicExtrapolator",
"QuarticExtrapolator",
]


@_flexible
@dataclass
class ResilienceOptions:
"""Resilience options.

Args:
noise_factors: An list of real valued noise factors that determine by what amount the
circuits' noise is amplified. Default: (1, 3, 5).

noise_amplifier: A noise amplification strategy. Default: "TwoQubitAmplifier".

extrapolator: An extrapolation strategy. Default: "LinearExtrapolator".
"""

noise_amplifier: NoiseAmplifierType = "TwoQubitAmplifier"
noise_factors: Sequence[float] = (1, 3, 5)
extrapolator: ExtrapolatorType = "LinearExtrapolator"
6 changes: 6 additions & 0 deletions releasenotes/notes/resilience_settings-80eb23a095f0381c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
Advanced resilience options can now be set under ``options.resilience``.
See :class:`qiskit_ibm_runtime.options.ResilienceOptions` for all
available options.
7 changes: 5 additions & 2 deletions test/unit/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_program_inputs(self):
execution={"shots": 100},
environment={"log_level": "DEBUG"},
simulator={"noise_model": noise_model},
resilience={"seed_mitigation": 42},
resilience={"noise_amplifier": "GlobalFoldingAmplifier"},
foo="foo",
)

Expand All @@ -141,7 +141,10 @@ def test_program_inputs(self):
"skip_transpilation": True,
"initial_layout": [1, 2],
},
"resilience_settings": {"level": 2, "seed_mitigation": 42},
"resilience_settings": {
"level": 2,
"noise_amplifier": "GlobalFoldingAmplifier",
},
"foo": "foo",
}
self.assertTrue(
Expand Down