From 34054ba0f039e309289c2f684748651aa9563333 Mon Sep 17 00:00:00 2001 From: Julien Gacon Date: Tue, 20 Aug 2024 17:54:19 +0200 Subject: [PATCH] Tiny follow up to #12983 (#12999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tiny follow up * Update releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> (cherry picked from commit b90c7a706f3848310fa1c0ddaaea5994b78ecfa4) # Conflicts: # qiskit/transpiler/passes/routing/stochastic_swap.py # releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml --- .../passes/routing/stochastic_swap.py | 9 ++++ ...ecate-StochasticSwap-451f46b273602b7b.yaml | 50 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml diff --git a/qiskit/transpiler/passes/routing/stochastic_swap.py b/qiskit/transpiler/passes/routing/stochastic_swap.py index 3732802b770e..d1121ff8a939 100644 --- a/qiskit/transpiler/passes/routing/stochastic_swap.py +++ b/qiskit/transpiler/passes/routing/stochastic_swap.py @@ -59,6 +59,15 @@ class StochasticSwap(TransformationPass): the circuit. """ +<<<<<<< HEAD +======= + @deprecate_func( + since="1.3", + removal_timeline="in the 2.0 release", + additional_msg="The StochasticSwap transpilation pass is a suboptimal " + "routing algorithm and has been superseded by the SabreSwap pass.", + ) +>>>>>>> b90c7a706 (Tiny follow up to #12983 (#12999)) def __init__(self, coupling_map, trials=20, seed=None, fake_run=False, initial_layout=None): """StochasticSwap initializer. diff --git a/releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml b/releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml new file mode 100644 index 000000000000..c858dd6fe6ab --- /dev/null +++ b/releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml @@ -0,0 +1,50 @@ +--- +deprecations_transpiler: + - | + Deprecated :class:`.StochasticSwap` which has been superseded by :class:`.SabreSwap`. + If the class is called from the transpile function, the change would be, for example:: + + from qiskit import transpile + from qiskit.circuit import QuantumCircuit + from qiskit.transpiler import CouplingMap + from qiskit.providers.fake_provider import GenericBackendV2 + + + qc = QuantumCircuit(4) + qc.h(0) + qc.cx(0, range(1, 4)) + qc.measure_all() + + cmap = CouplingMap.from_heavy_hex(3) + backend = GenericBackendV2(num_qubits=cmap.size(), coupling_map=cmap) + + tqc = transpile( + qc, + routing_method="stochastic", + layout_method="dense", + seed_transpiler=12342, + target=backend.target + ) + + to:: + + tqc = transpile( + qc, + routing_method="sabre", + layout_method="sabre", + seed_transpiler=12342, + target=backend.target + ) + + While for a pass manager, the change would be:: + + passmanager = PassManager(StochasticSwap(coupling, 20, 13)) + new_qc = passmanager.run(qc) + + to:: + + passmanager = PassManager(SabreSwap(backend.target, "basic")) + new_qc = passmanager.run(qc) + + +