Deep Diving Quantum Circuits

I’m a big fan of IBM Q Experience, mostly because I’m on a glorious quest to find useful things to do with NISQ qubits and IBM leads the way—by far — in making them available; I’m not usually interested in simulating anything classically. However, I’m discovering a wealth of advantages offered by Quirk, an online drag-and-drop quantum circuit simulator, when it comes to figuring out how quantum circuits work. The reason for this article is my observation that the first four participants in the Quantum Intuition (@explore_quantum) “Turn the Qubits Off!” challenges — including me — were all unfamiliar with Quirk’s wealth of features; perhaps a public awareness campaign is in order.

The puzzle in this video, which is also the puzzle in the image above, is a good starting example, because I solved this puzzle in about a minute, maybe less. In the equivalent time, I could’ve maybe run — and viewed the results of — only one test circuit in IBM Q; I definitely couldn’t have solved the entire puzzle so quickly.

The Puzzle

It’s not obvious from a static image, but the first thing you notice when you view this puzzle is that the probability of measuring 0 keeps changing; it rises from 0% to 100% and back in a seemingly endless loop. Therefore, whatever is in the black box is definitely not a standard gate in IBM Q. It is logical to assume, at this point, that standard gates can’t solve this puzzle, however — spoiler alert — that assumption turns out to be wrong.

Initial States

One tip I’ve picked up from Quantum Intuition is that you can change the initial states of qubits simply by tapping them. You can rotate from |0> through |1>, |+>, |->, |i>, and |-i>. Assuming that the solution to this puzzle would be something non-standard — unique to Quirk — my intuition was to go straight to features that cannot be done — or cannot be done as easily — in IBM Q.

Therefore, I started tapping on the initial state for the top qubit. While the first four states didn’t visibly change anything, the fifth did.

From an initial state of |i>, the probability of measuring zero holds steady at 50%.

The next logical thing to try is rotating the top qubit to |0>, the “off” state. Habit forces me to lead with a Hadamard gate, but the solution should at least be one of the 1/2 rotations. Since the solution is an Rx rotation, it becomes apparent that the qubit started at |i> and stayed there while the black box rotated the state around the y axis.

At this point, the puzzle makes sense. The top qubit starts at |0> and rotates around the y axis to |1> and back. The probability of measuring 0 therefore goes through the full range of 100% to 0% and back. When a quantum state is |i>, however, rotating around the y axis doesn’t change anything.

Go Left

To finish solving the puzzle, reset the initial state of the top qubit to |0> and then add a reverse Rx rotation to |i> before the black box. This was a tip, by the way, from Craig Gidney (@CraigGidney), the creator of Quirk. I think of circuits as flowing left-to-right, so I honestly never would’ve thought of placing anything to the left of the black box. But, it allows the puzzle to be completely solved with only two single-qubit operations.

Black Box

To prove that the black box contains a continuous rotation around the y axis, the initial state of the top qubit can be set to |-i>. The probability of measuring 0 once again holds steady at 50%.

Since the initial state is now on the opposite site of the Bloch sphere, the rotation back to |0> is reversed.

From here, simply reset the initial state to |0> and add an Rx rotation before the black box.

Why Two?

When I initially saw two qubits with one already in the “off” state and the other acting unfamiliarly, I assumed at least one multi-qubit gate would be involved in the solution. I honestly don’t know why the bottom qubit is there other than to confuse and delay.

Tip of the Iceberg

This article only points out two Quirk features, but they are features that allowed very rapid analysis of a quantum circuit. I still don’t know all of Quirk’s features — I’m looking forward to Craig Gidney’s upcoming participation in “Turn the Qubits Off!” — but it definitely seems like a browser tab worth having open while doing just about anything involving quantum computing.

In addition to trying Quirk, I also recommend trying deep diving, but that’s beyond the scope of this article.

How to fit a Decision Boundary to Data using the Logistic Function

Get the Medium app