Introduction to Quantum Error Correction
James R. Wootton
Qubit Wrangler
IBM Quantum / © 2020 IBM Corporation
Why do we need QEC?
– Superconducting qubits don’t work exactly the way
they should
• Each gate is slightly wrong
• Qubits get poked by (small) external forces
• Measurements sometimes lie
– The same is true for spin qubits, topological qubits,
photonic qubits, …
– Any qubit made out of a real-life physical system will be
at least a little bit rubbish
IBM Quantum / © 2020 IBM Corporation 2
Why do we need QEC?
– But algorithms like Shor, Grover, etc assume that qubits
are perfect
– Run them with imperfect physical qubits, and you’ll get
nonsense out
– Instead we need qubits that are flawless incarnations of
the idea of quantum information
– Such ideal qubits are called logical qubits
– We need to somehow make perfect logical qubits out of noisy physical qubits
IBM Quantum / © 2020 IBM Corporation 3
Why do we need QEC?
– QEC is how we do this!
– Typically, many physical qubits are needed per logical qubit
– Using QEC in algorithms is therefore a long-term goal
– As are the algorithms that require it
– In the near term, we’ll try to make do and mitigate
IBM Quantum / © 2020 IBM Corporation 4
In this lecture
– We’ll look at the ideas behind error correction (classical and quantum)
– We’ll go through specific examples
• Repetition code
• Surface code
– We’ll see the most important techniques
• Syndrome measurements
• Decoding
• Logical operations
IBM Quantum / © 2020 IBM Corporation 5
What is Error Correction?
– Before we explain quantum error correction, we
should think about the general idea
– A simple example: you are talking on the phone, and
need to answer a question with ‘yes’ or ‘no’.
– Two important things to consider:
• How likely is it that you will be misheard?
p = probability that ‘no’ sounds like ‘yes’, etc
• How much do you care about being misunderstood?
Pa = maximum acceptable error probability
IBM Quantum / © 2020 IBM Corporation 6
What is Error Correction?
– Usually 𝑝 ≪ 𝑃𝑎 , so we don’t need to worry.
– But what if we are being asked life-or-death
questions over a noisy line?
– How can we make sure we are understood?
IBM Quantum / © 2020 IBM Corporation 7
The Repetition Code
– We could repeat ourselves.
– With a lot of ‘no’s, it’s obvious we mean ‘no’.
– Same for mostly ‘no’s with a few random ‘yes’s
thrown in.
– With this encoding of our message, it has become
tolerant to small faults
IBM Quantum / © 2020 IBM Corporation 8
The Repetition Code
– The receiver will need to decode the message.
– A sensible option is majority voting.
– A misunderstanding only happens when the majority of
copies are flipped
– For d repetitions
𝑑/2 𝑑/2
𝑑 𝑛 𝑝
𝑃= 𝑝 (1 − 𝑝)𝑑−𝑛 ~
𝑛 (1 − 𝑝)
𝑛=0
– P decays exponentially with d
– With enough repetitions, we can make P as small as we like
IBM Quantum / © 2020 IBM Corporation 9
Encoding and Decoding
– This example contained all the basic features of
any protocol for quantum error correction.
• Input: Some information to protect.
• Encoding: Transform the information to make it
easier to protect.
• Errors: Random perturbations of the encoded
message.
• Decoding: Trying to deduce the input from the
perturbed message
IBM Quantum / © 2020 IBM Corporation 10
Computation
– The example we just considered was one of communication, with errors occurring during transmission.
– For computation, errors are introduced whenever we perform an operation.
– We need to keep corrected errors as they are introduced.
– Can be done by constantly decoding and re-encoding
IBM Quantum / © 2020 IBM Corporation 11
Computation
– For example, here’s a single bit using the Repetition code
– The ‘noisy operation’ here is just doing nothing (with some errors)
– Here we don’t completely decode and re-encode, but just do it enough to find and fix the errors.
IBM Quantum / © 2020 IBM Corporation 12
Quantum Computation
– This method works great for bits, but not for qubits
– Suppose we wanted to encode some superposition state
𝑎 0ۧ + 𝑏 1ۧ → 𝑎 000ۧ + 𝑏 111ۧ
– Decoding requires measurement, and that destroys the superposition.
– To protect against one bad thing, we caused another!
IBM Quantum / © 2020 IBM Corporation 13
Quantum Computation
– To solve this, we need to be more careful with our measurements.
– We do need to measure, to get information about errors. But we must avoid learning
about the encoded information
– For this, note that we don’t actually need the bit values. We only need to know which
ones have a different value to the rest.
IBM Quantum / © 2020 IBM Corporation 14
Quantum Repetition Code
– Can be done with some extra qubits: one for each pair of code qubits.
– They are are initialized in state |0ۧ, and are used as the target for two CX gates
– The net effect is to measure the observable 𝑍𝑗 𝑍𝑗+1 : the Z basis parity of the two qubits
– In short: whether they are the same or different
cx 00ۧ = 00ۧ
cx 01ۧ = 00ۧ
cx 10ۧ = 11ۧ
cx 11ۧ = 10ۧ
IBM Quantum / © 2020 IBM Corporation 15
IBM Quantum / © 2020 IBM Corporation 16
IBM Quantum / © 2020 IBM Corporation 17
Quantum Repetition Code
– The parity measurements are repeated over the course of the computation
– The results are used to identify where errors likely occurred and how to remove their effects
– This is done by means of a classical algorithm: a decoding algorithm
– With this we can protect against bit flip errors
for an arbitrarily long time
IBM Quantum / © 2020 IBM Corporation 18
Syndrome Measurement
– This measurement is a syndrome measurement
– The result is known as the syndrome
– All codes have them
– They are ways to check that all the qubits
are doing what they should be
– Their form changes from code to code,
but their job is always the same
– They provide the clues that allow us
to detect and correct errors
IBM Quantum / © 2020 IBM Corporation 19
Decoding
– Start with an unrealistically simple case: errors between parity measurements only (not during)
– Focus on identifying errors for now (not correcting)
– Look for changes between rounds
– Errors create pairs of ‘defects’. Majority voting can be used to find a minimal pairing.
IBM Quantum / © 2020 IBM Corporation 20
Decoding
– Next, a simple model of noise in the measurements: they randomly lie
– Again, look for changes between rounds
– Bit flips create defects with space-like separation, measurement errors with time-like
– Pairing is now a 2D problem, majority voting won’t work
IBM Quantum / © 2020 IBM Corporation 21
Decoding
– There are many ways to do this, all with pros and cons
– One of the best is to think of the problem as a graph
• Defects are nodes
• The number of errors required to link them are weighted edges
– A likely set of errors corresponds to the ‘minimum weight perfect matching’ of the graph
– Efficiently computable using the ‘Blossom’ algorithm
IBM Quantum / © 2020 IBM Corporation 22
Decoding
– Here it is in action for a portion of the example from earlier
IBM Quantum / © 2020 IBM Corporation 23
Logical Operations
– If we wanted to manipulate the logical qubit, how could we do it?
– This requires a logical operation, made up of many
physical operations
– The logical X gate is easy for the repetition code
• do physical X gates on code qubits
• Code corrects imperfections
– An Rx gate essentially needs you to take the
code apart and put it back together again
• Not protected while unencoded
𝑅𝑥 2𝜃 0ۧ = cos 𝜃 0ۧ + sin 𝜃|1ۧ
→ cos 𝜃 |000ۧ + sin 𝜃|111ۧ
IBM Quantum / © 2020 IBM Corporation 24
IBM Quantum / © 2020 IBM Corporation 25
Quantum Repetition Code
– The limited set of fault-tolerant logical gates is a major
problem with the repetition code
– But it is not the only one!
– The code only allows us to detect and correct bit fips, and
only bit flips
– Though we made sure that it doesn’t cause superpositions
to collapse, it doesn’t protect them either
– The repetition code is a good first example of quantum error correction,
but it cannot give us fault-tolerant quantum computation
IBM Quantum / © 2020 IBM Corporation 26
IBM Quantum / © 2020 IBM Corporation 27
Towards a good quantum code
– The problem with the repetition code is that it treats z basis states very different to x and y basis states
– Example 1: z basis states are product states, the others are entangled
|0ۧ → |000ۧ
1 1
|+ۧ = (|0ۧ + 1ۧ → (|000ۧ + |111ۧ)
2 2
– Example 2: Distinguishing encoded z basis requires a single qubit measurement, distinguishing x basis
states requires d
– Example 3: Flipping between z basis states requires d gates, but the x basis only takes one
|0ۧ → |1ۧ ∶ 𝑋0 𝑋1 𝑋2 |000ۧ = |111ۧ
1 1
|+ۧ → |−ۧ ∶ 𝑍𝑗 (|000ۧ + 111ۧ = (|000ۧ − |111ۧ)
2 2
– It is not good when things are too easy, because they are easy for errors too!
IBM Quantum / © 2020 IBM Corporation 28
The Surface Code
– Quantum error correcting codes are defined by the measurements we make
– Let’s move beyond the simple 𝑍𝑗 𝑍𝑗+1 of the repetition code
– In the surface code we use a 2D lattice of code qubits, and define observables for plaquettes and vertices
IBM Quantum / © 2020 IBM Corporation 29
IBM Quantum / © 2020 IBM Corporation 30
Plaquette Syndrome
– First let’s focus on the plaquette syndrome
– These are similar to the two qubit measurements in the repetition code
– Instead we measure the parity around plaquettes in the lattice
– Can again be done with CX gates and an extra qubit
IBM Quantum / © 2020 IBM Corporation 31
IBM Quantum / © 2020 IBM Corporation 32
IBM Quantum / © 2020 IBM Corporation 33
Plaquette Syndrome
– We can define a classical code (storing only a bit) based on the plaquette syndrome alone
– Valid states are those with trivial outcome for all plaquette syndrome measurements:
Even parity on all plaquettes
– How to store a 0 in this?
– How about the state where every code qubit is |0ۧ?
IBM Quantum / © 2020 IBM Corporation 34
Plaquette Syndrome
– We can define a classical code (storing only a bit) based on the plaquette syndrome alone
– Valid states are those with trivial outcome for all plaquette syndrome measurements:
Even parity on all plaquettes
– How to store a 0 in this?
– How about the state where every code qubit is |0ۧ?
IBM Quantum / © 2020 IBM Corporation 35
Plaquette Syndrome
– We can define a classical code (storing only a bit) based on the plaquette syndrome alone
– Valid states are those with trivial outcome for all plaquette syndrome measurements:
Even parity on all plaquettes
– How to store a 0 in this?
– How about the state where every code qubit is |0ۧ?
IBM Quantum / © 2020 IBM Corporation 36
Plaquette Syndrome
– There are ‘nearby’ states that also have even parity on all plaquettes
– These can’t be a different encoded state: they are only a few bit flips away from our encoded 0 state
– We’ll treat them as alternative ways to store a 0
IBM Quantum / © 2020 IBM Corporation 37
Plaquette Syndrome
– Given any state for an encoded 0
• Pick a vertex
• Apply bit flips around that vertex
– Now you have another valid state for 0
– This generates an exponentially large family
IBM Quantum / © 2020 IBM Corporation 38
Plaquette Syndrome
– The states in this family can be very different
– But they all share a common feature
• Any line from top to bottom (passing along edges) has even parity
– This is how we can identify an encoded 0
– And it gives us a clue about how to encode a 1
IBM Quantum / © 2020 IBM Corporation 39
Plaquette Syndrome
– For our basic encoded 1, we use a bunch of 0s with a line from left to right (passing through plaquettes)
– This also spawns an exponentially large family
– All have odd parity for a line from top to bottom
– Unlike the repetition code, distinguishing encoded 0 and 1 requires some effort (which is good!)
IBM Quantum / © 2020 IBM Corporation 40
Logical X and Z
– Distinguishing 0 and 1 corresponds to measuring Z on the physical qubit
– The following observables detect what we need
– Or the same on any line from top to bottom
– Uses the edges has a nice advantage: we can think of them as large (unenforced) plaquettes
IBM Quantum / © 2020 IBM Corporation 41
Logical X and Z
– To flip between 0 and 1, we can flip a line of qubits
– Such lines of flips act as an X on the logical qubit
IBM Quantum / © 2020 IBM Corporation 42
Effects of Errors
– Applying an X to any code qubit changes
the parity of its two plaquettes
– An isolated X creates a pair of defects
– Further Xs can be move a defect, or
annihilate pairs of them
– A logical X requires many errors to stretch
across the lattice
– With the plaquette operators, we can
encode and protect a bit
IBM Quantum / © 2020 IBM Corporation 43
IBM Quantum / © 2020 IBM Corporation 44
Vertex Syndrome
– Now forget the plaquettes and focus on vertices
– These observables can also be measured using CX gates an an ancilla
– In this case they look at the |+ۧ and |−ۧ states, and count the parity of the
number of |−ۧs
IBM Quantum / © 2020 IBM Corporation 45
IBM Quantum / © 2020 IBM Corporation 46
Vertex Syndrome
– These operators also allow is to encode and protect a bit value
– In this case, let’s use + and - to label the two states
– They are encoded using suitable patterns of |+ۧ and |−ۧ states
for the code qubits
– As with the plaquettes, these also correspond to exponentially
large families of states
IBM Quantum / © 2020 IBM Corporation 47
IBM Quantum / © 2020 IBM Corporation 48
Logical X and Z
– What is the X operator (distinguish between |+ۧ and |−ۧ )?
– What is the Z operator (flip between |+ۧ and |−ۧ )?
– Turns out they are exactly the same as before!
IBM Quantum / © 2020 IBM Corporation 49
Effects of Errors
– Applying a Z to any code qubit changes the X
parity of its two vertices
– An isolated Z creates a pair of defects
– Further Zs can be move a defect, or annihilate
pairs of them
– A logical Z requires many errors to stretch across
the lattice
– With the vertex operators, we can encode and
protect a bit
IBM Quantum / © 2020 IBM Corporation 50
IBM Quantum / © 2020 IBM Corporation 51
Putting it all Together
– The plaquette and vertex operators commute
– This allows us to detect both X and Z errors
– Since Y~XZ, we can detect Y errors too
IBM Quantum / © 2020 IBM Corporation 52
IBM Quantum / © 2020 IBM Corporation 53
IBM Quantum / © 2020 IBM Corporation 54
Putting it all Together
– Encoded states now unique: superposition of all previous solutions
– For example, the encoded 0
– Satisfies 𝐴𝑣 |𝜓ۧ= |𝜓ۧ and 𝐵𝑣 |𝜓ۧ= |𝜓ۧ, so will give the 0 outcome for all stabilizer measurements
IBM Quantum / © 2020 IBM Corporation 55
Putting it all Together
– The Z and X operators on the encoded qubit are exactly the same as before
– These, and the Hadamard, can be performed fault-tolerantly
IBM Quantum / © 2020 IBM Corporation 56
Putting it all Together
– The states we need are highly entangled quantum states
– They are examples of topologically ordered states
– Though such things can be hard to make, we create and protect them with the syndrome measurements
IBM Quantum / © 2020 IBM Corporation 57
Putting it all Together
– We are not just protected against X and Z, but all local errors
– As mentioned earlier, Y~XZ
– Everything else can be expressed
𝐸 =𝑎𝐼+𝑏𝑋+𝑐𝑌+𝑑𝑍
– This creates a superposition of different types of error on the surface code
– Measuring the stabilizers collapses this to a simple X, Y or Z
IBM Quantum / © 2020 IBM Corporation 58
IBM Quantum / © 2020 IBM Corporation 59
Final Readout
– The logical operators are many-body observables
– So how do we read them out fault-tolerantly
– When you decide on a basis for final measurement,
you stop caring about some errors
– You can then measurement in a product basis
– Final readout and final stabilizer measurement can
be constructed from the result
– Measurement errors are effectively the same as
errors before measurement
IBM Quantum / © 2020 IBM Corporation 60
Decoding
– Given the measurement results, we need to work out what errors happened
– More specifically, the ‘equivalence class’ of errors
– This is the job of the decoding algorithm
IBM Quantum / © 2020 IBM Corporation 61
Decoding with MWPM
– A good option is MWPM
– Just as we considered for the repetition code
– Again we start with the simple and unrealistic case: errors only
between measurement
– Each round can be decoded separately, corresponding to MWPM on
a 2D graph
– Decoding for X and Z errors can also be done independently
IBM Quantum / © 2020 IBM Corporation 62
Decoding
– We need to be careful to account for the effects of the edges
– This is done by introducing extra ‘virtual nodes’
(also required for the repetition code, but we ignored it earlier)
IBM Quantum / © 2020 IBM Corporation 63
Imperfect Measurements
– Again, we have the problem of imperfect measurements
• The measurements might lie
• Errors on the additional qubit
• Errors in the CX gates
– We base the decoding using syndrome changes
– This leads to a 3D MWPM problem (2D space + time)
IBM Quantum / © 2020 IBM Corporation 64
Threshold
– Correcting according to the right class removes the effects of errors
– Correcting according to the wrong class causes an operation on the encoded qubit (without our knowing)
– What is the probability of such an error, P, given the probability on the qubits of the code, p?
– We find a phase transition as L is increased (for an LxL grid)
IBM Quantum / © 2020 IBM Corporation 65
More Logical Gates
– We’ve seen how to do logical X and Z
– A logical CX can be done without much trouble
– A logical H requires the lattice to be rotated, but that
can be done
– Other logical Clifford gates can be done with some
crazy tricks
– But that’s all! No other logical operations can be done
fault-tolerantly.
– A solution is magic state distillation, using the logical
gates we have to clean up the one we don’t
– But that’s beyond today’s lecture…
IBM Quantum / © 2020 IBM Corporation 66
Anyons in the Surface Code
– There are many variants on how qubits can be encoded
and manipulated in the surface code
– They all depend on the unique topological nature
– The ‘defects’ created by errors in the surface code
behave like particles
– All particles in our universe are either bosons or
fermions
– This due to topological restrictions in a 3D universe
IBM Quantum / © 2020 IBM Corporation 67
Anyons in the Surface Code
– The surface code is only a 2D ‘universe’, so doesn’t have these restrictions
– How do these particles behave?
IBM Quantum / © 2020 IBM Corporation 68
Anyons in the Surface Code
– Braiding a particle corresponds to applying a stabilizer
– Their eigenstates defines the braiding phase
– Neither bosons nor fermions, but anyons!
IBM Quantum / © 2020 IBM Corporation 69
Minimal Implementation
– The first surface code will probably be a small one
– The smallest that allows correction is d=3
– This requires ~17 qubits
– Who will be among the first to run and study this code?
– Maybe you!
IBM Quantum / © 2020 IBM Corporation 70
IBM Quantum / © 2020 IBM Corporation 71