From 3ef47f2bcd34f276e735b7c007df63658b316531 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:04:01 +0000 Subject: [PATCH] greating a challenging backend to show the doc point (#12116) (#12141) (cherry picked from commit 59bdff9dcba1d3a304433a9b7fb3993cdc9f721f) Co-authored-by: Luciano Bello --- qiskit/transpiler/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qiskit/transpiler/__init__.py b/qiskit/transpiler/__init__.py index 6e1522e81fa9..12d9b9056b80 100644 --- a/qiskit/transpiler/__init__.py +++ b/qiskit/transpiler/__init__.py @@ -799,7 +799,7 @@ at the output. In order to highlight this, we run a GHZ circuit 100 times, using a "bad" (disconnected) -`initial_layout`: +``initial_layout`` in a heavy hex coupling map: .. plot:: @@ -816,18 +816,22 @@ import matplotlib.pyplot as plt from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import GenericBackendV2 - backend = GenericBackendV2(16) + from qiskit.transpiler import CouplingMap + + coupling_map = CouplingMap.from_heavy_hex(3) + backend = GenericBackendV2(coupling_map.size(), coupling_map=coupling_map) ghz = QuantumCircuit(15) ghz.h(0) ghz.cx(0, range(1, 15)) depths = [] - for _ in range(100): + for i in range(100): depths.append( transpile( ghz, backend, + seed_transpiler=i, layout_method='trivial' # Fixed layout mapped in circuit order ).depth() )