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()
    nm.add_all_qubit_quantum_error(error_1, ['id', 'h'])

    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

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

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

        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.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.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?

  • $\begingroup$ where have you built in an error correcting code and error correction? $\endgroup$
    – DaftWullie
    Jan 6, 2023 at 16:15
  • $\begingroup$ @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? $\endgroup$
    – AndyLiuin
    Jan 6, 2023 at 16:43

1 Answer 1


I think the issue you are running into is that the construction used in that paper, which they say comes from this other paper, is not just a [[7,1,3]] code. It's a [[7,1,3]] code concatenated some number of times, with a special rule of some sort for redoing the stabilizer measurements if errors are detected in the lower levels.

If you put circuit noise into a normal [[7,1,3]] circuit, as it measures its stabilizers, there are error locations that cause a logical error with no symptoms. This is probably why yours isn't working: you're bounded by those errors.

  • $\begingroup$ Thanks a lot! I'll try to implement the construction. As these are some papers 2 decades ago, what structure do people nowadays use for fault-tolerant Steane code? Would you maybe name a few papers? And also ... I wonder how people used to generate these graphs so smoothly back in the day without the current simulators $\endgroup$
    – AndyLiuin
    Jan 8, 2023 at 14:22
  • $\begingroup$ @AndyLiuin I wrote this blog post recently that covers various ways of doing fault-tolerant measurements. abdullahkhalid.com/blog/2022/Oct/26/… $\endgroup$ Jan 9, 2023 at 0:44
  • $\begingroup$ @AbdullahKhalid Thanks! I've just read it. Could I ask, were you able to generate the quadratic graph of logical error vs physical error and deduce the threshold with this cat state EC? $\endgroup$
    – AndyLiuin
    Jan 9, 2023 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.