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

Creating a challenging backend to show the transpiler stochasticity (backport #12116) #12141

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
10 changes: 7 additions & 3 deletions qiskit/transpiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::

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