Manuscript Offprint

arXiv:2610.10058

Cache the Encoder Within:Compact, Reusable Memory across LLM Queries

Hanzuo Liu, Chunyu Liu, Chaofan Lin, Alex Lamb, Mingyu Gao

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

Abstract

Repeated queries over shared documents incur redundant encoding, while caching model states introduces persistent storage costs. Building on CoMem's intermediate-state interface, EncBank treats a pretrained LLM's lower layers as a reusable document encoder and compactly stores their outputs for an adapted upper-layer reader. A self-distilled suffix adapter is shared across storage precisions within each backbone, without quantization-specific retraining. Across five benchmark suites on three Qwen backbones spanning different sizes and full-attention and hybrid architectures, 4-bit storage keeps each reported benchmark aggregate within one score point of native-precision EncBank. In a fixed Qwen3-8B workload, it retains 28.1% of the native-precision persistent GPU store. Separate native-precision controls yield a 1.40× selected-pack prefill speedup over same-evidence, same-adapter text replay, at a 3.12-point RULER accuracy cost. A native-precision Qwen3.8-27B configuration also passes 70 of 89 Terminal-Bench 2.1 tasks. EncBank thus combines reusable computation with compact memory, while task fidelity and end-to-end benefits remain dependent on the workload, preparation costs, and reuse frequency.

1 Introduction

Recent advances in large language models (LLMs) have enabled systems that answer questions over long documents, retrieve information from external knowledge collections, and draw on extended conversation histories (Lewis et al., 2020; Bai et al., 2024; Maharana et al., 2024). In these settings, a query is accompanied by context: source material that the model uses to construct its answer. The same collection or history may support many different queries, creating an opportunity to reuse the computation spent processing that material.

A straightforward approach encodes the relevant context anew for each request before generating an answer. Retrieval reduces this cost by selecting relevant passages, but does not by itself reuse their previous computation: selected tokens still pass through every decoder layer. Retaining processed representations could avoid some of this repeated work. However, those representations must persist between requests, so their storage cost grows with the retained collection. Efficient reuse therefore requires deciding both what computation to retain and how compactly to store it.

Storing text as token IDs is compact but preserves no model computation. Full-depth key-value (KV) caches retain more computation, but store attention states at every layer and must handle context and position dependencies when chunks are assembled (Gim et al., 2024; Yao et al., 2025; Lu et al., 2025). CoMem offers an intermediate object: one hidden state (residual) per token at a chosen layer boundary, followed by continuation through the remaining layers (Liu et al., 2026). On Qwen3-8B, this costs 8 KiB/token instead of

(a) Reader adaptation

Figure

(b) Reuse depth

(c) Storage precision

Figure 1: Reader adaptation, reuse depth, and storage precision. Qwen3-8B throughout. (a) Native LoCoMo full Judge, 1,986 items, fixed j = 12 and evidence; only suffix adaptation changes. (b) Separately adapted splits: RULER-B on 1,500 examples versus fixed-pack prefill from three processes. (c) Fixed-reader FP16 H16/H8/H4: RULER means over 1,500 examples and persistent GPU Store on six 8k documents. Quality and storage use distinct supports. Lines connect measured settings; the depth and precision studies are not a joint sweep.

144 KiB/token for full-depth 16-bit KV. Yet 128k tokens still require 1 GiB of residuals. Bounded retrieval limits the online working set; it does not limit the bytes retained for a growing document collection.

EncBank extends CoMem’s WRITE–SELECT–READ interface with low-bit persistent storage. Lower layers encode each chunk once; its states are stored in H16, H8, or H4 format. For each query, selected states are reconstructed and read by the upper layers. One adapted reader per backbone serves all three precisions. Split depth j controls prepaid computation; precision b controls retained bytes.

References (45)