How I Use Quantum Computing to Create Bubble Art

Radha Pyari Sandhir
Qiskit
Published in
7 min readDec 8, 2021

A creative visualization of quantum noise

Quantum computers are noisy. And by ‘noisy’ I don’t mean when your upstairs neighbor is really into techno, or when your cat sings the song of his people at 3 am (Thanks, Blade). Noise in the quantum sense has nothing to do with acoustics, but messiness. Specifically, messy answers.

If you ask a real quantum computer a single question one hundred times, you won’t necessarily get the same answer one hundred times. You might get it most of the time, yes, so from the majority you may be able to decipher the correct answer. But the output of a real quantum computer can stray a little from what you expect.

Photo by Stacy Spensley

It’s kind of like how as a child, I would ask my parents for mac and cheese. They’d agree, but they’d sneakily veggify it with peas. While I got my mac and cheese, I certainly did not ask for the peas. (No, I’m not bitter, why do you ask?)

Now, I’m not saying quantum computers are tricking you into eating your greens, but you certainly get answers you did not ask for. The question Dr James Wootton and I asked ourselves is: how can we visualize all the extra stuff quantum computers say?

Here’s where bubble art comes in. If you want to jump straight to creating bubble art for yourself, scroll down to the last section. Otherwise, let’s dive in to what these bubbles represent, and why quantum computers are noisy at all.

Bubble Art as a Visualization of Quantum Noise

Take a look at this artwork:

What you see here is a visual representation of the phrase “live long and prosper” in bubble form. The text was passed through a simulated quantum computer and transformed into these colorful bubbles by a method I’ll elaborate on below. In the ideal scenario, there’s absolutely no presence of noise at all, and the bubbles end up exactly the same size.

But running the same text through a simulation of a quantum computer susceptible to slight noise yields:

You can probably already see that by adding a little bit of noise, some unwanted results pop up that aren’t as prominent as the ideal, but are nonetheless noticeable. As you add more and more noise, you can witness a remarkable journey:

The fun part of this art generation is that the artwork is more visually interesting in the presence of noise — the noisiness of quantum computers doesn’t necessarily have to be a bad thing!

Here’s a high-level overview of how we created the bubble art:

  1. A user supplies a text input.
  2. The text is converted to a string of bits (0’s and 1’s), which are then encoded into a family of quantum circuits.
  3. The quantum circuits are simulated with specified noise levels by implementing a ‘noise model’. The levels can be zero (the ideal case) or non-zero.
  4. The quantum circuits yield an output that is another string of bits. In the ideal case with no noise, the original bit string of step 2 is recovered.
  5. Steps 3 and 4 are repeated many times to generate some statistics. (Remember, if you run the same quantum circuit one hundred times it doesn’t necessarily yield the same output one hundred times!) The results are converted to bubble colors and sizes, and the bubbles are printed on the canvas at random coordinates.

Now, we don’t need to get into how the colors are generated— though the code is available for anyone curious! — what’s important to note is that the size of each bubble is proportional to how often its corresponding output appears. Think about that for a moment. In the ideal case, the ideal answers always appear, with no extraneous stuff. Makes sense that the bubbles are big and equal in size, right?

But the more noise you add, you not only get extra bubbles, those extra bubbles become bigger and bigger as the ideal bubbles become smaller and smaller! It’s a bubble extravaganza!

Another thing that’s important to note is that we’ve been chatting about simulations. Unfortunately, in the real world you can’t tell a quantum computer how noisy it should be, you can only hope to impose some corrections on the errors that arise due to the noise (This is, incidentally, an entire and pretty cool field of study: Quantum Error Correction).

Why are Quantum Computers so Noisy, Anyway?

Now that you’ve understood that quantum computers can be noisy you may rightfully be wondering: why? Where are all these messy answers coming from, and why can’t quantum computers be as straightforward as the computers we use to circulate Lord of the Rings memes and recipes and TikTok dances?

The short answer is: quantum physics. You see, quantum systems are sensitive, susceptible to even the slightest fluctuations in their environment.

Photo by Sigmund

Think of a house of cards. It, too, is susceptible to tiny fluctuations: an errant breeze, a slight shake of the table, a cat overcome with the zoomies. These are all environmental disturbances, external to the system of the playing cards.

This is why, ideally, a quantum computer should be isolated and qubit states made as stable as possible to minimize even slight interactions with the environment. (A qubit is a quantum bit, the fundamental computing unit of a quantum computer.) Moreover, there are a number of different ways to physically realize quantum computers, and each type of hardware has its own sensitivities to contend with.

Now, environmental noise isn’t the only type of noise. Another type of noise arises due to physical limitations in how quantum systems are controlled. For instance, in order to operate on a qubit’s state to perform calculations, you switch on some sort of interaction with it, that is, you try to nudge it into behaving a certain way. But because of its inherent sensitivity, you cannot control that interaction with perfect precision. The interaction is either applied for too long or not enough.

Think of it like spinning the wheel of fortune. A slight under or over-rotation on your part could mean the difference between bankruptcy or a million dollars!

There are, technically, many — infinitely many — different types of noise that can play on a quantum system’s sensitivities. But we needn’t get into them here. The result is the same: messy answers, in other words, errors.

While generating the bubble art, there are two types of errors simulated by the noise model:

  • A Pauli error during measurement: a qubit’s state is flipped with a probability, P(meas), when the qubit is measured. For instance, if P(meas) is 0.02, then 2% of the time, 0s become 1s and 1s become zeros in the output.
  • A depolarizing error when a gate is applied: a qubit’s state is replaced by a completely random state with a probability, P(gate), whenever an operation is imposed on the qubit prior to measurement.

You can play with these probabilities while generating your art!

The QartGen App

And now it’s time to actually make the art with whatever textual input your heart fancies (don’t worry, we can’t see what you type). You can download and run the app locally from the QartGen app Github repo by following the instructions in the ReadMe.

There are two ways art can be generated:

  • ‘Preset Noise’ generates a slideshow of artworks with strategically preset levels of noise so that you can observe the journey as noise levels increase.
  • ‘Custom Noise’ generates a single piece of artwork from your own specified noise levels — this is where you can play with the probabilities associated with the two types of errors! Remember that probabilities need to be specified between 0.0 and 1.0.

Here’s something for you to try: in the Custom Noise mode, set both P(meas) and P(gate) to 0.5 and see what you get! Think about why the resulting artwork looks the way it does.

Alright, happy bubble making!

PS. We’d love to see whatever bubble art you create with this app! Tweet us with pictures at @RadhaPyari and @decodoku.

This project is part of the Qiskit Advocate Mentorship Program Fall 21 cohort. If you are interested in joining the Qiskit Advocate program, please check out the application guide. You can also fill this form to get an email update when the new application round open later this year.

More to Explore:

App specific: QartGen app Github repo

Quantum Error Correction and Noise

Generic Quantum Resources:

--

--

Radha Pyari Sandhir
Qiskit
Editor for

Scientific Advisor. Writer. Physicist. Cat lady and caffeinated.