Skip to content

Commit b90c7a7

Browse files
CryorisElePT
andauthored
Tiny follow up to #12983 (#12999)
* tiny follow up * Update releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml Co-authored-by: Elena Peña Tapia <[email protected]> --------- Co-authored-by: Elena Peña Tapia <[email protected]>
1 parent aa09a02 commit b90c7a7

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

qiskit/transpiler/passes/routing/stochastic_swap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class StochasticSwap(TransformationPass):
6363
@deprecate_func(
6464
since="1.3",
6565
removal_timeline="in the 2.0 release",
66-
additional_msg="The `StochasticSwap` transpilation pass is a suboptimal "
67-
"routing algorithm and has been superseded by the :class:`.SabreSwap` pass.",
66+
additional_msg="The StochasticSwap transpilation pass is a suboptimal "
67+
"routing algorithm and has been superseded by the SabreSwap pass.",
6868
)
6969
def __init__(self, coupling_map, trials=20, seed=None, fake_run=False, initial_layout=None):
7070
"""StochasticSwap initializer.

releasenotes/notes/deprecate-StochasticSwap-451f46b273602b7b.yaml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
11
---
22
deprecations_transpiler:
33
- |
4-
Deprecated ``StochasticSwap`` which has been superseded by :class:`.SabreSwap`.
4+
Deprecated :class:`.StochasticSwap` which has been superseded by :class:`.SabreSwap`.
55
If the class is called from the transpile function, the change would be, for example::
66
7+
from qiskit import transpile
8+
from qiskit.circuit import QuantumCircuit
9+
from qiskit.transpiler import CouplingMap
10+
from qiskit.providers.fake_provider import GenericBackendV2
11+
12+
13+
qc = QuantumCircuit(4)
14+
qc.h(0)
15+
qc.cx(0, range(1, 4))
16+
qc.measure_all()
17+
18+
cmap = CouplingMap.from_heavy_hex(3)
19+
backend = GenericBackendV2(num_qubits=cmap.size(), coupling_map=cmap)
20+
721
tqc = transpile(
8-
circuit,
9-
routing_method="stochastic",
10-
layout_method="dense",
11-
seed_transpiler=12342,
12-
target=GenericBackendV2(
13-
num_qubits=27,
14-
coupling_map=MUMBAI_CMAP,
15-
).target,
16-
)
22+
qc,
23+
routing_method="stochastic",
24+
layout_method="dense",
25+
seed_transpiler=12342,
26+
target=backend.target
27+
)
1728
1829
to::
1930
2031
tqc = transpile(
21-
circuit,
22-
routing_method="sabre",
23-
layout_method="sabre",
24-
seed_transpiler=12342,
25-
target=GenericBackendV2(
26-
num_qubits=27,
27-
coupling_map=MUMBAI_CMAP,
28-
).target,
29-
)
30-
31-
While for a pass mananager change::
32-
33-
qr = QuantumRegister(4, "q")
34-
qc = QuantumCircuit(qr)
32+
qc,
33+
routing_method="sabre",
34+
layout_method="sabre",
35+
seed_transpiler=12342,
36+
target=backend.target
37+
)
38+
39+
While for a pass manager, the change would be::
40+
3541
passmanager = PassManager(StochasticSwap(coupling, 20, 13))
3642
new_qc = passmanager.run(qc)
3743
3844
to::
3945
40-
qr = QuantumRegister(5, "q")
41-
qc = QuantumCircuit(qr)
42-
passmanager = PassManager(SabreSwap(target, "basic"))
46+
passmanager = PassManager(SabreSwap(backend.target, "basic"))
4347
new_qc = passmanager.run(qc)
4448
4549

0 commit comments

Comments
 (0)