qubits

Preparing for the “IBM Certified Associate Developer - Quantum Computation using Qiskit” Exam: My Process Log & Suggestions

SECTION:
THE QISKIT TEXTBOOK - 09.08.22

This textbook seems to be the place to start for studying for the exam. According to these slides from IBM, you’re meant to study Chapter 1, Chapter 2, and part of Chapter 3. I’m also going to read the sections leading up to those chapters so I’m not missing any context. It’ll be good for me to refresh my memory on some of the fundamentals, since I’ve spent time away while working on math.

It took me a minute, but I realized there are two versions of the textbook: the original, and the new beta. I checked out the new beta, and one new thing it seems to have is a “Python Scratchpad” for testing your code. I’ll stick with the original for now, but may switch it up later.

Suggestions and key remarks are underlined.

“WHAT IS QUANTUM”

This is the first part of the book (before Chapter 1) and it dives into amplitudes and probabilities. This section was fine, but I found myself wanting to go back and read some of my old blog posts to remember more context and get some clarity. I found this post particularly helpful as a refresher (thank you past self for making these posts!) I also wanted a more thorough refresh of interference, so I used another Qiskit resource here, and then I went to Brilliant.org, where they have a free section on interference that has several animations, interactive components, and quiz questions.

”0. PREREQUISITES”

The book wants you to pip install some stuff…for a variety of reasons, I don’t want to right now, so I’m going to skip this and see if I can do all this in IBM Quantum, which is IBM’s cloud-based quantum service.

 

The next section goes over some Python basics, which I skimmed. There’s a section on lists vs tuples which I appreciated, I think it’s an easy distinction to forget since lists are so much more common.

That was basically it for the intro sections! On to Chapter 1.

“1. QUANTUM STATES AND QUBITS”

“1.1 Introduction”

The introduction page has a diagram of a circuit as well as a Bloch sphere, without having introduced a lot of components of those images, which has me looking back at my post here called “Getting Familiar With Quantum Gates (Without the Math)”. That post is starting to help my brain process their circuit diagram (still left with some questions but I’ll assume they get to it later).

It seems like they also recommend getting up to speed on linear algebra before going much further, or suggest that you should expect to pause to learn it as you go. They say “This chapter will be most effective for readers who are already familiar with vectors and matrices. Those who aren't familiar will likely be fine too..” This doesn’t seem particularly reassuring to me personally, based on the pace the textbook has gone at so far (I have been fine, but I’m not sure that true beginners would be).

Also, they point to the appendix of the textbook which has a Linear Algebra section, but from skimming it over, it also seems to move quickly (for example, the appendix section introduces the formal definition of a vector space in paragraph 7…the textbook “Quantum Computing: An Applied Approach” by Jack Hidary takes 63 pages to move us from vectors to vector spaces). I’ll be talking more about this book throughout this log, and I’ll abbreviate it to QCAAA.

I’ll wait until I’ve gone through all the relevant sections of the textbook before making my recommendation for how to cover the necessary linear algebra.

09.09.22

“1.2 The Atoms of Computation”

This seems like the first section where you’ll really be running some code. If you click that button I was hopeful about earlier, it takes you to the Jupyter notebook version of the textbook inside IBM Quantum. Turns out, you can run the code samples in there, or you can run them right in the regular textbook on qiskit.org. I’m going to go for option 3, and just make my own new notebook in IBM Quantum. I prefer to type out the code samples instead of just running them, and I feel like I’ll get a better understanding of the IBM Quantum environment by doing it this way, plus then at the end I’ll have files with only the code (and not all the textbook text) included.

This Medium article suggests that you should know “how to install Qiskit”, and then links to this page which tells you that you need to download Python, Anaconda, and Qiskit. I’m not sure how they would test your ability to install this stuff locally on the exam, and I’m not sure why they would even want to given that we can just use IBM Quantum, so I’m going to skip this part for now. Instead, I’m going to follow my own Pluralsight guide about getting started with IBM Quantum.

This is the view I get when I create a new notebook. I’ve called this file TheAtomsOfComputation.ipynb and put it in a folder called ibm-cert-prep. Everything inside the file was already there, I haven’t added anything yet. All this quantum stuff comes preloaded when you create a new notebook because we’re in the Quantum Lab. One thing you’ll see is numpy, which the textbook talks about earlier in the Python basics section.

This is actually more than what this section of the textbook asks for, so I’m going to start by removing some stuff and just being mindful of what packages I’m leaving/using and how they’re getting loaded in. I also don’t know if I’ll need to do the load_account() thing, which you can learn more about here, so I’ll comment that out for now.

One thing worth noting is they do a great job explaining binary computation, and the interactive answer-checker is helpful too. They also show a classical circuit diagram, but say you don’t need to know much about them. In case you’re curious though, you can read more about them in my post on classical binary computation and gates.

09.12.22

I’m now at the part where we actually start to build our own half-adder with qubits, and at this point I would actually recommend checking out that blog post I just brought up in the paragraph above. Even knowing how a half-adder works, I found I needed to look at my old notes while working through this section.Some other observations/tips:

  • You might notice that you’re now calling QuantumCircuit with two numbers instead of one - this is because the first number is for the quantum register and the second is for the classical (see screenshot below).

 

What it means when you create a circuit and instantiate it with two integers.

  • When introducing classical bits to the register, notice that the circuit diagrams change on the bottom from “meas” to “c”.

  • Since I’m working in my own notebook in the Quantum Lab, I could manipulate the code and test various versions of the circuit (so now I’m glad I set it up this way!). I wanted to understand how to build the half-adder from scratch, so here is where I started:

 
# compare two qubits
# store the result in a third qubit, then measure that
qc_adder = QuantumCircuit(3,1)
qc_adder.x(0)
qc_adder.x(1)
qc_adder.barrier()

qc_adder.ccx(0,1,2)
qc_adder.barrier()

qc_adder.measure(2,0)

qc_adder.draw()
 

Notice how the Toffoli/AND (ccx) gate takes three values: two input qubits and a target qubit for the result. The tricky thing now is that with Qiskit, the CNOT gate takes only two values. It checks the two input qubits, but then overrides the second qubit with the answer - the second qubit is the target. For this reason, the half-adder needs two applications. I’ve added notes to my answer that might be helpful for some:

 
qc_adder = QuantumCircuit(4,2)
qc_adder.x(0) # input one
qc_adder.x(1) # input two
qc_adder.barrier()

# Two applications of XOR to the same target (q2)
# in order to effectively ask:

# 1. Does the input q0 equal 0 (the value of q2)?
qc_adder.cx(0,2)

# 2. If q0 does equal 0, is q1 also 0?
# If instead q0 equals 1, does q1 also equal 1?
qc_adder.cx(1,2)
# If either of these is true, the target q2 becomes 0.

# Now check if both qubits equal 1
# Put answer in target q3
qc_adder.ccx(0,1,3)
qc_adder.barrier()

qc_adder.measure(2,0) # result of XOR gate
qc_adder.measure(3,1) # result of Toffoli gate

qc_adder.draw()

09.22.2022

“1.3 representing qubit states”

Had to take some days away to focus on other projects, but I have a little time today to look at this next section!

It appears that this is where we start talking about vectors and get introduced to some notation. One nice thing is that the textbook offers little “reminder” banners that you can expand to read about how to do things like add matrices or multiply them by scalars. Some of them seem to try to pack a lot in, so if you’re new to the linear algebra you might find yourself needing to read and re-read them a couple times, or find more resources.

We’re getting into coding again in this section, so I’ll make another file now called RepresentingQubitStates.ipynb and keep my stuff organized that way.

10.12.2022

I didn’t even get to finish part 1 of the last section before needing to step away again - for a couple weeks this time 🙃 I think this is just the way it goes when you’re studying independently over months and years! I’ve learned to give myself some grace around that and to just keep taking good notes. The only thing to do is get back to it so..onward!

At this point I’ve made it to part 2, “The Rules of Measurement”, but I pretty quickly decided to do some supplementary reading and opened QCAAA to the sections on superposition and measurement. I had read these parts before, so when I got to this section of the Qiskit textbook, it all sounded familiar, but I still felt like I wanted more resources here. They’re talking about the Born rule, although they don’t refer to it by name, which can make it tricky if you’re trying to look it up. They also bring in the inner product and complex numbers sooner than QCAAA, adding to said trickiness.

10.14.2022

The three “Quick Exercises” were indeed pretty quick, and the answer checker was helpful.

I wanted more information on global phases, so I read the IBM docs on it, which explain that “the global phase of a quantum state is not detectable”.

10.17.2022

I’m now at part 3, “The Bloch Sphere”. I read through the section quickly, but I’m finding myself wanting to fill in some gaps by reviewing some old materials.

The first thing I went back to is the section I wrote on Hilbert spaces for my cheat sheet series. This section also uses Euler’s number, which I have a post about for beginners. For more information on the Bloch sphere, relative phases, and global phases, I went back to QCAAA. I also decided to resubscribe to my Brilliant premium account so I could look at their Quantum Computing course again (use my referral code for 3 months of premium free!).

After all that, I was was able to do the 5 Bloch sphere problems. The main thing that was tripping me up in this section and that I needed the extra resources was for problem #5. The reading gave me some understanding about global and relative phases, but between the notation used and how quickly it was covered, I felt like I wanted a deeper understanding.

What I ultimately found most helpful was this part of the Brilliant course, specifically the “Hidden explanation” for the problem: https://brilliant.org/practice/universal-gate-set/?p=5

It explains how the coefficients for the computation basis states can be complex numbers, but also a clear demonstration about how the complex component can be factored out from the lower computational state |0>, which greatly simplifies problem #5.

I’ve started storing my files in GitHub, so if you’d like to see the answer to #5 with some additional comments, check out the bottom of the file here.

…MORE SOON ~