---
title: Directional Codes in Quantum Systems
url: https://www.emergentmind.com/topics/directional-codes
type: topic
---

# Directional Codes in Quantum Systems

Directional codes are a class of constructions in which directional, orientational, or anisotropic structure is made explicit in the code definition rather than treated as incidental. In current arXiv literature, the term is used in several technically distinct ways. The most specific usage denotes a family of hardware-motivated quantum low-density parity-check (qLDPC) codes defined by stabilizer-measurement routes on square- and hex-grid hardware [2507.19430]. Closely related work studies the algebraic structure of such route-generated CSS codes [2602.19057], directionally informed decoding for quantum codes [2601.07240], and topological-code modifications with explicit anyonic confinement along one spatial direction [2506.22025]. In another line of work, “directional codes” denotes product-structured finite alphabets for preserving vector direction under low-precision quantization [2605.07662]. A related geometric theme also appears in spatio-directional neural encodings on $S^2$ [2603.05079].

## 1. Directional Codes as qLDPC codes on local-connectivity hardware

The qLDPC family called “Directional Codes” is defined on the infinite square lattice $\mathbb Z^2$, with data qubits on
$$
\mathbb Z^2_{\rm data}=\{(x,y)\colon x+y\equiv0\pmod2\}
$$
and ancilla qubits on the complementary checkerboard sublattice. A code is specified by a direction sequence $(D_1,D_2,\dots,D_w)$ with $D_j\in\{N,E,S,W\}$, a layout $\alpha:\mathbb Z^2_{\rm anc}\to\{X,Z\}$ assigning each ancilla to an $X$-type or $Z$-type plaquette, and two lattice vectors $\vec v_1,\vec v_2$ used to wrap the plane onto a torus [2507.19430].

Syndrome extraction is implemented by $w$ simultaneous layers of controlled-Pauli-then-swap gates. For an $X$ plaquette ancilla $A$, the elementary operation is
$$
\mathrm{CXSWAP}(A,Q)=\bigl(\mathrm{CX}(A,Q)\bigr)\,\mathrm{SWAP}(A,Q),
$$
and for a $Z$ plaquette ancilla the CX is replaced by CZ. Up to single-qubit Cliffords, both CXSWAP and CZSWAP are equivalent to the native iSWAP gate. In each round, ancillas are reset in $\lvert+\rangle$, the $w$ directional layers are applied, and ancillas are measured in the $X$ basis. Each ancilla thereby “slides” across the lattice and measures a weight-$w$ plaquette operator supported on the data qubits it visits. Under mild nondegeneracy conditions on the torus identification, this yields a finite CSS stabilizer code on $\mathbb Z^2/\langle \vec v_1,\vec v_2\rangle$ [2507.19430].

Several small-weight families were isolated explicitly. The weight-4 NEEN sequence yields a linear transform of the distance-$d$ toric code. The weight-5 $NE^3N$ family uses only hexagonal-grid connectivity, degree-$3$ per qubit. The weight-6 $N^2E^2N^2$ family admits a rectangular torus on the square grid, and the weight-7 $N^2E^3N^2$ family admits a layout on square or hex grid [2507.19430].

The principal finite families studied numerically encode $4$, $6$, or $12$ logical qubits.

| Family | Parameters | Connectivity or performance claim |
|---|---|---|
| $NE^3N$ | $n=\tfrac32 d^2+3d$, $k=4$, distance $d$ | Hexagonal-grid connectivity; comparable to four RPC copies at $37.5\%-56.25\%$ of the total qubit count at $p=10^{-3}$ |
| $N^2E^2N^2$ | $n=4d^2$, $k=6$, distance $d$ | Beats six RPC copies using $41.15\%-66.67\%$ of qubits |
| $N^2E^3N^2$ | $n=6d^2-12d$ or $6d^2$, $k=12$, distance $d$ | Beats twelve RPC copies using $25\%-50\%$ of qubits at equal distance $d\le10$ |

The numerical evaluation used the superconducting-inspired SI-1000 circuit-level Pauli noise model over five full QEC rounds, with BP-OSD decoding. At $p=10^{-3}$, the reported logical error probabilities were favorable relative to repeated rotated planar code instances. A representative $d=6$ comparison gave RPC$_{d=6}\times4$ with $480$ total qubits and $p_L=0.012$, versus $NE^3N$ $\llbracket72,4,6\rrbracket$ with $288$ total qubits and $p_L=0.0088$, $N^2E^2N^2$ $\llbracket144,6,6\rrbracket$ with $216$ total qubits and $p_L=0.0065$, and $N^2E^3N^2$ $\llbracket144,12,6\rrbracket$ with $264$ total qubits and $p_L=0.0071$ [2507.19430].

## 2. Word-first structural theory of route-generated codes

A later structural treatment places these qLDPC constructions into a “word-first” framework for route-generated, translation-invariant CSS codes on rectangular tori [2602.19057]. The starting object is a direction word
$$
W=d_1d_2\cdots d_w,\qquad d_j\in D,
$$
over the alphabet
$$
D=\{N=(0,1),\,E=(1,0),\,S=(0,-1),\,W=(-1,0)\}\subset\mathbb Z^2.
$$
With partial sums
$$
S_0=(0,0),\qquad S_j=\sum_{t=1}^j d_t,
$$
the route-to-support lemma defines midpoint offsets
$$
Q_j=S_{j-1}+S_j=2\sum_{t=1}^{j-1}d_t+d_j.
$$
On a checkerboard torus $G=\mathbb Z_{L_x}\times\mathbb Z_{L_y}$, an ancilla at $a\in\Lambda_A$ interacts with data qubits at $a+Q_j\pmod{(L_x,L_y)}$, and the support pattern is
$$
P(W)=\{Q_1,\dots,Q_w\}\subset\mathbb Z^2.
$$
This supplies a closed-form route-to-support map [2602.19057].

The central commutation invariant is the odd-multiplicity difference lattice. From the multiset of pairwise differences
$$
\Delta(W)=\{Q_j-Q_i:1\le i<j\le w\},
$$
one extracts
$$
\Delta_{\rm odd}(W)=\{v\in\mathbb Z^2:\mu(v)\equiv1\pmod2\},
\qquad
L(W)=\mathrm{span}_{\mathbb Z}\bigl(\Delta_{\rm odd}(W)\bigr).
$$
The layout coset theorem states that on the infinite checkerboard lattice any commuting CSS layout $\alpha:\Lambda_A\to\{X,Z\}$ must be constant on cosets of $L(W)$:
$$
a-b\in L(W)\Longrightarrow \alpha(a)=\alpha(b).
$$
Conversely, any such coset-constant labeling gives a translation-invariant CSS code satisfying $X$–$Z$ commutation [2602.19057].

The same framework gives conservative finite-torus admissibility criteria. Defining
$$
D(W)=\{\pm(Q_j-Q_i)\}_{1\le i<j\le w},
\quad
D(W)\pm D(W)=\{v\pm v':\,v,v'\in D(W)\},
$$
a sufficient bound is
$$
L_x>\max_{v\in D(W)\cup[D(W)\pm D(W)]}|v_x|,
\qquad
L_y>\max_{v\in D(W)\cup[D(W)\pm D(W)]}|v_y|.
$$
Under these inequalities, no nonzero relevant offset vanishes modulo $(L_x,L_y)$, so the infinite-lattice schedule remains collision-free on the torus [2602.19057].

The theory also quotients the search over direction words by dihedral lattice symmetries $D_4$, reversal plus inversion, and cyclic shifts. The equivalence class has size at most $16w$, and canonicalization chooses the lexicographically smallest representative in expanded-letter form. An inverse problem is solved as well: a translation-invariant support pattern $P$ is realizable by a single route iff, for some ordering $Q_1,\dots,Q_w$, one has $Q_1\in D$, each difference $\Delta_j=Q_{j+1}-Q_j$ lies in
$$
\Sigma=\{u+v:\,u,v\in D\}=\{\pm(2,0),\pm(0,2),\pm(1,1)\},
$$
and the recursion
$$
d_1=Q_1,\qquad d_{j+1}=\Delta_j-d_j
$$
stays in $D$ at every step. Failure certifies non-realizability [2602.19057].

As a case study, the word $W=NE^2NE^2N$ has
$$
P(W)=\{(0,1),(1,2),(3,2),(4,3),(5,4),(7,4),(8,5)\},
$$
$$
\Delta_{\rm odd}(W)=\{(2,2),(6,2),(8,4)\},
\qquad
L(W)=\mathrm{span}_{\mathbb Z}\{(4,0),(2,2)\}.
$$
For thin rectangles $(L_x,L_y)=(2d,d)$ with row alternation, the exact criterion is
$$
k=
\begin{cases}
4,&6\mid d,\\
0,&6\nmid d.
\end{cases}
$$
This makes the dependence of code dimension on boundary conditions completely explicit [2602.19057].

## 3. Decoding anisotropy and directional confinement in related quantum-code constructions

The directional-code program in quantum error correction extends beyond code construction to decoding and topological phase engineering. In directionally informed BP decoding for CSS codes, one assigns nonnegative orientation weights $D_Z(i,j)$ to Tanner-graph edges and aggregates them into per-qubit weights
$$
w_i=\sum_{j\in N_Z(i)}D_Z(i,j).
$$
For a fixed syndrome $s_Z$, each degeneracy class is scored by the minimum weighted Hamming cost
$$
\Delta_{\bm w}(E)=\sum_{i=1}^n w_iE_i,
\qquad
\Delta_*([e])=\min_{u\in S_X}\Delta_{\bm w}(e+u),
$$
leading to the directional degeneracy enumerator
$$
\Gamma_X(s_Z;\beta)=\sum_{[e]\in\mathcal D_X(s_Z)}\exp\bigl(-\beta\,\Delta_*([e])\bigr),\qquad \beta\ge0.
$$
A single bias parameter $\beta$ maps the weights to site-dependent log-likelihood ratios through
$$
p_i(\beta)=\frac{p_0\,e^{\beta w_i}}{\tfrac1n\sum_{j=1}^n e^{\beta w_j}},
\qquad
\ell_i(\beta)=\log\frac{1-p_i(\beta)}{p_i(\beta)},
$$
which plug directly into standard BP$\rightarrow$OSD decoders without altering the code itself [2601.07240].

The framework yields weighted-distance bounds,
$$
w_{\min}d\le d_{\bm w}^{\rm L}\le w_{\max}d,
\qquad
w_{\min}d_{\mathrm S}\le d_{\bm w}^{\rm S}\le w_{\max}d_{\mathrm S},
$$
and a MacWilliams-type expression for the global directional enumerator. Finite-length code-capacity simulations were reported for a planar NE3N code $\llbracket36,4\rrbracket$ on an $18\times4$ lattice and a toric code $\llbracket2L^2,2,L\rrbracket$ with $L=9$. For both families, a modest bias strength $\beta\approx1\text{--}3$ reduced the logical error rate by one to two orders of magnitude at physical error rates in the $10^{-3}$–$10^{-2}$ range, with a clear optimum around $\beta\approx1.5$–$2$ in the toric-code example [2601.07240].

A different use of directional structure appears in twisted toric codes with explicit anyonic confinement along one spatial direction. There, vertical plaquette terms are twisted by a group $2$-cocycle through projective representations of $G=\mathbb Z_2\times\mathbb Z_2$. A vertical string
$$
S^{\rm vert}_\alpha=\bigotimes_{j=1}^{L_y}X^\alpha_g(j)
$$
excites $L_y+2$ plaquettes, so its energy cost grows linearly with vertical length, whereas horizontal strings of $X_g$ remain deconfined. Binding a left-confined string and a right-confined string produces
$$
S^{\rm dipole}_g=\bigotimes_{j=1}^{L_y}\bigl(X^{\bar\alpha_g}(j)\otimes X^\alpha_g(j)\bigr),
$$
which creates dipolar excitations that can move vertically without extra plaquette cost but cannot move horizontally without breaking the bound state. On a torus, the logical-operator structure depends on the parity of $L_y$: when $L_y$ is odd, there are two logical operators and one logical qubit; when $L_y$ is even, there are four logical operators and two logical qubits [2506.22025].

These two developments are technically distinct. One alters priors and degeneracy accounting for a fixed quantum code [2601.07240]; the other alters the Hamiltonian itself to induce anisotropic excitation structure [2506.22025]. This suggests that “directionality” in quantum coding theory now functions at three levels: code construction, decoder design, and phase engineering.

## 4. Direction-preserving number representations

In low-precision numerical computing, directional codes are product-structured codes induced by a finite scalar alphabet $A\subset\mathbb R$ common to all coordinates [2605.07662]. For block dimension $n$, the achievable directions are
$$
{}_n(A):=\{x/\|x\|_2:\,x\in A^n\setminus\{0\}\}\subset S^{n-1},
$$
and worst-case angular fidelity is measured by the spherical covering radius
$$
F_n(A):=\sup_{u\in S^{n-1}}\min_{c\in{}_n(A)}\arccos\langle u,c\rangle.
$$
Equivalently,
$$
\alpha_n(A):=\inf_{u\in S^{n-1}}\max_{x\in A^n\setminus\{0\}}\frac{\langle u,x\rangle}{\|x\|_2},
\qquad
F_n(A)=\arccos \alpha_n(A).
$$
For alphabet size $|A|=q$, the best achievable product-code coverage is
$$
w_{n,q}:=\inf_{A:|A|=q}F_n(A).
$$

The theory compares these product codes with unconstrained spherical codes of the same total size. In dimension $n=2$, the exact planar optimum is $\rho_{\rm sph}(2,m)=\pi/m$. If $A=\{-a,+a\}$, then $F_2(A)=\pi/4=\rho_{\rm sph}(2,4)$. Otherwise,
$$
F_2(A)>\rho_{\rm sph}(2,q^2)=\pi/q^2.
$$
Except for the antipodal binary case, every two-coordinate product code is therefore strictly worse than the best unconstrained $2$-D spherical code with the same number of points [2605.07662].

In high dimension with fixed alphabet size $q$, the gap persists asymptotically. A harmonic-witness lower bound gives
$$
F_n(A)\ge \arccos\min\{1,\,2\sqrt{\lfloor q/2\rfloor/H_n}\},
$$
where $H_n=\sum_{i=1}^n (1/i)\to \log n+\gamma$. A sphere-covering upper bound via Wyner’s theorem shows that for any $\theta>\arcsin(1/q)$ there exists $N$ such that for all $n\ge N$,
$$
\rho_{\rm sph}(n,q^n)\le \theta<\pi/2.
$$
Combining the two yields
$$
\rho_{\rm sph}(n,q^n)<w_{n,q}
$$
for large $n$. Thus, for fixed bit-width $b$ with $q=2^b$, no product-code alphabet of size $2^b$ matches the angular coverage of the best spherical code under the same storage budget [2605.07662].

Within the product-code class, standard scalar formats are also suboptimal. For any $b$-bit floating-point family, including fixed-point and two’s complement as special cases,
$$
\limsup_{n\to\infty}\sqrt{H_n}\cos F^{fp}_{n,b}\le 2\sqrt{(2^{b-1}+1)/3},
$$
whereas an optimal $2^b$-symbol alphabet satisfies
$$
\liminf_{n\to\infty}\sqrt{H_n}\cos w_{n,2^b}\ge 2\sqrt{2^{b-1}-1}.
$$
For $b\ge3$, the latter constant is strictly larger; for $b=4$, the asymptotic constant-factor gap is at least $\sqrt{7/3}\approx1.53$ [2605.07662].

The paper then optimizes alphabets numerically by sampling one million random directions on $S^{n-1}$, using the scale-search algorithm of Theorem A.18 inside a derivative-free optimizer, with global Differential Evolution and local Powell refinement. By scale invariance, the smallest nonzero level is set to $1$. For $4$ bits and $d=16$, the optimized positive levels are
$$
[1,\,2.12,\,3.40,\,5.04,\,7.25,\,10.5,\,13.2].
$$
The sampled worst-case angular errors reported for $d\in\{4,8,16,32,64\}$ were as follows [2605.07662]:

| Format | Errors across $d=4,8,16,32,64$ |
|---|---|
| Optimized | $4.08^\circ, 5.15^\circ, 6.07^\circ, 6.96^\circ, 7.13^\circ$ |
| E2M1 (NVFP4) | $5.45^\circ, 5.91^\circ, 6.67^\circ, 7.10^\circ, 7.60^\circ$ |
| INT/E1M2 | $6.75^\circ, 8.08^\circ, 9.58^\circ, 10.9^\circ, 11.4^\circ$ |
| E3M0 | $10.7^\circ, 10.9^\circ, 11.0^\circ, 11.1^\circ, 11.1^\circ$ |

The near-optimality of NVIDIA’s E2M1 is therefore given a geometric explanation: it closely approximates the optimized alphabet for $4$-bit settings and target block sizes up to at least $64$ [2605.07662].

## 5. Spatio-directional neural encodings

A related, though terminologically distinct, development appears in neural scene representation and rendering, where the problem is to encode directional signals on $S^2$ without the distortions, singularities, and discontinuities induced by Cartesian parameterizations [2603.05079]. The “hash-sphere” encoding begins from a hierarchical geodesic grid: level $0$ tessellates the unit sphere into the $20$ triangular faces of a regular icosahedron, and each higher level subdivides every triangle into $4$ sub-triangles by bisecting edges and projecting new points back onto $S^2$. At level $l$, the vertex set satisfies $|V_l|=20\cdot 4^l$.

For a query direction $d\in S^2$, one finds the enclosing triangle $T_l(d)$ with vertices $V_{d,l}=\{v_1,v_2,v_3\}$, computes barycentric coordinates $\beta_v$, and interpolates learned features:
$$
f_l(d)=\sum_{v\in V_{d,l}}\beta_v\cdot \theta_l[\Phi_l(v)].
$$
The final directional feature is
$$
f(d)=[f_0(d);f_1(d);\dots;f_{L-1}(d)]\in\mathbb R^{L\cdot f},
$$
which is passed to a small MLP, for example $2$ layers with $16$ neurons and identity or ReLU activations, with final exponential or sigmoid depending on the application [2603.05079].

The five-dimensional “hash-grid-sphere” couples this directional encoding to the spatial hash-grid of Müller et al. 2022. Using the same number of spatial levels $L$ but only $M\le L$ directional refinement levels, controlled by a map such as $m(l)=\lfloor l/2\rfloor$, the per-level feature at query $(x,d)$ is
$$
f_l(x,d)=\sum_{c\in C_{x,l}}\sum_{v\in V_{d,m(l)}}[w_c\cdot \beta_v]\cdot \theta_l[\Phi_l(c,v)].
$$
The stated theoretical advantages are that factored interpolation respects $S^2$ topology and $\mathbb R^3$ topology independently, angular and spatial resolution are controlled separately through $m(l)$, hashing bounds memory by $O(L\cdot T)$ rather than $O(|C_l|\cdot |V_l|)$, and each sample touches only $8\cdot3=24$ entries per level versus $64$ for a $6$-D grid [2603.05079].

The implementation measurements were reported on an RTX 4070 in half precision. For a pure directional task with $L=8$, $T=2^{18}$, and $f=2$, hash-sphere used $0.74$ MB and $6.9$ ms/frame; a $2$-D polar hash-grid used $0.88$ MB and $6.6$ ms; and a $3$-D Cartesian hash-grid used $0.81$ MB and $9.5$ ms. In a 5D radiance-field experiment on the Phone scene, $3$D hash-grid + SH(100) used $55.7$ MB and $120$ ms, a $6$D hash-grid used $67.1$ MB and $1393$ ms, and hash-grid-sphere used $52.1$ MB and $301$ ms. For neural path guiding on an HD frame with $M=16$ candidates, the baseline hash-grid + One-Blob with a large MLP used $2.97$ MB and $20.4$ ms, whereas hash-grid-sphere with a small MLP used $1.80$ MB and $34.5$ ms [2603.05079].

Empirically, the path-guiding results reported up to $2.25\times$ lower variance for equal rendering time. Across the scenes “Veach Caustics,” “Kitchen Indirect,” “Living Room Indirect,” and “Staircase,” the method with $M=8$ candidates consistently outperformed the baseline with $M=32$. In simple single-bounce diffuse scenes both encodings performed similarly, whereas in multi-bounce glossy scenes the baseline produced “splotchy” cache artifacts and the hash-grid-sphere remained stable [2603.05079].

## 6. Terminological scope and conceptual distinctions

The literature therefore uses “directional codes” in more than one formal sense. In qLDPC theory, a directional code is a route-generated stabilizer code whose checks are induced by a direction word and measured through local iSWAP-compatible circuits on checkerboard lattices [2507.19430]. In the structural analysis of those codes, the direction word is elevated to the primary algebraic object, from which one derives support patterns, commutation lattices, equivalence classes, and boundary-sensitive dimension formulas [2602.19057]. In decoding, direction enters as an anisotropic prior over qubits and as a degeneracy-weighting scheme on Tanner graphs [2601.07240]. In low-precision arithmetic, directional codes are product codes on $S^{n-1}$ evaluated by worst-case angular coverage [2605.07662]. In neural representation, the analogous object is a directional encoding on $S^2$ coupled to a spatial hash-grid [2603.05079].

These usages suggest a shared methodological pattern: direction is not merely metadata but an organizing variable that changes the combinatorics, geometry, or energetics of the representation. The consequences are domain-specific. In qLDPC constructions, direction words determine stabilizer footprints and hardware schedules [2507.19430, 2602.19057]. In twisted toric codes, direction determines which anyons are linearly confined and which dipoles remain mobile [2506.22025]. In product-structured number representations, direction determines the governing approximation metric, namely worst-case angular error [2605.07662]. In neural rendering, direction determines the topology of the latent grid and the interpolation rule on $S^2$ [2603.05079].

By contrast, “codes for directional solidification” in phase-field benchmarking refers to massively parallel simulation implementations rather than to code constructions in the coding-theoretic or geometric sense [2602.10316]. That distinction is useful because it separates terminological overlap from substantive continuity. The primary continuous thread across the actual directional-code literature is the formalization of anisotropy: route anisotropy in lattice codes, noise anisotropy in decoding, confinement anisotropy in topological order, angular anisotropy in finite alphabets, and spherical anisotropy in neural signal representations.

Source: https://www.emergentmind.com/topics/directional-codes