Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®
  • Table Of Contents Toc
  • Feedback & Rating feedback
Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®

Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®

By : Hassi Norlen
5 (6)
close
close
Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®

Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®

5 (6)
By: Hassi Norlen

Overview of this book

IBM Quantum Experience® is a leading platform for programming quantum computers and implementing quantum solutions directly on the cloud. This book will help you get up to speed with programming quantum computers and provide solutions to the most common problems and challenges. You’ll start with a high-level overview of IBM Quantum Experience® and Qiskit®, where you will perform the installation while writing some basic quantum programs. This introduction puts less emphasis on the theoretical framework and more emphasis on recent developments such as Shor’s algorithm and Grover’s algorithm. Next, you’ll delve into Qiskit®, a quantum information science toolkit, and its constituent packages such as Terra, Aer, Ignis, and Aqua. You’ll cover these packages in detail, exploring their benefits and use cases. Later, you’ll discover various quantum gates that Qiskit® offers and even deconstruct a quantum program with their help, before going on to compare Noisy Intermediate-Scale Quantum (NISQ) and Universal Fault-Tolerant quantum computing using simulators and actual hardware. Finally, you’ll explore quantum algorithms and understand how they differ from classical algorithms, along with learning how to use pre-packaged algorithms in Qiskit® Aqua. By the end of this quantum computing book, you’ll be able to build and execute your own quantum programs using IBM Quantum Experience® and Qiskit® with Python.
Table of Contents (12 chapters)
close
close

Installing your API key and accessing your provider

Now that you have installed Qiskit®, you can immediately start creating your quantum programs and run these on local simulators. If, however, at some point, you want to run your quantum code on actual IBM Quantum® hardware, you must install your own unique API key locally.

API keys on IBM Quantum Experience®

If you are running your Qiskit® programs in the IBM Quantum Experience® notebook environment, your API key is automatically registered.

Getting ready

Before you can install your API key, you must first have an IBM Quantum Experience® account. If you have not yet created one, go back and do it (see the Creating your IBM Quantum Experience® account section).

How to do it...

Let's take a look at how to install the API key locally:

  1. Log in to IBM Quantum Experience® at https://quantum-computing.ibm.com/login.
  2. On the IBM Quantum Experience® dashboard, find your user icon in the upper-right corner, click it, and select My account.
  3. On the account page, find the Qiskit in local environment section, and click Copy token.
  4. You can now paste your token in a temporary location or keep it in the clipboard.
  5. On your local machine, access your Qiskit® environment. We have done this one, but here's a repeat of the process if you are using Anaconda.
  6. Activate your virtual environment:
    $ conda activate environment_name
  7. Open Python:
    $(environment_name) … $  python3

    Verify that the Python header displays and that you are running the correct version of Python:

    Python 3.7.6 (default, Jan  8 2020, 13:42:34) 
    [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
  8. Get the required IBMQ class:
    >>> from qiskit import IBMQ		
  9. Install your API token locally:
    >>> IBMQ.save_account('MY_API_TOKEN')

    Here, instead of MY_API_TOKEN, paste in the API token that you just copied from IBM Quantum Experience®: Keep the single quotes as they are required for the command.

  10. Load your account.

    Now that the token is in place, let's verify that all is in order and that your account has the correct privileges:

    >>> IBMQ.load_account()

    This should display the following output:

    <AccountProvider for IBMQ(hub='ibm-q', group='open', project='main')>

    This is the provider information for your account, with hub, group, and project.

How it works...

The main class that you import for this exercise is IBMQ, which is a toolbox for working with the quantum hardware and software that is provided by IBM in the cloud.

In this chapter, we used save.account() to store your account locally. As we go forward, in the recipes where we will access the IBM Quantum® machines, we will use the IBMQ.load_account() and IBMQ.get_provider() classes in your quantum programs to make sure that you have the correct access.

Updating your API key

If for some reason, you need to create a new API token on IBM Quantum Experience® and update your locally saved token, you can use the following command:

>>> IBMQ.save_account('NEW_API_TOKEN', overwrite=True)

There's more…

In the code that follows in the recipes in this cookbook, we will set a provider variable to hold the provider information for your account by using the following command:

>>> provider = IBMQ.get_provider()

We can then use the provider information when selecting the IBM Quantum® computer, or backend, to run your quantum programs on. In the following example, we select a quantum computer that is called IBM Q 5 Yorktown (ibmqx2) as our backend. The internal reference for this machine is ibmqx2:

>>> backend = provider.get_backend('ibmqx2')
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Quantum Computing in Practice with Qiskit® and IBM Quantum Experience®
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon