From ee943840efdccb1999a9e70fe1b440288a299e0b Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 23 Oct 2024 14:28:46 -0400 Subject: [PATCH] Deprecate pulse and restless related experiments and classes This change deprecates the experiments that rely on scanning the parameters of pulses in pulse gate calibrations. Qiskit 2.0 will remove support for pulse gate calibrations, making these experiments impossible to run. The `Calibrations` and `BasisGateLibrary` classes are also deprecated since they have no use without pulse gate calibrations to track. It is planned that Qiskit Pulse will be moved to Qiskit Dynamics and perhaps the experiments and calibrations can be adapted to that use case for calibrating simulated experiments. For now though, this code is removed from Qiskit Experiments to help with making the package more maintainable. Support for restless experiments is also deprecated with this change. Restless support is distinct from pulse support, but it is deprecated with the same motivation of simplifying the package overall. With improvements in the reliability of IBM Quantum's qubit initialization, circuit exectuion has already become reasonably fast and restless measurements do not add much performance improvement. It is expected that the restless features are little used as there has been no user feedback about them. --- .../characterization/stark_experiment.rst | 8 +++++ .../measurement/restless_measurements.rst | 8 +++++ docs/tutorials/calibrations.rst | 11 +++++++ docs/tutorials/data_processor.rst | 11 +++++++ docs/tutorials/visualization.rst | 11 +++++++ .../basis_gate_library.py | 9 ++++++ .../calibration_management/calibrations.py | 8 +++++ .../framework/restless_mixin.py | 6 ++++ .../characterization/cr_hamiltonian.py | 9 ++++++ .../library/characterization/drag.py | 17 ++++++++++ .../multi_state_discrimination.py | 9 ++++++ .../characterization/qubit_spectroscopy.py | 8 +++++ .../library/characterization/rabi.py | 25 +++++++++++++++ .../library/characterization/spectroscopy.py | 9 ++++++ .../library/driven_freq_tuning/p1_spect.py | 9 ++++++ .../library/driven_freq_tuning/ramsey.py | 9 ++++++ .../driven_freq_tuning/ramsey_amp_scan.py | 9 ++++++ .../deprecate-pulse-2a13fc783985ac27.yaml | 32 +++++++++++++++++++ test/base.py | 14 ++++++++ 19 files changed, 222 insertions(+) create mode 100644 releasenotes/notes/deprecate-pulse-2a13fc783985ac27.yaml diff --git a/docs/manuals/characterization/stark_experiment.rst b/docs/manuals/characterization/stark_experiment.rst index fd4f11fbda..6819d4272a 100644 --- a/docs/manuals/characterization/stark_experiment.rst +++ b/docs/manuals/characterization/stark_experiment.rst @@ -145,6 +145,14 @@ by a variant of the Hahn-echo pulse sequence [5]_. %matplotlib inline + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + from qiskit_experiments.library import StarkRamseyXY from qiskit import schedule, pulse from qiskit_ibm_runtime.fake_provider import FakeHanoiV2 diff --git a/docs/manuals/measurement/restless_measurements.rst b/docs/manuals/measurement/restless_measurements.rst index 313d4cde94..379d5fe391 100644 --- a/docs/manuals/measurement/restless_measurements.rst +++ b/docs/manuals/measurement/restless_measurements.rst @@ -65,6 +65,14 @@ they use always starts with the qubits in the ground state. .. jupyter-execute:: :hide-code: + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Support for restless.*", + category=DeprecationWarning, + ) + # Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime from qiskit_experiments.test.patching import patch_sampler_test_support patch_sampler_test_support() diff --git a/docs/tutorials/calibrations.rst b/docs/tutorials/calibrations.rst index f26e2e7373..1412d94a8a 100644 --- a/docs/tutorials/calibrations.rst +++ b/docs/tutorials/calibrations.rst @@ -33,6 +33,17 @@ This automatic updating can also be disabled using the ``auto_update`` flag. This tutorial requires the :mod:`qiskit_dynamics` package to run simulations. You can install it with ``python -m pip install qiskit-dynamics``. +.. jupyter-execute:: + :hide-code: + + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + .. jupyter-execute:: import pandas as pd diff --git a/docs/tutorials/data_processor.rst b/docs/tutorials/data_processor.rst index 96eb265a0c..890a1a164e 100644 --- a/docs/tutorials/data_processor.rst +++ b/docs/tutorials/data_processor.rst @@ -68,6 +68,17 @@ The code below sets up the Rabi experiment. This tutorial requires the :mod:`qiskit_dynamics` package to run simulations. You can install it with ``python -m pip install qiskit-dynamics``. +.. jupyter-execute:: + :hide-code: + + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + .. jupyter-execute:: import numpy as np diff --git a/docs/tutorials/visualization.rst b/docs/tutorials/visualization.rst index de971ef8bb..e9dd4a38c0 100644 --- a/docs/tutorials/visualization.rst +++ b/docs/tutorials/visualization.rst @@ -38,6 +38,17 @@ First, we display the default figure from a :class:`.Rabi` experiment as a start :external+qiskit_ibm_runtime:doc:`qiskit-ibm-runtime ` packages to run simulations. You can install them with ``python -m pip install qiskit-dynamics qiskit-aer qiskit-ibm-runtime``. +.. jupyter-execute:: + :hide-code: + + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + .. jupyter-execute:: import numpy as np diff --git a/qiskit_experiments/calibration_management/basis_gate_library.py b/qiskit_experiments/calibration_management/basis_gate_library.py index c5fd5a6781..cbc69d225c 100644 --- a/qiskit_experiments/calibration_management/basis_gate_library.py +++ b/qiskit_experiments/calibration_management/basis_gate_library.py @@ -25,6 +25,7 @@ from qiskit.circuit import Parameter from qiskit import pulse from qiskit.pulse import ScheduleBlock +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.calibration_management.calibration_key_types import DefaultCalValue from qiskit_experiments.exceptions import CalibrationError @@ -39,6 +40,14 @@ class BasisGateLibrary(ABC, Mapping): # Parameters that do not belong to a schedule, a set of names __parameters_without_schedule__ = set() + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, support for pulse " + "gate calibrations has been deprecated." + ), + ) def __init__( self, basis_gates: Optional[List[str]] = None, diff --git a/qiskit_experiments/calibration_management/calibrations.py b/qiskit_experiments/calibration_management/calibrations.py index 4058dcad7e..af5572570f 100644 --- a/qiskit_experiments/calibration_management/calibrations.py +++ b/qiskit_experiments/calibration_management/calibrations.py @@ -63,6 +63,14 @@ class Calibrations: ScheduleBlock are supported. """ + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, support for pulse " + "gate calibrations has been deprecated." + ), + ) def __init__( self, coupling_map: Optional[List[List[int]]] = None, diff --git a/qiskit_experiments/framework/restless_mixin.py b/qiskit_experiments/framework/restless_mixin.py index 19d65c238f..7a75cbd596 100644 --- a/qiskit_experiments/framework/restless_mixin.py +++ b/qiskit_experiments/framework/restless_mixin.py @@ -15,6 +15,7 @@ import logging from typing import Callable, Sequence, Optional from qiskit.qobj.utils import MeasLevel, MeasReturnType +from qiskit.utils.deprecation import deprecate_func from qiskit.providers import Backend from qiskit_experiments.framework import Options @@ -66,6 +67,11 @@ class makes it easy to determine if restless measurements are supported for a gi _physical_qubits: Sequence[int] _num_qubits: int + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=("Support for restless experiments has been deprecated."), + ) def enable_restless( self, rep_delay: Optional[float] = None, diff --git a/qiskit_experiments/library/characterization/cr_hamiltonian.py b/qiskit_experiments/library/characterization/cr_hamiltonian.py index 96ec192f60..b9e481ef7e 100644 --- a/qiskit_experiments/library/characterization/cr_hamiltonian.py +++ b/qiskit_experiments/library/characterization/cr_hamiltonian.py @@ -20,6 +20,7 @@ from qiskit.circuit.parameterexpression import ParameterValueType from qiskit.exceptions import QiskitError from qiskit.providers import Backend +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import ( BaseExperiment, BackendTiming, @@ -134,6 +135,14 @@ class CRPulseGate(circuit.Gate): def __init__(self, width: ParameterValueType): super().__init__("cr_gate", 2, [width]) + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Tuple[int, int], diff --git a/qiskit_experiments/library/characterization/drag.py b/qiskit_experiments/library/characterization/drag.py index d7ede194ca..ce8647495a 100644 --- a/qiskit_experiments/library/characterization/drag.py +++ b/qiskit_experiments/library/characterization/drag.py @@ -20,6 +20,7 @@ from qiskit.exceptions import QiskitError from qiskit.providers.backend import Backend from qiskit.pulse import ScheduleBlock +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BaseExperiment, Options from qiskit_experiments.framework.restless_mixin import RestlessMixin @@ -68,6 +69,14 @@ class RoughDrag(BaseExperiment, RestlessMixin): .. jupyter-execute:: :hide-code: + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + # backend from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=101) @@ -120,6 +129,14 @@ def _default_experiment_options(cls) -> Options: return options + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], diff --git a/qiskit_experiments/library/characterization/multi_state_discrimination.py b/qiskit_experiments/library/characterization/multi_state_discrimination.py index b0a33b9313..4acb492e94 100644 --- a/qiskit_experiments/library/characterization/multi_state_discrimination.py +++ b/qiskit_experiments/library/characterization/multi_state_discrimination.py @@ -12,6 +12,7 @@ """Multi state discrimination experiment.""" +import warnings from typing import Dict, List, Optional, Sequence from qiskit import QuantumCircuit @@ -141,6 +142,14 @@ def circuits(self) -> List[QuantumCircuit]: Returns: A list of circuits preparing the different energy states. """ + warnings.warn( + ( + "Setting pulse schedules for x gates is deprecated as of " + "version 0.8 due to the deprecation of Qiskit Pulse. It will be " + "removed in a future release." + ), + DeprecationWarning, + ) circuits = [] for level in range(self.experiment_options.n_states): circuit = QuantumCircuit(1) diff --git a/qiskit_experiments/library/characterization/qubit_spectroscopy.py b/qiskit_experiments/library/characterization/qubit_spectroscopy.py index a915bb98f3..1ca8b1b61c 100644 --- a/qiskit_experiments/library/characterization/qubit_spectroscopy.py +++ b/qiskit_experiments/library/characterization/qubit_spectroscopy.py @@ -49,6 +49,14 @@ class QubitSpectroscopy(Spectroscopy): .. jupyter-execute:: :hide-code: + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + # backend from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=199) diff --git a/qiskit_experiments/library/characterization/rabi.py b/qiskit_experiments/library/characterization/rabi.py index c8d997116c..7306ce23f5 100644 --- a/qiskit_experiments/library/characterization/rabi.py +++ b/qiskit_experiments/library/characterization/rabi.py @@ -21,6 +21,7 @@ from qiskit.providers import Backend from qiskit.pulse import ScheduleBlock from qiskit.exceptions import QiskitError +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BaseExperiment, Options from qiskit_experiments.framework.restless_mixin import RestlessMixin @@ -61,6 +62,14 @@ class Rabi(BaseExperiment, RestlessMixin): .. jupyter-execute:: :hide-code: + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + # backend from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend backend = SingleTransmonTestBackend(5.2e9,-0.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=199) @@ -115,6 +124,14 @@ def _default_experiment_options(cls) -> Options: return options + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], @@ -230,6 +247,14 @@ class EFRabi(Rabi): .. jupyter-execute:: :hide-code: + import warnings + + warnings.filterwarnings( + "ignore", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + # backend from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend backend = SingleTransmonTestBackend(5.2e9, -0.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=198) diff --git a/qiskit_experiments/library/characterization/spectroscopy.py b/qiskit_experiments/library/characterization/spectroscopy.py index 90ec4b9281..2d3454d8c2 100644 --- a/qiskit_experiments/library/characterization/spectroscopy.py +++ b/qiskit_experiments/library/characterization/spectroscopy.py @@ -20,6 +20,7 @@ from qiskit.exceptions import QiskitError from qiskit.providers import Backend from qiskit.qobj.utils import MeasLevel +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BaseAnalysis, BaseExperiment, Options from qiskit_experiments.curve_analysis import ResonanceAnalysis @@ -60,6 +61,14 @@ def _default_run_options(cls) -> Options: return options + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], diff --git a/qiskit_experiments/library/driven_freq_tuning/p1_spect.py b/qiskit_experiments/library/driven_freq_tuning/p1_spect.py index 5ee1bbc18e..77382a3db2 100644 --- a/qiskit_experiments/library/driven_freq_tuning/p1_spect.py +++ b/qiskit_experiments/library/driven_freq_tuning/p1_spect.py @@ -20,6 +20,7 @@ from qiskit.circuit import QuantumCircuit, Gate, Parameter, ParameterExpression from qiskit.providers.backend import Backend from qiskit.utils import optionals as _optional +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BackendTiming, BaseExperiment, Options from .p1_spect_analysis import StarkP1SpectAnalysis @@ -72,6 +73,14 @@ class StarkP1Spectroscopy(BaseExperiment): """ + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], diff --git a/qiskit_experiments/library/driven_freq_tuning/ramsey.py b/qiskit_experiments/library/driven_freq_tuning/ramsey.py index e214a5c4b4..fc46b198cf 100644 --- a/qiskit_experiments/library/driven_freq_tuning/ramsey.py +++ b/qiskit_experiments/library/driven_freq_tuning/ramsey.py @@ -21,6 +21,7 @@ from qiskit.circuit import QuantumCircuit, Gate, Parameter from qiskit.providers.backend import Backend from qiskit.utils import optionals as _optional +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BaseExperiment, Options, BackendTiming from qiskit_experiments.library.characterization.analysis import RamseyXYAnalysis @@ -88,6 +89,14 @@ class StarkRamseyXY(BaseExperiment): """ + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], diff --git a/qiskit_experiments/library/driven_freq_tuning/ramsey_amp_scan.py b/qiskit_experiments/library/driven_freq_tuning/ramsey_amp_scan.py index 528c3fd8bd..e5781ab5fb 100644 --- a/qiskit_experiments/library/driven_freq_tuning/ramsey_amp_scan.py +++ b/qiskit_experiments/library/driven_freq_tuning/ramsey_amp_scan.py @@ -20,6 +20,7 @@ from qiskit.circuit import QuantumCircuit, Gate, ParameterExpression, Parameter from qiskit.providers.backend import Backend from qiskit.utils import optionals as _optional +from qiskit.utils.deprecation import deprecate_func from qiskit_experiments.framework import BaseExperiment, Options, BackendTiming from .ramsey_amp_scan_analysis import StarkRamseyXYAmpScanAnalysis @@ -93,6 +94,14 @@ class StarkRamseyXYAmpScan(BaseExperiment): """ + @deprecate_func( + since="0.8", + package_name="qiskit-experiments", + additional_msg=( + "Due to the deprecation of Qiskit Pulse, experiments involving pulse " + "gate calibrations like this one have been deprecated." + ), + ) def __init__( self, physical_qubits: Sequence[int], diff --git a/releasenotes/notes/deprecate-pulse-2a13fc783985ac27.yaml b/releasenotes/notes/deprecate-pulse-2a13fc783985ac27.yaml new file mode 100644 index 0000000000..e720b04b81 --- /dev/null +++ b/releasenotes/notes/deprecate-pulse-2a13fc783985ac27.yaml @@ -0,0 +1,32 @@ +--- +deprecations: + - | + Experiments involving pulse gate calibrations have been deprecated, due to + the upcoming `deprecation of Qiskit Pulse in Qiskit 2.0 + `_. These experiments + include ``QubitSpectroscopy``, ``EFSpectroscopy``, ``Rabi``, ``EFRabi``, + ``ResonatorSpectroscopy``, ``RoughDrag``, ``StarkRamseyXY``, + ``StarkRamseyXYAmpScan``, ``StarkP1Spectroscopy``, + ``CrossResonanceHamiltonian``, ``EchoedCrossResonanceHamiltonian``, + ``RoughFrequencyCal``, ``RoughEFFrequencyCal``, ``FrequencyCal``, + ``FineFrequencyCal``, ``RoughDragCal``, ``FineXDragCal``, + ``FineSXDragCal``, ``FineDragCal``, ``FineAmplitudeCal``, + ``FineXAmplitudeCal``, ``FineSXAmplitudeCal``, ``HalfAngleCal``, + ``RoughAmplitudeCal``, ``RoughXSXAmplitudeCal``, and + ``EFRoughXSXAmplitudeCal``. + - | + Also due to the deprecation of Qiskit Pulse, support for providing pulse + gate calibrations to excite higher levels has been deprecated from + :class:`qiskit_experiments.library.MultiStateDiscrimination`. + - | + The ``Calibrations`` class and all of Qiskit Experiments' calibration + support is deprecated. The calibrations features were based on adjusting + parameters of pulses used in gates. With the deprecation of Qiskit Pulse, + these features are now also deprecated. + - | + Support for running experiments in restless mode using the + ``RestlessMixin`` is deprecated. With improvements in the reliability of + IBM Quantum's qubit initialization, circuit exectuion has already become + reasonably fast and restless measurements do not add much performance + improvement. It is expected that the restless features are little used as + there has been no recent user feedback about them. diff --git a/test/base.py b/test/base.py index d7fa6b763f..486de3ca06 100644 --- a/test/base.py +++ b/test/base.py @@ -145,6 +145,20 @@ def setUpClass(cls): message=".*have no effect in local testing mode.*", category=UserWarning, ) + # All of the pulse related code is going to be removed, so we just + # ignore its warnings for now. + warnings.filterwarnings( + "default", + message=".*Due to the deprecation of Qiskit Pulse.*", + category=DeprecationWarning, + ) + # All of the restless related code is going to be removed, so we just + # ignore its warnings for now. + warnings.filterwarnings( + "default", + message=".*Support for restless experiments has been deprecated.*", + category=DeprecationWarning, + ) # Some functionality may be deprecated in Qiskit Experiments. If # the deprecation warnings aren't filtered, the tests will fail as