# Coursera: Hands-on quantum error correction with Google Quantum AI
Recently, Google Quantum team published a [breakthrough](https://blog.google/technology/research/quantum-echoes-willow-verifiable-quantum-advantage/) about the verifiable quantum advantage on hardware. Quantum error correction one of the fundamental parts in quantum computing and I skipped that part in previous learnings. After failing to understand the work by just chatting with Gemini (master of analogy but still failed to resolve my questions), I decided to pick up this Coursera class again and finish it.
- [link](https://www.coursera.org/learn/quantum-error-correction/home/welcome)
- TL;DRs:
- Big learning curve for beginners; not the best place to start learning QC from scratch.
- Finishing the Quiz can help you understand the materials better.
- TBA
(Also, updates might be delayed because I am upgrading the Blog Infra (e.g. introducing Markdown) (with Gemini :D) so I might take longer to update posts).
### What is QC:
- Annealers: D-wave. qubits not on coherence but on applying control on the goal; an optimizer; not scalable
- Ion traps: a sufface patterned with electrodes that trap individual atomic ion; high fedility; bottomneck: scale, speed.
- Neutral atoms: trap with lasers; large qubit counts; challenges speed; atoms leaves wells;
- photonic: generate photons on chip; probabilistically entangle them ; changlleses overcoming loss and rapid switching pohotons
- Quantum dots: inividual electrons held in electrostatic fields; chellegnes: single borken split QC into two
- supercondcting:
- Google/IBM;
- Qubit are tunable frequency reasonant circuits;
- first execite state is |1>, not moving is |0> etc
- but string might have higher frequencies (higher excite state)
- changlleges:
- higher states cannot be used
- temperature (thermel enougy needs to be smaller than create energy gap to maintain circuits states)
- circuits are bigger compared single ion/photon
- circuits dont have 100% yield (some qubits and couplers unusable)
### Quantum Stats and circuits:
- classic computer: states, bit strings, operations(and, or, xor, +)
- Quautum states:
$\ket{\Psi} = \sum_{i=0}^{2^n-1}c_i\ket{i}, c_i \in \mathbb{C}, \sum_{i=0}^{2^n-1}|c_i|^2 = 1$
- Gates:
- X gate:
- $X\ket{0} = \ket{1}$
- $X\ket{1} = \ket{0}$
- Z gate:
- $Z\ket{0} = \ket{0}$
- $Z\ket{1} = -\ket{1}$
- Quantum Circuit
- one qubit in one row
- x-axis is time
- H gate:
- $H\ket{0} = \ket{+}$
- $H\ket{1} = \ket{-}$
- CNOT gate:
- $CNOT(1, 0)\ket{00} = \ket{00}$
- $CNOT(1, 0)\ket{01} = \ket{01}$
- $CNOT(1, 0)\ket{10} = \ket{11}$
- $CNOT(1, 0)\ket{11} = \ket{10}$
- Control-Z gate:
- $CZ(1, 0)\ket{00} = \ket{00}$
- $CZ(1, 0)\ket{01} = \ket{01}$
- $CZ(1, 0)\ket{10} = \ket{10}$
- $CZ(1, 0)\ket{11} = -\ket{11}$
- Measurement Gate:
- measure one, all entangled will collapse
### QEC I:
- classical error correction fundamentals
- setup: a bit 0/1
- question: probability p per unit time of flipping
- Solution: store multiple copies periodicially take majority vote
- multiple physical bits -> one logical bit
- code distance:
- the number of bits that need to be flipped to convert logical 0 into logical 1
- majority vote: dont' actually need to measure directly
- pairwise-parity: check the pairty; use Minimum weight perfect matching (MWPM) to decode;
- quantum errors
- e.g. leakage: higher stats, spreadable
- measurement can cause leakage as well
- high-energy impacts
- assumption: even with error the states can be represent by $\ket{0}$ or $|\ket{1}$. even leakage to higher state
- gates/init is followed by an error matrix; measure follows an error matrix;
- error matrix can be express as a linear combination of X (bit flip) and Z (phase flip) errors.
### Quantum error correction II: Detecting bit-flips and phase-flips
repeated detection (for bit flip):
```
0: ───@─────────────────@─────────────────@─────────────────@─────────────
│ │ │ │
1: ───X───M('m0')───R───X───M('m1')───R───X───M('m2')───R───X───M('m3')───
```
- no error: produce 0 output
- data error: error will be consistent in the future
- measure error: odd-one-out error (not preserved)
- (two measure bits to detect three bits)
```
┌──────────────┐ ┌──┐ ┌──────────────┐ ┌──┐ ┌──────────────┐ ┌──┐ ┌──────────────┐
0: ───@─────────────────@───────────@─────────────────@───────────@─────────────────@───────────@─────────────────@────────
│ │ │ │ │ │ │ │
1: ───X────M('m_anc0_0')┼─────R─────X────M('m_anc0_1')┼─────R─────X────M('m_anc0_2')┼─────R─────X────M('m_anc0_3')┼────────
│ │ │ │
2: ───@─────────────────X─────X─────@─────────────────X─────X─────@─────────────────X─────X─────@─────────────────X────X───
│ │ │ │ │ │ │ │
3: ───X────M('m_anc1_0')──────┼R────X────M('m_anc1_1')──────┼R────X────M('m_anc1_2')──────┼R────X────M('m_anc1_3')─────┼───
│ │ │ │
4: ───────────────────────────@─────────────────────────────@─────────────────────────────@────────────────────────────@───
└──────────────┘ └──┘ └──────────────┘ └──┘ └──────────────┘ └──┘ └──────────────┘
```
- distance-3-code, can cope with at most (d-1)/2 (i.e. 1) errors.
- with distance increase linearly, the p(at least half error) decays exponentially (errors are independent).
- we can calculate a graph where edges-value (thickness) is the propbility of having error in that transition by assuming there is an errors.
- and use Minimum weight perfect matching (wt = -ln p_edge) to locate the error bit
- superposition will collapse if circuit is not designed properly
for phase flip (Z):
```
┌──────────────┐ ┌──┐ ┌──────────────┐ ┌──┐ ┌──────────────┐ ┌──┐ ┌──────────────┐
0: ───@─────────────────@───────────@─────────────────@───────────@─────────────────@───────────@─────────────────@────────
│ │ │ │ │ │ │ │
1: ───X────Mx('m_anc0_0')┼─────R─────X────Mx('m_anc0_1')┼─────R─────X────Mx('m_anc0_2')┼─────R─────X────Mx('m_anc0_3')┼────────
│ │ │ │
2: ───@─────────────────X─────X─────@─────────────────X─────X─────@─────────────────X─────X─────@─────────────────X────X───
│ │ │ │ │ │ │ │
3: ───X────Mx('m_anc1_0')──────┼R────X────Mx('m_anc1_1')──────┼R────X────Mx('m_anc1_2')──────┼R────X────Mx('m_anc1_3')─────┼───
│ │ │ │
4: ───────────────────────────@─────────────────────────────@─────────────────────────────@────────────────────────────@───
└──────────────┘ └──┘ └──────────────┘ └──┘ └──────────────┘ └──┘ └──────────────┘
```
- where M_x is -H-M
### Quantum error correction III: Introduction to stabilizers
- stabilizer
- are operators that leave some useful state unchanged:
- e.g. $Z\ket{0} = \ket{0}$
- e.g. $-Z\ket{1} = \ket{1}$, i.e. $-Z$ is stablizer of $\ket{1}$, $\ket{1}$ is the eigenstates of the associcated stabilizer
- e.g. $X\ket{+} = \ket{+}$
- e.g. $-X\ket{-} = \ket{-}$
- e.g $\ket{\Psi} = \frac{1}{\sqrt{2}}(\ket{000}+\ket{111})$ is stablilized by three independent stabilizers:
- $+XXX$, $+ZZI$, $IZZ$,
- Notice that - $+XXX$, $+ZZI$, $IZZ$, $ZIZ$ is not a set of stablizer because $ZIZ=(ZZI)(IZZ)$.
- if there is an error for example $X_2$ then we will have:
- $(-Z_2Z_1)X_2\ket{\Psi} = X_2\ket{\Psi}$ or $+XXX$, $-ZZI$, $IZZ$
- If we can determine how to measure the sign of a stabilizer, we can detect errors
- General operator measure:
```
0: ───H───@───H───M('m')───
│
1: ───────A────────────────
│
2: ───────A────────────────
│
3: ───────A────────────────
```
- final result: = $ \frac{1}{\sqrt{2}} \left( |0\rangle \frac{1}{\sqrt{2}} (|\Psi\rangle + A|\Psi\rangle) + |1\rangle \frac{1}{\sqrt{2}} (|\Psi\rangle - A|\Psi\rangle) \right)$
- A zero measurement means that the output is the +1 eigenstate of A
- One means -1 eigenstate
- example
- error $X_1\ket{\Psi}$ will map stabilizers to +XXX, -ZZI, -IZZ
- error $X_0\ket{\Psi}$ will map stabilizers to +XXX, +ZZI, -IZZ
- represent it in a picture:
- ways to represent a state: explicit state (combination of all cases); set of stabilizers; picture
- 
### Quantum error correction IV: The surface code
- surface code is more easy to understand than stabilzier-representation or explicity state-representation
- a general way to express X operator and Z operator: 
(tbc)