|q⟩ Bad Qubits

advanced · Physics · Magic States & Distillation

Magic-State Injection

We now cash in the central promise of the module: given one copy of the magic state ∣T⟩=T∣+⟩|T\rangle = T|+\rangle and only Clifford operations, apply a TT gate to an arbitrary data qubit. The technique is gate teleportation, and the specific instance is TT-gate injection.[^gottesman-chuang]

The injection circuit

Let the data qubit be ∣ψ⟩=a∣0⟩+b∣1⟩|\psi\rangle = a|0\rangle + b|1\rangle on wire 00, and prepare the ancilla on wire 11 in the magic state

∣A⟩=T∣+⟩=12(∣0⟩+eiπ/4∣1⟩).|A\rangle = T|+\rangle = \frac{1}{\sqrt2}\bigl(|0\rangle + e^{i\pi/4}|1\rangle\bigr).

Apply a single CNOT\mathrm{CNOT} with the data as control and the ancilla as target, then measure the ancilla in the computational (ZZ) basis. Writing the joint state and applying CNOT0→1\mathrm{CNOT}_{0\to1},

∣ψ⟩∣A⟩→ CNOT0→1 12[(a∣0⟩+b eiπ/4∣1⟩)∣0⟩a+(a eiπ/4∣0⟩+b∣1⟩)∣1⟩a].|\psi\rangle|A\rangle \xrightarrow{\ \mathrm{CNOT}_{0\to1}\ } \tfrac{1}{\sqrt2}\Bigl[\bigl(a|0\rangle + b\,e^{i\pi/4}|1\rangle\bigr)|0\rangle_a + \bigl(a\,e^{i\pi/4}|0\rangle + b|1\rangle\bigr)|1\rangle_a\Bigr].

Reading off the two ancilla branches:

The Clifford correction

In the outcome-11 branch we have T†∣ψ⟩T^\dagger|\psi\rangle instead of T∣ψ⟩T|\psi\rangle. We repair it with a single SS gate, which is Clifford:

S T†=(100i)(100e−iπ/4)=(100eiπ/4)=T.S\,T^\dagger = \begin{pmatrix}1&0\\0&i\end{pmatrix}\begin{pmatrix}1&0\\0&e^{-i\pi/4}\end{pmatrix} = \begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix} = T .

So the recipe is: if the ancilla read 11, apply SS to the data. Either way the data ends up in exactly T∣ψ⟩T|\psi\rangle, and every operation we performed — CNOT\mathrm{CNOT}, ZZ-measurement, and a classically conditioned SS — is Clifford. The lone non-Clifford ingredient was the state ∣A⟩|A\rangle, prepared offline.

Why the correction must be classically conditioned

The byproduct SS is not optional decoration — without it, the outcome-11 branch applies T†T^\dagger, the inverse of what we wanted, and the computation is corrupted. The measurement result must be fed forward to decide whether to apply SS. This feed-forward of measurement outcomes is the operational heart of fault-tolerant non-Clifford gates, and it is why a fault-tolerant machine needs fast classical control.

Try it

Verify the protocol from first principles. For a real test input ∣ψ⟩=cos⁡(0.4)∣0⟩+sin⁡(0.4)∣1⟩|\psi\rangle = \cos(0.4)|0\rangle + \sin(0.4)|1\rangle, compute the corrected data state in both measurement branches (apply SS in the outcome-11 branch), and return the worst-case fidelity F=∣⟨Tψ∣corrected⟩∣2F = |\langle T\psi | \text{corrected}\rangle|^2. A correct protocol gives F=1F = 1 on both branches.

[^zhou-leung-chuang]: Zhou, Leung, Chuang, Methodology for quantum logic gate construction, arXiv:quant-ph/0002039.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.