From a20fa88412dd400536d5821badbb4b2ac2f1ed2e Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Wed, 11 Oct 2023 07:40:12 +0300 Subject: [PATCH] Support only LocalFoldingAmplifier as noise_amplifier option (#1093) * Removed support for all noise_amplifier options other than LocalFoldingAmplifier. Removed deprecation warning. * Removed tests that covered deprecation. Updated documentation --------- Co-authored-by: Kevin Tian --- docs/how_to/error-mitigation.rst | 15 +++-------- .../options/resilience_options.py | 24 +++-------------- test/unit/test_estimator.py | 26 +------------------ 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/docs/how_to/error-mitigation.rst b/docs/how_to/error-mitigation.rst index edbcfdaa4..34a00d36c 100644 --- a/docs/how_to/error-mitigation.rst +++ b/docs/how_to/error-mitigation.rst @@ -191,17 +191,8 @@ As a part of the beta release of the resilience options, users will be able conf +---------------------------------------------------------------+----------------------------------+--------------------------------------------------------+ | Options | Inputs | Description | +===============================================================+==================================+========================================================+ -| options.resilience.noise_amplifier(Optional[str]) | ``TwoQubitAmplifier`` [Default] | Amplifies noise of all two qubit gates by performing | -| | | local gate folding. | -| select your amplification strategy +----------------------------------+--------------------------------------------------------+ -| | ``CxAmplifier`` | Amplifies noise of all CNOT gates by performing local | -| | | gate folding. | -| +----------------------------------+--------------------------------------------------------+ -| | ``LocalFoldingAmplifier`` | Amplifies noise of all gates by performing local | -| | | gate folding. | -| +----------------------------------+--------------------------------------------------------+ -| | ``GlobalFoldingAmplifier`` | Amplifies noise of the input circuit by performing | -| | | global folding of the entire input circuit. | +| options.resilience.noise_amplifier(Optional[str]) | ``LocalFoldingAmplifier`` | Amplifies noise of all gates by performing local | +| (currently only one available option) | | gate folding. | +---------------------------------------------------------------+----------------------------------+--------------------------------------------------------+ | options.resilience.noise_factors((Optional[Sequence[float]]) | (1, 3, 5) [Default] | Noise amplification factors, where `1` represents the | | | | baseline noise. They all need to be greater than or | @@ -228,7 +219,7 @@ Example of adding ``resilience_options`` into your estimator session options.optimization_level = 3 options.resilience_level = 2 options.resilience.noise_factors = (1, 2, 3, 4) - options.resilience.noise_amplifier = 'CxAmplifier' + options.resilience.noise_amplifier = 'LocalFoldingAmplifier' options.resilience.extrapolator = 'QuadraticExtrapolator' diff --git a/qiskit_ibm_runtime/options/resilience_options.py b/qiskit_ibm_runtime/options/resilience_options.py index 017a0b07d..c15638c1a 100644 --- a/qiskit_ibm_runtime/options/resilience_options.py +++ b/qiskit_ibm_runtime/options/resilience_options.py @@ -16,7 +16,6 @@ from dataclasses import dataclass from .utils import _flexible -from ..utils.deprecation import issue_deprecation_msg ResilienceSupportedOptions = Literal[ "noise_amplifier", @@ -24,10 +23,7 @@ "extrapolator", ] NoiseAmplifierType = Literal[ - "TwoQubitAmplifier", - "GlobalFoldingAmplifier", "LocalFoldingAmplifier", - "CxAmplifier", ] ExtrapolatorType = Literal[ "LinearExtrapolator", @@ -48,10 +44,9 @@ class ResilienceOptions: Only applicable for ``resilience_level=2``. Default: ``None``, and (1, 3, 5) if resilience level is 2. - noise_amplifier (DEPRECATED): A noise amplification strategy. One of ``"TwoQubitAmplifier"``, - ``"GlobalFoldingAmplifier"``, ``"LocalFoldingAmplifier"``, ``"CxAmplifier"``. - Only applicable for ``resilience_level=2``. - Default: "TwoQubitAmplifier". + noise_amplifier (DEPRECATED): A noise amplification strategy. Currently only + ``"LocalFoldingAmplifier"`` is supported Only applicable for ``resilience_level=2``. + Default: "LocalFoldingAmplifier". extrapolator: An extrapolation strategy. One of ``"LinearExtrapolator"``, ``"QuadraticExtrapolator"``, ``"CubicExtrapolator"``, ``"QuarticExtrapolator"``. @@ -75,21 +70,10 @@ def validate_resilience_options(resilience_options: dict) -> None: ValueError: if extrapolator == "QuarticExtrapolator" and number of noise_factors < 5. ValueError: if extrapolator == "CubicExtrapolator" and number of noise_factors < 4. """ - if resilience_options.get("noise_amplifier", None) is not None: - issue_deprecation_msg( - msg="The 'noise_amplifier' resilience option is deprecated", - version="0.12.0", - period="1 month", - remedy="After the deprecation period, only local folding amplification " - "will be supported. " - "Refer to https://github.com/qiskit-community/prototype-zne " - "for global folding amplification in ZNE.", - ) - for opt in resilience_options: if not opt in get_args(ResilienceSupportedOptions): raise ValueError(f"Unsupported value '{opt}' for resilience.") - noise_amplifier = resilience_options.get("noise_amplifier") or "TwoQubitAmplifier" + noise_amplifier = resilience_options.get("noise_amplifier") or "LocalFoldingAmplifier" if noise_amplifier not in get_args(NoiseAmplifierType): raise ValueError( f"Unsupported value {noise_amplifier} for noise_amplifier. " diff --git a/test/unit/test_estimator.py b/test/unit/test_estimator.py index fdc3e96af..6212ad81e 100644 --- a/test/unit/test_estimator.py +++ b/test/unit/test_estimator.py @@ -12,15 +12,13 @@ """Tests for estimator class.""" -import warnings from qiskit import QuantumCircuit from qiskit.quantum_info import SparsePauliOp -from qiskit_ibm_runtime import Estimator, Session, Options +from qiskit_ibm_runtime import Estimator, Session from ..ibm_test_case import IBMTestCase -from ..utils import get_mocked_backend from .mock.fake_runtime_service import FakeRuntimeService @@ -47,25 +45,3 @@ def test_unsupported_values_for_estimator_options(self): with self.assertRaises(ValueError) as exc: _ = inst.run(self.circuit, observables=self.observables, **bad_opt) self.assertIn(list(bad_opt.keys())[0], str(exc.exception)) - - def test_deprecated_noise_amplifier(self): - """Test noise_amplifier deprecation.""" - opt = Options() - opt.resilience.noise_amplifier = "GlobalFoldingAmplifier" - - with warnings.catch_warnings(record=True) as warn: - warnings.simplefilter("always") - estimator = Estimator(backend=get_mocked_backend(), options=opt) - estimator.run(self.circuit, self.observables) - self.assertEqual(len(warn), 1, "Deprecation warning not found.") - self.assertIn("noise_amplifier", str(warn[-1].message)) - - def test_deprecated_noise_amplifier_run(self): - """Test noise_amplifier deprecation in run.""" - - with warnings.catch_warnings(record=True) as warn: - warnings.simplefilter("always") - estimator = Estimator(backend=get_mocked_backend()) - estimator.run(self.circuit, self.observables, noise_amplifier="GlobalFoldingAmplifier") - self.assertEqual(len(warn), 1, "Deprecation warning not found.") - self.assertIn("noise_amplifier", str(warn[-1].message))