Why do magic state consumption circuits work?

The following circuits from Litinski's Magic State Distillation paper are two ways to consume magic states. Why do these circuits work? I've heard there's a relationship with the Choi-Jamiolkowski isomorphism but can't understand the relationship.

1 Answer

First, note that you can phase a qubit by preparing an ancilla equal to it and phasing the ancilla:

You can pick $$\theta=1/4$$ to get a T gate. And because the bottom qubit is being discarded, you can do whatever you want with it without affecting the equality, such as doing a Hadamard and then measuring because why not:

You can then commute the CX through the H turning the CX into a CZ, and apply the deferred measurement principle to get it past the measurement:

Now we're going to use a type of analysis I call "getting the case where all measurements return False to do the right thing, and then fixing the rest later". This is also sometimes called "the ZX calculus" in more specialized contexts. Basically we replace measurement with postselection so we can analyze one case instead of all cases.

Anyways, define the symbol $$\approx$$ to mean "equal assuming all measurements return False". To avoid confusing measurement and postselection I will draw a measurement-assumed-to-return-False as "<0|". The identity above then simplifies, because the feedback only mattered in the case where the measurement returned True:

We can now fold the T and H into the measurement to produce a T basis postselection "<T|":

One of the great things about this kind of analysis is that postselection is the time reverse of preparation. We can mirror the circuit and still get the same result:

Turning the postselection back into a measurement, we have to check what's going on in the case where the output is True instead of False. It turns out that now the output is off by an S gate, instead of a Z gate, so we throw that in:

You can turn this basic circuit into the one from Daniel's paper by generalizing $$Z^\theta$$ into $$P^\theta$$ where $$P$$ is a product of Paulis instead of a single qubit's Z axis. Also you need to rewrite the S gate onto an ancilla in the same way we just rewrite the T gate onto an ancilla, and rearrange that a bit, in order to end up at the way he's doing the fixup.

So, in summary, the way you find these circuits is by doing manipulations while only worrying about the all-measurements-0 case. Then it tends to be much easier to solve the feedback needed to make the other measurement cases behave the same way as the all-0 case. By applying this technique several times in a row, you can produce some surprising results.

Once you have one of these results, you can separately confirm it works by grinding through what happens to the state vector in each case.

• Overall, would you recommend learning ZX calculus to get intuition of "why" Litinsky's circuit work? Or it wont help much (right now I am "brute force" checking all his equalityies which does not give intuition at all) Commented Aug 31, 2023 at 8:45
• @MarcoFellous-Asiani Yes you should learn the ZX calculus. You can understand these equalities without it, but it helps. And also it's pretty useful in that way in a lot of places. Commented Aug 31, 2023 at 18:06