Continuous quantum error detection and suppression with pairwise local interactions

Performing measurements for high-weight operators has been a practical problem in quantum computation, especially for quantum codes in the stabilizer formalism. The conventional procedure of measuring a high-weight operator requires multiple pairwise unitary operations, which can be slow and prone to errors. We provide an alternative method to passively detect the value of a high-weight operator using only two-local interactions and single-qubit continuous measurements. This approach involves joint interactions between the system and continuously-monitored ancillary qubits. The measurement outcomes from the monitor qubits reveal information about the value of the operator. This information can be retrieved by using a numerical estimator or by evaluating the time average of the signals. The interaction Hamiltonian can be effectively built using only two-local operators, based on techniques from perturbation theory. We apply this indirect detection scheme to the four-qubit Bacon-Shor code, where the two stabilizers are indirectly monitored using four ancillary qubits. Due to the fact that the four-qubit Bacon-Shor code is an error-detecting code and that the Quantum Zeno Effect can suppress errors, we also study the error suppression under the indirect measurement process. In this example, we show that various types of non-Markovian errors can be suppressed.


I. INTRODUCTION
In many conventional quantum algorithms, circuits are presented in discrete time-unitary operations and measurements are treated as if they happened instantly. However, each quantum gate requires an operational duration, during which, errors can also happen. These effects can be captured in a continuous-time description of the evolution of a quantum system. Continuous measurement can be naturally incorporated into this framework. In fact, continuous weak measurement has been extensively studied and used for both practical applications and fundamental understanding [1][2][3][4][5][6][7]. In particular, continuous measurement for single-qubit observables has been well studied both theoretically and experimentally [4,6,8,9]. There have been earlier studies of simultaneous continuous measurements of the non-commuting operators in the Bacon-Shor code [10,11], under the assumption that continuous measurements of the two-local operators exist. The same two-qubit continuous measurement is used in a more recent work [12] for error correction and suppression under time-dependent Hamiltonians. However, methods to perform practical continuous measurement of multi-qubit observables have not been fully developed.
In the context of continuous quantum error correction, early work by Paz and Zurek [13] introduces a jump-like error correction process, where the recovery operation is applied with probability γdt at each time step dt with rate γ. This continuous-time jump-like error correction * yihsianc@usc.edu † tbrun@usc.edu process can be realized as applying a sequence of weak measurements [14], and the minimum number of the required ancillary qubits is found to be n − k + 1 for an [[n, k, d]] code [15]. Another framework proposed by Ahn, Doherty, and Landahl (ADL) [16] uses continuous measurements with feedback control to maintain the fidelity of an unknown quantum state. Some feedback-based error correcting protocols related to the ADL scheme are studied in [17][18][19][20].
A major practical difficulty of almost all continuous quantum error correction schemes is that they assume that it is possible to continuously measure multi-qubit operators. Measuring high-weight operators is crucial for many quantum codes in the stabilizer formalism [21]. The surface code [22,23], for example, has stabilizer generators of weight four, and other codes can have even higher-weight stabilizers. To continuously measure these high-weight operators is challenging, since it requires Hamiltonians with many-body terms.
In this paper, we introduce a method to indirectly detect the value of a high-weight operator using local two-body interactions and single-qubit continuous measurements. The approach involves applying an interaction Hamiltonian for the system and additional qubits that are being continuously monitored. The information of the system's value for the observable translates into different signatures of the monitored qubits, which we can identify. The setup can be applied to quantum codes where we detect errors by measuring the stabilizers. As an example, we apply this detection scheme to the four-qubit Bacon-Shor, which is an error-detecting code that can detect errors by measuring two-local operators [24]. In this paper, we focus on the measurements of the weight-four stabilizers in the error-detecting Bacon-Shor code.
It is well-known that the Quantum Zeno Effect can freeze a state in an eigenstate of an observable that is frequently measured. Since the four-qubit Bacon-Shor code is an error-detecting code, we examine whether errors can be suppressed when we apply the continuous indirect measurement of the stabilizers. In [25], it is shown that non-Markovian errors can be suppressed by the Zeno effect when the system is being directly measured. Our results for indirect detection also agree with this observation.
The paper is organized as follows. In Sec. II, we introduce in detail the theory behind continuous indirect detection. We also show how to retrieve the information in the monitored qubits. In Sec. III, we demonstrate the application to the four-qubit Bacon-Shor code including the process of error detection and error suppression. In the last section IV, we provide a construction of the target Hamiltonian using only two-local interactions.

II. INDIRECT DETECTIONS
Suppose we want to detect the value of a Pauli operator O with eigenvalues +1 and −1 for a system. We design a Hamiltonian H = (k/2)(I − O)X m coupling the system to an additional monitor qubit m. It is convenient to rewrite the Hamiltonian in terms of projectors, i.e., H = kΠ − X m , where Π − is the projector onto the −1 eigenspace. The intuition behind this construction is that m will be static when the system is in the O = +1 eigenspace, while Z m will rotate when the system is in the O = −1 eigenspace. By measuring Z m , we gain information about which eigenspace the system is in. Therefore, we continuously measure Z m with measurement rate λ to indirectly measure the value of O. The measurement outcomes are given by a continuous output current I(t) [1, 2], with where dW is a Wiener process with zero mean and variance dt. The whole system evolves according to where This process drives ρ towards one of the eigenspace of O.
To observe this, we expand Eq. (2) using Ito's rule [26,27]: The expectation value of O evolves as where · ≡ Tr [ · ρ] is the expectation value. Here, O is a time-dependent stochastic variable. Since d O is proportional to the Weiner increment, the evolution of O is a random walk with a time-varying step size. This implies the following two properties: (1) the ensemble average of O remains constant at its initial value. (2) the variance of O tends to increase with time. The first property can be observed by the fact that The change of the variance of O is Eq. (7) implies that O tends to deviate from its average which remains at its initial value due to Eq. (6). However, O is bounded between −1 and 1. The increase of the variance implies that O approaches either +1 or −1 at later times. As O becomes close to ±1, we have Z m O ≈ Z m O , and the step size of the random walk becomes small. Hence, O tends to stabilize at ±1.
is stable. This shows that when ρ is constantly monitored by Z m , the process drives it towards an eigenspace of O. The probabilities of ρ approaching the O = ±1 eigenspaces also match the probabilities of getting the outcomes ±1 when an O measurement is directly applied to ρ. This is a direct consequence of Eq. (6) and the fact that O → ±1 at later times. In fact, after a period when O → ±1, where Tr I±O 2 ρ(0) are the probabilities of getting the results ±1 when an O measurement is performed on the system. This implies Tr I±O 2 ρ(0) = P ( O → ±1). These properties validate the whole process as a proper O measurement on the quantum system.

A. Detection methods
The value of O , however, is not directly accessible because only Z m is being continuously measured. In order to learn the value of O, we can use an estimatorρ, prepared maximally mixed, to evolve according to Eq. (2) with the outcomes dI from the Z m measurements of ρ. The information contained in dI steersρ to the correct eigenspace ρ is in. The following explains this behavior.
Since H commutes with O, the evolution from Eq. (2) does not cause transitions between the eigenspaces of O. If a state starts in a block diagonal form, i.e., such that Tr [Oρ ± (0)] = ±1, p ± (0) ≥ 0 and p + (0) + p − (0) = 1, then the state maintains the same block diagonal structure at all later times: where Tr [Oρ ± (t)] = ±1, p ± (t) ≥ 0 and p + (t) + p − (t) = 1 for all t ≥ 0. (ρ ± (t) are proper density matrices.) To evaluate how p ± evolves with time, we look at the expectation values of the eigenspace projectors, where N = Tr A(dI)ρ(t)A † (dI) . For infinitesimal dt, one can deduce that where Z m ρ± = Tr [Z m ρ ± (t)]. (The derivation is in Supplemental Material.) This form is essentially the same as Bayes's theorem-our knowledge of the probability of ±1 given the outcome dI is where the exponential represents the Gaussian distribution of the stochastic variable dI, given the value +1 or −1. The evolution for ρ ± (t) is which has the same form as Eq.
(2). This implies the following fact. If two initial states, ρ 1,2 (0) = σ 1,2 ⊗ |0 m 0|, are both in the +1 or both in the −1 eigenspace, i.e., O ρ1,2(0) = +1 or O ρ1,2(0) = −1, and they both evolve according to Eq. (2) with the same set of measurement operators A(dI), then we have Z m ρ1 = Z m ρ2 for any time. This is because for any state strictly in either O = ±1 eigenspace, the evolution of the whole system only involves the evolution of the monitor qubit m. Since both m's of ρ 1,2 are initially prepared in |0 m 0|, it is true that Z m ρ1 = Z m ρ2 for all times. These results are sufficient to show the steering effect of the estimator. Let us use an estimatorρ to represent our knowledge of a real system ρ real that is constantly monitored through the measurements of Z m . We initialize the estimator to be maximally mixed in the system part to represent our ignorance of the system. The initial state of the estimator can be written aŝ where d is the system dimension excluding m. The estimator initially has p ± (0) = 1/2 and ρ ± (0) = (2/d)Π ± ⊗ |0 m 0|. Suppose the real system ρ real (0) is in the O = −1 eigenspace and is coupled to a monitor qubit m prepared in state |0 m 0|. Continuously measuring Z m gives outcomes We use the signal dI from ρ real to evolveρ according to Eq.
(2). Since both ρ real (t) and ρ − (t) are in the O = −1 eigenspace and have the same initial state of m, we have for any time t ≥ 0. The ratio of the p ± becomes It shows that the ratio of p + /p − decreases on average due to the difference between Z m ρ real and Z m ρ+ . Since H = kΠ − X m , only the negative eigenspace causes transitions. Therefore, it is evident that Z m ρ real = Z m ρ+ = 1 for most times. It is expected that p − → 1 and p + → 0 at later times. If ρ real is in the O = +1 eigenspace, the ratio becomes where Z m ρ real = Z m ρ+ = 1. We will have p + → 1 and p − → 0 instead. The above shows that when ρ is in an eigenspace of O, the measurement records dI driveρ to that eigenspace. If O ρ approaches +1, we learn that ρ real is in the eigenspace of O = +1. If O ρ approaches −1 then ρ real is in the eigenspace of O = −1. These results are sufficient for error detections on general stabilizer codes, where we prepare the encoded state in the joint +1 eigenspace of a set of commuting operators. For each stabilizer O i , we attach an extra qubit m i to the system with Hamiltonian (1/2)(I −O i )X mi and continuously measure Z mi . From the signals of measuring Z mi , we are able to detect if errors have taken the state out of the stabilized space. However, simulating the evolution of the estimator requires computational overhead. As the system size grows, the exponential increase of the matrix dimension makes the method of simulating the estimator impractical. We provide in the following an alternative method to retrieve the information contained in the outcomes dI without simulating the whole quantum state.
Note that in this particular setup where H = kΠ − X m , it is clear that if the state ρ is in the +1 eigenspace then Z m = 1 at all times. The signal becomes a Wiener process with a constant drift, i.e., dI = 1dt + (dW/2 √ λ). We can evaluate an average function of dI defined by where w is the window width which is short compared to the average time between errors (1/the rate of errors) but long compared to the inverse of the measurement rate on the monitor qubits (1/λ), i.e., (1/λ) w (1/the rate of errors). In the case where ρ is in the +1 eigenspace, the average function reads The variance of I(t) is Var Because E I(t) = 1 and Var I(t) is inversely proportional to time, we should expect that I(t) converges to 1 after t ≥ w. If ρ is in the −1 eigenspace, there will be oscillations of Z m . The dynamics of Z m involve The X m in H causes a rotation of the y-z plane in the Bloch sphere for the monitor qubit m. The first terms in above equations indicate such a rotation. The exponential suppression in the second term for Y m is due to the measurements on Z m . The average function of dI becomes where Z m denotes the average value of Z m over an integration period, i.e., Since there are oscillations of Z m between −1 to 1, Z m should be noticeably smaller than 1. The later simulation shows that I(t) approaches zero after a period of time, when ρ is in the −1 eigenspace. By directly evaluating I(t) from the measurement outcomes, one can determine whether the state is in the +1 eigenspace. Although this method is noisier than the method of calculating O ρ from the estimator, it significantly speeds up the process of detecting errors. The relative size between the strength of the Hamiltonian k and the measurement rate λ plays a role in determining the effectiveness of this indirect detection scheme. If λ is too large, then the frequent measurements on Z m freeze m in the state |0 m 0| due to the quantum Zeno effect. In this case, Z m stays close to 1 for a much longer time, and the information gain is greatly reduced. If λ is too small, the ratio, in Eqs. (18) and (19), between p + and p − changes slowly. The rate at which the estimator approaches either ±1 eigenspace becomes small. This is also not an ideal limit for learning the value of O for ρ. From our testing, the most efficient regime is around λ = 0.5k ∼ 1.5k.
In most cases, the stabilizers are high weight operators, e.g., weight four stabilizers in the surface code. Directly measuring these high weight operators requires multiple gate operations, which can be more inaccurate. This passive indirect detection scheme can provide an alternative way to measure these stabilizers. In Sec. IV, we show how the desired Hamiltonians can be effectively constructed by 2-local operators. In the following subsection, we provide a minimal example demonstrating the process and the behavior of the indirect detection method. We set λ = 0.6k and the time unit to be 1/k throughout the rest of the paper.

B. ZZ example
We provide a simple 3-qubit example to demonstrate the indirect detection scheme. Suppose we want to know the value of the operator Z 1 Z 2 for qubits 1 and 2. We bring in an additional monitor qubit m and turn on the joint Hamiltonian H = (k/2)(I − Z 1 Z 2 )X m . Under continuous measurements of Z m with outcomes dI, the whole state ρ evolves according to Eq. (2). In experiment, dI are obtained from the measurement apparatus. For simulation, the outcomes are generated using where dW is a Wiener process. Figs. 1a and 1b show the dragging effect of the estimator-if the state ρ is in the Z 1 Z 2 = ±1 eigenspace then the estimatorρ approaches the eigenspace ρ is in. From the value that Z 1 Z 2 ρ approaches, one can know which eigenspace ρ is in. The plots Figs. 1e and 1f are the ensemble average over 500 trajectories of Z 1 Z 2 ρ . The other method to translate the information contained in dI is to evaluate the average function I(t) defined by Eq. (20). For convenience, we choose w = 40/k and evaluate I(t) from time 0 to w. Figs. 1c and 1d represent the average functionĪ(t). It converges to 1 when the physical state is in the +1 eigenspace, and it converges to 0 when the state is in the −1 eigenspace.
Note that there is a trade-off between accuracy and efficiency for the two methods-the estimator approach gives a more stable readout comparing toĪ(t) but requires computational overhead. The estimator approach can be more accurate for theoretical analysis while the average function is more experimentally feasible.

III. AN APPLICATION TO THE FOUR-QUBIT BACON-SHOR CODE
The 4-qubit Bacon-Shor code is an error-detecting code that can detect errors by measuring only weight-two operators. In the stabilizer formalism, it has two weightfour stabilizers, S z = ZZZZ and S x = XXXX. Checking if the system stays in the joint S z = +1 and S x = +1 eigenspace allows us to detect single-qubit errors. To measure the stabilizers, we could in principle bring in two extra qubits m z and m x and apply the Hamiltonian with continuous measurements on Z mz and Z mx . However, applying the weight-five Hamiltonian requires many-body interactions and is experimentally hard. As we show in Sec. IV, the above Hamiltonian would appear in the fifth-order expansion of the perturbation construction. It means that the base Hamiltonian should be five orders of magnitude stronger than the Hamiltonian needed for indirect detection. This poses a practical challenge for experiments. To reduce the energy scale, we can instead use which involves only 3-local interactions. As shown in Sec. IV, this Hamiltonian appears in the second order expansion of the perturbative construction, where m z and m x are effective two-level systems. To gain insight into this setup, let us first recall the stabilizer formalism for the 4-qubit Bacon-Shor code. The code uses four physical qubits to encode one logical qubit and can detect any single-qubit error. The Hilbert space decomposes into tensor products of four subsystems with the following set of commuting operators and their complements, for the four eigenspaces. The red isĪ z (t) and the blue isĪ x (t). The average function converges to 1 (or 0) if the corresponding stabilizer is in the +1 (or −1) eigenspace.
The encoded basis is |Z L Z G S x S z . We add a bar on each bit for the encoded basis to distinguish it from the physical basis. For example, |0101 represents the basis vector corresponding to Z L = +1, Z G = −1, S x = +1 and S z = −1. The relationship between the two bases can be found in Table I. In this encoded basis, it is convenient to rewrite Eq. (27) as where Π Sz − and Π Sx − are projectors onto their −1 eigenspaces. The signature for the state being in either combination of S z = ±1 and S x = ±1 is clear: when the state is in the S z = +1 and S x = +1 eigenspace, the monitor qubits are static; when either S z or S x is −1, there are oscillations for Z mz or Z mx . Note that since there is no term involving Z L or X L , the logical qubit is perfectly preserved during the process of indirect detection. The gauge qubit can be treated as an external degree of freedom for the system, where its dynamics are irrelevant. The non-commutativity between the two terms in H is on the gauge system, and does not affect the detection process. We prepare the state in the simultaneous +1 eigenspace of S z and S x and continuously monitor Z mz and Z mx . If there is no error, we should observe static values of Z mz,x , which are both one in our setting. If an error takes the state out of the +1 eigenspace of a stabilizer then we can detect it by the nonstatic evolution of Z mz,x . However, these expectation values are not directly obtained from experiments. The outcomes of the continuous measurements are dI z,x = Z mz,x dt + dW z,x /2 √ λ. To retrieve information contained in Z mz,x , we can evaluate the time average of the signals defined in Eq. (20). We can also use an estimatorρ to learn the stabilizer values as described in Sec. II. From the outcomes dI z,x = Z mz,x ρ dt + dW z,x /2 √ λ, we evolve the estimator according tô where The estimator is initially maximally mixed and can be decomposed into four blocks, i.e., where p αβ (t) = Tr Π Sx α Π Sz βρ (t) and ρ αβ (t) = Π Sx α Π Sz βρ (t)Π Sz β Π Sx α . The evolutions for the probabilities become When ρ is in the eigenspace of S x = α and S z = β, the p αβ of the estimator has the largest increase on average. Hence, the estimator approaches the eigenspace of S x = α and S z = β. The argument mostly follows the discussion in Sec. II for each S x and S z . Simulations of the time-averaged signal and of the estimator approach, over 500 trajectories, are shown in Fig. 2 and Fig. 3. We use the following initial states as examples for the system being in the four eigenspaces of S . 3: The estimator approach. The blue is the evolution of S x ρ . The red is the evolution of S z ρ . It is shown that the estimator approaches the eigenspace the system belongs to. and S z = ±1: where they are expressed in the encoded basis |Z L Z G S x S z . ρ(0) is one of the states above with monitor qubits initialized in state |0 0|.
A. Error analysis

Error detection
When we apply the four-qubit Bacon-Shor code, we prepare the state in the S x = +1 and S z = +1 eigenspace and store information in the logical qubit of the state. To detect errors, we attach monitor qubits to the system and continuously measure them. If there are no errors, the monitor qubits are static and bothĪ z,x (t) converge to 1. Or we can simulate the estimator, which will approach the joint +1 eigenspace. Let us first consider single-qubit errors. Suppose an X 1 error happened on the first system qubit. The error anticommutes with S z and the state is taken to the S z = −1 eigenspace. A sample trajectory is shown in Fig. 4, where the error is detected by observing thatĪ z (t) drifts to 0 and S z ρ flips to −1.
We present another example where the errors are continuous-in-time 1/f Hamiltonian errors, i.e., where each σ i is a single-qubit Pauli matrix acting on the ith qubit and i (t) is a time-dependent scalar function. Each i (t) consists of exponentially decaying random pulses with magnitude , i.e., where θ(t) is the Heaviside step function [28]. In Sec. III A 2, it is shown that this type of error can be suppressed by implementing continuous indirect measurements. For most trajectories, the system stays close to the S z,x = +1 eigenspace.Ī z,x (t) converges to 1 while S z,x ρ approaches 1 and stays at 1. Occasionally, the error can cause the system to jump to the −1 eigenspace of S z,x . A sample trajectory of this case is shown in Fig. 5, where we detect the system's S x jumping to −1 by observing thatĪ x (t) starts to decay to 0 and S x ρ flips to −1. In general, since any single-qubit Pauli error anticommutes with at least one of the S z,x , any single-qubit error can be detected. Multi-qubit errors can be detected when they consist of operators anticommuting with one of the S x,z . The undetectable errors are those commuting with both S x,z . However, they must be at least weight 2. They happen at lower rates than single-qubit errors. We now consider the cases when errors happen on the monitor qubits. Note that the essential indicator that allows us to distinguish the four eigenspaces of S x,z = ±1 is whether Z mz,x is static or oscillatory in motion. When S x,z is +1, Z mx,z is static. When S x,z is −1, Z mx,z is oscillatory. It turns out that the process of stabilizer detection can be preserved with low rate errors on the monitor qubits. Let us begin with the case of instantaneous errors on the monitor qubits. Suppose an X mz error happened on the monitor m z . If Z mz was static (because the system is in the S z = +1 eigenspace), Z mz flips  5: (a) shows S z,x for the system. After a period, S x is flipped to −1 while S z remains at +1. (b) shows I z,x (t). After a period,Ī x (t) starts to decay whileĪ z (t) remains at +1. (c) shows S z,x ρ for the estimator. S x ρ approaches +1 initially, but it flips to −1 after S x → −1.
FIG. 6: A sample ofĪ x,z (t) with an X mz error at t = 20 and an X 1 error at t = 100. The red curve represents I z (t), and the blue curve representsĪ x (t).Ī x (t) remains at 1 because the errors commute with S x .Ī z (t) flips to −1 due to the X mz error and then converges to 0 after the X 1 error happened. The window width w is set to 40/k in this example. from +1 to −1 but remains static. As shown in Fig. 6, I z (t) converges to −1 after an X mz error happened at t = 20, and then a subsequent X 1 error happened at t = 100 is detected by observingĪ z (t) evolving to 0. If Z mz is oscillatory, an X mz flips the value of Z mz but does not change the oscillatory motion. In general,Ī x,z (t) converging to ±1 indicates that there was no error, and eitherĪ x,z (t) converging to 0 indicates there was an error. When such instantaneous errors happen with rates much smaller than 0.1λ, which is approximately the inverse of the measurement time for the indirect detection, the error detection process is preserved. For continuous Hamiltonian errors, since the monitors are being continuously measured, errors with strength much smaller than the measurement rate λ are partially suppressed by the quantum Zeno effect. Hence, the process of detecting errors on the encoded four-qubit system can be preserved even with low-rate errors on the monitors. However, if the errors happen at high rates, it can cause rapid flipping that mimics the oscillatory effect of Z mz , which normally would occur only when S z = −1. In that limit indirect detection becomes ineffective. Of course, these conclusions are for the particular error model we have been considering. Experimental measurements of the error process might suggest alternative versions of this scheme, e.g., measuring X mz instead of Z mz if there are mainly X mz errors. In the full construction described in Sec. IV, the qubits m z and m x are two pairs of physical qubits (a, b) and (c, d) . Each pair (a, b) and (c, d) is confined to the ground space of the strong base Hamiltonian, (K/2)(I − Z a Z b ) + (K/2)(I −Z c Z d ). X a X b and X c X d in the effective Hamiltonian cause transitions only within the ground space, i.e., |00 ↔ |11 . Hence they act as X mz,x for the effective two qubits m z and m x . The process of detecting errors for the encoded system is similar: when S z = +1, both a and b are static; when S z = −1, both a and b are oscillatory. The same applies to c and d for S x . We only need to continuously measure one qubit for each pair, e.g., measuring a and c. If errors can happen on the monitor qubits, it follows similarly from the above argument that the error detection process for the system qubit can be preserved under low-rate errors.

Error suppression
It is well-known that frequent measurements can freeze a system in an eigenspace of the measurement observable due to the quantum Zeno effect. There have been many efforts to harness the Zeno effect for error suppression [29][30][31]. In [25], it is shown that non-Markovian errors can be suppressed by the quantum Zeno effect while Markovian errors can not. In this subsection, we investigate error suppression for various models under continuous indirect measurements. We first consider the 1/f Hamiltonian errors defined in Eq. (34), where the sum is over all physical qubits. In Fig. 7, we plot the ensemble average of the system's stabilizer values under this 1/f Hamiltonian error. As shown in Fig. 7a, the red and blue curves represent the case with indirect detection while the purple and yellow curves represent the case without the measurement setup. The pulse rate and are 0.1k and τ ∼ 1/k, where k is the strength of the Hamiltonian. The measurement rate λ is set to 0.6k. The red and blue curves decay noticeably more slowly than the purple and yellow, which shows that the system state tends to remain in the S z,x = +1 eigenspace in the presence of indirect stabilizer detection. Note that 1/f Hamiltonian noise is a type of non-Markovian error process. The exhibited suppression aligns with the result in [25] that non-Markovian errors can be suppressed by the quantum Zeno effect. We present another example of non-Markovian errors, where the errors are constant Hamiltonian terms, i.e., H err = σ i . To keep the same error magnitude as in the 1/f noise case, the is set to 0.01k, which is the average strength of i (t) in the 1/f noise. The result is shown in Fig. 7b. Convergence to the joint +1 eigenspace of S z,x is apparent when indirect detection is applied.
Another method to benchmark the state protection is to evaluate the trace distance between the state at time t and the initial state [29]. The smaller the trace distance the closer the state remains to its initial state. Fig. 8 shows a clear protection of the state when the system is being measured.
However, when the errors are Markovian (white noise) the measurements do not appear to fix the stabilizer values, as shown in Fig. 7c. For Markovian noise, the probability of a state transition is of order dt for a time step. Errors of this type cannot be suppressed by frequent measurements and full error correction is required to protect the states. For non-Markovian noise, by contrast, the probability of a state transition is of order dt 2 in a time step. This is why these transitions can be suppressed by the quantum Zeno effect [25]. The above simulations for continuous indirect measurements agree with these results. It is worth noting that for the purpose of error prevention, it is possible in principle to suppress Hamiltonian errors by applying a strong Hamiltonian alone. For example, suppose we have a qubit prepared in the |0 state in the Z basis with the presence of an X Hamiltonian error. The error can cause the state to rotate on the y-z plane in the Bloch sphere. However, if we apply a Z Hamiltonian, which is strong comparing to the error term X, the rotating axis becomes closely aligned with the z-axis. The evolution for the state will be confined in a small region near the north pole. The region can be made smaller as we increase the strength for the Z term. Therefore, the state is maintained close to its initial state |0 . Recall the setup in the indirect measurements. We require interaction Hamiltonians between the system and the monitor qubits. These Hamiltonians also contribute to the suppression of errors because of the above axis-pinning behavior. However, if an error term has a time-dependent coefficient with a frequency component on resonance with energy differences in the system Hamiltonian, transitions are not suppressed. In this case, applying the Hamiltonian alone is not effective FIG. 9: The evolution of S z under an on-resonance X 1 error. The blue curve is the case when the full indirect detection scheme is applied. The red curve is the case when the Hamiltonian for indirect detection is applied but no measurements are made on the monitor qubits.
against the error. However, applying both the Hamiltonian and the continuous measurements on the monitor qubits performs better in these cases as shown in Fig. 9. Overall, continuous indirect measurements can protect encoded states against errors.

IV. CONSTRUCTING THE HAMILTONIAN FOR INDIRECT DETECTION
In this section, we show how to build an effective Hamiltonian for indirect detection. The method is based on the idea of perturbation gadgets [32]. It uses 2-local Hamiltonians to produce an effective k-local Hamiltonian that appears in the first non-vanishing order for the lowlying energy eigenstates. We begin by briefly recapping the theory presented in [32].
Suppose we have a strong base Hamiltonian H (0) and a weak potential V . H (0) has zero ground state energy with a degenerate ground space G (0) spanned by eigenvectors |e 0 1 . . . |e 0 d , and V weakly perturbs it. The total Hamiltonian H = H (0) + V will have a d-dimensional vector space G spanned by the d lowest energy eigenstates |e 1 . . . |e d . For small enough , G largely overlaps with G 0 . The space spanned by the lowest d energy eigenstates has an effective Hamiltonian which can be expanded in powers of , i.e., (37) The operator P 0 projects any vector onto the unperturbed ground space G (0) , and the linear operator U satisfies UP 0 |e i = |e i and UG (0)⊥ = 0.
The operator S l is where P i is the projector corresponding to the energy level E (0) i of the base Hamiltonian H (0) . The summation (m−1) is over nonnegative integers l 1 , l 2 , . . . , l m−1 such that l 1 +· · ·+l m−1 = m−1 and l 1 +· · ·+l x ≥ x for any x from 1 to m−1. U and U † can also be expanded in powers of but only their zeroth order terms, which are both P 0 , will contribute in the later discussion. A more detailed derivation of these results can be found in [32]. Note that the expansion converges only if || V || < ∆E (0) /4, where ∆E (0) is the energy gap between the ground energy (assumed zero) and the second lowest energy. To have a good approximation from the perturbation, we would expect || V || to be much smaller than ∆E (0) . In this limit, the effect of adding V to H (0) becomes a small splitting of the degenerate ground space with a small deviation from the ground space G (0) to G. When an initial state is prepared in G (0) , its evolution stays mainly in G and the effective Hamiltonian H eff will be a good approximation for H.
The following construction for the indirect measurement requires us to design 2-local Hamiltonian terms H (0) and V such that the first non-vanishing order of the expansion gives the desired Hamiltonian.

A. First example: ZZ detection
Suppose we want to measure Z 1 Z 2 for qubits 1 and 2, and the desired Hamiltonian is We bring in two ancillary qubits m 1 and m 2 , and turn on a Hamiltonian H = H (0) + V , where and the perturbing term is K is a constant and 1. (Note that the identity term in the base Hamiltonian is unnecessary but we keep it for convenience.) The expansion of H eff in Eq. (37) up to second order in gives The ancillary qubits are prepared in the ground space, G (0) = H 12 ⊗ span{|00 , |11 } m1m2 , and the effective (or rate). We numerically simulated an example with 2 ∼ 0.001 to demonstrate the performance of the full perturbative construction. The result for S z is shown in Fig. 10. ( S x behaves similarly.) The ensemble averages of trajectories for S z are plotted for various cases. The orange curve represents the no-error case when we apply the full construction using only 2-local Hamiltonians from Eqs. (46) and (47) and continuous measurements of Z a and Z c . When there is no error, S z is expected to remain 1 throughout the detection process. This is true for the 6-qubit setup introduced in Sec. III. However, building the Hamiltonian perturbatively causes the stabilizers to drop slightly below 1, indicating the presence of small errors due to higher-order corrections. Nonetheless, the deviation is small as shown in Fig. 10. The blue and the green curves are the cases when the system suffers from the 1/f Hamiltonian errors defined in Eq. (34), where the sum is over all physical qubits (including the monitor qubits). The blue includes continuous indirect detection while the green does not. The suppression of errors is apparent, although it is slightly less effective than the ideal 6-qubit case shown in Fig. 7a. For most trajectories where errors are suppressed, the stabilizer values stay close to 1. For some trajectories where errors cause S z,x to flip to −1, we can detect them by observ-ingĪ a,c (t) decaying towards 0 or S z,x ρ flipping to −1. These behaviors are essentially the same as in Fig. 5.

V. CONCLUSION
We have presented and analyzed a method for the continuous measurement of high-weight operators, and applied this to the problem of continuous quantum error detection by the four-qubit Bacon-Shor code. This method includes engineering an interaction Hamiltonian between the system and the continuously measured ancillary qubits. More nontrivially, the Hamiltonian can be effectively built using physically viable two-local interactions, and the measurements on the monitor qubits consist of well-studied single-qubit continuous measurements.
In general, this detection scheme can be applied to measuring the stabilizers in any quantum code. However, as the weight of the stabilizers in a code increases, the difficulty of performing this detection scheme is also increased. This is because perturbatively constructing the Hamiltonian for the indirect detection requires applying a strong base Hamiltonian. The strength of this base Hamiltonian grows as the weight of the target term increases because these terms would appear at higher orders in the expansion. This is one of the reasons that we apply it to the four-qubit Bacon-Shor code, where the stabilizers are weight-four and their values can be obtained by measuring the two-local gauge operators. In this case, the target Hamiltonian can appear in the second order expansion, which is the minimum. The question of how the construction scheme applies to other quantum codes remains open, but it should certainly apply to the 9-qubit and larger Bacon-Shor codes.
Two methods are provided for retrieving the measurement outcomes. The estimator approach is computationally hard but may be beneficial to theoretical analysis. By contrast, the signal time average is noisier, but more efficient to perform in real time. It is shown that errors with low rates can be detected and (in the non-Markovian case) suppressed. This is in the regime where the indirect detection is effective. For high-rate or high-strength errors that change the system too rapidly, the detection scheme becomes inapplicable. However, if the type of errors can be learned from the experiments, it may be possible to adjust the setup for better performance.
Overall, we have presented a new method for measuring high-weight operators using practical experimental resources. This is a step towards practical quantum error-correction for quantum computing.