# Supplemental Material for “Low-Overhead Defect-Adaptive Surface Code with
Bandage-Like Super-Stabilizers”

Zuolin Wei  Hefei National Research Center for Physical Sciences at the
Microscale and School of Physical Sciences, University of Science and
Technology of China, Hefei 230026, China  Shanghai Research Center for Quantum
Science and CAS Center for Excellence in Quantum Information and Quantum
Physics, University of Science and Technology of China, Shanghai 201315, China
Tan He  Yangsen Ye  Dachao Wu  Yiming Zhang  Youwei Zhao  Weiping Lin  Hefei
National Research Center for Physical Sciences at the Microscale and School of
Physical Sciences, University of Science and Technology of China, Hefei
230026, China  Shanghai Research Center for Quantum Science and CAS Center for
Excellence in Quantum Information and Quantum Physics, University of Science
and Technology of China, Shanghai 201315, China  He-Liang Huang
<EMAIL_ADDRESS>Henan Key Laboratory of Quantum Information and
Cryptography, Zhengzhou, Henan 450000, China  Xiaobo Zhu<EMAIL_ADDRESS>Jian-Wei Pan<EMAIL_ADDRESS>Hefei National Research Center for Physical
Sciences at the Microscale and School of Physical Sciences, University of
Science and Technology of China, Hefei 230026, China  Shanghai Research Center
for Quantum Science and CAS Center for Excellence in Quantum Information and
Quantum Physics, University of Science and Technology of China, Shanghai
201315, China  Hefei National Laboratory, University of Science and Technology
of China, Hefei 230088, China

###### pacs:

03.65.Ud, 03.67.Mn, 42.50.Dv, 42.50.Xa

##  I Defective lattice surface code Adapter

The adapter we propose achieves the creation of functional surface codes on
defective lattices through three key steps: boundary deformation, internal
defect disabling, and stabilizer patching. Let’s explore each of these steps
and algorithms thoroughly. In the upcoming algorithms, we’ll approach it from
a graphical perspective, treating qubits (whether data or syndrome qubits) and
couplers within the lattice as nodes and edges on a graph, respectively.

###  I.1 Boundary Deformation

First up is boundary deformation, aimed at handling defects along the
boundary. We’ll kick things off by laying out the definitions for the
different types of boundary data nodes.

######  Definition 1.

Types of Boundary Data Node:

  * •

A boundary data node exclusively situated on $X$/$Z$ boundary is categorized
as a $X$/$Z$-type boundary data node (see Fig. S1(a) and Fig. S1(b)).

  * •

A boundary data node located on both $X$ and $Z$ boundaries is classified as a
$C$-type (Corner) boundary data node (see Fig. S1(c)).

Figure S2(a) provides an example, marking the different types of boundary data
nodes in a surface code. Following that, we define the frontier of a boundary
data node as the set of its neighboring syndrome nodes and the edges
connecting to these nodes, as illustrated in Fig. S1. With these concepts, we
can determine if a boundary data node is safe, which must meet the following
three conditions simultaneously:

  * •

Condition-1: The boundary data node itself is defect-free;

  * •

Condition-2: The components in its frontier, including syndrome nodes and
edges, are defect-free;

  * •

Condition-3: The type and number of syndrome qubits on the frontier should
match the type of the boundary data node, as illustrated in Fig. S1.

Figure S1: Safe boundary data nodes and theirs frontiers. The frontiers of a
boundary data node comprise neighboring syndrome nodes along with the
connecting edges. A boundary data node is safe if the node itself and its
frontier are defect-free, and its frontier should match the type of boundary
data node: (a) An $X$-type boundary data node should have a frontier
containing 2 $X$ syndrome nodes and 1 $Z$ syndrome node. (b) A $Z$-type
boundary data node should have a frontier containing 2 $Z$ syndrome nodes and
1 $X$ syndrome node. (c) A $C$-type boundary data node should have a frontier
containing 1 $Z$ syndrome node and 1 $X$ syndrome node.  Figure S2:  Detailed
steps for the boundary deformation of defective lattice in the Fig. 1(a) of
the main text. The entire process is illustrated sequentially from (a) to (d).
(a) Initial boundary data nodes are highlighted with colored stars. The top
and bottom boundaries correspond to $X$ boundaries, while the left and right
boundaries correspond to $Z$ boundaries. Intersections of $X$ and $Z$
boundaries are denoted as $C$ (corner) boundary data nodes. Step 1 addresses
corner boundary data qubits first. As shown, one corner boundary data node is
unsafe due to being defective, and should be disabled. Further, the $Z$
syndrome neighbors to it should be cleaned according to the frontier cleaner
subroutine. (b) Step 2 is introduced to address the remaining boundary data
node defects. Several scenarios are encountered here: Unsafe boundary data
nodes 1, 5 and 8 are defective themselves; unsafe node 2 has defective edge in
the frontier; unsafe nodes 3, 4, 6 and 7 have defective syndrome node in the
frontier. All these unsafe boundary data nodes need to be disabled, and the
syndrome nodes neighboring the unsafe ones should be cleaned using the
frontier cleaner, including isolated syndrome nodes and syndrome nodes with
the wrong type from the boundary. (c) Step 3 is similar to step 2. Unsafe
boundary data nodes 1-6 have an incorrect frontier shape with its boundary
type. (d) Upon completing the above process, a clean boundary with all
boundary data nodes safe is obtained.  Algorithm 1 Boundary Deformation

Input: Initial boundary data nodes

Output: Disabled boundary nodes

for $n_{0}$ in $C$ boundary data nodes do

if $n_{0}$ is unsafe then$\triangleright$ Visiting the corner first is better

Disable $n_{0}$

FrontierCleaner($n_{0}$)

end if$\triangleright$ Refer to Algorithm 2

end for

flag$\leftarrow$ True

while flag do

flag$\leftarrow$ False

for $n_{0}$ in undisabled boundary data nodes do

if $n_{0}$ is unsafe then

flag$\leftarrow$ True

Disable $n_{0}$

FrontierCleaner($n_{0}$)

end if$\triangleright$ Refer to Algorithm 2

end for

end while

We remove all the unsafe boundary data nodes using the boundary deformation
algorithm, detailed in Algorithm 1. This iterative algorithm evaluates the
safety of each boundary data node, starting with corner boundary data nodes in
the initial round and then assessing all boundary data nodes in subsequent
rounds. If an unsafe data node is detected, it needs to be disabled, and then
the frontier cleaner described in Algorithm 2 is called to clean its frontier.
This involves removing weight-0 syndrome nodes, defective syndromes, and
syndrome qubits of different types from the boundary, such as the $Z$ syndrome
qubit adjacent to the disabled $X$ boundary data qubit. After implementing
these, new boundary data nodes are introduced, pushing the boundary inward.
This iterative process continues until no unsafe boundary data nodes remain
within the boundary. Figure S2 illustrates a sample of boundary deformation
steps for the defect lattice in Fig. 1(a) of the main text.

###  I.2 Internal Defect Disabling

The step of Internal Defect Disabling addresses internal defects. This process
is straightforward; by applying the following rules (see Fig. S3) just once,
internal defects and their related qubits can be effectively removed.

  * •

Step 1: Disable the defective syndrome nodes and their neighboring data nodes,
as shown in Fig. S3(a).

  * •

Step 2: Disable all defective data nodes, as illustrated in Fig. S3(b).

  * •

Step 3: Disable data nodes if the edges (couplers) connected to them are
defective, as depicted in Fig. S3(c).

  * •

Step 4: Disable any weight-0 syndrome nodes resulting from the above steps.

After executing these steps, all defect nodes and edges in the surface code
lattice will be successfully processed. For example, in the lattice shown in
Fig. S2(d), after the step of Internal Defect Disabling, we obtain the lattice
shown in Fig. S4(a).

Figure S3: Internal defect disabling rules. (a) Rule for a defective syndrome
node; (b) Rule for a defective data node; (c) Rule for a defective coupler.
Red indicates defective components, while gray represents disabled components.
Algorithm 2 Frontier Cleaner Subroutine

Input: $n_{0}\leftarrow$ Disabled data node to clean its frontier

Output: Disabled syndrome nodes in the frontier, new introduced boundary data
nodes

$t\leftarrow$ boundary type of $n_{0}$$\triangleright$ Type of boundary data
node in BX, BZ or BC

$S_{\text{f}}\leftarrow$ undisabled syndrome nodes neighbor to $n_{0}$

for $s$ in $S_{\text{f}}$ do$\triangleright$ Disabling redundant syndrome
nodes

if $s$ is defective then Disable $s$, continue

else if $s$ is weight-0 syndrome node then Disable $s$, continue

else if $s$ is $X$ syndrome node and $t=\text{BZ}$ then Disable $s$, continue

else if $s$ is $Z$ syndrome node and $t=\text{BX}$ then Disable $s$, continue

end if

end for

if $t=\text{BC}$ then

$S^{\prime}_{\text{f}}\leftarrow$ undisabled syndrome nodes neighbor to
$n_{0}$ $\triangleright$ $S^{\prime}_{\text{f}}$ differs from $S_{\text{f}}$

if len($S^{\prime}_{\text{f}}$) $=2$ then

Disable the node with fewer undisabled neighbors; if they are equal, disable
the $Z$ syndrome node.

end if$\triangleright$ Prefer $X$ syndrome nodes

end if

$S_{\text{d}}\leftarrow$ disabled syndrome nodes that have undisabled
neighbors and are neighbors to $n_{0}$

if $t=\text{BC}$ then$\triangleright$ Introducing new boundary data nodes, $C$
Boundary situation

$x\leftarrow 0,z\leftarrow 0$

for $s$ in $S_{\text{d}}$ do

$N_{0}\leftarrow$ undisabled nodes that have 3 undisabled neighbors and are
neighbors to $s$

if $s$ is $X$ syndrome node then

$x\leftarrow x+\text{len}(N_{0})$

else if $s$ is $Z$ syndrome node then

$z\leftarrow z+\text{len}(N_{0})$

end if

end for

if $x<z$ then $t\leftarrow\text{BX}$$\triangleright$ Treat corner as $X$
boundary

else if $x>z$ then $t\leftarrow\text{BZ}$$\triangleright$ Treat corner as $Z$
boundary

else if $x=z$ then $t\leftarrow\text{BX}$$\triangleright$ Prefer $X$ syndrome
nodes

end if

end if

for $s$ in $S_{\text{d}}$ do

if $s$ is $X$ syndrome and $t=\text{BZ}$ or $s$ is $Z$ syndrome and
$t=\text{BX}$ then

$N_{1}\leftarrow$ undisabled nodes neighbor to $s$

if $t=\text{BX}$ then$\triangleright$ $X$ boundary situation

Add $N_{1}$ to the $X$ boundary

else if $t=\text{BZ}$ then$\triangleright$ $Z$ boundary situation

Add $N_{1}$ to the $Z$ boundary

end if

end if

end for

Figure S4: Subgraphs for stabilizer and logical operator search. (a) The
lattice has undergone boundary deformation and internal defect disabling,
rendering all defective nodes and edges (depicted in gray) inactive in this
diagram. This enables us to search for stabilizers and logical operators
within its subgraphs. (b) $X$ stabilizer search graph. This subgraph is
employed for searching $X$ stabilizers. It encompasses all internally
deactivated data nodes, alongside all $X$ syndrome nodes and their connecting
edges. Algorithm 3 is deployed to identify all connected components on this
graph containing active $X$ syndrome nodes, facilitating the creation of
stabilizers, including super-stabilizers. (c) $X$ logical operator search
graph. This subgraph is dedicated to the search for $X$ logical operators. It
includes all active data nodes, undisabled $Z$ syndrome nodes, and the
connecting edges. The shortest logical $X$ operator, highlighted by an orange
line, illustrates how it can span between the top and bottom sections of the
$X$ boundaries, composed of data nodes on the shortest path.

###  I.3 Stabilizer Patching

Since the previous steps have disabled some qubits, we need to search for
super-stabilizers to ensure that the surface code can function properly. The
bandage-like super-stabilizers combine the same type of gauge syndrome nodes
through disabled nodes and can be searched using a path finding algorithm. For
this purpose, we first define the stabilizer search graph to simplify the
stabilizer search procedure by identifying connected components on it.

######  Definition 2.

Stabilizer Search Graph.

An $X$($Z$) stabilizer search graph is a subgraph of the original surface code
lattice, containing:

  * •

All internally disabled data nodes within the lattice.

  * •

All $X$($Z$) syndrome nodes.

  * •

All edges connecting the aforementioned node types.

A sample $X$ stabilizer search graph is illustrated in Fig. S4(b). We then
utilize Algorithm 3 to conduct $X$($Z$) super-stabilizer search on the
$X$($Z$) stabilizer search graph. This algorithm traverses all undisabled
syndrome nodes on the stabilizer search subgraph and identifies all connected
components. The syndrome nodes within the same connected component naturally
constitute a super-stabilizer, as depicted in Fig. S4(b). By executing the
Stabilizer Search for both $X$ and $Z$ syndrome nodes, all stabilizers have
now been formed, effectively addressing all defects, and they all commute.

Finally, we will discuss the placement of logical operators on a surface code
to encode a logical qubit within the defective surface code lattice. To
achieve this, we will introduce the concept of the logical operator search for
positioning $X$/$Z$ logical operators.

######  Definition 3.

Logical Operator Search Graph.

An $X$($Z$) logical operator search graph is a subgraph of the original
surface code lattice that consists of several elements:

  * •

All undisabled data nodes

  * •

All $Z$($X$) undisabled syndrome nodes

  * •

All edges in the original graph that connect these elements

A sample $X$ logical operator search graph is depicted in Fig. S4(c). Once
established, determining logical operators becomes straightforward:

  * •

The $X$ logical operator is determined by identifying the shortest path
between the top and bottom boundaries of the $X$ boundaries on the $X$ logical
operator search graph.

  * •

Similarly, the $Z$ logical operator is determined by identifying the shortest
path between the left and right boundaries of the $Z$ boundaries on the $Z$
logical operator search graph.

The selection of the shortest path is based on the requirement that, following
the property of the surface code, all logical operators connecting both parts
of the boundaries in the logical operator search graph must be identical after
decoding.

After implementing these algorithmic steps, we have successfully adapted the
surface code, achieving the following outcomes:

  * •

Nodes related to defects were disabled to preserve the properties of the
stabilizer code.

  * •

Establishment of stabilizers (including super-stabilizers) in the adapted
code.

  * •

Determination of $X$ and $Z$ logical operators intended for protection by the
code.

Algorithm 3 Stabilizer Search

for $n_{s}$ in undisabled syndrome nodes do

if the $n_{s}$ is already part of a stabilizer then

continue$\triangleright$ Skip visited syndrome node.

end if

$cc\leftarrow$ ConnectedComponent($n_{s}$)$\triangleright$ Connected component
on stabilizer search graph, as shown in Fig. S4(b).

Combine all undisabled syndrome nodes in $cc$ to form a stabilizer.

end for

##  II Building Stabilizer Measurement Circuit

###  II.1 Shell Strategies

As mentioned in the main text, when building the stabilizer circuit, we can
employ two methods: using a global shell size for all stabilizer groups, or
using a local shell size for each stabilizer group, as illustrated in Fig. S5.
For the local approach, further subdivision is possible. In this section, we
will investigate three different shell strategies, as outlined below:

  * •

GLOBAL: All stabilizer groups share the same shell size $n_{\text{shell}}$,
ranging from $1$ to $(L-1)/2$, where $L$ is the code size of the original
lattice with $L\times L$ data qubits.

  * •

LOCALAVG: Each stabilizer group has a shell size of $\lfloor r\cdot
w_{\text{avg}}\rfloor$, where $r$ is the shell size-weight ratio, and
$w_{\text{avg}}$ represents the average weight of super-stabilizers in each
stabilizer group.

  * •

LOCALMAX: Each stabilizer group has a shell size of $\lfloor r\cdot
w_{\text{max}}\rfloor$, where $w_{\text{max}}$ represents the maximum weight
of super-stabilizers in each stabilizer group.

Figure S5: Illustration of global and local shell strategies. (a) Global
strategy. The same shell size is maintained for different stabilizer groups I,
II, and III. Stabilizer IV and V, unaffected by defects, are measured every
cycle. (b) Local strategy. Different shell sizes are allocated for different
stabilizer groups. For instance, groups I, II, and III have shell sizes of 2,
3, and 4, respectively. Stabilizers IV and V are measured every cycle, similar
to the global strategy.

Next, we’ll demonstrate the performance of different shell size strategies
from a simulation perspective. It’s worth noting that in our simulations, we
did not consider complex noise models like crosstalk or leakage. Therefore,
considering the specific physical implementation, we recommend initially
comparing these strategies through experiments to choose the one that offers
better performance. And our analysis in this section can provide insights for
how to select the optimal strategy.

###  II.2 Settings for the Simulation

We generate a stabilizer measurement circuit and leverage the Stim simulator
Gidney (2021) for the simulation. Our choice of the SI1000 circuit-level noise
model, as described in Gidney  _et al._ (2021), is particularly suitable for
simulating superconducting experiments. The error rate for each quantum gate
is outlined in Table S1. We conducted simulations on 100 devices with randomly
introduced defects for each defect rate and code size, and these devices
maintain a consistent defect rate for both qubits and couplers (applicable to
the scenario of superconducting quantum devices with tunable coupler
architecture). Logical error rates for the $\ket{0}$ and $\ket{+}$ states are
simulated after $L$ cycles of stabilizer measurements, where $L$ represents
the code size of the unadapted lattice. The circuit begins by measuring the
opposite super-stabilizer of the initial state to cover all types of errors
that may occur at the beginning of the circuit. For instance, when considering
the $\ket{0}$ state, we begin by measuring $X$ super-stabilizers.

Gate | Error Rate | Noise Channel
---|---|---
CZ | $p$ | 2-qubit depolarizing
AnyClifford1 | $p/10$ | 1-qubit depolarizing
InitZ | $2p$ | bitflip
MZ | $5p$ | bitflip
Idle | $p/10$ | 1-qubit depolarizing
ResonatorIdle | $2p$ | 1-qubit depolarizing
Table S1: SI1000 circuit-level noise model Gidney  _et al._ (2021). We use $p$
to indicate the physical error rate. Figure S6: Determining the optimal shell
size by investigating different values of $n_{\text{shell}}$ for the GLOBAL(G)
method, and $r$ for the LOCALAVG(LA) and LOCALMAX(LM) methods. (a) LER versus
global shell size $n_{\text{shell}}$ for a specific device, with a defect rate
of 0.02 for qubits and couplers, code size $L=21$ and a physical error rate of
$p=0.002$. (b) LER versus local shell ratio $r$ for the same specific device.
Both global and local methods exhibit a trend of decreasing LER followed by an
increase. The point with the lowest LER is referred to as the “sweet point”.

###  II.3 Simulation Results

For each strategy, we must first determine the optimal shell size. To achieve
this, we analyze the trend of the logical error rate (LER) as the shell size
increases. The simulation results for a specific device are depicted in Fig.
S6 (a) and (b). Typically, the LER for this device typically exhibits a
decreasing-then-increasing trend with the growth of either the global shell
size $n_{\text{shell}}$ or the local shell ratio $r$. Hence, there exists an
optimal point for the global shell size or the local shell ratio. This trend
is consistent across most random devices. The point with the lowest LER is
termed the “sweet point” for each device. In our simulation, we use LER at the
“sweet point” to represent the LER for each random device.

Figure S7: Cumulative Distribution Function (CDF) shows the difference in
relative LER between the GLOBAL(G), LOCALAVG(LA) and LOCALMAX(LM) Strategies.
G-LA represents
$(\text{LER}_{\text{G}}-\text{LER}_{\text{LA}})/\text{LER}_{\text{LA}}$; G-LM
represents
$(\text{LER}_{\text{G}}-\text{LER}_{\text{LM}})/\text{LER}_{\text{LM}}$. The
colored vertical dashed lines indicate the medians on the plots. In our
simulation, we randomly generated 100 devices with $L=21$ and a defect rate of
0.02 for qubits and couplers, using a physical error rate of $p=0.002$.

We then conducted a comparison of the performance differences between the
global and local shell strategies. In our simulation, we randomly generated
100 devices with code size $L=21$ and a defect rate of 0.02. We compared the
relative LER difference at the sweet point to investigate the variance in
error correction ability between different shell strategies, as depicted in
Fig. S7. From the results, we observed that the LOCALAVG strategy exhibited a
greater advantage over the GLOBAL strategy compared to the LOCALMAX strategy.
The GLOBAL strategy exhibits a median 12% increase in LER compared to the
LOCALAVG strategy. This suggests that customizing a local shell strategy for
each stabilizer subgroup yields better performance than the global approach.
Moreover, different local strategies demonstrate varying performance
disparities. For achieving higher error correction performance, further
customization of local strategies based on experimental system requirements
may be warranted. However, it’s worth noting that our current analysis
overlooks complex noise sources such as leakage and crosstalk. When
considering these noise factors, the global strategy might have advantages,
particularly when calibrating a few parallel CNOT or CZ patterns.
Nevertheless, we refrain from delving into detailed discussions on this aspect
here. For simplicity, we primarily employ the global shell method in most of
our simulations in the main text.

##  III The Advantage of Bandage-Like Super-Stabilizers

###  III.1 Advantages over Traditional Methods in Handling Bridge Syndrome
Qubits (Using the Case of Fig. 3(a) in the Main Text as an Example)

Figure S8: An example is provided to illustrate the difference between the
bandage-like and traditional methods in handling bridge syndrome qubits. (a) A
lattice with a code size of $L=7$ as mentioned in main text Fig. 3(a), with 1,
2, and 3 diagonal data qubit defects from left to right. (b) The lattice
obtained by the bandage-like method. Only defective data qubits are disabled.
(c) The lattice obtained by the traditional method. Bridge syndrome qubits
(and popped-up weight-1 syndrome qubits) are disabled, leading to the
disabling of more qubits, resulting in the formation of a large area of
disabled qubits protected by large weight super-stabilizers.

In comparison to traditional methods, our approach retains bridge syndrome
qubits instead of removing them when dealing with internal defects. This could
potentially result in obtaining a larger code distance. Here, we illustrate
and analyze this phenomenon using a specific example from the main text in
Fig. 3(a): an $L=7$ lattice with 1 (left panel of Fig. S8(a)), 2 (middle panel
of Fig. S8(a)), and 3 (right panel of Fig. S8(a)) diagonal nearest neighbor
data qubit defects.

In the case of 1 data qubit defect (left panel of Fig. S8(a)), both methods
show no difference (see left panel of Fig. S8(b) and Fig. S8(c)), as no bridge
syndrome qubits appear.

For 2 nearest neighbor data qubit defects (middle panel of Fig. S8(a)), the
bandage-like method demonstrates an advantage over the traditional one. In the
traditional method, after removing the defective data qubits, a bridge
syndrome qubit marked as $①$ appears. This qubit and its surrounding data
qubits need to be removed to form the super-stabilizer shown in Fig. S8(c).
However, with the bandage-like method, no additional qubits need to be removed
after disabling the defective data qubits, enabling the surface code to
function normally with bandage-like super-stabilizers. As a result, the $Z$
distance improves from 5 (traditional) to 6 (bandage-like), while the $X$
distance remains 5 for both methods. Moreover, the average super-stabilizer
weight decreases from 10 (traditional) to 6.67 (bandage-like). By preserving
the syndrome qubit $①$, not only two additional data qubits are saved, but
also two more syndrome qubits marked as $②$ and $③$ remain unaffected by
defects, providing extra information for error correction.

In the case of 3 nearest neighbor data qubit defects (right panel of Fig.
S8(a)), the advantage of the bandage-like method is further amplified. Two
bridge syndrome qubits marked as $④$ and $⑤$ in Fig. S8(b) are preserved,
leading to an improvement in $Z$ distance from 4 (traditional) to 6 (bandage-
like), and a decrease in the average super-stabilizer weight from 14
(traditional) to 7 (bandage-like).

###  III.2 Advantages over Traditional Methods in Handling Weight-1 Syndrome
Qubits

Figure S9: An example illustrates the contrast between the bandage-like and
traditional methods in handling weight-1 syndrome qubits. (a) Bandage-like
method: Depicts a scenario with a weight-1 $Z$ syndrome qubit, labeled as $①$.
It forms a C-shaped $X$ bandage-like super-stabilizer and a T-shaped $Z$
bandage-like super-stabilizer. By preserving weight-1 syndrome qubit $①$,
qubit $②$ is also preserved, while syndrome qubit $③$ remains unaffected by
defects. (b) Traditional method: Involves disabling the weight-1 syndrome
qubit and its neighboring data qubit, resulting in the formation of a higher-
weight $Z$ super-stabilizer.

Our bandage-like method also preserves weight-1 syndrome qubits, unlike the
traditional approach where they are disabled. Illustrated in Fig. S9(a), the
weight-1 syndrome qubit marked as $①$ is retained, resulting in a C-shaped
weight-8 $X$ super-stabilizer and a T-shaped weight-10 $Z$ super-stabilizer.
However, in contrast to the traditional method shown in Fig. S9(b), the
weight-1 syndrome qubit $①$ would be disabled, and further the data qubit
marked as $②$ must also be disabled. Consequently, our method yields a weight
of 10 for the $Z$ super-stabilizer, lower than the traditional method’s 12,
while maintaining the $X$ super-stabilizer’s weight at 8. Additionally, we
gain an extra normal $Z$ syndrome qubit $③$, enhancing error correction by
providing more information.

It’s noteworthy that qubit $②$ in Fig. S9(a) is included twice in the $X$
super-stabilizer, indicating that the $X$ super-stabilizer will not be
triggered if a $Z$ error occurs on it. However, according to our logical
operator placement strategy, no $X$ logical operator will pass through the
qubit $②$. Thus, disregarding $Z$ errors on qubit $②$ does not negatively
impact the integrity of the code.

###  III.3 More Shortcomings of Traditional Methods

Traditional methods disable weight-1 and bridge syndrome qubits when handling
internal defects, which can introduce more issues, as described below.

####  III.3.1 Avalanche Effect

In the process of disabling weight-1 and bridge syndrome qubits, traditional
methods may generate new weight-1 and bridge syndrome qubits. Therefore, this
process needs to be iterated until no new weight-1 and bridge syndrome qubits
are generated. This iterative process may require many iterations and result
in the removal of many qubits, a phenomenon referred to as the avalanche
effect.

Figure S10 provides a very intuitive example. For the surface code lattice in
Fig. S10(a), after three iterations of the traditional method to disable all
weight-1 and bridge syndrome qubits, a total of 13 qubits are disabled.
However, in the bandage-like method, only the 3 defective qubits will be
disabled, maintaining the least overhead.

Figure S10: An example illustrates the avalanche effect of the traditional
method. (a) A device generated by the internal defect-disabling rules of the
bandage-like method. Three data qubits are disabled. A bridge syndrome qubit
exists, marked as $①$. If the traditional method is used, this bridge syndrome
qubit needs to be removed. (b) Using the traditional method to remove bridge
syndrome qubit $①$ results in the emergence of a new bridge syndrome qubit,
marked as $②$. (c) Continuing with the traditional method to remove bridge
syndrome qubit $②$ leads to the appearance of two new weight-1 syndrome
qubits, marked as $③$ and $④$. (d) The two weight-1 syndrome qubits, $③$ and
$④$, are then disabled. Finally, the iterative disabling process results in a
significant area of disabled qubits.

####  III.3.2 Boundary Affected by Traditional Internal Defect Disabling Rules

In our method, the second step of handling internal defects does not affect
the boundary qubits anymore, whereas in traditional methods, disabling
weight-1 and bridge syndrome qubits neighboring boundary data qubits may
impact the boundary.

An intuitive example is illustrated in Fig. S11. For the surface code lattice
in Fig. S11(a), the bandage-like method does not require further disabling of
qubits, while in the traditional method, additional weight-1 and bridge
syndrome qubits need to be disabled, resulting in the boundary being affected,
as shown in Fig. S11(b). One drawback of this process is the need for repeated
execution of boundary deformation and internal defect disabling steps until no
unsafe qubits remain. However, in our method, this situation does not arise,
as only one iteration of boundary deformation and internal defect disabling is
required.

It is worth mentioning that, for simplicity, when dealing with internal
defects in both the main text and appendix, we do not remove weight-1 and
bridge syndrome qubits neighboring boundary data qubits, even in traditional
methods. Therefore, in practice, the modified traditional method we use as the
baseline should perform better than the original traditional method.

Figure S11: An example illustrates the traditional method’s potential impact
on the boundary when handling internal defects. (a) The device processed using
the internal defect-disabling rules of the bandage-like method. Weight-1
syndrome qubits (marked as $④$) and bridge syndrome qubits (marked as $①$-$③$)
are adjacent to boundary data qubits. (b) The traditional method requires
further disabling of $①$-$④$, leading to the disabling of more qubits and
altering the shape of the boundary.

###  III.4 Extended Data for the Main Text

####  III.4.1 Extended Data for Fig. 1 in the Main Text

Figure S12: Comparison between the bandage-like method and traditional method
in handling the defective lattice shown in Fig. 1(a) of the main text. (a) The
result from the bandage-like method. (b) The result from the traditional
method. The red lines indicate the logical error strings occurring on
undisabled data qubits that trigger no stabilizer. The solid line marked as
$E_{1}$ and $E_{4}$ represents the $X$ error string, while the dashed line
marked as $E_{2}$, $E_{3}$, $E_{5}$ and $E_{6}$ represent $Z$ error strings.
Figure S13: Extended Data for Fig. 3(c-f) in the Main Text. The whiskers
extend to data within 1.5 times the IQR from the box. Points beyond are
fliers. (a-d) display statistics for the bandage-like (B) and traditional (T)
methods regarding (a) Average $X$ distance, (b) Average $Z$ distance, (c)
Average disabled qubit percentage, and (d) Average super-stabilizer weight
across different defect rates. (e) Average super-stabilizer weight without
fliers.

For the defective lattice shown in Fig. 1(a) of the main text, we compare the
surface codes obtained using the bandage-like method and traditional methods
for handling defects, illustrated in Fig. S12(a) and Fig. S12(b) respectively.

To showcase the effectiveness of the bandage-like method in improving the code
distance, we examine the shortest error strings that do not trigger any
stabilizer. In Fig. S12(a), using the bandage-like method, we find that the
shortest $X$ error string labeled as $E_{1}$ consists of 5 undisabled data
qubits, with a weight of 5. Consequently, the $X$ distance achieved with the
bandage-like method is 5. Conversely, in Fig. S12(b), employing the
traditional method, the shortest $X$ error string labeled as $E_{4}$ consists
of 4 undisabled data qubits, with a weight of 4. Thus, the $X$ distance of the
code generated by the bandage-like method exceeds that of the traditional
method. Additionally, the bandage-like method reduces the average super-
stabilizer weight from 8.5 to 7.2 and disables 5 fewer qubits.

For $Z$ errors, both the shortest $Z$ logical error strings marked as $E_{2}$
and $E_{5}$ have a weight of 5. Therefore, the $Z$ distance of the bandage-
like method is not improved. However, even though the $Z$ distance is not
improved, saving more qubits in the bandage-like method increases the weight
of some logical error strings. For instance, consider a data qubit marked as
$①$ saved in the bandage-like method. Qubit $①$ elevates a weight-5 $Z$ error
string marked as $E_{6}$ in the traditional method to a weight-6 string marked
as $E_{3}$ in the bandage-like method. In this example device, 12 weight-5 $Z$
logical error strings are elevated, reducing the total number of weight-5 $Z$
error strings from 18 (traditional) to 6 (bandage-like). Elevating the weight
of logical error strings led to a decrease in their probability of occurrence,
ultimately reducing the logical error rate. This phenomenon is also discussed
in Lin  _et al._ (2024), which highlights the correlation between error
correction ability and the number of unique weight-$d$ logical operators.

Figure S14: Performance comparison of the traditional method with our approach
in handling defects for the scenarios of devices with only coupler defects
(a-d) display statistics for the bandage-like (B) and traditional (T) methods
regarding (a) Average $X$ distance, (v) Average $Z$ distance, (c) Average
disabled qubit percentage, and (d) Average super-stabilizer weight across
different defect rates. The defects occur exclusively in couplers.

####  III.4.2 Extended Data for Fig. 3(c-f) in the Main Text

Here, we provide comprehensive boxplots illustrating the advantages in terms
of code distance preservation, disabled qubit percentage, and average super-
stabilizer weight, as discussed in Fig. 3(c-f) of the main text. The results
are depicted in Fig. S13. For each defect rate and code size $L$, we generated
100 devices with randomly distributed defects. Notably, the results for
disabled qubit percentage and average super-stabilizer weight display numerous
fliers for the traditional method at higher defect rates. This indicates that
as the defect rate increases, defects tend to cluster, resulting in a
significant overhead for the traditional method in handling such situations.
Occasionally, the traditional method for adapting devices fails to generate a
correct stabilizer measurement circuit at high error rates due to excessive
qubit disabling. Conversely, the bandage-like method adeptly manages such
situations and successfully generates stabilizer measurement circuits for all
cases in the simulation. For better clarity, the average super-stabilizer
weight without fliers is presented in Fig. S13(e).

####  III.4.3 Scenarios of Devices with Only Coupler Defects

In the main text, our discussion mainly focuses on scenarios where qubits and
couplers share the same defect rate. In fixed-frequency transmon setups,
frequency collisions are the most significant fabrication defects, treated as
coupler defects in our method. Continuous coupler defects often result in
weight-1 syndrome qubits and bridge syndrome qubits, leading to the
traditional method disabling more qubits and resulting in higher-weight super-
stabilizers. However, the bandage-like method effectively mitigates this issue
with minimal additional costs. Therefore, in scenarios with only coupler
defects, the bandage-like method demonstrates even more significant advantages
over the traditional approach.

We considered extreme scenarios of devices with only coupler defects. Similar
to Fig. 3(c-f) in the main text, we simulated the variations of code distance,
disabled qubit percentage, and average super-stabilizer weight with changing
defect rates and code size $L$, as shown in Fig. S14. It’s evident that under
conditions where only coupler defects are present, the bandage-like method
exhibits even greater advantages compared to traditional methods. For
instance, at a code size of $L=27$ and a defect rate of 0.04 for the couplers
(the defect rate on the entire lattice is greater than the situation where
both coupler and qubit defect rates are 0.02), the average $X$ distance
improves from 5.8 to 12.5, and the $Z$ distance from 5.8 to 12.6, representing
a 117% average improvement. Meanwhile, the disabled qubit percentage decreases
from 43.2% to 9.8%, and the average super-stabilizer weight decreases from
10.4 to 7.2, marking a 31% improvement. This increase in improvement is
significantly higher than scenarios where qubits and couplers share the same
defect rate as shown in the main text.

## References

  * Gidney (2021) C. Gidney, Quantum 5, 497 (2021).
  * Gidney  _et al._ (2021) C. Gidney, M. Newman, A. Fowler, and M. Broughton, Quantum 5, 605 (2021).
  * Lin  _et al._ (2024) S. F. Lin, J. Viszlai, K. N. Smith, G. S. Ravi, C. Yuan, F. T. Chong, and B. J. Brown, “Codesign of quantum error-correcting codes and modular chiplets in the presence of defects,” (2024), arXiv:2305.00138 [quant-ph] .