I keep reading (e.g. Nielsen and Chuang, 2010; pg. 456 and 465) the following three phases; "code space", "code word" and "stabilizer code" - but am having a difficult time finding definitions of them and more importantly how they differ from one another.

My question is therefore; how are these three terms defined and how are they related?


3 Answers 3


Code spaces and code-words

A quantum error correcting code is often identified with the code-space (Nielsen & Chuang certainly seem to do so). The code space $\mathcal C$ of e.g. an $n$-qubit quantum error correction code is a vector subspace $\mathcal C \subseteq \mathcal H_2^{\otimes n}$.

A code word (terminology which was borrowed from the classical theory of error correction) is a state $\lvert \psi \rangle \in \mathcal C$ for some code-space: that is, it is a state which encodes some data.

Quantum error correction codes

In practice, we demand some non-trivial properties to hold of a quantum error correction code, such as:

  • That $\mathop{\mathrm{dim}} \mathcal C \geqslant 2$, so that there is a non-zero amount of information being encoded;
  • That there are a set $\mathcal E = \{ E_1, E_2, \ldots \}$ of at least two operators including the operator $E_1 = \mathbb 1$, such that — if $P$ is the orthogonal projector onto $\mathcal C$ — we have $$P E_j E_k P = \alpha_{j,k} P$$ for some scalars $\alpha_{j,k}$ (known as the Knill–Laflamme conditions).

This determines some set of error operators against which you can in principle protect a state $\lvert \psi \rangle \in \mathcal C$, in that if the Knill–Laflamme conditions hold of a set of operators $\mathcal E$, and some operator $E \in \mathcal E$ acts on your state, it is possible in principle to detect the fact that $E$ has occurred (as opposed to some other operator in $\mathcal E$) and undo the error, without disrupting the data stored in the original state $\lvert \psi \rangle$.

A quantum error correction code is a code-space $\mathcal C$, together with a set of error operators $\mathcal E$ which satisfy the Knill–Laflamme conditions — that is, a quantum error correcting code must specify which errors it is meant to protect against.

Why it is common to identify quantum error correcting codes with their code-spaces

You cannot determine a unique set $\mathcal E$ of operators which satisfy the Knill–Laflamme conditions from the code-space $\mathcal C$ alone. However, it is most common to consider which low-weight operators (ones which act only on a small number of qubits) can be simultaneosuly corrected by a code, and to an extent this can be derived from the code-space alone. The code distance of a code space $\mathcal C$ is the smallest number of qubits that you have to act on, to transform one "code-word" $\lvert \psi \rangle \in \mathcal C$ into a distinct codeword $\lvert \psi' \rangle \in \mathcal C$. If we then describe a code-space as being a $[\![n,k,d]\!]$ code, this then says that $\mathcal C \subseteq \mathcal H_2^{\otimes n}$ has dimension $2^k$, and that the set $\mathcal E$ that we consider is the set of all Pauli operators with weight at most $\lfloor (d{-}1)/2 \rfloor$.

In some cases, describing a code as an $[\![n,k,d]\!]$ code is enough. For instance, the 5-qubit code is a $[\![5,1,3]\!]$ code, and it is possible to show that five qubits cannot encode a single qubit in such a way that any other errors can be corrected in addition to all of the single-qubit errors. However, the same is not true of the Steane $[\![7,1,3]\!]$ code, which can protect against any single-qubit Pauli error as well as some (but not all) two-qubit Pauli errors. Which two-qubit Pauli errors you should protect against depends on what your error model is; and if your noise is symmetric and independently distributed, it won't matter very much what you choose (so that you will likely make the conventional choice of any single $X$ error together with any single $Z$ error). It is however a choice, and one which will guide how you protect your data against noise.

Stabiliser codes

A stabiliser code is a quantum error correction code determined by a set $\mathscr S$ of stabiliser generators, which are Pauli operators which commute with one another, and which define a code-space $\mathcal C$ by the intersection of their +1-eigenspaces. (It is often useful to consider the stabiliser group $\mathcal G$ formed by products of $P \in \mathscr S$.)

Almost all quantum error correction codes that people consider in practise are stabiliser codes. This is one reason why you may have problems distinguishing the two terms. However, we do not require that a quantum error correction code be a stabiliser code — just as in principle we do not require a classical error correction code to be a linear code. Stabiliser codes just happen to be an extremely successful way of describing quantum error correcting codes, just as linear error correcting codes are an extremely successful way of describing classical error correcting codes. And indeed, stabiliser codes can be regarded as a natural generalisation of the theory of classical linear codes to quantum error correction.

As people are often interested just in low-weight operators which are less than half the code distance, the set of stabilisers is often all people say about an stabiliser correction code. However, to specify the set of errors $\mathcal E$ against which the code can protect, it is necessary also to specify a relationship $\sigma$ between Pauli product operators $E$ and subsets $S \subseteq \mathscr S$, such that

  • $E$ anticommutes with $P \in \mathscr S$ if and only if $P \in S$ for $\sigma(E,S)$;
  • If $E, E'$ both satisfy $\sigma(E,S)$ and $\sigma(E',S)$, then $E E' \in \mathcal G = \langle \mathscr S \rangle$.

This defines a set $$\mathcal E = \bigl\{ E \mathbin{\big\vert} \exists S \subseteq \mathscr S: \sigma(E,S) \bigr\}$$ of errors against which the code can protect. The subsets $S \subseteq \mathscr S$ are called error syndromes, and the relation which I've called $\sigma$ here (which you don't usually see given an explicit name) associates syndromes to one or more errors which 'cause' that syndrome, and whose effects on the code are equivalent.

'Syndromes' represent information that can actually be obtained about an error by 'coherent measurement' — that is, by measuring operators $P \in \mathscr S$ as observables (a process which is usually simulated by eigenvalue estimation). An error $E$ 'causes' a syndrome $S \subseteq \mathscr S$ if, for any code-word $\lvert \psi \rangle \in \mathcal C$, the state $E \lvert \psi \rangle$ is in the $-1$ eigenspace of all operators $P \in S$, and in the $+1$-eigenspace of all other operators in $\mathscr S$. (This property is directly related to the anticommutation of $E$ with all of the elements of $S \subseteq \mathscr S$, and only those elements.)

  • $\begingroup$ In your second paragraph you say that a code word is a state in $\mathcal{C}$ i.e. a state which encodes some data. Are you saying what the other answers seems to be saying - i.e. the codewords are those states we associate with e.g. logical $\lvert 0 \rangle$ and $\lvert 1 \rangle$. Or that more generally any state in $\mathcal{C}$ are called code words? $\endgroup$ Apr 18, 2018 at 3:51
  • 2
    $\begingroup$ The terminology can vary a little bit. For example, you read Gottesman’s thesis, and he talks about a code word being any valid state in the code space, and he distinguishes ‘basis code words’ as the logical 0 and 1. $\endgroup$
    – DaftWullie
    Apr 18, 2018 at 5:32
  • 1
    $\begingroup$ @QuantumSpaghettification: as DaftWullie suggests, I mean any state in $\mathcal C $. It is very often a mistake to be too preoccupied with the standard basis. Historically, it was easiest to describe a QECC in reference to the span of two particular states and to describe the correcting properties in terms of those two states. The theory of stabiliser codes makes this sort of description unnecessary, and allows you to be flexible with what the logical reference frame is, so it is better now to avoid defining things in a way that emphasises the standard basis. $\endgroup$ Apr 18, 2018 at 7:46
  • $\begingroup$ @NieldeBeaudrap Sorry to come back to this post over a month later. Am I correct in saying that the mapping $\mu$ may be one-to-many if the effect of the error on the "basis code words" is degenerate. I am thinking phase flips on Shor's code. $\endgroup$ May 29, 2018 at 14:40
  • 1
    $\begingroup$ My answer above is, possibly, an old-fashioned presentation. People might well want to identify the two 'codes' you describe above, because they are related by a very simple isomorphism, and indeed would involve a very similar procedure to maintain. Indeed, the notion of a Pauli frame essentially is the idea that you can have a single 'code', and that eigenvalues are extra (but important) information. It's likely that this is an example of a concept whose definition may undergo a change as we find a more refined and practically-motivated way to describe it. $\endgroup$ Jul 7, 2022 at 19:38

A code word (for a quantum code) is a quantum state that is typically associated with a state in the logical basis. So, you’ll have some state $|\psi_0\rangle$ that corresponds to the 0 state of the qubit to be encoded (you don’t have to use qubits, but you probably are), and you’ll have another that’s $|\psi_1\rangle$ that corresponds to the 1 state of the qubit to be encoded.

The code space is the space spanned by the code words, i.e. the entire space $\alpha|\psi_0\rangle+\beta|\psi_1\rangle$ for all possible $\alpha$ and $\beta$ (normalised).

A stabilizer code is one possible formalism for telling you how to work out the code words and therefore the code space. For an [[n,k,d]] code, you are given n-k stabilizer operators $S$ ($S^2=\mathbb{I}$) that mutually commute, and act on n qubits. Any state $|\psi\rangle$ in the code space satisfies $S|\psi\rangle=|\psi\rangle$. You will further have operators $Z_m$ and $X_m$ for $m=1,\ldots k$ that all commute with the stabilizers $S$ but pairwise anticommute, $\{Z_m,X_m\}=0$, for matching subscripts. These define the Logical Pauli operators for the code, and the code words are therefore the states that satisfy $Z_m|\psi\rangle=\pm|\psi\rangle$.


In a quantum error correcting code, you store a number of logical qubits, $k$, in a state of many physical qubits, $n$.

A code word is a state of the physical qubits that is associated with a specific logical state. So, for example, however you store the $|0\rangle$ state for one of your logical qubits is a code word.

The code space is the Hilbert space spanned by all possible code words. For a stabilizer code, this term is synonymous with the stabilizer space. Any state within this code space is a code word

A stabilizer code is a quantum error correcting code described by the stabilizer formalism. The stabilizer space is defined as the mutual $+1$ eigenspace of $n-k$ mutually commuting and independent tensor products of Pauli operators.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.