# Estimate of threshold values for 7-qubit Steane code with qiskit (or stim)

I have trouble recreating the graphs shown in this paper https://arxiv.org/pdf/quant-ph/0508176.pdf i.e. the quadratic trend of the logical error against physical single qubit error for [7,1,3] code

I attempted to do the simplest case, the logical error rate graph for a transversal H gate and wrote the following piece of quantum circuit with qiskit,

 lz = ['0000000', '1010101', '1100110', '0110011',
'1111000', '0101101', '0011110', '1001011']

for ind, pi in enumerate(p):
error_1 = noise.depolarizing_error(4 * pi / 3, 1)
error_2 = noise.depolarizing_error(16 * pi / 15, 2)
nm = noise.NoiseModel()

s = 0
fid = 0
for i in tqdm(range(n)):
lq = QuantumRegister(7)
x_anc = QuantumRegister(3)
z_anc = QuantumRegister(3)
x_syn = ClassicalRegister(3)
z_syn = ClassicalRegister(3)
qc = QuantumCircuit(x_anc, z_anc, lq, x_syn, z_syn)

# prepare a logical 0 state as in [AGP05][1]
perf_qc_0(qc, lq)
# to compute threshold of transversal H gate
qc.h(lq)

EC(qc, x_anc, z_anc, lq, x_syn, z_syn)

# append a noiseless transversal H as reverse operation
qc.append(h_nl, [lq])
qc.measure_all()

run = backend.run(qc, noise_model=nm, shots=1).result() #
mmt = list(run.get_counts().keys())[0]

# if measurement returns to space spanned by logical 0 components, accept
if (mmt[:7] in lz):
s += 1

le[ind] = 1-s/n
print("logical error rate is {}".format(le[ind]))


The error correction gadget I have is

def EC(qc, x_anc, z_anc, lq, x_syn, z_syn):
# Syndrome measurements
qc.h(x_anc)
qc.h(z_anc)

qc.cx(z_anc[2], [lq[i - 1] for i in [4, 5, 6, 7]])
qc.cx(z_anc[1], [lq[i - 1] for i in [2, 3, 6, 7]])
qc.cx(z_anc[0], [lq[i - 1] for i in [1, 3, 5, 7]])

qc.cz(x_anc[2], [lq[i - 1] for i in [4, 5, 6, 7]])
qc.cz(x_anc[1], [lq[i - 1] for i in [2, 3, 6, 7]])
qc.cz(x_anc[0], [lq[i - 1] for i in [1, 3, 5, 7]])

qc.h(x_anc)
qc.h(z_anc)
qc.measure(x_anc, x_syn)
qc.measure(z_anc, z_syn)

# Apply correction X gates
for i in range(1,8):
qc.x(lq[i-1]).c_if(x_syn, i)

# Apply correction Z gates
for i in range(1,8):
qc.z(lq[i-1]).c_if(z_syn, i)


The graph I obtain is more of a linear trend for some reason ...

I must have done something wrong but I can't see where. I'm still quite new to QECC so thanks if you can help!!

Update: I found that Stim is a library specifically for QECC, however I'm not sure how to implement Steane code with correct decoder in pymatching. Anyone can help?

• where have you built in an error correcting code and error correction? Jan 6, 2023 at 16:15
• @DaftWullie Hi I updated my question. I did the simplest Steane syndrome extraction, as in Fig1 of the paper link. But it's still not the trend expected. What exactly should I do to obtain the corresponding graphs? Jan 6, 2023 at 16:43