Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn Quantum Computing with Python and IBM Quantum Experience
Learn Quantum Computing with Python and IBM Quantum Experience

Learn Quantum Computing with Python and IBM Quantum Experience: A hands-on introduction to quantum computing and writing your own quantum programs with Python

By Robert Loredo
€25.99 €17.99
Book Sep 2020 510 pages 1st Edition
eBook
€25.99 €17.99
Print
€32.99
Subscription
€14.99 Monthly
eBook
€25.99 €17.99
Print
€32.99
Subscription
€14.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 28, 2020
Length 510 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838981006
Vendor :
IBM
Category :
Table of content icon View table of contents Preview book icon Preview Book

Learn Quantum Computing with Python and IBM Quantum Experience

Chapter 1: Exploring the IBM Quantum Experience

Quantum computing has been growing in popularity over the past few years, most recently since IBM released the IBM Quantum Experience (IQX) back in May 2016. This release was the first of its kind, hosted on the cloud and providing the world with the opportunity to experiment with a quantum computer for free. The IQX includes a user interface that allows anyone to run experiments on both a simulator and on a real quantum computer.

The goal of this chapter is to first introduce you to the IBM Quantum Experience site, specifically the dashboard, which contains everything you need in order to run experiments. It also allows you to experiment with existing experiments contributed by other developers from around the world, the benefits of which can help you to understand how others are experimenting, and you can perhaps collaborate with them if the experiments correlate with your own ideas.

This chapter will help you understand what actions and information are available in each view. This includes creating an experiment, running experiments on a simulator or real quantum device, information about your profile, available backends, or pending results to experiments. So, let's get started!

The following topics will be covered in this chapter:

  • Navigating the IBM Quantum Experience
  • Getting started with IBM Quantum Experience

Technical requirements

Throughout this book, it is expected that you will have some experience in developing with Python and, although it isn't necessary, some basic knowledge of classical and quantum mechanics would help.

Most of the information will be provided with each chapter, so if you do not have knowledge of classical or quantum mechanics, we will cover what you need to know here.

For those of you that do have knowledge, the information here will serve as a refresher. The Python editor used throughout this book is Jupyter Notebook. You can, of course, use any Python editor of your choice. This may include Watson Studio, PyCharm, Spyder, Visual Studio Code, and so on. Here is the link for the CiA videos: https://bit.ly/35o5M80

Here is the source code used throughout this book: https://github.com/PacktPublishing/Learn-Quantum-Computing-with-Python-and-IBM-Quantum-Experience.

Navigating the IBM Quantum Experience

As mentioned earlier, the dashboard is your high-level view of what you will normally see once you log in to IQX. It aggregates multiple views that you can see, and this helps you to get an idea as to what machines you have access to and what experiments you have pending, running, or completed.

In this section, we will go through the steps to get registered on IQX. Let's do that in the next section.

Registering to the IBM Quantum Experience

In this section, we will get registered and explain what happens in the background once you sign up to IQX for the first time. This will help you understand what features and configurations are prepared and available to you upon registration.

To register to the IBM Quantum Experience, follow these steps:

  1. The first step is to head over to the IBM Quantum Experience site at the following link: https://quantum-computing.ibm.com/
  2. Sign-in to your account from the login screen, as shown in Figure 1.1. Your individual situation will determine how to proceed from there.

    If you already have an account or are already signed in, you can skip this section and move on to the next one.

    If you have not registered, then you can select the login method of your choice from the sign-in screen. As you can see, you can register using various methods, such as with your IBM ID, Google, GitHub, Twitter, LinkedIn, or by email.

    If you do not have any of the account types listed, then you can simply register for an IBMid account and use that to sign in:

    Figure 1.1 – The IBM Quantum Experience sign-in page

    Figure 1.1 – The IBM Quantum Experience sign-in page

  3. Once you select the login method of your choice, you will see the login screen for that method. Simply fill out the information, if it's not already there, and select login.
  4. Once signed in, you will land on the Home page. This is the first page you will see each time you log in to the IBM Quantum Experience site:
Figure 1.2 – The IBM Quantum Experience home page

Figure 1.2 – The IBM Quantum Experience home page

Now that you have registered to the IBM Quantum Experience, let's take a quick tour and delve into some features that make up the IQX home page. Let's start by reviewing the home page, specifically the Personal profile tab. You can access your personal profile via your avatar, located at the top right of the page (as pointed out in Figure 1.2).

Understanding the Personal profile tab

This section explains the profile of the logged-in user. This is helpful if you have multiple accounts and you wish to keep track of them. The provider limits the number of jobs that can be executed or queued on a given device at any one time to a maximum, as specified in the documentation. There are many ways to access all the various quantum devices; those listed in the open group will see all freely available quantum devices, as illustrated along the right side of Figure 1.2. For those who are members of the IBM Q Network, you will have access to the open devices, as well as premium quantum devices such as the 65 qubit quantum computer.

Now that you have completed the sign-up process and successfully logged in, we can start off by taking a tour of the IBM Quantum Experience application. This will be where most of the work within this book will take place, so it will benefit you in understanding where everything is so that you can easily make your way around it while developing your quantum programs.

Getting started with IBM Quantum Experience

This section provides a quick way to launch either Circuit Composer or the notebooks located in the Quantum Lab views, herein simply referred to as Qiskit notebooks, each of which we will cover in detail in Chapter 2, Circuit Composer – Creating a Quantum Circuit, and Chapter 3, Creating Quantum Circuits Using Qiskit Notebooks, respectively, so hang in there. But as with other views, know that you can kick-start either from the main dashboard view or from the left panel. Each button easily provides a quick launch for either of the two circuit generators.

Learning about your backends

This section lists the available backend quantum systems that are provisioned for your use (as shown in Figure 1.3). It not only provides a list of the available backends but also provides details for each, such as the status of each backend. The status includes whether the device is online or in maintenance mode, how many qubits (quantum bits) each device contains, and how many experiments are in the queue to be run on the device. It also contains a color bar graph to indicate queue wait times, as illustrated between ibmq_16_melbourne and ibmq_rome in the following screenshot. Be aware that the quantum devices listed for you may be different from those listed here:

Figure 1.3 – Provisioned backend simulators and devices

Figure 1.3 – Provisioned backend simulators and devices

From the preceding screenshot, you can see that another great feature that IQX has with respect to the backend service is the ability to see the hardware details of each real quantum device. If you hover your mouse over each device listed, you will see an expansion icon appear at the top right of the device information block. If you select a device (for example, ibmq_16_melbourne), you will see the device details view appear, as shown in the following screenshot:

Figure 1.4 – Device details view: The status (left) and configuration and error rates (right)

Figure 1.4 – Device details view: The status (left) and configuration and error rates (right)

From the previous screenshot, you can see that the device details view contains some very relevant information, particularly if you are working on any experiments that have intricate connectivity between qubits or analyzing error mitigation techniques. On the left of the screenshot (Figure 1.4), you can see the basic status information of the device. This is similar to what you see before expanding the device information. In the square on the right, we get into a little more detail with respect to the devices' configuration, connectivity, and error rates.

As described in the shaded bar area, where the error rate range is illustrated by Single-qubit U3 error rate, and CNOT error rate (single qubit and multi-qubit, respectively), qubits are identified as the circles where the number specifies the qubit number in the device. The arrows in between identify how each qubit is connected to the other qubits. The connections are specific to how the multi-qubit operations are specified.

For example, in the 15 qubit configuration in Figure 1.4 (on the right), you can see that qubit number 4 is the source for target qubits 3 and 10 (we will get into what source and target mean later, but for now just assume that actions to the target qubit are triggered by the source qubit). You can also see that qubit 4 is the target qubit of qubit 5. This visual representation is based on information provided by the device configuration, which you can also access programmatically using Qiskit.

Another piece of information you can get here is the error rates. The devices are calibrated at least once a day or so, and each time they are calibrated, they calculate the average error rates for a single gate (u3) and multi-gates (CNOT). The error rates vary per qubit, or qubits for multi-gates, and therefore, the diagram uses a color heat map to identify where the qubit sits on the error rate scale. Each qubit has a different color associated with it. This color makes it possible to visually identify where on the error rate scale that qubit falls. If you are running an experiment on a qubit that requires low error rates, then you can see from this diagram which of these qubits has the lowest error rate when last calibrated.

Below the qubit configuration, you will see a link that also allows you to download the entire configuration information in a spreadsheet. The details there are very specific to each qubit and they provide more information that isn't visible on the qubit configuration diagram.

Finally, at the bottom of the view are the specifics of the device itself, which includes the number of qubits, the date the device went online, and the basis gates available on the device.

You can now close the device configuration diagram to return to the dashboard, where we will next learn about the quantum programs and how to monitor them.

Learning about pending and latest results

The table shown in Figure 1.5 contains the experiments that are pending completion on the backend devices. You can use this view to quickly see whether your experiments have run, and if not, where in the queue your experiment is set to run next.

Under your pending results table is the table where all your latest results are stored. These are the last few experiment results that were run on either the simulator or real devices on the backend. Each device is initially sorted by creation date but can be sorted by either backend or status, if need be.

Important Note

Details regarding job objects will be covered in Chapter 9, Executing Circuits Using Qiskit Aer.

As well as this, the job ID is listed so that you can call back the details from that job at a later time, as seen in the following screenshot:

Figure 1.5 – Pending results and latest results

Figure 1.5 – Pending results and latest results

In this section, you have learned where to find information about your experiments, hardware details about the simulators and the real quantum devices. Next, we will explore your account profile.

Exploring My Account

In this section, you will explore your account details view, where you will find information about your account and what services are available to you. This includes services such as the ability to view the list of backend systems available to you, notification settings, and resetting your password.

To open the account view, follow these steps:

  1. Click on your avatar at the top right of the dashboard (as highlighted in the following screenshot) and select My Account:
    Figure 1.6 – The My Account option on the dashboard

    Figure 1.6 – The My Account option on the dashboard

  2. Once the My Account view is loaded, you will see a page similar to this:
Figure 1.7 – The My Account view

Figure 1.7 – The My Account view

From the preceding screenshot, you can see that on your account page, you will see the following information sections:

  • Account details: This section has your account and contact information that you used to register. It also includes options such as resetting your password, privacy and security information, and the option to delete your account.
  • Qiskit in IBM Quantum Experience: This includes a quick link to launch a Qiskit notebook to run your experiments. We will review the Qiskit notebook later in this book, but for now, just know that you can launch a Qiskit notebook from here as well.
  • Qiskit in local environment: This section allows you to install Qiskit and run experiments from your local machine without the need to connect to IQX via the cloud. This is exceptionally helpful when you wish to run experiments but do not have access to a network. By running experiments from your local machine, this allows you to run simulators that are installed as part of the Qiskit installation. However, keep in mind that in order to run the experiments on a real quantum device, you will need network connectivity to those real devices.

    If you want to run the experiments on a real device from your local machine, then you will need to copy the token (highlighted in Figure 1.7) that was generated for you in the background. You should then assign it to the Qiskit IBMQ provider class. Details of the IBMQ provider class will be discussed in Chapter 9, Executing Circuits Using Qiskit Aer, but for now, this is where you can copy the Application Programming Interface (API) token.

    Also, note that there is an option to regenerate the API token. If you choose to regenerate the token, you will need to delete your old token and save the regenerated one in your local IBMQ provider class. The save account method of the IBMQ provider class will persist the value in your local machine, so you will only have to save it once and then load the account each time you wish to use a real quantum device for your experiment.

    Since this book is written primarily for use on the IBM Quantum Experience site, we will cover running and setting up on your local machine. Just in case you happen to not have network connectivity, you can still run simulated experiments locally.

  • Notification Settings: This section simply allows you to set your notifications and how you prefer to receive information, such as when experiments have completed or other information or surveys that you wish to contribute.
  • Your accounts: This last section toward the bottom of the My Account view is an overview of the accounts that you have and a list of the provisioned systems you have access to. These provisions are selected and assigned as part of the sign-up process. This includes information such as when you first signed up, the project that you are associated with (main is usually the default project), provider information, and the allocated backend systems that you have access to. These allocated backends that you can see are either real devices, such as ibmq_16_melbourne, or simulators, such as ibmq_qasm_simulator, which are running on the IQX cloud. We will discuss the details of the simulators and devices in later chapters.

Now that we are done with our tour of the IBM Quantum Experience layout, we're ready to get to work. In the following chapters, we will delve into each section and progress to writing quantum programs.

Summary

In this chapter, we reviewed the dashboard, which provides plenty of information to help you get a good lay of the land. You now know where to find information regarding your profile, details for each of the devices you have available, the status of each device, as well as the status and results of your experiments.

Knowing where to find this information will help you monitor your experiments and enable you to understand the state of your experiments by reviewing your backend services, monitoring queue times, and viewing your results queues.

You also have the skills to create an experiment using either Circuit Composer or the Qiskit notebooks. In the next chapter, we will learn about Circuit Composer in detail.

Questions

  1. Which view contains your API token?
  2. Which device in your list has the fewest qubits?
  3. How many connections are there in the device with the fewest qubits?
  4. What are the two tools called that are used to generate quantum circuits?
  5. Which view would provide you with the list of basis gates for a selected device?
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Determine the difference between classical computers and quantum computers
  • Understand the quantum computational principles such as superposition and entanglement and how they are leveraged on IBM Quantum Experience systems
  • Run your own quantum experiments and applications by integrating with Qiskit

Description

IBM Quantum Experience is a platform that enables developers to learn the basics of quantum computing by allowing them to run experiments on a quantum computing simulator and a real quantum computer. This book will explain the basic principles of quantum mechanics, the principles involved in quantum computing, and the implementation of quantum algorithms and experiments on IBM's quantum processors. You will start working with simple programs that illustrate quantum computing principles and slowly work your way up to more complex programs and algorithms that leverage quantum computing. As you build on your knowledge, you’ll understand the functionality of IBM Quantum Experience and the various resources it offers. Furthermore, you’ll not only learn the differences between the various quantum computers but also the various simulators available. Later, you’ll explore the basics of quantum computing, quantum volume, and a few basic algorithms, all while optimally using the resources available on IBM Quantum Experience. By the end of this book, you'll learn how to build quantum programs on your own and have gained practical quantum computing skills that you can apply to your business.

What you will learn

Explore quantum computational principles such as superposition and quantum entanglement Become familiar with the contents and layout of the IBM Quantum Experience Understand quantum gates and how they operate on qubits Discover the quantum information science kit and its elements such as Terra and Aer Get to grips with quantum algorithms such as Bell State, Deutsch-Jozsa, Grover’s algorithm, and Shor s algorithm How to create and visualize a quantum circuit

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 28, 2020
Length 510 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838981006
Vendor :
IBM
Category :

Table of Contents

21 Chapters
Preface Chevron down icon Chevron up icon
1. Section 1: Tour of the IBM Quantum Experience (QX) Chevron down icon Chevron up icon
2. Chapter 1: Exploring the IBM Quantum Experience Chevron down icon Chevron up icon
3. Chapter 2: Circuit Composer – Creating a Quantum Circuit Chevron down icon Chevron up icon
4. Chapter 3: Creating Quantum Circuits using Quantum Lab Notebooks Chevron down icon Chevron up icon
5. Section 2: Basics of Quantum Computing Chevron down icon Chevron up icon
6. Chapter 4: Understanding Basic Quantum Computing Principles Chevron down icon Chevron up icon
7. Chapter 5: Understanding the Quantum Bit (Qubit) Chevron down icon Chevron up icon
8. Chapter 6: Understanding Quantum Logic Gates Chevron down icon Chevron up icon
9. Section 3: Algorithms, Noise, and Other Strange Things in Quantum World Chevron down icon Chevron up icon
10. Chapter 7: Introducing Qiskit and its Elements Chevron down icon Chevron up icon
11. Chapter 8: Programming with Qiskit Terra Chevron down icon Chevron up icon
12. Chapter 9: Monitoring and Optimizing Quantum Circuits Chevron down icon Chevron up icon
13. Chapter 10: Executing Circuits Using Qiskit Aer Chevron down icon Chevron up icon
14. Chapter 11: Mitigating Quantum Errors Using Ignis Chevron down icon Chevron up icon
15. Chapter 12: Learning about Qiskit Aqua Chevron down icon Chevron up icon
16. Chapter 13: Understanding Quantum Algorithms Chevron down icon Chevron up icon
17. Chapter 14: Applying Quantum Algorithms Chevron down icon Chevron up icon
18. Assessments Chevron down icon Chevron up icon
19. Other Books You May Enjoy Chevron down icon Chevron up icon
Appendix A: Resources Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.