The Anti-Infinity Parade

Nov 01, 2022

Logical Operations for the Steane Code

Today, I want to discuss how to obtain a universal set of gates for the Steane code.

Previously, we discussed Gottesman's method for constructing the encoded Xˉ\bar{X} and Zˉ\bar{Z} logical operations for stabilizer codes.

import stac
cd = stac.CommonCodes.generate_code('[[7,1,3]]')
cd.construct_logical_operators()
print('encoded X =')
stac.print_paulis(cd.logical_xs)
print('encoded Z =')
stac.print_paulis(cd.logical_zs)
encoded X =

IIIIXXX\displaystyle IIIIXXX

encoded Z =

ZZIIIIZ\displaystyle ZZIIIIZ

There are many other 77-qubit Pauli operators that can act as Xˉ\bar{X} and Zˉ\bar{Z}. A nicer choice is Xˉ=X0X1X2X3X4X5X6,\bar{X} = X_0X_1X_2X_3X_4X_5X_6, Zˉ=Z0Z1Z2Z3Z4Z5Z6.\bar{Z} = Z_0Z_1Z_2Z_3Z_4Z_5Z_6.

Clifford gates

Recall that the Clifford group is generated from the operations H,S,CXH, S, CX. We will first show how to find the logical

Hadamard gate

The Hadamard gate is also transversal (no two qubit gate between the qubits of a single block). It is Hˉ=i=06Hi=H0H1H2H3H4H5H6.\bar{H} = \otimes_{i=0}^6 H_i = H_0H_1H_2H_3H_4H_5H_6. Why do we know this works? We can check that HˉXˉHˉ=Zˉ\bar{H}\bar{X}\bar{H}^\dagger = \bar{Z}, and that HˉZˉHˉ=Xˉ\bar{H}\bar{Z}\bar{H}^\dagger = \bar{X}, which are the required relations that Hˉ\bar{H} must obey.

logicalH = stac.Circuit()
for i in range(7):
logicalH.append('H', i)
logicalH.draw(output='latex',scale=0.7)

code output

CXCX gate

The CXCX gate is also transversal and actually just made of seven CXCX gates. Let us have two logical qubits, and designate one as control and the other as target. Let the physical qubits of the control logical qubits be indexed by (c,i)(c,i) and those of the target logical qubit be indexed by (t,i)(t,i). Then CXˉc,t=i=06CX(c,i),(t,i).\bar{CX}_{c,t} = \otimes_{i=0}^6 CX_{(c,i),(t,i)}.

To check that this works, we have to verify the conjgation relations that we had previously.

GG CX01GCX01CX_{01}GCX_{01}
XIX \otimes I XXX \otimes X
IXI \otimes X IXI \otimes X
ZIZ \otimes I ZIZ \otimes I
IZI \otimes Z ZZZ \otimes Z

Exercise: check that the CXˉ\bar{CX} satisfies these conjugation relations.

logicalCX = stac.Circuit()
for i in range(7):
logicalCX.append('CX', i,7+i)
logicalCX.draw(output='latex',scale=0.7)

code output

Logical SS gate

The SS gate is the gate, S=(100\iu),S = \begin{pmatrix}1 & 0 \\ 0 & \iu\end{pmatrix}, but is often defined in a nicer fashion with an overall phase factor as S=(e\iuπ400e\iuπ4).S = \begin{pmatrix}e^{-\iu\frac{\pi}{4}} & 0 \\ 0 & e^{\iu\frac{\pi}{4}}\end{pmatrix}.

Exercise: Compute the conjugacy relations of SS i.e. SGSSGS^\dagger for G=X,YG=X,Y.

Let Sˉ=i=06ZS.\bar{S} = \otimes_{i=0}^6 ZS.

Exercise: Verify that the defined Sˉ\bar{S} satisfies the conjugacy relations that SS should have.

The TT gate

The Clifford gate set does not allow us to do universal quantum computation, but the addition of the TT gate will. The TT gate is S=(100eiπ4),S = \begin{pmatrix}1 & 0 \\ 0 & e^{i\frac{\pi}{4}}\end{pmatrix}, or S=(e\iuπ800e\iuπ8).S = \begin{pmatrix}e^{-\iu\frac{\pi}{8}} & 0 \\ 0 & e^{-\iu\frac{\pi}{8}}\end{pmatrix}.

Magic states

For the Steane code, it's not possible to create a transversal TT gate on an encoded qubit. The way to obtain the TT gate is via magic states. The relevant magic state in our case is T=T+=0+eiπ412.\ket{T} = T\ket{+} = \frac{\ket{0} + e^{i\frac{\pi}{4}}\ket{1}}{\sqrt{2}}. This state is used in the following circuit, where ψ=α0+β1\ket{\psi}=\alpha\ket{0} + \beta\ket{1} be some unknown state on which we want to apply the TT gate, i.e we want Tψ=α0+βeiπ41T\ket{\psi} = \alpha\ket{0} + \beta e^{i\frac{\pi}{4}}\ket{1}.

Magic T gate

Let's evaluate to make sure everything works. Starting with Tψ\ket{T}\ket{\psi}, if we apply the CXCX gate from the first qubit to the second, we obtain, CX01Tψ=CX01(0+eiπ41)(α0+β1)/2,CX_{01}\ket{T}\ket{\psi} = CX_{01}(\ket{0}+e^{i\frac{\pi}{4}}\ket{1})(\alpha\ket{0}+\beta\ket{1})/\sqrt{2}, =(α00+β01+αeiπ411+βeiπ410)/2,= (\alpha\ket{00} + \beta\ket{01} + \alpha e^{i\frac{\pi}{4}}\ket{11} + \beta e^{i\frac{\pi}{4}}\ket{10})/\sqrt{2}, =12(α0+eiπ4β1)0+12(β0+eiπ4α1)1.= \frac{1}{\sqrt{2}}(\alpha\ket{0} + e^{i\frac{\pi}{4}}\beta\ket{1})\ket{0} + \frac{1}{\sqrt{2}}(\beta\ket{0} + e^{i\frac{\pi}{4}}\alpha\ket{1})\ket{1}. Next, we measure the second qubit in the ZZ basis. We either obtain 00 and the first qubit is left in the state α0+βeiπ41=Tψ,\alpha\ket{0} + \beta e^{i\frac{\pi}{4}}\ket{1} = T\ket{\psi}, or we obtain 11 and the first qubit is left in the state β0+αeiπ41.\beta\ket{0} + \alpha e^{i\frac{\pi}{4}}\ket{1}. In the first case, we have obtained the desired state. In the second case, if we just apply, SXSX to the state, we obtain TψT\ket{\psi}.

In summary, if it is possible to create a T\ket{T} state, one can apply a TT gate to any state using just Clifford operations.

Creating the T\ket{T} state

One can probabilistically create the T\ket{T} state. The circuit for it is given below, where the second control gate is a CSCS gate.

T state prep

Tstateprep = stac.Circuit()
Tstateprep.append('H', 1)
Tstateprep.append('CX', 1, 0)
Tstateprep.append('cp(pi/2)', 1, 0)
Tstateprep.append('H', 1)
Tstateprep.append('M', 1)
Tstateprep.draw()
# an iteration that yielded 0 for the measurement
Tstateprep.simulate()

code output

  basis  amplitude
------- -----------
00 0.707
10 0.707j
# an iteration that yielded 1 for the measurement
Tstateprep.simulate()
  basis  amplitude
------- -----------
01 0.707
11 -0.707j

Exercise: Evaluate this circuit by hand to show that if the measurement outcome is 00, then the first qubit will be in the T\ket{T} state.

If instead the measurement outcome is 11, then we apply the ZZ operator to correct the state.