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 matrix with a linear-size graph over local windows and 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 () or sorting-free token-local thresholded ReLU (), driving excess distractor mass to zero; (2) a three-sweep annealed row-closed Sinkhorn schedule that damps bipartite residuals; (3) an exact rank- 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 reaches 97.40% zero-shot recall of fixed bindings at under pure task loss () and 98.83% at (matched by thresholded ReLU at , vs. 80.60% at ), while softmax-gated hub OT drops to 3.52%. In bidirectional operator microbenchmarks, our kernel runs forward+VJP in 100.1 ms at (2.2x faster with 4.0x smaller compiler temporaries than latent softmax) and 1.34 ms vs. 4.37 ms for cuDNN FlashAttention at ; multi-layer LM runs use the unfused path. Zero-shot WikiText-103 multi-needle retrieval hits 100.00% (128/128 queries at ) 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 cost of standard attention [34]: even with IO-aware tiling such as FlashAttention [8, 7, 27], dense forward-plus-backward passes at 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 with 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 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:
Softmax capacity dilution (). Even on an 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 hubs as sequence length grows, dropping zero-shot associative recall from 98.31% () to 3.52% ().
Finite-step parity residuals under bipartite hub routing. Blocking hub-to-hub shortcuts () 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.
Unrolled backward memory and tile-padding overhead. Naive reverse-mode automatic differentiation through finite Sinkhorn sweeps launches repeated width- sparse passes and incurs register padding waste, leaving unfused OT over slower than latent softmax attention at .
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 (), sparsemax THOT maintains 97.40% zero-shot recall of fixed bindings at (98.83% with ); thresholded ReLU matches 98.83% at in time while dropping to 80.60% at .
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 ) 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-() modifier evaluated in two width-
sparse passes over the terminal plan (plus one pass for and four 1D scalar passes), matching exact FP32 differentiation within . Batched multi-head Triton kernels [33] with BF16 Tensor Cores and FP32 dual potentials reach 100.1 ms forward+VJP at , , (2.2× faster with 4.0× smaller compiler temporaries than latent softmax) and 1.34 ms vs. 4.37 ms for cuDNN FlashAttention at 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 (with annealed gate warmup), bidirectional sparsemax THOT reaches 100.00% (128/128 queries) zero-shot multi-needle retrieval in WikiText-103 prose at (), 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 real tokens augmented with shared global hub slots ( nodes per attention head). Each real token connects via an active sparse edge set to: (i) a circular local window , and (ii) all global hubs; each hub connects to all nodes (with hub-to-hub edges modulated by ). Hence scales linearly in sequence length , reducing edge count from to .
Given query and key projections , score scale , and a learned node-type bias matrix indexed by whether is real-to-real (), real-to-hub (), hub-to-real (), or hub-to-hub (), the edge affinity score is
Given positive row marginals (emitting budget per query or hub) and column marginals (absorbing budget per key or hub, satisfying in balanced mode), Sinkhorn scaling [29, 6, 17] iteratively updates log-space dual potentials defining the transport plan on :
Once row-normalized so that , the row-stochastic attention weights are , aggregating value vectors via . Note that a single bidirectional THOT layer executes one hop over , updating both token and hub states; consequently, two-hop Source Hub 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 initial sweeps without tracking gradients and backpropagate exactly through a short refinement tail of sweeps.
Failure Mode 1: The Capacity Dilution Law
Suppose a routing gate allocates a total excess capacity budget across real tokens on top of a uniform local baseline , so that . Define the excess filler share as the fraction of excess source budget landing on irrelevant distractor positions:
When excess capacities are allocated via a global softmax, , suppose relevant source tokens exceed irrelevant background filler by a logit margin . Because softmax assigns strictly positive weight to every distractor, if stays bounded away from zero as grows, the denominator expands as . Consequently, the signal fraction of excess routing capacity decays as
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 remains bounded across lengths; in principle, a logit gap growing as (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 (99.2% excess source share) and 83.98% at (67.3% share), before plunging to 12.24% at and 3.52% at (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 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 to . (a) On synthetic associative recall ( fixed bindings, trained at ), softmax-gated Hub OT (Hub OT (Softmax Gate), dashed crimson) collapses from 98.31% to 3.52% at K as distractors absorb 93.4% of excess source capacity. Sparsemax gating with our annealed row-closed schedule (THOT) holds 98.83% with light gate supervision () and 97.40% under pure cross-entropy training (). (b) On zero-shot multi-needle retrieval embedded in WikiText-103 prose (pure cross-entropy, trained at ), 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 .
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 () so queries route through hubs to source tokens rather than circulating mass among hubs. With distractors reduced to their floor and blocked, however, the active routing mass concentrates on a nearly bipartite subgraph between real tokens () and hubs ().
To quantify class-level mixing empirically, let denote the aggregate plan mass between the two node classes, for , and let and be the corresponding 1-hop row- and column-normalized class transition matrices. Note that is distinct from the full-cycle Sinkhorn fixed-point Jacobian on column potentials, [17]: is diagonally similar to a positive-semidefinite Gram matrix and therefore has nonnegative eigenvalues, with class quotient . However, when is near-bipartite, its subdominant eigenvalue lies close to , which both produces alternating half-step parity imbalance between the and partitions and drives the nonnegative two-step quotient eigenvalue of toward (slow contraction).
On our diagnostic (Table 1), a standard bipartite schedule retains 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 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).
| Schedule | TV () | TV (Row / Col, ) | TV | Flow ( / ) |
| Standard Bipartite OT | 0.0323 () | 0.0276 (0.0553 / 0.0000, ) | 0.0263 | 89.4% / 100.0% |
| Bipartite OT (3-sweep) | 0.0263 () | 0.0253 (0.0506 / 0.0000, ) | 0.0231 | 90.2% / 100.0% |
| Bipartite OT (3-sweep, RC) | 0.0262 () | 0.0250 (0.0000 / 0.0499, ) | 0.0227 | 100.0% / 90.3% |
| Aperiodic OT (3-sweep, RC) | 0.0760 () | 0.0396 (0.0000 / 0.0792, ) | 0.0238 | 100.0% / 84.0% |
| THOT (1+2, Row-Closed) | 0.0760 () | 0.0209 (0.0000 / 0.0419, ) | 0.0185 | 100.0% / 91.7% |
| THOT-SR () | 0.0760 () | 0.0201 (0.0000 / 0.0402, ) | 0.0102 | 100.0% / 91.5% |
Table 1. Table 1: Class-quotient diagnostic and marginal residual audit at . Here is the subdominant eigenvalue of the 1-hop Real/Hub class transition matrix (distinct from the PSD two-step Sinkhorn Jacobian), and TV error averages half the row and column deviations from at sweep . THOT’s detached aperiodic Sweep 1 yields , exact row stochasticity (row TV = 0.0000, 100.0% 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.
| Variant | Gate Cost | Causality | Gate Supervision () | Recall | Primary Trade-off |
| THOT (1+2, Sparsemax) | Bidirectional | / | 97.40% / 98.83% | Strongest recall; requires global sort | |
| THOT (1+2, ReLU-Thresh) | Bidirectional | / | 80.60% / 98.83% | Sorting-free; needs light for | |
| THOT-SR () | Bidirectional | / | 95.57% / 97.40% | Lowest 6-sweep TV & best overload | |
| Causal THOT (Alg. 2) | (/tok) | Strictly causal | Annealed (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- recall, sorting-free gating, and causality; each row reports the exact observed trade-off at .
Bounded-Support Capacity Gating: Sparsemax and Thresholded ReLU
To prevent excess capacity from leaking onto distractors under a bounded score margin, we allocate excess budgets with compact support on top of the uniform local baseline:
Algorithm 1: Bidirectional THOT — Forward Pass and Exact One-Reference-Tile Adjoint
Input: (), node-type biases , local radius , marginals from (6) or (7).
Warm start & degree prior: Set and .
Detached aperiodic Sweep 1: With open hub-to-hub coupling (stop-gradient), run one Sinkhorn cycle (2)–(3), center across active rows (, ), and detach .
Differentiable bipartite Sweeps 2–3: Clamp and run two centered Sinkhorn cycles starting from , producing raw row potentials and centered pairs (with optional prior-preserving semi-relaxed exponent on real columns of Sweep 3 for THOT-SR).
Exact row closure & row-stochastic read: Compute , terminal plan (row sums ), unnormalized aggregate , and row-stochastic attention output , . Cache for backward.
Exact One-Reference-Tile Adjoint (backward; full recurrence in Appendix A): Given , set (adding quotient term to ) and compute in one width- transposed pass. Propagate terminal dual sensitivities through row closure and Sweeps 3–2 via four lightweight 1D scalar sparse matvecs to form the scalar factor columns using diagonal rescaling relative to . Finally, execute two width- split-factor sparse passes over the single reference plan : one row-major pass for and one transposed pass for .
Simplex sparsemax gate (). Given scalar routing logits produced by a lightweight token-wise MLP, we replace softmax with Euclidean simplex projection sparsemax [20, 5]:
with total excess mass distributed across real tokens and matched across the hubs ( for ; total sequence mass on real tokens plus on hubs). Because sparsemax maps low logits below its data-dependent threshold to exact zero, excess filler share (4) drops to identically 0.00% across while retaining the baseline on every token for local-window connectivity.
Token-local thresholded ReLU gate (, sorting-free). Global sparsemax requires sorting across all tokens, which costs and couples future tokens through in causal models. Inspired by ReLU attention [37], learned scalar thresholds (initialized at ) yield a sorting-free gate:
and symmetrically for , or purely token-local unnormalized in streaming causal mode. Whenever distractor logits stay below , 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 annealed row-closed schedule:
Marginal warm start and degree prior. We initialize column potentials at the target log-marginals [32] and add a structural degree prior to real-to-real edges (where ) so local neighborhoods remain balanced against hubs as scales.
Sweep 1 (detached aperiodic warm-start). Keeping hub-to-hub affinity open rather than clamped to , we execute one stop-gradient Sinkhorn sweep and center row potentials across active tokens. Opening moves the 1-hop class eigenvalue from to on Sweep 1 at (Table 1), providing a well-equilibrated initialization before bipartite refinement.
Sweeps 2–3 (differentiated bipartite refinement). Clamping suppresses hub-to-hub shortcuts across two differentiable Sinkhorn cycles.
Exact row closure and normalization. Column updates leave 4%–5% row-marginal error at finite sweep count. Performing one final row log-normalization and dividing by guarantees exact row stochasticity (row TV = 0.0000) and 100.0% Query Hub mass utilization.
Prior-preserving semi-relaxed annealing (THOT-SR). When many active bindings compete for fewer hubs (), relaxing column constraints on real tokens reduces marginal residuals. Standard KL-unbalanced Sinkhorn with unweighted reference kernel [4] applies the relaxation exponent to the entire dual update, , which scales down the learned log-capacity prior . To preserve the full learned capacity prior while relaxing column matching, we instead minimize the prior-preserving semi-relaxed objective using reference measure :
First-order stationarity with and yields , hence the exact fixed-point update
applied on real token columns (keeping on hubs). Applying standard unweighted semi-relaxed updates naively from Sweep 1 (Naive Semi-Relaxed OT, ) collapses under pure cross-entropy training (, 0.13% accuracy; §4.1). Preceding prior-preserving relaxation with two balanced sweeps (THOT-SR, ) preserves stability (95.57% at ) while cutting six-sweep marginal TV error from 0.0185 to 0.0102 (Table 1). Because the naive () vs. annealed () comparison changes both the schedule and , we also evaluate an intermediate annealed configuration in Table 4, which still reaches 88.54% at (97.53% at ).
| Variant | / 8K / 262K | Coll. 8K (C0/16/32/64) | Cap. 512 (R8/16/32) | |
| THOT (1+2, ReLU-Thresh, ) | 0.05 | 99.09/98.96/98.83 | 98.18/40.10/20.83/8.98 | 98.05/80.66/39.81 |
| THOT (1+2, ReLU-Unnorm, ) | 0.05 | 97.92/96.88/94.79 | 96.74/42.58/18.62/7.55 | 97.66/78.32/40.20 |
| THOT-SR (, Sparsemax) | 0.05 | 97.79/97.53/97.40 | 98.57/42.06/23.57/11.33 | 97.53/78.84/38.90 |
| THOT-SR (, Sparsemax) | 0.05 | 97.66/97.66/97.53 | 96.88/45.05/23.83/10.68 | 97.53/77.73/39.06 |
| THOT (4-Head, , Sparsemax) | 0.05 | 96.74/96.74/95.96 | 95.57/38.93/18.49/6.51 | 95.31/73.63/34.31 |
| THOT (1+2, ReLU-Thresh, ) | 0.00 | 97.92/93.49/80.60 | 93.62/35.16/18.10/7.03 | 96.74/77.67/37.57 |
| THOT-SR (, Sparsemax) | 0.00 | 98.44/97.01/95.57 | 95.70/40.23/22.53/10.03 | 97.27/76.89/39.91 |
| THOT-SR (, Sparsemax) | 0.00 | 91.93/89.19/88.54 | 90.23/36.20/20.18/9.24 | 91.28/72.14/36.52 |
| THOT (4-Head, , Sparsemax) | 0.00 | 97.01/95.44/94.14 | 95.05/36.98/15.76/6.77 | 96.09/72.98/34.67 |
| Control: Naive Semi-Relaxed OT () | 0.00 | 0.13/0.13/0.13 | 0.65/0.65/0.65/0.65 | 0.26/0.33/0.33 |
| Control: Uncentered Implicit-VJP OT | 0.05 | 0.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 thresholded ReLU (with ) sustain high accuracy at K.
Hardware-Efficient Execution: Exact One-Reference-Tile Adjoint and Split-Factor Kernels
Naive unrolled reverse-mode differentiation through Sinkhorn sweeps plus terminal row closure launches width- 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 , 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 during Sweeps 2–3 acts on the same sparse support and shares the same edge scores , each intermediate plan is an exact rank-1 diagonal rescaling of the terminal plan : . By caching the forward tail potentials —avoiding all five recomputation log-sum-exp launches—the exact reverse recurrence over Sweeps 3–2 and terminal row closure computes all marginal gradients and constructs scalar factor columns using four lightweight 1D scalar sparse matvecs (no width- payloads). Combining these with the width- terminal factors yields the exact rank- score adjoint (derived in full in Appendix § 7):
All parameter score gradients then execute in two width- sparse passes over the single reference plan (one row-major pass for and , one transposed pass for ), alongside one width- transposed pass for . On a single , 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:
Split feature and scalar-factor accumulators: Concatenating the width- factors and width- scalar factors into a single tile forces power-of-two padding up to width 128 at . Keeping them as two separate SRAM dot products—width and width (padded to 16)—halves register footprint.
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.
Dedicated 1D scalar matvecs and fused bias gradients: The four reverse-recurrence scalar passes skip vector payload tiling altogether, and the node-type bias gradient accumulates directly in registers during the row-major pass (with on the bipartite tail).
Algorithm 2: Strictly Causal Chunked THOT (Single Attention Head)
Input: Token tensors (optional position-invariant write keys ), token-local capacities , hub slots , bias , chunk size , local radius . Partition sequence into chunks.
1. Chunk-local Write OT ( hubs tokens per chunk ): With chunk score matrix and hub capacity , run 1 detached base sweep at scale () followed by 2 differentiated tail sweeps and final column closure:
with , yielding satisfying . Compute chunk moments , , and hub mass .
2. Exclusive prefix accumulation across past chunks (): Compute exclusive prefix sums (zero for ), and form normalized past hub summaries with prior weight and residual key blend :
and bounded past hub capacity ().
3. Strictly causal Read OT ( queries local past past hubs): For chunk , each query (global index ) connects to with source capacities . Initialize and run 1 detached base sweep (), 2 differentiated tail sweeps, and final row closure, where every column reduction uses an exclusive causal prefix log-sum-exp strictly over earlier queries within chunk :
with . Return .
4. Mixed-precision BF16 Tensor Cores with FP32 duals: Matrix multiplies execute on BF16 Tensor Cores with FP32 accumulation, while potentials and log-sum-exp states stay strictly FP32—analogous to mixed-precision FlashAttention [7, 27]. Against the unfused FP32 reference implementation across on (, ), worst-case maximum absolute error is (relative ) in FP32 mode and in BF16 Tensor-Core mode (and independently matches pure-JAX unrolled dense autodiff within 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 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 . (i) Its capacities depend strictly on token . (ii) Its past hub summaries aggregate only completed chunks , all of whose tokens satisfy . (iii) Its local candidate set contains only positions . (iv) Crucially, during read-side Sinkhorn sweeps inside chunk , the column potential reduces strictly over earlier queries via an exclusive prefix log-sum-exp, preventing later queries in the same chunk from altering . By induction over the finite sweeps, no intermediate state entering depends on any input at . Both adversarial future-perturbation checks across chunk boundaries and exact reverse-mode Jacobians for 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 ( or ) and evaluated zero-shot without length fine-tuning out to or . Individual per-seed outcomes and key experimental configurations appear in Appendix § 7.
Synthetic Long-Context Extrapolation, Pure Training, and Ablations
Experimental setup. We evaluate retrieval of a fixed sparse set of key-value bindings embedded among growing distractor sequences using a 2-layer MoE Transformer (, 4 experts, hubs, local radius , queries over 512 distinct keys and 256 values). Each model trains for 1,536 updates at 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 (), key-group collision stress ( competing distractors sharing a key group), and hub-capacity overload ( against hubs). Auxiliary gate supervision weight tests whether routing emerges purely from task cross-entropy ().
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 accuracy from 3.52% to 89.71% even on the legacy schedule, and adding exact row closure (*Bipartite OT (3-sweep, RC) raises recall to 97.79% () and 95.96% (). 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 , outperforming Bipartite RC on all three seeds; 97.40% at 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 : non-annealed Bipartite RC achieves stronger accuracy across all three nonzero collision levels (), whereas annealed THOT leads on clean extrapolation and hub capacity overload (). Table 4 summarizes our gate, semi-relaxed, multi-head, and negative-control ablations:
| Benchmark | Model / Variant | Per-Seed Values | Mean |
| Synthetic Recall 262K () | 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, ) | 97.66/99.61/99.22% | 98.83% | |
| THOT-SR ( / 0.88) | 96.48/98.44/97.27% — 99.22/97.66/95.70% | 97.40% / 97.53% | |
| Synthetic Recall 262K () | 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, ) | 81.25/80.08/80.47% | 80.60% | |
| THOT-SR ( / 0.88) | 98.83/99.61/88.28% — 81.64/98.05/85.94% | 95.57% / 88.54% | |
| Causal Recall 262K () | Causal THOT | 91.41/91.41/87.50% | 90.10% |
| Causal Latent Softmax | 82.81/76.95/85.55% | 81.77% | |
| Causal Hub OT (Softmax Gate) | 33.98/33.98/30.47% | 32.81% | |
| WikiText Multi-Needle 64K () | 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 + Sparsemax | 81.25/78.12% | 79.69% | |
| Support Softmax + Sparsemax | 75.00/82.81% | 78.91% | |
| FlashAttention (cuDNN, RoPE) | 1.56/0.00% | 0.78% | |
| Causal WikiText-4K LM (Intact NLL) | Causal THOT | 4.1582/4.1538 | 4.1560 |
| Causal Local Window | 4.1676/4.1736 | 4.1706 | |
| Causal Latent Softmax | 4.2122/4.2027 | 4.2074 | |
| Causal FlashAttention | 4.4043/4.3763 | 4.3903 | |
| Deep WikiText-4K MLM (Intact NLL) | THOT (1+2, Sparsemax) | 5.5678/5.5636 | 5.5657 |
| Support Softmax + Sparsemax | 5.5623/5.6016 | 5.5819 | |
| Latent Softmax + Sparsemax | 5.6093/5.6768 | 5.6430 | |
| FlashAttention (cuDNN, RoPE) | 6.3156/6.3691 | 6.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 gating: THOT (1+2, ReLU-Thresh) matches sparsemax at (98.83% at K, 80.66% at ) with zero cross-token sorting, lowering gate-only forward latency from 0.355 ms to 0.220 ms at K and from 0.709 ms to 0.596 ms at K. Without gate supervision (), however, ReLU thresholding drops to 80.60% at K, whereas sparsemax retains 97.40%.
Prior-preserving semi-relaxed annealing: Naive unweighted semi-relaxed OT () collapses completely at (0.13% accuracy). Preceding prior-preserving relaxation with two balanced sweeps (THOT-SR) restores stability at both (95.57% at 262K; strongest overload at 39.91%) and (88.54% at , 97.53% at ).
Multi-head trade-off and negative controls: Parameter-matched 4-head THOT (, , 56,651 56,688 active parameters) retains 95.96% () and 94.14% () at K, although narrower head dimension slightly lowers overloaded recall (34.31% vs. 38.41%). Across all variants, severe overload ( bindings against 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 (, , ), 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 (, , , , ), THOT (BF16 TC) runs forward+VJP 3.3× faster than cuDNN FlashAttention (1.34 ms vs. 4.37 ms).
| Geometry | Operator (Bidirectional) | Forward (ms) | Forward+VJP (ms) | Comp. Temp (MiB) |
| <br>() | THOT Kernel (BF16 TC) | 34.708 | 100.097 | 1,132.1 |
| THOT Kernel (FP32) | 111.293 | 268.897 | 1,132.1 | |
| Unfused Hub OT | 109.278 | 480.834 | 2,160.6 | |
| Latent Softmax | 42.966 | 221.889 | 4,521.3 | |
| FlashAttention (cuDNN) | 2,227.004 | 9,235.409 | 1,040.0 | |
| <br>() | THOT Kernel (BF16 TC) | 1.684 | 5.380 | 74.3 |
| Unfused Hub OT | 7.175 | 24.448 | 142.0 | |
| Latent Softmax | 5.593 | 22.964 | 292.1 | |
| FlashAttention (cuDNN) | 279.524 | 1,287.432 | 66.0 | |
| WikiText-4K Layer<br>()<br>() | THOT Kernel (BF16 TC) | 0.544 | 1.337 | 33.0 |
| THOT Kernel (FP32) | 2.186 | 5.138 | 33.0 | |
| Unfused Hub OT | 3.959 | 12.795 | 59.3 | |
| Latent Softmax | 1.045 | 4.906 | 80.8 | |
| FlashAttention (cuDNN) | 1.100 | 4.368 | 16.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 (, , ) 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 , , , 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 1,132.1 MiB). Relative to Latent Softmax, our BF16 Tensor-Core kernel is 2.22 faster forward+VJP with 4.0 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 (, , , , , bidirectional), THOT beats cuDNN FlashAttention by 2.02 forward (0.544 vs. 1.100 ms) and 3.27 forward+VJP (1.337 vs. 4.368 ms). At the full 2-layer MoE model level (, , 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.
Strictly Causal Autoregressive Benchmarks
Table 6 and Figure 3(a) summarize our autoregressive evaluations. On strictly causal associative recall (all bindings precede all queries beyond the local window radius; 32 test sequences/seed, 768 queries across 3 seeds), all models train for 1,536 steps at using an annealed auxiliary gate warmup ( linearly decayed from 1.0 to 0.0 over steps 1–256, and for steps 257–1,536). Causal Local Window fails (0.52%) and softmax-gated causal OT drops to 32.81% at K as distractors absorb 98.87% of excess capacity. In contrast, Causal THOT maintains 0.00% excess filler share and sustains 90.10% accuracy at ((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 Model | 128 → 8K → 262K | 262K Ex. Fill | Step (ms) | Intact | Blocked | Ctx Gain | Acc |
| Causal THOT | 94.27/90.23/90.10% | 0.00% | 211.41 | 4.1560 | 4.1724 | +0.0165 | 22.48% |
| Causal Latent Softmax | 83.46/82.16/81.77% | 0.00% | 151.03 | 4.2074 | 4.2330 | +0.0256 | 21.57% |
| Causal Local Window | 0.52/0.52/0.52% | 99.99% | 121.54 | 4.1706 | 4.1786 | +0.0080 | 22.33% |
| Causal FlashAttention | — | — | 126.45 | 4.3903 | 4.4137 | +0.0234 | 18.21% |
| Causal Hub OT (Softmax Gate) | 84.77/75.39/32.81% | 98.87% | — | — | — | — | — |
Table 6. Strictly causal associative recall (, 3 seeds, 768 queries; gate supervision annealed over steps 1–256) and preliminary causal WikiText-4K LM (4-layer , , 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 (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 (, 2,048-token vocabulary, , , , 4 MoE experts) on 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 () 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 (). We embed 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 (, ) sampled without replacement from real-vocabulary tokens, and each value is drawn from 256 real-vocabulary tokens that also occur naturally in the surrounding prose. Each binding appears as the 5-token span [⟨BIND⟩, , , ⟨VAL⟩, ] inside the source arc [, ], and each corresponding query appears as [⟨QRY⟩, , , ⟨VAL⟩, ⟨MASK⟩] inside the disjoint query arc [, ] (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 (). Models train for 512 steps at across two seeds (1711, 2917) and are evaluated zero-shot on 16 passages/seed (256 total queries) at and 8 passages/seed (128 total queries) at .
Table 7(left) and Figure 1(b) report the results. The short-trained () RoPE FlashAttention (cuDNN) baseline reaches 99.22% in-distribution at , 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 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 | Coll. 8K (C0/16/32/64) | Cap. 512 (R8/16/32) | ||||
| Hub OT (Softmax Gate) | 0.05 | 98.31% | 83.98% | 3.52% | — | — |
| Support Softmax | 0.05 | 12.63% | 4.17% | 0.65% | — | — |
| Support Softmax + Sparsemax | 0.05 | 38.15% | 38.02% | 38.02% | 38.80/13.02/7.29/2.21 | 36.85/18.49/8.76 |
| Latent Softmax | 0.05 | 87.24% | 85.29% | 76.30% | — | — |
| Latent Softmax + Sparsemax | 0.05 | 84.77% | 81.77% | 69.79% | 81.38/38.67/19.66/9.24 | 84.64/64.06/37.92 |
| Hub OT (4+2, Sparsemax) | 0.05 | 91.41% | 91.02% | 89.71% | 90.76/37.11/16.02/6.90 | 89.71/62.96/26.24 |
| Bipartite OT (3-sweep, RC) | 0.05 | 97.40% | 97.66% | 97.79% | 96.88/39.19/22.53/10.03 | 97.92/75.98/36.07 |
| THOT (1+2, Sparsemax) | 0.05 | 98.44% | 98.96% | 98.83% | 97.92/42.06/20.44/9.77 | 97.01/78.12/37.66 |
| Bipartite OT (3-sweep, RC) | 0.00 | 98.18% | 95.57% | 95.96% | 95.18/44.53/24.48/12.76 | 96.22/75.00/36.52 |
| THOT (1+2, Sparsemax) | 0.00 | 98.57% | 97.66% | 97.40% | 97.53/36.33/18.88/9.24 | 97.92/79.95/38.41 |
Table 3. Zero-shot distractor extrapolation (K, fixed bindings), key-group collisions (K), and capacity overload () across 3 seeds (768 queries total per condition). Bounded-support gating eliminates softmax capacity collapse (3.52%), while row-closed THOT reaches 98.83% () and 97.40% () at .
| Method | 512 → 8K → 64K | 64K NLL | Step (ms) | Intact | Blocked | Ctx Gain | Acc |
| THOT (1+2, Sparsemax) | 95.31/98.05/100.0% | 0.0514 | 174.15 | 5.5657 | 5.5808 | +0.0151 | 10.07% |
| Hub OT (4+2, Sparsemax) | 84.77/81.64/83.59% | 0.5269 | — | — | — | — | — |
| Support Softmax + Sparsemax | 81.25/79.30/78.91% | 0.7507 | 139.45 | 5.5819 | 5.7954 | +0.2135 | 9.98% |
| Latent Softmax + Sparsemax | 88.28/87.50/79.69% | 0.8376 | 136.78 | 5.6430 | 5.6663 | +0.0233 | 9.41% |
| FlashAttention (cuDNN, RoPE) | 99.22/0.78/0.78% | 8.1803 | 136.32 | 6.3424 | 6.4496 | +0.1072 | 4.07% |
Table 7. Natural-language evaluation on WikiText-103 (2 seeds). Left: Zero-shot multi-needle prose retrieval (, , trained at ; 256 queries at 512/8K, 128 queries at 64K). Right: Preliminary 4-layer WikiText-4K MLM (256 held-out docs, 640 steps, Unigram NLL 6.4788, unfused step times). Multi-Needle Prose (); 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 .
Preliminary 4-layer WikiText-4K masked language modeling. We next evaluate bidirectional 4-layer (, , , , ) models on 256 held-out 4,096-token WikiText-103 confirmation documents after 640 training steps ( masked across 1–3 word geometric spans, learning rate , 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 (, 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 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 , (ii) replacing uniform marginals with input-dependent bounded-support token capacities to eliminate distractor dilution, (iii) introducing the annealed row-closed finite-sweep schedule (and prior-preserving semi-relaxed variant), (iv) deriving an exact rank- 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 -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 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 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 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 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- reference-tile passes.
Limitations, Reproducibility, and Conclusion
Limitations. We highlight five boundaries of the current study:
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.
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).
Fixed-binding retrieval vs. information capacity scaling: Our 262K extrapolation benchmarks hold relevant bindings fixed while expanding distractors; under hub overload ( vs. ), recall falls to 38%–40%. Scaling , , and jointly remains important future work.
Preliminary LM scale and dense baseline diagnostics: Our WikiText-4K experiments use compact 4-layer (, , 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.
Variant trade-offs: Sorting-free thresholded ReLU relies on to match sparsemax at 262K (98.83% vs. 80.60% at ), 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 .
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 annealed row-closed Sinkhorn schedule, an exact rank- 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 distractor collapse (3.52% 97.40% pure cross-entropy recall at ), while operator microbenchmarks show linear-time bidirectional OT surpassing cuDNN FlashAttention already at (1.34 vs. 4.37 ms) and running 2.2 faster than latent softmax at . 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 annealed row-closed operator in Algorithm 1 ( differentiated bipartite tail sweeps with , following a detached aperiodic warm-start potential ). Let and denote active rows and columns, with .
Forward states cached for backward. In Algorithm 1, Sweeps iterate from under the bipartite edge scores :
followed by exact row closure , terminal plan , unnormalized aggregate , and row-stochastic attention output . Forward execution caches (total storage scalars per head plus ), eliminating all five recomputation log-sum-exp passes during backward.
Step 1: Quotient normalization and terminal value pass. Given upstream loss gradient , differentiating yields the unnormalized aggregate cotangent together with the direct normalization marginal contribution . Differentiating gives the value gradient via one width- transposed sparse pass:
and nonzero terminal log-potential sensitivities
with direct score gradient .
Step 2: Terminal row-closure reverse step. Differentiating using yields
and adds the rank-1 score contribution (note that , confirming that row-stochastic has zero net direct sensitivity to outside the tail sweeps).
Step 3: Exact reverse recurrence through Sweeps . Define the intermediate plans (whose column sums satisfy ) and (whose row sums satisfy ). For and then (noting on entry since are unused outside their own sweep):
where is detached so no propagation past is required. Each sweep contributes to the edge score adjoint . Across Steps 2–3, the entire vector recurrence requires only four lightweight 1D scalar sparse matvecs: , , , and .
Step 4: Exact diagonal-rescaling factorization onto . Crucially, because intermediate plans and differ from the terminal plan on , their score contributions do not collapse to a rank-2 additive row-plus-column term . Instead, every intermediate plan is an exact rank-1 diagonal rescaling of :
where mean potential shifts and cancel identically inside the product while preventing floating-point overflow. Collecting the terminal row-closure term and the rescaled tail terms into two factor matrices
the exact total edge score adjoint across row closure and Sweeps 2–3 is
Hence (together with fused node-type bias sums , clamping ) and execute in two width- split-factor sparse passes over the single reference plan (down from 12 width- score-gradient passes in naive unrolled differentiation). In our GPU verification on (, ), this exact custom VJP matches the unfused reference implementation to max absolute error ( relative ) in FP32 and in BF16 Tensor-Core mode, and matches pure-JAX unrolled dense autodiff within in FP32 across all six input gradients (, , , , , ).
Experimental Configurations, Per-Seed Results, and Stabilization Notes
| Benchmark | Configuration, Schedule, and Evaluation Details |
| Hardware / Software | NVIDIA 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 Recall | 2-layer MoE (, 4 experts, hidden 48), , , , bindings/queries; AdamW, 1,536 steps at , 3 seeds (1711, 2917, 4129); evaluated on 32 held-out sequences/seed (256 queries/seed, 768 total) |
| Kernel Microbench | Standalone bidirectional attention operators; BF16 (, , ) 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 Recall | Same 2-layer MoE backbone (, , , ), 1,536 steps at , cosine LR (peak ), gate supervision linearly annealed 1.0 0.0 over steps 1–256; 3 seeds, 32 sequences/seed (768 queries) |
| Causal WT-4K LM | 4-layer MoE (, , , , , ), AdamW (lr = , , weight decay 0.01, cosine schedule), , 512 steps, 2 seeds (1711, 2917), evaluated on held-out confirmation split |
| WikiText Prose Needles | 4-layer (, , , , ), needles, , 512 steps at (lr = ), 2 seeds (1711, 2917); evaluated on 16 passages/seed (256 queries) at 512/8K and 8 passages/seed (128 queries) at 64K |
| WikiText-4K MLM | 4-layer (, , , , ), AdamW (lr = , ), , 640 steps, 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 ( backward Jacobian amplification), triggering global gradient-norm clipping; (ii) applying scaling after unit-norm embeddings doubly attenuated output logits by ; (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 (, base 10,000), and 1–3 word geometric masking spans uniformly addresses all four issues across every baseline and THOT model.
References
- [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]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]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]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]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]Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. In Advances in Neural Information Processing Systems, volume 26, 2013.
- [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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]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]Richard Sinkhorn and Paul Knopp. Concerning nonnegative matrices and doubly stochastic matrices. Pacific Journal of Mathematics, 21(2):343–348, 1967.
- [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]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]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]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]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]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]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]Mitchell Wortsman, Jaehon Lee, Justin Gilmer, and Simon Kornblith. Replacing softmax with ReLU in vision transformers. arXiv preprint arXiv:2309.08568, 2023.
- [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]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]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]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]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


