Tutorials
qcr:2606.51702.1

Compiling Braket Circuits with the Qiskit Provider

This notebook shows how to use the qiskit-braket-provider's circuit-compilation capabilities to transpile and optimize quantum circuits for Amazon Braket devices using Qiskit's mature compilation toolchain, bridging two frameworks for the benefit of better hardware-targeted circuits. Compilation (transpilation) adapts an abstract circuit to a specific device by decomposing gates into the device's native set, mapping logical qubits onto the hardware's physical qubits and connectivity, and applying optimization passes to reduce depth and gate count. The notebook demonstrates the provider's conversion utilities together with Qiskit's transpiler: taking a circuit, compiling it for a target Braket backend using Qiskit's optimization levels and pass managers, and producing a Braket-ready circuit, then running it on a Braket device. It explains how leveraging Qiskit's well-developed transpilation, including layout selection, routing, and gate optimization, can improve how circuits run on Braket hardware, and how the converted circuits move between the two ecosystems. By combining Qiskit's compiler with Braket's execution, the example gives researchers a flexible path to optimized, device-aware circuits. It is a focused look at cross-framework circuit compilation on Amazon Braket.
Compilation
Qubit
Circuit-based
Uploaded 3 days ago
12
Views
GitHub582
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

amazon-braket/amazon-braket-examples
582261
In [ ]:
# --- Setup cell added by QCR (not part of the original tutorial) ---
# Source: amazon-braket/amazon-braket-examples @ 0c0818f315479aab9deebed7e7ed7533ac581923, Apache License 2.0.
# Installs the example's dependencies. If a later cell still reports a missing
# package, restart the runtime/kernel and run again from the top.
%pip install -q amazon-braket-sdk==1.117.3 qiskit==2.4.1 qiskit-braket-provider==0.14.4 matplotlib networkx

Compiling Braket circuits with the Qiskit-Braket provider

In this example notebook we show how we can use the Qiskit-Braket provider to_braket function to provide circuit compilation for Braket circuits through the Qiskit compiler. Users can simply obtain a Circuit with the appropriate native gates, or explore advanced circuit compilation features, yielding programs ready for submission on Amazon Braket.

[!IMPORTANT] Further details and documentation for using the Qiskit-Braket provider can be found at the Qiskit-Braket provider tutorials and how-to pages.

Why circuit compilation?

The success of a quantum circuit execution generally scales negatively with the number of gates and there infinite ways of expressing the same circuit. Given so many logically equivalent circuits, a simple way to improve our results is to choose representations that have less gates.

There also are constraints given the physical device used. For instance, the connectivity of our device may differ from our input circuits, there is likely heterogeneity in the qubit quality, and we may have restrictions on the types of gates and parameters which can be utilized. Circuit compilation can help us create an executable circuit.

In [ ]:
from warnings import filterwarnings

import matplotlib.cm as cm
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
from circuit_utility import dprint
from matplotlib.colors import Normalize

from braket.aws import AwsDevice
from braket.devices import Devices

filterwarnings("ignore",category=UserWarning, module="qiskit_braket_provider")

garnet = AwsDevice(Devices.IQM.Garnet)

qubits = [
    [None,None,20,None,17,None,None],
    [None,19,None,16,None,12,None],
    [18,None,15,None,11,None,7,None],
    [None,14,None,10,None,6, None],
    [13,None,9,None,5,None],
    [None,8,None,4,None,2,None],
    [None,None,3,None,1,None,None]]

locs = {q:(j,-i) for i,row in enumerate(qubits) for j, q in enumerate(row) if q is not None}
nx.draw(garnet.topology_graph,locs, with_labels=True, font_color="white")
plt.axis("equal")
plt.show()

We can see a more detailed picture of physical attributes with some help from the device properties:

In [ ]:

props = garnet.properties.provider.properties
graph_nodes, graph_edges =list(garnet.topology_graph.nodes()), list(garnet.topology_graph.edges())

node_vals = [1 - props["one_qubit"][str(node)]["fRO"] for node in graph_nodes]

edge_vals = []
for edge in graph_edges:
    if edge[0] > edge[1]:
        edge = (edge[1], edge[0])
    edge_key = f"{edge[0]}-{edge[1]}"
    edge_vals.append(1 - props["two_qubit"][edge_key]["fCZ"])

edge_vals = np.log10(edge_vals)
node_vals = np.log10(node_vals)

fig, ax = plt.subplots(figsize=(10,6))

nx.draw(garnet.topology_graph,
        locs,
        node_color=node_vals, 
        edge_color=edge_vals, 
        cmap=cm.coolwarm, 
        edge_cmap=cm.coolwarm, 
        with_labels=True,
        ax=ax)

node_norm = Normalize(vmin=min(node_vals), vmax=max(node_vals))
edge_norm = Normalize(vmin=min(edge_vals), vmax=max(edge_vals))
sm_nodes = plt.cm.ScalarMappable(cmap=cm.coolwarm, norm=node_norm)
sm_edges = plt.cm.ScalarMappable(cmap=cm.coolwarm, norm=edge_norm)

cbar1 = plt.colorbar(sm_nodes, ax=ax, label="Readout Infidelity (log10)")
cbar2 = plt.colorbar(sm_edges, ax=ax, label="CZ Infidelity (log10)", location="left",)
ax.set_aspect("equal")
plt.show()

In this visualization, we see how the CZ gate infidelity and qubit readout errors can differ by orders of magnitude. Other relevant metrics include and times and single-qubit gate infidelities. The success of a particular circuit choice can depend heavily on how the circuit is mapped to the underlying device.

Compilation via the Braket Service

As detailed in the Developer Guide, one way to get the compiled circuit, is to submit a job, and then return the circuit via the compiled program (which is also accessible on the console). Here we show this for an 8-qubit GHZ circuit:

[!WARNING] Running this block will cost ~ $0.31, mainly the associate task submission cost for submitting to the Braket service plus a single per-shot price.

[!IMPORTANT] The following snippets will not work as-is with all providers. Rigetti results will be returned in Quil, and IonQ circuits are not returned.

In [3]:
from braket.circuits import Circuit

ghz = Circuit().h(0).cnot(0,1).cnot(1,2).cnot(2, 3).cnot(3, 4).cnot(4, 5).cnot(5, 6).cnot(6, 7)
dprint(ghz)
T  : │  0  │  1  │  2  │  3  │  4  │  5  │  6  │  7  │
      ┌───┐                                           
q0 : ─┤ H ├───●───────────────────────────────────────
      └───┘   │                                       
            ┌─┴─┐                                     
q1 : ───────┤ X ├───●─────────────────────────────────
            └───┘   │                                 
                  ┌─┴─┐                               
q2 : ─────────────┤ X ├───●───────────────────────────
                  └───┘   │                           
                        ┌─┴─┐                         
q3 : ───────────────────┤ X ├───●─────────────────────
                        └───┘   │                     
                              ┌─┴─┐                   
q4 : ─────────────────────────┤ X ├───●───────────────
                              └───┘   │               
                                    ┌─┴─┐             
q5 : ───────────────────────────────┤ X ├───●─────────
                                    └───┘   │         
                                          ┌─┴─┐       
q6 : ─────────────────────────────────────┤ X ├───●───
                                          └───┘   │   
                                                ┌─┴─┐ 
q7 : ───────────────────────────────────────────┤ X ├─
                                                └───┘ 
T  : │  0  │  1  │  2  │  3  │  4  │  5  │  6  │  7  │
In [4]:
task = garnet.run(ghz, shots=1)
result = task.result()
In [5]:
compiled_circuit = Circuit().from_ir(result.get_compiled_circuit())
dprint(compiled_circuit)
T   : │        0        │         1         │  2  │         3         │  4  │         5         │  6  │ ||
                         ┌─────────────────┐                                                            ||
q3  : ───StartVerbatim───┤ PRx(1.57, 4.71) ├─────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                            ||
               ║         ┌─────────────────┐                                                            ||
q4  : ─────────║─────────┤ PRx(1.57, 4.71) ├─────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                            ||
               ║         ┌─────────────────┐                                                            ||
q5  : ─────────║─────────┤ PRx(1.57, 4.71) ├─────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                            ||
               ║         ┌─────────────────┐                                                     ┌───┐  ||
q8  : ─────────║─────────┤ PRx(1.57, 4.71) ├─────────────────────────────────────────────────────┤ Z ├─ ||
               ║         └─────────────────┘                                                     └─┬─┘  ||
               ║         ┌─────────────────┐                                                       │    ||
q9  : ─────────║─────────┤ PRx(1.57, 4.71) ├───●───────────────────────────────────────────────────┼─── ||
               ║         └─────────────────┘   │                                                   │    ||
               ║         ┌─────────────────┐   │                                                   │    ||
q10 : ─────────║─────────┤ PRx(1.57, 4.71) ├───┼───────────────────────────────────────────────────┼─── ||
               ║         └─────────────────┘   │                                                   │    ||
               ║         ┌─────────────────┐   │                       ┌───┐ ┌─────────────────┐   │    ||
q13 : ─────────║─────────┤ PRx(1.57, 4.71) ├───┼───────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├───●─── ||
               ║         └─────────────────┘   │                       └─┬─┘ └─────────────────┘        ||
               ║         ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐   │                              ||
q14 : ─────────╨─────────┤ PRx(1.57, 4.71) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├───●───────────────────────────── ||
                         └─────────────────┘ └───┘ └─────────────────┘                                  ||
T   : │        0        │         1         │  2  │         3         │  4  │         5         │  6  │ ||

T   : │         7         │  8  │         9         │ 10  │        11         │ 12  │        13         │ 14  │ ||
                           ┌───┐ ┌─────────────────┐                                                            ||
q3  : ─────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├───●─────────────────────────────────────────────────────── ||
                           └─┬─┘ └─────────────────┘   │                                                        ||
                             │                       ┌─┴─┐ ┌─────────────────┐                                  ||
q4  : ───────────────────────┼───────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├───●───────────────────────────── ||
                             │                       └───┘ └─────────────────┘   │                              ||
                             │                                                 ┌─┴─┐ ┌─────────────────┐        ||
q5  : ───────────────────────┼─────────────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├───●─── ||
                             │                                                 └───┘ └─────────────────┘   │    ||
       ┌─────────────────┐   │                                                                             │    ||
q8  : ─┤ PRx(1.57, 1.57) ├───●─────────────────────────────────────────────────────────────────────────────┼─── ||
       └─────────────────┘                                                                                 │    ||
                                                                                                           │    ||
q9  : ─────────────────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                                           │    ||
                                                                                                         ┌─┴─┐  ||
q10 : ───────────────────────────────────────────────────────────────────────────────────────────────────┤ Z ├─ ||
                                                                                                         └───┘  ||
                                                                                                                ||
q13 : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q14 : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
T   : │         7         │  8  │         9         │ 10  │        11         │ 12  │        13         │ 14  │ ||

T   : │        15         │      16       │ 17  │
                                           ┌───┐
q3  : ───────────────────────EndVerbatim───┤ M ├─
                                  ║        └───┘
                                  ║        ┌───┐
q4  : ────────────────────────────║────────┤ M ├─
                                  ║        └───┘
                                  ║        ┌───┐
q5  : ────────────────────────────║────────┤ M ├─
                                  ║        └───┘
                                  ║        ┌───┐
q8  : ────────────────────────────║────────┤ M ├─
                                  ║        └───┘
                                  ║        ┌───┐
q9  : ────────────────────────────║────────┤ M ├─
                                  ║        └───┘
       ┌─────────────────┐        ║        ┌───┐
q10 : ─┤ PRx(1.57, 1.57) ├────────║────────┤ M ├─
       └─────────────────┘        ║        └───┘
                                  ║        ┌───┐
q13 : ────────────────────────────║────────┤ M ├─
                                  ║        └───┘
                                  ║        ┌───┐
q14 : ────────────────────────────╨────────┤ M ├─
                                           └───┘
T   : │        15         │      16       │ 17  │

Accessing Circuit Compilation via the Qiskit-Braket provider

Using the Qiskit-Braket provider, we can also utilize built-in features of Qiskit (namely the transpiler) to compile the circuit. The Qiskit-Braket provider provides pre-configured Backend objects, which populate relevant Qiskit Targets to perform noise-aware and device-aware transpilation. The relevant target and qubit labels are passed through in a number of ways. The most straightforward is to pass through an braket_device:

In [ ]:
from qiskit_braket_provider import to_braket

ghz_garnet = to_braket(ghz, braket_device=garnet)

dprint(ghz_garnet)
T   : │        0        │         1         │         2         │         3         │         4         │ ||
                         ┌─────────────────┐ ┌─────────────────┐                     ┌─────────────────┐  ||
q1  : ───StartVerbatim───┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├──────────●──────────┤ PRx(1.57, 0.00) ├─ ||
               ║         └─────────────────┘ └─────────────────┘          │          └─────────────────┘  ||
               ║         ┌─────────────────┐ ┌─────────────────┐        ┌─┴─┐        ┌─────────────────┐  ||
q2  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─ ||
               ║         └─────────────────┘ └─────────────────┘        └───┘        └─────────────────┘  ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                          ||
q3  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                          ||
               ║         ┌─────────────────┐                                                              ||
q4  : ─────────║─────────┤ PRx(1.57, 0.00) ├───────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                              ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                          ||
q5  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                          ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                          ||
q6  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                          ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                          ||
q7  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                          ||
               ║         ┌─────────────────┐        ┌───┐        ┌─────────────────┐        ┌───┐         ||
q8  : ─────────║─────────┤ PRx(1.57, 0.00) ├────────┤ Z ├────────┤ PRx(1.57, 0.00) ├────────┤ Z ├──────── ||
               ║         └─────────────────┘        └─┬─┘        └─────────────────┘        └─┬─┘         ||
               ║         ┌─────────────────┐          │          ┌─────────────────┐          │           ||
q9  : ─────────║─────────┤ PRx(1.57, 0.00) ├──────────●──────────┤ PRx(1.57, 0.00) ├──────────●────────── ||
               ║         └─────────────────┘                     └─────────────────┘                      ||
               ║         ┌─────────────────┐                                                              ||
q10 : ─────────║─────────┤ PRx(1.57, 0.00) ├───────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                              ||
               ║         ┌─────────────────┐                                                              ||
q11 : ─────────║─────────┤ PRx(1.57, 0.00) ├───────────────────────────────────────────────────────────── ||
               ║         └─────────────────┘                                                              ||
               ║         ┌─────────────────┐                                                              ||
q12 : ─────────╨─────────┤ PRx(1.57, 0.00) ├───────────────────────────────────────────────────────────── ||
                         └─────────────────┘                                                              ||
T   : │        0        │         1         │         2         │         3         │         4         │ ||

T   : │         5         │         6         │         7         │         8         │  9  │ ||
                                                                   ┌─────────────────┐        ||
q1  : ──────────────────────────────────────────────────●──────────┤ PRx(1.57, 0.00) ├───●─── ||
                                                        │          └─────────────────┘   │    ||
       ┌─────────────────┐ ┌─────────────────┐        ┌─┴─┐        ┌─────────────────┐ ┌─┴─┐  ||
q2  : ─┤ PRx(3.14, 0.00) ├─┤ PRx(1.57, 0.00) ├────────┤ Z ├────────┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
       └─────────────────┘ └─────────────────┘        └───┘        └─────────────────┘ └───┘  ||
                                                                                              ||
q3  : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q4  : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q5  : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q6  : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q7  : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
       ┌─────────────────┐        ┌───┐                                                       ||
q8  : ─┤ PRx(1.57, 0.00) ├────────┤ Z ├────────────────────────────────────────────────────── ||
       └─────────────────┘        └─┬─┘                                                       ||
       ┌─────────────────┐          │          ┌─────────────────┐ ┌─────────────────┐        ||
q9  : ─┤ PRx(1.57, 0.00) ├──────────●──────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────── ||
       └─────────────────┘                     └─────────────────┘ └─────────────────┘        ||
                                                                                              ||
q10 : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q11 : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
                                                                                              ||
q12 : ─────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                              ||
T   : │         5         │         6         │         7         │         8         │  9  │ ||

T   : │        10         │ 11  │        12         │ 13  │        14         │ 15  │        16         │ 17  │ ||
       ┌─────────────────┐       ┌─────────────────┐ ┌───┐ ┌─────────────────┐ ┌───┐ ┌─────────────────┐ ┌───┐  ||
q1  : ─┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
       └─────────────────┘   │   └─────────────────┘ └─┬─┘ └─────────────────┘ └─┬─┘ └─────────────────┘ └─┬─┘  ||
       ┌─────────────────┐ ┌─┴─┐                       │                         │                         │    ||
q2  : ─┤ PRx(1.57, 0.00) ├─┤ Z ├───────────────────────┼─────────────────────────┼─────────────────────────┼─── ||
       └─────────────────┘ └───┘                       │                         │                         │    ||
                                                       │                         │                         │    ||
q3  : ─────────────────────────────────────────────────┼─────────────────────────┼─────────────────────────┼─── ||
                                                       │                         │                         │    ||
                                                       │   ┌─────────────────┐   │   ┌─────────────────┐   │    ||
q4  : ─────────────────────────────────────────────────●───┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├───●─── ||
                                                           └─────────────────┘       └─────────────────┘        ||
                                                                                                                ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q9  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q10 : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q11 : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q12 : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
T   : │        10         │ 11  │        12         │ 13  │        14         │ 15  │        16         │ 17  │ ||

T   : │        18         │        19         │           20            │        21         │ 22  │ ||
       ┌─────────────────┐                                         ┌───┐ ┌─────────────────┐ ┌───┐  ||
q1  : ─┤ PRx(1.57, 0.00) ├─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
       └─────────────────┘                                         └─┬─┘ └─────────────────┘ └─┬─┘  ||
                                                                     │                         │    ||
q2  : ───────────────────────────────────────────────────────────────┼─────────────────────────┼─── ||
                                                                     │                         │    ||
              ┌───┐        ┌─────────────────┐ ┌─────────────────┐   │                         │    ||
q3  : ────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───┼─────────────────────────┼─── ||
              └─┬─┘        └─────────────────┘ └─────────────────┘   │                         │    ||
                │          ┌─────────────────┐                       │   ┌─────────────────┐   │    ||
q4  : ──────────●──────────┤ PRx(1.57, 0.00) ├───────────────────────●───┤ PRx(1.57, 0.00) ├───●─── ||
                           └─────────────────┘                           └─────────────────┘        ||
                                                                                                    ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q9  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q10 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q11 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q12 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
T   : │        18         │        19         │           20            │        21         │ 22  │ ||

T   : │        23         │ 24  │        25         │        26         │ 27  │        28         │ ||
       ┌─────────────────┐ ┌───┐                                                                    ||
q1  : ─┤ PRx(1.57, 0.00) ├─┤ Z ├─────────────────────────────────────────────────────────────────── ||
       └─────────────────┘ └─┬─┘                                                                    ||
                             │                                                                      ||
q2  : ───────────────────────┼───────────────────────────────────────────────────────────────────── ||
                             │                                                                      ||
                             │                                                                      ||
q3  : ───────────────────────┼─────────────────────────────────────────────●─────────────────────── ||
                             │                                             │                        ||
       ┌─────────────────┐   │   ┌─────────────────┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐  ||
q4  : ─┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├─ ||
       └─────────────────┘       └─────────────────┘ └─────────────────┘ └───┘ └─────────────────┘  ||
                                                                                                    ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q9  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q10 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q11 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q12 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
T   : │        23         │ 24  │        25         │        26         │ 27  │        28         │ ||

T   : │        29         │ 30  │        31         │        32         │ 33  │        34         │ ||
                                                                                                    ||
q1  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q2  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q3  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
       ┌─────────────────┐                                                                          ||
q4  : ─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────────────────────────── ||
       └─────────────────┘   │                                                                      ||
                           ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐                            ||
q5  : ─────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─────────────────────── ||
                           └───┘ └─────────────────┘ └─────────────────┘   │                        ||
                                                                         ┌─┴─┐ ┌─────────────────┐  ||
q6  : ───────────────────────────────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─ ||
                                                                         └───┘ └─────────────────┘  ||
                                                                                                    ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q9  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q10 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q11 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q12 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
T   : │        29         │ 30  │        31         │        32         │ 33  │        34         │ ||

T   : │        35         │ 36  │        37         │        38         │        39         │ 40  │ ||
                                                                                                    ||
q1  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q2  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q3  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q4  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
       ┌─────────────────┐                                                                          ||
q6  : ─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────────────────────────── ||
       └─────────────────┘   │                                                                      ||
                           ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌───┐  ||
q7  : ─────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
                           └───┘ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─┬─┘  ||
                                                                                               │    ||
q8  : ─────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                               │    ||
                                                                                               │    ||
q9  : ─────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                               │    ||
                                                                                               │    ||
q10 : ─────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                               │    ||
                                                                                               │    ||
q11 : ─────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                               │    ||
                                                                                               │    ||
q12 : ─────────────────────────────────────────────────────────────────────────────────────────●─── ||
                                                                                                    ||
T   : │        35         │ 36  │        37         │        38         │        39         │ 40  │ ||

T   : │        41         │ 42  │        43         │ 44  │        45         │ 46  │        47         │ 48  │ ||
                                                                                                                ||
q1  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q2  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q3  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q4  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
       ┌─────────────────┐ ┌───┐ ┌─────────────────┐ ┌───┐                                                      ||
q7  : ─┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├───────────────────────────────────────────────────── ||
       └─────────────────┘ └─┬─┘ └─────────────────┘ └─┬─┘                                                      ||
                             │                         │                                                        ||
q8  : ───────────────────────┼─────────────────────────┼─────────────────────────────────────────────────────── ||
                             │                         │                                                        ||
                             │                         │                                                        ||
q9  : ───────────────────────┼─────────────────────────┼─────────────────────────────────────────────────────── ||
                             │                         │                                                        ||
                             │                         │                                                        ||
q10 : ───────────────────────┼─────────────────────────┼─────────────────────────────────────────────────────── ||
                             │                         │                                                        ||
                             │                         │                             ┌─────────────────┐        ||
q11 : ───────────────────────┼─────────────────────────┼─────────────────────────●───┤ PRx(1.57, 0.00) ├───●─── ||
                             │                         │                         │   └─────────────────┘   │    ||
       ┌─────────────────┐   │   ┌─────────────────┐   │   ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐ ┌─┴─┐  ||
q12 : ─┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
       └─────────────────┘       └─────────────────┘       └─────────────────┘ └───┘ └─────────────────┘ └───┘  ||
T   : │        41         │ 42  │        43         │ 44  │        45         │ 46  │        47         │ 48  │ ||

T   : │        49         │ 50  │        51         │ 52  │        53         │ 54  │        55         │ 56  │ ||
                                                                                                                ||
q1  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q2  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q3  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q4  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                                                                                ||
q9  : ───────────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                                ||
                                                           ┌─────────────────┐       ┌─────────────────┐        ||
q10 : ─────────────────────────────────────────────────●───┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├───●─── ||
                                                       │   └─────────────────┘   │   └─────────────────┘   │    ||
       ┌─────────────────┐       ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐ ┌─┴─┐  ||
q11 : ─┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─┤ Z ├─ ||
       └─────────────────┘   │   └─────────────────┘ └───┘ └─────────────────┘ └───┘ └─────────────────┘ └───┘  ||
       ┌─────────────────┐ ┌─┴─┐                                                                                ||
q12 : ─┤ PRx(1.57, 0.00) ├─┤ Z ├─────────────────────────────────────────────────────────────────────────────── ||
       └─────────────────┘ └───┘                                                                                ||
T   : │        49         │ 50  │        51         │ 52  │        53         │ 54  │        55         │ 56  │ ||

T   : │ 57  │        58         │        59         │      60       │ 61  │
                                                                     ┌───┐
q1  : ─────────────────────────────────────────────────EndVerbatim───┤ M ├─
                                                            ║        └───┘
                                                            ║        ┌───┐
q2  : ──────────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║        ┌───┐
q3  : ──────────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║        ┌───┐
q4  : ──────────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║        ┌───┐
q5  : ──────────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║        ┌───┐
q6  : ──────────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║
q7  : ──────────────────────────────────────────────────────║──────────────
                                                            ║
                                                            ║
q8  : ──────────────────────────────────────────────────────║──────────────
                                                            ║
       ┌───┐ ┌─────────────────┐ ┌─────────────────┐        ║        ┌───┐
q9  : ─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────║────────┤ M ├─
       └─┬─┘ └─────────────────┘ └─────────────────┘        ║        └───┘
         │                                                  ║        ┌───┐
q10 : ───●──────────────────────────────────────────────────║────────┤ M ├─
                                                            ║        └───┘
                                                            ║
q11 : ──────────────────────────────────────────────────────║──────────────
                                                            ║
                                                            ║
q12 : ──────────────────────────────────────────────────────╨──────────────

T   : │ 57  │        58         │        59         │      60       │ 61  │

We can unpack this a bit by using the Qiskit-specific BraketAwsBackend, which provides both a Target as well as the device labels.

In [7]:
from qiskit_braket_provider import BraketAwsBackend

backend = BraketAwsBackend(device=garnet)
ghz_garnet_alt = to_braket(ghz, qubit_labels=backend.qubit_labels, target=backend.target, optimization_level=3)

dprint(ghz_garnet_alt)
T   : │        0        │         1         │         2         │  3  │         4         │         5         │ ||
                         ┌─────────────────┐ ┌─────────────────┐                                                ||
q4  : ───StartVerbatim───┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q5  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐ ┌───┐ ┌─────────────────┐ ┌─────────────────┐  ||
q6  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─ ||
               ║         └─────────────────┘ └─────────────────┘ └─┬─┘ └─────────────────┘ └─────────────────┘  ||
               ║         ┌─────────────────┐ ┌─────────────────┐   │                                            ||
q7  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q8  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q9  : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q13 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
               ║         └─────────────────┘ └─────────────────┘                                                ||
               ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q14 : ─────────╨─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
                         └─────────────────┘ └─────────────────┘                                                ||
T   : │        0        │         1         │         2         │  3  │         4         │         5         │ ||

T   : │  6  │         7         │         8         │  9  │        10         │        11         │ 12  │ ||
                                                     ┌───┐ ┌─────────────────┐ ┌─────────────────┐        ||
q4  : ───────────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─── ||
                                                     └─┬─┘ └─────────────────┘ └─────────────────┘   │    ||
       ┌───┐ ┌─────────────────┐ ┌─────────────────┐   │                                             │    ||
q5  : ─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─────────────────────────────────────────────┼─── ||
       └─┬─┘ └─────────────────┘ └─────────────────┘                                                 │    ||
         │                                                                                           │    ||
q6  : ───●───────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                                     │    ||
                                                                                                     │    ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                                     │    ||
                                                                                                     │    ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────────┼─── ||
                                                                                                     │    ||
                                                                                                   ┌─┴─┐  ||
q9  : ─────────────────────────────────────────────────────────────────────────────────────────────┤ Z ├─ ||
                                                                                                   └───┘  ||
                                                                                                          ||
q13 : ─────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                          ||
                                                                                                          ||
q14 : ─────────────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                          ||
T   : │  6  │         7         │         8         │  9  │        10         │        11         │ 12  │ ||

T   : │        13         │        14         │ 15  │        16         │        17         │ 18  │ ||
                                                                                                    ||
q4  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q5  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q6  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q7  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
                                                                                                    ||
q8  : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                    ||
       ┌─────────────────┐ ┌─────────────────┐                                                      ||
q9  : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────── ||
       └─────────────────┘ └─────────────────┘   │                                                  ||
                                                 │                                           ┌───┐  ||
q13 : ───────────────────────────────────────────┼───────────────────────────────────────────┤ Z ├─ ||
                                                 │                                           └─┬─┘  ||
                                               ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐   │    ||
q14 : ─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─── ||
                                               └───┘ └─────────────────┘ └─────────────────┘        ||
T   : │        13         │        14         │ 15  │        16         │        17         │ 18  │ ||

T   : │        19         │        20         │ 21  │        22         │        23         │      24       │ ||
                                                                                                              ||
q4  : ─────────────────────────────────────────────────────────────────────────────────────────EndVerbatim─── ||
                                                                                                    ║         ||
                                                                                                    ║         ||
q5  : ──────────────────────────────────────────────────────────────────────────────────────────────║──────── ||
                                                                                                    ║         ||
                                                                                                    ║         ||
q6  : ──────────────────────────────────────────────────────────────────────────────────────────────║──────── ||
                                                                                                    ║         ||
                                                                                                    ║         ||
q7  : ──────────────────────────────────────────────────────────────────────────────────────────────║──────── ||
                                                                                                    ║         ||
                                               ┌───┐ ┌─────────────────┐ ┌─────────────────┐        ║         ||
q8  : ─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────║──────── ||
                                               └─┬─┘ └─────────────────┘ └─────────────────┘        ║         ||
                                                 │                                                  ║         ||
q9  : ───────────────────────────────────────────┼──────────────────────────────────────────────────║──────── ||
                                                 │                                                  ║         ||
       ┌─────────────────┐ ┌─────────────────┐   │                                                  ║         ||
q13 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●──────────────────────────────────────────────────║──────── ||
       └─────────────────┘ └─────────────────┘                                                      ║         ||
                                                                                                    ║         ||
q14 : ──────────────────────────────────────────────────────────────────────────────────────────────╨──────── ||
                                                                                                              ||
T   : │        19         │        20         │ 21  │        22         │        23         │      24       │ ||

T   : │ 25  │
       ┌───┐
q4  : ─┤ M ├─
       └───┘
       ┌───┐
q5  : ─┤ M ├─
       └───┘
       ┌───┐
q6  : ─┤ M ├─
       └───┘
       ┌───┐
q7  : ─┤ M ├─
       └───┘
       ┌───┐
q8  : ─┤ M ├─
       └───┘
       ┌───┐
q9  : ─┤ M ├─
       └───┘
       ┌───┐
q13 : ─┤ M ├─
       └───┘
       ┌───┐
q14 : ─┤ M ├─
       └───┘
T   : │ 25  │

Importantly, we see that with Braket-compiled and Qiskit-compiled circuits, a different qubit layout has been applied, based on knowledge of the device.

[!Note] A critical keyword for this is qubit_labels, which is used for converting back to any non-contiguous qubits in Braket.

If instead, we want to perform more granular manipulation, we can directly specify items like basis_gates, coupling_map, angle_restrictions, or the optimization_level of the preset_pass_manager. For those more familiar with Qiskit, we can also supply a custom PassManager object.

[!IMPORTANT] Verbatim flags will not always be applied to a circuit. These are mainly supplied when a device or Target is specified, the verbatim flag is specified, or when a custom PassManger is utilized. To remove measurement, use the to_qiskit feature with add_measurement=False.

[!NOTE] Circuit indexing can also be accomplished via the target_mapping keyword in Circuit().add_circuit. However, for consistency with the contiguous Qiskit ordering convention, using backend.qubit_labels is preferred.

In [ ]:
ghz_basis = to_braket(ghz, basis_gates=["cz","r"]) #  
print("Circuit in a native basis for IQM:")
dprint(ghz_basis) # 

print("Circuit across a linear layout:")
ghz_linear = to_braket(ghz, coupling_map=[[5,4],[4,3],[3,2],[2,0],[0,6],[6,1],[1,7]], optimization_level=2) # custom linear layout
dprint(ghz_linear)
Circuit in a native basis for IQM:
T  : │         0         │         1         │  2  │         3         │         4         │  5  │ ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q0 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘   │                                                  ||
      ┌─────────────────┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐        ||
q1 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─── ||
      └─────────────────┘ └─────────────────┘ └───┘ └─────────────────┘ └─────────────────┘   │    ||
      ┌─────────────────┐ ┌─────────────────┐                                               ┌─┴─┐  ||
q2 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────┤ Z ├─ ||
      └─────────────────┘ └─────────────────┘                                               └───┘  ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q3 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘                                                      ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q4 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘                                                      ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q5 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘                                                      ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q6 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘                                                      ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q7 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘                                                      ||
T  : │         0         │         1         │  2  │         3         │         4         │  5  │ ||

T  : │         6         │         7         │  8  │         9         │        10         │ 11  │ ||
                                                                                                   ||
q0 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q1 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q2 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘   │                                                  ||
                                              ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐        ||
q3 : ─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─── ||
                                              └───┘ └─────────────────┘ └─────────────────┘   │    ||
                                                                                            ┌─┴─┐  ||
q4 : ───────────────────────────────────────────────────────────────────────────────────────┤ Z ├─ ||
                                                                                            └───┘  ||
                                                                                                   ||
q5 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q6 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q7 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
T  : │         6         │         7         │  8  │         9         │        10         │ 11  │ ||

T  : │        12         │        13         │ 14  │        15         │        16         │ 17  │ ||
                                                                                                   ||
q0 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q1 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q2 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
                                                                                                   ||
q3 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
      ┌─────────────────┐ ┌─────────────────┐                                                      ||
q4 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────────── ||
      └─────────────────┘ └─────────────────┘   │                                                  ||
                                              ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐        ||
q5 : ─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●─── ||
                                              └───┘ └─────────────────┘ └─────────────────┘   │    ||
                                                                                            ┌─┴─┐  ||
q6 : ───────────────────────────────────────────────────────────────────────────────────────┤ Z ├─ ||
                                                                                            └───┘  ||
                                                                                                   ||
q7 : ───────────────────────────────────────────────────────────────────────────────────────────── ||
                                                                                                   ||
T  : │        12         │        13         │ 14  │        15         │        16         │ 17  │ ||

T  : │        18         │        19         │ 20  │        21         │        22         │ 23  │
                                                                                            ┌───┐
q0 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
                                                                                            ┌───┐
q1 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
                                                                                            ┌───┐
q2 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
                                                                                            ┌───┐
q3 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
                                                                                            ┌───┐
q4 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
                                                                                            ┌───┐
q5 : ───────────────────────────────────────────────────────────────────────────────────────┤ M ├─
                                                                                            └───┘
      ┌─────────────────┐ ┌─────────────────┐                                               ┌───┐
q6 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───●───────────────────────────────────────────┤ M ├─
      └─────────────────┘ └─────────────────┘   │                                           └───┘
                                              ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐ ┌───┐
q7 : ─────────────────────────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ M ├─
                                              └───┘ └─────────────────┘ └─────────────────┘ └───┘
T  : │        18         │        19         │ 20  │        21         │        22         │ 23  │
Circuit across a linear layout:
T  : │  0  │  1  │  2  │  3  │  4  │  5  │  6  │  7  │  8  │
                        ┌───┐                         ┌───┐ 
q0 : ───────────────────┤ X ├───●─────────────────────┤ M ├─
                        └─┬─┘   │                     └───┘ 
            ┌───┐         │     │                     ┌───┐ 
q1 : ───────┤ X ├───●─────┼─────┼─────────────────────┤ M ├─
            └─┬─┘   │     │     │                     └───┘ 
              │     │     │   ┌─┴─┐                   ┌───┐ 
q2 : ─────────┼─────┼─────┼───┤ X ├───●───────────────┤ M ├─
              │     │     │   └───┘   │               └───┘ 
              │     │     │         ┌─┴─┐             ┌───┐ 
q3 : ─────────┼─────┼─────┼─────────┤ X ├───●─────────┤ M ├─
              │     │     │         └───┘   │         └───┘ 
              │     │     │               ┌─┴─┐       ┌───┐ 
q4 : ─────────┼─────┼─────┼───────────────┤ X ├───●───┤ M ├─
              │     │     │               └───┘   │   └───┘ 
              │     │     │                     ┌─┴─┐ ┌───┐ 
q5 : ─────────┼─────┼─────┼─────────────────────┤ X ├─┤ M ├─
              │     │     │                     └───┘ └───┘ 
              │   ┌─┴─┐   │                           ┌───┐ 
q6 : ─────────┼───┤ X ├───●───────────────────────────┤ M ├─
              │   └───┘                               └───┘ 
      ┌───┐   │                                       ┌───┐ 
q7 : ─┤ H ├───●───────────────────────────────────────┤ M ├─
      └───┘                                           └───┘ 
T  : │  0  │  1  │  2  │  3  │  4  │  5  │  6  │  7  │  8  │

The optimization_level matches the Qiskit transpiler keyword. The Qiskit transpiler (which performs quantum circuit compilation, also called transpilation) can take numerous constraints reflecting information on a device, including but not limited to, the unitary gate set, device connectivity, gate error rates and timing, and more. This can be supplied via a backend or Target, or as additional arguments. The optimization levels correspond with hierarchically increasing levels of optimization, which will first ensure that the circuit can be run on a particular basis set and connectivity, and with higher levels can perform advanced rerouting and attempt to simplify unitary gate sequences.

In [9]:
ghz_4 = Circuit().cnot(0,2).cnot(0,1).cnot(2,3)

for opt_level in [0,1,2,3]:
    print(f"Optimization Level: {opt_level}")
    circ =to_braket(ghz_4, braket_device=garnet, optimization_level=opt_level)
    n_cz = [ins.operator.name for ins in circ.instructions].count("CZ")
    print(f"Number of CZ Gates: {n_cz}")
    dprint(circ)
Optimization Level: 0
Number of CZ Gates: 6
T  : │        0        │         1         │         2         │         3         │  4  │         5         │ ||
                                                                                                               ||
q1 : ───StartVerbatim───────────────────────────────────────────────────────────────────────────────────────── ||
              ║                                                                                                ||
              ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q2 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
              ║         └─────────────────┘ └─────────────────┘                                                ||
              ║         ┌─────────────────┐        ┌───┐        ┌─────────────────┐ ┌───┐ ┌─────────────────┐  ||
q3 : ─────────║─────────┤ PRx(1.57, 0.00) ├────────┤ Z ├────────┤ PRx(1.57, 0.00) ├─┤ Z ├─┤ PRx(1.57, 0.00) ├─ ||
              ║         └─────────────────┘        └─┬─┘        └─────────────────┘ └─┬─┘ └─────────────────┘  ||
              ║         ┌─────────────────┐          │          ┌─────────────────┐   │   ┌─────────────────┐  ||
q4 : ─────────╨─────────┤ PRx(1.57, 0.00) ├──────────●──────────┤ PRx(1.57, 0.00) ├───●───┤ PRx(1.57, 0.00) ├─ ||
                        └─────────────────┘                     └─────────────────┘       └─────────────────┘  ||
T  : │        0        │         1         │         2         │         3         │  4  │         5         │ ||

T  : │  6  │         7         │         8         │  9  │        10         │        11         │ ||
                                                                                                   ||
q1 : ─────────────────────────────────────────────────●────────────●────────────────────────────── ||
                                                      │            │                               ||
                                                      │          ┌─┴─┐        ┌─────────────────┐  ||
q2 : ─────────────────────────────────────────────────┼──────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─ ||
                                                      │          └───┘        └─────────────────┘  ||
      ┌───┐ ┌─────────────────┐ ┌─────────────────┐   │                                            ||
q3 : ─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───┼─────────────────────────────────────────── ||
      └─┬─┘ └─────────────────┘ └─────────────────┘   │                                            ||
        │   ┌─────────────────┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐  ||
q4 : ───●───┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─ ||
            └─────────────────┘ └─────────────────┘ └───┘ └─────────────────┘ └─────────────────┘  ||
T  : │  6  │         7         │         8         │  9  │        10         │        11         │ ||

T  : │        12         │        13         │        14         │      15       │ 16  │
                                                                                  ┌───┐
q1 : ───────────────────────────────────────────────────────────────EndVerbatim───┤ M ├─
                                                                         ║        └───┘
      ┌─────────────────┐                                                ║        ┌───┐
q2 : ─┤ PRx(3.14, 0.00) ├────────────────────────────────────────────────║────────┤ M ├─
      └─────────────────┘                                                ║        └───┘
             ┌───┐        ┌─────────────────┐ ┌─────────────────┐        ║        ┌───┐
q3 : ────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────║────────┤ M ├─
             └─┬─┘        └─────────────────┘ └─────────────────┘        ║        └───┘
               │                                                         ║        ┌───┐
q4 : ──────────●─────────────────────────────────────────────────────────╨────────┤ M ├─
                                                                                  └───┘
T  : │        12         │        13         │        14         │      15       │ 16  │
Optimization Level: 1
Number of CZ Gates: 3
T  : │        0        │         1         │         2         │  3  │            4            │ ||
                                                                                                 ||
q4 : ───StartVerbatim─────────────────────────────────────────────●─────────────────────────●─── ||
              ║                                                   │                         │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐   │    ||
q5 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├───┼─── ||
              ║         └─────────────────┘ └─────────────────┘ └───┘ └─────────────────┘   │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐                             │    ||
q6 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────┼─── ||
              ║         └─────────────────┘ └─────────────────┘                             │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐                           ┌─┴─┐  ||
q9 : ─────────╨─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────┤ Z ├─ ||
                        └─────────────────┘ └─────────────────┘                           └───┘  ||
T  : │        0        │         1         │         2         │  3  │            4            │ ||

T  : │         5         │         6         │         7         │         8         │       9       │ 10  │
                                                                                                      ┌───┐
q4 : ───────────────────────────────────────────────────────────────────────────────────EndVerbatim───┤ M ├─
                                                                                             ║        └───┘
      ┌─────────────────┐                                                                    ║        ┌───┐
q5 : ─┤ PRx(3.14, 0.00) ├──────────●─────────────────────────────────────────────────────────║────────┤ M ├─
      └─────────────────┘          │                                                         ║        └───┘
                                 ┌─┴─┐        ┌─────────────────┐ ┌─────────────────┐        ║        ┌───┐
q6 : ────────────────────────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────║────────┤ M ├─
                                 └───┘        └─────────────────┘ └─────────────────┘        ║        └───┘
      ┌─────────────────┐ ┌─────────────────┐                                                ║        ┌───┐
q9 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────────────────────────────────────────────╨────────┤ M ├─
      └─────────────────┘ └─────────────────┘                                                         └───┘
T  : │         5         │         6         │         7         │         8         │       9       │ 10  │
Optimization Level: 2
Number of CZ Gates: 3
T  : │        0        │         1         │         2         │  3  │            4            │ ||
                                                                                                 ||
q4 : ───StartVerbatim─────────────────────────────────────────────●─────────────────────────●─── ||
              ║                                                   │                         │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐ ┌─┴─┐ ┌─────────────────┐   │    ||
q5 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├───┼─── ||
              ║         └─────────────────┘ └─────────────────┘ └───┘ └─────────────────┘   │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐                             │    ||
q6 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────┼─── ||
              ║         └─────────────────┘ └─────────────────┘                             │    ||
              ║         ┌─────────────────┐ ┌─────────────────┐                           ┌─┴─┐  ||
q9 : ─────────╨─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├───────────────────────────┤ Z ├─ ||
                        └─────────────────┘ └─────────────────┘                           └───┘  ||
T  : │        0        │         1         │         2         │  3  │            4            │ ||

T  : │         5         │         6         │         7         │         8         │       9       │ 10  │
                                                                                                      ┌───┐
q4 : ───────────────────────────────────────────────────────────────────────────────────EndVerbatim───┤ M ├─
                                                                                             ║        └───┘
      ┌─────────────────┐                                                                    ║        ┌───┐
q5 : ─┤ PRx(3.14, 0.00) ├──────────●─────────────────────────────────────────────────────────║────────┤ M ├─
      └─────────────────┘          │                                                         ║        └───┘
                                 ┌─┴─┐        ┌─────────────────┐ ┌─────────────────┐        ║        ┌───┐
q6 : ────────────────────────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────║────────┤ M ├─
                                 └───┘        └─────────────────┘ └─────────────────┘        ║        └───┘
      ┌─────────────────┐ ┌─────────────────┐                                                ║        ┌───┐
q9 : ─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────────────────────────────────────────────╨────────┤ M ├─
      └─────────────────┘ └─────────────────┘                                                         └───┘
T  : │         5         │         6         │         7         │         8         │       9       │ 10  │
Optimization Level: 3
Number of CZ Gates: 3
T  : │        0        │         1         │         2         │  3  │         4         │         5         │ ||
                        ┌─────────────────┐ ┌─────────────────┐ ┌───┐ ┌─────────────────┐ ┌─────────────────┐  ||
q4 : ───StartVerbatim───┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─ ||
              ║         └─────────────────┘ └─────────────────┘ └─┬─┘ └─────────────────┘ └─────────────────┘  ||
              ║                                                   │                                            ||
q5 : ─────────║───────────────────────────────────────────────────●────────────●────────────────────────────── ||
              ║                                                                │                               ||
              ║         ┌─────────────────┐ ┌─────────────────┐              ┌─┴─┐        ┌─────────────────┐  ||
q6 : ─────────║─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├──────────────┤ Z ├────────┤ PRx(1.57, 1.57) ├─ ||
              ║         └─────────────────┘ └─────────────────┘              └───┘        └─────────────────┘  ||
              ║         ┌─────────────────┐ ┌─────────────────┐                                                ||
q9 : ─────────╨─────────┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├─────────────────────────────────────────────── ||
                        └─────────────────┘ └─────────────────┘                                                ||
T  : │        0        │         1         │         2         │  3  │         4         │         5         │ ||

T  : │            6            │         7         │         8         │       9       │ 10  │
                                                                                        ┌───┐
q4 : ───────────────────────●─────────────────────────────────────────────EndVerbatim───┤ M ├─
                            │                                                  ║        └───┘
                            │                                                  ║        ┌───┐
q5 : ───────────────────────┼──────────────────────────────────────────────────║────────┤ M ├─
                            │                                                  ║        └───┘
      ┌─────────────────┐   │                                                  ║        ┌───┐
q6 : ─┤ PRx(3.14, 0.00) ├───┼──────────────────────────────────────────────────║────────┤ M ├─
      └─────────────────┘   │                                                  ║        └───┘
                          ┌─┴─┐ ┌─────────────────┐ ┌─────────────────┐        ║        ┌───┐
q9 : ─────────────────────┤ Z ├─┤ PRx(1.57, 1.57) ├─┤ PRx(3.14, 0.00) ├────────╨────────┤ M ├─
                          └───┘ └─────────────────┘ └─────────────────┘                 └───┘
T  : │            6            │         7         │         8         │       9       │ 10  │

For this example, the main difference is between Qiskit's optimization levels 0 and 1, though for more complex (and particularly larger) circuits, additional resynthesis and more agressive rerouting might be beneficial.

Further Information

The to_braket function supports Qiskit QuantumCircuits, as well as functional OpenQASM3 programs. More information and examples can be seen in the related tutorial. Quantum circuit compilation is a rich and critical field, relevant for current devices as well as fault tolerant considerations.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Versions

v1 Latest
Jun 15, 2026
qcr:2606.51702.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Amazon Braket SDK

Keywords

compilation
transpilation
qiskit
braket
provider

You may also like5