cs.DSJul 29, 2026

Memoization Without Keys: Compact, Out-of-Core Tables for Functions of Sorted Arguments

Authors: Tamal Maharaj

Abstract

Memoizing an expensive function of a sorted score vector is a data-structure problem before it is a numerical one: at a billion gridpoints, a hash map or a search tree spends most of its space on keys the grid already determines. We describe an implemented memo table that stores none. An entry's address is computed in closed form from the sorted argument itself, so NN values occupy NN slots, the argument is recoverable from the index, and the table can be memory-mapped and served from a file larger than RAM. Against a chained hash map it uses 5.7×5.7\times less memory at 3737M entries and 10.2×10.2\times less at 1.91.9B, answers queries up to 2.9×2.9\times faster and builds up to 250×250\times faster; on 64 threads its construction needs no coordination; a sharded hash gains only 1.17×1.17\times. Against an open-addressing table with inline keys it is 44--7×7\times smaller and 100×100\times faster to build but 1.5×1.5\times slower to query, a deficit we trace to the O(d)O(d) index arithmetic. At 2222 GB on a 1616 GB desktop it serves each query in one disk access, where no key-storing container can be built; and its order-preserving addressing keeps a perturbation workload on the same pages that a hashed layout scatters. The closed form exists because the key set is the multiset combinations, whose index is the combinatorial number system. Memoizing Plackett--Luce normalization runs 2525--55×55\times faster than Newton's method; memoizing αα-entmax thresholds does not pay. The contrast says when this structure is worthwhile.

Explore similar work

Aug 31, 2026cs.CL

What It Costs to Compose, Rebuild, and Correct Precomputed Memory

Language models can answer from precomputed memory, a model's saved reading of a body of material, reused across requests instead of read again at each. This paper maps where that practice preserves correctness and the conditions under which it fails. Across experiments on Llama-3.1-8B-Instruct using both saved key-value caches and trained compressions of them, precomputed memory degrades when assembled from separately prepared parts, stays current only through rebuilds costing a large fraction of full preparation in our measurements, and ignores corrections served beside it conditional on phrasing. If precomputed memories can be served alongside one another, be cost-efficiently rebuilt, and be superseded by new information arriving in real-time, they can serve as a way to avoid re-feeding context to a model over repeated queries. The implication of our results for a deployed system that deals with a variety of queries is that precomputed memories are best rebuilt on the cadence at which new information changes what the memory was originally computed from. Both warm-rebuilding trained compressions of key-value caches and serving specifically-phrased updates beside a memory, as pasted text or injected cache state, show particular promise for keeping precomputed memories current, the latter as an interim measure between rebuilds, and we measure the cost and name the remaining questions associated with each.
Asa Shepard
Jul 27, 2026cs.AI

Eviction as Estimation: A Fixed-Lag Smoothing View of Test-Time Memory, and When Measuring Beats Accumulating

A language model with a bounded working memory must repeatedly decide which stored items to keep. Every deployed method decides the moment an item arrives, from the past (StreamingLLM, H2O) or from a guess about the future (SnapKV). We recast the choice as an estimation problem on a hidden signal, whether an item will be reused, placing existing methods on one axis, the commit lag HH: online filters and learned predictors commit at H=0H=0, while Belady's offline optimum sits where the whole future is known. The missing regime in between, fixed-lag smoothing, waits a bounded number of steps, observes which items a correct near-future prediction attended to, and only then commits. This measurement, demonstrated utility, turns Belady's unobservable future request into something we read off the model itself. We instantiate it as a training-free policy, RMM, a strict generalization of H2O that reduces to it exactly when the measurement is uniform. In controlled settings where reuse is endogenous and separated in time, demonstrated utility identifies used memory far better than accumulated attention, and a small bounded memory behaves like a much larger one. But on independent third-party benchmarks, run inside NVIDIA's KVPress harness against its own SnapKV, H2O, and StreamingLLM implementations, the advantage mostly disappears: RMM is on par with H2O for single-turn question answering and loses to both H2O and SnapKV in a streaming multi-turn setting. The cause is simple: on natural text the model is correct about most tokens, so weighting attention by correctness barely changes it, and demonstrated utility collapses onto accumulated attention unless reuse is sharp and endogenous, which standard benchmarks do not exercise. Our contribution is the framework and an honest map of when measuring beats accumulating, not a new state of the art.
Maruthi Vemula, Neeraj Praneeth Gajula
Jan 29, 2026cs.AI

ShardMemo: Scope-Before-Routing for Agentic Memory Retrieval

Agentic systems accumulate persistent memory across sessions, tools, and tasks, and a later request must retrieve from it under two distinct constraints: which memories it is permitted to access, and which are relevant under a limited search budget. Existing memory systems handle access scope in two flawed ways: applying scope after retrieval wastes probe budget on inadmissible memories, while treating scope as a learned ranking feature makes a hard constraint depend on router quality. We present SHARD-MEMO, an agentic memory system built on scope-before-routing: metadata predicates first identify the admissible shards, and a learned router then selects a small number of them for shard-local approximate nearest neighbor retrieval. Given the supplied scope predicate and metadata, this separates hard admissibility from learned relevance ranking, so inadmissible shards cannot consume shard-probe budget. We evaluate on LoCoMo, HotpotQA, and ToolBench, covering conversational, long-context, and procedural memory. Under matched supervision and fixed budgets, SHARDMEMO improves over a learned router baseline by roughly +3 F1 on LoCoMo; in end-to-end LoCoMo evaluation it improves over the strongest evaluated memory baseline by up to +6.8 F1, with gains on HotpotQA and ToolBench.
Yang Zhao, Chengxiao Dai, Mengying Kou +2