diff --git a/qiskit/transpiler/passes/layout/noise_adaptive_layout.py b/qiskit/transpiler/passes/layout/noise_adaptive_layout.py index 3bbf4623a225..d212d3c9f3b9 100644 --- a/qiskit/transpiler/passes/layout/noise_adaptive_layout.py +++ b/qiskit/transpiler/passes/layout/noise_adaptive_layout.py @@ -20,6 +20,7 @@ from qiskit.transpiler.basepasses import AnalysisPass from qiskit.transpiler.exceptions import TranspilerError from qiskit.transpiler.target import target_to_backend_properties, Target +from qiskit.utils.deprecation import deprecate_func class NoiseAdaptiveLayout(AnalysisPass): @@ -55,6 +56,11 @@ class NoiseAdaptiveLayout(AnalysisPass): by being set in `property_set`. """ + @deprecate_func( + since="0.46", + package_name="qiskit", + removal_timeline="in the 1.0.0 release", + ) def __init__(self, backend_prop, coupling_map=None): """NoiseAdaptiveLayout initializer. diff --git a/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py b/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py index cfde23061020..eaf3e9754384 100644 --- a/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py +++ b/qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py @@ -40,6 +40,7 @@ from qiskit.circuit.barrier import Barrier from qiskit.dagcircuit import DAGOpNode from qiskit.utils import optionals as _optionals +from qiskit.utils.deprecation import deprecate_func NUM_PREC = 10 TWOQ_XTALK_THRESH = 3 @@ -50,6 +51,11 @@ class CrosstalkAdaptiveSchedule(TransformationPass): """Crosstalk mitigation through adaptive instruction scheduling.""" + @deprecate_func( + since="0.46", + package_name="qiskit", + removal_timeline="in the 1.0.0 release", + ) def __init__( self, backend_prop, crosstalk_prop, weight_factor=0.5, measured_qubits=None, target=None ): diff --git a/releasenotes/notes/deprecate-old-passes-b2650ec96683b924.yaml b/releasenotes/notes/deprecate-old-passes-b2650ec96683b924.yaml new file mode 100644 index 000000000000..d0af9e4f8992 --- /dev/null +++ b/releasenotes/notes/deprecate-old-passes-b2650ec96683b924.yaml @@ -0,0 +1,15 @@ +--- +deprecations: + - | + The :class:`.NoiseAdaptiveLayout` transpiler pass and the corresponding + ``"noise_adaptive"`` layout stage plugin have been deprecated and will + be removed in the 1.0.0 release. This pass has been largely superseded by + :class:`.VF2Layout` and :class:`.VF2PostLayout` which will set a layout + based on the reported noise characteristics of a backend. + - | + The :class:`.CrosstalkAdaptiveSchedule` transpiler pass has been deprecated + and will be removed in the 1.0.0 release. This pass was not usable any + longer because its internal operation was dependent on custom properties + being set in the :class:`.BackendProperties` payload of a + :class:`.BackendV1` instance. As no backends are setting these fields + the pass has been deprecated. diff --git a/test/python/transpiler/test_crosstalk_adaptive_scheduler.py b/test/python/transpiler/test_crosstalk_adaptive_scheduler.py index 1847cf35f059..f778bbab2ee8 100644 --- a/test/python/transpiler/test_crosstalk_adaptive_scheduler.py +++ b/test/python/transpiler/test_crosstalk_adaptive_scheduler.py @@ -160,7 +160,8 @@ def test_schedule_length1(self): layout = Layout({qr[i]: mapping[i] for i in range(6)}) new_circ = transpile(circuit, initial_layout=layout, basis_gates=["u1", "u2", "u3", "cx"]) dag = circuit_to_dag(new_circ) - pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) + with self.assertWarns(DeprecationWarning): + pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) scheduled_dag = pass_.run(dag) self.assertEqual(scheduled_dag.depth(), 3) @@ -181,7 +182,8 @@ def test_schedule_length2(self): layout = Layout({qr[i]: mapping[i] for i in range(6)}) new_circ = transpile(circuit, initial_layout=layout, basis_gates=["u1", "u2", "u3", "cx"]) dag = circuit_to_dag(new_circ) - pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) + with self.assertWarns(DeprecationWarning): + pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) scheduled_dag = pass_.run(dag) self.assertEqual(scheduled_dag.depth(), 1) @@ -202,7 +204,8 @@ def test_schedule_length3(self): layout = Layout({qr[i]: mapping[i] for i in range(6)}) new_circ = transpile(circuit, initial_layout=layout, basis_gates=["u1", "u2", "u3", "cx"]) dag = circuit_to_dag(new_circ) - pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) + with self.assertWarns(DeprecationWarning): + pass_ = CrosstalkAdaptiveSchedule(bprop, crosstalk_prop) scheduled_dag1 = pass_.run(dag) scheduled_dag2 = pass_.run(dag) self.assertEqual(scheduled_dag1.depth(), 3) diff --git a/test/python/transpiler/test_noise_adaptive_layout.py b/test/python/transpiler/test_noise_adaptive_layout.py index 69daa7c3d920..097d4f9e3454 100644 --- a/test/python/transpiler/test_noise_adaptive_layout.py +++ b/test/python/transpiler/test_noise_adaptive_layout.py @@ -62,7 +62,8 @@ def test_on_linear_topology(self): gates=gate_list, general=[], ) - nalayout = NoiseAdaptiveLayout(bprop) + with self.assertWarns(DeprecationWarning): + nalayout = NoiseAdaptiveLayout(bprop) nalayout.run(dag) initial_layout = nalayout.property_set["layout"] self.assertNotEqual(initial_layout[qr[0]], 0) @@ -92,7 +93,8 @@ def test_bad_readout(self): gates=gate_list, general=[], ) - nalayout = NoiseAdaptiveLayout(bprop) + with self.assertWarns(DeprecationWarning): + nalayout = NoiseAdaptiveLayout(bprop) nalayout.run(dag) initial_layout = nalayout.property_set["layout"] self.assertNotEqual(initial_layout[qr[0]], 2) @@ -138,7 +140,8 @@ def test_grid_layout(self): gates=gate_list, general=[], ) - nalayout = NoiseAdaptiveLayout(bprop) + with self.assertWarns(DeprecationWarning): + nalayout = NoiseAdaptiveLayout(bprop) nalayout.run(dag) initial_layout = nalayout.property_set["layout"] for qid in range(4): diff --git a/test/python/transpiler/test_preset_passmanagers.py b/test/python/transpiler/test_preset_passmanagers.py index c1df58eb03cf..decbb9f91cad 100644 --- a/test/python/transpiler/test_preset_passmanagers.py +++ b/test/python/transpiler/test_preset_passmanagers.py @@ -133,7 +133,10 @@ def test_7677(self, level): qc.cx(1, 11) backend = FakeMelbourne() - result = transpile(qc, backend, layout_method="noise_adaptive", optimization_level=level) + with self.assertWarns(DeprecationWarning): + result = transpile( + qc, backend, layout_method="noise_adaptive", optimization_level=level + ) self.assertIsInstance(result, QuantumCircuit) self.assertEqual(result.num_qubits, 14) @@ -372,13 +375,14 @@ def test_5409(self, level): qc.cx(qr[2], qr[4]) backend = FakeMelbourne() - _ = transpile( - qc, - backend, - layout_method="noise_adaptive", - optimization_level=level, - callback=self.callback, - ) + with self.assertWarns(DeprecationWarning): + _ = transpile( + qc, + backend, + layout_method="noise_adaptive", + optimization_level=level, + callback=self.callback, + ) self.assertIn("SetLayout", self.passes) self.assertIn("ApplyLayout", self.passes)