Quantum Computing With Amazon Braket

Photo by Maks Key on Unsplash

A bit of theory first

Bra-ket notation established by Paul Dirac
Amazon Braket is named after the bra-ket notation [4], which is a notation used to denote states of quantum mechanical systems. The English theoretical physicist, Paul Dirac [5], introduced this notation to describe the state of quantum systems. The Bra-ket notation is also known as the Dirac notation.

Bloch sphere — source: https://en.wikipedia.org/wiki/Bloch_sphere

The building blocks of the classical and quantum computer world

Like traditional logic gates, quantum gates are the fundamental building blocks of a quantum computer. In a classical computer, gates are implementing binary operations on binary inputs — i.e., the classical AND-Gate generates an output-bit 1 if both input bits are also 1. Classic logic gates are AND, OR, NOT, NOR, NAND, XOR, XNOR, BUFFER. For our first little quantum program, we will only need the Hadamard- and the controlled-Not Gate. If you want to understand the quantum gates in detail, please have a look at this Wikipedia Page.

Quantum logic gates

  • Hadamard-Gate (H)
  • Identity-Gate (IGate)
  • controlled-Not Gate (cNot)
  • Unitary-Gate
  • Toffoli-Gate
  • Pauli-Gates (X, Y, Z)
  • S- and T-Gate
  • Rotation-Gate
  • Swap-Gate

Quantum Simulators vs. Quantum Processing Units (QPU)

To start experimenting with quantum computing, Amazon Braket supports you either with a simulated quantum environment or with real quantum computers called Quantum processing units (QPU). To get your hands on and also to reduce your costs check out the simulators first.

Amazon Braket — The quantum computing service from Amazon

Using Quantum Simulators first

To prototype, validate, and debug your quantum algorithm Amazon Braket provides a suite of quantum simulators. You can choose four different simulators depending on your use cases and the number of simulated qubits you need. To learn more about quantum simulators, look at the blog Simulating quantum circuits with Amazon Braket [9].

  • SV1- a general-purpose State Vector Simulator
  • DM1- Density Matrix Simulator for simulating quantum circuits under the influence of noise
  • TN1- a high-performance Tensor Network Simulator

The real quantum hardware — AWS Quantum Processing Units

For running your algorithms on a real QPU, Amazon Braket currently provides five devices from the following providers:

  • D-Wave
  • IonQ
  • Rigetti

Getting started — build your first quantum circuit gate

Nearly every programming tutorial covers a Hello-World example [11]. A Hello-World in the quantum world is probably slightly different, but the so-called Bell state [10] is perhaps a good candidate for your first quantum program. Follow the next steps to write your first quantum circuit code.

  • Sign in to the AWS Management Console.
  • Currently, Amazon Braket is only available within the U.S. Regions US East — N. Virginia, US -West — N. California, and US-West — Oregon. Choose your preferred one.
  • Select the Amazon Braket Service.
  • Specify the data storage settings where Braket will be writing your algorithm results to. You can either use an existing S3 Bucket or create a new one. Further, you have to accept the Terms & conditions that the quantum computing hardware can be operated by third-party providers, and your data can be handled outside AWS facilities!
Specify where Amazon Braket should store the results of your algorithm runs.
Without accepting the terms of service, there is no quantum computing in the cloud.
Choose the ARN of one of the available Quantum Processing Units …
… or an ARN from the managed quantum simulator to run your program on.
  • To continue with our first implementation of a quantum circuit, we chose the option to use a managed notebook and a managed simulator to run it on.
  • Amazon Braket notebooks are fully managed Jupyter notebooks based on Amazon Sagemaker [7]. You’re paying the chosen SageMaker instance by usage. To keep costs low, remember to turn them off as soon as you do not need them anymore.
Specify the details of the managed Jupyter notebook — remember to turn it off again when not needed anymore.

Build your first quantum circuit — the Bell state —the Hello-World program of the quantum universe

This is the quantum circuit we want to build.
Counter({'11': 503, '00': 497})
# Import the AwsDevice module instead of using the LocalSimulator
from braket.aws import AwsDevice
# Create a Simulator Device for the managed Simulator SV1
device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
# This S3 bucket gets used by the Simulator to store the result
s3_output_folder = ("amazon-braket-Your-Bucket-Name", "folder-name")
# run Bell state circuit 1000 times and request the result
task = device.run(bell, shots=1000)
# print the result
  • arn:aws:braket:::device/quantum-simulator/amazon/sv1
  • arn:aws:braket:::device/quantum-simulator/amazon/tn
  • arn:aws:braket:::device/quantum-simulator/amazon/dm1


So what does all this rocket science cost if you want to experiment with Amazon Braket? Like all the other AWS services, you pay by usage, and it differs if you're going to run your algorithms on a simulator or a real quantum computer.


Quantum computing, and particularly putting quantum computing in the cloud as a service for everybody, has a high potential for changing and potentially disrupting certain areas. Probably not tomorrow or the day after, but maybe the day after that. Quantum computers will not replace their classical counterparts but complement each another — like a GPU complements a CPU. Having the ability to easily access a QPU not only for scientists and start programming these machines (even if it is an entirely new world also for experienced (classical) software engineers) will have a profound impact. The more people start programming and using these machines, the more ideas and innovations will be influencing this area.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Frank Haubenschild

Frank Haubenschild


Dad, Software Engineer, Photographer, Reef- & Bee-Keeper, Founder, Drone Pilot — 🤓 💻 📷 🐝 🐠 💡👨‍✈️