Introducing Joy Vazirani: Visualizing Text With Quantum Computers

Russell Huffman
Sep 28, 2020 · 8 min read

In September of 1970, 50 years ago this month, a very important scientific visualization was published by Harold D. Craft: The image depicted data from the first radio pulsar, known as CP 1919. The signal was significant for many reasons, including the fact that people thought it was an extraterrestrial beacon, at first. But for me, the significance of the CP 1919 image is its eventual use in the album artwork for Joy Division’s Unknown Pleasures. It is one of the most beautiful and recognizable visual adaptations of scientific data.

Image of Peter Saville’s design for Joy Division’s Unknown Pleasures album artwork.
Image of Peter Saville’s design for Joy Division’s Unknown Pleasures album artwork.
Image of Peter Saville’s design for Joy Division’s Unknown Pleasures album artwork.

To honor that legacy, I recreated the image, but instead of using pulsar data, I’m using data from a quantum computer. Try the web app here, and read on to understand how to use a quantum computer to create a similar image of your own.

Drawing with a quantum computer

This image was created with a quantum computer:

Image of data from a quantum computer styled like the Unknown Pleasures album artwork.

Even better, this image is a word written by a quantum computer, reading “Qiskit”. Each line shows the amplitude of the binary representation of the letters of “Qiskit” as an output of the Bernstein-Vazirani algorithm.

Didn’t understand that sentence? That’s okay. Let’s break it down and get into some details.

First, let’s talk a little bit about how quantum computers work. I’m going to skip some of the fundamentals, as they have been explained many times by people much more knowledgeable than myself, like this video.

For our purposes here, the important part is that unlike regular (or classical) computers, quantum computers use the effects of interference, a behavior only found in quantum physics where the wave-like nature of matter makes certain states of a quantum system become more likely and others become less likely, to find the output to an algorithm in fewer steps. These computers are manipulating really delicate quantum states which have lots of errors and may not get the right answer all the time, so we run an algorithm over and over to amplify the right answer. For example, a typical result from a quantum computer looks something like this.

Image of data from a quantum computer displayed as a histogram

Whatever the quantum computer was trying to compute, we can see that the right answer is that tall column in the middle. All those other little bars in our histogram are a result noise. Today’s quantum computers aren’t perfect, so there will be noise in our results, but in this case, our correct answer is still fairly clear. For the sake of creating a visualization, I think the noise is beautiful and adds to the final effect. Once quantum computers are fully fault tolerant, this visualization will be a lot more boring. For once, the noise is a good thing.

So, what is it calculating, and what is the answer? Let’s add some more data to our histogram.

Image of the probabilities of computational basis states

As you can see, each bar is labeled with a series of 0s and 1s. These are 7 bit binary strings, and our amplified answer is “1010001”, which is binary for the letter “Q”. This means that our quantum computer is amplifying the letter Q, the first letter of Qiskit, which is exactly what we want! (For those really paying attention, text to binary is often written as 8 bits, starting with a 0 or 0b, but more on that later in the FAQs).

From here, I exported the data as a .csv file and styled it to look like a line from Joy Division’s famous Unknown Pleasures album artwork using Apple Numbers and Adobe Illustrator. The amplitudes may look slightly different because the below image uses all the data provided by the quantum computer, while the above is just a summary.

Quantum computing data representing the letter “Q” styled like the Unknown Pleasures album artwork.

How does a quantum computer “compute” the letter Q?

That’s where the Bernstein-Vazirani algorithm comes in, which you can read all about it in depth here. Or instead, here is a quick summary: There is a function called an oracle that behaves in a particular way that depends on a secret string of binary digits (0s and 1s). The algorithm is a way to find the secret string. In our case, the secret string is our letters, so we encode the letters by first converting them to binary and then putting them into the oracle which we’re going to write ourselves with quantum logic gates. We then run the Bernstein-Vazirani algorithm on the quantum computer, asking it to find the oracle’s secret string as a quantum state, which we can measure. Because of the noise associated with current quantum computers, we run the algorithm multiple times to see how the function operates in order to figure out what oracle is driving the function’s behavior, giving us our amplitudes as shown above.

To do a full word (or sentence), the same algorithm will need to be run for each letter. This is why our “Qiskit” example has 6 lines, each corresponding to a letter of “Qiskit”. In the interactive version here, I pre-ran every letter of the alphabet (both capital letters and lowercase, which are different at the binary level) so you can play with it and create your own Joy Division style quantum computing-encoded message visualizations.

That’s basically it! I certainly skimmed over some details, but the entire Jupyter notebook with the Qiskit code can be found here, which builds upon the Qiskit implementation as described in the Qiskit textbook here. The source code for the web app is in the same GitHub repo here. The primary difference from what is shown in the notebook is that you can enter a string of text, and it will return an array of circuits, corresponding to each letter. The array of circuits can be run all at once with Qiskit as one job, so give it a try!

And if you haven’t picked up on it yet, I’m calling this “Joy Vazirani” because it styles the data output by the Bernstein-Vazirani algorithm to look like the Joy Division artwork.

For one last example, here is a mock up on a shirt that reads “qiskit terra aqua aer ignis” without spaces.

Rendering of the styled quantum amplitudes on a t-shirt.

Frequently asked questions

Why the minor inaccuracies in the amplitudes?

Towards the beginning of the chapter on Bernstein-Vazirani, the Qiskit textbook says “Using a quantum computer, we can solve this problem with 100% confidence after only one call to the function 𝑓(𝑥).” If that is the case, why are there any amplitudes other than the correct answer? It is true that the Bernstein-Vazirani algorithm is considered to be deterministic and should get the right results on the first try, but current quantum systems are have limitations. Specifically near term quantum computers are prone to a small level of error, called noise, which causes the little spikes. Researchers are hard at work removing the noise, but for this visualization it is key to creating a compelling image. Some day, running this algorithm will result in a completely flat line with one big spike over the right answer. That will be good for science, less good for art (in this case).

Why are some letters more accurate than others?

The circuit as it is created by the algorithm above is not the same circuit that gets sent to the actual quantum hardware. Each quantum computer available through IBM Quantum has its individual limitations. Not all qubits are entangled to every other qubit. And not every qubit performs equally. When a job gets sent to run, the circuit gets compiled (or transpiled, depending on who you talk to) to fit on the hardware as efficiently as possible. But not all letters are equally efficient.

In the example above, the circuits were run on “ibmq-paris”, which the qubit connectivity looks like the following:

Qubit connectivity diagram for the quantum backend “ibmq-paris”

When the circuit for “Q” was transpiled for this hardware, it looks like this:

Transpiled circuit for the letter “Q”

However, when the circuit for “k” was run, it was transpiled to look like this:

Transpiled circuit for the letter “k”

The second circuit is a fair bit longer (or as we say, has a greater depth), which makes it more difficult to maintain accuracy. The longer (in depth) a circuit is, the longer (in time) it takes to execute, which means more opportunity for noise to get into the system. Each letter looks a little different, so some letters will be less accurate than others.

Why only 7 bits instead of 8 to represent a letter?

The fewer bits used, the more accurate the result. When converting from text to binary in Python, the data is prepended with “0b”, which is just a computational way of saying “binary is about to follow”. In my script I scrape both of these off. If you were to google an ascii to binary table, you would see all text starts with 0. Again, we don’t need that, so I scrape it off. Like the above explanation about how circuit depth effects accuracy, so does the number of qubits used, called circuit width. At IBM, we take into consideration both circuit width and depth to account for accuracy, called quantum volume (or QV). For the web app implementation, I ran all circuits on the quantum computer call “ibmq_montreal” with the highest quantum volume, QV64.

Conclusion

Quantum computing is difficult, but slowly becoming more accessible. It is usually done by scientists and researchers for, well, science and research. But at IBM we’re trying to take quantum computing out of the lab and put it in the hands of everyone else with free, cloud-based tools like the IBM Quantum Experience and open source tools like Qiskit. I work for IBM Quantum, but I’m also an artist and I want to show that quantum computers can be used by non-scientists to do things that won’t necessarily advance the field of research, but are still valuable. I hope others like me, those without a quantum physics background but are curious and creative, can start learning quantum computing as a method of creative expression. I hope that this blog shows that quantum computing doesn’t always have to be about solving the world’s most complex problems, and that those of us who aren’t mathematicians can still learn to use quantum computers.

To me, a quantum computer is a paintbrush. It might be the world’s most complex paintbrush, but I hope this is the beginning of a learning path for using a quantum computer for creative expression.

Russell Huffman is a designer with IBM Quantum based in Austin, Texas. The above article is personal and does not necessarily represent IBM’s positions, strategies or opinions.

Qiskit

A community to discuss Qiskit, programming quantum…

Russell Huffman

Written by

I am a product designer at IBM on the quantum computing team. I have an art background but grad school at Georgia Tech brought me into the tech scene.

Qiskit

Qiskit

A community to discuss Qiskit, programming quantum computers, and anything else related to quantum computing.

Russell Huffman

Written by

I am a product designer at IBM on the quantum computing team. I have an art background but grad school at Georgia Tech brought me into the tech scene.

Qiskit

Qiskit

A community to discuss Qiskit, programming quantum computers, and anything else related to quantum computing.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store