Classical Repetition Code:
If a bank wants to transfer Rs 240, then it will convert 240 to binary. So the string will be 11110000 and will be sent into some account. If during transfer first bit is flipped as 0 due to noise then the amount received will be 112(01110000). Hence to correct such errors we encode each bit with a repetition of the same bit. Each 1 becomes 111 and each 0 becomes 000. Hence 11110000 becomes (111)(111)(111)(111)(000)(000)(000)(000). So now if the single bit in the first 3 bits is flipped then it becomes (101). Since the majority of bits is 1 we correct the error by converting 0 to 1. Hence the first 3 bit becomes (111) again.
Quantum Repetition Code:
Now in classical repetition code, we use many physical bits for 1 logical bit. Similarly, we assume to use many physical qubits for 1 logical qubit. E.g. Let's consider a 3-qubit quantum repetition code.
Imagine we incur a bit flip error.
To correct this error we first need to detect it. How can we detect a state change? We have to know the state of the system to detect errors. Hence we have to measure the system. Correcting this error consists of 2 steps:
Detect - Measure the qubit states.
Correct - Flip any qubits in the wrong state.
Let's see a truly quantum case, where we consider a superposition state and a bit flip error in it:
But if we do the 2 above steps then measurement changes the superposition state itself by collapsing it.
Why do we have to measure the original state? Can't we create a copy of the state and measure it, so that the original state will be saved?
No! This is due to the No-Cloning Theorem of Quantum Mechanics. According to the No-Cloning Theorem, it is impossible to create an independent copy of a quantum system, without damaging(collapsing) the state of the first system. Hence classical error correction cannot be used since it involves copying the states.
Read an amazing article on the No-Cloning Theorem:
https://www.educative.io/answers/what-is-the-no-cloning-theorem-in-quantum-computing
So how can we detect and correct the errors if we can't measure the qubits directly? This is one of the fundamental questions of Quantum Error Correction.
To handle this situation we have to ask the question 'Do we need to measure all of the qubits directly?' No! We could just detect differences between the qubit states and focus on correcting these before measurement happens. If differences exist then error exists. So we only need to find out if the qubits are all the same or if one of them flipped. Hence, we don't find out the quantum state, rather we find out if an error has occurred, where it has occurred, and the type of error so that we can correct it without hurting the original Quantum state.
To do this without measuring any of the physical qubits, we will need 2 components:
1) An extra or auxiliary qubit that we can measure. We call it a syndrome qubit. (Syndrome means symptoms or physical findings that indicate a specific condition)
2) Some way to change this auxiliary qubit's state based on the physical qubit states. A CX(Controlled NOT) gate gives different outputs, depending on the state of an input qubit.
Let's understand the CX or CNOT or Controlled-NOT gate
LHS: Symbol of the CX gate.
Definition of CX gate: Inverts the target qubit if the control qubit is 1.
RHS: Truth Table of CX gate.
Below is the 2-qubit repetition code error detection circuit.
Below is the result table of the above quantum circuit.
The state of the syndrome bit, called the error syndrome tells us if the the code qubits are the same or if a qubit flip error occurred.
Let's consider an example of a 3-qubit repetition code.
L0, L1,...L10 are different timestamps of the circuit. These labels are given to understand the quantum state at each timestamp.
The 'encode' block spreads the information across qubits to repeat the qubit. The quantum state at L2 gives the final state after the 'encode block'. Consider 2 tables where q0 is 0 and q0 is 1.
Let's consider the initial state(L2) as 111. In the noisy channel, the qubit q2 flips due to a bit-flip error. So the state becomes 110. Now consider operation from L3 to L7. Let syndrome qubits be S0 and S1. Due to these syndrome qubits, we can deduce if an error has occurred and on which qubits the error has occurred.
The S0 and S1 qubits are measured to obtain classical bits. This is called syndrome measurement. Based on the classical values of classical syndrome bits we will apply the Pauli X operation to the circuit to correct errors. We call this table a lookup table.
After L7 we apply the X-gate to undo the error. Now consider L7 to L10.
If we discard S0 and S1 then L10 is the same as L0. Thus, we have successfully corrected the single qubit-flip error.
Downside of Repetition Codes:
Repetition codes are good for understanding the basics, but they are not practical to use.
These codes are only correct for bit-flip but qubits can have other types of errors such as sign or phase flips.
It requires a lot of auxiliary qubits or extra qubits.
It uses a lookup table whose size grows exponentially with the number of syndrome qubits.
However many cutting-edge Quantum Error Correction algorithms require fewer qubits to detect and correct errors and can correct any type of errors. E.g. Shor Code, Bosonic Code, Surface Code.
Let's summarise the error correction process.
Encoding: Encode logical states and gates into physical states and gates using redundancies.
Sending over noisy channel: The physical state is exposed to noise and may incur errors.
Error Detection: Any errors in the state are detected and diagnosed using the error syndrome.
Error Correction: Any errors in the state are corrected.
Decoding: The final physical state is interpreted logically.
Thus, Quantum Repetition Code is a useful tool to correct errors but it is not feasible to use practically.