A language model spends a surprising share of its decoding time on one step: scoring every word in its vocabulary. A model with a 256,000-token vocabulary must stream a 256,000-row matrix from memory to produce each next token, and in small models this output layer can take more than 85% of inference latency (Navigating with Graph Representations for Fast and Scalable Decoding of Neural Language Models). Existing speedups pursue two strategies. Some re-search the vocabulary at every step with a nearest-neighbour index, which works on CPUs but stalls on GPUs and in large batches. Others fix a shortlist once per input and accept quality loss when the text drifts. Portfolio managers face the same dilemma. Rebalancing every period chases noise and pays fees each time. Never rebalancing drifts away from the target. The known answer is a no-trading zone: keep the current holdings until the gap to the ideal portfolio is large enough to justify paying the cost of trading.
We propose to treat the set of candidate tokens the model scores at each step as a portfolio. Adding new token rows costs memory bandwidth, like a trading fee. Carrying irrelevant rows costs compute, like holding cost. Missing the right token costs quality, like tracking error. The decoder holds a compact dense block of active output rows. It rebuilds that block only when a cheap certificate says the hidden state has left the block's zone of validity. The certificate bounds how much probability the excluded tokens could hold. Because the block is a contiguous dense matrix, scoring it is an ordinary GPU-friendly matrix multiply rather than pointer-chasing search. Because rebuilds are rare and shared across a batch, the batch-size collapse reported for per-step retrieval should not occur. The third direction, dataset transparency, enters as a reporting requirement. How often rebuilds fire depends heavily on the text domain, so speedup claims need a documented account of the corpus and hardware they were measured on.
Core Claim
Picking output candidates during decoding is an online allocation problem with switching costs, and it should be solved with the tools built for that problem. The relevant tools are the total-regret objective with turnover cost from online portfolio optimization (Dealing with transaction costs in portfolio optimization: online gradient descent with momentum) and threshold "inaction region" policies from impulse control (Transaction Costs-Aware Portfolio Optimization via Fast Lowner-John Ellipsoid Approximation; Concentrated Liquidity Provision: a Reinforcement Learning Perspective).
At step $t$ the decoder holds an active set $S_t$ of token rows and pays
$$ J = \sum_{t=1}^{T} \Big[ \mathrm{KL}\big(p_t \,\|\, p_t^{S_t}\big) + \mu\,|S_t| + \lambda\,|S_t \setminus S_{t-1}| \Big]. $$
Here $p_t$ is the full-vocabulary next-token distribution and $p_t^{S_t}$ is the distribution renormalized over the active set. The constant $\mu$ is the measured per-row scoring cost and $\lambda$ is the measured per-row cost of gathering a new row into the dense block. Both are calibrated in seconds on the target hardware, so the trade-off is physical rather than a free hyperparameter.
The two existing families are the endpoints of this objective. Setting $\lambda = 0$ gives per-step retrieval, as in Accelerating LLM Inference via Vector Index Based Output Embeddings. Setting $\lambda \to \infty$ gives the frozen per-input shortlist of On Using Very Large Target Vocabulary for Neural Machine Translation. The claim is that intermediate, cost-calibrated policies beat both on wall-clock latency at matched distributional fidelity. The claim matters most for batched GPU decoding, where neither endpoint works well today.
Research Program
The mechanism has three parts.
The certificate. Offline, we cluster the output embedding rows into $C$ groups, a few hundred of them. For each group we store its centroid $m_c$, its radius $r_c$, and its size $n_c$. Any token $w$ in cluster $c$ then satisfies $w^\top h \le m_c^\top h + r_c\|h\|$. Summing over the clusters that lie wholly outside $S_t$ gives an upper bound on the excluded exponentiated logits. Dividing by the active-set partition function bounds the probability mass the decoder is ignoring. The bound costs $O(Cd)$ per step. It plays the role of measured drift from the target portfolio.
The policy. The decoder keeps $S_t$ unchanged while the bound stays under a threshold $\tau$. This is the inaction region. When the bound crosses $\tau$, it rebuilds the block. It adds the rows of the highest-bound clusters, or HNSW-retrieved candidates as a second option. It evicts rows whose smoothed usage score has decayed. The smoothing is a momentum filter in the spirit of the OGDM update of Vittori et al., which damps oscillation from noisy steps.
The threshold $\tau$ and the eviction rate are chosen to minimize $J$ on calibration text. As a cheaper geometric variant, we also fit a minimum-volume ellipsoid around hidden states seen since the last rebuild, following the Löwner-John approximation of Shen and Wang. A rebuild fires when $h_t$ exits it. Comparing the ellipsoid trigger with the bound trigger tells us whether hidden-state geometry alone suffices.
Batches. In a batch, the block is shared across sequences, and each sequence's rebuild cost is a share of one gather. Loretz and Hochreiter report that per-step retrieval loses its savings once batch size exceeds 32, because the union of per-sequence candidates covers much of the matrix. Our objective prices that union explicitly through $\mu|S_t|$.
The transparency component. It is deliberately narrow. For every domain we evaluate, we publish a decoding datasheet that extends the lifecycle questions of Datasheets for datasets to inference cost. The datasheet records the corpus source and filtering, the tokenizer, the measured $\mu$ and $\lambda$ for each hardware target, the rebuild rate, the mean active-set size, and the certified versus realized excluded mass. Two precedents motivate this. FineWeb showed that curation choices change downstream behaviour in counterintuitive ways (The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale). Soft Latent Thinking showed that compact output bases tuned on math collapse on code (A Model with No Head and Many Thoughts). Our hypothesis is that output-layer speedups are similarly domain-bound, and that headline numbers are currently reported without the information needed to tell.
Baselines
The naive reference is the exact dense output projection, run in the same inference stack, at the same precision, on the same hardware. It defines quality: zero KL and identical greedy tokens. It also defines the latency denominator.
The strongest existing method is HNSW-indexed output embeddings from Accelerating LLM Inference via Vector Index Based Output Embeddings. It retrieves candidates every step and computes special tokens exactly. On Gemma 3 270M it reports an 82% end-to-end speedup, up to 12x output-layer speedup, more than 99% recall@2 at search depth ef=200 on a 20k-token Wikipedia subset, and AlpacaEval win rates near 50% against the dense head. We will run it at the paper's ef=200 and tune ef over the same grid size we use for $\tau$. Comparisons use the same model, prompts, and CPU and GPU machines. Beating it means one of two things. Either we match its realized excluded mass with lower end-to-end latency at batch size 1 on CPU, or we keep a speedup at batch sizes 32 and 64 on GPU, where its savings are reported to erode.
The second strong baseline is a frozen per-input shortlist, after Jean et al. It contains the top frequent tokens plus tokens retrieved from the prompt, built once and never updated. On WMT'14 En-Fr that paper reports 34.11 BLEU for its large-vocabulary single model and removes the roughly 5x decoding overhead. We will give it the same total row budget as our method.
A third baseline is fast graph decoding (Navigating with Graph Representations for Fast and Scalable Decoding of Neural Language Models) on IWSLT'14 De-En. It reports a 14x speedup with virtually no BLEU loss.
Three ablations isolate the key ingredient, the switching-cost term:
- Our policy with $\lambda = 0$, which rebuilds whenever any change helps.
- Our policy with fixed-interval rebuilds every $k$ tokens. This mirrors the fixed rebalancing schedules that DeepAries improved on (DeepAries: Adaptive Rebalancing Interval Selection for Enhanced Portfolio Selection).
- The ellipsoid trigger versus the certificate trigger.
Why not just…?
Why not just quantize the output matrix to 4 or 8 bits? Quantization shrinks the bytes per row but still touches all $|V|$ rows every step. Loretz and Hochreiter treat it as orthogonal to candidate selection, and Zhang et al. show dense projection time growing linearly with vocabulary regardless. We will stack INT8 output weights on both the dense baseline and our method. If quantization alone closes most of the gap, the result is still informative, and we will say so.
Why not just freeze a per-prompt shortlist? This is the real threat, because it pays no rebuild cost at all. If the certificate rarely fires on short prompts, our method reduces to it. The experiment settles the question directly. We plot the frozen shortlist at equal row budget against our method as generation length grows from 128 to 2,048 tokens and across domains. The prediction is that the frozen list's realized excluded mass grows with length and topic drift while ours stays bounded. If it does not grow, we report that the simple method suffices for that regime.
Why not just add an LRU cache on top of per-step retrieval? A least-recently-used cache still pays for a search every step, which is the cost that fails on GPUs. Recency is also a weaker eviction signal than smoothed usage. The fee literature (A Linearly Convergent Proximal Subgradient Algorithm for Sparse Portfolio Optimization with Transaction Cost) shows that heuristic turnover control without an explicit cost model collapses as fees rise. We include LRU-over-HNSW as an additional run.
Why not just use a smaller vocabulary? Smaller vocabularies lengthen sequences and hurt quality. Dynamic phrase vocabularies cut normalized length from 127.72 to 101.38 and raised MAUVE from 20.47 to 25.69 on WikiText-103 (Generation with Dynamic Vocabulary). Our method keeps the large vocabulary's expressiveness while paying only for the rows in use.
Proposed Experiments
Model and data. We use Gemma 3 270M, matching the strongest baseline, and a Qwen-family model with a vocabulary of roughly 150k. Evaluation text is drawn from FineWeb samples (HuggingFaceFW/fineweb), WikiText-103, AlpacaEval prompts, and HumanEval-style code. Translation results use IWSLT'14 De-En and WMT'14 En-Fr.
Metrics. We measure:
- realized KL to the full distribution and the certified excluded-mass bound;
- greedy token agreement;
- perplexity, and BLEU on translation;
- AlpacaEval pairwise win rate against the dense head;
- rows gathered per token, which is the "turnover";
- end-to-end latency at batch sizes 1, 8, 32, and 64, on both a CPU and a GPU.
First decisive check. The cost-calibrated policy should strictly dominate both endpoints ($\lambda=0$ and frozen shortlist) on the latency-versus-KL frontier on GPU at batch size 32 or more. If it does not, the portfolio analogy buys nothing.
Second decisive check. Is the certificate sound and tight enough to use? Realized excluded mass must never exceed the bound. The bound should fire within a small factor of the oracle rebuild rate, meaning the rate an oracle with the full softmax would choose.
Third check. Do $\tau$ and $\mu/\lambda$ tuned on FineWeb hold up on code and multilingual text, or do rebuild rates and speedups shift sharply? A sharp shift would confirm that output-layer efficiency claims need the domain and hardware documentation we propose, much as Fell et al. found that undocumented preprocessing made pathology results irreproducible (Reproducibility of deep learning in digital pathology whole slide image analysis).
No result on batched GPU decoding with candidate-set methods beyond batch 32 was found on Lacuna. That regime is where our first check is decided.
References
- Navigating with Graph Representations for Fast and Scalable Decoding of Neural Language Models
- Dealing with transaction costs in portfolio optimization: online gradient descent with momentum
- Transaction Costs-Aware Portfolio Optimization via Fast Lowner-John Ellipsoid Approximation
- Concentrated Liquidity Provision: a Reinforcement Learning Perspective
- Accelerating LLM Inference via Vector Index Based Output Embeddings
- On Using Very Large Target Vocabulary for Neural Machine Translation
- Datasheets for datasets
- The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale
- A Model with No Head and Many Thoughts
- DeepAries: Adaptive Rebalancing Interval Selection for Enhanced Portfolio Selection
- A Linearly Convergent Proximal Subgradient Algorithm for Sparse Portfolio Optimization with Transaction Cost
- Generation with Dynamic Vocabulary
- Reproducibility of deep learning in digital pathology whole slide image analysis