How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Reading Time: 9 minutes

In our previous blog, How do you use Amazon Braket to create quantum algorithms and test them on quantum circuit simulators? We have discussed how Quantum applications are transforming how we live, work, and play. We have discussed Quantum computing and a fully managed quantum computing service Amazon Braket, its features, benefits, how it works, pricing, etc. Refer to the following image for a quick recap:

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

The Amazon Braket is a cost-effective solution to experiment with quantum computers and simulators. Amazon Braket provides a development environment for you to explore and build quantum algorithms, test them on quantum circuit simulators, and run them on different quantum hardware technologies. Amazon Braket is not free, although it is relatively cheap to use. In this blog, we will see how we can enable the Amazon Braket service and then create a notebook instance for us to begin with the implementation of a use case. We will also explore the various devices and simulators, looking at their topologies that can be integrated with the notebook instance.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Let’s do Hands -On

In this hands-on, we will see how we can make use of Amazon Braket to create a notebook instance to begin with Quantum Computing. We will first enable Amazon Braket service so that we can create a notebook instance. We will see how you can design and build your own quantum algorithms from scratch or choose from a set of pre-built algorithms. Moving further, we will explore the various devices and simulators that can be integrated with Amazon Braket. We will also explore the various example use cases offered by Amazon Braket and look at an implementation for one of its use cases. Exploring the console we will also see the various topologies for the various devices and simulators.

To implement this, we will do the following:

  • Login to your AWS console and navigate to the AWS console.
  • Search for the Amazon Braket service and navigate to its dashboard.
  • Select your preferred region (based on the availability of service in that region).
  • Configure the setup and enable the Amazon Braket service.
  • Navigate to the notebook instances and create a new notebook instance.
  • Let the notebook instance get inservice for us to navigate to the notebook.
  • Click on the notebook instance and navigate to the jupyter dashboard.
  • Navigate to the SageMaker examples.
  • Explore the various examples and you can easily preview each of those to have a look at the various use cases.
  • To use and execute a particular example, click on Use and you will be navigated to the notebook execution dashboard for that use case.
  • Select a kernel based on the use case you choose.
  • Test out the use case executing the parts of it.
  • Explore the various devices and various simulators that can be integrated.

Login to your AWS console and navigate to the dashboard.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Search for the Amazon Braket service and click on it to open the dashboard.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Now notice that the service is currently available only in certain regions. Make sure you select one of the regions from the mentioned ones.

Once done, you will be navigated to the dashboard to enable Amazon Braket.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Click on Specify new to specify a new name for your bucket as per your choice.

Enter a name you would want to create your S3 bucket with and below that you will see the name of the bucket that will be created.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

If you expand the Permissions section, you’ll see that the following permission will be added for the service.

Now, scroll down and click on Enable Amazon Braket.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Now, search for the S3 service and click on it to navigate to the service.

Verify that the S3 bucket is created in your S3 console with the name you entered.

You will be navigated to the list of devices wherein you can see the various devices that can be integrated and tested out with Amazon Braket.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Scroll down and you will get to see the various simulators offered for integration with Amazon Braket.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Click on Notebooks in the left pane to create a new notebook instance.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

You will then be navigated to the notebook instance creation page. Enter a name for your notebook instance. Select the notebook instance type as ml.t3.medium.

Expand additional settings and select Volume size as 5 GB. Make the other configurations as shown in the image below.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Disable the root access for your notebook instance.

Expand the Network section and select a VPC if needed. Expand tags and enter a key-value pair tag if needed. Click on create notebook instance.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

You will see a new notebook instance created. The current status for the same will be pending and will take some time for it to be configured.

In some time, you will see the status as inservice and now you can access your Notebook instance.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Click on the instance to open the details dashboard and navigate to the instance. Click on Open Jupyter.

You will then be navigated to the Jupyter console. Over here you can create a new python file.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Click on SageMaker Examples, to begin with some of the examples. You can now explore various examples and try them out.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

When you click preview, you will be navigated to a page as shown in the image below. We will first explore the demo on the electricity dataset and then implement one of the examples. Over here you can see that the various import statements are provided for us to begin with.

In the next part, it shows how to import the dataset and upload it to S3.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Over here we can train and test splits for our execution.

The below code base provided by Amazon Braket lets us train our model on the dataset by fetching it from the S3 bucket.

After that, we create an endpoint and a predictor that would in turn help us with our prediction model.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

The below codebase will then perform predictions based on the dataset we provide and plot the prediction results in the form of a graph.

Moving further the below codebase will then prepare a dataset for a special day to create a time series for the dataset.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Finally, once the prediction is successfully done, we can then delete the endpoints using the below codebase.

Now, if you navigate back to the Jupyter console and when you scroll down, you will see the various examples available.

When you expand any of them, you will notice the various sub-sections for the use case that you can try out.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

To execute one of the use cases, just click on Use and a modal will appear to enter in a name for the python file. Once done, click on create copy.

You will then be navigated to the console with edit mode on for the execution. We will be executing the below example as shown in the image.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Execute the first part of the codebase either by clicking on Run on the toolbar or by pressing Alt+Enter on each of the sections.

On success, you will see that it checks for the execution role if it exists and then connects to the S3 bucket using boto3 making sure the requirements are satisfied.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Proceeding further, we provide an image name and send a tag name. You can manually add an image in the S3 bucket that’s created while enabling the Amazon Braket service and then mention the name of the image over here.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Executing the below command, you will then prepare your image input for the training model.

Similarly, execute the next codebase section to prepare the image data for training.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

The process of pulling the fs layers for the input of training the model then begins.

After successful completion, you will see the status as shown in the image below.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Amazon Braket also provides us with some instructions on what the next step exactly does and how we can proceed.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Amazon Braket provides a training script that we can make use of to train our model using the data fetched. On success, you can then proceed with executing the further sections of the codebase.

Coming back to the console, you will get to see that Amazon Braket provides us with various Devices as shown in the image below that can be easily integrated and executed based on our need with the notebook instance.

Click on one of the Devices to view the details for the same.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

If you scroll down, you will get to see the topology for the device and some codebase of its calibration respectively. You can view the same for any of the Simulators as well that are provided by the Amazon Braket service.

How to configure an Amazon Braket notebook instance to begin with Quantum Computing?

Conclusion

In this blog, we saw how we can make use of Amazon Braket to create a notebook instance to begin with Quantum Computing by enabling Amazon Braket service so that we can create a notebook instance. We explored the various devices and simulators that can be integrated with Amazon Braket. We even explored the various example use cases offered by Amazon Braket and looked at an implementation for one of its use cases. We will discuss more use cases of Amazon Braket in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies. 

Meanwhile …

Keep Exploring -> Keep Learning -> Keep Mastering

This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.

Back To Top