Spectral-gap adaptive Sinkhorn attention
Implementation & benchmark of arXiv:2608.11760 — Tight Nonasymptotic Local Convergence of Sinkhorn-Knopp
Source paper: Tight Nonasymptotic Local Convergence of Sinkhorn-Knopp arXiv:2608.11760 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace the fixed number of Sinkhorn iterations used to normalize an attention kernel with a per-example stopping rule based on the local spectral contraction factor. Estimate the remaining marginal error geometrically and stop early on easy examples while retaining extra iterations on difficult or nearly disconnected examples.
Formulas
Mathematical statement
The paper gives the asymptotic local convergence rate of Sinkhorn-Knopp as 1-\sigma_2, where \sigma_2 is defined by $$1-\sigma_{2}\coloneqq\lambda_{m-1}(P^{-1/2}A^{\star}Q^{-1}(A^{\star})^{\top}P^{-1/2}).$$ Here A^{\star}\in\mathbb{R}_{+}^{m imes n} is the optimally scaled matrix with row marginal p\in\mathbb{R}_{+}^{m}, column marginal q\in\mathbb{R}_{+}^{n}, P=\operatorname{diag}(p), Q=\operatorname{diag}(q), and \lambda_{m-1} denotes the second-largest eigenvalue under the paper's eigenvalue ordering. The dominant eigenvalue is associated with the stationary scaling direction; the remaining local error contracts approximately by \rho=1-\sigma_2. For an attention kernel A=\exp(S/ au), Sinkhorn alternately updates row and column scalings u,v so that X=\operatorname{diag}(u)A\operatorname{diag}(v) has prescribed marginals. Use the residual ratio \widehat{\rho}_k=\|r_k\|/\|r_{k-1}\| as an online estimate of the local contraction, where r_k concatenates row and column marginal errors. The predicted future residual after j more iterations is \|r_{k+j}\|\approx\widehat{\rho}_k^j\|r_k\|.
Implementation notes
Integrate this into the Sinkhorn normalization branch of an attention layer, immediately after attention logits S are converted to a positive kernel A=exp((S-c)/tau), where c is the per-row maximum used for numerical stability. Assume square sequence attention first, with p=q=1/L for sequence length L; for rectangular cross-attention use uniform marginals with equal total mass. Initialize u=v=ones and perform alternating updates in log-space: log u <- log p - log(A v) and log v <- log q - log(A^T u), using logsumexp rather than explicit division. After every two updates, construct the row and column marginal residuals r_k; do not materialize extra matrices beyond the current normalized attention X. Compute the residual ratio rho_hat from consecutive residual norms, smooth it with rho_ema <- 0.8 rho_ema + 0.2 rho_hat, and estimate the remaining iteration count from j_pred=ceil(log(eps/||r_k||)/log(rho_ema)). Continue until either ||r_k||<=eps or the configured maximum iteration count is reached. Require at least two iterations before early stopping, clamp rho_ema to [0.05,0.999], and reject a prediction if the residual increased. The exact mathematical quantity is rho=1-sigma_2; sigma_2 can optionally be estimated on a small subsampled kernel by 5-10 power iterations on B=P^{-1/2}XQ^{-1}X^T P^{-1/2}, while the MVP should use residual ratios as a cheaper proxy. First test on a small 4-8 layer Transformer trained on WikiText-2 or a synthetic assignment task, comparing fixed 10/20 Sinkhorn iterations against adaptive stopping at equal output tolerance. Measure average iterations, normalization FLOPs, marginal residual, training loss, validation perplexity, and gradient-norm variance. Success means at least 25% fewer average iterations at the same residual tolerance with no degradation in perplexity or assignment accuracy; stability is indicated by fewer residual spikes and NaNs at low attention temperature.
Verification
This idea has not been verified yet.
Verification happens in two stages: Stage 1 — a mechanism check on a toy system confirms the claimed mathematical phenomenon reproduces; Stage 2 — a benchmark implements the idea on a real (small) neural network task and compares it against a tuned baseline over 8 paired seeds with a permutation test.
Artifacts
Artifacts unavailable.