top of page

How to Decode Qubits

Posted on November 21, 2022, By Brian N. Siegelwax



Data goes in. How does it get out?


This article is inspired by a comment on one of my other articles. While there are a plethora of books and articles and tutorials and videos about encoding data onto qubits, I don’t recall anything dedicated to the other end of quantum algorithms. In other words, how do we get the data back out?


Measurements


This is the first method everyone learns, and it ought to be the one everyone knows best. We encode qubits. We do stuff. And then we measure. Hopefully we can find useful information in those measurements.


The following methods all incorporate measurements somehow. Feel free to think of them as something-plus-measurements, instead of just-measurements.


Inverse Quantum Fourier Transform


When you learn about the Quantum Fourier Transform (QFT), you generally learn about its inverse at the same time. Because I’m a computer scientist, I usually characterize the QFT as a digital-to-analogue converter, and its inverse as an analogue-to-digital converter.


If you’re reading about encoding data onto qubits, you might come across the QFT as an example. Maybe it’s been a while since you completed that tutorial. So, you’re only reading about how the QFT encodes data, but you’re not being reminded about its inverse; that’s not what that section is about. So, if you’re wondering how to decode QFT-encoded data, that’s what its inverse is for.


Tomography


You encode data. You do a bunch of stuff to your qubits. And then your measurements destroy your quantum state(s). All you have left are zeroes and ones. But those quantum state(s) are information; sometimes you want to extract that information.


This article isn’t a tutorial on tomography but, in a nutshell, you make repeated measurements in multiple bases, and then you can use trigonometry to imperfectly determine what a quantum state is. There are equations and explanations that can make tomography look fairly complicated, but the mathematics can be simplified to basic arithmetic and inverse cosines. You’re probably using a programming language that has a built-in function to calculate inverse cosines for you. And the simplest bases to measure are the z basis, which you normally measure anyway, and the x basis which simply adds a Hadamard gate before each measurement.


Nothing


You don’t always need to decode your qubits. For example, my Quantum MNIST experiment encoded the handwritten digits 0 through 9, as well as a handwritten test digit for comparison. The closest comparison is then the recommended classification. So, there’s no need to decode any of the digits, because they don’t change in any meaningful way. All we need to extract is the comparison information, which comes from measuring the ancilla “work” qubit(s).


Conclusion


Depending how you encode your data, there’s always some way to decode it. Because of the probabilistic nature of quantum mechanics, the results may be imperfect, but you can get pretty close. And it’s important to keep in mind that just because you’re using n qubits doesn’t mean you have to measure all n qubits. You only have to decode the useful information, which may be extracted from as few as a single qubit.


Brian N. Siegelwax

Comments


bottom of page