Long context models achieve faster, more precise information retrieval
Topology Hub Optimal Transport: Eliminating Long Context Dilution at Flash Speed
Machine Learning
Summary
Long-context models struggle to find important details when they consider very large amounts of information, because the attention they pay to each bit gets spread too thin. The authors present a new method called Topology Hub Optimal Transport (THOT) that uses a specialized graph structure and efficient computations to focus attention only where it matters, even across extremely long sequences. Their approach preserves accuracy very well and runs much faster than existing methods on modern hardware. This helps machines better understand and retrieve relevant facts within massive texts without confusion from distractions.
What this means in practice
- •For natural language processing engineers: Improve long document understanding in language models by enabling precise retrieval of relevant facts from very large texts at high speed and low memory cost.
- •For machine learning infrastructure teams: Deploy efficient GPU kernels for attention that scale up to hundreds of thousands of tokens without slowing training or inference.
Authors
Dylan Forde
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 \times L$ matrix with a linear-size graph over local windows and $K$ 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(L\log L)$) or sorting-free token-local thresholded ReLU ($O(L)$), driving excess distractor mass to zero; (2) a three-sweep $1+2$ annealed row-closed Sinkhorn schedule that damps bipartite residuals; (3) an exact rank-$(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=128$ reaches 97.40% zero-shot recall of fixed bindings at $L=262{,}144$ under pure task loss ($α=0$) and 98.83% at $α=0.05$ (matched by $O(L)$ thresholded ReLU at $α=0.05$, vs. 80.60% at $α=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=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{,}096$; multi-layer LM runs use the unfused path. Zero-shot WikiText-103 multi-needle retrieval hits 100.00% (128/128 queries at $L=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.