Matroidal Mahalanobis Attention
Source paper: Nonnegative conorms, regular matroids, and the tropical Schottky problem arXiv:2608.28783 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Parameterize a learned token metric as a nonnegative sum of sparse integral rank-one projections with unimodular support, rather than learning an unconstrained dense positive-semidefinite matrix. Graph-incidence covectors give an immediately implementable support family, while nonnegative coefficients guarantee positive semidefiniteness by construction.
Formulas
Mathematical statement
The paper defines a unimodular family of integral covectors $(a_e)_{e\in E}\subseteq L^*$ by requiring that, after choosing an integral basis of the rank-$g$ lattice $L$, every maximal minor of the matrix with columns $a_e$ is $0$ or $\pm1$. A quadratic form is matroidal when it has the decomposition $Q=\sum_{e\in E}\ell_e a_e^2$, where $\ell_e\ge0$ and $a_e^2(x)=\langle a_e,x\rangle^2$. In coordinates, let $A=[a_1,\ldots,a_m]\in\mathbb{R}^{d\times m}$ and let $\ell=(\ell_1,\ldots,\ell_m)$ with nonnegative entries. Then $Q(x)=x^TA\operatorname{diag}(\ell)A^Tx$ and the matrix $M=A\operatorname{diag}(\ell)A^T$ is positive semidefinite because $x^TMx=\sum_e\ell_e(a_e^Tx)^2\ge0$. Add $\varepsilon I_d$, with $\varepsilon>0$, when strict positive definiteness is required. The paper's characterization says that nonnegative conorms are equivalent to matroidality and that positive-conorm support determines a regular matroid; the implementation uses the constructive decomposition directly. For a graph support, use oriented incidence covectors $a_{(u,v)}=e_u-e_v$ after deleting one redundant vertex coordinate. Incidence matrices are totally unimodular, so all maximal minors satisfy the required $0,\pm1$ condition.
Implementation notes
(1) Integration point: replace the usual dot-product attention score, or a dense Mahalanobis distance in a metric-learning head, with the quadratic distance defined above. Let $z_i\in\mathbb{R}^d$ be the projected representation of token $i$. Fix a sparse covector matrix $A\in\mathbb{R}^{d\times m}$, and learn only the coefficient vector $\theta\in\mathbb{R}^m$ with $\ell_e=\operatorname{softplus}(\theta_e)$; use a small fixed $\varepsilon$, such as $10^{-4}$. (2) Pseudocode: compute u = einsum('dm,bnd->bnm', A, z), so u[b,n,e] = a_e^T z[b,n]; compute w = softplus(theta); for every query-key pair compute delta = u[:, :, None, :] - u[:, None, :, :], dist = (delta**2 * w).sum(-1) + eps * ((z[:, :, None, :] - z[:, None, :, :])**2).sum(-1); set logits = -dist/(2*tau) and apply the attention softmax. This is exactly $x^TMx=\sum_e\ell_e(a_e^Tx)^2+\varepsilon\|x\|^2$ applied to pairwise differences. (3) Computed from the paper: coefficient nonnegativity, the rank-one PSD decomposition, and the unimodular support. Estimated empirically: $\tau$, $\varepsilon$, the number of support columns $m$, and whether coefficient pruning is beneficial. Initially restrict $A$ to graph-incidence columns, for which total unimodularity is guaranteed; optionally prune columns with $\ell_e<\delta$ and compare the resulting sparse model. (4) First experiment: train a small 2-layer, 8-head Transformer on character-level Penn Treebank or CIFAR-10 represented as patch tokens. Compare standard dot-product attention, a dense learned Mahalanobis metric, and this matroidal metric at matched hidden dimension and approximately matched parameter count. Sweep $m\in\{d,2d,4d\}$ and measure validation loss or accuracy, gradient-norm variance, attention-logit numerical failures, parameter count, and measured attention FLOPs. The hypothesis is that the structured metric is most useful in low-data or low-parameter settings: success means equal or better validation loss with fewer metric parameters, smoother training, and no loss of stability relative to the dense baseline.
Verification
This idea has not been verified yet.
Verification happens in two stages: Stage 1 — a mechanism check on a toy system confirms the claimed mathematical phenomenon reproduces; Stage 2 — a benchmark implements the idea on a real (small) neural network task and compares it against a tuned baseline over 8 paired seeds with a permutation test.
Artifacts
Artifacts unavailable.