Decision-aware stopping for sparse attention: an oracle-bound pilot
Q100 research note · December 2026 · Synthetic pilot
Abstract
Can a decoder stop inspecting the key–value cache once omitted attention terms provably cannot change a greedy token decision? This note describes a sufficient, pairwise-margin condition and tests it on a synthetic model with one softmax attention head and a linear vocabulary readout. In 300 deterministic, randomly generated cases, the sparse rule selected the same argmax as dense evaluation. It stopped before reading all value pages in 95/100 sharp-score cases, 89/100 low-variance-value cases, and 0/100 baseline random cases. Average value pages examined were 71.0%, 72.2%, and 100%, respectively. The test has an oracle page-score bound that scans every key. It is a feasibility diagnostic rather than evidence of an inference speedup. The code implements floating-point approximations and is not a sound floating-point certificate.
Setting and stopping rule
For one query and a fixed prefix, let the full attention output be y = sum_i exp(s_i)v_i / sum_i exp(s_i), with scores s_i = q·k_i. Let S be inspected positions. Compute their exact partial softmax output y_S, log normalizer log Z_S, and approximate logits z_S = W y_S + b. The readout W is linear and includes any fixed affine contribution b. All vocabulary entries are evaluated.
For every uninspected page P, suppose U_P is a sound upper bound on its largest score, μ_P is the mean of its value vectors, and r_P upper-bounds their Euclidean distance from μ_P. Let U = sum_P |P| exp(U_P), α = U/(Z_S + U), and D = max_P (||μ_P − y_S||₂ + r_P). Then the omitted softmax mass is at most α and the difference ||y − y_S||₂ is at most αD.
Write a for the largest entry of z_S. For each rival b, let d_b = W_a − W_b. If
z_S[a] − z_S[b] > α D ||d_b||₂
holds for every rival, then a is the unique greedy winner of the full linear readout in exact arithmetic. This follows from Cauchy–Schwarz applied to the difference between the full and partial margins. If the strict condition fails, read another page. At full evaluation return the dense winner with the same tie policy.
The bound depends on a fixed query, fixed keys and values, and a linear readout. It does not certify a general transformer with earlier approximations, nonlinear final normalization, multiple heads, sampling, or later autoregressive steps. A real-number argument does not account for rounding in a floating-point kernel.
Experiment
We create 1,024 keys in 32 pages, key/value dimension 16 and a 12-way readout. We generate 100 cases for each regime using NumPy’s generator with seed 603. The sharp-score condition multiplies q by five. The value-aligned condition multiplies all randomly generated V entries by 0.08, creating low value variance. We compute the exact maximum score in every page, inspect pages from highest to lowest, and apply the stopping condition after each page. This oracle scan evaluates every q·k in advance. The reported metric is therefore the share of value pages visited after the scan, not the share of all keys read or a runtime saving.
| Synthetic regime | Cases | Early stops | Mean value-page fraction |
|---|---|---|---|
| Random | 100 | 0 | 100.0% |
| Sharp scores | 100 | 95 | 71.0% |
| Low-variance values | 100 | 89 | 72.2% |
The complete record of page counts and dense margins is provided in the reproduction download. The original code uses the conservative sum of the largest page-center distance and the largest radius; this can be looser than the maximum page-wise sum in the derivation. It also precomputes value-page summaries from all values. In addition, the synthetic readout bias standard deviation is 0.8 for the two modified regimes versus 0.2 in the random regime. The comparison therefore does not isolate the effect of sharp scores or low value variance. All 300 selected tokens matched the independently computed dense argmax. This small experiment checks the implementation on its generated inputs. It does not establish the numerical safety of all floating-point executions.
Relation to existing work
These results are a diagnostic, not a novelty claim. Calver’s work bounds error for quantized attention with precision fallback. Li derives probabilistic stopping criteria for sparse attention output error, and likewise reports a scan that reads every key. Singh and Mittal relate omitted softmax mass to error bounds, and Sharif gives a greedy output-margin certificate under bounded logit error. None of these references is used as evidence that this pilot is the first to combine a margin rule with attention sparsity.
- Dean Calver, Runtime-Certified Bounded-Error Quantized Attention.
- Runguo Li, Certified Sparse Attention via Perturbed Retrieval.
- Munish Singh and Namita Mittal, Tail-Mass Law for Softmax Attention.
- Raza Sharif, The Reproducibility Criterion for Machine-Generated Evidence.
Reproduce the pilot
Download the original experiment
and recorded outputs. The archive contains test.py and
the seed-603 per-trial output. From the extracted directory, using
Python 3.10+ with NumPy and SciPy:
mkdir -p attention06-public
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 python3 test.pyThe Q100 publication check reran the original code and reproduced all 300 per-case page counts and selected-token agreements. Dense margins matched to absolute tolerance 10⁻¹². This is a local rerun of the original experiment, not a separate external replication.
What changes without the all-key oracle?
In two follow-up controls I reused 100 sampled base inputs, crossing three regimes with two readout-bias scales for 600 paired cases per control. The first control kept the original oracle and varied the bias magnitude. With low-variance values, the mean fraction of pages read changed from 94.47% at bias standard deviation 0.2 to 67.34% at 0.8. A large part of the apparent saving therefore depended on the readout bias in this setup.
The second control replaced exact page maxima with conservative, query-independent page summaries: a center and radius, per-coordinate minima and maxima, or the tighter of the two bounds. It also tested ranking pages by center score while keeping the tighter bound. All five variants, including the reference oracle, matched the dense greedy choice on every case. Dense scores were computed as a separate test reference, not used to choose pages or certify stops in the summary methods.
- Sharp attention: at the two bias scales, the oracle read 77.31% and 72.94% of pages on average. Each summary variant read all pages at both scales.
- Low-variance values, higher bias: the tighter bound with upper-bound ranking read 86.78% of pages, compared with 67.34% using the oracle.
- At the lower bias, none of the summary variants skipped pages in any of the three regimes. At the higher bias they skipped pages only in the low-variance regime.
These are synthetic page counts, not timing measurements. The page summaries must still be constructed and stored, and the comparison excludes their overhead. The result shows how much the all-key oracle contributed on these fixtures; it does not rule out tighter summaries or establish useful savings in a trained transformer.
Download both follow-up scripts, per-case results, and run instructions. See the public bias discussion and key-summary update.
Questions for further work
Can a query-dependent score bound be computed without a full key scan and remain tight enough to certify early decisions on actual LLM KV caches? Can a pairwise output-margin bound retain useful information through the final normalization and multiple heads? When index construction, updates, floating-point safety and bandwidth are included, does any implementation beat a current dense attention kernel?
The available results support investigating these questions. They do not demonstrate a deployable speedup or a previously unknown algorithm.