Skip to content

Lesson 41: Amazon Braket

41.1 Learning Outcomes

By the end of this hour a student will be able to:

  1. Describe Braket's managed-service model and how it differs from vendor SDKs.
  2. Build and run circuits with the Braket SDK on simulators and QPUs.
  3. Compare the hardware vendors available through Braket.
  4. Compute the cost of a Braket experiment and design within a budget.
  5. Use Hybrid Jobs for variational algorithms.

41.2 The Managed-Service Model

Braket is not a competing SDK so much as a procurement and orchestration layer. Its value proposition is one account, one API and one bill for hardware from several independent companies.

Vendor SDK (Qiskit, Cirq) Amazon Braket
Hardware access one vendor many vendors
Account one per vendor one AWS account
Billing free tier / research grants pay per task and per shot
Simulators local local and managed (up to 34 qubits, GPU)
Storage your machine S3, automatic
Orchestration write your own Hybrid Jobs (managed containers)

When Braket is the right choice: benchmarking across hardware modalities, running production workloads with SLAs, or needing large managed simulators without owning a cluster.

When it is not: learning (IBM's free tier is better), or research needing pulse-level control (vendor SDKs expose more).

41.3 The Braket SDK

Installation and a first circuit

pip install amazon-braket-sdk
aws configure                    # set credentials and region
from braket.circuits import Circuit
from braket.devices import LocalSimulator

circ = Circuit().h(0).cnot(0, 1)
circ.probability()

device = LocalSimulator()
result = device.run(circ, shots=1000).result()
print(result.measurement_counts)
# Counter({'00': 508, '11': 492})

The chaining style is distinctive: Circuit().h(0).cnot(0,1).rx(2, 0.5). Every gate method returns the circuit, so operations chain fluently.

Gate reference

c = Circuit()
c.i(0); c.x(0); c.y(0); c.z(0)
c.h(0); c.s(0); c.si(0); c.t(0); c.ti(0); c.v(0); c.vi(0)   # v = sqrt(X)
c.rx(0, theta); c.ry(0, theta); c.rz(0, theta); c.phaseshift(0, phi)

c.cnot(0, 1); c.cz(0, 1); c.swap(0, 1); c.iswap(0, 1)
c.xx(0, 1, angle); c.yy(0, 1, angle); c.zz(0, 1, angle)     # Ising gates -- ion-native
c.ccnot(0, 1, 2); c.cswap(0, 1, 2)

Note xx, yy, zz. These Mølmer–Sørensen-type gates are native to trapped-ion hardware, so on IonQ they compile to a single physical operation, whereas a CNOT decomposes into several. Using the native gate set is often worth 2–3× in fidelity.

Result types

circ.probability()                       # full distribution
circ.expectation(observable=Observable.Z(), target=0)
circ.variance(observable=Observable.Z(), target=0)
circ.sample(observable=Observable.Z(), target=0)
circ.state_vector()                      # simulators only
circ.amplitude(state=["00", "11"])       # specific amplitudes

41.4 Devices

Simulators

Device ARN suffix Type Max qubits Notes
LocalSimulator() — statevector ~25 free, on your machine
SV1 sv1 statevector 34 managed, parallel
DM1 dm1 density matrix 17 noise simulation
TN1 tn1 tensor network 50 shallow circuits only
from braket.aws import AwsDevice

sv1 = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
result = sv1.run(circ, shots=1000, s3_destination_folder=s3).result()

Quantum processors

Vendor Technology Qubits Connectivity Native 2Q gate
IonQ Forte / Aria trapped ion 36 / 25 all-to-all MS (\(XX\))
Rigetti Ankaa-3 superconducting 84 octagonal lattice iSWAP / CZ
IQM Garnet superconducting 20 square lattice CZ
QuEra Aquila neutral atom 256 analog only Rydberg blockade
device = AwsDevice("arn:aws:braket:us-east-1::device/qpu/ionq/Forte-1")
print(device.properties.paradigm.qubitCount)
print(device.status)                       # ONLINE / OFFLINE
print(device.properties.service.executionWindows)   # availability schedule

QuEra Aquila is different in kind. It is an analog Hamiltonian simulator, not a gate device. You specify a time-dependent Rydberg Hamiltonian — atom positions, laser detuning and Rabi frequency — and it evolves the system. Excellent for many-body physics; it cannot run gate circuits at all.

Choosing a device

Requirement Choose
Highest fidelity, dense connectivity IonQ (all-to-all, no SWAPs)
Fastest execution, many shots Rigetti / IQM (ns gates)
Many qubits, analog physics QuEra
Debugging LocalSimulator (free)
30+ qubits noiseless SV1
Noise studies DM1

41.5 Cost Model

This is the practical constraint students must learn to plan around.

Component Price (indicative, US, 2024)
Per task (a job submission) $0.30
Per shot — IonQ $0.03
Per shot — Rigetti / IQM $0.00035
SV1 simulator $0.075 per minute
DM1 simulator $0.075 per minute
TN1 simulator $0.275 per minute
Hybrid Jobs (classical container) standard EC2 rates

The per-task charge is the trap. Submitting 1000 separate one-shot tasks costs \(1000\times\$0.30 = \$300\) in task fees alone. Always batch shots into a single task.

IonQ is ~85× more expensive per shot than Rigetti — reflecting slower gates and higher fidelity. Budget accordingly: use Rigetti for exploration and IonQ for final high-fidelity runs.

41.6 Hybrid Jobs

For variational algorithms, round-tripping between your laptop and AWS for every iteration is slow and expensive in task fees. Hybrid Jobs run your classical optimisation loop in an AWS container next to the QPU, with priority queue access.

from braket.jobs import hybrid_job
from braket.jobs.metrics import log_metric

@hybrid_job(device="arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1")
def run_vqe(n_iterations=100):
    from braket.aws import AwsDevice
    device = AwsDevice(get_job_device_arn())
    params = initial_params
    for i in range(n_iterations):
        energy = evaluate(device, params)
        params = update(params, energy)
        log_metric(metric_name="energy", value=energy, iteration_number=i)
    return params

job = run_vqe(n_iterations=50)
print(job.arn, job.state())

Three concrete benefits.

  1. Priority queueing. The QPU is reserved for the job's duration, so iterations do not sit behind other users' tasks — this alone can turn a 12-hour run into 20 minutes.
  2. Lower latency. The classical loop runs in the same AWS region as the QPU.
  3. Checkpointing and metrics. Progress survives interruptions and is visible in CloudWatch.

41.7 Solved Problems

Problem 1 — Cost of a QSVM experiment

A QSVM needs a 50×50 kernel matrix at 1000 shots per entry. Compute the cost on (a) IonQ, (b) Rigetti, (c) SV1, assuming one task per kernel entry.

Solution.

Number of kernel entries. Symmetric, diagonal known:

\[ \frac{50\times49}{2} = \mathbf{1225\ \text{entries}} \]

(a) IonQ.

\[ \text{task fees} = 1225\times\$0.30 = \$367.50 \]
\[ \text{shot fees} = 1225\times1000\times\$0.03 = \$36{,}750 \]
\[ \boxed{\text{Total} = \$37{,}117.50} \]

(b) Rigetti.

\[ \text{task fees} = 1225\times\$0.30 = \$367.50 \]
\[ \text{shot fees} = 1225\times1000\times\$0.00035 = \$428.75 \]
\[ \boxed{\text{Total} = \$796.25} \]

(c) SV1 (noiseless simulator). At roughly 0.5 s per 1000-shot circuit:

\[ \text{time} = \frac{1225\times0.5}{60} = 10.2\ \text{minutes} \]
\[ \boxed{\text{Total} = 10.2\times\$0.075 = \$0.77} \]

Comparison.

Platform Cost Ratio to SV1
SV1 simulator $0.77 1×
Rigetti QPU $796 1030×
IonQ QPU $37 118 48 000×

Three lessons.

  1. Develop on simulators. A $0.77 run tells you whether the algorithm works before you spend $37 000 finding out that it does not.
  2. Batch tasks. If the SDK allows submitting a batch of circuits as one task, the $367.50 in task fees collapses to $0.30. Use AwsQuantumTaskBatch.
  3. The \(O(M^2)\) wall is financial as well as computational (L27). Doubling to 100 training samples quadruples the cost: IonQ would run to about $150 000.

Problem 2 — Native gates and fidelity on IonQ

A circuit needs 20 CNOTs. Compare running it as CNOTs versus rewriting with native \(XX\) (MS) gates on IonQ, given CNOT decomposes to 1 MS + 4 single-qubit gates, with \(\epsilon_{\text{MS}} = 0.4\%\) and \(\epsilon_{1q} = 0.03\%\).

Solution.

As CNOTs. Each CNOT compiles to 1 MS gate plus 4 single-qubit gates:

\[ 20\ \text{CNOTs} \Rightarrow 20\ \text{MS} + 80\ \text{single-qubit} \]
\[ F = (1-0.004)^{20}\times(1-0.0003)^{80} = 0.996^{20}\times0.9997^{80} \]
\[ = 0.9231 \times 0.9763 = \mathbf{0.9013} \]

Rewritten with native \(XX\) gates. If the algorithm's two-qubit interactions are naturally Ising-type (as in QAOA's \(Z_iZ_j\) terms, or Trotterised spin Hamiltonians), each maps to one MS gate with no surrounding single-qubit gates:

\[ 20\ \text{MS gates only} \]
\[ F = 0.996^{20} = \mathbf{0.9231} \]

Improvement.

\[ \frac{1 - 0.9013}{1 - 0.9231} = \frac{0.0987}{0.0769} = \mathbf{1.28\times}\ \text{less error} \]

Where the gain is much larger. On superconducting hardware the same 20 two-qubit gates would also need SWAPs if the interactions are non-local. For a dense interaction graph on 8 qubits, routing typically triples the two-qubit count:

\[ F_{\text{supercond}} \approx (1-0.008)^{60} = \mathbf{0.618} \]

versus IonQ's \(0.923\) — a 5× smaller error on IonQ despite its 1000× slower gates.

\[ \boxed{\ \textbf{All-to-all connectivity plus native Ising gates is why trapped ions win on connectivity-heavy circuits.}\ } \]

Design rule. Express the algorithm in the hardware's native gate set. In Braket:

circ = Circuit().zz(0, 1, angle)     # native on IonQ -- 1 physical gate
# rather than
circ = Circuit().cnot(0,1).rz(1, angle).cnot(0,1)   # 2 MS + overhead

Problem 3 — Designing within a budget

You have $500 of AWS credit and must demonstrate QAOA on a 6-node Max-Cut problem. Design the full experiment.

Solution.

Phase 1 — Simulator development (budget: $5).

from braket.devices import LocalSimulator      # FREE
  • Implement QAOA for \(p = 1, 2, 3\) on 6 qubits (\(2^6 = 64\) amplitudes — instant).
  • Grid-search \((\gamma,\beta)\) over \(20\times20\) points for each \(p\).
  • Brute-force the exact optimum for comparison (only \(2^6 = 64\) bitstrings).
  • Cost: $0 (local simulator).

Phase 2 — Noise study on DM1 (budget: $20).

dm1 = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/dm1")
  • 6 qubits is within DM1's 17-qubit limit.
  • Sweep the two-qubit error rate from \(10^{-3}\) to \(10^{-2}\) to predict which \(p\) survives on hardware.
  • ~20 configurations × 30 s = 10 minutes → $0.75.
  • Expected finding: \(p=1\) survives, \(p=3\) is destroyed by noise.

Phase 3 — Rigetti hardware run (budget: $50).

  • Circuit: \(p=1\), 6 qubits, \(|E|\) = say 9 edges → 18 CNOTs + 6 \(R_x\).
  • Batch all parameter settings into one task using AwsQuantumTaskBatch.
  • 10 parameter points × 2000 shots:
\[ \text{cost} = \underbrace{\$0.30}_{\text{one batched task}} + 10\times2000\times\$0.00035 = \$0.30 + \$7.00 = \$7.30 \]

Phase 4 — IonQ confirmation run (budget: $400).

  • Run only the single best parameter setting found in Phase 3.
  • Higher fidelity and all-to-all connectivity → no SWAPs.
\[ \text{shots affordable} = \frac{\$400 - \$0.30}{\$0.03} = \mathbf{13{,}323\ \text{shots}} \]

Use 10 000 shots, leaving margin.

\[ \text{cost} = \$0.30 + 10{,}000\times\$0.03 = \$300.30 \]

Total budget.

Phase Platform Cost
1. Development LocalSimulator $0.00
2. Noise study DM1 $0.75
3. Exploration Rigetti $7.30
4. Final result IonQ $300.30
Total $308.35
Remaining $191.65 for reruns

The strategy in one sentence. Spend compute where it is free, spend cheap hardware where you need to explore, and spend expensive hardware once, on the single configuration you have already validated.

Problem 4 — Comparing three hardware modalities

Design a benchmark comparing IonQ, Rigetti and IQM on the same circuit, and predict the results.

Solution.

The benchmark circuit: GHZ state on \(n\) qubits, for \(n = 2,\dots,8\), measuring the fidelity of the \(\Pr[00\cdots0] + \Pr[11\cdots1]\) signal.

Why GHZ? It requires long-range entanglement — every qubit correlated with every other — which is exactly the regime where connectivity matters. It is also easy to verify: an ideal GHZ gives \(\Pr[0^n] = \Pr[1^n] = 0.5\) and zero probability for everything else.

def ghz(n):
    c = Circuit().h(0)
    for i in range(n - 1):
        c.cnot(i, i + 1)          # chain construction (topology-friendly)
    return c

devices = {
    "IonQ":    "arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1",
    "Rigetti": "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-3",
    "IQM":     "arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet",
}

for name, arn in devices.items():
    for n in range(2, 9):
        task = AwsDevice(arn).run(ghz(n).probability(), shots=1000)
        # record P(0^n) + P(1^n)

Predicted results.

\(n\) IonQ (all-to-all) Rigetti (lattice) IQM (square)
2 0.98 0.97 0.96
4 0.94 0.88 0.86
6 0.89 0.74 0.70
8 0.83 0.58 0.52

Reasoning behind the prediction.

  • IonQ uses a chain of MS gates with no SWAPs (all-to-all), so gate count is \(n-1\), giving \(F \approx 0.996^{n-1}\times(\text{single-qubit and readout errors})\).
  • Rigetti / IQM need the chain to lie along a physical path. On a lattice a linear chain usually fits without SWAPs too — so the gap is driven mainly by their higher two-qubit error (\(\sim0.8\)–\(1.5\%\) versus IonQ's \(0.4\%\)) and higher readout error.
  • The gap widens with \(n\) because errors compound multiplicatively.

A second, harder benchmark to add. Replace GHZ with a fully connected QAOA circuit (interactions between all pairs). Then Rigetti and IQM require \(O(n^2)\) SWAPs while IonQ requires none, and the gap should widen dramatically — predicted \(F_{n=8}\): IonQ 0.70, Rigetti 0.15.

What to report. Fidelity versus two-qubit gate count and versus wall-clock time, on the same axes. IonQ wins on fidelity; Rigetti wins on speed and cost by ~85×. There is no single "best" device — only best for a given circuit shape and budget.

Problem 5 — When to use Braket versus a vendor SDK

Recommend Braket or a vendor SDK for each scenario.

(a) An undergraduate course lab. (b) A benchmarking paper comparing four hardware platforms. (c) Production VQE for a pharmaceutical company. (d) Research needing pulse-level control on IBM hardware. (e) A 30-qubit noiseless simulation without owning a cluster.

Solution.

(a) Course lab → Qiskit (vendor SDK). IBM's free tier gives students hardware access at no cost and no credit card. Braket requires an AWS account with billing enabled — an administrative barrier, and a genuine financial risk if a student submits 1000 unbatched tasks by accident. Never expose students to per-shot billing in a first course.

(b) Benchmarking paper → Braket. This is Braket's purpose. One SDK, one billing account, and — importantly for reproducibility — one uniform circuit representation across all four devices, eliminating the confound of different compilers. Writing the study in four vendor SDKs would introduce compiler differences that contaminate the hardware comparison.

(c) Production VQE → Braket, using Hybrid Jobs. Priority queue access is decisive: a 500-iteration VQE submitted as ordinary tasks could take days sitting behind other users. Hybrid Jobs reserve the device. AWS also provides the SLAs, IAM access control, audit logging and S3 data governance that a regulated pharmaceutical company requires.

(d) Pulse-level control on IBM → Qiskit. Braket exposes only the gate layer. Qiskit Pulse gives access to the underlying microwave waveforms — essential for gate calibration, custom pulse shaping and dynamical-decoupling research. Braket is not the wrong tool so much as the wrong layer.

(e) 30-qubit noiseless simulation → Braket SV1. 30 qubits needs 17 GB and substantial CPU. SV1 handles up to 34 qubits on managed parallel hardware at $0.075/minute — perhaps $5 for a substantial study, versus buying or renting a large-memory server. (Alternative: lightning.gpu on a rented EC2 instance, which may be cheaper for very long runs but requires you to manage the instance.)

The summary rule.

\[ \boxed{\ \text{Vendor SDK for \emph{depth} (one platform, deeply); Braket for \emph{breadth} (many platforms, uniformly).}\ } \]

41.8 Practice Problems

  1. Cost of 5000 shots on IonQ as one task? [Ans: $150.30]
  2. Same on Rigetti? [Ans: $2.05]
  3. Write a Braket circuit for a 3-qubit GHZ state.
  4. Which Braket simulator for a 40-qubit shallow circuit? [Ans: TN1]
  5. Why does batching shots into one task matter?
  6. Which device for a fully connected 10-qubit QAOA, and why?
  7. Compute the cost of 100 tasks × 100 shots versus 1 task × 10 000 shots on Rigetti. [Ans: $33.50 vs $3.80]

41.9 Summary

  • Braket is a managed service, not a competing SDK: one AWS account and one API for IonQ (trapped ion, all-to-all), Rigetti and IQM (superconducting), and QuEra (neutral-atom analog).
  • Circuits use a fluent chaining style; native xx/yy/zz Ising gates compile to a single physical operation on trapped-ion hardware.
  • Simulators: LocalSimulator (free, ~25 qubits), SV1 (34 qubits), DM1 (17, noisy), TN1 (50, shallow).
  • Cost model: $0.30 per task plus per-shot fees — $0.03 on IonQ versus $0.00035 on Rigetti (85× cheaper). Always batch shots into one task; unbatched submission is the most common and most expensive mistake.
  • Hybrid Jobs run the classical optimisation loop next to the QPU with priority queueing — essential for variational algorithms.
  • The professional workflow: develop free on a local simulator → study noise on DM1 → explore cheaply on Rigetti → confirm once, at high shot count, on IonQ.
  • Vendor SDK for depth; Braket for breadth.

Next lesson: L42 — Microsoft Q# and the Quantum Development Kit.

Practise now: unit4-platforms-lab.html → Cost Calculator: enter circuit count, shots and device, and see the task and shot fees broken down, with batching savings highlighted.