CITE THIS NOTEBOOK: Quantum error-correction and magic state distillation by William Munizzi. Wolfram Community JAN 2 2023.
This notebook is meant to serve as a brief computational essay on foundational quantum error-correcting codes and their applications for distilling magic states.
Paclet Installation
Paclet Installation
In[]:=
PacletInstall["https://wolfr.am/DevWQCF",ForceVersionInstall->True]<<Wolfram`QuantumFramework`
Out[]=
PacletObject
Error-Correcting Codes
In this section we introduce a collection of well-known quantum error-correcting codes and briefly describe their functionality for protecting encoded logical information. Each code below is an example of a stabilizer code, a quantum error-correcting code that relies on appending ancillary qubits to the system, and performing successive stabilizer measurements, to diagnose and reverse potential errors.
5-Qubit Code
5-Qubit Code
We begin with the 5-qubit error-correcting code, the smallest code that can protect a logical qubit against arbitrary single-qubit error. In this scheme, one logical qubit is encoded into five physical qubits. Errors are detected through stabilizer measurements, which indicate the type and location of single-qubit error. Possessing exact information about the error occurrence, the user can then reverse the error and recover the intended logical information.
We begin by defining a circuit to encode a single logical qubit into 5 physical qubits. This corresponds to projecting the initial 5-qubit state into a chosen subspace of the overall Hilbert space, the so-called code subspace corresponding to this error-correcting scheme. This code subspace is defined as the space containing states upon which certain stabilizing operations act trivially (ΨΨ,∀Ψ∈C). We therefore can define the projecting operation as below.
C
Ψ
s
i
s
i
In[]:=
subspaceProjectorFiveQCode=QuantumCircuitOperator(("I"->Range[5])+"XZZXI"),(("I"->Range[5])+"IXZZX"),(("I"->Range[5])+"XIXZZ"),(("I"->Range[5])+"ZXIXZ");subspaceProjectorFiveQCode["Diagram"]
1
2
1
2
1
2
1
2
Out[]=
The stabilizer operations which generate the 5-qubit code are the following. These stabilizers will be used to detect whether a logical error has occurred throughout the evolution of the system.
In[]:=
s1=QuantumOperator["XZZXI"];s2=QuantumOperator["IXZZX"];s3=QuantumOperator["XIXZZ"];s4=QuantumOperator["ZXIXZ"];stabilizers={s1,s2,s3,s4};
Note: Operations on the logical stored information, such as Pauli-X and Pauli-Z operations, are defined below.
In[]:=
logicalX=QuantumOperator["X"->Range[5]];logicalZ=QuantumOperator["Z"->Range[5]];
Logical codewords are then encoded as,
In[]:=
fiveQubitLogical0=subspaceProjectorFiveQCode[QuantumState["00000"]];fiveQubitLogical1=subspaceProjectorFiveQCode[QuantumState["11111"]];
And one can verify that the four generating stabilizers act trivially on the stored logical information.
In[]:=
Table[stabilizers[[i]][fiveQubitLogical0]==fiveQubitLogical0,{i,Length[stabilizers]}]
Out[]=
{True,True,True,True}
As a quantum circuit, we can visualize this process with the below diagram.
In[]:=
QuantumCircuitOperator[stabilizers]["Diagram"]
Out[]=
The action of stabilizer measurement performs a parity check on the stabilizing operations. If an error has occurred, it is subsequently identified and reversed to preserve the logical information.
7-Qubit Code (Steane Code)
7-Qubit Code (Steane Code)
The Steane code, proposed by Andrew Steane in 1996, encodes one logical qubit into 7 physical qubits. As with the 5-qubit code, the Steane code is capable of correcting arbitrary single-qubit errors, and is the first example of a quantum Hamming code. It is also an example of a quantum color code, and can be used as such for distillation protocols (described below).
The code subspace for the Steane code is described by the following set of stabilizer operators.
In[]:=
SteaneCodeS1=QuantumOperator["IIIXXXX"];SteaneCodeS2=QuantumOperator["IXXIIXX"];SteaneCodeS3=QuantumOperator["XIXIXIX"];SteaneCodeS4=QuantumOperator["IIIZZZZ"];SteaneCodeS5=QuantumOperator["IZZIIZZ"];SteaneCodeS6=QuantumOperator["ZIZIZIZ"];SteaneStabilizers={SteaneCodeS1,SteaneCodeS2,SteaneCodeS3,SteaneCodeS4,SteaneCodeS5,SteaneCodeS6};
Logical operations on the stored information are defined analogously to the 5-qubit code.
In[]:=
SteaneLogicalX=QuantumOperator["XXXXXXX"];SteaneLogicalZ=QuantumOperator["ZZZZZZZ"];
Logical information can accordingly be encoded in the following 7-qubit physical states,
In[]:=
SteaneLogical0=Total[QuantumState/@{"0000000","0001111","0110011","0111100","1010101","1011010","1100110","1101001"}];SteaneLogical1=SteaneLogicalX[SteaneLogical0];
Where one can again note the trivial action of the defined stabilizers.
In[]:=
Table[SteaneStabilizers[[i]][SteaneLogical0]==SteaneLogical0,{i,Length[SteaneStabilizers]}]
Out[]=
{True,True,True,True,True,True}
As a circuit, the code can be visualized in the following diagram.
In[]:=
QuantumCircuitOperator[SteaneStabilizers]["Diagram"]
Out[]=
Codestates are linear combinations of the Steane logical states, and are constructed accordingly.
A parity-check operation is employed to identify the existence and location of error throughout evolution. The error can then be diagnosed and a recovery operation applied to reverse the occurrence.
Magic State Distillation
Magic State Distillation
Magic State Distillation
Magic states are a valuable resource for realizable universal quantum computation. It is famously known that the set of Clifford gates (Hadamard, phase, CNOT gates) are not themselves a universal set, however access to Clifford gates and one additional non-Clifford operation does provide a universal gate set. For this reason, much interest surrounds the acquisition of non-Clifford resources by simplest means available. In 2004 Sergey Bravyi and Alexei Kitaev demonstrated that stabilizer circuits, those circuits composed only of Clifford gates, could be used to imperfectly (probabilistically) access non-stabilizer states (those states not directly reachable from measurement basis using only Clifford operations). As a protocol, so-called “Magic States” of a given qubit-number are distilled from higher-qubit systems constructed in a noise-assumptive manner. Using an error-correcting scheme, higher-fidelity magic states can be extracted from the larger, faulty composite system. Once one has produced a magic state of sufficiently-high fidelity for computational viability, the state may be implemented as a non-Clifford resource in the appropriate quantum circuit, thus offering universal computation capabilities.
Distilling T-Type Magic
Distilling T-Type Magic
Define a function for producing a faulty version of a T-state based on some initial dephasing operation. An arbitrary input error is assumed and applied at the state-preparation stage, for example, with ϵ = 0.3 below.
Define a decoding circuit for purifying a single-qubit T-state from 5-qubit product state. This procedure extracts a single output state from the multi-qubit input. The fidelity of the final output state can then be analyzed.
Results and Fault-Tolerance Threshold
Results and Fault-Tolerance Threshold
Here we establish the fault-tolerant threshold for this distillation protocol, the characteristic error-threshold below which quantum error-correction is effective and logical errors can be suppressed. Successful distillation of magic T-states corresponds to detection of the trivial syndrome upon measurement, i.e. no logical operation was performed on the stored information. The probability of detecting this trivial syndrome can be computed by projecting a faulty T-state, with some initial input error, into the code subspace and subsequently tracing out over the four ancillary qubits. The plot below considers this calculation for a range of input errors.
For input error below the fault-tolerant threshold, the probability of detecting the trivial syndrome increases.
Distilling H-Type Magic
Distilling H-Type Magic
A logical H-state can be encoded in 7 physical qubits by acting with the following circuit on a specially-designed 7-qubit input state. The success of encoding this logical H-state relies on the success of generating a single-qubit H-type magic state.
We can verify successful H-state distillation by confirming that the circuit output is indeed equivalent to action of the T operator on the 7-qubit all-down state.
Appending a set of three ancillary flag qubits to the 7-qubit Steane Code allows for a fault-tolerant construction. The system of flag qubits are used to measure the Steane stabilizer and store syndrome information as the system is evolved. The circuit is composed of two iterations of Reichardt’s 7-qubit color code, defined below.
The circuit for this color code can be visualized in the below diagram.
Similarly, defining the same circuit with control and target bits flipped.
Composing the above.
One can also construct a fault-tolerant circuit to measure the logical H operator used to generate the input state for the 7-qubit code. This circuit employs two ancillary flag qubits to detect faults in initial state preparation. The circuit can be iterated as many times as needed to achieve the desired logical H state.
A Hadamard operation on the stored logical information can be defined as below.
To ensure this Hadamard operation is correctly initialized two ancillary flag qubits are appended to the register, allowing for a fault-tolerant preparation of the logical H-operator.
The fault-tolerant circuit for measuring the logical H-operator can be visualized in the diagram below.
If significant dephasing occurs throughout the preparation of a logical H-state, the prepared state will be rejected and the protocol will begin again. A measurement on the flag qubits indicates the significance of the potential error, where the final qubit will experience a Pauli-Z flip.
To put the entire scheme together and input state is initialized, then passed through the preparatory HFlag circuit followed by the fault-tolerant Steane code. First, initialize the three sets of ancillary registers used throughout the protocol.
After the HFlag circuit, the logical state can be accepted or rejected depending on flag qubit readout. Let us define a function to prepare a faulty version of the initial input state.
A properly-prepared H-state is then passed to the error-correcting circuit where arbitrary errors can detected and reversed up to a code distance of 3. Subsequent stabilizer measurements indicate error occurrence throughout the evolution.
Non-Local Magic Distillation
Non-Local Magic Distillation
Begin first by defining functions to construct the Phase-GHZ and GHZ-T states of desired dimension, weighting, and relative phase.
Define a function that computes T-fidelity of a given state, i.e. a measurement of fidelity between a chosen state and any state reachable from T0 through only local transformations. The user inputs a test state and set of unitary operations. For completeness, a full set of local transformations should be provided.
References
References