betaFeedback

WorksComputer Science

Topology Hub Optimal Transport: Eliminating Long Context Dilution at Flash Speed

Abstract

Long-context models use sparse or structured attention to avoid quadratic cost, yet retrieving a small set of relevant facts embedded among hundreds of thousands of distractors degrades as normalization mass disperses with length. Hub-and-spoke optimal transport (OT) replaces the dense L×LL \times L matrix with a linear-size graph over local windows and KK shared hubs balanced by Sinkhorn scaling. Building on block-wise tail refinement and fixed-support transport topology (arXiv:2605.08123, arXiv:2609.07954), we introduce Topology Hub Optimal Transport (THOT): (1) bounded-support capacity gating via simplex sparsemax (O(Llog⁡L)O(L\log L)) or sorting-free token-local thresholded ReLU (O(L)O(L)), driving excess distractor mass to zero; (2) a three-sweep 1+21+2 annealed row-closed Sinkhorn schedule that damps bipartite residuals; (3) an exact rank-(D+2R+1)(D+2R+1) One-Reference-Tile adjoint in batched split-factor Triton kernels (BF16 Tensor Cores, FP32 potentials); and (4) a chunked exclusive-prefix causal variant with verified zero future leakage. On NVIDIA L4, sparsemax THOT trained at L=128L=128 reaches 97.40% zero-shot recall of fixed bindings at L=262,144L=262{,}144 under pure task loss (α=0α=0) and 98.83% at α=0.05α=0.05 (matched by O(L)O(L) thresholded ReLU at α=0.05α=0.05, vs. 80.60% at α=0α=0), while softmax-gated hub OT drops to 3.52%. In bidirectional operator microbenchmarks, our kernel runs forward+VJP in 100.1 ms at H=8,D=64,L=262KH=8, D=64, L=262\mathrm{K} (2.2x faster with 4.0x smaller compiler temporaries than latent softmax) and 1.34 ms vs. 4.37 ms for cuDNN FlashAttention at L=4,096L=4{,}096; multi-layer LM runs use the unfused path. Zero-shot WikiText-103 multi-needle retrieval hits 100.00% (128/128 queries at L=65KL=65\mathrm{K}) vs. 0.78% for short-trained RoPE FlashAttention, and compact 4-layer WikiText-4K runs show modest causal and masked LM gains.

Introduction

Scaling attention to sequences of tens or hundreds of thousands of tokens poses two coupled bottlenecks. The computational bottleneck is the quadratic O(L2)O(L^2) cost of standard attention [34]: even with IO-aware tiling such as FlashAttention [8, 7, 27], dense forward-plus-backward passes at L=262,144L = 262{,}144 require multiple seconds on a single mid-range GPU. A second bottleneck is normalization dispersion: as irrelevant background tokens accumulate, standard softmax spreads strictly positive probability mass across distractors, degrading retrieval fidelity in long contexts [18, 14, 36, 35] and making zero-shot extrapolation beyond training lengths sensitive to positional encodings or sink caches [24, 22, 38].

A natural sparse alternative is a hub-and-spoke topology—combining a local sliding window of radius rr with KK shared global hubs [2, 41], latent bottleneck arrays [15], or global register slots [9]. Formulated as an entropic Optimal Transport (OT) problem [6, 23, 31, 25, 28], every token and hub receives an input-dependent routing capacity, and Sinkhorn matrix scaling allocates attention mass across O(L(r+K))O(L(r + K)) edges. Unlike unconstrained softmax attention, marginal capacity constraints prevent hubs from collapsing onto a single popular key and enable tokens to regulate their own routing budget—directly targeting the associative-recall fragility observed in sub-quadratic sequence models [1].

This work builds directly on Forde [11], who introduced block-wise differentiable Sinkhorn tail refinement, and Forde [12], who analyzed gradient propagation across fixed sparse transport supports. Scaling fixed-support hub OT to end-to-end training and quarter-million-token evaluation exposed four concrete engineering and modeling bottlenecks:

  1. Softmax capacity dilution (Θ(1/(1+αL))\Theta(1/(1 + \alpha L))). Even on an O(L)O(L) sparse topology, allocating token capacities with a global softmax assigns strictly positive excess mass to every distractor token. Under a bounded logit margin, cumulative background mass overwhelms the KK hubs as sequence length grows, dropping zero-shot associative recall from 98.31% (L=128L = 128) to 3.52% (L=262,144L = 262{,}144).

  1. Finite-step parity residuals under bipartite hub routing. Blocking hub-to-hub shortcuts (BHH=−20B_{HH} = -20) isolates two-hop routing through hubs [11, 12], but renders the active subgraph nearly bipartite. In finite Sinkhorn schedules, alternating row and column updates then leave 5%–6% row-marginal residuals unless six or more expensive sweeps are unrolled.

  1. Unrolled backward memory and tile-padding overhead. Naive reverse-mode automatic differentiation through finite Sinkhorn sweeps launches repeated width-DD sparse passes and incurs register padding waste, leaving unfused OT over 4×4\times slower than latent softmax attention at L=262KL = 262\mathrm{K}.

  1. Non-causality of full-sequence column scaling. Standard two-sided Sinkhorn column normalization couples future queries into earlier column potentials, violating autoregressive causality.

We address these four issues with Topology Hub Optimal Transport (THOT), focusing on sparse capacity allocation, exact finite-sweep differentiation, hardware-efficient bidirectional execution, and a strictly causal chunked variant:

  • Bounded-support capacity gating (§ 3.1). Replacing global softmax capacity allocation with simplex sparsemax [20, 5] or a sorting-free token-local thresholded ReLU gate [37] clamps excess distractor capacity to exact zero. Under pure task loss (α=0\alpha= 0), sparsemax THOT maintains 97.40% zero-shot recall of R=8R = 8 fixed bindings at L=262,144L = 262{,}144 (98.83% with α=0.05\alpha= 0.05); thresholded ReLU matches 98.83% at α=0.05\alpha= 0.05 in O(L)O(L) time while dropping to 80.60% at α=0\alpha= 0.

  • Swept topological annealing and row closure (§ 3.2). Starting from a marginal warm start [32] and local degree offset, one detached aperiodic sweep followed by two differentiated bipartite sweeps and exact row normalization eliminates row-marginal error in three total sweeps and provides a +1.04 to +1.44 percentage-point refinement (with tighter cross-seed spread at α=0\alpha= 0) over non-annealed row-closed bipartite OT. We also formalize a prior-preserving semi-relaxed variant (THOT-SR) via its exact variational objective.

  • Exact One-Reference-Tile adjoint and split-factor Triton kernels (§ 3.3, Appendix § 7). Exploiting diagonal rescaling across finite Sinkhorn iterates, we compress all score gradients across Sweeps 2–3 and row closure into a rank-(D+2R+1D + 2R + 1) modifier evaluated in two width-DD

sparse passes over the terminal plan (plus one pass for ∇V\nabla V and four 1D scalar passes), matching exact FP32 differentiation within 4.47×10−84.47 \times10^{-8}. Batched multi-head Triton kernels [33] with BF16 Tensor Cores and FP32 dual potentials reach 100.1 ms forward+VJP at H=8H = 8, D=64D = 64, L=262KL = 262\mathrm{K} (2.2× faster with 4.0× smaller compiler temporaries than latent softmax) and 1.34 ms vs. 4.37 ms for cuDNN FlashAttention at L=4,096L = 4{,}096 in operator microbenchmarks.

  • Strictly causal chunked transport and empirical evaluation (§ 3.4–§ 4). Combining chunk-local write OT, an exclusive prefix scan over past hub summaries, and an exclusive intra-chunk causal prefix log-sum-exp during read OT guarantees exact 0.0 future dependence (verified by perturbation tests and reverse-mode Jacobians). Causal THOT reaches 90.10% zero-shot recall at L=262KL = 262\mathrm{K} (with annealed gate warmup), bidirectional sparsemax THOT reaches 100.00% (128/128 queries) zero-shot multi-needle retrieval in WikiText-103 prose at L=65,536L = 65{,}536 (α=0\alpha= 0), and compact 4-layer WikiText-4K experiments show modest NLL improvements on both causal and masked language modeling.

Background: Failure Modes of Hub-and-Spoke OT

We first formalize the hub-and-spoke optimal transport attention layer and diagnose why naive formulations fail as distractor length grows or finite-sweep schedules are shortened.

Hub-and-Spoke Transport Formulation

Consider an input sequence of LL real tokens augmented with K≪LK \ll L shared global hub slots (N=L+KN = L + K nodes per attention head). Each real token i∈{1,…,L}i \in\{1, \ldots, L\} connects via an active sparse edge set Ω\Omega to: (i) a circular local window {j∈{1,…,L}:min⁡(∣i−j∣,L−∣i−j∣)≤r}\{j \in\{1, \ldots, L\} : \min(|i - j|, L - |i - j|) \le r\}, and (ii) all KK global hubs; each hub connects to all NN nodes (with hub-to-hub edges modulated by BHHB_{HH}). Hence ∣Ω∣=O(L(2r+1+K))|\Omega| = O(L(2r + 1 + K)) scales linearly in sequence length LL, reducing edge count from O(L2)O(L^2) to O(L)O(L).

Given query and key projections qi,kj∈RDq_i, k_j \in\mathbb{R}^{D}, score scale sscale=D−1/2s_{\mathrm{scale}} = D^{-1/2}, and a learned 2×22 \times2 node-type bias matrix BB indexed by whether (i,j)(i,j) is real-to-real (BRRB_{RR}), real-to-hub (BRHB_{RH}), hub-to-real (BHRB_{HR}), or hub-to-hub (BHHB_{HH}), the edge affinity score is

Sij=qiTkjD+Bτ(i),τ(j),(i,j)∈Ω.(1)S_{ij} = \frac{q_i^{\mathsf{T}} k_j}{\sqrt{D}} + B_{\tau(i),\tau(j)}, \qquad(i,j) \in\Omega. \tag*{(1)}

Given positive row marginals a∈R>0Na \in\mathbb{R}^{N}_{>0} (emitting budget per query or hub) and column marginals b∈R>0Nb \in\mathbb{R}^{N}_{>0} (absorbing budget per key or hub, satisfying ∑iai=∑jbj=T\sum_i a_i = \sum_j b_j = T in balanced mode), Sinkhorn scaling [29, 6, 17] iteratively updates log-space dual potentials u,v∈RNu, v \in\mathbb{R}^{N} defining the transport plan Pij=exp⁡(Sij+ui+vj)P_{ij} = \exp(S_{ij} + u_i + v_j) on Ω\Omega:

ui←ln⁡ai−log⁡∑j:(i,j)∈Ωexp⁡(Sij+vj).(2)u_i \leftarrow\ln a_i - \log\sum_{j:(i,j)\in\Omega} \exp(S_{ij} + v_j). \tag*{(2)}
vj←ln⁡bj−log⁡∑i:(i,j)∈Ωexp⁡(Sij+ui).(3)v_j \leftarrow\ln b_j - \log\sum_{i:(i,j)\in\Omega} \exp(S_{ij} + u_i). \tag*{(3)}

Once row-normalized so that ∑jPij=ai\sum_j P_{ij} = a_i, the row-stochastic attention weights are Wij=Pij/aiW_{ij} = P_{ij}/a_i, aggregating value vectors via Y=WV=diag⁡(a)−1(PV)Y = WV = \operatorname{diag}(a)^{-1}(PV). Note that a single bidirectional THOT layer executes one hop Y=WVY = WV over Ω\Omega, updating both token and hub states; consequently, two-hop Source →\to Hub →\to Query value propagation occurs across two or more stacked Transformer layers (whereas our causal architecture in § 3.4 performs an explicit Write-then-Read transfer inside every layer). Following Forde [11], we execute TbaseT_{\mathrm{base}} initial sweeps without tracking gradients and backpropagate exactly through a short refinement tail of TtailT_{\mathrm{tail}} sweeps.

Failure Mode 1: The 1/(1+αL)1/(1 + \alpha L) Capacity Dilution Law

Suppose a routing gate allocates a total excess capacity budget MM across real tokens on top of a uniform local baseline 1/L1/L, so that bj=1/L+bjexb_j = 1/L + b_j^{\mathrm{ex}}. Define the excess filler share as the fraction of excess source budget landing on irrelevant distractor positions:

Filler Share=∑j∈fillerbjex∑j=1Lbjex,bjex=max⁡(bj−1L,0).(4)\mathrm{Filler\ Share} = \frac{\sum_{j \in\mathrm{filler}} b_j^{\mathrm{ex}}}{\sum_{j=1}^{L} b_j^{\mathrm{ex}}}, \qquad b_j^{\mathrm{ex}} = \max\left(b_j - \frac{1}{L}, 0\right). \tag*{(4)}

When excess capacities are allocated via a global softmax, bjex=M⋅softmax⁡(g)jb_j^{\mathrm{ex}} = M \cdot\operatorname{softmax}(g)_j, suppose RR relevant source tokens exceed irrelevant background filler by a logit margin Δ\Delta. Because softmax assigns strictly positive weight ∝exp⁡(gfill)\propto\exp(g_{\mathrm{fill}}) to every distractor, if α=exp⁡(−Δ)>0\alpha= \exp(-\Delta) > 0 stays bounded away from zero as LL grows, the denominator expands as R+α(L−R)R + \alpha(L - R). Consequently, the signal fraction of excess routing capacity decays as

Signal Share(L)=RR+(L−R)e−Δ=Θ(11+αL),(5)\mathrm{Signal\ Share}(L) = \frac{R}{R + (L - R)e^{-\Delta}} = \Theta\left(\frac{1}{1 + \alpha L}\right), \tag*{(5)}

mirroring the softmax dispersion phenomenon analyzed for sharp size generalization by Veličković et al. [36] and Vasylenko et al. [35]. From (5), exact-zero sparsity is a sufficient solution whenever the learned margin Δ\Delta remains bounded across lengths; in principle, a logit gap Δ(L)\Delta(L) growing as Ω(ln⁡L)\Omega(\ln L) (for example via length-adaptive temperature [36]) could also maintain a nonzero signal share, making length-scaled softmax gating an informative control for future work.

Figure 1(a) confirms (5) empirically: under fixed-temperature softmax gating, Hub OT (Softmax Gate) achieves 98.31% accuracy at L=128L = 128 (99.2% excess source share) and 83.98% at L=8,192L = 8{,}192 (67.3% share), before plunging to 12.24% at L=131KL = 131\mathrm{K} and 3.52% at L=262,144L = 262{,}144 (6.6% signal share, 93.4% excess filler share). Non-OT global-softmax attention with the same structural bias prior (Support Softmax) degrades from 12.63% to 0.65%. Cross-attending into a fixed K=16K = 16 bottleneck (Latent Softmax, following Jaegle et al. [15]) resists query-side dilution better, yet key-side softmax normalization still dilutes excess source share from 96.2% down to 1.4%, pulling accuracy down from 87.24% to 76.30%.

Figure 1. Capacity dilution vs. THOT from L=128L = 128 to L=262,144L = 262{,}144. (a) On synthetic associative recall (R=8R = 8 fixed bindings, trained at L=128L = 128), softmax-gated Hub OT (Hub OT (Softmax Gate), dashed crimson) collapses from 98.31% to 3.52% at L=262L = 262K as distractors absorb 93.4% of excess source capacity. Sparsemax gating with our 1+21 + 2 annealed row-closed schedule (THOT) holds 98.83% with light gate supervision (α=0.05\alpha= 0.05) and 97.40% under pure cross-entropy training (α=0\alpha= 0). (b) On zero-shot multi-needle retrieval embedded in WikiText-103 prose (pure cross-entropy, trained at L=512L = 512), the short-trained RoPE FlashAttention baseline drops from 99.22% to 0.78% beyond its training window, while sparsemax THOT reaches 100.00% (128/128 queries, 0.0514 NLL) at L=65,536L = 65{,}536.

Failure Mode 2: Slow Contraction and Parity Residuals Under Bipartite Routing

Once sparse gating eliminates excess filler capacity, a finite-iteration optimization issue emerges inside the Sinkhorn solver. Prior hub routing [11] sets a large negative hub-to-hub penalty (BHH=−20B_{HH} = -20) so queries route through hubs to source tokens rather than circulating mass among hubs. With distractors reduced to their 1/L1/L floor and BHHB_{HH} blocked, however, the active routing mass concentrates on a nearly bipartite subgraph between real tokens (RR) and hubs (HH).

To quantify class-level mixing empirically, let F∈R2×2F \in\mathbb{R}^{2 \times2} denote the aggregate plan mass between the two node classes, Fc,c′=∑i∈c,j∈c′PijF_{c,c'} = \sum_{i \in c, j \in c'} P_{ij} for c,c′∈{R,H}c,c' \in\{R, H\}, and let Qrow=diag⁡(F1)−1FQ_{\mathrm{row}} = \operatorname{diag}(F\mathbf{1})^{-1}F and Qcol=diag⁡(FT1)−1FTQ_{\mathrm{col}} = \operatorname{diag}(F^{\mathsf{T}}\mathbf{1})^{-1}F^{\mathsf{T}} be the corresponding 1-hop row- and column-normalized class transition matrices. Note that QrowQ_{\mathrm{row}} is distinct from the full-cycle Sinkhorn fixed-point Jacobian on column potentials, J=diag⁡(b)−1PTdiag⁡(a)−1PJ = \operatorname{diag}(b)^{-1}P^{\mathsf{T}}\operatorname{diag}(a)^{-1}P [17]: JJ is diagonally similar to a positive-semidefinite Gram matrix and therefore has nonnegative eigenvalues, with 2×22 \times2 class quotient Msink=Qrowdiag⁡(γb,1)QcolM_{\mathrm{sink}} = Q_{\mathrm{row}}\operatorname{diag}(\gamma_b,1)Q_{\mathrm{col}}. However, when QrowQ_{\mathrm{row}} is near-bipartite, its subdominant eigenvalue λ2(Qrow)=tr⁡(Qrow)−1\lambda_2(Q_{\mathrm{row}}) = \operatorname{tr}(Q_{\mathrm{row}}) - 1 lies close to −1-1, which both produces alternating half-step parity imbalance between the RR and HH partitions and drives the nonnegative two-step quotient eigenvalue of MsinkM_{\mathrm{sink}} toward λ2(Qrow)2≈1\lambda_2(Q_{\mathrm{row}})^2 \approx1 (slow contraction).

On our L=262,144L = 262{,}144 diagnostic (Table 1), a standard bipartite schedule retains λ2(Qrow)=−0.9924\lambda_2(Q_{\mathrm{row}}) = -0.9924 after three sweeps, leaving 5.53% row total-variation (TV) error and only 89.4% query-to-hub flow share. Stopping early at 3 warm-started sweeps without row closure reaches only 70.57% recall at L=262KL = 262\mathrm{K} unless extended to 6 unrolled sweeps (96.48%). Meanwhile, replacing explicit tail differentiation with an uncentered implicit-gradient solver (Uncentered Implicit-VJP OT) fails to train (0.91% at 262K).

Schedules1s_1 TV (λ2\lambda_2)s3s_3 TV (Row / Col, λ2\lambda_2)s6s_6 TVs3s_3 Flow (Q→HQ \to H / H→SH \to S)
Standard Bipartite OT0.0323 (−0.9532-0.9532)0.0276 (0.0553 / 0.0000, −0.9924-0.9924)0.026389.4% / 100.0%
Bipartite OT (3-sweep)0.0263 (−0.9866-0.9866)0.0253 (0.0506 / 0.0000, −0.9827-0.9827)0.023190.2% / 100.0%
Bipartite OT (3-sweep, RC)0.0262 (−0.9879-0.9879)0.0250 (0.0000 / 0.0499, −0.9831-0.9831)0.0227100.0% / 90.3%
Aperiodic OT (3-sweep, RC)0.0760 (−0.7451-0.7451)0.0396 (0.0000 / 0.0792, −0.8596-0.8596)0.0238100.0% / 84.0%
THOT (1+2, Row-Closed)0.0760 (−0.7451-0.7451)0.0209 (0.0000 / 0.0419, −0.9680-0.9680)0.0185100.0% / 91.7%
THOT-SR (γb=0.92\gamma_b = 0.92)0.0760 (−0.7451-0.7451)0.0201 (0.0000 / 0.0402, −0.9389-0.9389)0.0102100.0% / 91.5%

Table 1. Table 1: Class-quotient diagnostic and marginal residual audit at L=262,144L = 262{,}144. Here λ2=tr⁡(Qrow)−1\lambda_2 = \operatorname{tr}(Q_{\mathrm{row}})-1 is the subdominant eigenvalue of the 2×22 \times2 1-hop Real/Hub class transition matrix (distinct from the PSD two-step Sinkhorn Jacobian), and TV error averages half the L1L_1 row and column deviations from (a,b)(a,b) at sweep sks_k. THOT’s detached aperiodic Sweep 1 yields λ2=−0.7451\lambda_2 = -0.7451, exact row stochasticity (row TV = 0.0000, 100.0% Q→HQ \to H flow), and the lowest 3-sweep residual among balanced schedules.

Topology Hub Optimal Transport

Topology Hub Optimal Transport (THOT) addresses capacity dilution, finite-step bipartite residuals, backward-pass overhead, and autoregressive causality through four components. Algorithm 1 summarizes the bidirectional forward pass and adjoint, Algorithm 2 specifies the strictly causal chunked variant, and Table 2 keeps all evaluated THOT variants explicitly separated.

VariantGate CostCausalityGate Supervision (α\alpha)L=262KL = 262\mathrm{K} RecallPrimary Trade-off
THOT (1+2, Sparsemax)O(Llog⁡L)O(L \log L)Bidirectionalα=0\alpha= 0 / α=0.05\alpha= 0.0597.40% / 98.83%Strongest α=0\alpha= 0 recall; requires global sort
THOT (1+2, ReLU-Thresh)O(L)O(L)Bidirectionalα=0\alpha= 0 / α=0.05\alpha= 0.0580.60% / 98.83%Sorting-free; needs light α\alpha for >98%> 98\%
THOT-SR (γb=0.92\gamma_b = 0.92)O(Llog⁡L)O(L \log L)Bidirectionalα=0\alpha= 0 / α=0.05\alpha= 0.0595.57% / 97.40%Lowest 6-sweep TV & best R=32R = 32 overload
Causal THOT (Alg. 2)O(L)O(L) (O(1)O(1)/tok)Strictly causalAnnealed 1→01 \to0 (256 steps)90.10%Exact 0.0 future leak; unfused chunk path

Table 2. Table 2: Summary of evaluated THOT configurations. No single configuration simultaneously attains 97.40% pure-α=0\alpha= 0 recall, sorting-free O(L)O(L) gating, and causality; each row reports the exact observed trade-off at L=262,144L = 262{,}144.

Bounded-Support Capacity Gating: Sparsemax and O(L)O(L) Thresholded ReLU

To prevent excess capacity from leaking onto distractors under a bounded score margin, we allocate excess budgets aex,bexa^{\mathrm{ex}}, b^{\mathrm{ex}} with compact support on top of the uniform 1/L1/L local baseline:

Algorithm 1: Bidirectional THOT — Forward Pass and Exact One-Reference-Tile Adjoint

Input: (Q,K,V)∈RN×D(Q, K, V) \in\mathbb{R}^{N \times D} (N=L+KN = L + K), node-type biases B∈R2×2B \in\mathbb{R}^{2 \times2}, local radius rr, marginals (a,b)∈R>0N(a,b) \in\mathbb{R}_{>0}^{N} from (6) or (7).

  1. Warm start & degree prior: Set v0←ln⁡bv_0 \leftarrow\ln b and BRR←BRR+ln⁡(L/min⁡(L,2r+1))B_{RR} \leftarrow B_{RR} + \ln(L/\min(L, 2r+1)).

  2. Detached aperiodic Sweep 1: With open hub-to-hub coupling BHHB_{HH} (stop-gradient), run one Sinkhorn cycle (2)–(3), center u1u_1 across active rows (u1←uraw(1)−uˉ(1)u_1 \leftarrow u_{\mathrm{raw}}^{(1)}-\bar{u}^{(1)}, v1←vraw(1)+uˉ(1)v_1 \leftarrow v_{\mathrm{raw}}^{(1)}+\bar{u}^{(1)}), and detach v1←detach⁡(v1)v_1 \leftarrow\operatorname{detach}(v_1).

  3. Differentiable bipartite Sweeps 2–3: Clamp BHH←−20B_{HH} \leftarrow-20 and run two centered Sinkhorn cycles starting from v1v_1, producing raw row potentials (uraw(2),uraw(3))(u_{\mathrm{raw}}^{(2)},u_{\mathrm{raw}}^{(3)}) and centered pairs (u2,v2),(u3,v3)(u_2,v_2),(u_3,v_3) (with optional prior-preserving semi-relaxed exponent γb=0.92\gamma_b=0.92 on real columns of Sweep 3 for THOT-SR).

  4. Exact row closure & row-stochastic read: Compute uout,i=ln⁡ai−LSE⁡j:(i,j)∈Ω(Sij+v3,j)u_{\mathrm{out},i}=\ln a_i-\operatorname{LSE}_{j:(i,j)\in\Omega}(S_{ij}+v_{3,j}), terminal plan Pijout=exp⁡(Sij+uout,i+v3,j)P_{ij}^{\mathrm{out}}=\exp(S_{ij}+u_{\mathrm{out},i}+v_{3,j}) (row sums aia_i), unnormalized aggregate Z=PoutVZ=P^{\mathrm{out}}V, and row-stochastic attention output Wij=Pijout/aiW_{ij}=P_{ij}^{\mathrm{out}}/a_i, Y=WV=diag⁡(a)−1ZY=WV=\operatorname{diag}(a)^{-1}Z. Cache (Z,v1,uraw(2),u2,v2,uraw(3),u3,v3,uout)(Z,v_1,u_{\mathrm{raw}}^{(2)},u_2,v_2,u_{\mathrm{raw}}^{(3)},u_3,v_3,u_{\mathrm{out}}) for backward.

  5. Exact One-Reference-Tile Adjoint (backward; full recurrence in Appendix A): Given Yˉ\bar{Y}, set Zˉi=Yˉi/ai\bar{Z}_i=\bar{Y}_i/a_i (adding quotient term −YˉiTYi/ai-\bar{Y}_i^{\mathsf{T}}Y_i/a_i to aˉi\bar{a}_i) and compute ∇V=(Pout)TZˉ\nabla V=(P^{\mathrm{out}})^{\mathsf{T}}\bar{Z} in one width-DD transposed pass. Propagate terminal dual sensitivities through row closure and Sweeps 3–2 via four lightweight 1D scalar sparse matvecs to form the 2R+1=52R+1=5 scalar factor columns (L(s),R(s))∈RN×5(L^{(s)},R^{(s)})\in\mathbb{R}^{N\times5} using diagonal rescaling relative to PoutP^{\mathrm{out}}. Finally, execute two width-DD split-factor sparse passes over the single reference plan PoutP^{\mathrm{out}}: one row-major pass for (∇Q,∇B)(\nabla Q,\nabla B) and one transposed pass for ∇K\nabla K.

Simplex sparsemax gate (O(Llog⁡L)O(L\log L)). Given scalar routing logits srec,ssrc∈RLs_{\mathrm{rec}},s_{\mathrm{src}}\in\mathbb{R}^{L} produced by a lightweight token-wise MLP, we replace softmax with Euclidean simplex projection sparsemax [20, 5]:

ai=1L+M⋅sparsemax⁡(srec)i,bj=1L+M⋅sparsemax⁡(ssrc)j,(6)a_i=\frac{1}{L}+M\cdot\operatorname{sparsemax}(s_{\mathrm{rec}})_i,\qquad b_j=\frac{1}{L}+M\cdot\operatorname{sparsemax}(s_{\mathrm{src}})_j, \tag*{(6)}

with total excess mass M=8.0M=8.0 distributed across real tokens and matched across the KK hubs (ahhub=bhhub=M/Ka_h^{\mathrm{hub}}=b_h^{\mathrm{hub}}=M/K for h=1,…,Kh=1,\ldots,K; total sequence mass 1+M1+M on real tokens plus MM on hubs). Because sparsemax maps low logits below its data-dependent threshold τ(s)\tau(s) to exact zero, excess filler share (4) drops to identically 0.00% across L=128…262,144L=128\ldots262{,}144 while retaining the 1/L1/L baseline on every token for local-window connectivity.

Token-local thresholded ReLU gate (O(L)O(L), sorting-free). Global sparsemax requires sorting across all LL tokens, which costs O(Llog⁡L)O(L\log L) and couples future tokens through τ(s)\tau(s) in causal models. Inspired by ReLU attention [37], learned scalar thresholds θrec,θsrc∈R\theta_{\mathrm{rec}},\theta_{\mathrm{src}}\in\mathbb{R} (initialized at −0.25-0.25) yield a sorting-free O(L)O(L) gate:

ai=1L+M⋅ReLU⁡(srec,i−θrec)∑m=1LReLU⁡(srec,m−θrec)+ϵ,(7)a_i=\frac{1}{L}+M\cdot\frac{\operatorname{ReLU}(s_{\mathrm{rec},i}-\theta_{\mathrm{rec}})}{\sum_{m=1}^{L}\operatorname{ReLU}(s_{\mathrm{rec},m}-\theta_{\mathrm{rec}})+\epsilon}, \tag*{(7)}

and symmetrically for bjb_j, or purely token-local unnormalized ai=1/L+c⋅ReLU⁡(srec,i−θrec)a_i=1/L+c\cdot\operatorname{ReLU}(s_{\mathrm{rec},i}-\theta_{\mathrm{rec}}) in streaming causal mode. Whenever distractor logits stay below θ\theta, excess filler share (4) is identically zero without cross-token sorting.

Swept Topological Annealing: The 1+2 Row-Closed Schedule

To keep total sweep depth at 3 while retaining clean bipartite routing and exact row normalization, we use an empirically effective 1+21+2 annealed row-closed schedule:

  1. Marginal warm start and degree prior. We initialize column potentials at the target log-marginals v0=ln⁡bv_0 = \ln b [32] and add a structural degree prior ln⁡(L/d)\ln(L/d) to real-to-real edges BRRB_{RR} (where d=min⁡(L,2r+1)d = \min(L, 2r + 1)) so local neighborhoods remain balanced against hubs as LL scales.

  1. Sweep 1 (detached aperiodic warm-start). Keeping hub-to-hub affinity BHHB_{HH} open rather than clamped to −20-20, we execute one stop-gradient Sinkhorn sweep and center row potentials across active tokens. Opening BHHB_{HH} moves the 1-hop class eigenvalue λ2(Qrow)\lambda_2(Q_{\mathrm{row}}) from −0.99-0.99 to −0.7451-0.7451 on Sweep 1 at L=262,144L = 262{,}144 (Table 1), providing a well-equilibrated initialization before bipartite refinement.

  1. Sweeps 2–3 (differentiated bipartite refinement). Clamping BHH←−20B_{HH} \leftarrow-20 suppresses hub-to-hub shortcuts across two differentiable Sinkhorn cycles.

  1. Exact row closure and normalization. Column updates leave 4%–5% row-marginal error at finite sweep count. Performing one final row log-normalization uout,i=ln⁡ai−LSE⁡j(Sij+v3,j)u_{\mathrm{out},i} = \ln a_i - \operatorname{LSE}_{j}(S_{ij} + v_{3,j}) and dividing PVoutP^{\mathrm{out}}_V by aia_i guarantees exact row stochasticity (row TV = 0.0000) and 100.0% Query →\to Hub mass utilization.

Prior-preserving semi-relaxed annealing (THOT-SR). When many active bindings compete for fewer hubs (R>KR > K), relaxing column constraints on real tokens reduces marginal residuals. Standard KL-unbalanced Sinkhorn with unweighted reference kernel exp⁡(Sij)\exp(S_{ij}) [4] applies the relaxation exponent γb=ρb/(1+ρb)\gamma_b = \rho_b/(1 + \rho_b) to the entire dual update, vj=γb(ln⁡bj−LSE⁡i(Sij+ui))v_j = \gamma_b(\ln b_j - \operatorname{LSE}_i(S_{ij} + u_i)), which scales down the learned log-capacity prior ln⁡bj\ln b_j. To preserve the full learned capacity prior bjb_j while relaxing column matching, we instead minimize the prior-preserving semi-relaxed objective using reference measure Kij=bjexp⁡(Sij)K_{ij} = b_j\exp(S_{ij}):

min⁡P1=a,  P≥0KL⁡(P∥exp⁡(S)diag⁡(b))+ρbKL⁡(PT1∥b).(8)\min_{P_1=a,\;P\ge0} \operatorname{KL}(P \mathbin{\|} \exp(S)\operatorname{diag}(b)) + \rho_b \operatorname{KL}(P^{\mathsf T}\mathbf{1} \mathbin{\|} b). \tag*{(8)}

First-order stationarity ln⁡Pij=Sij+ln⁡bj+ui−ρbln⁡(b^j/bj)\ln P_{ij} = S_{ij} + \ln b_j + u_i - \rho_b \ln(\hat b_j/b_j) with vj:=ln⁡bj−ρbln⁡(b^j/bj)v_j := \ln b_j - \rho_b \ln(\hat b_j/b_j) and ln⁡b^j=vj+LSE⁡i(Sij+ui)\ln\hat b_j = v_j + \operatorname{LSE}_i(S_{ij} + u_i) yields (1+ρb)vj=(1+ρb)ln⁡bj−ρbLSE⁡i(Sij+ui)(1 + \rho_b)v_j = (1 + \rho_b)\ln b_j - \rho_b\operatorname{LSE}_i(S_{ij} + u_i), hence the exact fixed-point update

vj=ln⁡bj−γbLSE⁡i:(i,j)∈Ω(Sij+ui),γb=ρb1+ρb∈(0,1],(9)v_j = \ln b_j - \gamma_b\operatorname{LSE}_{i:(i,j)\in\Omega}(S_{ij} + u_i), \qquad\gamma_b = \frac{\rho_b}{1 + \rho_b} \in(0, 1], \tag*{(9)}

applied on real token columns (keeping γb=1\gamma_b = 1 on hubs). Applying standard unweighted semi-relaxed updates naively from Sweep 1 (Naive Semi-Relaxed OT, γb=0.85\gamma_b = 0.85) collapses under pure cross-entropy training (α=0\alpha= 0, 0.13% accuracy; §4.1). Preceding prior-preserving relaxation with two balanced sweeps (THOT-SR, γb=0.92\gamma_b = 0.92) preserves α=0\alpha= 0 stability (95.57% at L=262KL = 262\mathrm{K}) while cutting six-sweep marginal TV error from 0.0185 to 0.0102 (Table 1). Because the naive (γb=0.85\gamma_b = 0.85) vs. annealed (γb=0.92\gamma_b = 0.92) comparison changes both the schedule and γb\gamma_b, we also evaluate an intermediate annealed γb=0.88\gamma_b = 0.88 configuration in Table 4, which still reaches 88.54% at α=0\alpha= 0 (97.53% at α=0.05\alpha= 0.05).

Variantα\alphaL=128L = 128 / 8K / 262KColl. 8K (C0/16/32/64)Cap. 512 (R8/16/32)
THOT (1+2, ReLU-Thresh, O(L)O(L))0.0599.09/98.96/98.8398.18/40.10/20.83/8.9898.05/80.66/39.81
THOT (1+2, ReLU-Unnorm, O(L)O(L))0.0597.92/96.88/94.7996.74/42.58/18.62/7.5597.66/78.32/40.20
THOT-SR (γb=0.92\gamma_b = 0.92, Sparsemax)0.0597.79/97.53/97.4098.57/42.06/23.57/11.3397.53/78.84/38.90
THOT-SR (γb=0.88\gamma_b = 0.88, Sparsemax)0.0597.66/97.66/97.5396.88/45.05/23.83/10.6897.53/77.73/39.06
THOT (4-Head, dh=8d_h = 8, Sparsemax)0.0596.74/96.74/95.9695.57/38.93/18.49/6.5195.31/73.63/34.31
THOT (1+2, ReLU-Thresh, O(L)O(L))0.0097.92/93.49/80.6093.62/35.16/18.10/7.0396.74/77.67/37.57
THOT-SR (γb=0.92\gamma_b = 0.92, Sparsemax)0.0098.44/97.01/95.5795.70/40.23/22.53/10.0397.27/76.89/39.91
THOT-SR (γb=0.88\gamma_b = 0.88, Sparsemax)0.0091.93/89.19/88.5490.23/36.20/20.18/9.2491.28/72.14/36.52
THOT (4-Head, dh=8d_h = 8, Sparsemax)0.0097.01/95.44/94.1495.05/36.98/15.76/6.7796.09/72.98/34.67
Control: Naive Semi-Relaxed OT (γb=0.85\gamma_b = 0.85)0.000.13/0.13/0.130.65/0.65/0.65/0.650.26/0.33/0.33
Control: Uncentered Implicit-VJP OT0.050.65/0.52/0.91——

Table 4. Gate complexity, semi-relaxed annealing, multi-head scaling, and negative controls across 3 seeds (768 queries per condition). Naive semi-relaxed OT and uncentered implicit differentiation fail during training, whereas 2-stage balanced-to-semirelaxed annealing (THOT-SR) and O(L)O(L) thresholded ReLU (with α=0.05\alpha= 0.05) sustain high accuracy at L=262L = 262K.

Hardware-Efficient Execution: Exact One-Reference-Tile Adjoint and Split-Factor Kernels

Naive unrolled reverse-mode differentiation through R=2R = 2 Sinkhorn sweeps plus terminal row closure launches 2+4R+2=122 + 4R + 2 = 12 width-DD score-gradient sparse passes (plus value and vector passes), taking 42.17 ms forward+VJP and 412.1 MiB static XLA compiler temporary storage even for a single D=32D = 32, L=262KL = 262\mathrm{K} head. We accelerate bidirectional THOT with two systems optimizations tailored for IO-aware Triton execution [33, 40]:

Exact One-Reference-Tile Adjoint. Because every intermediate plan P(t)=exp⁡(S+ut+vtT)P^{(t)} = \exp(S + u_t + v_t^{\mathsf T}) during Sweeps 2–3 acts on the same sparse support Ω\Omega and shares the same edge scores SS, each intermediate plan is an exact rank-1 diagonal rescaling of the terminal plan PoutP^{\mathrm{out}}: Pij(t)=Pijoutexp⁡(ut,i−uout,i)exp⁡(vt,j−v3,j)P_{ij}^{(t)} = P_{ij}^{\mathrm{out}} \exp(u_{t,i} - u_{\mathrm{out},i}) \exp(v_{t,j} - v_{3,j}). By caching the forward tail potentials (v1,uraw(2),u2,v2,uraw(3),u3,v3,uout)(v_1, u_{\mathrm{raw}}^{(2)}, u_2, v_2, u_{\mathrm{raw}}^{(3)}, u_3, v_3, u_{\mathrm{out}})—avoiding all five recomputation log-sum-exp launches—the exact reverse recurrence over Sweeps 3–2 and terminal row closure computes all marginal gradients (∇a,∇b)(\nabla_a, \nabla_b) and constructs 2R+1=52R + 1 = 5 scalar factor columns (L(s),R(s))∈RN×5(L^{(s)}, R^{(s)}) \in\mathbb{R}^{N \times5} using four lightweight 1D scalar sparse matvecs (no width-DD payloads). Combining these with the width-DD terminal factors (Zˉ,V)(\bar{Z}, V) yields the exact rank-(D+2R+1)(D + 2R + 1) score adjoint (derived in full in Appendix § 7):

Sˉij=Pijout(ZˉiTVj+∑m=12R+1Li,m(s)Rj,m(s)).(10)\bar{S}_{ij} = P_{ij}^{\mathrm{out}}\left(\bar{Z}_i^{\mathsf T}V_j + \sum_{m=1}^{2R+1} L_{i,m}^{(s)}R_{j,m}^{(s)}\right). \tag*{(10)}

All parameter score gradients (∇Q,∇K,∇B)(\nabla_Q, \nabla_K, \nabla_B) then execute in two width-DD sparse passes over the single reference plan PoutP^{\mathrm{out}} (one row-major pass for ∇Q\nabla_Q and ∇B\nabla_B, one transposed pass for ∇K\nabla_K), alongside one width-DD transposed pass for ∇V\nabla_V. On a single D=32D = 32, L=262KL = 262\mathrm{K} head, this alone cuts forward+VJP latency by 1.58× (42.17 → 26.64 ms) and shrinks static compiler temporaries by 2.86× (412.1 → 144.0 MiB).

Split-Factor Multi-Head Triton Tiling with BF16 Tensor Cores. We further remove four multi-head GPU bottlenecks in our custom Triton kernels:

  1. Split feature and scalar-factor accumulators: Concatenating the width-DD factors (Zˉ,V)(\bar{Z}, V) and width-(2R+1)(2R + 1) scalar factors (L(s),R(s))(L^{(s)}, R^{(s)}) into a single tile forces power-of-two padding up to width 128 at D=64D = 64. Keeping them as two separate SRAM dot products—width DD and width 2R+1=52R + 1 = 5 (padded to 16)—halves register footprint.

  1. Native head-batch grid scheduling: Dispatching across heads and batch items directly in the GPU thread-block grid eliminates per-head vectorization wrappers and removes padding/concatenation HBM copies on every half-sweep via predicated register masking.

  1. Dedicated 1D scalar matvecs and fused bias gradients: The four reverse-recurrence scalar passes skip vector payload tiling altogether, and the 2×22 \times2 node-type bias gradient ∇B\nabla B accumulates directly in registers during the row-major ∇Q\nabla_Q pass (with ∇BHH=0\nabla B_{HH} = 0 on the bipartite tail).

Algorithm 2: Strictly Causal Chunked THOT (Single Attention Head)

Input: Token tensors (Q,K,V)∈RL×D(Q,K,V) \in\mathbb{R}^{L \times D} (optional position-invariant write keys KwK^{\mathrm{w}}), token-local capacities (a,b)∈R>0L(a,b) \in\mathbb{R}_{>0}^{L}, hub slots (Q0hub,K0hub,V0hub)∈RK×D(Q^{\mathrm{hub}}_0,K^{\mathrm{hub}}_0,V^{\mathrm{hub}}_0) \in\mathbb{R}^{K \times D}, bias B∈R2×2B \in\mathbb{R}^{2 \times2}, chunk size C=32C = 32, local radius rr. Partition sequence into Nc=⌈L/C⌉N_c = \lceil L/C \rceil chunks.

1. Chunk-local Write OT (KK hubs ←C\leftarrow C tokens per chunk cc): With chunk score matrix Scw=scale⁡Q0hub(Kcw)⊤+BHRS_c^{\mathrm{w}} = \operatorname{scale}Q^{\mathrm{hub}}_0(K_c^{\mathrm{w}})^\top+ B_{HR} and hub capacity cap⁡κc=max⁡(1K∑j∈cbc,j,max⁡j∈cbc,j)\operatorname{cap}\kappa_c = \max(\frac{1}{K}\sum_{j \in c}b_{c,j},\max_{j \in c}b_{c,j}), run 1 detached base sweep at scale sscale/εfs_{\mathrm{scale}}/\varepsilon_f (εf=1.5\varepsilon_f = 1.5) followed by 2 differentiated tail sweeps and final column closure:

uc,kw←−γwReLU⁡(LSE⁡j∈c(Sc,k,jw+vc,jw)−ln⁡κc),vc,jw←ln⁡bc,j−LSE⁡k=1K(Sc,k,jw+uc,kw).u_{c,k}^{\mathrm{w}} \leftarrow-\gamma_{\mathrm{w}}\operatorname{ReLU}\left(\operatorname{LSE}_{j \in c}(S_{c,k,j}^{\mathrm{w}}+v_{c,j}^{\mathrm{w}})-\ln\kappa_c\right),\qquad v_{c,j}^{\mathrm{w}}\leftarrow\ln b_{c,j}-\operatorname{LSE}_{k=1}^{K}(S_{c,k,j}^{\mathrm{w}}+u_{c,k}^{\mathrm{w}}).

with γw=0.70\gamma_{\mathrm{w}} = 0.70, yielding Pcwrite∈RK×CP_c^{\mathrm{write}} \in\mathbb{R}^{K \times C} satisfying ∑kPc,k,jwrite=bc,j\sum_k P_{c,k,j}^{\mathrm{write}} = b_{c,j}. Compute chunk moments Wc(V)=PcwriteVcW_c^{(V)} = P_c^{\mathrm{write}}V_c, Wc(K)=PcwriteKcwW_c^{(K)} = P_c^{\mathrm{write}}K_c^{\mathrm{w}}, and hub mass zc=Pcwrite1Cz_c = P_c^{\mathrm{write}}\mathbf{1}_C.

2. Exclusive prefix accumulation across past chunks (c′<cc' < c): Compute exclusive prefix sums (M<c(V),M<c(K),z<c)=∑c′<c(Wc′(V),Wc′(K),zc′)(M_{<c}^{(V)},M_{<c}^{(K)},z_{<c}) = \sum_{c'<c}(W_{c'}^{(V)},W_{c'}^{(K)},z_{c'}) (zero for c=0c = 0), and form normalized past hub summaries with prior weight m0=0.05m_0 = 0.05 and residual key blend β=0.80\beta= 0.80:

V<chub=m0V0hub+M<c(V)m0+z<c,K<chub=(1−β)K0hub+βm0K0hub+M<c(K)m0+z<c.V_{<c}^{\mathrm{hub}}=\frac{m_0V_0^{\mathrm{hub}}+M_{<c}^{(V)}}{m_0+z_{<c}},\qquad K_{<c}^{\mathrm{hub}}=(1-\beta)K_0^{\mathrm{hub}}+\beta\frac{m_0K_0^{\mathrm{hub}}+M_{<c}^{(K)}}{m_0+z_{<c}}.

and bounded past hub capacity b<c,khub=min⁡(∑hz<c,h,Mhub)z<c,k∑hz<c,hb_{<c,k}^{\mathrm{hub}}=\min(\sum_h z_{<c,h},M_{\mathrm{hub}})\frac{z_{<c,k}}{\sum_h z_{<c,h}} (Mhub=8.0M_{\mathrm{hub}}=8.0).

3. Strictly causal Read OT (CC queries ←(r+C)\leftarrow(r+C) local past +K+K past hubs): For chunk cc, each query i∈{0,…,C−1}i \in\{0,\ldots,C-1\} (global index t=cC+it=cC+i) connects to Ωc,i={j:max⁡(0,t−r)≤j≤t}∪{H<c,k:c>0,z<c,k>0}\Omega_{c,i}=\{j:\max(0,t-r)\leq j\leq t\}\cup\{H_{<c,k}:c>0,z_{<c,k}>0\} with source capacities bcread=[b<chub;b<c]b_c^{\mathrm{read}}=[b_{<c}^{\mathrm{hub}};b_{<c}]. Initialize vc,i,sr=ln⁡bc,sreadv_{c,i,s}^{r}=\ln b_{c,s}^{\mathrm{read}} and run 1 detached base sweep (sscale/εfs_{\mathrm{scale}}/\varepsilon_f), 2 differentiated tail sweeps, and final row closure, where every column reduction uses an exclusive causal prefix log-sum-exp strictly over earlier queries 0≤i′<i0\leq i'<i within chunk cc:

uc,ir←ln⁡ac,i−LSE⁡s∈Ωc,i(Sc,i,sread+vc,i,sr),vc,i,sr←ln⁡bc,sread−γrLSE⁡0≤i′<is∈Ωc,i′(Sc,i′,sread+uc,i′r),u_{c,i}^{r}\leftarrow\ln a_{c,i}-\operatorname{LSE}_{s\in\Omega_{c,i}}(S_{c,i,s}^{\mathrm{read}}+v_{c,i,s}^{r}),\qquad v_{c,i,s}^{r}\leftarrow\ln b_{c,s}^{\mathrm{read}}-\gamma_r\operatorname{LSE}_{0\leq i'<i\atop s\in\Omega_{c,i'}}(S_{c,i',s}^{\mathrm{read}}+u_{c,i'}^{r}),

with γr=0.25\gamma_r=0.25. Return Yc,i=ac,i−1∑s∈Ωc,iexp⁡(Sc,i,sread+uc,ir,out+vc,i,sr)Vc,sreadY_{c,i}=a_{c,i}^{-1}\sum_{s\in\Omega_{c,i}}\exp(S_{c,i,s}^{\mathrm{read}}+u_{c,i}^{r,\mathrm{out}}+v_{c,i,s}^{r})V_{c,s}^{\mathrm{read}}.

4. Mixed-precision BF16 Tensor Cores with FP32 duals: Matrix multiplies execute on BF16 Tensor Cores with FP32 accumulation, while potentials (u,v)(u,v) and log-sum-exp states stay strictly FP32—analogous to mixed-precision FlashAttention [7, 27]. Against the unfused FP32 reference implementation across (Y,∇Q,∇K,∇V,∇a,∇b,∇B)(Y,\nabla_Q,\nabla_K,\nabla_V,\nabla_a,\nabla_b,\nabla_B) on L∈{128,256}L\in\{128,256\} (H∈{2,4}H\in\{2,4\}, D∈{32,64}D\in\{32,64\}), worst-case maximum absolute error is 4.47×10−84.47\times10^{-8} (relative L2≤5.02×10−7L_2\leq5.02\times10^{-7}) in FP32 mode and 3.27×10−43.27\times10^{-4} in BF16 Tensor-Core mode (and independently matches pure-JAX unrolled dense autodiff within ≤6.56×10−7\leq6.56\times10^{-7} in FP32).

Strictly Causal Autoregressive Chunked Transport

Full-sequence Sinkhorn scaling couples future keys and queries into earlier potentials via (3). To support linear-time autoregressive modeling alongside causal linear attention, selective state spaces, and slot-memory architectures [16, 13, 39, 42], we partition sequences into chunks of size C=32C=32 and replace both global sorting and intra-chunk column coupling with strictly causal operations, specified completely in Algorithm 2.

Causal dependency guarantee. Consider any output position t=cC+it = cC + i. (i) Its capacities (at,bt)=1/L+ReLU⁡(st−θ)(a_t, b_t) = 1/L + \operatorname{ReLU}(s_t-\theta) depend strictly on token tt. (ii) Its past hub summaries (K<chub,V<chub,b<chub)(K^{\mathrm{hub}}_{<c}, V^{\mathrm{hub}}_{<c}, b^{\mathrm{hub}}_{<c}) aggregate only completed chunks c′<cc' < c, all of whose tokens satisfy t′<cC≤tt' < cC \leq t. (iii) Its local candidate set Ωc,i\Omega_{c,i} contains only positions j≤tj \leq t. (iv) Crucially, during read-side Sinkhorn sweeps inside chunk cc, the column potential vc,i,srv_{c,i,s}^{r} reduces strictly over earlier queries 0≤i′<i0 \leq i' < i via an exclusive prefix log-sum-exp, preventing later queries i′>ii' > i in the same chunk from altering vc,i,srv_{c,i,s}^{r}. By induction over the finite sweeps, no intermediate state entering YtY_t depends on any input at t′>tt' > t. Both adversarial future-perturbation checks across chunk boundaries and exact reverse-mode Jacobians (∂Yt/∂{Kt′src,Vt′src,st′src}(\partial Y_t/\partial\{K_{t'}^{\mathrm{src}}, V_{t'}^{\mathrm{src}}, s_{t'}^{\mathrm{src}}\} for t<t′)t < t') verify a maximum leakage of identically 0.0.

Summary of Evaluated THOT Variants

Because our empirical study evaluates four distinct THOT configurations with different complexity, causality, and supervision properties, Table 2 summarizes their exact boundaries so claims are never conflated across variants.

Experiments

All experiments were conducted on NVIDIA L4 GPUs using JAX (0.11.1, NumPy 2.4.6) under matched training budgets, fixed random seeds, and deterministic evaluation splits. For all length-extrapolation benchmarks, models are trained exclusively on short sequences (L=128L = 128 or L=512L = 512) and evaluated zero-shot without length fine-tuning out to L=65,536L = 65{,}536 or L=262,144L = 262{,}144. Individual per-seed outcomes and key experimental configurations appear in Appendix § 7.

Synthetic Long-Context Extrapolation, Pure α=0\alpha= 0 Training, and Ablations

Experimental setup. We evaluate retrieval of a fixed sparse set of R=8R = 8 key-value bindings embedded among growing distractor sequences using a 2-layer MoE Transformer (D=32D = 32, 4 experts, K=16K = 16 hubs, local radius r=4r = 4, Q=8Q = 8 queries over 512 distinct keys and 256 values). Each model trains for 1,536 updates at L=128L = 128 across three seeds (1711, 2917, 4129) and is evaluated zero-shot on 32 held-out sequences per seed (256 queries/seed; 768 queries across 3 seeds) for length scaling (L∈{128,8,192,262,144}L \in\{128, 8{,}192, 262{,}144\}), L=8,192L = 8{,}192 key-group collision stress (C∈{0,16,32,64}C \in\{0, 16, 32, 64\} competing distractors sharing a key group), and L=512L = 512 hub-capacity overload (R=Q∈{8,16,32}R = Q \in\{8, 16, 32\} against K=16K = 16 hubs). Auxiliary gate supervision weight α∈{0.05,0}\alpha\in\{0.05, 0\} tests whether routing emerges purely from task cross-entropy (α=0\alpha= 0).

Findings (Tables 3–4). The primary jump in long-context recall comes from sparse capacity gating and row closure: replacing softmax gating with sparsemax lifts L=262KL = 262\mathrm{K} accuracy from 3.52% to 89.71% even on the legacy 4+24 + 2 schedule, and adding exact row closure (*Bipartite OT (3-sweep, RC) raises recall to 97.79% (α=0.05\alpha= 0.05) and 95.96% (α=0\alpha= 0). Adding 1 + 2 topological annealing (THOT (1+2, Sparsemax)) provides a further +1.04 to +1.44 percentage-point refinement on zero-shot 262K extrapolation (98.83% at α=0.05\alpha= 0.05, outperforming Bipartite RC on all three seeds; 97.40% at α=0\alpha= 0 with tightly clustered seeds (96.88, 97.27, 98.05)% vs. (99.61, 99.22, 89.06)% for Bipartite RC; Table 9). Notably, this schedule exhibits a clear trade-off under α=0\alpha= 0: non-annealed Bipartite RC achieves stronger accuracy across all three nonzero collision levels (C∈{16,32,64}C \in\{16, 32, 64\}), whereas annealed THOT leads on clean extrapolation and hub capacity overload (R∈{8,16,32}R \in\{8, 16, 32\}). Table 4 summarizes our gate, semi-relaxed, multi-head, and negative-control ablations:

BenchmarkModel / VariantPer-Seed ValuesMean
Synthetic Recall 262K (α=0.05\alpha= 0.05)THOT (1+2, Sparsemax)98.83/98.44/99.22%98.83%
Bipartite OT (3-sweep, RC)98.44/97.27/97.66%97.79%
THOT (1+2, ReLU-Thresh, O(L)O(L))97.66/99.61/99.22%98.83%
THOT-SR (γb=0.92\gamma_b = 0.92 / 0.88)96.48/98.44/97.27% — 99.22/97.66/95.70%97.40% / 97.53%
Synthetic Recall 262K (α=0.00\alpha= 0.00)THOT (1+2, Sparsemax)96.88/97.27/98.05%97.40%
Bipartite OT (3-sweep, RC)99.61/99.22/89.06%95.96%
THOT (1+2, ReLU-Thresh, O(L)O(L))81.25/80.08/80.47%80.60%
THOT-SR (γb=0.92\gamma_b = 0.92 / 0.88)98.83/99.61/88.28% — 81.64/98.05/85.94%95.57% / 88.54%
Causal Recall 262K (α:1→0\alpha: 1 \to0)Causal THOT91.41/91.41/87.50%90.10%
Causal Latent Softmax82.81/76.95/85.55%81.77%
Causal Hub OT (Softmax Gate)33.98/33.98/30.47%32.81%
WikiText Multi-Needle 64K (α=0\alpha= 0)THOT (1+2, Sparsemax)100.00/100.00% (64/64, 64/64)100.00%
Hub OT (4+2, Sparsemax)76.56/90.62%83.59%
Latent Softmax + Sparsemax81.25/78.12%79.69%
Support Softmax + Sparsemax75.00/82.81%78.91%
FlashAttention (cuDNN, RoPE)1.56/0.00%0.78%
Causal WikiText-4K LM (Intact NLL)Causal THOT4.1582/4.15384.1560
Causal Local Window4.1676/4.17364.1706
Causal Latent Softmax4.2122/4.20274.2074
Causal FlashAttention4.4043/4.37634.3903
Deep WikiText-4K MLM (Intact NLL)THOT (1+2, Sparsemax)5.5678/5.56365.5657
Support Softmax + Sparsemax5.5623/5.60165.5819
Latent Softmax + Sparsemax5.6093/5.67685.6430
FlashAttention (cuDNN, RoPE)6.3156/6.36916.3424

Table 9. Individual per-seed outcomes across primary benchmarks (seeds 1711 / 2917 / 4129 for 3-seed synthetic and causal recall; seeds 1711 / 2917 for 2-seed WikiText-103 evaluations).

  • Sorting-free O(L)O(L) gating: THOT (1+2, ReLU-Thresh) matches sparsemax at α=0.05\alpha= 0.05 (98.83% at L=262L = 262K, 80.66% at R=16R = 16) with zero cross-token sorting, lowering gate-only forward latency from 0.355 ms to 0.220 ms at L=8L = 8K and from 0.709 ms to 0.596 ms at L=262L = 262K. Without gate supervision (α=0\alpha= 0), however, ReLU thresholding drops to 80.60% at L=262L = 262K, whereas sparsemax retains 97.40%.

  • Prior-preserving semi-relaxed annealing: Naive unweighted semi-relaxed OT (γb=0.85\gamma_b = 0.85) collapses completely at α=0\alpha= 0 (0.13% accuracy). Preceding prior-preserving relaxation with two balanced sweeps (THOT-SR) restores α=0\alpha= 0 stability at both γb=0.92\gamma_b = 0.92 (95.57% at 262K; strongest R=32R = 32 overload at 39.91%) and γb=0.88\gamma_b = 0.88 (88.54% at α=0\alpha= 0, 97.53% at α=0.05\alpha= 0.05).

  • Multi-head trade-off and negative controls: Parameter-matched 4-head THOT (H=4H = 4, dh=8d_h = 8, 56,651 ≤\leq 56,688 active parameters) retains 95.96% (α=0.05\alpha= 0.05) and 94.14% (α=0\alpha= 0) at L=262L = 262K, although narrower head dimension slightly lowers overloaded R=32R = 32 recall (34.31% vs. 38.41%). Across all variants, severe overload (R=32R = 32 bindings against K=16K = 16 hubs) remains bounded near 38%–40%, confirming that our 262K result measures distractor tolerance for a fixed sparse set rather than unbounded hub capacity. Uncentered implicit differentiation fails to train (0.91% at 262K).

GPU Operator Microbenchmarks and Compiler Memory

Benchmark protocol and scope. Table 5 and Figure 2 benchmark the standalone bidirectional attention operators on NVIDIA L4 (JAX 0.11.1, jaxlib 0.11.1, NumPy 2.4.6), reporting the median of five device-synchronized executions after JIT compilation warmup. Every operator receives identical

Figure 2. Bidirectional GPU operator latency and static XLA compiler temporary memory on NVIDIA L4. (a) At multi-head transformer geometry (H=8H = 8, D=64D = 64, L=262,144L = 262{,}144), our batched split-factor BF16 Tensor-Core kernel completes forward+VJP in 100.1 ms (1,132 MiB static compiler temp), outperforming Unfused Hub OT by 4.8×, Latent Softmax by 2.2× (4.0× smaller compiler temporaries than Latent Softmax), and dense cuDNN FlashAttention by 92×. (b) On a bidirectional WikiText-4K layer geometry (B=2B = 2, L=4,096L = 4{,}096, H=8H = 8, D=32D = 32, r=32r = 32), THOT (BF16 TC) runs forward+VJP 3.3× faster than cuDNN FlashAttention (1.34 ms vs. 4.37 ms).

GeometryOperator (Bidirectional)Forward (ms)Forward+VJP (ms)Comp. Temp (MiB)
H=8,D=64,L=262,144H = 8, D = 64, L = 262{,}144<br>(B=1,r=4,K=16B = 1, r = 4, K = 16)THOT Kernel (BF16 TC)34.708100.0971,132.1
THOT Kernel (FP32)111.293268.8971,132.1
Unfused Hub OT109.278480.8342,160.6
Latent Softmax42.966221.8894,521.3
FlashAttention (cuDNN)2,227.0049,235.4091,040.0
H=1,D=32,L=262,144H = 1, D = 32, L = 262{,}144<br>(B=1,r=4,K=16B = 1, r = 4, K = 16)THOT Kernel (BF16 TC)1.6845.38074.3
Unfused Hub OT7.17524.448142.0
Latent Softmax5.59322.964292.1
FlashAttention (cuDNN)279.5241,287.43266.0
WikiText-4K Layer<br>(B=2,L=4,096,H=8B = 2, L = 4{,}096, H = 8)<br>(D=32,r=32,K=16D = 32, r = 32, K = 16)THOT Kernel (BF16 TC)0.5441.33733.0
THOT Kernel (FP32)2.1865.13833.0
Unfused Hub OT3.95912.79559.3
Latent Softmax1.0454.90680.8
FlashAttention (cuDNN)1.1004.36816.5

Table 5. Bidirectional operator and WikiText-4K attention-layer microbenchmarks on NVIDIA L4 (median of 5 synchronized runs; attention operator only, excluding QKV projections and gating/sorting). Memory reports XLA static compiler temporary buffer estimates, not runtime peak VRAM.

BF16 (QQ, KK, VV) inputs (plus FP32 marginals and biases where applicable). FlashAttention (cuDNN) executes cuDNN BF16 attention; Unfused Hub OT, Latent Softmax, and THOT Kernel (FP32) execute FP32 matmuls and reductions; THOT Kernel (BF16 TC) executes BF16 Tensor-Core matmuls with FP32 accumulation and strictly FP32 dual potentials. Timings isolate the attention operator itself (plus hub-RMSNorm/content-slice assembly in the WikiText-4K layer row), excluding QKV projections, capacity MLP/sorting, and FFN/MoE blocks. Importantly, Table 5 evaluates the bidirectional kernel, not the causal chunked scan (§ 3.4), and these kernels have not yet been wired into the multi-layer WikiText-4K training loops (where full-model step times remain slower than dense FlashAttention: 174.15 vs. 136.32 ms in MLM and 211.41 vs. 126.45 ms in causal LM).

Operator results. At H=8H = 8, D=64D = 64, L=262,144L = 262{,}144, THOT Kernel (BF16 TC) executes forward in 34.71 ms and forward+VJP in 100.10 ms with 1,132.1 MiB static XLA compiler temporary allocation. Even in full FP32 precision, split accumulators and native grid batching cut forward+VJP latency from 480.83 ms (Unfused Hub OT) to 268.90 ms while halving compiler temporary storage (2,160.6 →\to 1,132.1 MiB). Relative to Latent Softmax, our BF16 Tensor-Core kernel is 2.22×\times faster forward+VJP with 4.0×\times smaller compiler temporaries (1,132.1 vs. 4,521.3 MiB; note that cuDNN FlashAttention requires slightly smaller static compiler temporaries at 1,040.0 MiB). At moderate sequence length (B=2B = 2, L=4,096L = 4{,}096, H=8H = 8, D=32D = 32, r=32r = 32, bidirectional), THOT beats cuDNN FlashAttention by 2.02×\times forward (0.544 vs. 1.100 ms) and 3.27×\times forward+VJP (1.337 vs. 4.368 ms). At the full 2-layer MoE model level (D=32D = 32, L=262,144L = 262{,}144, measured prior to split-factor kernel integration), THOT runs forward+grad in 139.26 ms (2,614.1 MiB static temp), beating Latent Softmax + Sparsemax (144.34 ms, 2,851.1 MiB) and outpacing the dense FlashAttention MoE (1,426.69 ms) by over 10×\times.

Strictly Causal Autoregressive Benchmarks

Table 6 and Figure 3(a) summarize our autoregressive evaluations. On strictly causal associative recall (all R=8R = 8 bindings precede all Q=8Q = 8 queries beyond the local window radius; 32 test sequences/seed, 768 queries across 3 seeds), all models train for 1,536 steps at L=128L = 128 using an annealed auxiliary gate warmup (α\alpha linearly decayed from 1.0 to 0.0 over steps 1–256, and α=0\alpha= 0 for steps 257–1,536). Causal Local Window fails (0.52%) and softmax-gated causal OT drops to 32.81% at L=262L = 262K as distractors absorb 98.87% of excess capacity. In contrast, Causal THOT maintains 0.00% excess filler share and sustains 90.10% accuracy at L=262,144L = 262{,}144 ((91.41, 91.41, 87.50)% across seeds; 0.564 NLL), outperforming Causal Latent Softmax (81.77%, 1.162 NLL) by +8.3 percentage points.

Causal Model128 → 8K → 262K262K Ex. FillStep (ms)IntactBlockedCtx GainAcc
Causal THOT94.27/90.23/90.10%0.00%211.414.15604.1724+0.016522.48%
Causal Latent Softmax83.46/82.16/81.77%0.00%151.034.20744.2330+0.025621.57%
Causal Local Window0.52/0.52/0.52%99.99%121.544.17064.1786+0.008022.33%
Causal FlashAttention——126.454.39034.4137+0.023418.21%
Causal Hub OT (Softmax Gate)84.77/75.39/32.81%98.87%—————

Table 6. Strictly causal associative recall (L=128→262KL = 128 \to262\mathrm{K}, 3 seeds, 768 queries; gate supervision α\alpha annealed 1.0→0.01.0 \to0.0 over steps 1–256) and preliminary causal WikiText-4K LM (4-layer D=256D = 256, V=2,048V = 2{,}048, 2 seeds ×512 steps). Every model verifies 0.0 future-token leakage; full-model step times reflect the unfused reference path.

Figure 3. Figure 3: Strictly causal associative recall and compact WikiText-103 4K language modeling. (a) Under verified 0.0 future leakage (annealed gate warmup over steps 1–256), Causal THOT sustains 90.10% zero-shot recall at L=262KL = 262\mathrm{K} (0.00% excess filler share), outperforming Causal Latent Softmax (81.77%) and Causal Hub OT (Softmax Gate) (32.81%). (b) On compact 4-layer Causal Next-Token LM (512 steps) and Deep 4-Layer MLM (640 steps) over WikiText-103 4K documents, THOT achieves the lowest held-out NLL, with modest margins (0.015–0.016 nats) over the strongest nearby structured baselines.

We also run a preliminary compact-scale causal LM comparison using 4-layer, 8-head models (D=256D = 256, 2,048-token vocabulary, r=32r = 32, K=16K = 16, C=32C = 32, 4 MoE experts) on L=4,096L = 4{,}096 WikiText-103 documents (batch size 2, 2 seeds, 512 steps, unigram NLL 6.4770). Held-out NLL is evaluated on intact 4K sequences (Intact) and when documents are segmented into isolated 16 × 256-token blocks (Blocked). Causal THOT reaches the lowest intact NLL (4.1560: 4.1582/4.1538 across seeds) and highest token accuracy (22.48%), ahead of Causal Local Window (4.1706: 4.1676/4.1736) by a modest 0.0146 nats, Causal Latent Softmax (4.2074) by 0.0514 nats, and Causal FlashAttention (4.3903). Because Causal Local Window (r=32r = 32) itself gains +0.0080 nats on intact over blocked documents due to artificial 256-token boundary truncation, the intact-minus-blocked difference (Ctx Gain) mixes boundary effects with genuine long-range context use and should be interpreted cautiously. On this unfused multi-layer training path, Causal THOT takes 211.41 ms/step (1.67× slower than Causal FlashAttention at 126.45 ms/step).

Natural-Language Evaluation: Multi-Needle Prose Retrieval and WikiText-4K MLM

To assess behavior on natural English text beyond synthetic token streams, we evaluate two compact benchmarks derived from WikiText-103 [21]:

Zero-shot multi-needle retrieval in WikiText-103 prose (α=0\alpha= 0). We embed R=8R = 8 constructed key-value pairs into contiguous WikiText-103 passages using three zero-occurrence real-vocabulary punctuation markers (⟨BIND⟩, ⟨VAL⟩, ⟨QRY⟩). Each key is a 2-token pair (k1k_1, k2k_2) sampled without replacement from 16×32=51216 \times32 = 512 real-vocabulary tokens, and each value vv is drawn from 256 real-vocabulary tokens that also occur naturally in the surrounding prose. Each binding appears as the 5-token span [⟨BIND⟩, k1k_1, k2k_2, ⟨VAL⟩, vv] inside the source arc [L/10L/10, 3L/83L/8], and each corresponding query appears as [⟨QRY⟩, k1k_1, k2k_2, ⟨VAL⟩, ⟨MASK⟩] inside the disjoint query arc [5L/85L/8, 9L/109L/10] (strictly beyond the multi-layer local window radius). Cross-entropy loss and accuracy are evaluated strictly on the ⟨MASK⟩ positions over the full 2,048-token vocabulary without any gate supervision (α=0\alpha= 0). Models train for 512 steps at L=512L = 512 across two seeds (1711, 2917) and are evaluated zero-shot on 16 passages/seed (256 total queries) at L∈{512,8,192}L \in\{512, 8{,}192\} and 8 passages/seed (128 total queries) at L=65,536L = 65{,}536.

Table 7(left) and Figure 1(b) report the results. The short-trained (L=512L = 512) RoPE FlashAttention (cuDNN) baseline reaches 99.22% in-distribution at L=512L = 512, then drops to 0.78% (8.0463–8.1803 NLL) at 8K and 64K. Because this dense baseline uses rotary position embeddings (RoPE; [30]) evaluated up to 128×128\times beyond its training length, its collapse reflects both positional extrapolation failure and attention dispersion rather than normalization dilution in isolation (the controlled isolation of gating dilution remains Table 3). Among the sparse-gated linear-time architectures on the identical task, legacy 4 + 2 OT (83.59%), Latent Softmax + Sparsemax (79.69%), and

Methodα\alphaL=128L = 128L=8,192L = 8{,}192L=262,144L = 262{,}144Coll. 8K (C0/16/32/64)Cap. 512 (R8/16/32)
Hub OT (Softmax Gate)0.0598.31%83.98%3.52%——
Support Softmax0.0512.63%4.17%0.65%——
Support Softmax + Sparsemax0.0538.15%38.02%38.02%38.80/13.02/7.29/2.2136.85/18.49/8.76
Latent Softmax0.0587.24%85.29%76.30%——
Latent Softmax + Sparsemax0.0584.77%81.77%69.79%81.38/38.67/19.66/9.2484.64/64.06/37.92
Hub OT (4+2, Sparsemax)0.0591.41%91.02%89.71%90.76/37.11/16.02/6.9089.71/62.96/26.24
Bipartite OT (3-sweep, RC)0.0597.40%97.66%97.79%96.88/39.19/22.53/10.0397.92/75.98/36.07
THOT (1+2, Sparsemax)0.0598.44%98.96%98.83%97.92/42.06/20.44/9.7797.01/78.12/37.66
Bipartite OT (3-sweep, RC)0.0098.18%95.57%95.96%95.18/44.53/24.48/12.7696.22/75.00/36.52
THOT (1+2, Sparsemax)0.0098.57%97.66%97.40%97.53/36.33/18.88/9.2497.92/79.95/38.41

Table 3. Zero-shot distractor extrapolation (L=128→262L = 128 \to262K, R=8R = 8 fixed bindings), key-group collisions (L=8L = 8K), and capacity overload (L=512L = 512) across 3 seeds (768 queries total per condition). Bounded-support gating eliminates softmax capacity collapse (3.52%), while row-closed THOT reaches 98.83% (α=0.05\alpha= 0.05) and 97.40% (α=0\alpha= 0) at L=262,144L = 262{,}144.

Method512 → 8K → 64K64K NLLStep (ms)IntactBlockedCtx GainAcc
THOT (1+2, Sparsemax)95.31/98.05/100.0%0.0514174.155.56575.5808+0.015110.07%
Hub OT (4+2, Sparsemax)84.77/81.64/83.59%0.5269—————
Support Softmax + Sparsemax81.25/79.30/78.91%0.7507139.455.58195.7954+0.21359.98%
Latent Softmax + Sparsemax88.28/87.50/79.69%0.8376136.785.64305.6663+0.02339.41%
FlashAttention (cuDNN, RoPE)99.22/0.78/0.78%8.1803136.326.34246.4496+0.10724.07%

Table 7. Natural-language evaluation on WikiText-103 (2 seeds). Left: Zero-shot multi-needle prose retrieval (R=8R = 8, α=0\alpha= 0, trained at L=512L = 512; 256 queries at 512/8K, 128 queries at 64K). Right: Preliminary 4-layer D=256D = 256 WikiText-4K MLM (256 held-out docs, 640 steps, Unigram NLL 6.4788, unfused step times). Multi-Needle Prose (α=0\alpha= 0); Deep WikiText-4K MLM (Unigram 6.4788).

Support Softmax + Sparsemax (78.91%) preserve functional retrieval at 64K, whereas THOT (1+2, Sparsemax) reaches 100.00% (64/64 on both seeds; 128/128 queries, 0.0514 NLL) at L=65,536L = 65{,}536.

Preliminary 4-layer WikiText-4K masked language modeling. We next evaluate bidirectional 4-layer (D=256D = 256, H=8H = 8, V=2,048V = 2{,}048, r=32r = 32, K=16K = 16) models on 256 held-out 4,096-token WikiText-103 confirmation documents after 640 training steps (∼15%\sim15\% masked across 1–3 word geometric spans, learning rate 10−310^{-3}, 2 seeds, unigram NLL 6.4788). Four uniform stabilization practices are applied across all models (Appendix § 7): non-zero learned mask embeddings, unit output logit scaling, independent query/key initializations with full rotary coverage (drope=32d_{\mathrm{rope}} = 32, base 10,000) for dense FlashAttention, and short 1–3 word spans. Under this compact setup (Table 7, right), THOT (1+2, Sparsemax) obtains the lowest intact NLL (5.5657: 5.5678/5.5636 across seeds, 10.07% accuracy), modestly ahead of Support Softmax + Sparsemax (5.5819: 5.5623/5.6016, a 0.0162-nat mean difference with overlapping single-seed values) and Latent Softmax + Sparsemax (5.6430). Full-RoPE FlashAttention reaches only 6.3424 NLL (barely below the 6.4788 unigram baseline) within 640 updates at batch size 2; because that gap could reflect undertraining or hyperparameter sensitivity of dense attention at small step budgets, we treat these MLM numbers as preliminary diagnostics rather than evidence of broad language-modeling superiority. On this unfused path, THOT runs at 174.15 ms/step (1.28× slower than dense FlashAttention at 136.32 ms/step).

Related Work

Sparse, latent, slot-memory, and linear long-context architectures. Longformer [2] and BigBird [41] introduced combined local sliding windows and global tokens for linear-time Transformers, while Perceiver [15] routes inputs through learned latent bottleneck arrays and Vision

Transformers employ global register tokens as routing scratchpads [9]. Complementary linear-time methods—including linear attention [16], selective state-space models [13], gated linear attention [39], and Gated Slot Attention (GSA) [42]—compress history into recurrent or slot-based memories via parallel scans; GSA is particularly relevant to our causal extension § 3.4, as it targets associative recall via compact recurrent slots with context-dependent reading, whereas Causal THOT balances chunk writes and prefix reads through semi-relaxed optimal transport coupled with explicit local windows and thresholded token capacities. Arora et al. [1] highlighted recall deficits in sub-quadratic models, while long-context evaluations document U-shaped positional drop-offs [18], multi-needle degradation [14], and sensitivity to positional extrapolation or attention sinks [24, 22, 38].

Differentiable optimal transport and low-rank Sinkhorn attention. Entropic regularization [6, 23] made Sinkhorn scaling [29, 17] practical inside neural layers, motivating feature matching [26], unbalanced/semi-relaxed transport [4], smooth quadratic transport [3], doubly-stochastic attention [31, 25], warm-start initialization [32], and unrolled or implicit differentiation [19, 10]. Closely related to our hub-mediated architecture is LOTFormer [28], which constructs query-to-pivot and pivot-to-key optimal transport problems through a small learned intermediate measure and composes them into an O(nr)O(nr) low-rank doubly-stochastic attention operator. THOT differs from LOTFormer in five specific ways: (i) coupling global hubs jointly with a local sliding-window band inside a single sparse graph Ω\Omega, (ii) replacing uniform marginals with input-dependent bounded-support token capacities (a,b)(a,b) to eliminate distractor dilution, (iii) introducing the 1+21 + 2 annealed row-closed finite-sweep schedule (and prior-preserving semi-relaxed variant), (iv) deriving an exact rank-(D+2R+1)(D + 2R + 1) One-Reference-Tile adjoint implemented in split-factor BF16 Tensor-Core Triton kernels, and (v) providing a strictly causal chunked exclusive-prefix construction. Most directly, this paper builds on Forde [11] (block-wise Sinkhorn tail refinement) and Forde [12] (fixed-support gradient mixing).

Sparse attention normalization and anti-dilution. Sparsemax [20] and α\alpha-entmax [5] replace softmax with compact-support simplex projections, while Wortsman et al. [37] studied point-wise ReLU attention scaling. Most closely aligned with our anti-dilution motivation are Veličković et al. [36], who proved that standard softmax must disperse on sharp size generalization and studied adaptive temperature, and Long-Context Generalization with Sparse Attention [35], who showed that distractors accumulate softmax mass and used exact-zero sparse attention normalization to achieve up to ∼1,000×\sim1{,}000\times synthetic length extrapolation and improved language-model generalization. Whereas Vasylenko et al. [35] apply exact sparsity directly to the pairwise attention weights, THOT applies exact-zero sparsity at the OT marginal capacity gate (via sparsemax or O(L)O(L) thresholded ReLU), pairing sparse capacity allocation with a linear-time hub-and-local transport graph and custom Triton kernels.

IO-aware attention and OT kernels. The FlashAttention family [8, 7, 27] avoids O(L2)O(L^{2}) HBM materialization via SRAM tiling and mixed-precision Tensor Cores implemented in CUDA or Triton [33]. For dense entropic optimal transport, FlashSinkhorn [40] recently introduced IO-aware streaming Triton kernels for full N×NN \times N Sinkhorn scaling. Our split-factor Triton kernels apply analogous SRAM tiling and BF16 Tensor Cores directly to the sparse hub-and-spoke graph while keeping dual potentials strictly FP32 and compressing all finite-tail score gradients into two width-DD reference-tile passes.

Limitations, Reproducibility, and Conclusion

Limitations. We highlight five boundaries of the current study:

  1. Operator vs. full-model kernel integration: Our split-factor BF16 Tensor-Core kernels were benchmarked on standalone bidirectional operators (100.10 ms at 262K; 1.337 ms vs. 4.368 ms cuDNN FlashAttention at 4K), whereas the multi-layer WikiText-4K training loops ran on our unfused path (174.15 ms/step MLM vs. 136.32 ms dense; 211.41 ms/step causal vs. 126.45 ms dense). Faster end-to-end language-model training has therefore not yet been demonstrated and requires wiring the Triton kernels into full multi-layer bidirectional and causal stacks.

  1. Static compiler vs. runtime memory: Reported memory figures reflect static XLA compiler temporary estimates rather than dynamic peak runtime VRAM profiles, and the 4.0× compiler-temporary reduction is strictly relative to Latent Softmax (not FlashAttention).

  1. Fixed-binding retrieval vs. information capacity scaling: Our 262K extrapolation benchmarks hold R=8R = 8 relevant bindings fixed while expanding distractors; under hub overload (R=32R = 32 vs. K=16K = 16), recall falls to 38%–40%. Scaling RR, KK, and LL jointly remains important future work.

  1. Preliminary LM scale and dense baseline diagnostics: Our WikiText-4K experiments use compact 4-layer (D=256D = 256, V=2,048V = 2{,}048, 512–640 steps, 2 seeds) models with modest 0.015–0.016 nat margins over nearby structured baselines, and our prose-needle dense baseline conflates RoPE extrapolation with attention dispersion. Diagnosing why the dense MLM baseline remained near unigram (6.3424 vs. 6.4788) and adding content-only (no-RoPE) dense retrieval controls are priorities for a follow-up revision.

  1. Variant trade-offs: Sorting-free O(L)O(L) thresholded ReLU relies on α=0.05\alpha= 0.05 to match sparsemax at 262K (98.83% vs. 80.60% at α=0\alpha= 0), Causal Recall uses an annealed gate warmup over steps 1–256, and non-annealed row-closed bipartite OT outperforms annealed THOT on nonzero collision stress under α=0\alpha= 0.

Reproducibility and Code Availability. All experiments ran on NVIDIA L4 GPUs in JAX (0.11.1, jaxlib 0.11.1, NumPy 2.4.6) with fixed random seeds, deterministic data generators, and matched parameter budgets across compared arms. Key experimental configurations, evaluation counts, and individual per-seed results appear in Appendix § 7. A concise standalone JAX/Triton reference implementation covering the capacity gates, batched split-factor THOT kernels (with an exact pure-JAX reference for CPU verification), and strictly causal chunked operator accompanies this manuscript. Notice on arXiv:2609.07954: this manuscript extends our earlier fixed-support transport analysis with sparse capacity gating, finite-sweep annealing, exact Triton adjoint kernels, causal chunking, and empirical long-context benchmarks.

Conclusion. Topology Hub Optimal Transport pairs bounded-support capacity gating, a 1+21 + 2 annealed row-closed Sinkhorn schedule, an exact rank-(D+2R+1)(D + 2R + 1) One-Reference-Tile adjoint implemented in split-factor BF16 Tensor-Core Triton kernels, and a strictly causal exclusive-prefix chunked variant. Controlled ablations isolate sparse capacity allocation as the decisive factor preventing 1/(1+αL)1/(1 + \alpha L) distractor collapse (3.52% →\rightarrow 97.40% pure cross-entropy recall at L=262KL = 262\mathrm{K}), while operator microbenchmarks show linear-time bidirectional OT surpassing cuDNN FlashAttention already at L=4,096L = 4{,}096 (1.34 vs. 4.37 ms) and running 2.2×\times faster than latent softmax at L=262KL = 262\mathrm{K}. Integrating these kernels into full multi-layer causal and bidirectional language models at larger scale is the natural next step.

Exact Adjoint Derivation and Experimental Details

Exact One-Reference-Tile Adjoint for Algorithm 1

We derive the exact reverse-mode vector-Jacobian product (VJP) implemented by our batched Triton kernel for the bidirectional 1+21 + 2 annealed row-closed operator in Algorithm 1 (R=2R = 2 differentiated bipartite tail sweeps with BHH=−20B_{HH} = -20, following a detached aperiodic warm-start potential v1v_1). Let A={i:ai>0}A = \{i : a_i > 0\} and B={j:bj>0}B = \{j : b_j > 0\} denote active rows and columns, with ∣A∣=∑i1[i∈A]|A| = \sum_i \mathbf{1}[i \in A].

Forward states cached for backward. In Algorithm 1, Sweeps t∈{2,3}t \in\{2, 3\} iterate from v1=detach⁡(v1)v_1 = \operatorname{detach}(v_1) under the bipartite edge scores SS:

uraw,i(t)=ln⁡ai−LSE⁡j∈Ω(i)(Sij+vt−1,j),st=1∣A∣∑i∈Auraw,i(t),ut,i=uraw,i(t)−st,vt,j=ln⁡bj−LSE⁡i∈Ω⊤(j)(Sij+uraw,i(t))+st,(11)\begin{aligned} u_{\mathrm{raw},i}^{(t)} &= \ln a_i - \operatorname{LSE}_{j \in\Omega(i)}(S_{ij} + v_{t-1,j}), \qquad s_t = \frac{1}{|A|}\sum_{i \in A} u_{\mathrm{raw},i}^{(t)}, \\ u_{t,i} &= u_{\mathrm{raw},i}^{(t)} - s_t, \qquad v_{t,j} = \ln b_j - \operatorname{LSE}_{i \in\Omega^\top(j)}(S_{ij} + u_{\mathrm{raw},i}^{(t)}) + s_t, \tag*{(11)} \end{aligned}

followed by exact row closure uout,i=ln⁡ai−LSE⁡j∈Ω(i)(Sij+v3,j)u_{\mathrm{out},i} = \ln a_i - \operatorname{LSE}_{j \in\Omega(i)}(S_{ij} + v_{3,j}), terminal plan Pijout=exp⁡(Sij+uout,i+v3,j)P_{ij}^{\mathrm{out}} = \exp(S_{ij} + u_{\mathrm{out},i} + v_{3,j}), unnormalized aggregate Z=PoutVZ = P^{\mathrm{out}}V, and row-stochastic attention output Yi=Zi/aiY_i = Z_i/a_i. Forward execution caches (Z,v1,uraw(2),s2,v2,uraw(3),s3,v3,uout)(Z, v_1, u_{\mathrm{raw}}^{(2)}, s_2, v_2, u_{\mathrm{raw}}^{(3)}, s_3, v_3, u_{\mathrm{out}}) (total storage O(N)O(N) scalars per head plus ZZ), eliminating all five recomputation log-sum-exp passes during backward.

Step 1: Quotient normalization and terminal value pass. Given upstream loss gradient Yˉ=∂ℓ/∂Y\bar{Y} = \partial\ell/\partial Y, differentiating Yi=Zi/aiY_i = Z_i/a_i yields the unnormalized aggregate cotangent Zˉi=Yˉi/ai\bar{Z}_i = \bar{Y}_i/a_i together with the direct normalization marginal contribution aˉinorm=−(Yˉi⊤Yi)/ai\bar{a}_i^{\mathrm{norm}} = -(\bar{Y}_i^\top Y_i)/a_i. Differentiating Z=PoutVZ = P^{\mathrm{out}}V gives the value gradient via one width-DD transposed sparse pass:

∇V=(Pout)⊤Zˉ=W⊤Yˉ,(12)\nabla_V = (P^{\mathrm{out}})^\top\bar{Z} = W^\top\bar{Y}, \tag*{(12)}

and nonzero terminal log-potential sensitivities

gu,i=Zˉi⊤Zi=Yˉi⊤Yi,gv,j=Vj⊤(∇V)j,(13)g_{u,i} = \bar{Z}_i^\top Z_i = \bar{Y}_i^\top Y_i, \qquad g_{v,j} = V_j^\top(\nabla_V)_j, \tag*{(13)}

with direct score gradient Eijdirect=Pijout(Zˉi⊤Vj)E_{ij}^{\mathrm{direct}} = P_{ij}^{\mathrm{out}}(\bar{Z}_i^\top V_j).

Step 2: Terminal row-closure reverse step. Differentiating uout,i=ln⁡ai−LSE⁡j(Sij+v3,j)u_{\mathrm{out},i} = \ln a_i - \operatorname{LSE}_j(S_{ij} + v_{3,j}) using ∑jPijout=ai\sum_j P^{\mathrm{out}}_{ij} = a_i yields

rout,i=gu,iai(i∈A),aˉ←aˉnorm+rout,gv←gv−(Pout)Trout,(14)r_{\mathrm{out},i} = \frac{g_{u,i}}{a_i}\quad(i \in A),\qquad\bar{a} \leftarrow\bar{a}^{\mathrm{norm}} + r_{\mathrm{out}},\qquad g_v \leftarrow g_v - (P^{\mathrm{out}})^{\mathsf{T}}r_{\mathrm{out}}, \tag*{(14)}

and adds the rank-1 score contribution −Pijoutrout,i-P^{\mathrm{out}}_{ij}r_{\mathrm{out},i} (note that aˉinorm+rout,i=0\bar{a}^{\mathrm{norm}}_i + r_{\mathrm{out},i} = 0, confirming that row-stochastic Yi=Zi/aiY_i = Z_i/a_i has zero net direct sensitivity to aia_i outside the tail sweeps).

Step 3: Exact reverse recurrence through Sweeps t=3,2t = 3,2. Define the intermediate plans Pij(t)=exp⁡(Sij+ut,i+vt,j)P^{(t)}_{ij} = \exp(S_{ij} + u_{t,i} + v_{t,j}) (whose column sums satisfy (P(t))T1=b(P^{(t)})^{\mathsf{T}}\mathbf{1} = b) and Praw,ij(t)=exp⁡(Sij+uraw,i(t)+vt−1,j)P^{(t)}_{\mathrm{raw},ij} = \exp(S_{ij} + u^{(t)}_{\mathrm{raw},i} + v_{t-1,j}) (whose row sums satisfy Praw(t)1=aP^{(t)}_{\mathrm{raw}}\mathbf{1} = a). For t=3t = 3 and then t=2t = 2 (noting gu=0g_u = 0 on entry since u3,u2u_3,u_2 are unused outside their own sweep):

ct,j=gv,jbj(j∈B),dc,t=1∣A∣∑j∈Bgv,j,rt,i=dc,t−(P(t)ct)iai(i∈A),(15)c_{t,j} = \frac{g_{v,j}}{b_j}\quad(j \in B),\qquad d_{c,t} = \frac{1}{|A|}\sum_{j \in B}g_{v,j},\qquad r_{t,i} = \frac{d_{c,t} - (P^{(t)}c_t)_i}{a_i}\quad(i \in A), \tag*{(15)}
aˉ←aˉ+rt,bˉ←bˉ+ct,gv←−(Praw(t))Trt(for t=3 only),\bar{a} \leftarrow\bar{a} + r_t,\qquad\bar{b} \leftarrow\bar{b} + c_t,\qquad g_v \leftarrow-(P^{(t)}_{\mathrm{raw}})^{\mathsf{T}}r_t\quad(\text{for }t=3\text{ only}),

where v1v_1 is detached so no propagation past t=2t = 2 is required. Each sweep tt contributes −Pij(t)ct,j−Praw,ij(t)rt,i-P^{(t)}_{ij}c_{t,j} - P^{(t)}_{\mathrm{raw},ij}r_{t,i} to the edge score adjoint Sˉij\bar{S}_{ij}. Across Steps 2–3, the entire vector recurrence requires only four lightweight 1D scalar sparse matvecs: (Pout)Trout(P^{\mathrm{out}})^{\mathsf{T}}r_{\mathrm{out}}, P(3)c3P^{(3)}c_3, (Praw(3))Tr3(P^{(3)}_{\mathrm{raw}})^{\mathsf{T}}r_3, and P(2)c2P^{(2)}c_2.

Step 4: Exact diagonal-rescaling factorization onto PoutP^{\mathrm{out}}. Crucially, because intermediate plans P(t)P^{(t)} and Praw(t)P^{(t)}_{\mathrm{raw}} differ from the terminal plan PoutP^{\mathrm{out}} on Ω\Omega, their score contributions do not collapse to a rank-2 additive row-plus-column term αi+βj\alpha_i + \beta_j. Instead, every intermediate plan is an exact rank-1 diagonal rescaling of PoutP^{\mathrm{out}}:

Pij(t)=Pijoutexp⁡((ut,i−uout,i)−μu,t)⏟et,iuexp⁡((vt,j−v3,j)+μu,t)⏟et,jv,P^{(t)}_{ij} = P^{\mathrm{out}}_{ij}\underbrace{\exp\bigl((u_{t,i}-u_{\mathrm{out},i})-\mu_{u,t}\bigr)}_{e^u_{t,i}}\underbrace{\exp\bigl((v_{t,j}-v_{3,j})+\mu_{u,t}\bigr)}_{e^v_{t,j}},
Praw,ij(t)=Pijoutexp⁡((uraw,i(t)−uout,i)−μraw,t)⏟et,irawexp⁡((vt−1,j−v3,j)+μraw,t)⏟et,jprev,(16)P^{(t)}_{\mathrm{raw},ij} = P^{\mathrm{out}}_{ij}\underbrace{\exp\bigl((u^{(t)}_{\mathrm{raw},i}-u_{\mathrm{out},i})-\mu_{\mathrm{raw},t}\bigr)}_{e^{\mathrm{raw}}_{t,i}}\underbrace{\exp\bigl((v_{t-1,j}-v_{3,j})+\mu_{\mathrm{raw},t}\bigr)}_{e^{\mathrm{prev}}_{t,j}}, \tag*{(16)}

where mean potential shifts μu,t=1∣A∣∑i∈A(ut,i−uout,i)\mu_{u,t} = \frac{1}{|A|}\sum_{i\in A}(u_{t,i}-u_{\mathrm{out},i}) and μraw,t=1∣A∣∑i∈A(uraw,i(t)−uout,i)\mu_{\mathrm{raw},t} = \frac{1}{|A|}\sum_{i\in A}(u^{(t)}_{\mathrm{raw},i}-u_{\mathrm{out},i}) cancel identically inside the product while preventing floating-point overflow. Collecting the terminal row-closure term and the 2R=42R = 4 rescaled tail terms into two (N×5)(N \times5) factor matrices

L(s)=[−rout, −e3u, −e3raw⊙r3, −e2u, −e2raw⊙r2]∈RN×(2R+1),L^{(s)} = \left[ -r_{\mathrm{out}},\ -e^u_3,\ -e^{\mathrm{raw}}_3 \odot r_3,\ -e^u_2,\ -e^{\mathrm{raw}}_2 \odot r_2 \right] \in\mathbb{R}^{N\times(2R+1)},
R(s)=[1B, e3v⊙c3, e3prev, e2v⊙c2, e2prev]∈RN×(2R+1),(17)R^{(s)} = \left[ \mathbf{1}_B,\ e^v_3 \odot c_3,\ e^{\mathrm{prev}}_3,\ e^v_2 \odot c_2,\ e^{\mathrm{prev}}_2 \right] \in\mathbb{R}^{N\times(2R+1)}, \tag*{(17)}

the exact total edge score adjoint across row closure and Sweeps 2–3 is

Sˉij=Pijout(ZˉiTVj+∑m=12R+1Li,m(s)Rj,m(s)).(18)\bar{S}_{ij} = P^{\mathrm{out}}_{ij}\left(\bar{Z}_i^{\mathsf{T}}V_j + \sum_{m=1}^{2R+1}L^{(s)}_{i,m}R^{(s)}_{j,m}\right). \tag*{(18)}

Hence ∇Q=sscaleSˉK\nabla_Q = s_{\mathrm{scale}}\bar{S}K (together with fused node-type bias sums ∇Bc,c′=∑(i,j)∈Ωc,c′Sˉij\nabla B_{c,c'} = \sum_{(i,j)\in\Omega_{c,c'}}\bar{S}_{ij}, clamping ∇BHH=0\nabla B_{HH}=0) and ∇K=sscaleSˉTQ\nabla K = s_{\mathrm{scale}}\bar{S}^{\mathsf{T}}Q execute in two width-DD split-factor sparse passes over the single reference plan PoutP^{\mathrm{out}} (down from 12 width-DD score-gradient passes in naive unrolled differentiation). In our GPU verification on L∈{128,256}L \in\{128,256\} (H∈{2,4}H \in\{2,4\}, D∈{32,64}D \in\{32,64\}), this exact custom VJP matches the unfused reference implementation to ≤4.47×10−8\le4.47 \times10^{-8} max absolute error (≤5.02×10−7\le5.02 \times10^{-7} relative L2L_2) in FP32 and ≤3.27×10−4\le3.27 \times10^{-4} in BF16 Tensor-Core mode, and matches pure-JAX unrolled dense autodiff within ≤6.56×10−7\le6.56 \times10^{-7} in FP32 across all six input gradients (∇Q\nabla Q, ∇K\nabla K, ∇V\nabla V, ∇a\nabla a, ∇b\nabla b, ∇B\nabla B).

Experimental Configurations, Per-Seed Results, and Stabilization Notes

BenchmarkConfiguration, Schedule, and Evaluation Details
Hardware / SoftwareNVIDIA L4 GPU; JAX 0.11.1, jaxlib 0.11.1, NumPy 2.4.6; microbenchmarks report median of 5 device-synchronized repeats after compilation warmup
Synthetic Recall2-layer MoE (D=32D = 32, 4 experts, hidden 48), K=16K = 16, r=4r = 4, M=8.0M = 8.0, R=Q=8R = Q = 8 bindings/queries; AdamW, 1,536 steps at L=128L = 128, 3 seeds (1711, 2917, 4129); evaluated on 32 held-out sequences/seed (256 queries/seed, 768 total)
Kernel MicrobenchStandalone bidirectional attention operators; BF16 (QQ, KK, VV) inputs; THOT BF16 TC (BF16 matmul, FP32 acc. & potentials), THOT FP32, Unfused Hub OT (FP32), Latent Softmax (FP32), cuDNN FlashAttention (BF16); excludes QKV projections and gating/sorting
Causal RecallSame 2-layer MoE backbone (D=32D = 32, K=16K = 16, r=4r = 4, C=32C = 32), 1,536 steps at L=128L = 128, cosine LR (peak 2×10−32 \times10^{-3}), gate supervision α\alpha linearly annealed 1.0 →\to 0.0 over steps 1–256; 3 seeds, 32 sequences/seed (768 queries)
Causal WT-4K LM4-layer MoE (H=8H = 8, D=256D = 256, V=2,048V = 2{,}048, r=32r = 32, K=16K = 16, C=32C = 32), AdamW (lr = 2.5×10−32.5 \times10^{-3}, β2=0.98\beta_2 = 0.98, weight decay 0.01, cosine schedule), B=2B = 2, 512 steps, 2 seeds (1711, 2917), evaluated on held-out confirmation split
WikiText Prose Needles4-layer (H=8H = 8, D=256D = 256, V=2,048V = 2{,}048, r=32r = 32, K=16K = 16), R=8R = 8 needles, α=0\alpha= 0, 512 steps at L=512L = 512 (lr = 3×10−33 \times10^{-3}), 2 seeds (1711, 2917); evaluated on 16 passages/seed (256 queries) at 512/8K and 8 passages/seed (128 queries) at 64K
WikiText-4K MLM4-layer (H=8H = 8, D=256D = 256, V=2,048V = 2{,}048, r=32r = 32, K=16K = 16), AdamW (lr = 10−310^{-3}, β2=0.95\beta_2 = 0.95), B=2B = 2, 640 steps, ∼15%\sim15\% 1–3 word span masking, 2 seeds (1711, 2917), evaluated on 256 held-out 4,096-token documents

Table 8. Key experimental configurations, optimizer schedules, and evaluation sample counts.

WikiText-4K optimization stabilization details. In preliminary MLM prototypes, four initialization interactions selectively degraded baselines: (i) zero-initialized masked token embeddings produced zero vectors entering RMSNorm (≈103×\approx10^3 \times backward Jacobian amplification), triggering global gradient-norm clipping; (ii) applying 1/D1/\sqrt{D} scaling after unit-norm embeddings doubly attenuated output logits by 16×16\times; (iii) nearly aligned query and key initializations combined with short-period partial RoPE locked dense FlashAttention onto the diagonal self-token; and (iv) overly long 10-word corruption spans hindered early optimization. Applying non-zero learned mask embeddings, unit logit scaling, independent query/key projections with full rotary coverage (drope=32d_{\mathrm{rope}} = 32, base 10,000), and 1–3 word geometric masking spans uniformly addresses all four issues across every baseline and THOT model.

References

  1. [1]Simran Arora, Sabri Eyuboglu, Aman Timalsina, Isys Johnson, Michael Poli, James Zou, Atri Rudra, and Christopher Ré. Zoology: Measuring and improving recall in efficient language models. In International Conference on Learning Representations, 2024.arxiv.org/abs/2312.04927
  2. [2]Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020. doi: 10.48550/arXiv.2004.05150.DOI
  3. [3]Mathieu Blondel, Vivien Seguy, and Antoine Rolet. Smooth and sparse optimal transport. In Proceedings of the 21st International Conference on Artificial Intelligence and Statistics, volume 84 of Proceedings of Machine Learning Research, pages 880–889, 2018.arxiv.org/abs/1710.06276
  4. [4]Lénaïc Chizat, Gabriel Peyré, Bernhard Schmitzer, and François-Xavier Vialard. Scaling algorithms for unbalanced optimal transport problems. Mathematics of Computation, 87(314):2563–2609, 2018.DOI
  5. [5]Gonçalo M. Correia, Vlad Niculae, and André F. T. Martins. Adaptively sparse transformers. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 2174–2184, 2019.
  6. [6]Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. In Advances in Neural Information Processing Systems, volume 26, 2013.
  7. [7]Tri Dao. FlashAttention-2: Faster attention with better parallelism and work partitioning. In International Conference on Learning Representations, 2024.arxiv.org/abs/2307.08691
  8. [8]Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Advances in Neural Information Processing Systems, volume 35, 2022.arxiv.org/abs/2205.14135
  9. [9]Timothée Darcet, Maxime Oquab, Julien Mairal, and Piotr Bojanowski. Vision transformers need registers. In International Conference on Learning Representations, 2024.arxiv.org/abs/2309.16588
  10. [10]Marvin Eisenberger, Aysim Toker, Laura Leal-Taixé, Florian Bernard, and Daniel Cremers. A unified framework for implicit Sinkhorn differentiation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 509–518, 2022.arxiv.org/abs/2205.06688
  11. [11]Dylan B. Forde. Block-wise differentiable Sinkhorn attention: Tail-refinement gradients with a gap-aware dustbin bridge. arXiv preprint arXiv:2605.08123, 2026. doi: 10.48550/arXiv.2605.08123.DOI
  12. [12]Dylan B. Forde. Support topology and gradient mixing in Sinkhorn layers. arXiv preprint arXiv:2609.07954, 2026. doi: 10.48550/arXiv.2609.07954.DOI
  13. [13]Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. In Conference on Language Modeling, 2024.arxiv.org/abs/2312.00752
  14. [14]Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. RULER: What’s the real context size of your long-context language models? In Conference on Language Modeling, 2024.arxiv.org/abs/2404.06654
  15. [15]Andrew Jaegle, Felix Gimeno, Andy Brock, Oriol Vinyals, Andrew Zisserman, and João Carreira. Perceiver: General perception with iterative attention. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 4651–4664, 2021.arxiv.org/abs/2103.03206
  16. [16]Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 5156–5165, 2020.arxiv.org/abs/2006.16236
  17. [17]Philip A. Knight. The Sinkhorn–Knopp algorithm: Convergence and applications. SIAM Journal on Matrix Analysis and Applications, 30(1):261–275, 2008. doi: 10.1137/060659624.DOI
  18. [18]Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173, 2024.arxiv.org/abs/2307.03172
  19. [19]Giulia Luise, Alessandro Rudi, Massimiliano Pontil, and Carlo Ciliberto. Differential properties of Sinkhorn approximation for learning with Wasserstein distance. In Advances in Neural Information Processing Systems, volume 31, pages 5864–5874, 2018.arxiv.org/abs/1805.11897
  20. [20]André F. T. Martins and Ramón Fernandez Astudillo. From softmax to sparsemax: A sparse model of attention and multi-label classification. In Proceedings of the 33rd International Conference on Machine Learning, volume 48 of Proceedings of Machine Learning Research, pages 1614–1623, 2016.arxiv.org/abs/1602.02068
  21. [21]Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In International Conference on Learning Representations, 2017.arxiv.org/abs/1609.07843
  22. [22]Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. YaRN: Efficient context window extension of large language models. In International Conference on Learning Representations, 2024.arxiv.org/abs/2309.00071
  23. [23]Gabriel Peyré and Marco Cuturi. Computational optimal transport with applications to data sciences. Foundations and Trends in Machine Learning, 11(5–6):355–607, 2019. doi: 10.1561/2200000073.
  24. [24]Ofir Press, Noah A. Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations, 2022.arxiv.org/abs/2108.12409
  25. [25]Michaël E. Sander, Pierre Ablin, Mathieu Blondel, and Gabriel Peyré. Sinkformers: Transformers with doubly stochastic attention. In Proceedings of the 25th International Conference on Artificial Intelligence and Statistics, volume 151 of Proceedings of Machine Learning Research, pages 3515–3530, 2022.arxiv.org/abs/2110.11773
  26. [26]Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. SuperGlue: Learning feature matching with graph neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020.arxiv.org/abs/1911.11763
  27. [27]Jay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar, Pradeep Ramani, and Tri Dao. FlashAttention-3: Fast and accurate attention with asynchrony and low-precision. In Advances in Neural Information Processing Systems, volume 37, 2024.arxiv.org/abs/2407.08608
  28. [28]Ashkan Shahbazi, Chayne Thrash, Yikun Bai, Keaton Hamm, Navid NaderiAlizadeh, and Soheil Kolouri. LOTFormer: Doubly-stochastic linear attention via low-rank optimal transport. arXiv preprint arXiv:2509.23436, 2025. doi: 10.48550/arXiv.2509.23436.DOI
  29. [29]Richard Sinkhorn and Paul Knopp. Concerning nonnegative matrices and doubly stochastic matrices. Pacific Journal of Mathematics, 21(2):343–348, 1967.
  30. [30]Jianlin Su, Murtadha Ahmed, Yu Shenfeng Pan, Wen Bo, and Yunfeng Liu. RoFormer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.arxiv.org/abs/2104.09864
  31. [31]Yi Tay, Dara Bahri, Liu Yang, Donald Metzler, and Da-Cheng Juan. Sparse Sinkhorn attention. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 9438–9447, 2020.
  32. [32]James Thornton and Marco Cuturi. Rethinking initialization of the Sinkhorn algorithm. In Proceedings of the 26th International Conference on Artificial Intelligence and Statistics, volume 206 of Proceedings of Machine Learning Research, pages 8682–8698, 2023.arxiv.org/abs/2206.07630
  33. [33]Philippe Tillet, H. T. Kung, and David Cox. Triton: An intermediate language and compiler for tiled neural network computations. In Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages, pages 10–19, 2019.
  34. [34]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30, 2017.arxiv.org/abs/1706.03762
  35. [35]Pavlo Vasylенко, Hugo Pitorro, André F. T. Martins, and Marcos Treviso. Long-context generalization with sparse attention. In International Conference on Learning Representations, 2026.
  36. [36]Petar Veličković, Christos Perivolaropoulos, Federico Barbero, and Razvan Pascanu. Softmax is not enough (for sharp size generalisation). In Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pages 61190–61211, 2025.arxiv.org/abs/2410.01104
  37. [37]Mitchell Wortsman, Jaehon Lee, Justin Gilmer, and Simon Kornblith. Replacing softmax with ReLU in vision transformers. arXiv preprint arXiv:2309.08568, 2023.
  38. [38]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations, 2024.arxiv.org/abs/2309.17453
  39. [39]Songlin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, and Yoon Kim. Gated linear attention transformers with hardware-efficient training. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 56501–56523, 2024.arxiv.org/abs/2312.06635
  40. [40]Felix X.-F. Ye, Xingjie Li, An Yu, Ming-Ching Chang, Linsong Chu, and Davis Wertheimer. FlashSinkhorn: IO-aware entropic optimal transport on GPU. arXiv preprint arXiv:2602.03067, 2026. doi: 10.48550/arXiv.2602.03067.DOI
  41. [41]Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontañón, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences. In Advances in Neural Information Processing Systems, volume 33, pages 17283–17297, 2020.arxiv.org/abs/2007.14062
  42. [42]Yu Zhang, Songlin Yang, Ruijie Zhu, Yue Zhang, Leyang Cui, Yiqiao Wang, Bolun Wang, Freda Shi, Bailin Wang, Wei Bi, Peng Zhou, and Guohong Fu. Gated slot attention for efficient linear-time sequence modeling. In Advances in Neural Information Processing Systems, volume 37, pages 116870–116898, 2024.arxiv.org/abs/2409.07146

Paper details

vlnc:W_6ah3j2ap
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents