Flipping a Coin With a Quantum Computer

Anyone with an AWS account can flip a coin using quantum mechanics

Steven Heidel


An ion trap quantum computer.

Amazon recently announced its latest AWS offering: Quantum computing as a service. It’s called Amazon Braket (pronounced “bracket”). Last week it moved from a closed beta to general availability.

Here’s how you can run your first quantum program in just a few minutes.

Step 1: Set Up Your Account

The first thing you need to do is create an AWS account if you don’t have one already. Go to https://aws.amazon.com and follow the instructions.

Next, you’ll need to activate Amazon Braket by going to https://aws.amazon.com/braket/ and clicking “Get Started with Amazon Braket.”

This will walk you through some terms and conditions, which you’ll need to agree with to proceed. You’ll also be prompted to create an S3 bucket for storing the results of quantum programs. You’ll also have to set up access rules for the account. Fortunately, there are default settings filled in for you already. I just left every option alone. Make a note of the name of the S3 bucket for later.

Next, click “notebooks” on the left and create a new notebook instance to run your code. Name it something meaningful and select the “ml.t3.medium” instance type. Keep in mind that this costs money to run. It is included in the AWS free tier, so you may be eligible to run up to 250 hours for free.

There are some other settings for permissions and networking. Again, I just left the defaults.

Step 2: Write Some Code

Click the notebook URL shown on the notebook instance list. The URL will look something like: amazon-braket-[name].notebook.[region].sagemaker.aws

This opens up a Jupyter Notebook environment. Click “New” on the top right then choose conda_braket. (This is the name of the Python virtual environment with all the needed dependencies pre-installed).