# How is Magic State Distillation (MSD) compatible with Stabiliser Measurement?

Suppose I have the rotated surface code in which I want to inject a $$T$$-state. What I don't get it is: suppose we do end up with the logical state $$|0_L\rangle+e^{i\pi/4}|1_L\rangle$$, then we must still measure stabiliser outcomes to chart an error history at the end of the quantum error correction experiment. However, stabilisation projects the logical state back onto eigenstates of $$X$$ and $$Z$$-stabilisers simultaneously. So we destroy the state, don't we?

In general, how are magic states injected into an error correction code preserved, and how are the errors occurring on that state mapped and corrected?

• Could you please clarify your starting situation? Is your T-state already encoded in a surface code or something else? $\left| 0_L \right\rangle$ and $\left| 1_L \right\rangle$ are by definition already eigenstates of the $X$ and $Z$-stabilizers so the logical state wouldn't be destroyed by measuring them.
– AG47
Apr 8 at 13:20
• Yes, the state is already encoded in the surface code, we just want to measure stabilisers now to make sure that after some finite time $\delta t$, we are still in the same state. $|0\rangle_L+e^{i\pi / 4}|1\rangle$ is not a simultaneous eigenstate of $X$ and $Z$. Apr 9 at 8:59
• Then I am failing to see how the magic state context is relevant here. You seem to be confused about how a stabilizer code can preserve any logical state $\alpha \left|0_L\right\rangle + \beta \left|1_L\right\rangle$. I am doubling down on what I said: a $T$-state is an eigenstate of all the $X$ and $Z$ stabilizers of the code. However, it is neither an eigenstate of the $X$ nor $Z$ logical operator of the code. This is not a problem, because you never measure the logical state of the code for error correction purposes, only the stabilizers, and you never collapse the state doing so.
– AG47
Apr 9 at 11:35
• I see, I must have been utterly confused. The point is that the logical wavefunction is highly entangled and thus hard to fault-tolerantly manipulate, and that only for a select number of operations, such as X-gates or Hadamard gates, you can implement these with transversal operations. For the T-gate you cannot do this, however you can still get a logical T-state through MSD, and the stabilisers will still tell you how errors have occurred throughout the code. Am I correct saying this? Does this also work then for arbitrary rotational $R_Z(\theta)$-gates? Apr 12 at 7:31
• Yes, this is correct. The tricky part is to get the magic state encoded into the code through MSD, but once it is in there, things are no more difficult than for any other logical state regarding errors. If you come up with a specific MSD protocol for them, this will be true for any $R_Z(\theta)$ (and others). This seminal paper on MSD also found a $R_Z(\pi/6)$ but I know some people distills $CCZ$ magic states. The main goal is to get a state that cannot be reached through Clifford gates (i.e. with $H$ + $R_Z(\pi/2)$ + $CZ$) to achieve universal QC.
– AG47
Apr 12 at 8:35

EDIT: Where I was wrong was thinking that somehow, because the T-gate cannot be transversally implemented, that this would disrupt stabiliser outcomes. They don't. Stabilisers can still be entangled and measured out repeatedly to chart out an error history. The only thing magic state distillation does is inject a state into a code that cannot be implemented through transversal means. For some reason, I mistakenly thought this was incompatible with stabiliser measurent because $$[X,T]\neq 0$$, but this is not true.