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

Deprecate NoiseAdaptiveLayout and CrosstalkAdaptiveSchedule #11402

Merged
merged 8 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions qiskit/transpiler/passes/layout/noise_adaptive_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
):
Expand Down
15 changes: 15 additions & 0 deletions releasenotes/notes/deprecate-old-passes-b2650ec96683b924.yaml
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 6 additions & 3 deletions test/python/transpiler/test_crosstalk_adaptive_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions test/python/transpiler/test_noise_adaptive_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 12 additions & 8 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading