Magic states
We start by preparing a particular magic state, the eigenstate of the “SH” operator. To simulate noise, we add a depolarizing channel after state preparation:
By undoing the state preparation at the end, we can measure the infidelity:
Output
The noisy state preparation process produces a magic state with 97% fidelity.
Magic state distillation: The ideal case
Given multiple noisy magic states of low fidelity, we can distill a single high-fidelity magic state using a distillation circuit:
In this distillation circuit, qubits [q1, q2, q3, q4] are the distillation syndrome.
If we measure them in the state [1,0,1,1], we know that distillation was successful and the first qubit q0 is in a magic state with higher fidelity.
We can simulate this using Tsim. To measure the fidelity, we undo the magic state preparation on the first qubit and perform a measurement in the Z basis.
Output
R_X gate:
Magic state distillation: The realistic case (with noise)
On a real quantum computer, the distillation circuit is noisy itself. Here, the benefit of distillation is generally outweighed by the noise in the distillation circuit. We can explicitly see this using a simulation, where we add noise to the distillation circuit. Note that we consider two different noise scales:pis the noise that captures the magic state preparation process.noiseis the strength of the depolarizing noise in the distillation circuit.
Output
Encoding the distillation circuit
To address this issue, we need to make our distillation circuit resilient to noise. We do this by encoding it using a quantum error correction code, specifically the [17,1,5] color code. The helper classColorEncoder5 provides a convenient way to encode the distillation circuit. Each qubit will be encoded into 17 physical qubits using an encoding circuit. After that, each gate of the distillation circuit will be applied transversally to the encoded qubits.
Output
The fully encoded protocol
The full circuit now contains 85 qubits: 5 logical qubits, constructed from 17 physical qubits each. Let us summarize the protocol we are going to simulate:- Prepare 5 encoded magic states at 97% fidelity. The input magic states are noisy, and we assume the encoding process to be noiseless. While this is a simplification for this tutorial, it does not introduce any qualitative changes. We can think of this as an abstract preparation protocol that produces 5 encoded magic states, each with 97% fidelity.
- Distill 5 encoded magic states into a single logical qubit. We use the transversal encoding of the distillation circuit shown above. This includes depolarization noise with strength
noise. - Perform post-selection We will perform two stages of post-selection: (a) post-select on perfect stabilizers, and (b) post-select on the [1,0,1,1] distillation syndrome of logical bits.
- Quantum state tomography We will perform quantum state tomography on the output logical qubit to estimate its magic state fidelity.
Output
Output
- how to model noisy magic states and simulate fidelities using Tsim
- how to perform magic state distillation and post-selection
- how to encode a distillation circuit using the [17,1,5] color code
- how to simulate hundreds of thousands of shots of this 85-qubit circuit within seconds on a laptop
- how magic state distillation can improve the fidelity of noisy magic states, even when the distillation circuit is noisy itself