Encoder Circuit For Surface Code using Measurement-Based Quantum Computing Model
Abstract
Surface codes are one of the most important topological stabilizer codes in the theory of quantum error correction. In this paper, we provide an efficient way to obtain surface codes through Measurement-based quantum computation (MBQC) using cluster state as the resource state. Simple two-dimensional surface codes are studied and analyzed using stabilizer formalism. We also present an algorithm to computationally obtain the stabilizer of the surface codes, through which we later determine the distance of the codes. We note the difference in the stabilizers of the surface codes obtained by Fowler et al. [1] wherein they used CNOT entangling operation to create the resource state as opposed to the cluster state which is formed using CZ entangling operation. We provide a theoretical calculation to understand this difference. The obtained surface codes can be used practically as an encoder circuit to encode one logical qubit.
Keywords— surface code, quantum error correction, measurement-based quantum computation, MBQC.
1 Introduction
Quantum information theory [2] is a rapidly growing field with the potential to revolutionize computing and cryptography. It offers the prospect of speeding up computational tasks like factorization [3] and database searching [4], which may be beyond the capabilities of present-day classical computers. However, building a large-scale, reliable quantum computer that can perform practical computations remains a significant challenge. This challenge arises from the complex interactions and correlations between quantum systems, which form the fundamental building blocks of such devices, and their surrounding environment.
These quantum devices rely on entanglement as a core mechanism for interactions. However, the entanglement that mediates these interactions is susceptible to various environmental influences, leading to unwanted errors during computation. Unlike classical information, quantum information is highly fragile and easily corrupted by noise and other sources of interference. For instance, in classical communication, we send a stream of bits (0s and 1s) through a classical channel, where some bits may flip due to noise (i.e., from 0 to 1 or from 1 to 0). Similarly, in quantum communication [5], we send qubits (represented as |0⟩ and |1⟩) through a quantum channel, which also preserves the quantum coherence of the system. In this case, errors can manifest as bit flips, phase changes (, the relative phase between the qubits), or a combination of both. For example, we may encounter the following errors:
(1) | ||||
To protect quantum information against such errors, the field of quantum error correction [6] plays a critical role. Quantum error correction involves developing codes capable of detecting and correcting errors in devices of interest by encoding the information-carrying quantum states into a larger quantum system and using measurements to detect and correct errors. The surface code [1] is one such family of quantum error-correcting codes that can protect quantum information against a wide range of errors. It is based on the principle of stabilizer codes [7]. The surface code consists of a two-dimensional lattice of qubits, where each qubit is connected to its four nearest neighbors (assuming a square lattice). The code works by measuring the parity of sets of qubits, known as stabilizers, which form closed loops on the lattice. By repeatedly measuring these stabilizers, errors can be detected and corrected without destroying the quantum information. The encoder circuit for the surface code typically involves connecting or entangling qubits using CNOT gates, which aligns with a gate-based model of computation. In this entangling scheme, control and target qubits are defined based on the measurement pattern followed by a set of qubits called measure qubits in surface codes. The code can correct any single-qubit error and any two-qubit error involving two adjacent lattice qubits. It is desirable because it is relatively simple to implement and can correct multiple errors simultaneously.
Our work proposes a different encoder scheme for implementing such a circuit by employing the resource state used in the measurement-based quantum computation model. In this model, the traditional quantum circuit is replaced by a quantum state called a cluster state, which is prepared by entangling multiple qubits through Ising-type interactions [8]. Computation is performed by measuring individual qubits in a specific order and using the measurement outcomes to guide the computation. This model enables fault-tolerant quantum computing schemes [9] with significantly high error thresholds [10].
In this paper, we aim to study the circuit required to implement surface code computation using a cluster-based MBQC scheme. We begin by introducing different definitions involved in the field of quantum error correction, along with the stabilizer formalism, in Section 2. This foundation will enable us to explore quantum error-correcting principles effectively. In Section 3, we delve into the theoretical background of measurement-based quantum computation, providing a comprehensive understanding of how measuring a qubit in the cluster state can control the necessary operations in this computational model. Moving forward, Section 4 provides an overview of existing surface code implementation schemes that utilize CNOT entangling operations. It briefly describes the operations involved in implementing such a circuit. Building upon the various concepts discussed in the previous section, we introduce an encoder circuit for implementing similar surface code operations using the measurement-based model in Section 5. Implementing the surface code using a different scheme involves encoding the quantum information into a large cluster state, followed by an ordered measurement to detect and correct errors. To achieve this, we present an algorithm to realize the stabilizer evolution of our encoder circuit for the surface code and define the stabilizer generators of such a circuit. We implement the algorithm and study the stabilizer evolution of our 3x3 and 5x5 cluster states as examples. We demonstrate the contrast in stabilizer evolution between our 3x3 cluster state with CZ operation and one entangled by CNOT gates. Furthermore, we provide a theoretical study to explain the reason for such a contrast. Finally, we explore the stabilizer evolution of a 5x5 cluster state and define the logical operators and distance of such a circuit to further investigate its error-correcting properties.
Notation
X, Y, Z | Measurement in , , and respectively |
---|---|
XL | Logical X-Operator |
ZL | Logical Z-Operator |
Hadamard Gate | |
Set of all errors | |
CZ | diag(1,1,1,-1) |
CZij | CZ operation between and qubit |
Pauli Groups acting on qubits | |
Cyclic Group of Order 2 containing elements {0,1} | |
Stabilizer Group | |
Normalizer Group of | |
Eigenspace corresponding to | |
Elements in but outside of | |
Quotient Group | |
Measurement Array | |
Cluster state | |
Stabilizer of node in a cluster state |
2 Quantum Error Correction
Quantum error correction (QEC) is a procedure to protect the quantum information from unwanted environmental noise [11][12]. QEC forms one of the most important aspects of quantum computation, and we can safely say that quantum computers would be of no practical use without QEC. Among all the unwanted noise encountered in quantum computation the most prevalent and difficult to correct is decoherence [13]. In decoherence, due to the interaction between the environment and the quantum device, quantum information gets nonlocally correlated with the environment. Practically, that means loss of quantum information. Errors due to decoherence degrade the quantum information quickly and render a quantum computer useless. Apart from decoherence, qubit flip and phase error also occurs during quantum computation. Qubit flip error corresponds to applying an X-quantum gate on the state written in the computational basis states and . It is analogous to bit flip error in classical error correction. Qubit phase error introduces a relative phase of between the basis states of the qubit and corresponds to applying a Z-quantum gate on the state. From quantum mechanics, we know that, unlike the global phase, relative phases are important as they change the state, and hence the probability density, of the system. There is no analog of phase errors in classical error correction.
2.1 Difficulties faced while correcting quantum errors
The first complication we face while correcting quantum errors is that there is no way to protect the quantum information by making extra copies of it, as done in classical coding schemes. No-cloning theorem prohibits making a copy of the qubit thus making quantum error correction difficult to implement.
The second complication is that quantum computers are susceptible to both bit ()-flip and phase ()-flip errors. We should be able to correct both errors simultaneously. But since there is no classical analog of phase flip errors it is hard to devise a quantum error correcting code that allows us to achieve simultaneous correction of both - and -errors.
The last complication is due to the fact that we cannot measure qubits without losing quantum information. The problem of wavefunction collapse due to measurement renders quantum error correction hard to achieve as we would not be able to detect and correct errors without measuring the qubits. We will see in the later sections how stabilizer formalism allows us to overcome this complication.
2.2 Quantum error-correcting codes
Despite the obstacles, it turns out that quantum error correction is possible. Quantum error-correcting codes (QECC) can be viewed as a mapping from qubits to qubits, that is, it maps a Hilbert space of dimensions to a Hilbert space of dimensions. The extra qubits allow us to store the information stored in the logical qubits in a redundant manner, thereby protecting it from errors. The basic principles required to construct a QECC are: 1) To construct a code it is necessary to have an idea of the errors that we want to correct; 2) The principle of redundant information is used in QECC. If a part of the resource is damaged by errors, the logical qubit can still be accurately recovered from the rest of the redundant qubits.
We already saw in the previous section the types of errors that may occur in quantum computation. One of the four possible things can happen to the qubit: nothing (), qubit flip (), phase flip (), or both (). In an -qubit Hilbert space, the evolution of qubit can be expanded in terms of the operators . Thus, we can express the action of a unitary operator () on n-qubits and their environment as
(2) |
where are the -qubit Pauli operator, runs over all possible combinations of and are the states of the environment. Some important properties of the Pauli group are:
-
•
Each element of is unitary.
-
•
; or
-
•
Any two elements either commute, i.e., , or anticommute, i.e., .
To understand how to construct a QECC we will first define some important quantities:
Definition 1: Each Pauli operator can be assigned a weight which is an integer with ; the weight is the number of qubits acted upon by non-trivial Pauli operators, that is , , and . For example, let us look at some Pauli operators acting on a 4-qubit Hilbert space
(3) | |||
Using this definition we see that if we are able to devise a QECC that can identify a subset whose elements have weight , then that QECC can correct errors.
Definition 2: Choose a subgroup which satisfies . Such a subgroup defines an eigenspace . This space is called code subspace. Basis vectors of code subspace are protected from errors. Important properties of code subspace are:
-
•
If the subgroup has generators, then the space has dimensions.
-
•
Any operator is a stabilizer of any state , that is
(4)
This is why these QECCs are also called stabilizer codes. We will construct QECC in such a way that it is capable of correcting errors which anti-commutes with operators from the group . Therefore, if and , then for we will have
(5) | ||||
We see that if the eigenvalue of the operator is -1 then the state is affected by the error . Therefore, when constructing a QECC we must proceed as follows: 1) Determine the error operators that we want to correct; 2) From all the possible Pauli operators, choose those which commute with themselves and at the same time anti-commute with the error operators.
Now, a necessary and sufficient condition that must be satisfied by code subspace to make QECC work [14] is,
(6) |
Here, and are two codewords that belong to , and and are two different errors that we want to correct. Equation 6 is also known as the Knill-Laflamme error correction condition. In simple words, the above condition means that different errors should affect states differently. If two different errors change the state in the same way then there is no way to distinguish which error occurred and hence one cannot correct it too. To get a better understanding see Appendix 8.1 where we have explained, using a simple example, how quantum error correcting codes are devised.
2.3 General Stabilizer Codes
Definition 3: Let be the stabilizer group and be the corresponding QECC, then we define [7] the normalizer of in as
(7) |
Now, if we have an error then our QECC will not be able to detect this error. This is because the eigenvalue of when operated with remains +1.
Furthermore, errors in are not really errors per se, because they leave the encoded state unchanged. This means that our QECC will detect all errors that are either in or anticommuting with some element of , that is . In simple words, we can say that QECC only detects errors that are outside of .
Definition 4: The distance of is the weight of the smallest Pauli operator in .
A stabilizer code with distance will correct errors, or in other words, any QECC that corrects errors has distance 2+1. We can also think of the distance of QECC in the following way: If we look at a subset of qubits, then no information is revealed about the encoded state, that is, the reduced density matrix tells nothing about the relative phases; hence the superposition persists.
Logical operators belong to the normalizer set . Fowler et al. [1] defined the distance of the surface code as the minimum number of physical qubit bit-flips or phase-flips needed to define a logical or operator. We will look into this more deeply in Section 4.2
Definition 5: To define the error syndrome for a stabilizer code, let
(8) |
Then , where are the generators of , is a ()-bit binary number. Note that can have different values. Two different errors and have the same error syndrome if they commute with the same set of generators of . Then, this would mean that . The error syndrome can distinguish different errors if . Further, if then and act in the same way on the codeword. Hence, there is no need to distinguish them. Therefore, we can conclude that the QECC corrects errors for which for all pairs . From this condition, we can see how the distance of QECC is . If our QECC corrects errors the product can act on at most 2 qubits. Since to correct the errors must be outside , we will have the weight of smallest Pauli operator in , which is defined as the distance, as 2+1. Now, in order to perform an error correction operation, all we need to do is measure the eigenvalue of each generator of the stabilizer. For a non-degenerate code, error syndrome will be different for different errors and hence will exactly tell which error to correct. Unlike a non-degenerate code, for a degenerate code, there exist pairs of errors that have the same error syndrome. This occurs if has elements of weight less than distance .
We know that elements of commute with elements of the , in fact, lies inside . This means moves codewords around within , and hence we can interpret it as encoded operations on the codewords. Only elements in acts non-trivially on . Here, is the quotient or factor group, which is the set of cosets of in , and is defined as
(9) |
Note that we can only define quotient group when is an invariant subgroup of . This is precisely the case here as, by definition, commutes with every element of , and hence the right cosets () will be the same as left cosets (). It is possible to show that this group is a Pauli group with size . Putting these considerations together we can define an automorphism . We will write Xi and Zi, where , as the encoded/logical operators. Xi maps to X in and Zi maps to Z in .
3 Measurement Based Quantum Computation
Measurement-based quantum computation (MBQC), which originated from the pioneering work of Raussendorf and Briegel [15], is a technique to perform quantum computation using only local measurements. The central physical ingredient of MBQC is the cluster state [16]. It is a special type of entangled state that allows for quantum computation using only one-qubit projective measurements. This scheme is also called the "one-way quantum computer" (1WQC) because the entanglement in the cluster state is destroyed by the one-qubit measurements and therefore it can only be used once. Before we go into the details, let us have a general picture of how 1WQC works.
The first step to 1WQC is to form the cluster state. Figure 1 shows a 2d cluster state. A cluster state can be created efficiently in any system using Ising-type interaction at very low temperatures. Next, we write the information onto the cluster through entanglement. Then, we apply local one-qubit measurements on the cluster state qubits to process the information. The processed information is then read out. We see that cluster state provides in advance all entanglement that is involved in the subsequent quantum computation. It is important, at this stage, to distinguish between cluster qubits and logical qubits. The logical qubits constitute the quantum information being processed, and cluster qubits are the qubits that form the cluster state. Measurements in the X - (and Y) basis propagate the quantum information through the circuit i.e., they act as a wire, and measurement in Z-basis removes the respective qubit from the cluster (Section 3.2). The processing is finished once all qubits except the last one on each wire have been measured. The remaining unmeasured qubits form the quantum register which is then read out. Results of previous measurements determine in which basis the output qubits need to be measured for the final readout.

3.1 Cluster States
The most important ingredient of MBQC is the cluster state. Cluster state is a special type of entangled state that allows for universal quantum computation using local measurement [17]. A 2 cluster state, as shown in Figure 1, can be thought of as a blank slate upon which we can draw the quantum circuit using local measurements. Cluster states are a particular case of graph states. For a particular graph = (, E), where are the vertices and edges; we use the following algorithm to generate cluster states: 1) To each vertex we associate the qubit ; 2) Next all the pairs of neighboring qubits are entangled by the CZ operation which is defined as
(10) |
As a result, we can write the cluster state as
(11) |
The cluster state satisfies the following set of eigenvalue equations
(12) |
where is the set of neighbouring vertices of vertex . Also, . We define
(13) |
as the stabilizers of the cluster state. We notice that stabilizers corresponding to different sites commute with each other. This means there exist a set of common eigenstates. All the eigenstates form a group and every one of them is equally good for computation. Eigenstates within this group with the same set of eigenvalues form an equivalence class. There are such equivalence classes corresponding to every eigenvalue sets . We can choose any one of the equivalence classes and select any one element from it as its representative. such representatives from every equivalence class forms the ||-qubit Hilbert space. Note that elements of the equivalence class are orthogonal to each other [18].
There are essentially two ways to create a cluster state. The first way is to measure all the stabilizers given in Equation 13 for on an arbitrary -qubit state or to cool into the ground state of the Hamiltonian . A more practical way is to first create a product state . Then we apply a unitary transformation , which is given as
(14) |
on the product state . has the form
(15) |
The condition in Equation 14 restricts the interaction of a qubit with only its nearest neighbors. Therefore, in dimension (), we will have , , and .
3.2 Removing redundant cluster qubits
There always exist qubits on the cluster state that are not needed in realizing a quantum circuit. We can remove these redundant qubits by measuring them in the basis. The resulting entangled state is again a cluster state. To see this we write the cluster state after measurement as a product of entangled quantum state on the cluster of the unmeasured qubits and product state on cluster of qubits which are measured. Therefore,
(16) |
where and are the results of the measurements. is the initial cluster state. We notice that we can also write as follows
(17) |
The term in the above equation is the projection operator corresponding to the measurements. Since satisfies Equation 12 we insert with in the r.h.s of the above equation between the projector and the state, and simplify it to obtain
(18) | ||||
with the new stabilizers of the remaining unmeasured qubits
(19) |
and the set specifying the eigenvalues
(20) |
To obtain the second equality in Equation 18 we used the fact that projection operator and correlation operator commute with each other as they act on different qubits. To obtain the last equality we apply on to get . The new correlation operators act only on the cluster qubits in and obey the following eigenvalue equations as can be seen from Equation 18
(21) |
The above equation proves that the residual state is again a cluster state. We also note that the measurement results of the removed qubits influence the process of computation. Since, any cluster state is equally good for computation we can put . The above analysis shows that we can discard the redundant qubits by measuring them in the basis.
3.3 Scheme to realize a gate on a cluster state
To implement a gate we take a cluster . We divide it into three sections; an input section , a body and an output section such that
(22) | ||||
The input qubits in are prepared in the state on which we need to apply the gate , while the qubits in are in the usual state. We entangle the qubits via the interaction given in equation 14. To realize the gate on the state appropriate measurements are applied to the qubits in . It was seen that apart from required operation corresponding to the gate obtained on the output qubits , we get an extra Pauli operation which depends on the measurement outcomes of the qubits measured in [18], that is,
(23) |
where
(24) |
Here, and denotes Pauli operator acting on the logical qubit and not the cluster qubits. The values are computed from the measurement outcomes .
Now, we define a theorem that provides a criterion describing the functioning of the gate in MBQC.
Theorem 1: Let be a cluster used to implement a unitary transformation corresponding to gate , and be the cluster state. Suppose the state obeys the 2 eigenvalue equations for the measurement pattern ,
(25) | ||||
with depends on the measurement outcomes of qubits in which are measured according to and . is the number of input qubits. We can, then, realize gate on the cluster state using Scheme 3.3 with measurement pattern described by , and the measurements of the qubits in being X measurement. After measurement, we can relate input and output states as
(26) |
where is the byproduct operator given by
(27) |
where is the measurement outcome of measurement performed on the .
In the next section, we have implemented the theory we have developed till now to implement surface codes on and cluster states. Before we start discussing our work we would like to state an important lemma that would be helpful during our discussion on stabilizer evolution in the later sections
Lemma 1 If are the stabilizers of a state then are the stabilizers of the state , where is an unitary operator.
4 Surface Code implementation
A surface code is a special type of stabilizer code. The idea behind surface codes is to encode information in "homological degrees of freedom" (See [19] and [20] to understand the topology of surface codes). See Appendix 8.3 for a brief introduction to homology. The surface code implementation, as done by Fowler et al. [1], utilizes an array of states initialized in the ground state (computational basis) followed by a patterned CNOT implementation based on whether a -measurement or -measurement takes place on the measure qubit. However, the work demonstrated in this paper follows a slightly different pattern as the qubits are initialized in the |+ state instead of the computational basis. The cluster of qubits initialized in such a manner is then entangled using the symmetric CZ gate instead of the previously mentioned CNOT which is not symmetric.
But before we discuss our work we will briefly talk about Fowler’s way of implementing surface codes. Figure 2 shows the surface code on a 2D array. Open circles represent data qubits and filled circles are the measurement qubits. The measurement qubits, essentially, are used to stabilize and manipulate the quantum state of the data qubits. There are two types of measurement qubits: ‘measure-Z’ qubits (colored green), and ‘measure-X’ qubits (colored orange). Each data qubit is coupled to two measure-Z qubits and two measure-X qubits, and each measurement qubit is coupled with four data qubits.

All the measurement qubits are initialized in ground state . Figure 2b and c show one complete cycle for measure-X and measure-Z qubits. After projective measurement of all measure qubits, the state of all data qubits simultaneously satisfies with eigenvalues , and with eigenvalues . The state is called the quiescent state. In Figure 2, there are 12 measure qubits. This means there are possible measurement outcomes. Corresponding to each outcome there will be quiescent state . We randomly select any one state from possible states after one complete cycle as shown in Figure 2b and c. Once selected the same state will be maintained by each subsequent cycle of the sequence unless an error occurs. This is because all the stabilizers commute with each other. The commutation relation of stabilizers with no common data qubits is trivial to show. Here we show the commutation relation of the stabilizers which have two common data qubits
(28) | ||||
We can visualize the 2D surface code given in Figure 2 as a set of data qubits on every edge of an embedded square lattice on the planar surface, and measure qubits on every vertex (face) and face (vertex) of the lattice (dual lattice).
4.1 Single qubit error detection and correction
Let us suppose that a bit-flip error occurs on one of the data qubits. The two adjacent measure-Z qubits will detect this because the sign of these measure-Z qubits will change. This will also change the quiescent state
(29) | ||||
(30) |
This shows that is an eigenstate of stabilizer but with an opposite sign. This will be more clear with the following example: Let us assume that a bit-flip error occurs on the data qubit. We select the quiescent state corresponding to the set , which has measurement outcomes of all the 12 measure qubits. Since, bit-flip error occurs on the data qubit, sign of the measurement outcome at and measure-Z qubits will change. Similarly, we can detect phase-flip errors. If instead of a bit-flip error on 7 data qubit a phase-flip error occurs then measurement outcome at and measure-X qubit will flip signs.
Now, to correct for the bit-flip we apply a second operator on the corrupted data qubit. The same can be done for the phase-flip errors where we apply on the data qubit to correct for the error. An issue with applying an extra gate operation for practical purposes is that we cannot obtain fidelity. This could introduce more errors in the surface code. Instead, the errors are corrected using a classical control software which changes the sign of measurement qubits that get flipped due to errors.
4.2 Logical Operators
A planar 2D surface code with a single boundary cannot encode any qubit. This is because all the possible 1-chains are homologically equivalent. Therefore, the first homology group will be isomorphic to the trivial group . Since it does not have any generators there will be no encoded qubit. It may seem that the surface code in Figure 2 can also not encode any qubit, but that is not the case. This is because it has two different kinds of boundaries. There is a boundary that terminates with measure-X qubits, which in literature is referred to as smooth boundary. The other boundary terminates with a measure-Z qubit, called rough boundary. Since there are two different types of boundaries the first homology group will be isomorphic to . Since has one generator, the surface code will encode 1 qubit. This can also be seen in Figure 3. It has 25 data qubits and 24 measure qubits, so there are degrees of freedom in the data qubits and constraints from the stabilizer measurements. The two unconstrained degrees of freedom act as a logical or encoded qubit [1][21].

We can now define logical operators that allow us to manipulate these additional degrees of freedom. Logical operators form closed 1-chain cycles. In Figure 3 operators (in blue) and (in red) show the two possible logical operators acting on the data qubits. We note that the product chain and is closed 1-cycles and homologically inequivalent (See Appendix 8.3 to read more on the homology of curves). They represent the two equivalence classes of . We can choose other chains of single qubit operator products to define different and . Consider for example the chain also shown in Figure 3. It can be easily seen that it is homologically equivalent to and hence belong to the same equivalence class (See the Section 8.4). Notice that we can write . The term in the parentheses is the stabilizer operator. Therefore, if we operate on a quiescent state with we will get the same state obtained when is applied on up to an overall phase. Hence, there is only one linearly independent operator for this array.
At first glance this result may seem mysterious; after all, if we operate on the array with a loop of operators corresponding to a stabilizer we are bit-flipping four data qubits so the state should be different from . The only way and are the same is if already contains the superposition of un-bit-flipped and bit-flipped data qubits. This is precisely how we define surface code. A surface code state is the superposition of all homologically equivalent cycles. A stabilizer loop like will only lead to homologically equivalent configurations. Look at Appendix 8.3 to get a mathematical perspective and intuitive understanding of the homology of curves.
Notice that the operator chain is in the dual lattice, which makes it a 1-cochain. Since in the dual lattice we have measure-X qubits (i.e., and are the basis states); the face stabilizer will be a loop of operators. So, we see that the same argument applies to the operator.
4.2.1 Creating logical qubits:
To increase the number of logical qubits we need to define more non-trivial homologically inequivalent cycles. An efficient way to do that is to create holes inside the boundaries of the array. This can be done in two ways: turn off measure-Z qubits or measure-X qubits.
When we create a hole inside the array by turning off a measure-Z qubit, we create additional two degrees of freedom or another logical qubit. This logical qubit is called a Z-cut qubit. The newly formed logical operator connects the array’s outer X-boundary with the internal X-boundary of the hole. The logical operator forms a loop (joining measure-X qubits) around the Z-cut hole. Note that this loop is not the stabilizer because it is not simply connected. It is clear that this hole/defect is in the dual basis, we call the single Z-cut qubit a smooth defect or a dual defect.
Analogously, we can define an X-cut qubit by turning off the measure-X qubit. Then operator is a chain of operators from the array Z boundary to the internal Z boundary created by turning off the measure-X qubit, and operator is a loop of bit-flips surrounding the X-cut hole. A single X-cut qubit is called a rough defect or a primal defect. We can create more logical qubits by making more holes within the boundaries of the array. See [1] for a more detailed explanation.
4.3 Distance of surface code
In this subsection, we are going to demonstrate a way of finding the distance of a surface code in reference to finding the logical operators and then using that to create a set of operators that commutes with the stabilizer generator which in technical language is termed as the centralizers of stabilizers generator. As discussed in Section 2.3, the minimum weight of the elements of the centralizer of the stabilizer generator would provide the distance of the code. We defined the logical operator by creating a chain of operators commute with our stabilizer generator. As seen above in a simple 2D surface code there are 2 homologically inequivalent 1-cycles and hence two logical operators and . Fowler et al. [1] defined the distance of a 2D surface code as the minimum weight of the logical operators. For simple geometries in which we can encode only one qubit.
5 Surface Code Implementation Using Cluster State
In the previous two sections, we discussed the concepts of surface codes and the measurement-based computation model utilizing cluster state generation separately. Now, in this section, we aim to explain whether we can study the stabilizer evolution and perform similar computations through a different initialization procedure that differs from the usual computational basis initialization of the qubit and CNOT entangling operation. To study a different initialization, we performed initialization of our qubits in the which was followed by the CZ entangling operator in order to prepare the initial surface code cluster state. Such a circuit is used to study the stabilizer evolution of the prepared state and a comparison is demonstrated with respect to the usual computation basis surface code circuit in this section. Regarding the initialization, compared to the CNOT entangling operation, the CZ entanglement being symmetric allows one the flexibility of not worrying about defining the control and target qubits involved in the process while entangling the qubits to form the cluster state on which the computation can be performed. In the study to provide a comparison along with other computations, we will discuss our work wherein we realized a surface code on and cluster states.
5.1 Realizing Stabilizer Evolution for a Surface Code
To investigate a surface code that captures our attention, we employ Algorithm 1, a modified version of the algorithm proposed by [22] for realizing stabilizer codes. This algorithm enables us to determine the ultimate stabilizer generator of the evolving cluster state. Subsequently, the cluster state undergoes a transformation using a suitable measurement pattern.
Algorithm 1 involves a meticulous selection process, wherein the stabilizer operator is carefully chosen to commute with every measurement operator during each
cycle specified by the measurement pattern. It depends on considering the cases of commutation relation between the evolving stabilizer generators (beginning from the initial cluster state generators) and the measurement pattern under consideration. At each cycle for an element of the measurement operator, we store the stabilizers in or depending on whether the element commute or anti commute with measurement operator respectively. If the anticommuting array () contains more than one element, we multiply the elements within themselves and append the new terms in the commuting array (i.e., in ) to get the final stabilizer generators corresponding to a particular measurement operator. We repeat the process for each element of the measurement array to get the final stabilizer for our cluster state. This ensures that the desired stabilizer generators commute within themselves and with the prescribed measurement patterns.
The algorithm is implemented using the AWS Braket platforms and requires the Qiskit libraries. The resulting stabilizer generators obtained from this implementation will be utilized in the subsequent subsections, with an aim to demonstrate and study the observed changes compared to the established CNOT implementation for 3×3 and 5×5 circuits.
5.2 Surface Code Using 3 3 Cluster State
In this section, we will conduct a comparable analysis on the stabilizer evolution of a 3×3 array of qubits, consisting of a cluster of 9 qubits, following a specific measurement pattern. This measurement pattern is an extension of the pattern utilized in the previous section. As illustrated in Figure 4, the measurement pattern involves Z-measurements on qubits and X-measurements on qubits . The resulting circuit, which will be used for subsequent computations, takes the following form:

5.2.1 Stabilizer Evolution of a 33 Surface Code:
On applying the algorithm to study the stabilizer evolution of the above-mentioned circuit with 5 data qubits and 4 measure qubits, as seen in Figure 4. We study the stabilizer evolution both for the CNOT entangled circuit and our CZ entangled circuit which can be seen in the following results:


The above results demonstrate a deviation between the different surface code initialization mentioned using CNOT and CZ operations respectively. Opposite indexing for and stabilizer is observed as a difference from the predecessor initialization which can be attributed to the fundamental Hadamard transformation incorporated in the theoretical framework as demonstrated in the next subsection demonstrating the theoretical calculation to support the results obtained.
5.2.2 Theoretical Background:
From Figure 4 we have , and . Let the state of the cluster be . Using Equation 13, we can write the following eigenvalue equations for :
(31) | |||
(32) | |||
(33) | |||
(34) | |||
(35) | |||
(36) | |||
(37) | |||
(38) | |||
(39) |
Since qubits 1 and 7 are measured in basis we can remove these qubits from the state. This is because we saw in Section 3.2 that qubits measured in do not affect the final outcome and hence can be removed. The remaining qubits are shown in Figure 7. Let the state of the remaining qubits be . It will satisfy the following set of cluster state eigenvalue equations:
(40) | |||
(41) | |||
(42) | |||
(43) | |||
(44) | |||
(45) | |||
(46) |

Using the above equations we can write the following two equations:
(47) | |||
(48) |
Now, by incorporating Theorem 1, we can say that we have to apply an additional Hadamard gate () on the output qubits (0,2,4,6,8) to get the correct surface code stabilizers.
5.3 Surface Code Using 55 Cluster State
In this section, we will perform a similar study of the stabilizer evolution of a cluster of 25 qubits stacked as a 55 array of qubits following a particular measurement pattern. As seen in Figure 8, the measurement pattern followed is an extension of the pattern with Z-measurement and X-measurement being performed on qubits and respectively, with the circuit to be considered taking the following form:

5.3.1 Stabilizer Evolution of a 55 Surface Code:
On applying the algorithm to study the stabilizer evolution of the above-mentioned circuit with 13 data qubits and 12 measure qubits, we obtain the following stabilizer evolution for our circuit:

On studying the corresponding indexes in Figure 9 of our independent stabilizer generator, a similar stabilizer evolution of different indexing is observed in this case as well. The opposite indexing of the stabilizer as compared to its equivalent CNOT implementation counterpart can be similarly explained by extending the theoretical background mentioned in the study of a 33 surface code.
5.3.2 Distance of a 5 Surface Code:
In this subsection, we are going to demonstrate a way of finding the distance of a surface code in reference to finding the logical operators and then using that to create a set of operators that commutes with the stabilizer generator which in technical language is termed as the centralizers of stabilizers generator. As discussed in Section 2.3, the minimum weight of the elements of the centralizer of the stabilizer generator would provide the distance of the code. We defined the logical operator by creating a chain of operators commute with our stabilizer generator. In the process, we make an observation that the chain of Pauli Operators that constitutes the logical operators also follow similar opposite indexing of Z-logical and X-logical operators in a similar fashion as the stabilizer generators of our surface codes which can be attributed once again to the fundamental Hadamard transformation involved in the theoretical background of our cluster state formulation. Taking care of the opposite indexing, creating the logical operators (the first three elements in the centralizer array below corresponds to the X, Z, and Y logical operator respectively), and performing multiplications of logical operators and stabilizer generators gives us our required element of the centralizers of the stabilizer along with the corresponding weight which is helpful to find the distance of the code, as demonstrated below:

As seen from Figure 10, the distance of the code is 3, which implies that our 5x5 surface code can be denoted as . With such a code of distance 3, we can hope to correct 1 error. Such a structure provides the smallest structure which can be used as an error-correcting code for future consideration of the study. The work demonstrates how one using such an initialization of a surface code structure can result in just the opposite indexing of the stabilizer generator which can be taken care of by using a suitable Hadamard transformation while providing easier initialization to our CNOT entangled cluster state.
6 Discussion
In this paper, we proposed a way to create surface codes using cluster state as the resource. We noted that the cluster state, formed using the CZ operation, gives an advantage over the entangled state formed using the CNOT operation. This is primarily because the CZ operation is symmetric and does not differentiate between the control and target qubits. Another benefit of using cluster states was that it is practically easy to create in the lab. The unitary interaction, in Equation 14, corresponds to an Ising-type interaction that can be realized via controlled collisions in optical lattices [15]. This means that the temporal resources required to create a cluster state are independent of the size of the cluster. Once the cluster states are obtained we applied MBQC to get the desired surface code.
We presented an algorithm to obtain the stabilizers of the surface codes. Stabilizer formalism plays a central role in all of quantum information specifically in fault-tolerant quantum computation. We only analyzed simple 2D square-shaped surface code structures mainly 33 and 55. With the help of stabilizers, we were able to obtain the distance. The geometry of our surface codes only allowed two homologically inequivalent logical operators; hence, we could only encode one logical qubit irrespective of the number of physical qubits. We noted that the distance of the surface code can be written as a function of as . We further saw that the 33 surface is of no practical use as it cannot correct any quantum error. But 55 can be used to correct one type of error in the encoded logical qubit. From our analysis, we can see that MBQC provides an efficient mechanism to create surface codes. These surface codes can then be used as an encoder circuit to encode one or more than one logical qubit depending on the topology and structure of the surface code.
7 Acknowledgement
We thank MeitY QCAL for their generous financial support, which made this research possible. Dr. A.R. thanks the IISER-B for the startup fund for the same. We would also like to acknowledge Mr. Mehul Chakraborty’s contributions to the discussions during the project’s initial phase.
8 Appendix
8.1 3 qubit code
Now, let’s see how we can devise a 3-qubit stabilizer code using the method discussed in Section 2.2. We know that in 3 qubit code three physical qubits are used to encode one logical qubit, hence and . Qubit flip errors in one qubit are described by the following error operators
(49) |
We select from all the three-qubit Pauli operators elements that commute with themselves and anti-commute with elements of in Equation 49. We will obtain the following set of stabilizers
(50) |
Any 2 elements of form the generator of the set. Therefore the code subspace has dimensions 2 and has the eigenstates
(51) | |||
8.2 5 qubit code
Table 1 shows the stabilizer group generators for a five-qubit code. Since no. of generators is 4, i.e., , we have . Consider an error . This error commutes with all the generators. Therefore, . We will see that this is the smallest error that is undetectable; hence this code has distance . One can also note that this is a perfect code; it means that all the possible single-qubit errors (16 in this case) exhaust all the possible error syndromes (also 16). In Table 1, X and Z define the encoded bit-flip and phase-flip operators respectively. Now, using the stabilizer group we can define the basis for the code subspace
(52) | ||||
X | Z | Z | Z | I | |
I | X | Z | Z | X | |
X | I | X | Z | Z | |
Z | X | I | X | Z | |
X | X | X | X | X | |
Z | Z | Z | Z | Z |
8.3 Homology of curves
Homology is a branch of topology that is most relevant for topological codes. Topological codes can be formulated and understood almost entirely in homological terms. Homology is the mathematical field that abstracts and generalizes the notion of boundary. In this work, we will limit our study to homology on the group . We will see that there is a topological invariant called the first homology group of the surface which is essential in making topological codes [20].
8.3.1 homology
Consider a particular lattice embedded in the surface. We write vertices as 0-cells, edges as 1-cells, and faces as 2-cells. We will associate an element from the group with each -cell, with =0,1,2 for our case. The group is the simplest non-trivial group. It has two elements and is isomorphic to the set of integers with group composition given by addition modulo 2. For example, if we label edges as we can represent any set of edges as
(53) |
A sum of this form is called a 1-chain. Given any set of edges we can represent 1-chain by substituting each element in by 1 and the rest of the elements by 0. One such example is shown in Figure 11.

We can add two 1-chains via bit-wise modulo 2 addition to produce another 1-chain (See Figure 12). We can easily see that 1-chain forms an abelian group under component-wise addition modulo 2. We denote this group by where is the number of edges. This means that is the direct product of done times. The order of the group is . Further, we identify independent generators of the group by associating a generator with each edge. We place 1 on the edge associated with a specific generator and 0 on every other edge. This procedure gives us generators, also called edge generators. Similarly, we can form the group of 0-chains and the group of 2-chains . One can also visualize as vector spaces with group generators being one set of basis elements .

8.3.2 Boundary operators
We introduce a family of group homomorphisms called boundary operators or maps. As the name suggests, takes objects to their boundaries. We define a homomorphism such that:
(54) |
(2-boundary operator/map) maps a set of faces to a set of edges that forms its boundary. (1-boundary operator/map) maps a set of edges to a set of vertices where an odd number of edges meet. We can define 0-boundary operator as a map that takes every 0-chain to null chain, i.e., . Null chain is sometimes referred to as 1-chain.
8.3.3 Cycles
We define a subgroup which is a group of 1-chains that have no boundary, that is , the kernel of . Elements of are also called 1-cycle. Generally, an -cycle is an -chain with a null boundary. The group of -cycles is labeled as . Now, a crucial observation is that all boundaries are also cycles. We define a subgroup which is a group of 1-chains that are a boundary of a 2-chain , i.e., or for some . This means that
(55) |
8.4 Homological Equivalence
Two -chains are homologically equivalent if they are equal up to composition with an -boundary. This means if two chains and are homologically equivalent, then there exists a ()-chain such that
(56) |
Fig 13 shows two homologically equivalent 1-chains.

8.5 Homology group
If two chains are homologically equivalent then they share the same boundary but the reverse is not always true, that is, not all chains with the same boundary are homologically equivalent. Homological equivalence partitions the subgroup of chains with a given boundary into equivalence classes. Since cycles are the chains with null boundary it can be partitioned under homological equivalence. We define a quotient group by partitioning into equivalence classes under composition with elements of as
(57) |
From algebraic topology, we know that the properties of the homology group depend only on the topology of the surface it is defined. The first homology group, up to isomorphisms, can be written as
(58) |
The elements of are cosets of the form for some .
References
References
- [1] Austin G. Fowler, Matteo Mariantoni, John M. Martinis, and Andrew N. Cleland. Surface codes: Towards practical large-scale quantum computation. Physical Review A, 86(3), sep 2012.
- [2] Michael A Nielsen and Isaac L Chuang. Quantum computation and quantum information. Phys. Today, 54(2):60, 2001.
- [3] Peter W Shor. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM review, 41(2):303–332, 1999.
- [4] Lov K Grover. A fast quantum mechanical algorithm for database search. In Proceedings of the twenty-eighth annual ACM symposium on Theory of computing, pages 212–219, 1996.
- [5] Nicolas Gisin and Rob Thew. Quantum communication. Nat. Photonics, 1:165–171, March 2007.
- [6] Joschka Roffe. Quantum error correction: an introductory guide. Contemporary Physics, 60(3):226–245, 2019.
- [7] Daniel Gottesman. Stabilizer codes and quantum error correction, 1997.
- [8] H. J. Briegel, D. E. Browne, W. Dür, R. Raussendorf, and M. Van den Nest. Measurement-based quantum computation. Nat. Phys., 5:19–26, January 2009.
- [9] R. Raussendorf, J. Harrington, and K. Goyal. A fault-tolerant one-way quantum computer. arXiv, October 2005.
- [10] Robert Raussendorf and Jim Harrington. Fault-tolerant quantum computation with high threshold in two dimensions. Phys. Rev. Lett., 98:190504, May 2007.
- [11] Frank Gaitan. Quantum error correction and fault tolerant quantum computing. CRC Press, 2008.
- [12] Dieter Suter and Gonzalo A Álvarez. Colloquium: Protecting quantum information against environmental noise. Reviews of Modern Physics, 88(4):041001, 2016.
- [13] Maximilian Schlosshauer. Decoherence and Quantum Computing, pages 293–328. Springer Berlin Heidelberg, Berlin, Heidelberg, 2007.
- [14] Emanuel Knill and Raymond Laflamme. Theory of quantum error-correcting codes. Physical Review A, 55(2):900, 1997.
- [15] Robert Raussendorf and Hans J Briegel. A one-way quantum computer. Physical Review Letters, 86(22):5188, 2001.
- [16] Hans J Briegel and Robert Raussendorf. Persistent entanglement in arrays of interacting particles. Physical Review Letters, 86(5):910, 2001.
- [17] Robert Raussendorf and Tzu-Chieh Wei. Quantum computation by local measurement. arXiv preprint arXiv:1208.0041, 2012.
- [18] Robert Raussendorf, Daniel E Browne, and Hans J Briegel. Measurement-based quantum computation on cluster states. Physical review A, 68(2):022312, 2003.
- [19] Héctor Bombín. An introduction to topological quantum codes. arXiv preprint arXiv:1311.0277, 2013.
- [20] Dan Browne. Toplological codes and computation, 2014.
- [21] Eric Dennis, Alexei Kitaev, Andrew Landahl, and John Preskill. Topological quantum memory. Journal of Mathematical Physics, 43(9):4452–4505, 2002.
- [22] Swayangprabha Shaw, Harsh Gupta, Shahid Mehraj Shah, and Ankur Raina. Construction of non-css quantum codes using measurements on cluster states, 2023.