Exact-Distance Landmark Attention
Implementation & benchmark of arXiv:2607.29648 — Exact-Distance Domination in Grid Graphs
Source paper: Exact-Distance Domination in Grid Graphs arXiv:2607.29648 ⓘ · analyzed Aug 31, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace dense spatial attention on a 2D feature grid by attention from every non-landmark token to a small periodic set of landmark tokens. Choose landmarks using the paper's residue construction so that every non-landmark token has at least one landmark exactly k Manhattan steps away. Use this guaranteed edge as a sparse global-information route, combined with a cheap local convolution or residual path for accuracy.
Formulas
Mathematical statement
Let k >= 2, s = 2k+1, L = 2k-2, and M = 2(3k^2-k-1). The paper constructs a model coverage region C_k of size |C_k| = M and labels lattice coordinates by phi_k(x,y) = x + s y modulo M. The selected residue set is R_k = {0,s,2s,...,(L-1)s} as a subset of Z/MZ. For a shift t, the infinite-grid landmark set is D_infinity(t) = {z in Z^2 : phi_k(z) is in t+R_k}. Proposition 4.5 guarantees that every vertex not in D_infinity(t) has a landmark at Manhattan distance exactly k. The landmark density is |R_k|/M = (k-1)/(3k^2-k-1). On an n by n finite grid, define the boundary strip partial_k G_n = {(i,j): min(i,j,n+1-i,n+1-j) <= k}, include that strip as landmarks, and apply the residue rule only to the interior: D_t = partial_k G_n union {(i,j) not in partial_k G_n : phi_k(i,j) is in t+R_k}. Lemma 4.6 guarantees exact-distance k coverage for every non-landmark interior token.
Implementation notes
Integrate this as a sparse cross-attention layer over an H by W image or spatial feature map, before or instead of dense self-attention. First choose k, usually 3 or 5, and one or several shifts t in {0,...,M-1}. Precompute a Boolean landmark mask using the exact residue formula; mark the width-k boundary strip as landmarks. For every interior non-landmark position v=(i,j), enumerate the finite offset set Delta_k = {(a,b): |a|+|b|=k}, retain offsets for which v+(a,b) is in bounds and belongs to D_t, and store one or all resulting indices q in N_k(v) intersected with D_t. The paper's lemma guarantees this list is nonempty. Compute keys and values only for landmarks. For each query token, gather its stored landmark indices and apply the sparse attention equation above, then add the result through a residual projection. Process landmark tokens with local convolution or a small global attention block. A practical variant uses different shifts t in different heads and concatenates their outputs. The residue mask, offset table, and coverage guarantee are computed exactly; no learned estimator is needed. Validate first on CIFAR-100 or ImageNet-32 with a 32 by 32 ViT. Compare dense attention, 7 by 7 local attention, and this layer at matched hidden size. For k=3, the asymptotic landmark fraction is 4/46, approximately 8.7 percent, so landmark key/value memory should be roughly 11 times smaller than dense key/value memory. Success means equal or better validation accuracy at lower attention FLOPs and peak memory.
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.