Overview of Amazon Bracket with a Practical Example

Overview of Amazon Bracket with a Practical Example

In this article, I am going to give an overview of Amazon Bracket based on my exploration. I will give a basic introduction, security aspects, costs, product offerings and finally I will show a simple circuit run in one of the simulators. The documentation on Amazon Bracket is available publicly and you can get more details as required from the documentation.

So, let's begin with a fun fact. What does “Bra-ket” signify? In the “bra-ket” notation or Direc notation, the “Ket” - represented by a vertical bar & right angular bracket (|>) - denotes a vector in a complex vector space and this physically represents a quantum state. The “Bra” - represented by the left angular bracket and a vertical bar (<|) - represents a linear map of each element of a vector in a complex plane. Bra-Ket notations are used heavily in quantum mechanics as a large part of it is based on linear algebra. 

General Overview of AWS Braket service:

Now, after the fun fact, let me describe in a simplistic term what Amazon Braket offering is. Amazon Braket service gives a platform to build, test, and run quantum algorithms. Below is the AWS elaboration of what bracket service is (sourced from AWS documents):

No alt text provided for this image

The build part is done through a set of jupyter notebooks (SagerMaker). When you register for the bracket service, you can spin up jupyter notebook instances for your own. There are multiple Notebook instance types available to choose from and you can pick the one which meets your requirements. The process to create the notebook is very simple. Select the instance name, instance type, and custom the volume size to your need. Below is the reference screenshot to create a notebook instance:

No alt text provided for this image

The next step is selecting the Role, access & encryption. Here is the screenshot:

No alt text provided for this image

Finally, if you want to make any changes for the network or if you want to put any tags, go ahead and make the required selections. 

No alt text provided for this image

After all the fields are populated, just click on “Create Notebook Instance” and your notebook will spin up in a few minutes. To access the notebook, click the URL. 

No alt text provided for this image

When you log into the instance, you will see multiple examples, which I found quite useful and give good study material. 

No alt text provided for this image

You can go to any of the examples and try to run. When you run the notebook, it shows it is running at the backend and you get charged based on the time spent. Below is an example of how it looks when you run a basic simulator. 

No alt text provided for this image

You can see the notebook from the running pen, and don’t forget to shut it down when you are done with your simulation. 

Now, after the Notebook and build part, let's explore what is available for Devices. The device section is where you get the list of available Quantum Processing Units and simulators. You can use any of the available providers to run & test your algorithm. The pricing of the QPU depends on the vendor and the number of Tasks & shots. For example the D-Wave — Advantage_system1.1 cost is $0.30 / task + $0.00019 / shot. Below is the device (QPU) listing from the service. 

No alt text provided for this image

In addition to the QPUs there are simulators available to run and test your algorithms. Below are the offerings available.

No alt text provided for this image

Cost of Braket Service:

After the offering, let's look at the cost part. There are two cost components for using the QPU, a per-shot cost and a per-task cost. A shot is defined as a single execution of the algorithm in the QPU. while a task is a sequence of repeated shots.

No alt text provided for this image

Refer to AWS Service page for more details on costs. 

Security Controls on Braket Components:

Now, as we have spoken about the service & cost, let’s look into the security aspect and how we can keep our notebooks, algorithms & results secured. 

  • Braket uses S3 to store the results for the run, you can use an existing bucket (need to have a specific naming convention) or create one while enabling Braket service. You can put the standard security controls for S3, like bucket & IAM policies, restriction to private IPs etc. You can also integrate with cloud watch for monitoring etc. 
  • Data transfer from Braket to 3rd party systems are encrypted in transit, account information is not transmitted to the 3rd party providers, only the content required to execute the task is transmitted. 
  • Bracket communication can happen over the private links from within the VPC, so no Internet transmission is required.
  • For the Notebook instances

- We can use specific IAM roles to control access

- We can control the access for the user (root or general user)

- We can encrypt the notebook data. 

- We can use VPC, subnet & define the private access for the notebook. 

  • Standard security controls that are applicable to SageMaker can be applied to the configuration. 
  • Amazon Braket is integrated with CloudWatch, CloudTrail, EventBridge, IAM to enable the monitoring of workloads, generate notifications when tasks are completed, and manage access controls and permissions. 

A Sample Run to Demonstrate the Service:

Finally, I will conclude the article by showing a very simple circuit run in one of the simulators available as part of the service. I have picked Amazon Web Services — SV1 to run my task. I will take an example of 12 Qbits, and will draw a circuit with some basic gates (Hadamard, S, T, CNOT) and run the circuit in the local simulator and SV1 simulator. 

The 1st step is to open a notebook and import the general modules and AWS modules. Now those who are familiar with Qiskit, will find a difference here as we will be importing the AWS-specific modules. 

No alt text provided for this image

Next, I will define my bucket and folder to store the result. 

No alt text provided for this image

Followed by that, comes my circuit definition, as I mentioned, this is a very simple circuit with H gate at q0, t & s gate at q1 and then cnot gates for other qn. 

No alt text provided for this image

Here comes the circuit print with 12 Qbits.

No alt text provided for this image

Now, I will run this circuit in a local simulator with 500 shots and will count the bitstrings. I will use the device = LocalSimulator(). 

No alt text provided for this image

In the final part, I will use an SV1 simulator with 500 shots. Just to make sure, running in an SV1 simulator has a cost @ $0.075 / minute. 

If you want to run this in a real quantum computer, the cost is based on the number of tasks + number of shots. so , if you run 1 task and define 500 shots for a D-Wave 2000Q system, it is going to cost you @ $0.30 / task + $0.00019 / shot: hence ( $0.30 + 500 * $0.00019) = $0.395. 

Below is the distribution of the 500 shots in SV1. 

No alt text provided for this image

The results get stored in the S3 bucket, below is a screenshot of how it looks.

No alt text provided for this image

As a concluding remark, I would say, I found Amazon Braket very interesting, this gives you a chance to run your algorithm across multiple devices and simulators. You can choose what you need. The service is easily configurable and you can secure your work with the controls as I mentioned earlier. 

To view or add a comment, sign in

Others also viewed

Explore content categories