Skip to content

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

Dylan Forde

cs.LG

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.

Create a lesson