From Qubit to Shor’s Algorithm. Experimenting with Quantum Computing at IBM Qiskit Global Summer School 2020

From Qubit To Shor'S Algorithm. Experimenting With Quantum Computing At Ibm Qiskit Global Summer School 2020


It was the summer of 2020; well, monsoon time in the southern part of India. We’re going through uncertain times. What better way to spend time than to learn about uncertainties? Speaking of uncertainties, by chance I managed to apply for the IBM Qiskit Global Summer School (QGSS).

From Qubit To Shor'S Algorithm. Experimenting With Quantum Computing At Ibm Qiskit Global Summer School 2020
Figure 1: I was here
Reference: link

Let me introduce myself – I’m Praveen, currently working as a Machine Learning Engineer in EY. I’ve a Bachelor’s degree in Electrical & Electronics Engineering from University of Kerala. I also hold a Master’s degree in Clinical Psychology from IGNOU. I’m born and brought up in Kerala, a state in the southern part of India.

Once I got to know that I was admitted to QGSS, and that I was also part of the 2000 lab students, I admired my luck! But being a complete newbie to the area of Quantum Mechanics, I felt very sceptical about my participation in the program. It’d be fair to say that I had no idea of what I was stepping into.

I’m glad to share my learning and experiences here, by considering the journey as an experiment in Quantum Mechanics, wherein our aim is to gather knowledge as much as we can, and eventually use a classical apparatus to measure my final state.

The QGSS experimental setup

Experiment: IBM Qiskit Global Summer School 2020
Aim: To reach a higher energy level in Quantum Computing
System: IBM Q & Qiskit
Observer: None (no eavesdropping!) 

A qubit more about me to put things in perspective – I’ve a clear understanding of Quantum Mechanics but if you measure it then you’ll find a ship hung in the sky, in much the same way that bricks don’t.[2]

About Qiskit Global Summer School (QGSS)

This was the first-ever QGSS hosted by IBM and they were thrilled to have us although I was still in the dubious phase to join them on this journey. In mathematical terms,

My state: ket 0 or ground state

\Vert0\Rangle = \Begin{Bmatrix}1\\0\End{Bmatrix}

IBM was already on Cloud 9, fully excited. As if they knew beforehand that the event was going to be a massive success! Sounds suspicious? Could they see the future using a powerful quantum computer? Have they found the answer to the ultimate question? Is it IBM?

IBM’s state: ket 1 or excited state

\Vert1\Rangle = \Begin{Bmatrix}0\\1\End{Bmatrix}

Here’s a peek into what was taught in the summer school.

The lectures were on

  • Qiskit implementation of Deutsch–Jozsa algorithm by Elsa Baumer
  • Shor’s Algorithm, QFT, QPE by Abe Asfaw
  • Quantum Error Correction by James Wootton
  • Superconducting Qubits by Zlatko Minev
    • Quantizing a Harmonic Oscillator
    • Josephson Junctions
  • Quantum Chemistry
    • Going from problem description to Qubit Hamiltonian for Hydrogen and Lithium hydride by Antonio Mezzacapo
    • Solving qubit Hamiltonian for Hydrogen and Lithium hydride using Variational Quantum Eigensolver by Abhinav Kandala 

As you can see, the schedule was really tight – 6 months equivalent topic were compressed into just 2 weeks! I can see yet another application for quantum computing here.


There were multiple stages to the experiment. In stages 1 and 2, we made use of superposition and Shor’s algorithm to find the prime factors of a number. In stage 3, we used Quantum Error Correction to reduce the noise in measurements. Finally, the last stage was to see the action in actual quantum computers.

Stage 1 – Superposition

From day 1, there were 3-hour lectures followed by the distribution of lab assignments. The lecturers did a wonderful job in explaining the concepts crisp and clear.

I was moving in all directions, to and fro, up and down, like an electron in an atom, going through the materials – lectures and lab works! If someone were to observe what I was doing, then I’d have collapsed into either one of these –
–       trying to understand the days’ lectures
–       working on submitting the lab works on time
–       getting acquainted with my fellow mates in QGSS

In language terms, superposition is a compound word. In the quantum mechanical world, superposition is everything – zeroes, ones and both – expressed as a complex linear combination of the individual states, at the same time. What makes QM so powerful is this principle of superposition.

I could say that I became in superposition with QGSS. 

\Frac{1}{\Sqrt{4}}\Left(\Vert00\Rangle + \Vert01\Rangle + \Vert10\Rangle + \Vert11\Rangle\Right)
superposition of all states

with 1/2 as the probability amplitude for observing the corresponding state

Stage 2 – Shor’s algorithm

Shor’s algorithm has a demi-god status in the field of Quantum Computing. Basically, it is this algorithm that poses a threat to certain types of encryptions! Shor’s algorithm can find the prime factors in much less time which classical computers could take years. It takes advantage of the superposition principle; here, all the required multiples of a number which arises at one stage of the algorithm are available in the superposition state. This makes quantum computers far better when it comes to optimization problems.

Short summary of Shor’s algorithm

Problem: find prime factors of “15”

In real scenario, let’s say there’s a message encrypted by “15”; you need to find the prime factors, which are 3 & 5 to decrypt.

1. Get a quantum computer (QC)!
2. Random guess, say for example  9
3. Check if 9 is a factor of 15; stop if the number is, else continue
4. find period ‘p’
– assumption being (9)^(p/2) +- 1 is a better candidate than the initial random guess

Problem statement is then all about finding the period p:-
– 9^p  =  (multiple of 15) + 1

5. Use a QC to create the superposition of
a. the powers of 9: [9, 81, 729, …. ] and
b. the (multiples of 15) + 1: [16, 31, 46, …]
6. the QC then determines the period ‘p’ with which the required results differ from each other

Stage 3 – Quantum Error Correction

One of the topics which I liked in the QGSS is Quantum Error Correction (QEC). As the name suggests, the need for error correction arises from the fact that qubits are not perfect unlike the logical qubits. Each gate becomes slightly wrong as the qubits get poked by (small) external forces! Imagine the scenario where measurements lie sometimes. i.e., measuring a 0 when you’ve 1 or measuring 1 when you’ve 0. In classical analogy, considering a telephone conversation wherein you hear “yes” when the person said “no” at the other end. This is the reason why we need error correction. It’d have been easier had they lied always. 

This calls upon the need for having a greater number of physical qubits to represent a logical qubit. Then we can use some of the error correction codes like repetition code, surface code etc. 

The simplest one being the repetition code! Simply repeat the statement over and over – say “yes” or “no” multiple times so that the message can be confirmed with a good amount of probability. The “yes” or “no” messages are encoded and decoded accordingly. With the chances of misunderstanding reduced to the point where error is inevitable only when the majority of the messages are wrong. A sample success message would consist of multiple “yes’s” and far less number of “no’s”.

From Qubit To Shor'S Algorithm. Experimenting With Quantum Computing At Ibm Qiskit Global Summer School 2020
QEC Probability equation

P is the probability that the person fails to decode the message, and it decreases exponentially with the number of repetitions (d)

Lower case p is the probability that the error or flip happens

n ranges from 0 to half the number of repetitions

Coming to the computation part where errors are introduced whenever we perform an operation. The errors are corrected by repetitively encoding and decoding the input.  

From Qubit To Shor'S Algorithm. Experimenting With Quantum Computing At Ibm Qiskit Global Summer School 2020
Sample representation of QEC in action

Input – 0, Repetition – 4 times, encoding and decoding repetitively, until we get the desired output 0 with reasonable probability.

Let’s see the state –

\Frac{1}{\Sqrt{2}}\Left(\Vert00\Rangle + \Vert01\Rangle\Right)

As you can see, there’s a reduction in the noise!

Stage 4 – Labs

Theory is one thing; physical realization is another. Noise is the bad guy here. But then you’ve Quantum Error Correction which has shown promising results to take quantum computers farther.

When Zlatko Minev started his lecture, no one expected to see the Holy Grail. Inside the case is what looks like a fridge. Inside the fridge is a chandelier. Everything quantum is at the very bottom of the chandelier – in the below picture.

From Qubit To Shor'S Algorithm. Experimenting With Quantum Computing At Ibm Qiskit Global Summer School 2020
IBM’s Holy Grail of Quantum Computing
Reference: link

While the lectures were mind-boggling, it was a refresher to see the actual quantum computers in action. From the fact that the gold-plated cables were used owing to superior conductivity, to the exceptionally low levels of temperatures (15 milli Kelvin) at which the qubits were maintained, it was a peek into the future, wherein I’ll be working on a quantum laptop!

I had signed up for the IBM Quantum Experience platform a week before the start of the summer school. I was not able to grasp the idea behind quantum circuits or how the Jupyter notebook examples worked. It was as if I was trying to decipher an alien language. 

The QGSS turned out to be my “babel fish”. Not only could I understand the Qiskit language, I learned how to swim in the ocean of Quantum Mechanics as well!

One thing that made me stand out was my experience in Python. I could fix the encoding issues, server issues (by simply taking out the problematic one among three) and a plotting related issue. I was no longer in the ground state! It was the time of realization, not measurement. Nothing ever really goes away, it just changes into something else. Something beautiful. 

I’m glad to tell you that me and IBM are now entangled, thanks to QGSS for being my launchpad to higher energy levels!

Let’s conclude the experiment by looking at my final state –

\Frac{1}{\Sqrt{2}}\Left(\Vert00\Rangle + \Vert11\Rangle\Right)

This state is known as the entangled state or the Bell state.

Key takeaways

The real learning and contributions begin now. Below are the key pre-requisites along with the main takeaways from the program.

  • Basics of Probability and Linear algebra
  • Basics of Python and Jupyter notebooks
  • Understanding of Qiskit library, circuits and notebooks
  • Experience with the final project
  • Applying for Qiskit Advocate program
  • Networking with like-minded people

Closing remarks – It’s exciting to hear some of the challenging problems that physicists face in their real life – one of which is to classify themselves into one among spins and oscillators.

There are two kinds of physicists:
– those who believe all of physics is spins
– those who believe all of physics is oscillators

There’s something funny and intriguing about this certainly – but you will only get either the funny part or the intriguing part, unfortunately not both.

I’ll forever be happy to remember 2020 as the year I graduated from QGSS!

The journey is on…!


  1. Heisenberg Principle – You are probably here
  2. Holy Grail 
  3. IBM QGSS 2020 Attendee Guide
  4. IBM QGSS 2020 – Lectures by Abe Asfaw, James Wootton, Zlatko Minev etc.