Adaptive syndrome measurements for Shor-style error correction

The Shor fault-tolerant error correction (FTEC) scheme uses transversal gates and ancilla qubits prepared in the cat state in syndrome extraction circuits to prevent propagation of errors caused by gate faults. For a stabilizer code of distance $d$ that can correct up to $t=\lfloor(d-1)/2\rfloor$ errors, the traditional Shor scheme handles ancilla preparation and measurement faults by performing syndrome measurements until the syndromes are repeated $t+1$ times in a row; in the worst-case scenario, $(t+1)^2$ rounds of measurements are required. In this work, we improve the Shor FTEC scheme using an adaptive syndrome measurement technique. The syndrome for error correction is determined based on information from the differences of syndromes obtained from consecutive rounds. Our protocols that satisfy the strong and the weak FTEC conditions require no more than $(t+3)^2/4-1$ rounds and $(t+3)^2/4-2$ rounds, respectively, and are applicable to any stabilizer code. Our simulations of FTEC protocols with the adaptive schemes on hexagonal color codes of small distances verify that our protocols preserve the code distance, can increase the pseudothreshold, and can decrease the average number of rounds compared to the traditional Shor scheme. We also find that for the code of distance $d$, our FTEC protocols with the adaptive schemes require no more than $d$ rounds on average.


Introduction
One essential component for constructing a largescale quantum computer is quantum error correction (QEC). One has to make sure that the QEC process can be implemented fault-tolerantly so that a small number of faults in the process will not cause uncorrectable errors. It has been proved that a fault-tolerant error correction (FTEC) scheme and other schemes for faulttolerant quantum computation (FTQC) can be used to simulate any quantum circuit with an arbitrarily low logical error rate if the physical error rate is below some scheme-dependent threshold value [1,2,3,4,5,6,7,8,9]. However, implementing an FTEC scheme is physically challenging because larger space and time overhead (ancilla qubits and quantum gates) are required for a lower logical error rate [10,11,12,13]. Another reason is that for the same family of quantum error correcting codes (QECC), an FTEC protocol that requires more space and time overhead tends to have a lower fault-tolerant threshold since there are more possible fault combinations that can cause the protocol to fail [9]. Therefore, an FTEC scheme that requires only a small amount of overhead is desirable.
The Shor FTEC scheme [1] is one of the very first FTEC schemes. It handles gate faults by measuring the stabilizer generators of a stabilizer code using the cat states and transversal gates. In addition, the Shor FTEC scheme handles ancilla preparation and measurement faults by repeated syndrome measurements; traditionally, full syndrome measurements are performed until the outcomes are repeated t + 1 times in a row, where t = ⌊(d − 1)/2⌋ is the number of errors that a stabilizer code of distance d can correct. The Shor FTEC scheme satisfies the strong FTEC condi-tions [9] (to be defined in Definition 1), so it is compatible with code concatenation (an FTEC scheme that only satisfies the weak FTEC conditions [14], defined in Definition 2, is not compatible with code concatenation and only works at the highest level of concatenation). The Shor scheme is applicable to any stabilizer code and requires the number of ancilla qubits to be equal to the maximum weight of the stabilizer generators. In the worst-case scenario (when there are no more than t faults in the scheme), the Shor scheme requires (t + 1) 2 rounds of full syndrome measurements.
One way to reduce the time overhead required for an FTEC scheme similar to the Shor scheme is by using adaptive syndrome measurements, in which the measurement sequences depend on the prior measurement outcomes. Zalka [15] constructed an adaptive Shor-style FTEC protocol for the [[7, 1, 3]] Steane code that uses Shor circuit for syndrome extraction. Delfosse and Reichardt [14] further developed the adaptive measurement idea and constructed adaptive Shor-style FTEC protocols for any stabilizer code of distance 3, any Calderbank-Shor-Steane (CSS) codes of distance 3, and some stabilizer codes of distance ≤ 7. Their protocols for different code families require different maximum numbers of syndrome bit measurements. One drawback of the FTEC protocols in [14] is that they only satisfy the weak FTEC conditions and are not generally compatible with code concatenation (unless the code being used is a perfect code, a perfect CSS code, or the [ [16,4,3]] color code invented in [16]).
In this work, we develop Shor-style FTEC schemes with adaptive syndrome measurements that use information from the differences of syndromes obtained from any two consecutive rounds. The main results of this work are the following: (1) we construct an adaptive Shor-style FTEC scheme that satisfies the strong FTEC conditions (Definition 1) and is applicable to any stabilizer code. In our protocol, stabilizer generators are measured using Shor syndrome extraction circuits. For a protocol that can tolerate up to t = ⌊(d − 1)/2⌋ faults (which is applicable to a stabilizer code of distance d), we prove that the number of required rounds of full syndrome measurements is no more than (t + 3) 2 /4 − 1.
We also discuss some minor improvements that can further reduce the total number of syndrome

Protocol
The maximum number of required rounds Strong FTEC (t + 3) 2 /4 − 1 Weak FTEC (t + 2) 2 /4 if ⃗ s 1 ̸ = 0 (t + 3) 2 /4 − 2 if ⃗ s 1 = 0 Traditional Shor [1] (t + 1) 2 Table 1: The maximum number of rounds required for the protocols in this work which satisfy the strong FTEC conditions (Definition 1) and the weak FTEC conditions (Definition 2) compared to the traditional Shor FTEC protocol when applying to a stabilizer code of distance d that can correct up to t = ⌊(d − 1)/2⌋ errors. Our protocols are applicable to any stabilizer code.
bit measurements. (2) We construct an adaptive Shor-style FTEC scheme that satisfies the weak FTEC conditions (Definition 2) and is applicable to any stabilizer code. The protocol requires at most (t + 2) 2 /4 rounds if the syndrome obtained from the first round is ⃗ s 1 ̸ = 0, and requires at most (t + 3) 2 /4 − 2 rounds if ⃗ s 1 = 0. With some minor improvements, our protocol that satisfies the weak conditions and can correct up to 1 fault is similar to the adaptive FTEC protocol for a distance-3 stabilizer code proposed in [14]. Our main results on the maximum number of rounds are summarized in Table 1. (3) We show that the lower bound of the fault-tolerant threshold for a concatenated code can be improved when the adaptive scheme satisfying the strong FTEC conditions is used instead of the traditional Shor scheme. We also compare both of our adaptive schemes with the traditional Shor scheme by simulating FTEC protocols on the hexagonal color codes of distance 3, 5, 7, and 9. Our numerical results verify that the adaptive schemes are fault tolerant, preserve the code distance, can increase the pseudothreshold, and can decrease the average number of rounds of syndrome measurements. We also observe that the average number of rounds for the strong and the weak schemes approach d and d − 1, respectively, as the physical error rate approaches 1. This paper is organized as follows: In Section 2, we formally define the strong and weak conditions for FTEC, and briefly review the traditional Shor FTEC scheme. In Section 3, we introduce the notion of difference vector, construct an algorithm to find an error syndrome suitable for FTEC, and construct an FTEC protocol that satisfies the strong conditions. In Section 4, we apply the algorithm from the previous section and construct an FTEC protocol that satisfies the weak conditions. In Section 5, we compare our adaptive schemes developed in the previous sections with the traditional Shor scheme both analytically and numerically. Our results and possible future directions are discussed in Section 6.

FTEC conditions and the traditional Shor FTEC scheme
A quantum [[n, k, d]] stabilizer code [17,18] uses n physical qubits to encode k logical qubits and can correct an error of weight up to τ = ⌊(d − 1)/2⌋, where d is the code distance. A stabilizer code can be described by its corresponding stabilizer group, the Abelian group generated by r = n − k commuting independent Pauli operators called stabilizer generators. The coding subspace is a simultaneous +1 eigenspace of all elements in the stabilizer group. In an ideal situation, if the weight of the error on a codeword is no more than τ , a process of quantum error correction (QEC) can remove such an error. For a stabilizer code, the QEC process involves measuring the eigenvalues of all stabilizer generators on the corrupted codeword. The combined measurement results, called error syndrome, will be used to find an EC operator for undoing the corruption.
In practice, however, any quantum gate involved in the syndrome measurements can be faulty. In this work, we will assume the standard depolarizing noise model in which each onequbit gate is followed by a single-qubit Pauli error (I, X, Y, or Z), each two-qubit gate is followed by a two-qubit Pauli error of the form P 1 ⊗ P 2 (where P 1 , P 2 ∈ {I, X, Y, Z}), and each single qubit measurement (which outputs a classical bit of information) is followed by either no error or a bit-flip error. Note that an error from each fault in the QEC process may propagate to other qubits (depending on the circuit being used in the syndrome measurement) and become an error of higher weight on the data block; i.e., a few faults may lead to the total error of weight more than τ , causing the QEC process to fail. To prevent such cases from happening, we want to make sure that the QEC protocol being used is fault tolerant; vaguely speaking, if the weight of an input error plus the number of faults in the FTEC pro-tocol is small enough, we want to make sure that the output state is logically correct and has an error of weight no more than the total number of faults in the FTEC protocol. For a stabilizer code that can correct errors up to weight τ , one might want to construct an FTEC protocol that can tolerate up to t faults where t is as close to τ as possible.
We can define the strong conditions for FTEC as follows: Definition 1. Strong conditions for faulttolerant error correction [9] Let t ≤ ⌊(d − 1)/2⌋ where d is the distance of a stabilizer code. An error correction protocol is strongly t-fault tolerant if the following two conditions are satisfied: (Note that Definition 1 can be further generalized by defining r as the number of faults that causes the input error, as proposed in [19]. For an FTEC scheme in which stabilizer generators are measured using cat states and transversal gates similar to the Shor FTEC scheme, however, there is no difference in the uses of Definition 1 and the generalized definition in [19] since a single gate fault in each generator measurement will lead no more than weight 1 error on the data qubits.) Definition 1 is one of the main ingredients to prove the threshold theorem in [9], a theorem which shows that an arbitrarily low logical error rate can be attained through code concatenation if the physical error rate is below some threshold value. It should be noted that for an FTEC protocol satisfying the strong FTEC conditions when the weight of the input error is large (r + s > t) but the number of faults is small (s ≤ t), ECRP guarantees that the output state will be in the 'correctable' subspace, but the input and the output states might not be logically the same. This property is necessary for constructing a conventional FTEC protocol for a concatenated code; for a code with two levels of concatenation, an FTEC protocol for the 2nd-level code is constructed from an FTEC protocol for the 1st-level code by replacing every physical qubit with a code block and replacing every physical gate with its corresponding logical gate. To do error correction, the 1st-level FTEC protocol is applied on each code block, and the 2nd-level FTEC protocol is applied afterwards. ECRP guarantees that an error on each code block after applying the 1stlevel protocol can be corrected by the 2nd-level FTEC protocol. The idea can also be extended to a code with more levels of concatenation; see [9].
For some families of codes, a code of high distance can be obtained without code concatenation. Surface codes [3,20] and color codes [21] are examples of topological codes in which the code distance can be made arbitrarily large by increasing the lattice size. For such code families, an arbitrarily low logical error rate can be attained without code concatenation if the physical error rate is below some threshold value. In that case, there is no need to guarantee the weight of the output error for high-weight input errors with r + s > t. To achieve fault tolerance, it is sufficient to show that an FTEC protocol for such code families satisfies the following weak conditions for FTEC: Definition 2. Weak conditions for fault-tolerant error correction [14] Let t ≤ ⌊(d − 1)/2⌋ where d is the distance of a stabilizer code. An error correction protocol is weakly t-fault tolerant if the following two conditions are satisfied:  [1] is an example of an FTEC scheme that satisfies the strong FTEC conditions. The details of the traditional Shor scheme are as follows: Suppose that a stabilizer generator being measured is a Pauli operator of weight w of the form M = P 1 ⊗ P 2 ⊗ · · · ⊗ P w . An eigenvalue of the stabilizer generator is measured by first preparing ancilla qubits in a cat state of the form 1 √ 2 (|0⟩ ⊗w + |1⟩ ⊗w ), then applying controlled-P 1 , controlled-P 2 , ..., controlled-P w gates; see Fig. 1 for an example. Afterward, Hadamard gates are applied transversally to the ancilla qubits, which are measured in the Z basis. The even and odd parities of the measurement results of ancilla qubits correspond to +1 and −1 eigenvalues of M , respectively. For convenience, we will call a circuit for measuring an eigenvalue of a stabilizer generator in this form the Shor syndrome extraction circuit. (Note that the cat state used in the Shor syndrome extraction circuit must be prepared fault-tolerantly; i.e., if there are s ≤ t faults during the cat state preparation, the resulting cat state must differ from an ideal cat state by an error of weight no more than s. This can be done by using the ancilla verification method in [1] or the ancilla decoding and measurement method in [22].) Since some faults may lead to an incorrect measurement outcome, the full syndrome measurement will be performed repeatedly. In the traditional Shor FTEC scheme, the syndromes will be measured until they are repeated t + 1 times in a row. By doing so, we can make sure that if there are no more than t faults in the whole protocol, there is at least one correct round in the last t + 1 rounds with the same syndrome, and the repeated syndrome corresponds to the data error at the end of the correct round. An EC operator to be applied is a Pauli operator of the minimum weight whose syndrome is the repeated syndrome. Here we will call the process of selecting the syndrome for error correction using the aforementioned criteria Shor decoder.
It is not hard to verify that both conditions in Definition 1 are satisfied with t = τ = ⌊(d−1)/2⌋; because the controlled Pauli gates are applied transversally between the data block and the ancilla qubits, each single gate fault will lead to an error of weight ≤ 1 on the data block or the ancilla qubits (or both). Also, any errors on the ancilla qubits and measurement faults can be handled by repeatedly performing syndrome measurements. When s ≤ t, the repeated syndrome is the syndrome of the input error plus any error that occurs before the last correct round in the last t + 1 rounds with the same syndrome. Therefore, after applying the EC operator corresponding to the repeated syndrome, the output state differs from an uncorrupted logical state by an error of weight ≤ s (an error that may arise from some faults after the last correct round). The input and the output states are always logically the same when r + s ≤ t, but the states may be logically different when r + s > t. For these reasons, both ECCP and ECRP in Definition 1 are satisfied.
Any quantum circuit can be fault-tolerantly simulated with arbitrarily low logical error rates using an FTEC scheme together with faulttolerant gadgets for quantum gates, state preparation, and state measurement. However, a lower logical error rate requires more overhead (ancilla qubits and quantum gates). One drawback of the traditional Shor scheme is that the number of required ancilla qubits is equal to the maximum weight of stabilizer generators; this is because of the Shor syndrome extraction circuit. Another drawback is that the traditional Shor scheme requires repeated syndrome measurements. Suppose that there are t faults in the protocol, in the worst-case scenario, (t + 1) 2 rounds of the syndrome measurements must be performed before the syndromes are repeated t + 1 times in a row; this is because of the Shor decoder.
There are several FTEC schemes whose syndrome extraction circuits require fewer ancilla qubits compared to the Shor syndrome extraction circuit. Examples of such FTEC schemes are the flag FTEC schemes, in which a few 'flag' ancilla qubits are used to detect faults that can lead to a high-weight error on the data block [23]. The flag FTEC scheme for a general stabilizer code of distance d requires d + 1 ancillas [24], while the schemes for certain families of codes may require fewer [23,25,26,27,28,29,19]. However, to handle syndrome measurement faults, the flag scheme still requires repeated syndrome measurements which use ideas similar to the Shor decoder.
The main goal of this work is to construct a better algorithm for finding a syndrome suitable for FTEC which requires fewer rounds of syndrome measurements compared to the Shor decoder in the traditional Shor scheme (where the syndrome measurements are performed until the syndromes are repeated t + 1 times in a row). In Sections 3 and 4, we will develop FTEC protocols satisfying the strong FTEC conditions (Definition 1) and the weak FTEC conditions (Definition 2), respectively. In our protocols, we will assume that stabilizer generators are measured using the Shor syndrome extraction circuits and focus on reducing the number of required rounds. The processes of selecting the syndrome for error correction in these protocols will be referred to as adaptive strong and adaptive weak decoders.

Adaptive measurements for Shor error correction satisfying the strong FTEC conditions
In this section, we will construct an FTEC protocol that satisfies the strong FTEC conditions (Definition 1). Stabilizer generators will be measured using the Shor syndrome extraction circuits, so any single gate fault will cause an error of weight ≤ 1 on the data block or one of the ancilla qubits (or both). The main difference between our protocol and the traditional Shor FTEC scheme is that we will perform the syndrome measurements in an 'adaptive' way; instead of measuring until the syndromes are repeated t + 1 times in a row (where t is the number of faults that the protocol can correct), the condition to stop the measurement sequences will change dynamically depending on syndromes collected from all rounds. We call this kind of procedure adaptive measurements because of its similarity to the measurement procedure proposed by Delfosse and Reichardt in [14] (later in Section 4, readers will find that our FTEC protocol satisfying the weak FTEC conditions is similar to the FTEC protocol in [14] when applying to a stabilizer code of distance 3).
To make sure that both ECCP and ECRP in Definition 1 are satisfied, we will use the following ideas: given the whole syndrome history, we will try to find a syndrome ⃗ s i obtained from round i that is correct, i.e., it corresponds to the data error at the end of round i. Finding such a syndrome should be possible regardless of the weight of the input error. Let r be the weight of the input error, s be the number of faults in the protocol, and t = ⌊(d − 1)/2⌋ be the weight of error that a stabilizer code of distance d can correct. Suppose that s ≤ t. If such a syndrome ⃗ s i can be found, combining the input error, the error from faults occurred up to round i, and the EC operator corresponding to ⃗ s i will result in a logical operator; it is always a trivial logical operator (i.e., a stabilizer) when r + s ≤ t and it can be a nontrivial logical operator when r + s > t. After applying the EC operator, the output state will differ from an uncorrupted logical state by an error from faults that occur after round i (the error weight is always ≤ s). If the procedure explained above can be done, both ECCP and ECRP in Definition 1 are satisfied.

Difference vectors for single-fault cases and an FTEC protocol satisfying the strong FTEC conditions for a stabilizer code of distance 3
Our algorithm for finding a syndrome suitable for error correction will use the information from the differences of syndromes between any two consecutive rounds. First, let us consider how a single fault can affect the differences between the syndrome from the round that the fault occurs, and the syndromes from the rounds before and after.
Suppose that in each round of full syndrome measurements, stabilizer generators are measured sequentially. Let ⃗ s j denote the syndrome obtained from the j-th round of full syndrome measurements, and assume that a single fault occurs on the i-th round (an input error of weight 1 can be considered as a single data-qubit fault on the 0-th round).
1. Let E denote the data error at the end of the (i − 1)-th round. If a single fault during a generator measurement on the i-th round causes a data error F , subsequent generator measurements in the same round may or may not be able to detect the newly occurred error. F may be fully detectable (⃗ s i is exactly the syndrome of E · F ), partially detectable (some part of ⃗ s i represents the syndrome of E · F , and the other part represents the syndrome of E), or undetectable (⃗ s i represents the syndrome of E only). Thus, ⃗ s i may or may not be the syndrome of the data error at the end of the i-th round. Nevertheless, F will be fully detectable by the syndrome measurements at the (i+1)-th round, so ⃗ s i+1 is the syndrome of the data error at the end of the i-th round (which is the syndrome of E · F in this case).
2. If a single fault during a generator measurement causes an error on the ancilla qubits or is an ancilla measurement fault, it may cause a single bit-flip on ⃗ s i , so ⃗ s i may or may not be the syndrome of the data error at the end of the i-th round. Nevertheless, ⃗ s i+1 is the syndrome of the data error at the end of the i-th round.
Possible single faults can be categorized into three types depending on their effects on the syndromes: 1. Type I: a single fault on the i-th round that causes ⃗ s i−1 ̸ = ⃗ s i ̸ = ⃗ s i+1 . Examples of Type I faults are an ancilla measurement fault and a fault leading to a data error partially detectable by generator measurements in the i-th round.

Type II: a single fault on the i-th round that causes ⃗ s
An example of a Type II fault is a fault leading to a data error undetectable by generator measurements in the i-th round.
3. Type III: a single fault on the i-th round that causes ⃗ s i−1 ̸ = ⃗ s i = ⃗ s i+1 . An example of a Type III fault is a fault leading to a data error fully detectable by generator measurements in the i-th round.
Since for any Type III fault on the i-th round, there is a Type II fault on the (i−1)-th round that causes the same data error, it is safe to consider only faults of Types I and II (a fully detectable data error from a fault on the 1st round is equivalent to an input error). Note that any single fault on the i-th round cannot cause ⃗ s i−1 = ⃗ s i = ⃗ s i+1 unless the data error is trivial. This is because the (i + 1)-th round of syndrome measurements can always detect a data error of weight 1 from the i-th round when the code distance is d ≥ 3. This is also true in the case of multiple faults because a data error of weight ≤ t from the the i-th round are always detectable by the (i + 1)-th round of syndrome measurements when the code distance is d ≥ 2t + 1, useless the data error is trivial. For convenience, we will define a difference vector from a sequence of syndrome measurement results as follows:

Definition 3. Difference vector
Let m be the total number of rounds of full syndrome measurements, and let ⃗ s i denote the error syndrome obtained from the i-th round. The dif- Let I(i) and II(i) denote single faults of Types I and II on the i-th round, where i = 1, . . . , m and m is the total number of rounds. By Definition 3, the difference vector of length m − 1 corresponding to each fault type is the following: (For an input error which may be denoted by II(0), the difference vector is the zero vector.) To see how a difference vector can be used to determine a syndrome suitable for error correction, let us consider an FTEC protocol correcting up to t = 1 fault as an example. When only I(i) occurs, the syndrome ⃗ s i is the only syndrome that cannot be used for error correction since it might not correspond to the data error at the end of any round. On the other hand, when only II(i) occurs, the syndrome from any round can be used for error correction; ⃗ s i = ⃗ s i−1 = . . . corresponds to the data error at the end of the (i−1)-th round (which is trivial), while ⃗ s i+1 = ⃗ s i+2 = . . . corresponds to the data error at the end of the i-th round (which is the data error caused by II(i)).
In actual syndrome measurements, we cannot perfectly distinguish between Type I and Type II faults using the difference vector as some faults of different types can give the same difference vector (for example, I(1) and II (1), and I(m) and II(m−1)). Nevertheless, whenever we find δ i = 0, we are certain that neither Type I nor Type II fault occurs on the i-th round. That is, ⃗ s i is usable for error correction if δ i = 0 (⃗ s i+1 = ⃗ s i is also usable). Another case that a usable syndrome can be found is whenever ⃗ δ has a substring 11, which implies that one fault already occurred on some round before the m-th round (the latest round).
In that case, we can do error correction using the syndrome obtained from the m-th round. Using these facts, an FTEC protocol satisfying the strong FTEC conditions with t = 1 can be constructed as follows:

Protocol 1. FTEC protocol satisfying the strong FTEC conditions for a stabilizer code of distance 3
In each round of full syndrome measurements, measure stabilizer generators using the Shor syndrome extraction circuits. After the j-th round (j ≥ 2), calculate the (j − 1)-th bit of the difference vector. Repeat syndrome measurements until one of the following conditions is satisfied, then perform error correction using the error syndrome corresponding to each condition: stop the syndrome measurements. Perform error correction using the syndrome ⃗ s i .
2. If ⃗ δ contains a substring 11, stop the syndrome measurements. Perform error correction using the syndrome obtained from the latest round.
Suppose that the total number of rounds in the protocol is 3. All possible single faults, their corresponding difference vectors, syndromes suitable for error correction, and the syndromes that will be used for error correction according to our protocol are displayed in Table 2. In fact, 3 is the Fault type difference vector syndromes suitable syndrome to be used ⃗ δ for error correction for error correction smallest number of rounds required to make sure that a usable syndrome exists; 2 rounds are not sufficient since I(1) and I (2) give the same ⃗ δ = 1 but they cannot be distinguished, and neither ⃗ s 1 nor ⃗ s 2 works for both cases. 3 is also the number of rounds of syndrome measurements in the worst-case scenario of our protocol for t = 1; i.e., the total number of rounds is at most 3 in any case.

Difference vectors for multiple-fault cases
and an FTEC protocol satisfying the strong FTEC conditions for a stabilizer code of any distance In this section, we will extend our method for finding a syndrome suitable for error correction to the case of multiple faults so that an FTEC protocol satisfying the strong FTEC conditions for a stabilizer code of any distance can be constructed. First, let us consider the case that up to t faults simultaneously occur on the i-th round. Unless the total data error is trivial, a combination of such . A syndrome suitable for error correction, in this case, is similar to that of a Type I or a Type II fault. In other words, what matters is the presence of any faults in each round. If we can deal with any case of a single fault, we can also deal with any case that multiple faults occur on the same round.
As we aim to analyze the worst-case scenario, we can assume that no more than one fault occurs on each round when considering the case of multiple faults.
Next, we will see how difference vectors of two faults that occur on different rounds can be combined. Let us consider syndromes from any two consecutive rounds j and j + 1 which arise from two faults λ A and λ B .
. Combining λ A and λ B results in one of the following cases: 1. If s A,j = s A,j+1 and s B,j = s B,j+1 , then s A,j +s B,j = s A,j+1 +s B,j+1 ; that is, δ A,j = 0 and δ B,j = 0 lead to δ AB,j = 0.

If s
We will refer to the case that δ A,j = 1 and δ B,j = 1 lead to δ AB,j = 1 as an OR case (since 1 OR 1 = 1), and refer to the case that δ A,j = 1 and δ B,j = 1 lead to δ AB,j = 0 as an XOR case (since 1 XOR 1 = 0). For convenience, the first three cases where δ A,j OR δ B,j = δ A,j XOR δ B,j will be simply referred to as OR cases.
If there are only OR cases when combining difference vectors of multiple faults, a syndrome suitable for error correction can be easily found; whenever we find δ i = 0 on the resulting difference vector, we know that no fault occurs on the i-th round so ⃗ s i can be used. In practice, however, the OR and XOR cases cannot be easily distinguished. Thus, finding that δ i = 0 does not guarantee that there is no fault on the i-th round.
In this case, ⃗ s 6 and ⃗ s 7 cannot be used for error correction.
In the example above, none of ⃗ s 1 -⃗ s 7 works for all cases, so error correction cannot be done accurately when ⃗ δ = 010010 is found. Fortunately, an FTEC protocol is normally developed to handle a limited number of faults. We can use this fact to determine whether a zero bit in the resulting difference vector can arise from the XOR case. For example, suppose that the total number of faults is limited to t = 3 and the resulting difference vector is ⃗ δ = 0100010: 1. ⃗ δ can be from combining I(1), I(2), and II (6) with difference vectors 1000000, 1100000, and 0000010 where XOR cases happen when combining the 1st bits. In this case, ⃗ s 1 and ⃗ s 2 cannot be used for error correction.
2. Also, ⃗ δ can be from combining II(2), I(7), and I(8) with difference vectors 0100000, 0000011, and 0000001 where XOR cases happen when combining the 7th bits. In this case, ⃗ s 6 and ⃗ s 7 cannot be used for error correction.
4. Note that ⃗ δ can be from combining II (2), II (5), and I(6) with difference vectors 0100000, 0000100, and 0000110 where XOR cases happen when combining the 5th bits. Although a Type I fault occurs on the 6th round, ⃗ s 6 can still be used for error correction since ⃗ s 6 = ⃗ s 5 and there is no Type I fault on the 5th round. In this case, any ⃗ s i can be used for error correction.
From the example above, we know that at least one of the bits δ 3 -δ 5 must be a bit zero arising from the OR case (0 OR 0 OR 0) if the total number of faults is no more than 3. Moreover, ⃗ s 3 = ⃗ s 4 = ⃗ s 5 = ⃗ s 6 . Thus, ⃗ s 3 -⃗ s 6 correspond to the data error at the end of some round and all of them can be used for error correction. We will develop a general algorithm for finding a syndrome for error correction for any t using the ideas explained previously. For convenience, we will introduce the notions of OR and XOR zeros, and usable and unusable zero substrings as follows:

Definition 4. OR and XOR zeros
Let ⃗ δ be a difference vector obtained from combining the difference vectors of some faults, and suppose that some bit δ i of ⃗ δ is zero. δ i is said to be an OR zero if it arises from the OR case of fault combination (0 OR 0 = 0), and δ i is said to be an XOR zero if it arises from the XOR case of fault combination (1 XOR 1 = 0).

Definition 5. Usable and unusable zero substrings
Let a difference vector ⃗ δ be of the form ⃗ δ = η 1 1η 2 1 . . . 1η c for some positive integer c, where η j (j = 1, . . . , c) is a zero substring of the form 00 . . . 0 (the length of η j can be zero). For any η j with positive length, if it is certain that η j contains at least one OR zero, then η j is said to be usable; otherwise, η j is unusable.
For any ⃗ δ of the form η 1 1η 2 1 . . . 1η c , we aim to find whether η j is usable for all η j with positive length. If a usable η j exists, we can use a syndrome of any round corresponding to η j to do error correction; because at least one zero bit in η j is an OR zero and all rounds corresponding to the same η j give the same syndrome, the syndrome accurately represents the data error at the end of some round. Here we will use the fact that the total number of faults are limited to find a usable syndrome.
For each η j of length ≥ 1 (2 ≤ j ≤ c − 1), we can define α j and β j to be the minimum numbers of faults that lead to the substrings η 1 1 . . . 1η j−1 and η j+1 1 . . . 1η c (the substrings before and after 1η j 1). That is, suppose that, Then, α j is equal to the total number of nonoverlapping 11 substrings plus the total number of remaining one bits before * , and β j is equal to the total number of non-overlapping 11 substrings plus the total number of remaining one bits after * * . For example, for a substring η j = 000 in ⃗ δ = 1011000111101, α j = 2 and β j = 3.
The following theorem states the sufficient and necessary condition for a zero substring to be usable.

Theorem 1.
Let t be the maximum number of faults, ⃗ δ be a difference vector of the form η 1 1η 2 1 . . . 1η c , and α j and β j be the minimum numbers of faults leading to the substrings before and after 1η j 1 (or η 1 1 or 1η c ). Suppose that the length of η j is γ j > 0. Then, η j is usable if and only if α j + β j + γ j ≥ t.
If α j + β j + γ j ≥ t, the zeros in 1η j 1 cannot be all XOR zeros (i.e., 1η j 1 must arise from less than γ j + 1 faults). In other words, there is at least one OR zero in η j , so η j is usable. In contrast, if α j + β j + γ j < t, η j may arise from γ j + 1 faults. Because it is not certain whether there is an OR zero in η j or not, η j is unusable. Similar analysis is applicable to η 1 and η c , where the substrings η 1 1 and 1η c are considered instead of 1η j 1, and α 1 = 0 and β c = 0 are defined. It is also applicable when all bits of ⃗ δ are zeros, in which ⃗ δ = η 1 and α 1 = β 1 = 0.
Theorem 1 can be interpreted as follows: Let t be the total number of faults. For each η j , α j +β j is the minimum number of occurred faults, thus t − α j − β j is the maximum number of remaining faults, while γ j + 1 is the number of rounds with repeated syndromes. If the syndromes are repeated more than the maximum number of remaining faults, it is certain that at least one round in the γ j + 1 rounds must have a correct syndrome which can be used for error correction.
By Theorem 1, an algorithm for finding a usable zero substring from a given fault number t in and a difference vector ⃗ δ in can be constructed as follows: Algorithm 1. Let t in be any number of faults and ⃗ δ in = η 1 1η 2 1 . . . 1η c be a difference vector for some positive integer c. For each η j with length γ j > 0, calculate α j and β j (as defined in Theorem 1). If α j + β j + γ j ≥ t in , return η j as a usable zero substring.
Using Algorithm 1, an FTEC protocol correcting up to t faults that satisfies the strong FTEC conditions can be developed:

Protocol 2. FTEC protocol satisfying the strong FTEC conditions for a stabilizer code of any distance
Let t = ⌊(d−1)/2⌋ be the weight of error that a stabilizer code of distance d can correct. In each round of full syndrome measurements, measure stabilizer generators using the Shor syndrome extraction circuits. After the i-th round (i ≥ 2), calculate δ i−1 . Repeat syndrome measurements until one of the following conditions is satisfied, then perform error correction using the error syndrome corresponding to each condition: 1. If at least one usable η j is found by Algorithm 1 where t in = t and ⃗ δ in = ⃗ δ (the current difference vector), stop the syndrome measurements. Perform error correction using the syndrome corresponding to any zero in η j .
2. If the total number of non-overlapping 11 substrings in ⃗ δ is t, stop the syndrome mea-surements. Perform error correction using the syndrome obtained from the latest round.
(The second condition to stop the syndrome measurements is introduced to count the number of occurred faults in case that all bits in ⃗ δ are ones and there is no zero substring of positive length.) It is possible to find the number of rounds of syndrome measurements in the worst-case scenario of Protocol 2 for any t. This number is the same as the minimum number of rounds required to guarantee that a usable syndrome exists in any case. The number can be found by the following theorem:

− 1 rounds of full syndrome measurements is sufficient.
A proof of Theorem 2 is provided in Appendix A.
Note that in some cases, we do not have to complete the full syndrome measurements in the very last round to find a usable syndrome. For example, if a generator measurement reveals that the first bit of ⃗ s i is different from the first bit of ⃗ s i−1 , we can immediately tell that δ i−1 is 1. To reduce the total number of generator measurements using this idea, we can modify Protocol 2 by checking the difference between the syndromes of the two latest rounds (i and i − 1) more frequently, and running Algorithm 1 as soon as δ i−1 = 1 is found (or at the end of the i-th round if δ i−1 = 0).
Moreover, Protocol 2 applied to a CSS code can be further optimized using the fact that Z-type and X-type errors can be corrected separately. Let t = ⌊(d − 1)/2⌋ be the number of faults that the protocol can correct (where d is the code distance). We can first measure X-type generators repeatedly and a difference vector ⃗ δ x will be obtained. A syndrome ⃗ s x suitable for Z-type error correction can be found using Algorithm 1 with t in = t and ⃗ δ in = ⃗ δ x . Once ⃗ s x is found, the minimum number of faults that occur during the X-type generator measurement, denoted by t oc , can be calculated by counting the total number of non-overlapping 11 substrings plus the total number of remaining one bits in ⃗ δ x . After that, we can measure Z-type generators repeatedly, and a difference vector ⃗ δ z can be obtained. A syndrome ⃗ s z suitable for X-type error correction can be found using Algorithm 1 with t in = t − t oc and ⃗ δ in = ⃗ δ z . Because the maximum number of remaining faults t − t oc is used instead of t in the latter part of the protocol, ⃗ s z could be found faster than ⃗ s x , and the total number of generator measurements in the protocol could be reduced.
Recall that in the traditional Shor FTEC scheme where the Shor decoder is used, the repeated syndrome measurements are done until the syndromes are repeated t + 1 times in a row; i.e., a substring η j in ⃗ δ with length γ j = t is found. With the notations introduced in this work, the Shor decoder can be considered as a special case where α j and β j are defined to be 0 for any η j . That is, for the Shor decoder, η j is usable iff γ j ≥ t (by Theorem 1).
One interesting aspect of our scheme is that the information from the past, the current, and the future rounds (which is contained in α j , γ j , and β j ) is used to determine whether the syndrome of the current rounds (that leads to η j ) is suitable for error correction. Here, the word "future" refers to the fact that the syndromes obtained in the very first rounds can be found usable at a later stage of the protocol as more syndromes are collected. This is in contrast to the Shor decoder in which only information of the current rounds (the number of rounds with repeated syndromes) is used.
Note that although our adaptive scheme requires less time overhead compared to the traditional Shor scheme, it requires more classical processing since Algorithm 1 must be run after each round of syndrome measurements. Nevertheless, the classical time complexity of Algorithm 1 is O(t 3 ), so the classical processing part is not likely to limit the performance of the adaptive scheme. The analysis of the classical time complexity of Algorithm 1 is provided in Appendix B.

Adaptive measurements for Shor error correction satisfying the weak FTEC conditions
As previously mentioned in Section 2, a code of high distance can be obtained in some code families without using code concatenation. In that case, the weak FTEC conditions in Definition 2 are sufficient to guarantee that fault tolerance can be achieved; it is not necessary to guarantee the weight of the output error when the weight of the input error is too high. In this section, we will develop an FTEC protocol similar to the protocol in Section 3, but the weak FTEC conditions are considered instead of the strong FTEC conditions (the conditions in Definition 1). The main goal of this section is to further reduce the number of rounds required to find a syndrome suitable for error correction for some families of codes in which the strong FTEC conditions need not be satisfied.
Similar to the EC scheme in Section 3 (and the traditional Shor scheme), stabilizer generators will be measured using the Shor syndrome extraction circuits. However, we will use a different idea to find a syndrome suitable for error correction. Let r be the weight of the input error, s be the number of faults in the protocol, and t = ⌊(d − 1)/2⌋ be the weight of error that a stabilizer code of distance d can correct. To make sure that both ECCP and ECRP in Definition 2 are satisfied whenever r + s ≤ t, we will use the following ideas when developing an FTEC protocol: 1. For any case with r ≥ 1 and r+s ≤ t, at least one syndrome suitable for error correction (a syndrome ⃗ s i obtained from some round i which corresponds to the data error at the end of that round) must be found. In this case, error correction using ⃗ s i will remove the input error and the error from faults that occurred up to round i. Thus, the output state will be logically the same as the input state, and the weight of the output error (the error from faults after round i) will be ≤ s.
2. For any case with r = 0 and s ≤ t, if the difference vector of that case is the same as the difference vector of some case with r ≥ 1 and r + s ≤ t, at least one syndrome suitable for error correction must be found (the same syndrome must work for both cases since they cannot be distinguished by observing the difference vector). In this case, the error correction will remove the error from some faults that occurred early in the protocol, so the output state will be logically the same as the input state, and the weight of the output error will be ≤ s.
3. For any case with r = 0 and s ≤ t, if the difference vector of that case is different from the difference vectors of all cases with r ≥ 1, a protocol can stop without doing any error correction. Because there is no input error, the output state will be logically the same as the input state, and the weight of the output error will be ≤ s.
The syndrome of the first round ⃗ s 1 is special since it is related to the weight of the input error. If ⃗ s 1 ̸ = 0, then either one of the following is true: A) the input error has weight ≥ 1, and there are s ≤ t − 1 faults in the protocol (a Type I fault may or may not be present in the first round), or B) there is no input error, there are s ≤ t faults in the protocol, and the first round has a Type I fault (I(1)).
On the other hand, if ⃗ s 1 = 0, then either one of the following is true: C) the input error has weight ≥ 1, there are s ≤ t − 1 faults in the protocol, and the first round has a Type I fault (I(1)), or D) there is no input error, there are s ≤ t faults in the protocol, and the first round has no Type I faults (no I(1)).
(Here we assume that there is at most one fault in each round, which is either Type I or Type II. Please see Section 3.2 for the validity of this assumption.) To see how a syndrome suitable for error correction can be found from a difference vector ⃗ δ in each case of ⃗ s 1 , let us consider an FTEC protocol correcting up to t = 1 fault as an example. First, suppose that r + s ≤ 1 and ⃗ s 1 ̸ = 0. There are two possibilities: 1. r = 1 and s = 0 (Case A): In this case, δ 1 = 0 (⃗ s 1 = ⃗ s 2 ). The error correction can be done using ⃗ s 1 .
2. r = 0 and s = 1 (Case B): In this case, there must be I (1) and no faults on the other rounds, so δ 1 = 1 (⃗ s 1 ̸ = ⃗ s 2 ). The error correction is not necessary in this case.
We can see that when ⃗ s 1 ̸ = 0, the protocol will find a syndrome suitable for error correction or stop without doing error correction within 2 rounds. Next, suppose that ⃗ s 1 = 0. There is only one possible case: there is no input error and the first round has no Type I fault (Case D). Thus, we can stop without doing error correction whenever ⃗ s 1 = 0. Only 1 round of full syndrome measurements is needed in this case. Using these ideas, an FTEC protocol for t = 1 can be constructed as follows: In fact, Protocol 3 is similar to the protocol for a stabilizer code of distance 3 proposed by Delfosse and Reichart in [14].
In case that t ≥ 2, finding a usable zero substring (which gives a syndrome suitable for error correction) from a difference vector obtained from repeated syndrome measurements can be more complicated. Suppose that a difference vector is ⃗ δ = δ 1 δ 2 . . . δ m for some positive integer m. We will use the following procedures to find a usable zero substring η j : 1. If ⃗ s 1 ̸ = 0, a usable zero substring will be found by Algorithm 1 with t in = t − 1 and ⃗ δ in = δ 2 . . . δ m (the first bit of ⃗ δ is removed).
2. If ⃗ s 1 = 0, a usable zero substring will be found by Algorithm 1 with t in = t and ⃗ δ in = 0δ 1 δ 2 . . . δ m (bit zero is added to the beginning of ⃗ δ).
To see how these work, assume that r + s ≤ t and first consider the case that ⃗ s 1 ̸ = 0. Case A has r ≥ 1 and s ≤ t − 1, while Case B has r = 0, s ≤ t, and I(1). In both cases, the second rounds onward have ≤ t−1 faults. When a usable zero substring η j is found by Algorithm 1 with t in = t − 1 and ⃗ δ in = δ 2 . . . δ m , it is guarantee that there is at least one OR zero in η j . Thus, the syndrome corresponding to η j can be used for error correction in both cases.
1. If the algorithm finds that η j with j ≥ 2 is usable, the syndrome corresponding to η j can be used for error correction in both cases since there is an OR zero in η j .
2. Suppose that the algorithm finds that 0η 1 is usable. By Theorem 1, this can happen only when β 1 + γ 1 + 1 ≥ t (where γ 1 is the number of zeros in η 1 ). In Case C where I(1) is present, the substring η 1 1 must arise from γ 1 + 1 faults. Because the total number of faults in Case C must satisfy s ≤ t − 1, i.e., β 1 + γ 1 + 1 ≤ t − 1 must hold, the algorithm will never find that 0η 1 is usable when Case C happens. In other words, the algorithm will find that 0η 1 is usable only when Case D happens. It is okay not to perform any error correction in this case since Case D has no input error (the syndrome corresponding to 0η 1 is ⃗ s 1 = 0 which leads to no error correction).
Here we can construct an FTEC protocol correcting up to t faults that satisfies the weak FTEC conditions as follows:

Protocol 4. FTEC protocol satisfying the weak FTEC conditions for a stabilizer code of distance d ≥ 5
Let t = ⌊(d−1)/2⌋ be the weight of error that a stabilizer code of distance d can correct (d ≥ 5).
In each round of full syndrome measurements, measure stabilizer generators using the Shor syndrome extraction circuits. After the i-th round (i ≥ 2), calculate δ i−1 . Repeat syndrome measurements until one of the following conditions is satisfied, then perform error correction using the error syndrome corresponding to each condition: 1. If ⃗ s 1 ̸ = 0, obtain ⃗ δ ′ by removing the first bit of ⃗ δ.
(a) If at least one usable η j is found by Algorithm 1 where t in = t − 1 and ⃗ δ in = ⃗ δ ′ , stop the syndrome measurements. Perform error correction using the syndrome corresponding to any zero in η j .
(b) If the total number of non-overlapping 11 substrings in ⃗ δ ′ is t − 1, stop the syndrome measurements. Perform error correction using the syndrome obtained from the latest round.
(a) If at least one usable η j is found by Algorithm 1 where t in = t and ⃗ δ in = ⃗ δ ′ , stop the syndrome measurements. Perform error correction using the syndrome corresponding to any zero in η j .
(b) If the total number of non-overlapping 11 substrings in ⃗ δ ′ is t, stop the syndrome measurements. Perform error correction using the syndrome obtained from the latest round.
The number of rounds of syndrome measurements in the worst-case scenario of Protocol 4 for each of ⃗ s 1 ̸ = 0 and ⃗ s 1 = 0 cases, which is also the minimum number of rounds required to guarantee that a usable syndrome exists in each case, can be found by the following theorem: is the distance of a stabilizer code being used in Protocol 4. Performing the following number of rounds of full syndrome measurements is sufficient to guarantee that Protocol 4 is weakly t-fault tolerant; Proof. Suppose that Algorithm 1 is run with t in and ⃗ δ in . From the proof of Theorem 2 (provided in Appendix A), the maximum length of ⃗ δ in such that no usable zero substring is found by − 3 when t in is even). Let ⃗ δ = δ 1 δ 2 . . . δ m be the difference vector obtained from repeated syndrome measurements. First, consider the case that ⃗ s ̸ = 0 in which t in = t − 1 and if t is even (or t is odd), the maximum length of ⃗ δ ′ with no usable zero substring is t+2 . That is, a usable zero substring exists in ⃗ δ ′ when the length of ⃗ δ is t+2 . This is always achievable when ) rounds of full syndrome measurements are performed.
In any case, the syndrome corresponding to a usable zero substring found by Algorithm 1 can be used to perform error correction as described earlier in this section.
Similar to the protocols in Section 3, we do not have to complete the full syndrome measurements in the very last round of Protocol 3 or Protocol 4; we can check the difference between the syndromes of the two latest rounds (i and i − 1) more frequently, and run Algorithm 1 to find a syndrome suitable for error correction or stop as soon as we are certain that δ i−1 = 1 (the syndromes ⃗ s i and ⃗ s i−1 differ by at least one bit). Also, for a CSS code in which X-type and Ztype errors can be corrected separately, we can further reduce the total number of stabilizer generators; after a syndrome for correcting errors of X-type or Z-type is found, the minimum number of occurred faults can be calculated and used to find a syndrome for correcting errors of another type. See the technique proposed in Section 3 for more details.

Decoder Comparison
Compared to the traditional Shor FTEC scheme, our FTEC schemes with adaptive decoders require fewer rounds of syndrome measurements in the worst-case scenario. Because the faulttolerant threshold is related to the number of fault combinations that can cause a logical error (which is related to the total number of gates in the whole protocol), we expect to see a higher threshold when the number of rounds is reduced. In this section, we compare our adaptive decoders with the Shor decoder both analytically and numerically.

Improvement of the lower bound of the fault-tolerant threshold for a concatenated code
Consider an FTEC protocol that uses a stabilizer code of distance d = 2t + 1 with Shor syndrome extraction circuits. Let L be the number of locations (a single qubit preparation, a 1-qubit or 2-qubit gate, or a single qubit measurement) in each round of full syndrome measurements, and suppose that each location can fail with probability p. Also, let r 1 and r 2 be the numbers of rounds required in the worst-case scenario for the protocols with the traditional Shor decoder and the adaptive strong decoder from Section 3. Because both protocols are strongly t-fault tolerant, error correction can fail only when there are at least t + 1 faults in each protocol.
Let us first consider the protocol with the traditional Shor decoder. Pessimistically assuming that the protocol fails every time when t+1 faults occur, the number of fault combinations that can cause the protocol to fail is r 1 L t+1 . The logical error rate p (1) when the quantum data is encoded once satisfies, Let p T,1 = r 1 L t+1 −1/t . Eq. (1) can be rewritten as, (2) Suppose that the FTEC protocol for a concatenated code is constructed by recursively replacing each qubit in the protocol by a block of code and replacing each physical gate by a logical gate, the logical error rate p (m) when the quantum data is encoded m times satisfies, (3) The logical error rate p (m) can be suppressed to an arbitrarily small value by increasing the level of concatenation whenever p ≤ p T,1 ; that is, p T,1 is the fault-tolerant threshold for a concatenated code when the traditional Shor scheme is used. However, in practice not all combinations of t + 1 faults cause the protocol to fail, so p T,1 = r 1 L t+1 −1/t is actually a lower bound of the fault-tolerant threshold for the traditional Shor scheme.
Using similar analysis, a lower bound of the fault-tolerant threshold for the adaptive strong decoder is p T,2 = r 2 L t+1 −1/t . We find that for any x ∈ {0, . . . , t} when r 1 ≥ r 2 , the following holds; That is, This implies that the lower bound of the faulttolerant threshold for a concatenated code can be improved when the adaptive strong decoder is used instead of the Shor scheme. The improvement factor becomes larger as the distance of the base code for concatenation increases, and it reaches a factor of 4 as t → ∞.
It should be noted that the improvement factor of the actual fault-tolerant threshold can be lower than the factor in Eq. (6) since the ratio of the average numbers of rounds is most likely lower than the ratio of the numbers of rounds in the worst-case scenarios. Also, the analysis above is not applicable to families of codes in which a code of high distance can be obtained without concatenation, such as topological codes. In the next section, we present numerical simulations of hexagonal color codes which show that our adaptive strong and adaptive weak decoders can improve the pseudothreshold and the average number of rounds.

Improvement of the pseudothreshold and the average number of rounds for hexagonal color codes
To verify that our adaptive schemes are fault tolerant and have some advantages over the traditional Shor scheme, we simulate FTEC protocols on the hexagonal color codes of distance 3, 5, 7, and 9. The hexagonal color code of distance d is a [[(3d 2 + 1)/4, 1, d]] code [21]. It is a CSS code [30,31] in which X-type and Z-type generators have the same form. Hexagonal color codes of distance 3, 5, 7, and 9 are illustrated in Fig. 2.
Our simulations consider the circuit-level depolarizing noise model as described below.
1. Each 1-qubit gate is followed by X, Y , or Z error with probability p/3 each, i.e., the 1qubit symmetric depolarizing noise with error probability p.
3. Ancilla qubits for a measurement of weightw generator are initially prepared in a cat state of the form |0⟩ ⊗w + |1⟩ ⊗w / √ 2 and each qubit is subjected to the 1-qubit symmetric depolarizing noise with error probability p.

After each qubit measurement, the classical
outcome is subjected to a bit-flip error with probability p.
5. There is no idling (or wait-time) error.
Each stabilizer generator is measured using the Shor syndrome extraction circuit. After each round of full syndrome measurements, the difference vector is calculated. Syndrome measurements are performed until the difference vector satisfies the stopping condition of the decoder being used (which is the Shor, the adaptive strong, or the adaptive weak decoder). Once a usable syndrome is found, an EC operator is obtained by the minimum-weight decoder for a hexagonal color code, and it is applied to the output error from the last round of syndrome measurements. Finally, an ideal error correction is applied, and we verify whether the output error is a logical error.
(In our implementation of the Shor decoder, syndrome measurements stop when either (1) the syndromes are repeated t + 1 times in a row, or (2) the total number of rounds reaches (t + 1) 2 . Then, we use the syndrome from the last round for error correction. Note that the case in which the first condition is not satisfied but the number of rounds exceeds (t + 1) 2 only happens when the total number of faults is more than t. The second condition is introduced to prevent a simulation blowup.)  Table 3: Pseudothresholds and the average number of rounds for the hexagonal color codes of distance d = 3, 5, 7, 9 when the Shor, the adaptive strong, or the adaptive weak decoder is applied.
In our numerical simulations, we generate the syndrome extraction circuits using Cirq [32] and use Stim's Pauli frame simulator [33] as a C++ library to sample from them. On our plots, the data points are calculated from between 5 × 10 8 and 10 5 samples at lower error rates, and at high error rates, we stop the sampling when 1000 out of all samples resulted in a logical error. The plots are generated with Sinter [33]. Each data point is the number of logical errors divided by the number of samples. As the experiments follow the binomial distribution, this ratio is an estimator of the logical error rate p L . Using Bayesian hypothesis testing, Sinter [33] calculates the maximum and the minimum possible values of p L , and the bounds are represented with the shaded area. Any other distribution with p L outside these limits is highly unlikely, quantified by the Bayes factor of 10 3 . The software developed for the simulations in this work is similar to the one presented in [34], where the technical and implementation details of similar decoders are discussed.
Our numerical results are shown in Fig. 3 and Table 3. From the plots of logical error rates p L versus physical error rates p for each hexagonal color code (Fig. 3 left), we observe that all plots for the code of distance d = 2t + 1 are parallel to p L = p t+1 at low error rates. This means that the Shor, the adaptive strong, and the adaptive weak decoders are t-fault tolerant, i.e., the code distance is preserved. Furthermore, both adap-tive strong and adaptive weak decoders can increase the pseudothreshold 1 of each code (except for d = 3 in which the performances of the Shor and the adaptive strong decoders are very similar). As the code distance grows, the difference in the performances between the Shor and the adaptive strong decoders becomes larger. In contrast, the difference between the adaptive strong and the adaptive weak decoders becomes smaller.
From the plots of average number of rounds N versus physical error rates p for each hexagonal color code (Fig. 3 right), we find that the average number of rounds of the Shor and the adaptive strong decoders are similar when p is much lower than the pseudothresholds, but the difference becomes more noticeable as p increases. We also observe that the average number of rounds of the adaptive weak decoder are roughly 1 round fewer than that of the adaptive strong decoder for the entire range of p.
Moreover, we observe an interesting behavior of our adaptive decoders at the high physical error rate regime. For the hexagonal color code of distance d = 2t + 1, the average number of rounds for the adaptive strong and the adaptive weak decoders approach 2t + 1 and 2t, respectively. In contrast, the number for the Shor decoder approaches (t + 1) 2 . This is because the chance of observing repeated syndromes becomes exponentially small at high error rates. Thus, an average is dominated by the case that all bits of the difference vector are ones, which causes the Shor, the strong, and the weak decoders to stop at (t + 1) 2 , 2t + 1, and 2t rounds, respectively. Since N monotonically increases as p increases in every case, the observation suggests that FTEC on a code of distance d with our adaptive strong (or weak) decoder can be achieved by repeating no more than d (or d − 1) rounds of syndrome measurements on average. We also expect this result to hold for any stabilizer code.

Discussions and conclusions
In this work, we present FTEC schemes which are improved versions of the Shor FTEC scheme. Our protocols measure the error syndromes repeatedly using the Shor extraction circuits, then the difference vector is calculated from the differences of syndromes between any two consecutive rounds. Afterwards, a syndrome for error correction is determined by the pattern of the difference vector. We call this kind of technique an adaptive measurement technique since the condition to stop repeated syndrome measurements changes dynamically depending on the measurement results. This is in contrast to the traditional Shor FTEC scheme, where syndrome measurements are done until the results are repeated t+1 times in a row regardless of the measurement results.
Our protocols with the adaptive strong and the adaptive weak decoders (which satisfy the strong and the weak FTEC conditions in Definitions 1 and 2) are developed in Sections 3 and 4, respectively. The protocol with the adaptive strong decoder can be applied to a concatenated code by replacing each qubit (and each physical gate) in the protocol with a code block (and the corresponding logical gate). On the other hand, the protocol with the adaptive weak decoder does not support code concatenation but can be applied to code families in which a code of higher distance can be obtained without code concatenation. The maximum number of rounds required for the protocols with the strong and the weak decoders are proved in Theorems 2 and 3. For a stabilizer code that can correct up to t errors, the protocol with the strong decoder requires no more than (t + 3) 2 /4 − 1 rounds of syndrome measurements, while the protocol with the weak decoder requires no more than (t + 3) 2 /4 − 2 rounds (or no more than (t + 2) 2 /4 rounds) if the syndrome from the first round is trivial (or nontrivial). The maximum numbers of required rounds for t = 1, . . . , 9 for each of our protocols are compared in Table 4.
In Section 5.1, we analytically show that compared to the Shor decoder, our adaptive strong decoder can improve the lower bound of the faulttolerant threshold when applied to a concatenated code. The improvement factor for the bound approaches 4 times when the distance of the base code for concatenation approaches infinity. However, it should be noted that the number of rounds used in our analysis is the number of rounds for the worst-case scenario, not the average number of rounds. Thus, the improvement factor for the actual threshold might be lower than 4 times as the worst-case scenario is very unlikely. In Section 5.2, we present numerical simulations of FTEC protocols with the Shor, the adaptive strong, and the adaptive weak decoders on the hexagonal color codes of distance d = 3, 5, 7, 9. The results show that the protocols with adaptive decoders preserve the code distance and can indeed improve the pseudothreshold. Interestingly, we also find that while the maximum number of rounds for each of our adaptive decoders grows quadratically as the code distance grows, the maximum of the average number of rounds grows linearly (in contrast to the Shor decoder in which both numbers grow quadratically). The results suggest that our FTEC protocols with adaptive decoders applied to any stabilizer code of distance d require no more than d rounds of syndrome measurements on average.
We expect that the adaptive measurement technique from Sections 3 and 4 could be applicable to other fault-tolerant protocols in which eigenvalues of Pauli operators are measured using circuits similar to the Shor syndrome extraction circuit, and the ancilla measurement faults are handled by repeated measurements. An extension of our adaptive decoders to flag FTEC is developed in [34]. Other possible protocols that could be improved by our adaptive scheme are fault-tolerant protocols for operator measurements [35], and for code-switching [36,37,38,39]. However, one has to make sure that the protocols are modified in a way that the conditions for fault tolerance for such tasks are satisfied. A careful
Note that in our adaptive measurement technique, each bit of the difference vector δ i indicates the difference of the whole syndromes ⃗ s i−1 and ⃗ s i . One possible research direction would be seeing how an FTEC protocol can be improved by comparing each pair of bits of ⃗ s i−1 and ⃗ s i . Another possible direction would be improving the protocol by comparing syndromes from nonconsecutive rounds (for example, ⃗ s i−2 and ⃗ s i ). We point out that the standard FTEC method for a surface code of distance d = 2t + 1 performs d rounds of syndrome measurements [40]. If our adaptive measurement technique is modified using the aforementioned ideas, hopefully, we can obtain an FTEC protocol that the maximum number of rounds (not the maximum average number of rounds) grows linearly in d similar to the FTEC protocol for a surface code, but is applicable to any stabilizer code. It might be harder to classically compute a syndrome for error correction from the measurement results, but the amount of required quantum resources may decrease, making the FTEC protocol more practical.
Last, we point out that the FTEC protocols developed in this work are applicable to any stabilizer code; we did not use any specific code structure in our development. It has been shown in [14] that when tailored for specific families of codes, FTEC protocols with adaptive syndrome measurements can be further improved. We are hopeful that the FTEC protocols developed in this work could be further optimized for some families of codes as well.

Acknowledgements
We thank Shilin Huang and other members of Duke Quantum Center for helpful discussions on protocol development and possible future directions. The work was supported by the Office of the Director of National Intelligence -Intelligence Advanced Research Projects Activity through an Army Research Office contract (W911NF-16-1-0082), the Army Research Office (W911NF-21-1-0005), and the National Science Foundation Institute for Robust Quantum Simulation (QLCI grant OMA-2120757).

A Proof of Theorem 2
Let ⃗ δ be a difference vector obtained from repeated syndrome measurements, and suppose that there are at most t faults in the FTEC protocol. First, consider the case that all bits in ⃗ δ are ones. The repeated syndrome measurements in Protocol 2 will stop when length( ⃗ δ) = 2t, i.e., the number of rounds is 2t + 1. In this case, there are I(2), I(4), ..., I(2t) faults, thus the syndrome ⃗ s 2t+1 is correct and can be used for error correction.
Next, consider the case that at least one bit in ⃗ δ is zero. We will show that the maximum length of ⃗ δ such that a usable zero substring does not exist (i.e., Algorithm 1 cannot return any usable zero substring when t in = t and ⃗ δ in = ⃗ δ) is  − 2 and t is even), at least one usable zero substring must be found by Algorithm 1. The number of rounds that gives such a difference vector is t+3 2 2 − 1 when the number of required operations is linear in the length of ⃗ δ. After the calculations, the condition α j + β j + γ j ≥ t which requires a constant number of operations is checked. Thus, computing whether each η j is usable requires no more than K 1 t+3 2 2 − 2 + K 2 operations where K 1 , K 2 are some constant numbers. For any t, the total number of one bits in ⃗ δ is at most 2t since each fault causes at most two ones in ⃗ δ. Because ⃗ δ is of the form η 1 1η 2 1 . . . 1η c , the maximum number of η j is 2t + 1. Therefore, total number of operations in Algorithm 1 is no