Mastering Quantum Programming

How to program a quantum computer using Qiskit

Estimated read time: 1:20

    Learn to use AI like a Pro

    Get the latest AI workflows to boost your productivity and business performance, delivered weekly by expert consultants. Enjoy step-by-step guides, weekly Q&A sessions, and full access to our AI workflow archive.

    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo
    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo

    Summary

    In this video by IBM Technology, the basics of programming a quantum computer using Qiskit are explored. The presenter begins by revisiting the concept of qubits, which differ from classical bits by allowing superposition and entanglement. The focus then shifts to using Qiskit, a Python-based quantum SDK, to write a simple quantum program. This involves creating quantum and classical registers, applying gates like the Hadamard and control-not gates, and performing measurements. The video concludes by highlighting Qiskit's higher-level algorithm packages, particularly in machine learning, which allow classical applications to benefit from quantum computations.

      Highlights

      • Learn how a qubit differs from a classical bit and what superposition is! 🎢
      • Explore the role of entanglement in quantum computing! 🔗
      • Discover Qiskit, a Python-based quantum SDK, and its simplicity! 💼
      • Write a simple quantum program with two qubits using Qiskit! ✍️
      • Understand the application of Hadamard and control-not gates! 🔧
      • Realize the significance of quantum measurements! 🧮
      • Qiskit offers resources for blending quantum and classical computing! 🎯

      Key Takeaways

      • Qubits can exist in superposition, unlike classical bits! 🌟
      • Entanglement allows qubits to become correlated! 🤝
      • Qiskit is a powerful, user-friendly quantum SDK based on Python! 🐍
      • Apply Hadamard and control-not gates to manipulate qubits! 🚪
      • Measure qubits to retrieve classical data! 📏
      • Qiskit makes integrating quantum algorithms with classical applications easy! ⚡

      Overview

      Quantum computers use qubits, which differ from classical bits by allowing states of superposition and entanglement. Superposition allows a qubit to be both 0 and 1 at the same time, while entanglement causes qubits to become interlinked, sharing a unified quantum state. These properties are foundational to the power of quantum computing.

        In this video, viewers are introduced to Qiskit, a leading quantum software development kit (SDK) based on Python. With a focus on accessibility, the guide walks through the process of writing a simple quantum program. This involves creating quantum and classical registers, applying quantum logic gates such as the Hadamard and control-not gates, and measuring the qubits to obtain results.

          Beyond basic programming, Qiskit provides tools for integrating quantum algorithms with classical computing. This includes packages for machine learning, enabling enhanced performance of classical algorithms. The video invites viewers to engage further by trying out quantum programming and exploring Qiskit's robust offerings.

            Chapters

            • 00:00 - 00:30: Introduction to Quantum Computing This chapter serves as an introduction to quantum computing for developers. It starts with a quick recap of the fundamental concept of qubits, which differ from classical bits. Unlike classical bits, which are either 0s or 1s, qubits can be in a state of superposition, meaning they can be both 0 and 1 simultaneously, or any linear combination of these states. This characteristic is what makes quantum computing distinct and powerful. The chapter sets the stage for understanding how to write code for quantum computers.
            • 00:30 - 01:00: Quantum Qubits and Gates The chapter titled 'Quantum Qubits and Gates' delves into the concept of entangling multiple qubits, creating strongly correlated states. It explains how to manipulate these states using a series of gates, akin to classical logic gates. The ultimate goal is to measure the qubits to obtain results, and the text briefly hints at the implementation of these concepts in coding.
            • 01:00 - 01:30: Introducing Qiskit In this chapter, we introduce Qiskit, the most widely used quantum software development kit. Qiskit is based on Python, making it accessible even for beginners. We discuss a simple program using Qiskit, involving operations on two qubits where one is put into superposition and entangled with another.
            • 01:30 - 02:00: Building a Quantum Circuit The chapter titled 'Building a Quantum Circuit' discusses the process of setting up a quantum circuit using Qiskit. It involves importing necessary components and proceeding with configuration and implementation using quantum gates and measurements.
            • 02:00 - 02:30: Quantum and Classical Registers The chapter introduces the concept of using two types of registers in quantum computing: quantum registers and classical registers. Quantum registers are utilized for performing quantum computations, with each register corresponding to one qubit. Classical registers, on the other hand, are used to store the results of these computations after they are measured. The need for classical registers arises because, despite the quantum nature of the physical world, much of what is observed and utilized in the classical world remains classical.
            • 02:30 - 03:00: Applying Quantum Gates In 'Applying Quantum Gates', the chapter explores the process of transitioning between quantum and classical information using classical registers. The focus is on applying quantum gates, specifically examining the Hadamard gate applied to qubit 0. This gate creates a superposition of states 0 and 1, making the qubit equally likely to be measured as either 0 or 1.
            • 03:00 - 04:00: Understanding the Control Not Gate The chapter introduces the concept of the control not gate, abbreviated as 'cx'. It is described as a conditional two-qubit gate, consisting of a control qubit and a target qubit.
            • 04:00 - 04:30: Measuring Qubit States The chapter "Measuring Qubit States" explains the concept of entanglement and how measurements are taken in quantum computing. It begins with the explanation of the control not gate, describing its function of flipping the target qubit's state based on the control qubit's state when it is 1. This process creates a correlation between at least two qubits, which leads to their entanglement. To finalize the operations and obtain the results, the measure all function is utilized to perform measurements on the system.
            • 04:30 - 05:30: Running the Quantum Program The chapter titled 'Running the Quantum Program' explains the execution of a simple quantum program developed using Qiskit. When the program is run on an ideal quantum computer, it outputs '00' or '11' about 50% of the time each. The transcript discusses how the qubits, like the first qubit, exist in superposition which leads to such probabilistic outcomes. Outcomes '01' or '10' are not possible with this program configuration.
            • 05:30 - 06:00: Qiskit's High-Level Algorithms This chapter explains the concept of entanglement in quantum computing, using Qiskit to illustrate how qubits get affected simultaneously when entangled. It details the creation of a quantum circuit, akin to classical assembly language, which enables efficient direct manipulation of qubits.
            • 06:00 - 06:30: Conclusion and CTA The chapter explores alternative higher-level algorithms in Qiskit for those less interested in low-level circuit manipulation. It highlights the machine learning package, which includes several pre-built classes. A specific use case mentioned is the quantum kernel class, which can be employed to train and test data, followed by utilizing the trained quantum model.

            How to program a quantum computer using Qiskit Transcription

            • 00:00 - 00:30 In my previous video, I talked about what quantum  computing is and what makes it special. But as   a developer, I'm sure you want to know how to  actually write a piece of code that would run   on a common computer. But before we dive into  that, let's just do a little bit of a quick   recap. Instead of the classical bits of 0s and 1s,  quantum computers use qubits. A qubit can be a 0,   a 1, or any linear combination of the two.  And that is what we called a superposition.
            • 00:30 - 01:00 We can also entangle multiple qubits. So their states become strongly correlated. In order   to change the states of qubits, we apply  a series of gates, similar to the classical   logic gates. And in the end, we want to measure  these qubits so we can get the results.   So how do we take all these concepts into  code? And the answer is simple. We use a
            • 01:00 - 01:30 quantum software development kit. In  this video, we will be using Qiskit.   Which is the most widely used quantum SDK today.   Qiskit is based on Python, which is fairly simple  to learn, even if you've never used it before.   So let's write a simple program in his Qiskit. In this program, we will use two qubits.   We will put one into superposition, entangle it with the other, and then
            • 01:30 - 02:00 do a measurement of both of them. And  of course, all that is done using gates.   So let's start by importing quantum circuit from  Qiskit. We then can create a quantum circuit
            • 02:00 - 02:30 with two quantum registers  and two classical registers.   The quantum registers are used for quantum   computation. One for each qubit. And the classical  registers are used to store the measured results.   We need a classical registers because  even though the physical world is quantum,   the majority of the classical  world is still classical.
            • 02:30 - 03:00 And the classical registers allow us to bring  quantum information back into the classical world.   So the next thing we want to do is  apply some gates. And in this program,   we're going to apply two gates. The  first one is the Hadamard gate  on qubit 0. The Hadamard gate puts  the qubit into a superposition between 0   and 1. That means it now has an equal  chance of being measured a 0 or 1.
            • 03:00 - 03:30 The next gate we need is the control  not gate, or "cx" for short.   The control not gate is a conditional two qubits gate. It has a control qubit and the target qubit.
            • 03:30 - 04:00 Without superposition, the control  not gate is fairly simple to understand.   That is, it is as if the state of the control qubit is  1, then you flip the state of the target qubit.   And that's why it's called control not.   And because the states of least two  qubits are now strongly correlated,   we now say they are entangled. So the  last thing we want to do is actually do   measurements so we can get the outputs. And we  do this by calling the measure all function.
            • 04:00 - 04:30 And there you have it. We just wrote a simple  quantum program using Qiskit. Now, if you take   this program and run it a bunch of times on an  ideal quantum computer, you'll find out that   there's a 50% chance of the outputs being 00 and  50% chance of it being 11. But you would never   be a 01 or 10. The 50/50 of the first  qubit comes from the superposition. And while
            • 04:30 - 05:00 we didn't explicitly change the state of the  second qubit, it got changed anyway because   it is entangled with the first qubit.  So it changes with the first qubit.   So in this program, we created a quantum  circuit which operates at the same level   as classical assembly language and allows you  to efficiently manipulate the qubits directly.
            • 05:00 - 05:30 However, if you're not fond of  playing with low level circuits,   Qiskit also offers a number of higher  level algorithms. For example, Qiskit has   a package focusing on machine learning that has  a number of pre-built classes. You can take a   quantum kernel class, use it to train and test  data. You can then take this trained quantum
            • 05:30 - 06:00 kernel and pass it into a classical algorithm  such as the support vector classification   from scikit-learn. Then you can then  accelerate your classical application.   Thanks for watching. If you have any questions,  please leave them in the comments below.   Also, please remember to Like this  video and Subscribe to our channel   so we can continue to bring you  content that matters to you.