/Video1-Qubit-Rotation

Video 1: Qubit Rotation Tutorial in PennyLane

Primary LanguagePython

Video 1: Qubit Rotation Tutorial

YouTube Video Tutorials

In this repository, we will go through the PennyLane tutorial on qubit rotations. We will talk a little about quantum gates (which are just matrices operating on vectors) and how to interpret quantum circuit diagrams as linear algebra operations.

Prerequisites and Dependencies

Programming Experience

You will not need any programing experience. The vast majority of the coding that you will need to do will be explained in the tutorials. You will be able to get more comfortable with coding in Python as we go. So don't worry if you are not a professional programmer, it is not really needed. If you are really into coding and you're already familiar with Python, then you are a step ahead! There is a stripped down version of the Python script that you can run if you like, without all of the frills of the notebook environment and without the tutorial info included in the PennyLane version. All you need to do now is learn linear algebra, tensor products, quantum computing, and machine learning!

Anaconda and Jupyter

To run the tutorial, we will need Jupyter Notebooks. You can get Jupyter by downloading the latest version of Anaconda. You can also run Jupyter Lab right in your browser without having to downlaod anything. Most of our tutorials will run in Jupyter Lab. If you prefer to run Python scripts rather than the interactive environments provided by Jupyter Lab, we will provide Python Scripts as well. We will use terminal some, but not much, but feel free to convert everything over to those environments if you prefer.

Math

We have included a PDF document showing how to convert quantum circuit diagrams to linear algebra.

For example, in the PennyLane tutorial, the following circuit diagram:

circuit_diagram_pltutorial

can be interpreted as matrix operators, the first operator being:

matrix_operator_pltutorial

The PDF document includes the Pauli operators (also called the Pauli gates), the Hadamard gate, and the CNOT gate. There are three circuits. The first two only involve a single qubit and should be very easy for people who already know the basics of linear algebra. If you are not familiar with linear algebra, it is a prerequisite, so it is highly recommended that you go to Khan Academy and go through their linear algebra course. This should be enough linear algebra to get you through the tutorials. You may also want to quickly review the basics of complex numbers if you are a little rusty on complex conjugates and other basics. If you are looking for a slighltly more advanced introduction to linear algebra you can check out the Gilbert Strang MIT Lectures. You might also check out the Linear Algebra and Machine Learning Lectures by Gilbert Strang as well if you want to obtain some background on machine learning. This is not strictly necessary but it will give more background on machine learning for later tutorials and more practice with linear algebra.

The third circuit in the PDF document we have provided as practice for converting quantum circuit diagrams to linear algebra involves a CNOT gate on two qubits which means you will need to use a tensor product. If you are unfamiliar with tensor products, we will be using them often so you can get used to them as you go along, treat them as a black-box that the code takes care of, or you can go learn about tensor products in the context of quantum computing in this video:

Alt text

If you are feeling adventurous, check out the challenge problems. Correct solutions will be featured on the YouTube channel!

Gate Operations

Quantum logic gates are just unitary matrix operators that operate on one or several qubits. For example, the Hadamard gate puts a qubit into a superposition of the 0 and 1 state:

superposition

Hadamard

Operating on the qubit with other unitary operators (gates) can move it to some position on the Bloch sphere:

Bloch sphere state

More complicated operators may operate on several qubits at a time, each of which might be in a superposition. In this tutorial we focus on a single qubit to keep things simple, but more complicated operations on tensor producst will be needed soon, so be sure to think about the third circuit diagram given in the Circuit Diagrams to Linear Algebra Document. If you are curious and familiar with LaTeX, the library used to create the circuit diagrams in this document is the TikZ library quantikz.

Applications

From this tutorial, you will understand some of the most common quantum gates. We will focus primarily on the following gates:

  • The Pauli X, Y, and Z gates
  • The Hadamard gate
  • The CNOT gate

There are many other gates and these will not be difficult to understand once you have a grasp of the gates we cover:

Quantum Logic Gates

You will also learn how to convert quantum circuit diagrams to linear algebra. This will help you understand how to use circuit composers such as those found in the IBM Quantum Experience

IBM Circuit Composer

Other places you will see circuit diagrams are in Strawberry Fields

Strawberry Fields Circuit Composer

as well as Google Cirq

Google Cirq

Practically every quantum computing programming language, paper, and book involves circuit diagrams, so understanding what circuit diagrams are doing and being able to translate the circuit diagrams into linear algebra is key to being proficient at quantum computing and quantum machine learning. If you want to be able to understand scientific articles or if you want to do any programming with quantum computers you will need to understand this at some point.