What this blog is about?
I can safely assume that anyone reading this blog has at least heard the phrase quantum computation in one form or another. If not, this is a perfectly good time to visit this nice 3Blue1Brown video and get a flavour of what the subject is about.
You have also probably heard the usual headline: quantum computers can make some computations dramatically faster than the classical algorithms we currently know. Factoring large integers is the famous example, and there are already many excellent explainers online about why quantum speedups can occur.
But most of us do not have a quantum computer sitting at home. I am technically cheating here, because there is one in the lab next door, but that is not a particularly scalable solution for everyone reading this blog. You can of course access quantum hardware through cloud services such as IBM Quantum, but our question here is deliberately different.
Suppose you want to run a quantum computation and all you have is your laptop.
Are there quantum computations that look genuinely quantum, but that we can nevertheless simulate efficiently on an ordinary classical computer?
That is the question I want to answer.
I will later give a formal description of what “to simulate classically efficiently” might mean, but for now this is how you can think of it: no matter how big the computation might be, we can run it on a laptop without waiting for the universe to end.
Now, the question of how a quantum computation can be classically simulated is rather multi-faceted and is a frontier question of research. And depending on the intended application, say machine learning with quantum computers (which is of my interest), there are different sets of techniques that one might use. However, for this blog I will talk about the one that is perhaps most easily explained, as well as the one I find most elegant.
By the end of this blog I will have explained a well-known result known as the Gottesman-Knill theorem. Broadly speaking, it says that a certain class of “apparently” quantum computations can be efficiently simulated on a classical computer. This theorem has huge implications in the field and has been used in several forms to derive more advanced results ever since it first appeared in 1998. And it is certainly one of my favourite results in the entire quantum computing literature.
Even though there are enough textbooks and lecture notes available online that cover this theorem and associated topics, I have not come across many that have the 3B1B approach to explaining why any of this is even important. And this is why I prepared this blog. The idea of writing this blog is somewhat inspired by the seminar I gave to educate other (non-quantum) computer scientists in our department about certain fun results in the field, and I have carried over the same vibe in this blog.
As for audience expectations, I will assume that you were seriously attentive in your linear algebra classes (if not, like me, 3B1B has a nice series which is all you will need) and know how to count the number of entries in a matrix. Though I do not think anything more will be needed to grasp the key ideas I will be talking about, feel free to ask ChatGPT if certain ideas are too tedious. I have also included a small exercise within the text for you to “pause and ponder” (honestly, I was simply lazy). Given that this is a blog and not a research paper, I will resort to simplifications that would otherwise get me fired from the job of being a PhD student — were I speaking to my professors — but at the same time they allow a smooth story, and so I will take the risk.
(AI usage note: The idea of the blog and the text, along with all its em-dashes, were human generated. I used AI for coding the interactive components.)
Map of contents
I will start by going over the basic operations that constitute a quantum computation, while also explaining the costs associated with storing and processing those operations classically. By the end, you will see why a naive approach to classical processing of quantum computations is inefficient.
Then I will talk about Pauli strings, which could be thought of as a special data structure, and show how they allow a more efficient representation of the quantum operations suitable for classical computers.
Then I will show how, when you restrict the class of quantum operations, this efficient classical representation made possible by Pauli strings leads to an algorithm that allows you to classically simulate a quantum computation. This is the main result of the Gottesman-Knill theorem.
Quantum computation and classical problems
Broadly speaking, quantum computation consists of having a quantum state, a method for evolving that quantum state with time, and a means of reading out information about the quantum state.
The first thing to learn about is the “state”.
In computer science the word state refers to whatever you are supposed to track. For example, in classical computation the state of the system is simply a bitstring, i.e. a string of ‘s and ‘s. And no matter how fancy your interface looks, at its core it is simply a lot of transistors that are either ‘on’ or ‘off’ in the processor.
So if your computer has bits available, then the number of different states your computer could be in is simply , since for each bit you have two choices. For two bits, for example, the possibilities are .
The corresponding analogue in quantum computation is a “statevector”, which is, in some sense, a different creature.
For a quantum computer with qubits — which is the quantum analogue of a bit — the statevector is a vector of size , where each entry is a complex number and each individual entry is related to the probability of the computer being in that state.
For example, for a -qubit system the state could be expressed as
Here the states are the basis vectors, expressible as
and so on.
So indeed you could pack up the statevector in a vector of the form
and it would mean the same thing.
But what is this expression even telling you?
The above expression tells you that has probability (which is always a real number) of being in the state , and it has probability of being in the state , and so on. In the literature, is referred to as the amplitude of the state in . Note that for the probability interpretation to hold, we need the additional condition that all the probabilities must sum to unity. So here
Observe that if only one of the amplitudes is non-zero, say is the only non-zero term, then the state , although still a quantum state, feels more classical — since the state of the computer is just and not a superposition. This notion of what kind of state feels more quantum than the other is something worth pondering, and I will let you do some thinking of your own until we come back to it later in the blog.
Now if you recall your linear algebra, the choice of basis is not unique. In the above I chose the computational basis, i.e. all the possible basis states resemble possible bitstring values.
However, depending on the problem, you can often choose a different basis. For example, the Hadamard basis has the following basis vectors:
The ‘plus’ and ‘minus’ states on a single qubit can be expressed as
This allows you to derive the two-qubit basis states as tensor products of the two single-qubit states, e.g.
If you find the name ‘tensor’ scary, do not worry — all it does is give you a way to say that the first qubit is in some state and the second qubit is in another state. This joint description of the states on two qubits is done by taking a tensor product of the states on the individual qubits. By the way, can you think of a two-qubit state that cannot be represented as a tensor product of two single-qubit states?
I leave it as an exercise to find the vector representation of all the basis vectors in the Hadamard basis. As a hint,
So in general, for a system of qubits, you will have basis vectors (of course you can choose the basis as you would like), and the state will thus be described by those basis vectors along with the complex coefficients for each of them. In practice, the computational basis is the one that is most used, but you are free to pick any basis in general. The space of all the states is called the Hilbert space.
What makes a quantum state really distinct from a classical state is the fact that you do not have direct access to the state. What I mean is that if I tell you that the state is loaded into the quantum computer, you do not have a way to directly read out its complete statevector. Instead, a measurement in a chosen basis produces one of the corresponding basis outcomes probabilistically.
The best you can do is ask whether the state is in a particular basis state. For the two-qubit example, we can ask whether the state is in . The quantum process by which we do this is called measurement.
In the above case, the measurement operation answers ‘yes’ — the state is in with probability — and ‘no’ — the state is not in with probability .
Here is simply the scalar obtained by taking the dot product (with conjugation of the coefficients) of the vector with the vector .
Moreover, once the measurement answers yes, the state of the computer changes to . So making the measurement actually changes the state of the system, and you will have no way to retrieve the original state . This is the main difficulty with quantum states: wanting to know what state they are in ruins the state itself. It also means that if you had planned further operations on , you will not be able to do them anymore since you no longer have access to the original state.
But what happens when we get the answer ‘no’? How does the state look after the measurement? This is a bit complicated to answer at the moment, but feel free to pause and ponder. An intuitive hint: it must lie entirely in the subspace spanned by .
You could also ask whether the state was in the state , and the answers would follow similarly.
Also, you could ask a question about a single qubit: is the first qubit in in the state ? Observe that this amounts to asking two questions simultaneously: is in either of or ? Using the intuition given already, try to see if you can compute the probability of this.
Here it is worth pausing and highlighting some key facts, which is what most people get wrong at times. You might ask: But why can we not reconstruct the state after the measurement? After all, we can always keep a record of the coefficients .
And indeed you are right. If we keep track of the statevector with all the amplitudes classically — say you write it down in your notebook or on your computer — much like we did above, then the intricacies of the quantum world indeed cannot prevent you from going back to , because it is simply written on your notebook.
This is the subtle point where the difference between “running a quantum computer” and “classically simulating a quantum computer” comes into play. For a quantum state loaded in an actual quantum computer, you will never have a way to know the amplitude-wise description of the state, because quantum mechanics prevents you from doing so. So the only workaround is to keep track of the statevector classically by noting down all the amplitudes and then simulating what happens when a measurement is to be made.
But then, “Why not keep track of the amplitudes?” Well, there are many reasons, but most importantly observe that the number of amplitudes you will need to keep track of grows exponentially with the number of qubits. So even if you had wanted to, classically simulating the computation would have been practically impossible. And thus there would be no way other than actually doing it on a quantum computer, in which case you are left at the mercy of weird quantum phenomena.
This is also the main problem this blog is supposed to address, and I believe that what I have explained so far gives you enough reason to want to have a classical means of simulating quantum computations even for computations that involve a large number of qubits.
So we have covered states and measurement, two operations that are often conflated in the classical realm — having a bitstring on the computer and reading out that bitstring from the computer are the same thing — and yet they are so different in the quantum realm.
The question now is how to do computation with the state. In classical computers this is done by logic gates — you pass the bitstring through a sequence of gates and get an updated bitstring on the other side. In quantum computation the corresponding analogue is a unitary operation.
From linear algebra you know that a unitary matrix is one that satisfies . So, in general, the unitary is specified by a matrix of size for an -qubit system.
For example, one of the simplest single-qubit gates is the Hadamard gate,
It maps the computational-basis states according to and .
On an -qubit system, a gate may act only on one or two qubits at a time. A complete quantum computation is therefore usually not specified by writing down one enormous matrix. Instead, much like in a classical circuit, we specify a sequence of smaller gates whose combined action gives the overall unitary .
This is already good news from the point of view of merely describing the computation. A circuit containing a reasonable number of one- and two-qubit gates can be written down compactly, even though the full matrix represented by that circuit would contain exponentially many entries.
But unfortunately this does not yet make the computation easy to simulate.
Suppose we are storing the state directly as its statevector. Even if the next gate acts on only one or two qubits, the state we are updating still contains amplitudes. A classical statevector simulator can exploit the fact that the gate is local—it certainly does not need to construct a fresh matrix for every gate—but it still has to update an object whose size grows exponentially with .
So we have arrived at an important distinction: A quantum computation may have a compact classical description even when simulating its evolving quantum state is exponentially expensive.
Let us summarize where the difficulty comes from.
A generic -qubit state requires complex amplitudes if we store it directly. Even when the unitary is given compactly as a sequence of local gates, those gates act on that exponentially large statevector. To reproduce a measurement classically, we must eventually compute the relevant outcome probabilities and, if we want to continue the computation, the corresponding post-measurement state.
So the problem is not that classical computers are incapable of storing complex numbers or multiplying matrices. They are perfectly happy doing both. The problem is that the objects we have chosen to keep track of become exponentially large.
And this suggests that perhaps we have been asking the wrong question. Instead of asking : “How can we make our laptop manipulate a -dimensional statevector faster ?”, perhaps we should ask “Do we really need to store the statevector at all ?”
So the main motivation of the blog is now as follows: can we come up with a more clever way to represent the various operations in a quantum computation, and perhaps an even more clever way that will allow us to execute the computation on a laptop without waiting until the end of the universe?
Here, execution of a quantum computation can be thought of as follows: we are given an initial state , a unitary , and some descriptions of the measurements that you might wish to make. So running a quantum computation would involve evolving the state using the unitary , i.e. , and then trying to get the probability distribution over the measurement outcomes.
What we mean by classically efficient simulation would be to be able to do: storing the state , obtaining the state , and then being able to get the probability distribution over the measurement outcomes, all of it using resources, i.e. space to store and time to process the computation, that do not scale exponentially with the number of qubits .
A word of caution here: the word “classically simulate” really has too many different meanings in the literature --- which is usual when you leave scientists with their thoughts and enough cookies --- but for the scope of this blog the above is the only description I would use. If you need keywords to search, try looking for “strong simulation”, “weak simulation”, etc.
In what follows I will start by explaining a cool way that would allow you to represent a quantum computation in a more efficient fashion. Following that, I will show that this representation leads to a classical simulation for a certain restricted class of quantum computations.
To give you a teaser, by the end you will be able to simulate a quantum computation on qubits by tracking bitstrings of size instead of -sized vectors --- and if that does not impress you, I’m afraid nothing else will :)
Pauli Strings: or the bit-strings of quantum computers
Pauli strings are undoubtedly the single most important concept in this blog, and they will serve as the bricks for building a bridge across the gap of classical inefficiency that we so aim to cover.
Now a Pauli string is a string of Pauli operators; each Pauli operator is a matrix that acts on a single qubit. The string corresponds to the tensor product of Pauli operators acting on each qubit. That’s what happens when physicists adopt a computer scientist’s vocabulary.
Now the Pauli operators can be of four types:
All of them are unitary operators and can be interpreted as gates. Let us take a look at how they act on the state.
The is the identity and does nothing.
The operator can be understood as a “bit-flip” operator: and .
The operator is a phase flip: and , since it adds a phase.
The operation is basically: , so it does both an and a operation.
Above I showed their action on the computational basis. I leave it as an exercise to derive their action on the Hadamard basis.
Observe that all the operators have the property that they square to the identity (): if you apply them twice you get back the same state.
A Pauli string is simply a tensor product of these single-qubit operators, one letter per qubit. For example, on four qubits, a Pauli string might have the shape , where the subscripts indicate the qubit the operator is acting on. Since a Pauli operator is a matrix, a Pauli string on qubits is a matrix of size .
An important property is that of commutation. If you know something about matrices then you know that any two matrices and applying and then is not same as applying and then .
Now when it comes to Pauli-strings the possibilities are rather limited i.e they either commute or anticommute : If they commutes then , while if they anticommute then .
For our conventions we will use the notation , which we will call the ‘commutation signature’, to capture this binary relation, specifically:
What is interesting is that whether two Pauli strings commute or anticommute can be expressed as a linear sum of the commutation signatures of the Pauli operators acting on individual qubits.
For instance, say we have two Pauli strings on a -qubit system and . At qubit 1, and anticommute; at qubit 2, and anticommute. There are two local conflicts. Two is even, so the two minus signs cancel and the full Pauli strings commute.
In terms of the notation , where indicates addition modulo two or the XOR operation.
More generally, for Pauli strings and , we can have the formula
which summarizes the idea that the commutation signature of two Pauli strings is the sum (modulo two) of the local commutation signatures on each individual qubit.
Computing commutation of Pauli strings
Build two Pauli strings of your choice and compute their commutation relation. The commutation signature of the strings is the sum of the local commutation bits at each qubit, modulo two.
| Pauli string | Qubit 1 | Qubit 2 | Qubit 3 | Qubit 4 | Qubit 5 | Qubit 6 |
|---|---|---|---|---|---|---|
| Local bit 0 = commute, 1 = anticommute |
The XOR is 0, so and commute.
Okay, lots of fun computing commutations. But in the end they are still matrices of size , which is still very big for a classical computer. How does it even help us?
You are right, and here is the smart fact that changes the story.
Observe that any Pauli operator can be expressed as
where and is a binary string of length 2.
For most of the questions regarded in this blog — especially commutation — the overall phase will not matter. Ignoring that phase, we can therefore identify a Pauli operator with the binary pair . See if you can build all four Pauli operators by picking suitable and pairs.
For qubits we collect the local bits into two length- binary vectors, and , and represent the Pauli string by . This is the binary, or symplectic, representation of Pauli strings. If the scares you, all it is saying is that the allowed elements are either or and their addition must be done modulo two.
A useful precision point: this binary vector represents the Pauli group modulo overall phases. It is not a faithful representation of the full Pauli group unless the phase information is stored separately, but we can care less about the complex scalar for now.
Now the commutation relation becomes a simple binary calculation.
For and ,
Here is the dot product, which is the same as a regular dot product except that the sum is taken modulo . This quantity is called the symplectic product.
For example, if we look at the two Pauli strings and , their symplectic representations are
In other words, , , , and . Their symplectic product is therefore
The symplectic product is , so and anticommute. This also matches the local picture: and anticommute on the first qubit, while the two factors commute on the second.
So we have shown that a question about two exponentially large matrices has become a dot-product calculation on bitstrings of length . This exponential reduction in the computation is at the core of the classical efficiency of quantum computation that we are trying to achieve.
Pauli strings: or answering classical questions about quantum states.
About states
We will now see how we can use Pauli strings to characterize states and measurements.
Let us start again with the single-qubit Pauli operator .
We know that the computational basis for a single qubit is . Now observe that , while .
So relative to this basis, has very neatly split our two possible basis states into two parts: gets a sign, while gets a sign.
Let us now try the same thing with . This time the computational basis is not particularly useful. Instead recall the states and . These satisfy and .
So the exact same thing has happened again, except that this time the basis being split into the and sides is instead of .
So what we have seen is that, given a single-qubit Pauli operator, we can find a choice of orthonormal basis such that one basis state gets mapped to itself and the other gets mapped to negative times itself.
That was easy enough for one qubit. Let us see what happens when there are two.
Consider the Pauli string .
The computational basis now consists of the four states . Acting with gives and , while, and .
So again the Pauli string has split our basis into two groups. On the positive side we have and , while on the negative side we have and .
But something slightly more interesting follows from this. It is not only the individual states and that get a sign. Any linear combination of them does.
For example, for arbitrary and any state satisfies .
Similarly, any state of the form picks up an overall minus sign when acts on it.
So what is the Pauli strings actually doing ? Avoiding mathematical sophistication the naswer simply is this. Given a Pauli string we can always find an orthonormal basis of the -dimensional Hilbert space such that exactly half of those basis states satisfy and the other half satisfy .
Thus it follows that any linear combination made entirely from the first half also gets , while any linear combination made entirely from the second half gets when acted on by .
Thus intuitively : a Pauli string splits the Hilbert space in half.
Not in the sense that someone has physically taken a pair of quantum scissors to Hilbert space, but in the sense that it divides all the possible directions in that space into two equally large sets: a side and a side.
However one must be careful to strech the meaning of this quote. You can always build a state by taking a linear combination of states that from both both sides of the split.
For example, for the single-qubit operator, contains one component from the side and one from the side. Then . So the state is neither mapped to itself nor to minus itself: applying actually changes it into a different state.
This gives us a useful way of thinking about any state relative to a Pauli string .
There are three possibilities:
- the state lies entirely on the side, so ;
- the state lies entirely on the side, so ;
- or the state has components on both sides, in which case applying changes the state.
So given a Pauli string, we can essentially ask of a state: Are you on my positive side, on my negative side, or somewhere across both?
And as we will see this already allows a Pauli string to describe an entire set of possible quantum states.
For example, suppose I tell you that some two-qubit state satisfies without giving you the exact description of the state.
Even though I may not have told you the exact state, I have already told you quite a lot: it must be some linear combination of and since otherwise the would have either got a nagative sign or been mapped to something else completely.
Likewise, if I tell you that , then the state must be some linear combination of and .
So one Pauli string and its effect on the state gives us a compact way to specifying the possible beasis vectors a state is composed of without writing down the statevector itself. But what if we have two Pauli strings ?
Now let us bring in another Pauli string: . We already know that and . Therefore, on two qubits, gives a sign to and , because either both signs are positive or both are negative. On the other hand, and get a sign.
So just like , the Pauli string also splits the four-dimensional Hilbert space into two halves — only it does so in a different basis. So if I had a told you that a state satisfies either or , you could have guessed what basis vectors is composed of.
But now let us do something more interesting. What if we require that both and are satisfied ?
From the first equation, we know that has to be a linear combination of and . From the second, we know that it has to be a linear combination of and . So what kind of state could possibly satisfy both conditions at once ?
Try the state .
Applying clearly leaves it unchanged. And applying simply swaps and , which again leaves the total state unchanged. So satisfies both equations.
Interestingly, if we write exactly the same state in the Hadamard basis, it can also be written as . This might initially look slightly suspicious — in one basis the state is built from and , while in another it is built from and .
But that is exactly the point. The state itself has not changed. Only the basis we used to describe it have.
And here something rather nice has happened. The individual condition described a whole family of states. The individual condition also described a whole family. But requiring both simultaneously leaves us with exactly one unique state.
I will leave it as an exercise to convince yourself that there is no other two-qubit state satisfying both equations.
We could also have changed the signs. For example, we could ask for a state satisfying and . Or perhaps and . I leave it as an exercise for you to find states that would satisfy these constraints.
Now what in the world does any of this have to do with efficiently representing a quantum state?
Well, normally the state would be stored as a statevector containing complex entries.
But we just discovered that there is another way to specify it uniquely by using the Pauli string that constraints them. Instead of storing the statevector, we can simply store the two Pauli strings and , and say describe the state as a state that satisfies the two constraints.
And this idea generalizes. Given an -qubit state , if we manage to find independent, mutually commuting Pauli strings such that each satisfies , then those equations uniquely identify the state .
We call these stabilizing equations, the Pauli strings are called stabilizer generators, and is called a stabilizer state. The set of Pauli strings that we can make by taking the products of the stabilizer generators is called the stabilizer group of the state, in practise it is common to just mention the generators and the group can then be assumed to be generated from those generators.
The advantage should now be apparent.
Instead of storing a -sized vector of complex numbers, we store only Pauli strings.And from the previous section we know that each Pauli string itself can be represented by a bit string of size . So instead of an exponentially large description, we need only order bits, together with the signs. That is a rather dramatic discount.
I did however lie to you slightly. We cannot just pick any Pauli strings satisfying these equations. They need to obey two important conditions.
First, they should be independent.
Suppose and . Then automatically their product also satisfies .
So from only two pieces of information I can manufacture a third equation for free and thus it does not add in adding constraints on the state that was not conveyed by the other two.To avoid counting such fake extra information, none of our chosen generators should be obtainable as a product of the others.
Second — and more importantly — all the stabilizer generators must commute.
There is a very quantum-mechanical reason for this. If two Pauli strings and both satisfy and , then they cannot anticommute.
I leave the prove as an exercise (because I have to justify calling this an interactive blog somehow). Start by assuming and plugging that information in the two stabilizing equations.
Its worth noting that the fact two anticommuting Pauli strings cannot satisfy this relations is cloesly related to the Hisenberg uncertainty princeiple. But that’s a story for another day — or you ask ChatGPT.
Can you guess the stabilizers?
For the following states, can you guess their stabilizer generators?
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
Choose an overall phase and one Pauli operator per qubit.
About measurements
So we have learnt that a way of using Pauli strings to describe certain quantum states. Can we as well use Pauli strings to describe measurements ?
Previously we talked about a measurement of quantum state as asking the probability of observing it on either of the basis states. For example, we given a state has some probability of being in or . But how can we use a Pauli string to talk about measurements ?
To see this recall that the operators is known to satisfy and . Thus the question of whether is on or can be translated to whether the maps the state to itself or its negative.
Mathematically, measuring the on the state can be described as the scalar . This is the same as evolving the state with and then taking the inner product of with . If you do the computation, you will get a scalar function of and . But what does this scalar represent?
If the two outcome probabilities are and , then
Since , this also means
We can think of the Pauli string as a random variable, which takes the value when and the value when . Then the scalar can be thought of as the expectation value of the random variable. For an arbitrary state, this expectation is somewhere between .
For instance, if you take , then the expectation will be , which implies that the measurement yields always, since the state is in . For , we get the expectation to be since the state is in . But other than these two extremes, the expectation will be a function of the coefficients, since the state has non-zero probability of being in either or .
As an exercise, try figuring out what measuring the operator on the state might mean. You would like to start by changing the computational basis to the Hadamard basis: .
But how does this idea generalize when we have more than one qubit?
Let us try the Bell state . Can we compute the expectation of the Pauli string ?
It is apparent that any state that is a linear combination of satisfies , whereas those that are linear combinations of satisfy .
Now seems to be a state that is a linear combination of basis states from the positive and negative side of the Hilbert space as seen by . In this particular case, since the weight on each side is equal, the expectation of is .
Now what about the expectation value of ? You might find it easy to answer, since you know that this Pauli string is actually a stabilizer of the state, so the whole state lies on the positive side of the Hilbert space as seen by and consequently the expectation value is . You can prove it by computing yourself.
This idea generalizes for any -qubit system, although explicitly computing the expectation might require more effort if you proceed by looking at each of the basis vectors a state is composed of.
From the previous discussion, we learned that corresponding to any Pauli string there is a choice of basis such that half of the states stay the same when acted upon by , and the other half gets a sign.
The expectation of the Pauli string on the state , i.e. , gives us a measure of the overlap of the state with the basis vectors corresponding to the positive and negative side of the Hilbert space as seen by .
For example, if the state satisfies , it is easy to see that the expectation of is ; similarly it is when is satisfied. For all other cases it is somewhere between , depending on the degree of overlap on each side of the Hilbert space.
One case of interest is when the state has equal total probability weight in the and eigenspaces of , in which case the expectation is zero.
If we write , where the two components lie in the eigenspaces of , then
However, there is one question to ask. We already learned that using the stabilizing equations we can represent stabilizer states using just their stabilizer generators without storing all the amplitudes in any chosen basis, but can we then directly use the stabilizing equations to answer the question about the expectation values of a Pauli string without inspecting the state directly? As we will see later, we indeed can.
Pauli strings : or how to rotate the state
So far we have covered the state and the measurements. Now what about the unitary?
A brief note here: this part will require us to take exponentials of matrices. In case you are not familiar with this, 3Blue1Brown has a very nice video explaining what a matrix exponential actually means.
Given a Pauli string , we can construct a unitary operation by exponentiating it as . We will call this a Pauli rotation.
And because every Pauli string satisfies , the exponential takes a particularly simple form:
So although is technically a matrix exponential, which is again a matrix of size , we really only need two things to describe it: the Pauli string , which requires bits to describe, and the angle , which is a float.
Let us first see what one of these rotations actually does.
We know that the operator acting on flips it to . So if we apply the Pauli rotation generated by , we obtain .
So rather than completely flipping into , the Pauli rotation creates a weighted combination of the two, where the weights depend on the angle . At nothing happens. At other angles we gradually move away from . At we obtain , which is the usual gate up to an irrelevant global phase.
The same idea works for multi-qubit Pauli strings. For example, start with and apply the rotation generated by . Since , we obtain
And of course we can apply one Pauli rotation after the other, as to build more complicated unitaries.
How Pauli rotation affects the superposition?
Start by choosing the initial state and the rotation generator. See how the distribution over the computational basis states changes.
The useful fact is that, up to an overall global phase, arbitrary unitaries can be built from sequences of Pauli rotations. I will leave the details of such decompositions out of this blog — partly because that is another interesting story by itself, and partly because at some point this blog has to end.
So instead of thinking of a unitary as on enormous matrix, we can think of it as a sequence of Pauli rotations
where every is simply a Pauli string and every is a number. From the point of view of classical storage this is already rather convenient since instead of an exponentially sized matrix you are storing sized bitstrings and float values.
Now, if I insist on describing a completely arbitrary -qubit unitary this way, I might still require exponentially many Pauli rotations. And exponentially many Pauli strings and floats is as good as exponentially many entires of a matrix, ie its too big to be stored on your computer. But most quantum computations of practical relevance are given by circuits containing only polynomially many Pauli rotations which is rather tractable.
As a side note, this way of thinking about unitaries is particularly common when one is doing quantum machine learning since the angles give something tunable much like the parameters in a nueral-network, but more of it later — I have already made enough promises for one blog.
What Did We Learn so far ?
Let us take stock of where we are. We started with three things that seemed rather unpleasant to describe classically: the state, the unitary, and the measurement.
For certain states called the stabilizer states, we learnt that instead of storing amplitudes, we can store Pauli strings whose stabilizing equations uniquely identify the state. And similarly we learnt how we can use Pauli strings to describe measurements. And for unitaries, we have now seen that instead of storing an enormous matrix we can describe the evolution as a sequence of Pauli rotations, each specified by a Pauli string and an angle.
So for the class of quantum computations we are interested in, our classical description starts looking much less terrifying. Instead of constantly carrying around exponentially large vectors and matrices, we are carrying around things like : bit strings representing Pauli operators, floating-point numbers representing rotation angles.
So if all you wanted to do was describe the quantum computation — for instance to send the instructions to a quantum computer at your friend’s place — things are looking pretty good : You do not need to upload a matrix describing the complete unitary and then grow old watching the progress bar.
But unfortunately this still does not solve the problem I promised to solve at the beginning of the blog. We wanted to actually simulate the quantum computation on our laptop. And compactly describing a computation is not the same thing as efficiently simulating it. That distinction is important.
Recall that to simulate we would need not only a classically efficient way to represent the state and the unitary , but as well to compute the updates state efficiently, as well compute the measurement outcome probabilities. And the representation above would be of no use if we need turn them back into exponentially large matrices to do this step.
Even if I store the state using stabilizers and store the unitary as a sequence of Pauli rotations, I still need some way of updating my efficient description of the state after application of unitary.
What we would really like is something stronger: Can we perform the computation directly using the Pauli-strings themselve ? If we can do that efficiently, then we genuinely have a classical simulation. Which is what I will describe in the next section.
Pretending to do quantum computation in your classical computer
Simulating the evolution
Let us start with the part of evolving the state. Suppose is a stabilizer state and is one of its stabilizers, so .
Now suppose we apply some unitary to the state. The new state is . What stabilizes this new state ? A bit of calculation shows, that is the answer :
This is potentially good news. Remember, our stabilizer generators already uniquely identify the state. So rather than evolving an exponentially large statevector, perhaps we can simply evolve each of its stabilizer generators under the unitary and keep track of them ? Since the generators specified the state uniquely before the evolution, the evolved generators must specify the state state uniquely after the evolution.
That would be a great idea, no ? Unfortunately, there’s a problem, even though the stabiblizers specify the state uniquely the stabilizers themselves are not simple Pauli strings anymore.
Let us try with an example. Take again our old friend, the Bell state: , which we know is stabilized by and .
Now apply the Pauli rotation , and we want to know the stabilizer of the evolved state .
For a general stabilizer , the updated stabilizer under a Pauli rotation is given by:
where we used and for convenience. Observe that when the generator and the stabilizer commute, i.e. , the evolved stabilizer is simply .
Now for our case, the stabilizer remains unchanged because it commutes with the rotation generator . The stabilizer becomes .
So the state is stabilzied by the . And there is our first problem. Before the rotation, the stabilizer was one Pauli string. After a generic rotation, it has become a weighted sum of two Pauli strings. That is no longer something we can represent using one neat -bit Pauli string.
This example is actually rather mild: only one of the two generators branched. But the general problem is already visible.
Every time we apply another a Pauli rotation, every stabilizer generator that anticommutes with the generator of that rotation can splits into two Pauli strings, and tracking the stabilizer now require tracking both these Pauli strings.
So schematically the Pauli strings that we need to track might grow like :
So after applying such Pauli rotations, in the worst case we could therefore need as many as Pauli terms. If grows with the system size, this need not be polynomial; for example, if , the number of terms can grow as . We have therefore walked straight back into an exponential overhead.
Very nice. We escaped the enormous statevector only to rebuild something enormous out of Pauli strings instead. Quantum mechanics: very considerate.
So we need one more trick. Can we put some restrictions on the Pauli rotations so that when we evolve a stabilizer, it remains a single Pauli string rather than splitting into a sums of many ?. Turns out we can.
And the answer is hiding inside the angle . Recall that when anticommutes with , the evolved stabilizer is . Usually both coefficients are non-zero, which is what creates the troublesome sum. But consider what happens if we restrict to integer multiples of :
For , we trivially get back.
For , the cosine vanishes and we get simply .
For , the sine vanishes and we get .
For , the cosine again vanishes and we get .
And because and are Pauli strings, is itself another Pauli string.
So in every one of these cases, conjugation by the unitary amounts to turning one Pauli string to another Pauli string.
(Here note that we will need to store the sign as well, but again storing a sign is something you can do classically, without much overhead needed)
How many Pauli strings do we need to keep track of ?
We evolve the Bell state using Pauli rotations, aim is to track how the number of Pauli strings in the stabilizers evolve.
The initial stabilizers are . You can choose the generator of the Pauli rotation and the angle of the rotation. And it will show how the Pauli strings in the stabilzier branch under the rotation.
Things to look out for :
Can you try to see how the commutation between the stabilizers and generators of the rotation play a role in the branching ?
Does choosing certain values of the angles suddenly reduce the branching ? Try multiples of .
Evolving the stabilizer through Pauli rotations
Try to guess how the stabilizers of the state evolve through the Pauli rotations. The stabilizer generators of the initial state are given, and the circuit is made up of Pauli rotations with the angles set to multiples of . Guessing correctly the stabilizers after one Pauli rotation unlocks the next round.
Why it works
Row-by-row update
And also if commutes with , life is even easier: remains unchanged for any angle.
So by restricting ourselves to Pauli rotations whose angles are multiples of , something remarkable happens: Pauli strings remain Pauli strings throughout the evolution.
More generally, this kind of unitaries that map Pauli operators to Pauli operators under conjugation, i.e for every Pauli operator , is also a Pauli string, are collectively called Clifford unitaries.
So generalizing the observation from this example. Given the initial stabilizer state, which is represented by independent stabilizer generators.
After the first Clifford unitary, we still have exactly Pauli stabilizer generators. After the second Clifford unitary, still and even after a thousand Clifford unitaries — still . There is no exponential branching. Instead, every Clifford unitary merely updates the Pauli strings we are tracking.
And because we know how to represent Pauli strings as bit strings and compute their commutation and multiplication using binary arithmetic, we can perform those updates directly on the classical representation. Importantly, we never needed to construct the -component statevector. This is precisely the kind of thing we were looking for.
We started with a class of quantum state that though looked exponentially large could be represented by a small collection of Pauli strings, and have now found a class of unitary operations under which that compact representation remains compact.
But there is still one last hurdle. A quantum computation does not consist only of evolving states. Eventually we have to measure something, and we want a classicallly efficient means of getting the outcome probabilities.
So for this to become a complete classical simulator, we need to show that Pauli measurements can also be carried out — i.e computation of the measurement probabilities as well as the post-measurement state — using nothing more than the Pauli string manipulations.
Fortunately, we have already done most of the conceptual work needed for that. We already know that a Pauli measurement on a given state means conceptually, all we need is to see if we can do it directly on the stabilizer generators that we were tracking.
And that is exactly what we will do next.
Simulating the measurement
Recall how we interpreted a Pauli measurement earlier.
A Pauli measurement produces one of the two outcomes . Its expectation value summarizes the corresponding probability distribution and tells us the imbalance between the and eigenspaces of .
The whole aim now is to be able to estimate the expectation value directly from the stabilizers of the state themselves without needing to inspect the statevector of the state.
From what we established already previously, measuring a Pauli string that is a stabilizer of the state, i.e. satisfies , will always lead to a expectation. Similarly a Pauli string that satisfies will always lead to a expectation.
But what happens when does not satisfy either of the relations ?
For instance previously we showed that making a measurement on the Bell state leads to a expectation. But we computerd that by explicitly looking at the expansion of the state into basis vectors and the stabilizers of the state.
Here we make the observation that the state Pauli string anticommutes with one of the stabilizers but commutes with .
Now by using the expression for the expectation, we can observe that:
which can only be true when . Here we used the property of anticommutation between and .
Note that this would hold true for any Pauli string as long as it anticommutes with one of the stabilizer generators of the state.
Thus, collecting the two observations: if a Pauli string (up to an overall sign) belongs to the stabilizer group of the state, then for the Bell state case any that can be expressed as a product of and up to an overall sign has expectation always . And if anticommutes with at least one of the generators, it has expectation .
Because the only possible outcomes of a Pauli measurement are and , an expectation value of zero implies
and therefore
Could there be any other kind of Pauli string that does something different? For a pure stabilizer state described by independent generators, there is no third case. Every Pauli string is either, up to an overall sign, contained in the stabilizer group, or it anticommutes with at least one of the stabilizer generators.
So computing the expectation of a Pauli measurement has become a rather small decision problem.
Given the Pauli string that we want to measure:
- if belongs to the stabilizer group, then ;
- if belongs to the stabilizer group, then ;
- otherwise anticommutes with at least one stabilizer generator, and .
There is one important detail in the first two cases. Saying that belongs to the stabilizer group does not mean that has to appear explicitly in the particular list of generators we stored. It may instead be obtained by multiplying some of those generators together.
Computationally, we can first check the commutation signature . If any entry is , the expectation is immediately . If all entries are , then for a pure stabilizer state must agree, up to sign, with an element of the stabilizer group, and we determine that sign from the generators. All of this requires only polynomial-time operations on Pauli strings.
Let us try all three possibilities. Rather than introducing yet another quantum state, we can reuse the final stabilizer state from the Clifford simulation exercise above:
For each Pauli measurement below, try to decide which of the three cases it belongs to without reconstructing the statevector.
Measure the final Clifford state
The circuit is complete. Use only its final stabilizer generators to predict the expectation of each Pauli measurement.
Compare the measured Pauli directly with the three final stabilizer generators.
This Pauli is not listed directly. Remember that products of generators also belong to the stabilizer group.
Check the commutation of this Pauli with each final stabilizer generator.
Hint: Pauli-string multiplication table
Use the single-qubit products independently on each wire, keeping the phase factors.
The three probes required three slightly different kinds of reasoning.
For , the answer was visible immediately: it is one of the stored generators, so its expectation is .
For , the answer was not written directly in the generator list. But multiplying two of the stored stabilizers gives
so belongs to the stabilizer group and therefore .
Finally, anticommutes with , so its expectation is , corresponding to a distribution over the two possible measurement outcomes.
So we now know how to obtain the measurement probabilities classically using only the stabilizer description.
But what about the post-measurement state?
In the initial example we saw how making a measurement forced the state to be in one of the basis states. But in those cases we computed the post-measurement state explicitly from the statevector description and not from the stabilizers.
Like measuring the state in the basis leads to turning the state into either or depending on the measurement outcome. But can we do something similar directly using the stabilizers of the state?
It turns out there is indeed a way. A Pauli measurement on a stabilizer state turns into a different stabilizer state, and how these stabilizer states look can be derived using an easy analogy.
Recall what happened in the simplest measurement example from earlier.
Suppose we had a single-qubit state and measured it in the computational basis. If the outcome was , then the post-measurement state became . In particular, if we immediately performed the same measurement again, we would now obtain with certainty.
The same idea can be expressed using Pauli strings. Measuring in the computational basis is the same as measuring : the outcome corresponds to the side and the outcome corresponds to the side. So if we measure and obtain the outcome , the resulting state must satisfy .
In other words, after obtaining the outcome , has become a stabilizer of the post-measurement state. Similarly, if the outcome was , then the resulting state must satisfy , or equivalently is now a stabilizer of the state.
This observation generalizes immediately. If we measure any Pauli string and obtain an outcome , then after the measurement the state must lie entirely on the corresponding side of the Hilbert-space split made by . Therefore the post-measurement state satisfies , which simply means that must be one of its stabilizers.
Let us see what this means for our Bell-state example. Before measuring , the state was stabilized by and .
We already know that measuring gives either or with equal probability, because anticommutes with the stabilizer , giving the overall measurement expectation to be zero.
Suppose our measurement gives the outcome . Then must stabilize the post-measurement state. At the same time, the old stabilizer cannot remain: it anticommutes with , and two anticommuting Pauli strings cannot both stabilize the same state.
So we replace by the newly learned stabilizer , while keeping the commuting stabilizer . The new stabilizer description is therefore . These two conditions uniquely describe : tells us that the first qubit is , while tells us that the two qubits have the same computational-basis value.
If instead the measurement outcome was , the newly learned stabilizer is , giving , which uniquely describes .
So we have recovered exactly the same post-measurement states as before, but this time without ever inspecting the amplitudes of the Bell state.
The general update rule is only slightly more involved. Suppose we measure a Pauli string and obtain outcome . If the measurement was already deterministic, then was already contained in the stabilizer group, so there is nothing to update.
Otherwise, choose one stabilizer generator that anticommutes with . Replace by the newly learned stabilizer . If any other stabilizer generator also anticommutes with , replace it by first. Since both and anticommute with , their product commutes with , so all the remaining generators are compatible with the newly added stabilizer.
And that is all we need. A Pauli measurement on a stabilizer state can be simulated by computing commutation relations, classically sampling a outcome when necessary, and updating a small collection of Pauli strings. Once again, no exponentially large statevector is required.
Big picture of a small class of computation
So, just like I promised near the beginning of the blog, we have finally found a class of quantum computations that can be simulated efficiently on an ordinary classical computer.
Let us collect exactly what we have shown.
Given a stabilizer state, a Clifford unitary, and Pauli measurements, we can:
- Store the state as a set of Pauli strings, where each Pauli string is a bitstring of size .
- Compute the state evolution by evolving each Pauli string describing the state through the Clifford unitary.
- Compute the expectation values of the Pauli measurements as well as the post-measurement state of the evolved state.
All of this would only require storing and manipulating the Pauli strings as required by the operation. At no point do we need to construct or manipulate the exponentially large statevector. And that, essentially, is the computational engine behind the Gottesman–Knill theorem. There are some details and variations that I have swept under the rug — but the important idea is exactly what we have developed here.
So we can now return to the question in the title: But how quantum is the computation?
At least for this particular class of computation, perhaps not as quantum as it first appeared. The computation may involve entangled states, quantum gates, and measurements, and yet its behaviour can still be reproduced efficiently on a classical computer. Now are they practically useful? No, not in the way you might think. The fact that you can simulate them implies that this particular class of computation has no quantum advantage — by which it is not worth making a quantum computer to run this kind of computation.
But then why must we study them? The answer most suitable here is that the set of techniques, along with the more sophisticated counterparts they inspired, allows you to understand when a given quantum computation will actually require a quantum computer. For instance, a legitimate research question (which is part of my research interests) is to find clever means by which you can separate the parts of the quantum computation that would actually require a quantum computer from those that can be simulated by classical means quite efficiently. In such a setting the question “How quantum is the computation?” has an operational meaning, often referring to the amount of quantum resource you would actually require for the computation, and coming up with novel ways of answering it is a core part of current research.
Moreover, the above techniques have been well studied for quantum error correction, and if you are already aware of 3Blue1Brown’s video on Hamming codes then you might find it interesting to investigate if they have any possible connection to stabilizer states. To give you a hint --- they lead to stabilizer codes, but we will talk about it another time.
That ends this blog. I leave you with this puzzle that appears very often in my PhD:
Variational Circuits
The input state is fixed at , and is then followed by four Pauli rotations. On the final state we make three Pauli measurements. You can try tuning those angles—by tuning the dials or entering the angles—which will change the corresponding probabilities of the measurement outcomes. Circuits like this arise in quantum machine-learning problems, where the aim is to find the right parameter settings so that the expectation value of the Pauli measurements equals a certain value.
Things to try:
Can you try spotting a Pauli rotation which does not affect the measurement outcomes for all possible values of the angle?
Can you find an angle setting that maximizes the expectation of and minimizes the expectation of at the same time? How would you do the parameter optimization?
Live Pauli readout
Outcome probabilities
Inspect amplitudes
The simulator keeps this four-entry statevector only to make the demonstration exact.