Christoffel-Balanced Sparse Attention
Implementation & benchmark of arXiv:2609.01270 — Farey Structure in Modulo Krinkle Tilings: Mediant Splicing and Generation of Prototiles from a Single Edge
Source paper: Farey Structure in Modulo Krinkle Tilings: Mediant Splicing and Generation of Prototiles from a Single Edge arXiv:2609.01270 ⓘ · analyzed Sep 2, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace a dense or ad hoc sparse attention pattern with a circulant mask generated by the paper's carry word c(m,k). Every query attends to exactly m of k relative positions, and the selected positions are prefix-balanced, avoiding the large gaps and collisions produced by random sparsification. Use several Farey-related slopes across heads or layers to combine local, medium-range, and long-range coverage.
Formulas
Mathematical statement
For a reduced fraction m/k with 0 < m < k, the paper defines the direction permutation s_j = jm mod k and the carry word c(m,k) = (c_0,...,c_{k-1}), where c_j = floor(((j+1)m)/k) - floor((jm)/k) is either 0 or 1. Therefore the word contains exactly m ones, and every prefix of length r contains floor(rm/k) ones, so its discrepancy from the ideal allocation rm/k is less than one. The paper identifies c(m,k) as a lower Christoffel word and organizes coprime parameters through Farey mediants. Its canonical parent denominator is k_1 = m^{-1} mod k, with m_1 = (m k_1 - 1)/k and (m_2,k_2) = (m - m_1, k - k_1). We use the exact carry-word formula to define relative attention offsets. For a sequence of length L and period k, the mask is M_{i,j} = 1 when c_{(j-i) mod k}(m,k) = 1, subject to causal or bidirectional constraints.
Implementation notes
Integrate the construction at the attention-logit stage of a decoder or encoder Transformer. Choose a period k dividing the target context length and choose a reduced density m/k, such as m = 64 and k = 512 or m = 128 and k = 1024. Compute the Boolean vector with c[j] = floor((j+1)*m/k) - floor(j*m/k) using integer arithmetic or high-precision arithmetic, then precompute the allowed relative offsets O = {j: c[j] == 1}. For query position i, form the key indices from these offsets, retain only indices satisfying the causal condition j <= i for a decoder, and compute logits, softmax, and the value sum only on those keys. Pseudocode is: for j in 0..k-1: c[j] = floor((j+1)*m/k) - floor(j*m/k); O = where(c == 1); for each query i: J = [i + offset for offset in O if 0 <= i + offset < L and, if causal, i + offset <= i]; logits = Q[i] @ K[J].T / sqrt(d); A = softmax(logits); Y[i] = A @ V[J]. For a production implementation, avoid materializing an L by L mask and write or adapt a block-sparse kernel that gathers the m allowed offsets for each query block. For bidirectional attention, use signed offsets or combine two masks generated by slopes m/k and (k-m)/k. The mathematical quantities computed exactly are the carry word, its m selected offsets, and its prefix-balance guarantee. The engineer must estimate empirically whether this balance improves connectivity and optimization; measure graph reachability across layers because a single periodic mask may create undesirable residue classes. Begin with a 12-layer, 256-dimensional Transformer on WikiText-103 or a synthetic long-range copying task at context length 2048. Compare dense attention, a contiguous local window with the same number of edges, random m-edge attention, fixed strided attention, and the Christoffel mask. Keep parameter count and attention-edge count equal. Measure validation perplexity, loss versus training FLOPs, wall-clock throughput, peak memory, and accuracy on long-range copying or retrieval. The method succeeds if it matches or improves perplexity while reducing attention memory and compute, or if it gives faster loss descent at equal sparse-attention FLOPs. Also inspect attention-reachability, offset histograms, and gradient norms to detect disconnected or overly periodic behavior.
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.