Learning Quantum Computing
Tags: beginners, programming, quantumcomputing, qiskit
Published: 2024-02-20 22:19:44

## Overview
Quantum computing technology is poised to revolutionize the way we solve complex problems beyond the grasp of traditional computers.  The technology grows every day as computers become larger and quantum algorithms more sophisticated. Quantum computers will profoundly influence Artificial Intelligence, cryptography, and optimizations and aid scientific discovery such as predicting how a protein will fold.

Recently I began a journey to learn the basics of quantum computing.  Along the way, I evaluated many educational resources.  I want to share my findings so far. 

Learning quantum computing is a challenge in part because it is different from current, traditional computing.  No matter how big or small, today's computing devices all operate on electrical circuits.  Quantum computers at their core do not.  They exploit the principles of quantum physics such as superposition and entanglement to provide much more efficient computations.  Quantum computers will not replace today's computers but complement them with their ability to solve complex problems relatively quickly.

In this article, I outline the main areas one may study to get started designing quantum algorithms along with resources containing information I found useful.  No single source of information is exhaustive.  Moreover, different resources offer varied perspectives.  The different angles complement one another and fortunately, rarely contradict.
<br/>

## Areas of Study
I broke down this article into the following areas of study for the beginner:
 
- Overview of quantum physics
- Necessary Math
- Explanation of qubits and gates
- Programming languages and libraries
- Running on simulators and quantum hardware

I will cover more advanced topics such as algorithms, machine learning, and quantum cryptography in later articles.  I found it essential to become comfortable with these concepts before I paused to write an article.
<br/>

### Overview of quantum physics
The word 'quantum' has grown in popularity.  It is used as an adjective for many ideas and products. Of course, not everything on the market has an association to the physics.  Quantum computing has certainly earned the privilege to use the word as the computational model is based on quantum physics.

I came into my study of quantum computing with a layman's understanding of the physics.  I have read many popular books on the subject and am intrigued by the philosophical implications.  I have a science background insofar as I have an engineering degree.  So I felt comfortable with the concepts.

Many physical concepts in quantum physics have no everyday counterpart to help explain their behavior.  They make no sense on the surface yet they predict the behavior of the natural world brilliantly. Most resources I digested give a brief overview of superposition and entanglement but assume you are comfortable moving ahead.

I want to single out one particular resource that dedicates much time to introducing the physics.  Udemy offers a course entitled [QC101 Quantum Computing & Intro to Quantum Machine Learning] (https://www.udemy.com/course/qc101-introduction-to-quantum-computing-quantum-physics-for-beginners/) that gently introduces superposition and quantum measurements using photon polarization.  They even encourage the reader to purchase inexpensive equipment as an aid to observing the strangeness of quantum physics firsthand.  It's a great introduction to prepare you without getting into the weeds.  The video course was one of the first sources I used to learn quantum computing and I will mention it again later.

Wait though, do you need to understand these physical concepts to do quantum computing?  I believe the answer is a definite yes.  Even if the concepts defy common sense, they need to be accepted by the student as they drive to the very heart of understanding quantum computing.
<br/>

### Necessary math
It is impossible to do anything useful in quantum computing without having the mathematical background for support.  Luckily, there are many resources out there to teach you the required concepts.  As you move deeper into quantum computing more advanced math is necessary.  

This might sound dreadful for many readers.  But there is no way around it.  However, I believe anybody who had an aptitude for math in high school can do well with a little patience.  Before starting, I hadn't done any math since college and most of the required math for quantum computing was new to me.  With exposure to the same ideas from different resources, the importance of the concepts gels.  I also find the math beautiful.  

The essential math requirements to start are linear algebra, Boolean algebra, probability, and complex numbers.  All of these areas intersect at quantum computing.  Emphasize linear algebra.  It goes far beyond anything learned in high school.

Just as the resources I digested varied on the depth of quantum physics's basics, they also greatly vary on what they assume you already know about the math.  Consequently, some resources were more useful to me at the very beginning.  Then I started to become comfortable with other resources that picked up the pace.  Therefore, I will introduce sources based on points on the learning curve.

The aforementioned Udemy course [QC101 Quantum Computing & Intro to Quantum Machine Learning] (https://www.udemy.com/course/qc101-introduction-to-quantum-computing-quantum-physics-for-beginners/) should be near the beginning for people learning the required math.  The author patiently and gently introduces all the essential requirements listed above.  Take good notes as the information grows over time.  The points learned here will be reinforced by other sources.

I found a wonderful book called [Essential Mathematics for Quantum Computing: A beginner's guide to just the math you need without needless complexities] (https://www.amazon.com/Essential-Mathematics-Quantum-Computing-complexities/dp/1801073147/) by Leonard Spencer Woody III.  It leans in a little deeper.  Among the subjects are: vector spaces, linear independence and transformations, linear basis, orthonormality, matrices, complex numbers, Eigenvectors and Eigenvalues, types of operators (Hermitian/Unitary among others), Bra-ket notation, and matrix decomposition.  Explaining all these concepts in a book is daunting but the author manages it well.  I understood most of it but had to reread many sections to let it sink in.

From there, other resources I used assumed a bit of prior knowledge.  Armed with knowledge from the previous resources, these reinforced what I already learned and led me even deeper.  IBM is a great resource for everything quantum computing.  They provide a comprehensive educational track. I want to point out their introductory course [Basics of quantum information] (https://learning.quantum.ibm.com/) that presents quantum computing concepts with a heavy emphasis on math. The math is more challenging than other resources but worth every second.  The instructor punctuates concepts with interesting mathematical proofs.  Again, it assumes some prior math knowledge but you should have it by this point.

Personally, the math required for quantum computing is the most challenging aspect of learning.  I still struggle with some concepts.  I believe they will eventually come to me over time.  I find it helpful that many resources of learning tend to repeat many of the same concepts.  
<br/>

### Explanation of qubits and gates
The basic unit of information in common (classical) computing is the bit.  In quantum computing, qubits hold information.   Gates manipulate bits in classical computing to produce desired outcomes.  Gates (in gate-based quantum computers) are also used in quantum computing to manipulate qubits. However, they are vastly different.  The most common type of quantum computers are gate-based thus almost all sources of information relate to that paradigm.

At the least, most resources I encountered and studied explain the basics of quantum gates.  Again, resources vary in depth of explanation.  Some are more suitable for beginners than others.  I found an impressive introduction to qubits and gates in the LinkedIn Learning course [Understanding Quantum Computing] (https://www.linkedin.com/learning/quantum-computing-fundamentals/learn-quantum-computing).  The instructors seem to anticipate any difficulties users might have in understanding the concepts.  The Bloch Sphere is a powerful tool to understand the state of a qubit.  But it can be difficult to explain.  The authors take a novel approach to teaching the Bloch Sphere by using decorated beach balls.  They proceed to use the balls to introduce how each gate affects a qubit.  It is very powerful and worth beyond the price of the platform.  

I experienced some very artful and nuanced ways of explaining quantum gates.  For instance, check out the website [Quantum Country] (https://quantum.country/), a must-have resource for all beginners.  The website contains a series of articles, the first being 'Quantum computing for the very curious'.  The article gradually builds up the reader's knowledge of gates by presenting them within the context of related quantum concepts.  The articles are extremely well-written and employ a learning technique called 'spaced-repetition' to embed concepts in the reader's mind.

A successful quantum developer knows how to use quantum gates to build up 'circuits'.  Similar to classical computing, these circuits run algorithms to obtain desired results.  Resources for learning algorithm design are beyond the scope of this article, however, I will cover them in the future.  I still have more to learn!    
<br/>

### Programming languages and libraries
In this article up to now, my audience (probably mostly software professionals) has learned subjects in which they may not be too familiar.  Let's take a moment to talk about something we all love, programming.

How do mere mortals instruct quantum computers what to do?  After all, we know in essence they do not use electrical circuits for computations.  Therefore, can we use traditional programming languages?  The answer is yes.  Quantum circuits can be coded in a variety of popular languages and platforms.

The code we write requires transpilation to an assembly language understood by quantum computers.  A popular open standard assembly language understood by many quantum platforms is OpenQASM.  Fortunately, established libraries will transpile for you. 

Among the popular higher-level languages are Python and Q#.  Python users can choose between a few libraries but the most popular is [Qiskit] (https://www.ibm.com/quantum/qiskit) from IBM.  Most sources I reviewed provide code examples using Qiskit. Another option for Python is [Cirq] (https://quantumai.google/cirq) from Google.  For those who want to develop against the Azure Quantum Development Kit, 
 [Q#] (https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk) will be the language of choice.  A couple sources I encountered provide introductory tutelage in Q#, the often mentioned [QC101 Quantum Computing & Intro to Quantum Machine Learning] (https://www.udemy.com/course/qc101-introduction-to-quantum-computing-quantum-physics-for-beginners/) and a Pluralsight course [Quantum Computing: Getting Started with Q#] (https://app.pluralsight.com/library/courses/quantum-computing-getting-started-q-sharp/)

Amazon Braket is a service in the Amazon Web Services cloud allowing access to a variety of quantum vendors.  We will talk about Braket later.  For now, I want to mention the service has its own Python library [Amazon Braket Python SDK] (https://docs.aws.amazon.com/braket/latest/developerguide/api-and-sdk-reference.html).  The beauty of this library is that it will transpile to the necessary assembly languages required by the devices Braket supports.  AWS maintains a library to convert Qiskit to the Amazon Braket Python SDK.

Up to now, I have used Qiskit for creating quantum circuits (I did dabble in the Amazon Braket Python SDK, too).  Most educational sources use Qiskit so it has been a natural choice.  Another incredibly useful tool for me is Jupyter Notebooks.  They allow Python users to create inline visualizations of quantum circuits, Bloch Spheres, histograms, and statevectors.   
<br/>

### Running on simulators and quantum hardware
The prospect of executing on actual quantum hardware helped spur me to keep learning.  When I started my studies, I believed renting time on an actual device would only be possible for researchers or people with money to burn.  It turns out, anybody can execute quantum circuits on real hardware for no cost or little cost.

However, quality tends to correlate with price.  Qubits are highly sensitive to external disturbance, therefore, all executions deal with noise that shows up in results.  More expensive quantum processing often has more sophisticated noise-reducing technology.

Furthermore, if one needs to develop a probability distribution they will need to repeat the circuit over and over (the increase of 'shots').  This also contributes to processing costs.

Libraries and platforms provide quantum simulators to test circuits before execution on actual physical devices.  For learning, this is perfect as initial experimentation usually involves a low number of qubits.  If you are using many qubits, say 50, a simulator will not help as such a circuit will be too compute intensive.

I perform most of my live executions on IBM quantum computers.  They provide a generous amount of free processing time (10 minutes per month) on a subset of their fleet of hardware.  Again, great for learning.  Go to the [IBM Quantum Platform] (https://quantum.ibm.com/) to sign up.  The documentation will show you how to run your circuit. In my experience, most submitted jobs will run within an hour.  As I already mentioned, IBM also provides educational resources in the form of video courses.  All of this is tough to beat.

Earlier I mentioned Amazon Braket as a service allowing access to a variety of quantum computers. The list of available vendors and devices changes periodically.  This makes it a great way to experiment with different architectures.  Whether or not you use Braket, I encourage readers to pick up [Quantum Computing Experimentation with Amazon Braket: Explore Amazon Braket quantum computing to solve combinatorial optimization problems] (https://www.amazon.com/Quantum-Computing-Experimentation-Amazon-Braket/dp/1800565267/) by Alex Khan.  While the examples are specific to Braket, the author touches on the general types of quantum computers such as gate-based, annealing-based, and neutral atom-based.  He provides a chapter exclusively on quantum annealing.  Most valuable to me are the nuggets of wisdom for dealing with the idiosyncracies of individual devices.  It is good general information.  I will continue to use this book in my further studies as it is rich in information.

Running circuits on real quantum hardware is thrilling even if the circuits are only learning examples.  So far, I have picked valuable information that can only be earned by actually doing.  As time passes, devices are getting bigger (more qubits) and more reliable (less noise).  Hopefully, it will lead to more economical processing.
<br/>

## Conclusion
I hope this article provides direction to those eager to learn quantum computing.  Subsequent articles will document my journey.  Each day, the material continues to become more challenging.  My achievements will be harder earned.  In the big picture, I am a novice and that's perfect for now.