Manuscript Offprint

arXiv:2610.10845

Real Long-Term Memory for AI: A 50-Million-Token Window That Is Faster and Cheaper Than Recompute

Sietse Schelpe

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Transformer language models can only attend to the tokens inside their context window, and serving systems recompute the key-value (KV) attention state of a prompt each time it is sent. We describe a memory layer, released as the public package galahad-kv, that removes both restrictions for a served model, and we report measurements of it on a corpus of 50,000,000 tokens. The layer writes the KV state that the model computes for each block of ~16,000 tokens to encrypted local NVMe storage and can later restore any block byte-exact, with zero recompute and at constant GPU memory. In our experiment the corpus consisted of real public text and the model was served through vLLM on one NVIDIA H100. All probed blocks were restored from the encrypted store without recompute (100 of 100, at depths from 0 to 50M tokens) for both Gemma 4 12B and Gemma 4 31B. Compared with recomputing the same block, a restore was 2.8×2.8\times to 4.3×4.3\times faster and consumed 8.8×8.8\times to 12.3×12.3\times less GPU energy, while GPU memory remained flat over the entire 50M-token stream. When asked about facts planted millions of tokens earlier, the 12B model answered 82/100 correctly and the 31B model 98/100, with zero hallucinations on either. We also describe the cheat-resistant protocol used for the evaluation and provide a complete single-GPU reproduction that relies only on public software.

1 Introduction

A language model that is served in the usual way loses information in two places. Tokens that fall outside the context window of a transformer [1] (16k tokens in the configuration we use) can no longer be attended to, so whatever they contained is unavailable to the model. In addition, the KV cache [2] is rebuilt for every prompt, which means the model pays the full prefill cost again for text it already processed in an earlier request.

In this paper we keep the KV state that the model computes for each block on disk and restore it when it is needed again. With this in place, a model with a fixed window can hold on to everything it has processed and reuse it later. We use the term long-term memory for this and avoid the term cache, because the stored state is durable, encrypted and byte-exact and because it covers material that lies far outside the window. Section 7 comes back to this distinction.

Our contributions are the following, and each of them is backed by measurements in §6.

  1. We demonstrate a 50-million-token memory window on a real served model, with byte-exact restore at every depth we probed and constant VRAM. A block is processed once and can afterwards be reused without recompute.

  2. We measure the cost of reuse against the cost of recompute. Restoring a block is 2.8×2.8 \times to 4.3×4.3 \times faster and takes 8.8×8.8 \times to 12.3×12.3 \times less GPU energy than recomputing the same tokens, and the restore time stays flat as depth increases.

  3. We define a cheat-resistant benchmark protocol and provide the harness, so that a third party can rebuild the experiment on a single GPU and check the result independently.

The scope of these claims is limited to KV reuse at any depth. The system does not widen single-pass attention and it does not do learned retrieval. One block is resident at a time, and deeper content is restored from disk when it is requested instead of being held in VRAM.

References (29)