---
title: 'Triorthogonal Matrices: Quantum Coding & Distillation'
url: https://www.emergentmind.com/topics/triorthogonal-matrices
type: topic
---

# Triorthogonal Matrices: Quantum Coding & Distillation

Triorthogonal matrices are binary matrices over $\mathbb F_2$ whose row supports obey simultaneous pairwise and triple-wise parity constraints. In quantum information, they furnish a combinatorial interface between classical linear codes and Calderbank–Shor–Steane (CSS) stabilizer codes, with the distinctive feature that the resulting quantum codes admit transversal non-Clifford operations, most notably the $T$ gate and, in related constructions, $CCZ$. For that reason, triorthogonality has become a standard organizing principle for magic-state distillation, transversal-gate analysis, and the construction of CSS-$T$ code families [1209.2426][1304.3709].

## 1. Definition and basic algebraic structure

A binary matrix $G\in\mathbb F_2^{m\times n}$ with rows $g_1,\dots,g_m$ is called triorthogonal when two conditions hold. First, every pair of distinct rows is orthogonal:
\[
\sum_{j=1}^n G_{a j}G_{b j}\equiv 0 \pmod 2
\quad\text{for all }a\neq b.
\]
Second, every triple of distinct rows has even triple overlap:
\[
\sum_{j=1}^n G_{a j}G_{b j}G_{c j}\equiv 0 \pmod 2
\quad\text{for all distinct }a,b,c.
\]
Equivalently, if $\wedge$ denotes coordinate-wise product and $|\,\cdot\,|$ denotes Hamming weight modulo $2$, then triorthogonality is the requirement that $|g_a\wedge g_b|=0$ for all pairs and $|g_a\wedge g_b\wedge g_c|=0$ for all triples [1209.2426][2408.09685].

In most quantum-coding applications, the rows are partitioned by parity into an odd-weight block $G_1$ and an even-weight block $G_0$. This parity split is not merely notational. The odd rows are later interpreted as logical operators, while the even rows generate an $X$-stabilizer subspace. The pairwise condition alone makes the row space self-orthogonal; the triple condition is the additional constraint that enables transversal gates above the Clifford level [2408.09685].

Several later works reformulate the same definition in adjacent languages. One may write the condition using incidence matrices for row overlaps, using Schur products and the space $(C^{\star 2})^\perp$, or via “indicator polynomials” in Reed–Muller spaces. These reformulations do not change the underlying object: a triorthogonal matrix is always a matrix whose pairwise and triple-wise intersections of row supports have even parity [2408.02916][2107.09684].

## 2. From triorthogonal matrices to CSS stabilizer codes

Given a triorthogonal matrix $G$, one obtains a CSS stabilizer code by assigning the even-weight rows $G_0$ to the $X$-type stabilizers and taking the orthogonal complement of the full row span to define the $Z$-type stabilizers. The odd-weight rows then specify logical $X$ operators, and the same rows can be used to choose logical $Z$ operators. In the standard binary formulation, if $G$ has $k$ odd rows, the associated CSS code encodes $k$ logical qubits into $n$ physical qubits [1209.2426][1304.3709].

A common formulation writes $C_1=\mathrm{rowspan}(G)$ and $C_2=(\mathrm{rowspan}(G_0))^\perp$, so that the quantum code is $CSS(C_1,C_2)$. In this language, the code distance is
\[
d=\min\Bigl\{\min_{r\in C_1\setminus C_2^\perp}|r|,\;
\min_{s\in C_2\setminus C_1^\perp}|s|\Bigr\},
\]
while in the earlier Bravyi–Haah presentation the relevant distillation parameter is the $Z$-distance
\[
d=\min\Bigl\{|f|: f\in \mathcal V_0^\perp,\ f\notin \mathcal V^\perp\Bigr\},
\]
with $\mathcal V_0$ the span of the even rows and $\mathcal V$ the span of all rows [2510.05708][1209.2426].

The operational importance of the construction is that triorthogonality permits transversal implementation of non-Clifford gates. Bravyi and Haah showed that there exists a diagonal Clifford $U$, built from $\Lambda(Z)$ and $S$ gates, such that $U\,T^{\otimes n}$ acts as logical $T$ on each encoded qubit [1209.2426]. Jones showed that triorthogonal stabilizer codes also admit transversal implementation of $CCZ$, and that logical Hadamard is not purely transversal because no triorthogonal code is fully self-dual; instead, Hadamard can be completed fault-tolerantly by combining transversal $H$ with error correction [1304.3709]. More recently, a logical Hadamard protocol based on transversal $CZ$ teleportation and code-switching between a triorthogonal code and a symmetric CSS code was proposed, with the claim that these gadgets can be folded into Steane error correction without increasing the ancilla count [2510.05708].

## 3. Role in magic-state distillation

Triorthogonal matrices were introduced in their modern form as a tool for low-overhead magic-state distillation. In the Bravyi–Haah protocol, one prepares an encoded state $\ket G$, applies noisy physical $T$ gates supplied by imperfect $T$-states, performs a diagonal Clifford cleanup, measures the $X$-stabilizers coming from the even-row subspace, post-selects on the trivial syndrome, and then decodes. If the input state is $\rho=(1-p)\ket A\!\bra A + p\,Z\ket A\!\bra A Z$, the output error on each logical qubit scales as $O(p^d)$, where $d$ is the $Z$-distance of the code, and the success probability is $1-O(p)$ [1209.2426].

The asymptotic overhead is expressed through the exponent
\[
\gamma=\frac{\log(n/k)}{\log d},
\]
so that the resource cost behaves as $C(\epsilon)=O(\log^\gamma(1/\epsilon))$. Bravyi and Haah constructed an explicit infinite family with $n=3k+8$ and $d=2$, yielding $\gamma\to\log_2 3\approx 1.585$ as $k\to\infty$, together with leading-order behavior
\[
p_{\rm out}\sim (3k+1)p^2
\]
for the distillation error [1209.2426].

The framework was later generalized beyond single-qubit $T$ states. Haah and Hastings introduced generalized triorthogonal matrices with row blocks $G_T$, $G_{CS}$, $G_{CCZ}$, and $G_0$, arranged so that transversal $T$ induces not only logical $T$ gates but also controlled-$S$ and $CCZ$ on designated logical subsets. In that setting they presented both randomized and Reed–Muller-based constructions and showed an asymptotic distillation efficiency $\gamma\to 1$ [1709.02832].

The use of triorthogonality in distillation is not limited to abstract asymptotics. Jones adapted the triorthogonal-code approach to Toffoli-state distillation and gave an explicit leading-order estimate
\[
p_{\rm out}=(3k+1)p^2
\]
for a family of $[[3k+8,k,2]]$ codes used in that setting [1304.3709]. This places triorthogonal matrices at the intersection of error detection, transversal-gate synthesis, and resource-state production.

## 4. Classification and the small-code regime

A substantial structural advance is the classification of all small triorthogonal codes with $n+k\le 38$. In that regime, there are exactly $38$ inequivalent unital triorthogonal subspaces $S\subseteq\mathbb F_2^c$, each containing the all-ones vector. Every triorthogonal code with parameters $[[n,k,d_Z\ge 2]]$ and $n+k\le 38$ descends from exactly one of these $38$ parent subspaces by puncturing and qubit deletion [2107.09684].

The puncturing operation is organized by a subset $P\subseteq\{1,\dots,c\}$ of size $p$ satisfying the full-rank condition $\Pi_P(S)=\mathbb F_2^p$. Depending on parity, one obtains either an even descendant with $k=p$ and $n=c-p$, or an odd descendant with $k=p-1$ and $n=c-p$. Qubit deletion then removes repeated or zero columns from the resulting generator. This descendant structure gives a canonical way to view small triorthogonal codes as arising from a finite list of “parent” subspaces [2107.09684].

The classification is expressed through Reed–Muller theory. To each unital subspace $S$ of dimension $r$ one associates an indicator polynomial
\[
f(x_1,\dots,x_{r-1})\in RM(r-5,r-1)
\]
of Hamming weight $|f|=c$, defined so that $f(v)=1$ precisely when $(1,v_1,\dots,v_{r-1})$ is a column of a generator for $S$. The key lemma is that $S$ is triorthogonal unital if and only if $\deg f\le r-5$ and $f$ has no linear factor. Thus the small-code classification reduces to classifying low-weight codewords in Reed–Muller codes. Using the results of Kasami, Tokura, and Azumi together with an exhaustive computer search, the authors found exactly $38$ affine-inequivalent such polynomials of weight $c<40$ [2107.09684].

Several concrete consequences follow. The canonical $[[15,1,3]]$ distillation code arises from the indicator polynomial $f=1\in RM(1,4)$ with $r=5$ and $c=16$, followed by puncturing. A new extremal example in the classified range is the $[[35,3,3]]$ code obtained as the even descendant of subspace $\#33$. The paper also proves a rate bound: for any triorthogonal code $[[n,k,d_Z\ge 2]]$, one has $n\ge 2k$. In the range $n+k\le 38$, no code achieves $d_Z>3$ [2107.09684].

## 5. Construction methods, existence criteria, and decoding

Beyond the small-code classification, several complementary methods have been developed for constructing triorthogonal matrices. One early approach is the Bravyi–Haah linear-equation search: one introduces a binary variable $N_x$ for each column type $x\in\mathbb F_2^m$ and translates pairwise and triple-wise overlap conditions into sparse linear equations over $\mathbb F_2$. With additional constraints excluding the all-zero column and repeated column pairs, this search produced numerous examples, including a $49\times 13$ triorthogonal matrix whose code has distance $5$ and yields a $49\to 1$ distillation routine [1209.2426].

Haah and Hastings proposed a randomized row-by-row construction for generalized triorthogonal matrices. Each new row is chosen uniformly from the linear subspace defined by all previously imposed pairwise and triple-wise constraints together with the required row parity. They showed, by a first-moment argument and a version of the Lovász Local Lemma, that for $m\approx \theta\sqrt n$ with $\theta<\sqrt 2$ small, the algorithm succeeds with high probability, the code distance obeys $d=\Omega(\sqrt n/\log n)$, and the distillation efficiency satisfies $\gamma\to 1$ [1709.02832].

A more recent constructive route uses dual-distance constraints. For an even-weight generator matrix $H_X$, one lets $C$ be the classical code generated by $H_X$ and imposes the conditions $B_1=\cdots=B_{d-1}=0$ on the dual weight enumerator, with
\[
B_\ell=|C|^{-1}\sum_{j=0}^n A_j K_\ell(j;n),
\]
where $K_\ell$ are binary Krawtchouk polynomials. Combined with linear overlap constraints, this yields an integer linear programming formulation whose feasibility is equivalent to the existence of an even-weight triorthogonal $H_X$ of length $n$ and dual distance at least $d$. Using symmetry constraints, the method found nontrivial $[[n,1,3]]$ triorthogonal codes for odd $n\le 80$, including $n=39,43,45(TE),47(TE),49,51,\dots,79$, and many of these are not generated by classical triply-even codes. The same work evaluated decoding over the dephasing channel and compared bounded-distance decoding, belief propagation plus ordered-statistics post-processing, and a GRAND-based decoder adapted to the quantum setting, identifying the latter as a promising option [2605.24519].

An additional algebraic construction starts from binary self-dual codes. Given a self-dual code $C\le \mathbb F_2^n$ of dimension $k=n/2$, Shi et al. described an algorithm that grows a maximal triorthogonal subspace by repeatedly solving linear equations of the form $|x\wedge a\wedge b|=0$ for all distinct $a,b$ already chosen. If the resulting triorthogonal subspace has dimension $r$, then
\[
r\le k
\quad\text{and}\quad
r\ge \left\lceil\frac{\sqrt{8k+1}-1}{2}\right\rceil.
\]
The same work generalized shortening and extending to triorthogonal matrices and gave simple propagation rules such as concatenation and direct sum [2408.09685].

## 6. Generalizations, equivalence theory, and nonbinary variants

Triorthogonality has been extended in several directions. The most direct binary generalization is the generalized triorthogonal matrix of Haah and Hastings, in which the inhomogeneous cubic overlap conditions are arranged so that transversal $T$ implements a prescribed collection of logical $T$, controlled-$S$, and $CCZ$ gates. Their Reed–Muller construction uses the relations
\[
RM(r,m)\wedge RM(r,m)=RM(2r,m),\qquad
RM(r,m)^\perp = RM(m-r-1,m),
\]
and produces a generalized triorthogonal code with parameters
\[
[[2^m,\;3k_{CCZ},\;2^{m/3}]]
\]
when $r=m/3-1$. For $m=9$, this yields a $[[512,30,8]]$ code used to distill $10$ logical $CCZ$ states from $512$ noisy $T$ gates, with roughly $20.3$ $T$ gates per output $CCZ$. The same paper also reported punctured Reed–Muller triorthogonal codes with parameters $[[887,137,5]]$, $[[912,112,6]]$, and $[[937,87,7]]$ [1709.02832].

A separate line of work studies binary triorthogonal codes as objects in their own right, rather than solely as distillation gadgets. In the CSS-$T$ poset framework, a triorthogonal code $C$ is minimal if and only if $\dim C=1$ and all nonzero words have even weight, and maximal if and only if $(C^{\star 2})^\perp=C\cap C^\perp$. The same analysis characterizes which row-equivalent generators remain triorthogonal: if $G=[G_1;G_0]$ with odd rows in $G_1$ and even rows in $G_0$, then $MG$ is triorthogonal exactly when
\[
M=\begin{pmatrix}P & M_2\\ 0 & M_4\end{pmatrix},
\]
with $P$ a permutation matrix, $M_4$ invertible, and $M_2$ arbitrary. Consequently, any equivalent matrix that is also triorthogonal gives rise to a triorthogonal quantum code with the same parameters [2408.02916].

There is also a qutrit analogue. Over $\mathbb F_3$, a triorthogonal matrix $H$ is partitioned into $H_1$ and $H_0$ so that distinct rows are pairwise orthogonal modulo $3$, all triples of rows satisfy the ternary cubic orthogonality condition, every row of $H_0$ is self-orthogonal, and every row of $H_1$ is not self-orthogonal. From this structure one obtains a family of qutrit CSS codes with parameters $[[9m-k,k,2]]_3$ for $k\le 3m-2$. For the maximal-rate choice $k=3m-2$, the yield parameter is
\[
\gamma=\log_2\!\Bigl(2+\frac{6}{3m-2}\Bigr)\xrightarrow[m\to\infty]{}1.
\]
The case $m=3$ gives a $[[20,7,2]]_3$ code with yield parameter $1.51$, which was reported to outperform all known qubit triorthogonal codes of size less than a few hundred qubits [2403.06228].

Triorthogonal matrices therefore occupy a broad technical niche. At the binary level they are simultaneously a class of self-orthogonal classical generators, a source of CSS-$T$ codes, and a mechanism for transversal non-Clifford gates. At the level of contemporary research, they support exact small-parameter classification, randomized and ILP-based synthesis, decoding studies, extensions to $CS$ and $CCZ$, structural ties to self-dual and CSS-$T$ theories, and nonbinary generalizations relevant to qutrit magic-state distillation [2107.09684][2605.24519][2403.06228].

Source: https://www.emergentmind.com/topics/triorthogonal-matrices