Shilpa Mahato

Jul 5, 2021

6 min read

Quantum Computing

My IBM Quantum Challenge’21 Experience - Part 1

My journey into Quantum and solving the first two exercises of IQC’21.

Buckle up as I take you through my first-ever Quantum Challenge experience.😄

IBM Quantum Challenge was the most exciting bit of the summer of 2021. Somewhat out of boredom I started exploring Quantum Computing in the middle of the pandemic. I did hear a word or two about it from my seniors but didn’t indulge in research to find out more. I was introduced to Quantum Information in the 3rd semester; this is when I started exploring Quantum Computing and its different aspects. Soon, I came across Qiskit and later the community. Although I was too late to apply for the Qiskit Global Summer School 2020, I did take part in an alternative Quantum Computing course that was sponsored by IBM Quantum. I have been hooked to Quantum Computing since then.

It’s also the five-year anniversary of IBM Quantum putting a quantum computer on the Cloud …

Around this time, I read the article about IBM Quantum Challenge’21 and the topics it was going to cover. I was very excited to read about the five important milestones in the history of Quantum Computing on which the challenge was going to be based.

Soon after, I connected to the slack channel of the Qiskit community. Since I hadn’t participated in similar challenges before, I was skeptical whether it’s a good idea to take part in this challenge. I didn’t have much hope initially, but the motivation I received from the community encouraged me to take part in the challenge. The challenge began on 20th May. I went through the Qiskit documentation a day before just to prepare myself enough. The event was 8 days long so I decided to take it slow, one exercise a day. Since I had plenty of time to solve, I thought I will cover all the background materials mentioned in the reference before attempting any exercise. Although, later I realized it wasn’t necessary, but I am glad that I learned more rather than just solving the exercises. I used to solve in the evening after roughly going through the materials because the slack channel used to be most active during this time. The Qiskit Slack community had been very supportive throughout the challenge. What I assumed to be a competition at the beginning turned out to be a fun team game where we were helping each other out, giving the right hints so that everyone could finish the challenge.

All the exercises were very informative and beginner-friendly, consisting of relevant theory and tutorials to help solve the exercises. A few of them had a cost associated with them evaluated as 𝐶𝑜𝑠𝑡=10𝑁(𝐶𝑁𝑂𝑇)+𝑁(𝑜𝑡ℎ𝑒𝑟) and the idea was to solve an exercise with minimum cost.

1. Toffoli Gate:

As the name suggests, the first exercise was based on the implementation of the Toffoli gate using some basic quantum gates. Toffoli gate is a universal quantum gate also known as the controlled-controlled not (CCNOT) gate and can be used to implement classical AND/NAND gate. This exercise seemed more difficult but interesting at the same time than the following three. It walked me through the concept of different quantum logic gates, rotations caused by these gates in the Bloch Sphere, and decomposing some gates into an allowed set of basic gates. The problem statement was to implement a Toffoli gate using CX, RZ, SX, and X gates only.

I took the help of IBM Quantum Composer to try out combinations of gates with the help of the truth table I prepared. It took me my entire evening to figure out the correct sequence of gates but this paper helped me get to the correct circuit. I still had to decompose the T and T^† gates into the allowed set of gates. And voila! I finished the first exercise with a cost of 79! Now the successive Rz rotations could be combined if not interrupted by a CNOT gate, so I used this to further reduce the number of gates and get a cost of 72.

Solving the first exercise hyped me up and I was determined to solve the second exercise and get the Foundation badge.😤

2. Shor’s Algorithm:

The second exercise was based on using Shor’s algorithm to factor the number 35. This exercise was easy for someone who had thoroughly understood the exercise. Although I did have a brief introduction to Shor’s Algorithm, this exercise was solvable even by someone who hadn’t studied Shor’s algorithm in detail. It was based on doing phase estimation on a circuit that implements 13y mod 35. In Shor’s algorithm, we do phase estimation of “U” which behaves as 𝑈|𝑦⟩=|𝑎𝑦mod𝑁⟩. The exercise consisted of 4 sub exercises of which only the 4th one was graded i.e. it was required to be completed for the completion of the entire exercise. In the first one, we had to create a circuit for U as follows:

I noticed that there is a bit flip for target_0 and bit flip for target_1 when target_0 was one. The later implementation required the use of the CNOT(Controlled Not) Gate and bit flip is achieved using X Gate. To invoke control, I designed the circuit the following way:

And I obtained this circuit for U. With a similar approach I constructed the circuit for U² and U⁴.

Now the final exercise was to use a controlled gate based on U, U², and U⁴ to combine into a circuit for implementing the quantum part of Shor’s Algorithm. Thus, the task was to create the circuit as 𝐶𝑈𝒸₀t𝐶𝑈²𝒸₁t𝐶𝑈⁴𝒸₂t. With the help of the previous 3 sub exercises, I could successfully construct the main circuit required to complete the exercise with a cost of only 6!!

The remaining part of the exercise used this circuit to successfully factorize 35.

And that is how I finished the first two exercises of the IBM Quantum Challenge 2021 and was overjoyed to have secured the Foundational Badge already❗️❗️

Stay tuned for Part 2 where I take you through my Intermediate Badge experience, and finally the struggle of getting the Advanced Badge, and getting into the 3CNOT club!!🏆