Quantum information is highly susceptible to various sources of error, including decoherence, environmental noise, and imperfect operations. One effective way to protect quantum data, which is similar to classical error correction, is to encode a single qubit into a larger entangled state across multiple physical qubits. This redundancy allows local errors, which affect only some of the qubits, to be detected and corrected without disturbing the underlying logical information. Steane's code is one of the well known quantum correction code, famous for its evolution from the classical
A valid logical state is a superposition of the states in the code space, which is spanned by two orthonormal logical basis states,
The logical basis state
where I used a spreadsheet to illustrate how to obtain the codewords using the stabilizers.
Procedures are as followed:
-
Write down the parity-check matrix
$H$ of the Hamming code. -
Create all 128 basis states
$\left|x\right\rangle$ of a 7-qubit. -
Get the dot products
$H\cdot x$ for all$x$ . -
The
$x$ with zero dot products, i.e.$(0, 0, 0)^T$ , are in the code space. -
In addition, the
$\left|x\right\rangle$ with zero dot products AND with even number of 1s are the logical basis states of$|0_L\rangle$ .
As a result, I obtained:
It will be implemented in the circuit manually instead of using a collection of Pauli gates because we are not going to decode the corrected 7-qubit at the end. If decoding is needed, an encoding circuit is needed and the decode circuit would be the inverse of the encoding circuit.
We never measure the logical qubit directly during quantum error correction, as this would cause the quantum state to collapse. Instead, it is standard practice to use ancilla qubits to store the results of error checks, known as syndromes. In the circuit I am building, three ancilla qubits will be used to record the bit-flip syndromes (calculated as dot products modulo 2), and another three ancillas will record the phase-flip syndromes (also dot products modulo 2). These ancillas are then measured to obtain the syndrome values, which are encoded as classical bits. The resulting classical bits represent integers from 0 to 7, each corresponding to a specific error that can be identified and corrected:
The same recipe will be used for both
(Click to enlarge)
- 1st-7th wires: The 7-qubit logical quantum state.
- 8-10th wires:
$X_0$ ,$X_1$ and$X_2$ to check bit flips, they are storing the dot products (mod 2) of the 7-qubit with stabilizers XIXIXIX, IXXIIXX, IIIXXXX respectively. - 11-13th wires:
$Z_0$ ,$Z_1$ and$Z_2$ to check phase flips, they are storing the dot products (mod 2) of the 7-qubit with stabilizers ZIZIZIZ, IZZIIZZ, IIIZZZZ respectively. - 14th wire: Store the measured 8-10th wires, correction will be based on this and the error recipe.
- 15th wire: Store the measured 11-13th wires, correction will be based on this and the error recipe.
- 16th wire: Measure the corrected 7-qubit and store the result here.
- Step 1: Prepare the logical quantum state
$|0_L\rangle$ described in section Logical-state-preparation. - Step 2: Inject random errors, in our case, 3 small random errors on random qubits, 1 big large fixed error on a fixed qubit.
- Step 3: Perform the dot products (mod 2) of the 7-qubit with stabilizers XIXIXIX, IXXIIXX, IIIXXXX and store.
- Step 4: Perform the dot products (mod 2) of the 7-qubit with stabilizers ZIZIZIZ, IZZIIZZ, IIIZZZZ and store.
- Step 5: Measure the syndromes and store.
- Step 6: Perform bit flip error correction based on the value of 14th wire according to the error recipe.
- Step 7: Perform phase flip error correction based on the value of 15th wire according to the error recipe.
- Step 8: Measure the corrected 7-qubit and store.
When an error affects a valid logical state, it typically transforms the state into a superposition that includes basis states outside the code space. As a result, if we measure the system, it may collapse to a state that is not part of the code space, indicating that an error has occurred. This phenomenon can be observed by disabling the error correction steps in the circuit and running it for 50,000 repetitions to produce a histogram of measurement outcomes. The presence of out-of-code-space results reveals the impact of uncorrected errors.
The 16 tall bars represent the valid basis states within the code space. The remaining shorter bars correspond to states outside the code space, indicating the presence of uncorrected errors.
The 16 valid basis states remain, but the short bars have disappeared! This shows that all measurements now fall within the code space, confirming that the error correction is successfully working.
As the probability of error increases, multiple errors may occur and the Steane's code may not be able to fully fix the error.




