Amazon Braket: Get started with quantum computing

Amazon’s quantum computing service is currently good for learning about quantum computing and developing NISQ-regime quantum algorithms, but stay tuned

Amazon Braket: Get started with quantum computing / Pete Linforth (CC BY-SA 3.0)
At a Glance

While IBM, Microsoft, and Google have made major commitments and investments in quantum computing, Amazon has, until recently, been fairly quiet about the field. That changed with the introduction of Amazon Braket.

Amazon still isn’t trying to build its own quantum computers, but with Braket it is making other companies’ quantum computers available to cloud users via AWS. Braket currently supports three quantum computing services, from D-Wave, IonQ, and Rigetti.

[ Also on InfoWorld: A hands-on look at the Microsoft Quantum Development Kit and IBM Q and Qiskit quantum computing SDKs ]

D-Wave makes superconducting quantum annealers, which are usually programmed using D-Wave Ocean software, although there is also an annealing module in the Braket SDK. IonQ makes trapped ion quantum processors, and Rigetti makes superconducting quantum processors. In Braket, you can program both IonQ and Rigetti processors using the Braket Python SDK circuits module. The same code also runs on local and hosted quantum simulators.

The name Braket is kind of an in-joke for physicists. Bra-ket notation is the Dirac formulation of quantum mechanics, which is an easier way of expressing Schrödinger’s equation than partial differential equations. In Dirac notation, a bra <f| is a row vector, and a ket |f> is a column vector. Writing a bra next to a ket implies matrix multiplication.

Amazon Braket and the Braket Python SDK compete with IBM Q and Qiskit, Azure Quantum and Microsoft Q#, and Google Cirq. IBM already has its own quantum computers and simulators available to the public online. Microsoft’s simulator is generally available, but its quantum offerings are currently in limited preview for early adopters, including access to quantum computers from Honeywell, IonQ, and Quantum Circuits, and optimization solutions from 1QBit. Microsoft hasn’t announced when its own topological superconducting quantum computers will become available, nor has Google announced when it will make its quantum computers or Sycamore chips available to the public.

Amazon Braket overview

Amazon Braket is a fully managed service that helps you get started with quantum computing. It has three modules, Build, Test, and Run. The Build module centers around managed Jupyter notebooks pre-configured with sample algorithms, resources, and developer tools, including the Amazon Braket SDK. The Test module provides access to managed, high-performance, quantum circuit simulators. The Run module provides secure, on-demand access to different types of quantum computers (QPUs): gate-based quantum computers from IonQ and Rigetti, and a quantum annealer from D-Wave.

Tasks may not run immediately on the QPU. The QPUs only execute tasks during execution windows.

Amazon Braket SDK API

The Braket Python SDK defines all of the operations you need to build, test, and run quantum circuits and annealers. It is organized into five packages: braket.annealing,, braket.circuits, braket.devices, and braket.tasks.

The braket.annealing package allows you to define two kinds of binary quadratic models (BQMs): Ising (a mathematical model of ferromagnetism in statistical mechanics, using magnetic dipole moments of atomic “spins”) and QUBO (Quadratic Unconstrained Binary Optimization) problems, to solve on a quantum annealer, such as a D-Wave unit. The braket.circuits package lets you define quantum circuits based on a set of gates, to solve on gate-based quantum computers, such as ones from IonQ and Rigetti.

The other three packages control the running of your problem. The package allows you to select quantum devices, load problems into tasks, and connect tasks to AWS sessions. The braket.devices package lets you run tasks on quantum devices and simulators. The braket.tasks package lets you manage, track, cancel, and get results from quantum tasks.

Amazon Braket circuits and gates

Circuits in a quantum computer such as the ones from IonQ or Rigetti (or IBM or Honeywell, for that matter) are built from a standard set of gates (see figure below), although not every QPU may have an implementation of every kind of gate. In the Braket SDK you define a circuit using the Circuit() method from the braket.circuits package, qualified by the gates in the circuit and their parameters.

For example, this Braket code (from Amazon’s Deep_dive_into_the_anatomy_of_quantum_circuits example) defines a circuit that initializes four qubits to a Hadamard (equal probability of 1 and 0) state, then entangles qubit 2 with qubit 0 and qubit 3 with qubit 1 using Controlled Not operations.

# define circuit with 4 qubits
my_circuit = Circuit().h(range(4)).cnot(control=0, target=2).cnot(control=1, target=3)

The Braket SDK seems to have a nearly full set of quantum logic gates, as shown in this enumeration of the Gate class. I don’t see a Deutsch gate listed, but as far as I know it hasn’t yet been implemented on a real QPU.

# print all available gates currently available within SDK
gate_set = [attr for attr in dir(Gate) if attr[0] in string.ascii_uppercase]
['CCNot', 'CNot', 'CPhaseShift', 'CPhaseShift00', 'CPhaseShift01', 'CPhaseShift10', 'CSwap', 'CY', 'CZ', 'H', 'I', 'ISwap', 'PSwap', 'PhaseShift', 'Rx', 'Ry', 'Rz', 'S', 'Si', 'Swap', 'T', 'Ti', 'Unitary', 'V', 'Vi', 'X', 'XX', 'XY', 'Y', 'YY', 'Z', 'ZZ']
Common quantum logic gates by name, circuit form(s) and matrices. Rxtreme (CC BY-SA 4.0)

D-Wave Ocean

Ocean is the native Python-based software stack for D-Wave quantum annealers. For use via Braket, you can combine the Ocean software with the Amazon Braket Ocean plug-in, which translates between Ocean and Braket formats.

Quantum annealers function quite differently than gate-based QPUs. Essentially, you formulate your problem as a binary quadratic model (BQM) that has a global minimum at the solution you want to find. Then you use the annealer to sample the function many times (since the annealer isn’t perfect) to find the minimum. You can create the BQM for a given problem mathematically or generate the BQM using Ocean software. The code that follows, from Amazon’s D-Wave_Anatomy example, uses the Braket Ocean plug-in to solve a BQM on a D-Wave device.

# set parameters
num_reads = 1000
# define BQM
bqm = dimod.BinaryQuadraticModel(linear, quadratic, offset, vartype)
# run BQM: solve with D-Wave device
sampler = BraketDWaveSampler(s3_folder,'arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6')
sampler = EmbeddingComposite(sampler)
sampleset = sampler.sample(bqm, num_reads=num_reads)
# aggregate solution:
sampleset = sampleset.aggregate()
amazon braket 02 D-Wave Systems

To use a quantum annealer, you need to formulate your problem as a quadratic objective function, or BQM (binary quadratic model). Then you sample the solution space to find the global minimum of the BQM.

Enabling Amazon Braket and using notebooks

Before you can use Braket, you need to enable it in your AWS account.

amazon braket 03 IDG

The Anatomy of Quantum Circuits example, one of the simpler tutorials, demonstrates running circuits on a simulator and controlling tasks.

Then you need to create a notebook instance. Notebooks use Amazon SageMaker (read my review).

amazon braket 04 IDG

Creating a Braket notebook instance is a matter of naming the notebook, picking an instance type, and either creating or reusing an IAM role with the correct permissions. Using an encryption key and VPC are both optional.

When you open a notebook, you can enter new code or use one of Amazon’s examples.

amazon braket 05 IDG

The Braket examples supplied by Amazon are divided into four categories: simple circuits, advanced circuits, hybrid, and annealing.

You need to check the status of the QPU devices, as they aren’t always available.

amazon braket 06 IDG

The Devices screen shows you the current status of each quantum processing unit. An hour after this screenshot, the D-Wave annealer was online and available, but the Rigetti QPU had a two-hour queue.

While you can run them yourself, the Braket example notebooks have been saved with results from a previous run.

amazon braket 07 IDG

The Anatomy of Quantum Circuits example, one of the simpler Braket tutorials, demonstrates running circuits on a simulator and controlling tasks.

There are examples for both gate-based QPUs, as above, and quantum annealers, as below.

amazon braket 08 IDG

The D-Wave anatomy example demonstrates how to perform quantum annealing, both with a simulator and with a D-Wave device. Block 20 in the example uses the D-Wave device, takes 1,000 samples, and performs an aggregate operation to simplify the output.

Learn today, useful tomorrow

Amazon Braket is a reasonable way to get your feet wet with quantum computers and simulators. Since we’re still in the NISQ (Noisy Intermediate Scale Quantum) phase of quantum computing, you can’t really expect useful results from Braket. We’ll need more qubits, less noise, and longer coherence times, all of which are being actively researched.

Braket’s current QPU offerings are modest. The 2048-qubit D-Wave annealer is mostly useful for optimization problems; it’s about half the size of D-Wave’s latest-generation annealer. The 11-qubit IonQ QPU, which has relatively long coherence times, is way too small to implement the algorithms for quantum computers that should exhibit useful quantum supremacy, such as Grover’s algorithm for finding the inverse of a function and Shor’s algorithm for finding the prime factors of an integer. The 30-qubit Rigetti Aspen-8 is also too small.

Braket is not free, although it is relatively cheap to use. By comparison, IBM Q is completely free, although the publicly available IBM QPUs are very small: they range from a 1 qubit QPU in Armonk to a 15-qubit QPU in Melbourne. IBM also offers a paid premium QPU service.

[ Also on InfoWorld: Review: Amazon SageMaker plays catch-up ]

IBM also rates its QPUs by their quantum volume (QV), a measure that combines the number of qubits with their error rate and coherence time. There are five-qubit IBM QPUs ranging from QV8 to QV64: higher is better. Honeywell has also announced achieving QV64.

What Braket is currently good for is learning about quantum computing and developing NISQ-regime quantum algorithms. Stay tuned, though. As QPUs improve and are plugged into AWS, Braket will become more and more useful.

Cost: Managed notebooks: $0.04 to $34.27 per instance-hour; quantum simulator: $4.50 per hour; quantum computers: $0.30 per task plus $0.00019 to $0.01 per shot (repetition of a circuit). 

Platform: AWS; installing the Braket SDK locally requires Python 3.7.2 or greater, and Git.

At a Glance
  • Amazon Braket is a good and affordable way to get your feet wet with quantum computers and simulators. As QPUs improve and are plugged into AWS, Braket will become more and more useful.


    • Gives you access to two gate-based QPUs and a quantum annealer
    • Supplies a quantum simulator
    • Easy to switch devices
    • Inexpensive


    • Not free, unlike IBM Q
    • Devices aren’t yet powerful enough to be useful
    • Quantum devices are remote from AWS data centers, not co-located

Copyright © 2020 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!