Sparse Transport Attention Through Pivots

Attention layers decide how much each token listens to every other token. A recent line of work treats this decision as an optimal transport problem, where mass is moved from queries to keys at minimal cost. In that view every key is guaranteed some attention and no single key can swallow it all. LOTFormer makes this run in linear time by routing all mass through a small set of $r$ learned "pivot" points. It solves two small transport problems, queries to pivots and pivots to keys, and glues them together. Both subproblems use entropic regularization, a smoothing penalty that makes the problem easy to solve with Sinkhorn's algorithm (alternating row and column rescaling). The same penalty creates a familiar bind. If the smoothing is weak (small temperature $\varepsilon$), the plan is sharp, but the Gibbs kernel $\exp(-C/\varepsilon)$ underflows and the derivatives become badly conditioned. If the smoothing is strong, the plan stays stable but blurry, which is exactly the "token dilution" that hurts linear attention on tasks needing precise lookups.

We propose to replace the entropy penalty inside the pivot subproblems with a squared-norm penalty. Quadratic regularization produces transport plans with exact zeros: each query sends mass to only a handful of pivots. Its derivatives also stay well behaved at small regularization. Because each subproblem involves only $n$ tokens and $r \ll n$ pivots, the dual problem reduces to an $r$-dimensional smooth optimization. It can be solved by Newton's method and differentiated implicitly through an $r \times r$ linear system, at cost $O(nr + r^3)$. The result is a bidirectional attention layer with linear cost, balanced row and column marginals, and sparse routing. Its sharpness can be pushed further than the entropic version before training becomes unstable.

Core Claim

Our central claim is that entropic OT attention is limited not by what it can express but by the conditioning of its gradients at the sharpness levels that matter. We further claim that a quadratically regularized pivot coupling removes this limit without giving up linear complexity or balanced marginals.

The claim has a concrete, falsifiable form. Take the quadratically regularized subproblem between $n$ queries with uniform mass $a$ and $r$ pivots with learned mass $g$:

$$\min_{P \ge 0,\; P\mathbf{1}=a,\; P^\top\mathbf{1}=g} \langle C, P\rangle + \frac{\gamma}{2}\|P\|^2 .$$

Here $C_{ij}$ is the cost between query $i$ and pivot $j$, and $\gamma>0$ is the regularization strength. The optimal plan has the closed form $P_{ij} = [\alpha_i + \beta_j - C_{ij}]_+/\gamma$, where $\alpha$ and $\beta$ are the dual potentials (Lagrange multipliers for the row and column constraints) and $[\cdot]_+$ is the positive part. Given the $r$-vector $\beta$, each $\alpha_i$ is found by a sort-based projection over $r$ entries. The remaining semi-dual objective in $\beta$ is concave and piecewise quadratic, as in Smooth and Sparse Optimal Transport.

Its Hessian is $1/\gamma$ times a Laplacian-like matrix of the bipartite graph of active (nonzero) query–pivot pairs. This mirrors what Quadratically Regularized Optimal Transport on Graphs proves for flows on graphs. It follows that, for a fixed active set, the condition number of this Hessian does not depend on $\gamma$ at all: the $1/\gamma$ scales every eigenvalue equally. The one exact singular direction is the shift $\alpha+c,\ \beta-c$, which we remove by pinning one pivot potential.

The entropic analogue behaves differently. Robust First and Second-Order Differentiation for Regularized Optimal Transport shows that the derivative system degrades sharply as $\varepsilon \to 0$, with standard implicit differentiation failing in 97% of singular settings. The predicted gap in conditioning is the testable core of the proposal.

Research Program

We will build the layer in three parts. The forward pass solves the query–pivot and pivot–key subproblems by semi-dual Newton iterations on the $r$ pivot potentials. Each step costs $O(nr\log r)$ for the per-row projections plus $O(r^3)$ for the solve. The two sparse plans are then glued as $P = Q\,\mathrm{diag}(1/g)\,R^\top$, following Low-Rank Sinkhorn Factorization and LOTFormer, so the full coupling is never formed. The output is computed as $Q\,\mathrm{diag}(1/g)\,(R^\top V)$. When each row of $Q$ has $k$ nonzeros, the unpack step costs $O(nkd)$ rather than $O(nrd)$, where $d$ is the head dimension.

The backward pass uses implicit differentiation of the optimality conditions. Gradients with respect to queries, keys, pivot locations and pivot masses all flow through one $r \times r$ solve per subproblem. Nothing is unrolled.

The analysis part tracks four quantities across training for both regularizers:

  • the measured condition number of the $r\times r$ derivative system;
  • the variance of gradient norms;
  • the sharpness of the coupling, measured as mean row entropy;
  • pivot usage.

The column constraint guarantees that every pivot receives its mass $g_j$, so pivots cannot die even though the positive part has zero gradient on inactive entries. We will verify this empirically rather than assume it.

The scope is bidirectional (encoder) attention. Balanced marginals conflict with causal masking, a problem LOTFormer and ESPFormer both leave open, and we do not claim to solve it.

Baselines

The naive reference point is standard softmax attention in the same backbone. For DeiT-Tiny on ImageNet-1K, LOTFormer reports 72.2% top-1 for this softmax baseline. On Long Range Arena (LRA), Luna reports a 54.39 average for the vanilla Transformer.

The strongest existing method is LOTFormer itself: entropic, doubly stochastic, linear-time attention through learned pivots. It is the closest design to ours and the best linear model in the file. It reports a 62.90 LRA average, ahead of Mamba2 at 62.21 and DeltaNet at 61.19, and 74.8% ImageNet top-1 with a DeiT-Tiny backbone.

We will reimplement both LOTFormer and our layer in one codebase with identical $r$, backbone, data, epochs and optimizer. Each method gets the same hyperparameter search budget, spent on $\varepsilon$ for LOTFormer and on $\gamma$ for ours. Beating LOTFormer means one of two outcomes. The first is a higher LRA average, with the gain concentrated on ListOps and Retrieval where sharp routing should matter, together with no loss on ImageNet. The second is equal accuracy reached at a sharpness LOTFormer cannot train at.

Luna-256 (61.95 LRA) is the row-normalized pack-and-unpack analogue without balanced marginals. Performer (51.41 LRA, as reported in Luna) is the kernel linear-attention floor. Both are cited from their reported numbers and rerun where compute permits.

Three ablations isolate the key ingredient:

  • LOTFormer at small $\varepsilon$ with log-domain Sinkhorn (cheap here, since the problem is only $n\times r$) and unrolled gradients.
  • The same model with the truncated-SVD implicit differentiation of Li et al. This is the strongest available way to stabilize entropic gradients.
  • Our quadratic layer with the column constraint removed, which turns it into row-wise sparsemax over pivots. This tests whether balanced marginals, rather than sparsity alone, carry the benefit.

Why not just…?

Why not just lower $\varepsilon$ in LOTFormer and use log-domain Sinkhorn? This is the most serious threat. Because the subproblems are only $n \times r$, log-domain stabilization costs little, so underflow alone is not a convincing objection. Our argument rests on gradients rather than the forward pass. The prediction is that unrolled or implicit entropic gradients become high-variance and ill-conditioned before the coupling reaches the sharpness where accuracy peaks. The first ablation tests this directly. If small-$\varepsilon$ log-domain LOTFormer trains stably and matches our accuracy at matched row entropy, our central claim is false and we will report it as such.

Why not just fix the entropic gradients with truncated SVD? Robust First- and Second-Order Differentiation for Regularized Optimal Transport reports a 100% success rate and Hessian marginal errors 3–8 orders of magnitude better than standard methods. It is therefore a credible repair. However, truncation discards spectral directions, which biases gradients, and its cost and accuracy inside an attention layer trained over millions of steps are uncharacterized. We run it as the second ablation. If it closes the gap, the honest conclusion is that a stabilized backward pass, not the choice of regularizer, is what matters.

Why not just use top-$k$ or sparsemax routing to pivots, without any transport constraint? Hard or row-only sparse routing is simpler and also produces exact zeros. Nothing prevents it, however, from sending every query to the same few pivots. That is the overfocusing pathology that Sinkformers, ESPFormer and LOTFormer report correcting with balanced marginals. The row-only ablation measures pivot usage and accuracy directly. If it matches the full method, column balance is unnecessary and the simpler design wins.

Proposed Experiments

The first experiment is a mechanism check on a synthetic task whose ideal attention is a hard permutation: recovering a shuffled sequence of distinct tokens. We sweep $\gamma$ and $\varepsilon$ across matched ranges of row entropy and record:

  • the derivative-system condition number;
  • gradient-norm variance;
  • the fraction of five seeds that diverge;
  • task accuracy.

The prediction is that the quadratic condition number stays flat as $\gamma$ shrinks while the entropic one grows. Entropic accuracy should plateau or collapse at higher row entropy than the quadratic variant reaches.

The main evaluation uses all six LRA tasks from Long Range Arena, with Pathfinder-X reported as a stress test. All models are known to fail Pathfinder-X, so we make no promise there. We add ImageNet-1K with the DeiT-Tiny backbone. As a check on drop-in usability, we swap the layer into pretrained BERT-base on GLUE and compare against LOTFormer's reported recovery of 99.7% of original performance.

Efficiency is reported as wall-clock time and memory against LOTFormer at sequence lengths up to $2^{17}$. Both are unfused PyTorch, so the comparison is fair, and we expect the per-row sort over $r$ entries to cost some constant-factor overhead that sparse unpacking may or may not recover.

The decisive check is a single plot of accuracy against measured coupling sharpness for the entropic, TSVD-entropic and quadratic layers under equal tuning budgets. The proposal succeeds if the quadratic curve extends to sharper couplings while training stays stable, and if that extension yields a gain on ListOps or Retrieval that the TSVD-entropic variant does not match. It fails if the three curves coincide.