A four-dimensional toric code on the D4 lattice

A four-dimensional toric code on the D
4
lattice:
[[16L
4
, 6, 2L
2
]] with weight-4 X-stabilizers
from the 16-cell honeycomb
Raghu Kulkarni
SSMTheory Group, IDrive Inc., Calabasas, CA 91302, USA
raghu@idrive.com
Abstract
We build a four-dimensional toric code on the D
4
lattice, the densest lattice packing in four
dimensions. The building blocks come from the Delaunay decomposition of D
4
, which fills
space with regular 16-cells. Qubits sit on the 16L
4
triangles of a four-dimensional torus of
side L. Each X-stabilizer acts on the 4 triangles of a tetrahedron, and each Z-stabilizer acts
on the 8 triangles that meet along an edge. Weight 4 is the smallest weight any check of this
kind can have, and every X-check in this code reaches it.
We determine the code exactly. The parameters are [[16L
4
, 6, 2L
2
]] for every even L 4.
The distance follows from a short geometric argument: a logical operator must cast a shadow
that covers a whole two-dimensional cross-section of the torus, and one triangle can only
shadow an area of 1/2, so at least 2L
2
triangles are needed. A close-packed plane of the lattice
supplies exactly that many, and its shadow covers the cross-section once with nothing left over.
A brute-force search confirms the same count for the three-dimensional code on a slice, where
the argument also applies.
Because the distance grows twice as fast as it does on the hypercubic lattice, the comparison
between the two codes reverses once it is made at equal distance rather than equal side length:
this code needs 4d
2
physical qubits where the hypercubic four-dimensional toric code needs
6d
2
. The larger checks do not cost anything extra here: a single circuit fault behaves like a
weight-2 error in one sector and a weight-4 error in the other, and against distances of 2L
2
and 4L
2
those give the same factor. Neither sector has point-like excitations, so the code sits
in the same self-correcting class as the hypercubic one, and its equal-time slices are the face-
centred-cubic Delaunay lattice. Everything reported here reproduces from the appendices, in
minutes on a laptop.
Keywords: quantum error correction, 4D toric code, D
4
lattice, self-correcting memory,
single-shot codes
1 Introduction
The four-dimensional toric code is the standard example of a quantum memory that protects
itself. In two dimensions, errors form strings whose ends are free to wander, and a chain of errors
costs no more energy than a short one. In four dimensions both kinds of error form closed loops
instead, and a big loop costs more energy than a small one. Thermal noise is therefore pushed
back rather than allowed to spread [1, 3]. On the hypercubic lattice the code is [[6L
4
, 6, L
2
]], with
qubits on square faces and weight-6 checks on edges and cubes [1, 4].
Known variants change the shape of the space or the shape of the support: fractal subsets of
the hypercubic lattice [5], hyperbolic lattices, and the tesseract colour code [6]. Closest to this
1
work, Jochym-O’Connor and Yoder built four-dimensional toric codes on the 24-cell tessellation
with qubits on 3-cells [7], and Kubica and Vasmer showed those codes to be gauge fixings of their
four-dimensional subsystem toric code, with the 16-cell honeycomb turning up as the alternated
lattice of that correspondence [2]. What we do here is take a different part of the same geometry:
put the qubits on the triangles of the 16-cell honeycomb. Then both kinds of logical operator
are sheets and both kinds of excitation are loops, which is the structure that makes the four-
dimensional toric code self-correcting. We are not aware of a previous construction of this sector.
We use the lattice that four-dimensional geometry singles out. D
4
is the four-dimensional
checkerboard: the densest lattice packing in four dimensions, in which every point touches 24
others [12]. Its gaps are all of one kind, which is special to D
4
, and filling them in gives a
honeycomb of identical regular 16-cells. The resulting code has three properties we want to set
out first.
(i) The X-checks are as small as they can be. The 3-cells of this honeycomb are tetra-
hedra, so every X-check touches 4 qubits. A 3-cell has at least 4 faces, so no check of this
type can be smaller. The price is a weight-8 Z-sector.
(ii) The distance is 2L
2
. That is twice the hypercubic value at the same L. Section 5 proves
it. Section 8 works out what this costs in hardware: at a fixed target distance the code
needs one third fewer qubits than the hypercubic code.
(iii) Slicing gives the FCC lattice. Cutting at a fixed value of the fourth coordinate leaves the
face-centred-cubic lattice, and the cut passes cleanly through the honeycomb. The smallest
logical operator of the whole four-dimensional code lies inside one such slice.
Every claim is checked by computer at L = 4; the scripts are in the appendices and run in
minutes. Structural claims hold for all even L 4 by the arguments given. The case L = 2 is
degenerate, the torus is too small and edges collapse, so L 4 throughout. A related construction
on the three-dimensional close-packed lattice appears in [14].
2 The lattice and its honeycomb
Take the points of Z
4
whose coordinates add up to an even number:
D
4
= {x Z
4
: x
1
+ x
2
+ x
3
+ x
4
is even},
and wrap them on a four-dimensional torus of even side L. Two points are neighbours when they
differ by a root: a vector with two entries equal to ±1 and two entries equal to 0. There are 24
roots, so every point has 24 neighbours. That is the largest number possible in four dimensions
[12, 13].
The gaps between the points come in three families, odd-sum integer points and two families
of half-integer points, but they are all the same shape. Each gap is surrounded by 8 lattice points
forming a regular 16-cell (Fig. 1a). Filling every gap tessellates the torus with 3L
4
/2 identical
16-cells. This is the Delaunay decomposition of D
4
.
Counting the pieces of the honeycomb:
points edges triangles tetrahedra 16-cells
count L
4
/2 6L
4
16L
4
12L
4
3L
4
/2
L = 4 128 1536 4096 3072 384
2
The alternating sum is zero, as it must be on a torus. The way the pieces fit together, checked
exhaustively at L = 4 (Fig. 1d): every triangle lies in 3 tetrahedra and in 3 16-cells; every
tetrahedron lies in exactly 2 16-cells; every edge lies in 8 triangles. Triangles are two steps down
from the top dimension here, which is why 3 appears rather than the 2 one expects for a face of
a solid. The number 2 for tetrahedra is the one that matters later. It is what forces error signals
into loops.
(a) One 16-cell: 8 corners, 24 edges
qubit = triangle (blue),
X
-check = tetrahedron (orange)
(b) The same 16-cell cut by a slice
4 corners in the slice (blue), 4 just outside (red)
X
-check
(this code)
X
-check
(hypercubic)
Z
-check
(this code)
Z
-check
(hypercubic)
0
2
4
6
8
qubits touched by one check
4
6
8
6
smallest possible
(c) Check weights
counted at
L
=4
value
triangle sits in how many tetrahedra
3
triangle sits in how many 16-cells
3
tetrahedron sits in how many 16-cells
2
edge sits in how many triangles
8
checks touching one qubit
3 + 3
(d) How the pieces fit together
"tetrahedron in 2 16-cells" is why errors make loops
Figure 1: The building blocks. (a) One 16-cell of the honeycomb, drawn in three dimensions:
8 corners and 24 edges. A qubit lives on each triangle (blue); each tetrahedron inside carries
a weight-4 X-check (orange). (b) The same 16-cell cut by a slice: its 8 corners split 4 and 4,
one group in the slice and one group just outside. This is the geometric content of Section 7.
(c) Check weights against the hypercubic four-dimensional toric code: the X-sector reaches the
smallest weight a check of this kind can have; the Z-sector pays weight 8. (d) The verified
incidence counts.
3 The code
Definition 1 (D
4
face code). Put one qubit on each triangle of the 16-cell honeycomb. Then:
X-stabilizers: for each tetrahedron, apply X to its 4 triangles (weight 4);
Z-stabilizers: for each edge, apply Z to the 8 triangles containing that edge (weight 8).
3
Every X-check has weight 4 and every Z-check has weight 8, with no exceptions anywhere on
the torus. Each qubit is touched by 3 checks of each type. The two check types commute because
a tetrahedron and an edge always share an even number of triangles; in the language of chain
complexes, H
X
=
T
3
and H
Z
=
2
, so H
X
H
T
Z
= 0 follows from = 0. We verify it numerically
anyway (Appendix A). This is the hypercubic construction with squares replaced by triangles and
cubes by tetrahedra.
4 What the computer confirms
Theorem 1 (Parameters at L = 4). At L = 4 the code is a valid CSS code with
n = 4096, rk(H
Z
) = 1405, rk(H
X
) = 2685, k = n rk(H
Z
) rk(H
X
) = 6.
The number of logical qubits is fixed by the shape of the space rather than by the lattice.
A four-dimensional torus has
4
2
= 6 independent two-dimensional sheets, so k = 6 at every L.
The six X-type logical operators are sheets that wrap the torus; the six Z-type ones are sheets in
the dual honeycomb, which is the 24-cell honeycomb. Both are sheets, as in the hypercubic case
[1, 3].
As a further check, an exhaustive scan over all
4096
2
pairs of qubits finds that the only weight-
4 operators that commute with every Z-check are the 3072 tetrahedron boundaries, that is, the
X-stabilizers themselves, with nothing extra, and that no weight-4 operator commutes with every
X-check. Both facts are consistent with the distance computed next.
5 The distance is exactly 2L
2
Here is the argument in words before we give it properly. A logical operator is a sheet that wraps
the torus. Look at its shadow : pick two of the four coordinates and squash the torus onto that
two-dimensional cross-section. A wrapping sheet has to shadow the whole cross-section, with no
gaps. The cross-section has area L
2
, and one triangle can shadow at most an area of 1/2, so at
least 2L
2
triangles are needed. A close-packed plane of the lattice has exactly that many.
The local ingredient comes first.
Lemma 1 (How big a shadow can be). Let π
ij
be the map that keeps only the coordinates x
i
and x
j
. Every triangle f of the honeycomb has area(π
ij
(f))
1
2
, and every 2-cell f
of the dual
24-cell honeycomb has area(π
ij
(f
))
1
4
. Both values are reached.
Proof. A triangle is {v, v + r, v + s} where r, s and r s are all roots, so its shadow is a triangle
of area
1
2
|r
i
s
j
r
j
s
i
|. A root has exactly two nonzero entries, each ±1, so |r
i
s
j
r
j
s
i
| 2. The
value 2 needs r and s to both live on the coordinates i and j with opposite sign patterns, say
r = (1, 1, 0, 0) and s = (1, 1, 0, 0). But then r s and r + s each have a single entry ±2, and
neither is a root, so there is no such triangle. Hence |r
i
s
j
r
j
s
i
| 1 and the area is at most
1
2
.
It is reached, for instance by r = (1, 1, 0, 0) and s = (1, 0, 1, 0) shadowed onto (x
1
, x
2
).
A 2-cell of the dual honeycomb is the triangle joining the centres of the 3 16-cells that contain
a given triangle (Section 2). Running through the 96 kinds of triangle and all 6 coordinate pairs
gives a largest shadow of
1
4
. Appendix B is the computation; it is exact arithmetic and takes a
second.
Theorem 2 (Lower bound). For even L 4, every X-type logical operator has weight at least
2L
2
, and every Z-type logical operator has weight at least 4L
2
.
4
Proof. Let z be an X-type logical operator, that is, a sheet that wraps the torus in a way no
stabilizer can undo. Its wrapping class lives in H
2
(T
4
; F
2
), which has a basis labelled by the six
pairs of coordinates; choose a pair (i, j) appearing in the class of z, and write π for the shadow
map onto (x
i
, x
j
).
Suppose some point p of the cross-section were missed by the shadow. Then z would lie entirely
inside the part of the torus lying over the punctured cross-section. A punctured two-dimensional
torus carries no wrapping sheets at all, so the class of z would have to be trivial in the (i, j)
direction , contradicting the choice of (i, j). So the shadow covers every point of the cross-section.
Areas can only add up, so
X
fsupp z
area
π(f)
area
cross-section
= L
2
.
By Lemma 1 each term is at most
1
2
, so z contains at least 2L
2
triangles.
A Z-type logical operator is the same kind of object in the dual honeycomb, where the qubits
correspond one-to-one to dual 2-cells. The same argument with the constant
1
4
gives at least
4L
2
.
Theorem 3 (A logical operator of exactly this size). Let L be even and c even, and let
Π
c
= {x : x
1
+ x
2
+ x
3
c mod L, x
4
= 0}.
Then Π
c
contains exactly L
2
lattice points, and the 2L
2
triangles they span are triangles of the
honeycomb and form an X-type logical operator. Hence d
X
2L
2
.
Proof. Because L is even, fixing x
1
+ x
2
+ x
3
modulo L also fixes it modulo 2; for c even all L
2
solutions have even coordinate sum and so lie in D
4
. The roots that stay inside Π
c
are those with
r
4
= 0 and r
1
+ r
2
+ r
3
= 0, of which there are six, so the points of Π
c
form a triangular lattice,
a close-packed plane (Fig. 2a). A triangular lattice with N points on a two-dimensional torus
has 3N edges and 2N triangles, and every edge belongs to exactly two of them. Every Z-check
therefore sees an even number of triangles, so the set commutes with all of them; and the sheet
wraps the torus, so no product of stabilizers can remove it. With N = L
2
its weight is 2L
2
.
Corollary 1 (Parameters). For every even L 4 the D
4
face code has d
X
= 2L
2
and d
Z
4L
2
,
so
d = min(d
X
, d
Z
) = 2L
2
, and the code is [[ 16L
4
, 6, 2L
2
]].
The bound is tight for a reason one can see in the picture. Each of the 2L
2
triangles of Π
c
shadows an area of exactly
1
2
, the most allowed, and the shadows tile the cross-section once with
no overlaps and no gaps (Fig. 2b). Nothing is wasted, which is why the constant comes out exact
instead of only having the right order.
Only even weights can occur. Every triangle lies on 3 edges, so adding up all the Z-checks
gives the operator acting on every qubit at once. Anything commuting with all the Z-checks must
overlap that operator evenly, and so has even weight. Every triangle also lies in 3 tetrahedra, so
the same holds in the other sector. Odd weights are therefore impossible on both sides, which is
why the search below tests even weights only.
5
(a) The smallest logical operator
a close-packed plane of the lattice (grey = other lattice points)
0 1 2 3 4
x
1
0
1
2
3
4
x
2
(b) Its shadow covers the square exactly once
32 shadows of area
1/2
add to
16=
L
2
: nothing wasted
6 8 10 12 14 16 18 20 22 24 26 28 30 32
weight of the operator
no logical operator exists
at any of these weights
d
=2
L
2
=32
(c) Exhaustive search at
L
=4
odd weights are ruled out on parity grounds
10 20 30 40 50 60 70 80
distance
d
0
5000
10000
15000
20000
25000
30000
35000
40000
physical qubits
n
one third fewer
qubits
(d) Cost at the same distance
hypercubic:
6
d
2
D
4
face code:
4
d
2
Figure 2: The distance. (a) The smallest logical operator: a close-packed plane of the lattice, L
2
points carrying 2L
2
triangles. Grey dots are the other lattice points nearby. (b) Its shadow on a
two-dimensional cross-section at L = 4: 32 triangles, each of area 1/2, tiling an area of 16 = L
2
exactly once. Nothing is wasted, which is why the bound is attained. (c) The brute-force search
on the slice code at L = 4: no logical operator exists at weight 30 or below, and one exists at
32, matching what the shadow argument predicts. Odd weights need not be tested, by the parity
remark in Section 5. (d) Physical qubits needed to reach a given distance, against the hypercubic
four-dimensional toric code.
A check on the argument. The shadow argument applies just as well to the three-dimensional
face code on a slice, where it again predicts a smallest logical operator of weight 2L
2
. That code
is small enough to settle by brute force. We encoded “there is a logical operator of weight at most
w as a satisfiability problem, with parity constraints from the checks, one constraint forcing the
operator to be nontrivial, and a counter limiting the weight, and raised w one step at a time
(Appendix C). At L = 4 the answer is unsatisfiable at every even weight up to 30 and satisfiable
at 32. The slice code therefore has smallest logical operator of weight exactly 32 = 2L
2
, which
is what the shadow argument says it should be. We have not run the same search on the four-
dimensional code, where n = 4096 puts it out of reach; there the distance rests on Corollary 1.
On the Z side, reducing logical operators greedily against the Z-stabilizers stops at weight
exactly 64 = 4L
2
, so the bound of Theorem 2 is attained and d
Z
= 4L
2
at L = 4.
6
Which logical qubits have flat operators. Not all six do. A flat sheet spans two roots
whose difference is again a root, and such a pair always lies inside three of the four coordinates.
Its wrapping class is therefore built from the three coordinate pairs inside that triple, and there
are only four triples, whose classes add up to zero. Flat sheets thus reach only a three-dimensional
slice of the six-dimensional space of classes. An exhaustive search at L = 4 finds 128 flat sheets,
every one of weight 32, realising four classes that span three dimensions, and every one of them
lying inside a slice x
i
= const, that is, inside a copy of the FCC lattice (Section 7). The other
three logical qubits have no flat operator at all, which is the homological restatement of the fact
that a flat coordinate plane of D
4
contains no triangles. Their smallest operators are heavier (a
search at L = 4 reaches weights 78 and 116), but this does not change d, which is a minimum
over all classes.
6 Excitations are loops, never points
Theorem 4 (No point excitations). Neither sector of the D
4
face code has point-like excitations:
(a) no error can light up a single X-check. The linear system H
X
y = e
t
has no solution for
one tetrahedron t (verified directly). The reason is that every tetrahedron sits in exactly two
16-cells, so the lit checks around each 16-cell must come in pairs and the pattern closes into
a loop in the dual honeycomb;
(b) no error can light up a single Z-check, for a reason that needs no computation: the pattern
of lit edges is always the boundary of a set of triangles, and a boundary is always a closed
loop. A single edge is not a closed loop.
Loops in both sectors is the mechanism behind self-correction in the hypercubic four-dimensional
toric code. Making an excitation costs energy in proportion to its length, so noise cannot spread
cheaply [1, 3], and the D
4
face code has the same structure. This settles the excitations, not the
thermodynamics. A free-energy barrier calculation on this honeycomb, matching what has been
done for the hypercubic code [1, 4], is still to be done. One detail matters for anyone building a
decoder: a single error lights up 3 checks of each type, an odd number, which follows from the
triangular geometry and is more familiar from colour codes.
7 Slicing gives the FCC lattice
Cut the lattice at a fixed value of the fourth coordinate. What is left is exactly the face-centred-
cubic lattice, and the honeycomb cuts cleanly along with it. All of the following is verified at
L = 4:
(a) the slice contains L
3
/2 points, 3L
3
edges, 4L
3
triangles and L
3
tetrahedra: exactly the
pieces of the three-dimensional tetrahedron-octahedron honeycomb, which is what you get
by filling the gaps of the FCC lattice;
(b) every edge in the slice lies in exactly 4 triangles of the slice, which is the Z-check weight of
the three-dimensional face code on that lattice;
(c) the gaps cut cleanly. A 16-cell centred in the slice meets it in an octahedron (6 of its 8
corners); a 16-cell centred between slices meets it in a tetrahedron (4 of 8, with the other 4
in the next slice, Fig. 1b); a 16-cell a full step away meets it in a single corner and contributes
nothing.
7
The slices carry the code’s best logical operators. By Theorem 3 the smallest logical operator
in the whole four-dimensional code is a close-packed plane of one of them, and by the last part of
Section 5 every flat logical operator lies in a slice.
Someone has already built a decoder for this geometry. The FCC lattice of a slice is
dual to the rhombic dodecahedral lattice. On that lattice Vasmer, Browne and Kubica proved
that a local decoder based on the sweep rule has a non-zero error threshold, and they measured
how well it works when the checks themselves are noisy [10]. Sweep decoders were built for both
three- and four-dimensional toric codes [11], so a sweep decoder is the first thing to try here.
Two warnings. The slice inherits the geometry but not the code. A tetrahedron that straddles
a slice leaves only one of its triangles inside, so cutting the checks down to a slice gives weight-1
operators rather than the three-dimensional code. We have also not checked whether the sweep
rule works on the 16-cell honeycomb. The slice says where to start looking.
The 16-cell honeycomb is also the alternated lattice through which Kubica and Vasmer relate
the four-dimensional subsystem toric code to the 24-cell toric codes of Jochym-O’Connor and
Yoder [2, 7], and the three-dimensional subsystem toric code of that same correspondence is
the standard single-shot code [2, 8]. The lattice is already present in the single-shot and self-
correction literature; the triangle sector is not. Writing down a dimension-jump protocol along a
slice remains open.
8 Comparison with the hypercubic code
The natural comparison is at equal distance, not at equal side length. Side length is not compa-
rable between two different lattices; distance is what a device designer is buying. The hypercubic
code needs L
2
= d, hence n = 6d
2
qubits. The D
4
face code needs 2L
2
= d, hence n = 16L
4
= 4d
2
.
hypercubic [1, 4] D
4
face code (this work)
lattice Z
4
D
4
(densest packing)
qubit cell square faces triangles
parameters [[6L
4
, 6, L
2
]] [[16L
4
, 6, 2L
2
]]
qubits at equal d 6d
2
4d
2
X-check weight 6 4 (smallest possible)
Z-check weight 6 8
checks per qubit 4+4 3+3
point excitations none none (verified)
three-dimensional slice cubic lattice FCC (tet–oct) lattice
Comparing instead at equal side length would suggest the D
4
code spends 8/3 times as many
qubits. That comparison is misleading, because at the same L the D
4
code also has twice the
distance. At equal distance it uses two thirds as many qubits as the hypercubic code, with smaller
X-checks and fewer checks per qubit in both sectors. What it pays for this is a weight-8 Z-sector.
The largest check in the code grows from 6 to 8. On hardware where cost is set by the largest
check rather than by the qubit count, that is the number to weigh.
8
8.1 The weight-8 checks and hook errors
A bigger check takes a longer circuit to measure, and a longer circuit gives a single fault more
chances to spread onto data qubits. This is the natural worry about a weight-8 sector, so we
checked it.
Measure a weight-w Z-check by preparing an ancilla in |0, applying one CNOT from each
data qubit, and measuring the ancilla. A Z fault on the ancilla after k of the CNOTs travels back
through the remaining w k and lands as a Z error on that suffix of the data qubits. One fault
can therefore produce a data error of weight up to w 1: up to 7 here.
What matters is not the raw weight but the smallest weight the error can be reduced to using
the stabilizers, since two errors differing by a stabilizer are the same error. Adding the whole check
turns a suffix of length s into the complementary prefix of length w s, so the long suffixes are
cheap and the middle one is the worst. Running every suffix through an exact minimum-weight
coset search (Appendix D; the code is translation invariant, so one check of each type settles it)
gives:
suffix length 1 2 3 4 5 6 7
weight-8 Z-check, reduced to 1 2 3 4 3 2 1
weight-4 X-check, reduced to 1 2 1
So one fault behaves like a weight-2 error in the X sector and a weight-4 error in the Z sector,
and the circuit distances are at least
d
X
2
=
2L
2
2
= L
2
,
d
Z
4
4L
2
4
= L
2
.
The two sectors come out equal. The Z sector has twice the distance and twice the hook weight,
and the factors cancel, so the weight-8 checks are no worse in this respect than the weight-4 ones.
Both sectors lose a factor of 2, which is the usual price of going to circuit level.
Two limits on this. It is a lower bound from counting, not a measured circuit distance, so
the true value may be higher. And it covers single faults; correlated multi-fault events are not
included. It is the standard check, and it says the weight-8 sector is not the weak point one might
expect, but it is not a threshold.
9 Open problems
The Z-distance for general L. We prove d
Z
4L
2
everywhere and exhibit a weight-4L
2
operator
at L = 4, so d
Z
= 4L
2
there. A general-L construction would close this. It does not affect d,
which is 2L
2
either way.
The three classes with no flat operator. Their smallest logical operators are somewhere between
2L
2
and the weights 78 and 116 found by search at L = 4. Identifying them would complete the
picture of the code’s logical structure.
Thermodynamics. Loop-only excitations put the code in the self-correcting class, but the
size of the energy barrier and how long the memory survives at a given temperature deserve the
treatment the hypercubic code has received [1, 4].
Decoding. A decoder matched to the triangular geometry, where a single error lights 3 checks
of each type, is the practical next step. There is somewhere to start. By Section 7 the slices
carry the rhombic dodecahedral geometry, and a sweep decoder with a proven threshold already
9
exists there [10]. Section 8.1 shows the weight-8 checks cost the same factor of 2 at circuit level
as the weight-4 ones, so they are not the obstacle. What is still missing is a measured threshold.
Adapting the sweep decoder and running it under a depolarizing gate model would turn the qubit
counts of Section 8 into claims about performance.
Single-shot decoding through a slice. Given the code’s place in the subsystem toric code
correspondence [2, 7], a dimension-jump protocol [8] in which the four-dimensional memory hands
logical information to a three-dimensional code along a slice looks natural. Making it explicit is
the most interesting problem this construction poses.
10 Conclusion
Filling the gaps of the D
4
lattice gives a honeycomb of regular 16-cells, and putting qubits on its
triangles gives a four-dimensional toric code with parameters
[[ 16L
4
, 6, 2L
2
]]
for every even L 4: uniform weight-4 X-checks, which is the smallest possible, weight-8 Z-
checks, three checks of each type per qubit, and no point-like excitations in either sector. The
distance follows from the observation that a logical operator must shadow a whole cross-section
of the torus while a single triangle can shadow only an area of 1/2; a close-packed plane of the
lattice meets that bound exactly, tiling the cross-section once with nothing wasted. Because the
distance is twice the hypercubic value at equal side length, the code reaches a given distance with
4d
2
physical qubits where the hypercubic code needs 6d
2
. Everything needed to reproduce these
statements is in the appendices and runs in minutes on a laptop.
Data availability
Appendix A builds the honeycomb and checks the incidence structure, CSS validity, the param-
eters of Theorem 1, the low-weight scans, the slice property, and Theorem 4(a); under a minute.
Appendix B computes the two shadow constants of Lemma 1 in exact arithmetic; seconds. Ap-
pendix C is the brute-force check on the slice code. Appendix D reproduces the hook-error table
of Section 8.1; a few minutes. Appendix A needs only numpy; Appendix B needs nothing beyond
the standard library; Appendices C and D need python-sat.
References
[1] E. Dennis, A. Kitaev, A. Landahl, and J. Preskill, “Topological quantum memory,” J. Math.
Phys. 43, 4452 (2002). doi:10.1063/1.1499754, arXiv:quant-ph/0110143.
[2] A. Kubica and M. Vasmer, “Single-shot quantum error correction with the three-dimensional
subsystem toric code,” Nat. Commun. 13, 6272 (2022). doi:10.1038/s41467-022-33923-4,
arXiv:2106.02621.
[3] Error Correction Zoo, “(2, 2) Loop toric code,” https://errorcorrectionzoo.org/c/4d_
surface.
[4] T. Bergamaschi, R. Gheissari, and Y. Liu, “Rapid mixing for Gibbs states within a logical
sector: a dynamical view of self-correcting quantum memories,” arXiv:2507.10976 (2025).
10
[5] C. G. Brell, “A proposal for self-correcting stabilizer quantum memories in 3 dimensions (or
slightly less),” New J. Phys. 18, 013050 (2016). doi:10.1088/1367-2630/18/1/013050.
[6] V. V. Albert and P. Faist, Handbook of Error-Correcting Codes, arXiv:2606.11484 (2026).
[7] T. Jochym-O’Connor and T. J. Yoder, “Four-dimensional toric code with
non-Clifford transversal gates,” Phys. Rev. Research 3, 013118 (2021).
doi:10.1103/PhysRevResearch.3.013118.
[8] H. Bomb´ın, “Single-shot fault-tolerant quantum error correction,” Phys. Rev. X 5, 031043
(2015). doi:10.1103/PhysRevX.5.031043, arXiv:1404.5504.
[9] Error Correction Zoo, D
4
hyper-diamond lattice,” https://errorcorrectionzoo.org/c/
dfour.
[10] M. Vasmer, D. E. Browne, and A. Kubica, “Cellular automaton decoders for topolog-
ical quantum codes with noisy measurements and beyond,” Sci. Rep. 11, 2027 (2021).
doi:10.1038/s41598-021-81138-2, arXiv:2004.07247.
[11] A. Kubica and J. Preskill, “Cellular-automaton decoders with provable thresholds for topo-
logical codes,” Phys. Rev. Lett. 123, 020501 (2019). doi:10.1103/PhysRevLett.123.020501,
arXiv:1809.10145.
[12] J. H. Conway and N. J. A. Sloane, Sphere Packings, Lattices and Groups, 3rd ed. (Springer,
New York, 1999). doi:10.1007/978-1-4757-6568-7.
[13] O. R. Musin, “The kissing number in four dimensions,” Ann. Math. 168, 1 (2008).
arXiv:math/0309430.
[14] R. Kulkarni, “A 67%-rate CSS code on the FCC lattice: [[192, 130, 3]] from weight-12 stabi-
lizers,” arXiv:2603.20294 (2026).
A Building the honeycomb and checking it
Self-contained; needs only numpy; under a minute at L = 4. It builds the honeycomb, checks how
the pieces fit together, verifies that the two check types commute, computes the parameters of
Theorem 1, scans for low-weight operators, checks the slice property of Section 7, and confirms
Theorem 4(a).
#!/usr/bin/env python3
"""D4 face code -- construction and verification"""
import numpy as np
from itertools import product, combinations
def rank(rows):
piv = {}; rk = 0
for r in rows:
while r:
h = r.bit_length()-1
if h in piv: r ^= piv[h]
else: piv[h] = r; rk += 1; break
return rk
def solvable(rows, rhs):
piv = {}
for i, r in enumerate(rows):
11
a = (r << 1) | rhs[i]
while a >> 1:
h = (a >> 1).bit_length()-1
if h in piv: a ^= piv[h]
else: piv[h] = a; break
else:
if a & 1: return False
return True
L = 4
vs = [v for v in product(range(L), repeat=4) if sum(v)%2 == 0]
add = lambda a,b: tuple((a[i]+b[i]) % L for i in range(4))
adj = lambda a,b: sorted(min((a[i]-b[i])%L,(b[i]-a[i])%L)
for i in range(4)) == [0,0,1,1]
NN = [v for v in product((-1,0,1), repeat=4) if sum(map(abs,v)) == 2]
nb = {v: [add(v,d) for d in NN] for v in vs}
E, F, T, C4 = {}, {}, {}, []
for v in vs:
for u in nb[v]:
k = frozenset((v,u))
if k not in E: E[k] = len(E)
for ek in list(E):
a, b = tuple(ek)
for c in nb[a]:
if c != b and adj(c,b):
fk = frozenset((a,b,c))
if fk not in F: F[fk] = len(F)
for fk in list(F):
a, b, c = tuple(fk)
for d in nb[a]:
if d not in fk and adj(d,b) and adj(d,c):
tk = frozenset((a,b,c,d))
if tk not in T: T[tk] = len(T)
for h in product(range(L), repeat=4): # odd-integer gaps
if sum(h)%2 == 1:
C4.append([add(h, tuple(int(i==j)*s for j in range(4)))
for i in range(4) for s in (1,-1)])
for hb in product(range(L), repeat=4): # half-integer gaps
h = tuple(x+.5 for x in hb)
want = 0 if sum(hb)%2 == 0 else 2
C4.append([tuple(int((h[i]+s[i]*.5)) % L for i in range(4))
for s in product((1,-1), repeat=4) if sum(s)%4 == want])
nV, nE, nF, nT, nC = len(vs), len(E), len(F), len(T), len(C4)
print("cells:", nV, nE, nF, nT, nC, "␣Euler:", nV-nE+nF-nT+nC)
fin = [0]*nF
for tk in T:
for tri in combinations(tuple(tk),3): fin[F[frozenset(tri)]] += 1
tin = [0]*nT
for cv in C4:
prs = {frozenset(p) for p in combinations(cv,2) if adj(*p)}
for q in combinations(cv,4):
if all(frozenset(p) in prs for p in combinations(q,2)):
tin[T[frozenset(q)]] += 1
print("triangle-in-tets:", set(fin), "␣tet-in-16cells:", set(tin))
HZ = [0]*nE
12
for fk, fi in F.items():
for pr in combinations(tuple(fk),2):
HZ[E[frozenset(pr)]] |= 1 << fi
HX = []
for tk in T:
r = 0
for tri in combinations(tuple(tk),3): r |= 1 << F[frozenset(tri)]
HX.append(r)
wz = {bin(r).count(’1’) for r in HZ}
wx = {bin(r).count(’1’) for r in HX}
css = all(bin(x & z).count(’1’)%2 == 0 for x in HX for z in HZ)
rz, rx = rank(HZ), rank(HX)
print("weights␣Z/X:", wz, wx, "␣commute:", css)
print("n=%d␣rk(HZ)=%d␣rk(HX)=%d␣k=%d" % (nF, rz, rx, nF-rz-rx))
rhs = [1] + [0]*(nT-1)
print("single␣X-check␣reachable:", solvable(HX, rhs))
def cols(H):
c = [0]*nF
for i, r in enumerate(H):
m = r
while m:
b = (m & -m).bit_length()-1; c[b] |= 1 << i; m &= m-1
return c
for H, nm in ((HZ,’ker␣HZ’), (HX,’ker␣HX’)):
c = cols(H)
print(nm, "wt-1:", c.count(0), "␣wt-2:", len(c)-len(set(c)))
fic = [0]*nF
for cv in C4:
for tri in combinations(cv,3):
fk = frozenset(tri)
if fk in F: fic[F[fk]] += 1
print("triangle-in-16cells:", set(fic))
sv = [v for v in vs if v[3] == 0]
se = [k for k in E if all(u[3] == 0 for u in k)]
sf = [k for k in F if all(u[3] == 0 for u in k)]
st = [k for k in T if all(u[3] == 0 for u in k)]
print("slice␣V,E,F,T:", len(sv), len(se), len(sf), len(st))
print("slice␣edge␣in␣4␣slice␣triangles:",
all(sum(1 for fk in F if ek <= fk and
all(u[3] == 0 for u in fk)) == 4 for ek in se))
sec = sorted({sum(1 for u in cv if u[3] == 0)
for cv in C4 if 0 < sum(1 for u in cv if u[3] == 0) < 8})
print("16-cell␣slice␣sections:", sec) # [1, 4, 6]
B The two shadow constants
This proves Lemma 1. It runs over every kind of triangle and every coordinate pair in exact
arithmetic, and reports the largest shadow a triangle and a dual 2-cell can cast. Output: 1/2 and
1/4. Needs nothing beyond the standard library and runs in about a second.
#!/usr/bin/env python3
"""Largest shadow a single cell can cast on a coordinate plane."""
13
from itertools import product, combinations
from fractions import Fraction
roots = [tuple(r) for r in product((-1,0,1), repeat=4)
if sum(map(abs,r)) == 2]
rootset = set(roots)
area2 = lambda a,b,i,j: abs(a[i]*b[j] - a[j]*b[i]) # twice the area
best = 0
for r, s in combinations(roots, 2):
if tuple(r[i]-s[i] for i in range(4)) not in rootset: continue
for i, j in combinations(range(4), 2):
best = max(best, area2(r, s, i, j))
print("triangle:␣max␣shadow␣=", Fraction(best,2)) # 1/2
print("␣␣=>␣every␣X-logical␣has␣weight␣>=", Fraction(2,best), "L^2")
# gaps: odd-integer points and half-integer points
holes = [tuple(map(Fraction,p)) for p in product(range(-2,3), repeat=4)
if sum(p)%2 == 1]
holes += [tuple(Fraction(2*x+1,2) for x in p)
for p in product(range(-2,3), repeat=4)]
bestd = 0
for r, s in combinations(roots, 2):
if tuple(r[i]-s[i] for i in range(4)) not in rootset: continue
tri = [(Fraction(0),)*4, tuple(map(Fraction,r)), tuple(map(Fraction,s))]
hs = [h for h in holes
if all(sum((u[i]-h[i])**2 for i in range(4)) == 1 for u in tri)]
assert len(hs) == 3 # every triangle lies in three 16-cells
a = tuple(hs[1][i]-hs[0][i] for i in range(4))
b = tuple(hs[2][i]-hs[0][i] for i in range(4))
for i, j in combinations(range(4), 2):
bestd = max(bestd, area2(a, b, i, j))
print("dual␣cell:␣max␣shadow␣=", Fraction(bestd,2)) # 1/4
print("␣␣=>␣every␣Z-logical␣has␣weight␣>=", Fraction(2,bestd), "L^2")
C Brute-force check on the slice code
This tests the shadow argument on the three-dimensional face code of a slice, where the same
argument predicts 2L
2
and the code is small enough to settle exactly. Parity constraints are
encoded by chaining exclusive-ors; one further constraint forces the operator to be nontrivial;
a counter caps the weight; the bound is raised one step at a time until the problem becomes
satisfiable. Needs python-sat.
#!/usr/bin/env python3
"""Smallest nontrivial logical of the slice face code, by SAT."""
from pysat.formula import IDPool
from pysat.card import ITotalizer
from pysat.solvers import Cadical195
# HZ, nF for the slice complex; LZ = a basis of dual logicals
def bits(v):
out = []
while v:
b = (v & -v).bit_length()-1; out.append(b); v &= v-1
return out
14
def xor_chain(lits, parity, pool, cnf):
acc = lits[0]
for v in lits[1:]:
nxt = pool.id()
cnf += [[-nxt,-acc,-v], [-nxt,acc,v], [nxt,-acc,v], [nxt,acc,-v]]
acc = nxt
cnf.append([acc] if parity else [-acc])
for f in LZ: # one run per logical functional
pool = IDPool(start_from=nF+1); cnf = []
for r in HZ:
xor_chain([b+1 for b in bits(r)], 0, pool, cnf)
xor_chain([b+1 for b in bits(f)], 1, pool, cnf)
tot = ITotalizer(lits=list(range(1,nF+1)), ubound=32, top_id=pool.top)
with Cadical195(bootstrap_with=cnf) as s:
s.append_formula(tot.cnf.clauses)
for w in range(6, 33, 2): # even weights only
if s.solve(assumptions=[-tot.rhs[w]]):
print("logical␣found␣at␣weight", w); break
print("no␣logical␣of␣weight␣<=", w)
tot.delete()
# unsatisfiable at 6,8,...,30, satisfiable at 32 => 32 = 2L^2
D Hook errors
Reproduces Section 8.1. For each suffix of a check’s support it solves an exact minimum-
weight coset problem: the smallest weight reachable by adding stabilizers to that suffix. Needs
python-sat. Runs in a few minutes at L = 4.
def min_coset_weight(S, group, cap):
"""Smallest weight in the coset S + span(group), by SAT."""
pool = IDPool(start_from=nF + len(group) + 1); cnf = []
rowsfor = [[] for _ in range(nF)] # which rows touch each qubit
for j, g in enumerate(group):
for i in bits(g): rowsfor[i].append(nF + 1 + j)
for i in range(nF): # x_i = S_i XOR (sum of rows)
lits, xv = rowsfor[i], i + 1
if not lits:
cnf.append([xv] if (S >> i) & 1 else [-xv]); continue
acc = lits[0]
for v in lits[1:]:
nxt = pool.id()
cnf += [[-nxt,-acc,-v], [-nxt,acc,v], [nxt,-acc,v], [nxt,acc,-v]]
acc = nxt
cnf += ([[xv, acc], [-xv, -acc]] if (S >> i) & 1
else [[-xv, acc], [xv, -acc]])
tot = ITotalizer(lits=list(range(1, nF+1)), ubound=cap, top_id=pool.top)
with Cadical195(bootstrap_with=cnf) as s:
s.append_formula(tot.cnf.clauses)
for w in range(0, cap+1):
if s.solve(assumptions=[-tot.rhs[w]]): return w
# a Z fault after k CNOTs lands on the remaining data qubits
for s in range(1, 8):
S = 0
15
for i in faces8[8-s:]: S |= 1 << i
print(s, min_coset_weight(S, HZ, cap=6))
# 1,2,3,4,3,2,1 -> worst hook reduces to weight 4
16