forked from RyujiPat/error_resource_TYC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpieceable_7qubit.txt
259 lines (210 loc) · 4.58 KB
/
pieceable_7qubit.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// Pieceable 7-qubit CCZ gate
// Definitions
// P0(q) -- preparing qubit q in |0>
// Pp(q) -- preparing qubit q in |+>
// Id(q) -- identity gate on qubit q
// H(q) -- Hadamard on qubit q
// S(q) -- Phase gate on qubit q
// K(q) -- S.H gate (H followed by S) on qubit q
// Sinv(q) -- inverse S gate on qubit q
// Kinv(q) -- inverse K gate on qubit q
// CX(p,q) -- CNOT from qubit p to q
// CZ(p,q) -- controlled-Z between qubits p and q
// CCZ(p,q,r) -- controlled-controlled-Z between qubits p, q, and r
// MeasZ(q) -- measures qubit q in the Z-basis
// MeasX(q) -- measures qubit q in the X-basis
// A(qi-qf) Ð single-qubit gate A applied transversally on qubits qi,qi+1,...,qf
// B(pi-pf,qi-qf) Ð two-qubit gate B applied transversally from qubit pi to qi, from pi+1 to qi+1,...,from pf to qi
// C(pi-pf,qi-pf,ri-rf) Ð three-qubit gate C applied transversally between qubit pi, qi, and ri, between pi+1, qi+1, and ri+1,...,between pf, qf, and rf.
// Circuits are broken into timesteps by newlines - a qubit should only be
// involved in at most 1 gate per timestep
// Circuits are organized into subcircuits by "def". Subcircuits take sets of
// input and output qubits as arguments. Input qubits are never prepared
// within the subcircuit, and output qubits are never measured.
// Fault-tolerantly prepares a logical |+> state in the 7-qubit code a la Goto
def LogicalPlus(in=(), out=(1,2,3,4,5,6,7)):
Pp(1)
P0(2)
P0(3)
P0(4)
Pp(6)
Pp(7)
CX(1,2)
CX(7,3)
CX(6,4)
Pp(5)
CX(1,3)
CX(5,2)
CX(7,4)
Id(6)
Pp(8)
CX(8,1)
CX(6,2)
Id(3)
Id(4)
CX(5,7)
Id(1-5)
CX(8,6)
Id(7)
Id(1-6)
CX(8,7)
Id(1-7)
MeasX(8)
// Fault-tolerantly prepares a logical |0> state in the 7-qubit code a la Goto
def LogicalZero(in=(), out=(1,2,3,4,5,6,7)):
P0(1)
Pp(2)
Pp(3)
Pp(4)
P0(6)
P0(7)
CX(2,1)
CX(3,7)
CX(4,6)
P0(5)
CX(3,1)
CX(2,5)
CX(4,7)
Id(6)
P0(8)
CX(1,8)
CX(2,6)
Id(3)
Id(4)
CX(7,5)
Id(1-5)
CX(6,8)
Id(7)
Id(1-6)
CX(7,8)
Id(1-7)
MeasZ(8)
// Alternative fault-tolerant preparation of a logical |+> state in the 7-qubit Bacon-Shor code
def LogicalZero(in=(), out=(1,2,3,4,5,6,7)):
P0(1)
P0(2)
Pp(3)
P0(4)
Pp(6)
Pp(7)
P0(8)
P0(9)
Pp(10)
P0(11)
Pp(13)
Pp(14)
CX(3,1)
CX(7,2)
CX(6,4)
Pp(5)
CX(10,8)
CX(14,9)
CX(13,11)
Pp(12)
CX(5,1)
CX(6,2)
CX(7,4)
Id(3)
CX(12,8)
CX(13,9)
CX(14,11)
Id(10)
CX(7,1)
CX(3,2)
CX(5,4)
Id(6)
CX(14,8)
CX(10,9)
CX(12,11)
Id(13)
CX(8-14,1-7)
Id(1-7)
MeasX(8-14)
// Alternative fault-tolerant preparation of a logical |0> state in the 7-qubit Bacon-Shor code
def LogicalZero(in=(), out=(1,2,3,4,5,6,7)):
Pp(1)
Pp(2)
P0(3)
Pp(4)
P0(6)
P0(7)
Pp(8)
Pp(9)
P0(10)
Pp(11)
P0(13)
P0(14)
CX(1,3)
CX(2,7)
CX(4,6)
P0(5)
CX(8,10)
CX(9,14)
CX(11,13)
P0(12)
CX(1,5)
CX(2,6)
CX(4,7)
Id(3)
CX(8,12)
CX(9,13)
CX(11,14)
Id(10)
CX(1,7)
CX(2,3)
CX(4,5)
Id(6)
CX(8,14)
CX(9,10)
CX(11,12)
Id(13)
CX(1-7,8-14)
Id(1-7)
MeasZ(8-14)
// Implements intermediate error-correction on the 7-qubit code
def IMErrorCorrection (in=out=(1,2,3,4,5,6,7)):
LogicalPlus(in=(), out=(8,9,10,11,12,13,14))
CX(1-7,8-14)
Id(1-7)
MeasZ(8-14)
// Implements Steane error-correction on the 7-qubit code
def ErrorCorrection (in=out=(1,2,3,4,5,6,7)):
LogicalZero(in=(), out=(8,9,10,11,12,13,14))
LogicalPlus(in=(), out=(15,16,17,18,19,20,21))
CX(1-7,15-21)
CX(8-14,1-7)
MeasZ(15-21)
Id(1-7)
MeasX(8-14)
// The circuit for logical CCZ
def FaultTolerantCCZ(in=out=(1,2,...,21)):
ErrorCorrection(in=out=(1,2,3,4,5,6,7))
ErrorCorrection(in=out=(8,9,10,11,12,13,14))
ErrorCorrection(in=out=(15,16,17,18,19,20,21))
CCZ(1,8,15)
CCZ(2,11,18)
CCZ(3,9,16)
CCZ(4,10,17)
CCZ(5,14,21)
CCZ(6,12,19)
CCZ(7,13,20)
CCZ(1,9,16)
CCZ(2,12,19)
CCZ(3,11,18)
CCZ(4,13,20)
CCZ(5,10,17)
CCZ(6,14,21)
CCZ(7,8,15)
IMErrorCorrection(in=out=(1,2,3,4,5,6,7))
IMErrorCorrection(in=out=(8,9,10,11,12,13,14))
IMErrorCorrection(in=out=(15,16,17,18,19,20,21))
CCZ(1,10,17)
CCZ(2,8,15)
CCZ(3,13,20)
CCZ(4,12,19)
CCZ(5,11,18)
CCZ(6,9,16)
CCZ(7,14,21)
ErrorCorrection(in=out=(1,2,3,4,5,6,7))
ErrorCorrection(in=out=(8,9,10,11,12,13,14))
ErrorCorrection(in=out=(15,16,17,18,19,20,21))