From c67678815a558ff5a4600d0e072c89ee151a273d Mon Sep 17 00:00:00 2001 From: Eli Arbel <46826214+eliarbel@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:57:28 +0300 Subject: [PATCH] Add missing pulse-related deprecation (#13392) This commit deprecates `inst_map` in `PassManagerConfig.__init__`. It should have been part of the pulse deprecation PR #13164 but I somehow missed to covere it. We're already in our feature freeze period for version 1.3 but since this is not a new feature but rather an addendum to the pulse deprecation PR we should squeeze this in as well. --- crates/circuit/src/dag_circuit.rs | 2 + qiskit/transpiler/passmanager_config.py | 2 + .../generate_preset_pass_manager.py | 37 +++++++++++-------- ...recate-pulse-package-07a621be1db7fa30.yaml | 4 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/crates/circuit/src/dag_circuit.rs b/crates/circuit/src/dag_circuit.rs index e631b6971580..279966080df5 100644 --- a/crates/circuit/src/dag_circuit.rs +++ b/crates/circuit/src/dag_circuit.rs @@ -888,6 +888,8 @@ impl DAGCircuit { /// /// Raises: /// Exception: if the gate is of type string and params is None. + /// + /// DEPRECATED since Qiskit 1.3.0 and will be removed in Qiskit 2.0.0 #[pyo3(signature=(gate, qubits, schedule, params=None))] fn add_calibration<'py>( &mut self, diff --git a/qiskit/transpiler/passmanager_config.py b/qiskit/transpiler/passmanager_config.py index baf4482a3b05..52f3d65449e5 100644 --- a/qiskit/transpiler/passmanager_config.py +++ b/qiskit/transpiler/passmanager_config.py @@ -17,11 +17,13 @@ from qiskit.transpiler.coupling import CouplingMap from qiskit.transpiler.instruction_durations import InstructionDurations +from qiskit.utils.deprecate_pulse import deprecate_pulse_arg class PassManagerConfig: """Pass Manager Configuration.""" + @deprecate_pulse_arg("inst_map", predicate=lambda inst_map: inst_map is not None) def __init__( self, initial_layout=None, diff --git a/qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py b/qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py index 04516f4b0c6a..00b4b1418258 100644 --- a/qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +++ b/qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py @@ -412,21 +412,28 @@ def generate_preset_pass_manager( "qubits_initially_zero": qubits_initially_zero, } - if backend is not None: - pm_options["_skip_target"] = _skip_target - pm_config = PassManagerConfig.from_backend(backend, **pm_options) - else: - pm_config = PassManagerConfig(**pm_options) - if optimization_level == 0: - pm = level_0_pass_manager(pm_config) - elif optimization_level == 1: - pm = level_1_pass_manager(pm_config) - elif optimization_level == 2: - pm = level_2_pass_manager(pm_config) - elif optimization_level == 3: - pm = level_3_pass_manager(pm_config) - else: - raise ValueError(f"Invalid optimization level {optimization_level}") + with warnings.catch_warnings(): + # inst_map is deprecated in the PassManagerConfig initializer + warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + message=".*argument ``inst_map`` is deprecated as of Qiskit 1.3", + ) + if backend is not None: + pm_options["_skip_target"] = _skip_target + pm_config = PassManagerConfig.from_backend(backend, **pm_options) + else: + pm_config = PassManagerConfig(**pm_options) + if optimization_level == 0: + pm = level_0_pass_manager(pm_config) + elif optimization_level == 1: + pm = level_1_pass_manager(pm_config) + elif optimization_level == 2: + pm = level_2_pass_manager(pm_config) + elif optimization_level == 3: + pm = level_3_pass_manager(pm_config) + else: + raise ValueError(f"Invalid optimization level {optimization_level}") return pm diff --git a/releasenotes/notes/deprecate-pulse-package-07a621be1db7fa30.yaml b/releasenotes/notes/deprecate-pulse-package-07a621be1db7fa30.yaml index 5b4941f9d847..479c31556eb5 100644 --- a/releasenotes/notes/deprecate-pulse-package-07a621be1db7fa30.yaml +++ b/releasenotes/notes/deprecate-pulse-package-07a621be1db7fa30.yaml @@ -43,8 +43,8 @@ deprecations_transpiler: * :class:`~qiskit.transpiler.passes.EchoRZXWeylDecomposition` - | The `inst_map` argument in :func:`~qiskit.transpiler.generate_preset_pass_manager`, - :meth:`~transpiler.target.Target.from_configuration` and :func:`~qiskit.transpiler.preset_passmanagers.common.generate_scheduling` - is being deprecated. + :meth:`~transpiler.target.Target.from_configuration`, :class:`~qiskit.transpiler.PassManagerConfig` initializer + and :func:`~qiskit.transpiler.preset_passmanagers.common.generate_scheduling` is being deprecated. - | The `calibration` argument in :func:`~qiskit.transpiler.target.InstructionProperties` initializer methods is being deprecated.