# Initialization of surface code into a logical state

I read this nice answer about how to initialize a surface code into a logical state but have a basic question about it.

If I take a surface code patch with all physical qubits in the $$\vert 0\rangle$$ state and then measure the $$XXXX$$ stabilizers as well as boundary $$XX$$ stabilizers, I will get a list of $$\pm 1$$ measurement outcomes. I store these outcomes somewhere. I define the current state of my surface code to be $$\vert \Psi\rangle = \vert 0\rangle_L$$. Any changes in future stabilizer measurement cycles tell me what physical qubits need to be corrected to go back to $$\vert 0\rangle_L$$.

But I can repeat the argument in the paragraph above but just assume after the first round of stabilizer measurements that my surface code encodes $$\vert \Psi\rangle = \vert 1\rangle_L$$ instead. Or more generally, I could assume it is in the state $$\vert \Psi\rangle = \sqrt{\alpha}\vert 0\rangle_L + e^{i\phi}\sqrt{1-\alpha}\vert 1\rangle_L$$. The future rounds of stabilizer measurements then tell me what error happened on $$\vert \Psi\rangle$$ and how to correct them.

Isn't initializing the surface code into a desired logical state a trivial operation due to the freedom we have in choosing which logical qubit corresponds to which physical state? I guess I am missing something but where does this way of doing things go wrong?

Related question: When I initialize a surface code in Stim, what logical state is it in?

circ = stim.Circuit.generated(
"surface_code:rotated_memory_z",
distance=3,
rounds=1)


just assume after the first round of stabilizer measurements that my surface code encodes $$\vert \Psi\rangle = \vert 1\rangle_L$$ instead. Or more generally, I could assume it is in the state $$\vert \Psi\rangle = \sqrt{\alpha}\vert 0\rangle_L + e^{i\phi}\sqrt{1-\alpha}\vert 1\rangle_L$$

You can't just freely assert the state is whatever you want; not in any useful sense. An analogy would be... there are 24 rotational symmetries of a cube. Looking at a cube from some weird angle may make it look like you can get at some new state beyond these 24, but the rotational symmetry group still only has 24 entries. They're just being looked at from a different perspective.

More concretely: the surface code can implement Clifford gates using lattice surgery. Given Clifford gates, adding the ability to prepare $$|T\rangle$$ state is sufficient to achieve universal computation. Describing your states in a basis that makes it look like they are T states doesn't achieve universal computation. You're just describing Clifford gates in a basis that makes it hard to see that they are Clifford gates, so it's not universal.

If you only have horizontal (0°) polarizing filters, turning your head x° clockwise may make it look like you can have a x° polarizing filter, but it doesn't fix the fact that you only have one type of filter. And it's the limitation on the number of types that you have that's the actual relevant restriction.

There are ways in which you can usefully play with the concept of "what basis am I tracking?" in surface codes. Pauli gates can be tracked entirely classically, so in fact you're right that for the specific case of $$\vert \Psi\rangle = \vert 1\rangle_L$$ vs $$\vert \Psi\rangle = \vert 0\rangle_L$$ that you can do the same operations on the quantum computer (and account for the difference entirely in the classical control system). The Clifford frame tracking done in game of surface codes is another example of playing with this concept. But these techniques are more than just tilting your head; they have physical consequences for what happens in the control system (for Pauli frame tracking) and on the quantum computer (for Clifford frame tracking).

Basically: okay, great, you've picked a basis where your ground state is $$\vert \Psi\rangle = \sqrt{\alpha}\vert 0\rangle_L + e^{i\phi}\sqrt{1-\alpha}\vert 1\rangle_L$$. But now how do you prepare $$|0\rangle$$ in that basis? If I ask you to provide me with a computer program that takes 1 bit of input and produces a surface code preparing $$|0\rangle$$ if that bit was false or else $$\vert \Psi\rangle = \sqrt{\alpha}\vert 0\rangle_L + e^{i\phi}\sqrt{1-\alpha}\vert 1\rangle_L$$ if that bit was true, you can't just play basis choice games. The two outputs can't be the same circuit, because they need to prepare different states. When I repeatedly run the circuit returned by the program, and append a transversal Z measurement to it, I had better see an expectation of 0% for the $$|0\rangle$$ state and of $$1-\alpha$$ for the $$\sqrt{\alpha}\vert 0\rangle_L + e^{i\phi}\sqrt{1-\alpha}\vert 1\rangle_L$$ state. And that won't happen if you're just playing basis games.

• Thank you for the answer. Two clarifications: What are the set of logical states $S$ of the surface code that I can reach purely with Pauli frame tracking? In Stim, when I initialize a patch of surface code as in the code of the question, am in one of the states of $S$ and I have the freedom to pick which one (provided I keep track of this for future operations)? Commented Mar 29 at 12:44
• @user1936752 For a single surface code patch in a stabilizer state, you can only reach two distinct states by Pauli tracking (like 0 and 1 for Z init, or + and 0 for X init). For more general states there's up to four states. Commented Mar 29 at 13:12
• Did you mean + and - for the X initialization in that last comment? Thanks! Commented Mar 29 at 15:24
• Oops yes that was a typo Commented Mar 29 at 17:37