MemOnce cuts 1M active cache to 25MB and beats full context by 5.77 points

MemOnce: A Scalable Memory Architecture for Large Language Models

Chang Nie, Chaoyou Fu, Songlin Liu, Yiqing Hu, Caifeng Shan

cs.CL

2026-11-21

Adapting Qwen3.5-4B with MemOnce drops 1M active cache to 25MB and raises the five-benchmark memory average to 60.07, 5.77 points above full context.

What problem this solves

Continual dialogue has to keep a history the next turn can reuse. A standard Transformer stores a KV cache, the keys and values attention has already computed, at every layer and every token. GPU memory grows linearly with length. Prefill grows with length squared. Mamba, RWKV, and GDN (Gated DeltaNet, a linear layer that writes history into a fixed-size state with a gated delta rule) hold memory and time constant, and fine facts fall out.

Hybrids and sparse attention still touch a global cache that grows with length during continual inference. YOCO (You Only Cache Once) keeps one intermediate hidden state and feeds it to later layers, which removes the depth factor and leaves the sequence factor in place. Native memory models such as M+, Metis, and Titans compress harder, then usually pay with lower scores, per-layer retrieval, or a backbone that has forgotten its old skills. External memory banks are trained apart from the model.

Three requirements have to hold together: recall that still keeps detail, time linear in length, and a constant active memory on the GPU.

Method

Each stage of the default backbone is three GDN blocks plus one memory-sparse attention block. History is written once and expanded into per-layer KV only when it is read.

Causal masking packs a segment onto its tail tokens, so the encoder stores final-layer states only, and only the last 1/r of each segment. The default r is 8. Depth drops from L copies to one, and the sequence shrinks by r, so the persistent bank is about 1/(L·r) of a full multi-layer KV cache. On Qwen3.5-4B (hidden size 2560, segment length 512) a compressed segment is 64 tokens, about 320KB.

The latest 16 segments stay on GPU as a short-term window, roughly 8K raw tokens and 5MB, so local context needs no search. Older states move to CPU or SSD. A new input uses only its last final-layer token: a two-layer MLP, L2 normalization, then cosine similarity, taking the top 64 long-term entries. Those indices are shared across attention layers and later decoding steps. M+ retrieves once per layer. MemOnce retrieves once.

The active set is those 64 segments plus the short window, about 20MB plus 5MB, 25MB in total. Each full-attention layer decodes the set into its own K and V with a LayerNorm and a linear map, then prepends them to the current input. Sharing one KV across depths would tie those layers together, so the projections are learned per layer. The paper's example is Qwen3.5-4B, with full attention in 8 of 32 layers. GDN blocks store no history. Active GPU state is constant in length. The persistent bank still grows. It just does not sit on the GPU.

Pretraining optimizes the backbone and the memory codec together under next-token prediction, with segments encoded in parallel. Post-training freezes Qwen3.5 and updates the index projection, the decoders, and a LoRA (a low-rank adapter, rank 128) that is on only while memory is written. The LoRA is off at generation time. Routing uses InfoNCE, with positive evidence turns labeled by a Qwen3.5-35B-A3B teacher. MemOnce-1M has 1 million multi-turn samples, mean length about 7,099 tokens, 90th percentile about 16,426.

Results

From-scratch training uses FineWeb-Edu. On the main comparison table, uncompressed MemOnce averages 52.63 zero-shot commonsense accuracy, r=8 averages 52.35, the Transformer 51.85, and GDN 52.31. After 8× compression the model is essentially tied with GDN and under a point ahead of the Transformer. WikiText-103 perplexity is 19.28 uncompressed, against 20.90 for the Transformer. Raising r from 1 to 8 moves commonsense accuracy from 0.5280 to 0.5255. At about 150M, MemOnce's WikiText perplexity is 23.40, against 25.64 for the Transformer and 31.22 for GDN. The 8× model at 945M has fewer parameters than the 1007M full-attention Transformer and still posts the higher downstream average.

Post-training attaches to Qwen3.5. Five memory benchmarks run from about 4K to about 1M tokens. Open answers are graded by DeepSeek-V4.1-Flash.

MethodSizeFive-benchmark average
Qwen3.5 full context4B54.30
MemOnce4B60.07
Qwen3.5 full context2B49.33
MemOnce2B51.17
M+ (official)8B41.39
EvoEmbedding4B39.15
Metis (retrained / official)4B31.76 / 27.80
RAG, 8 raw segments4B52.87

The margin is +5.77 points at 4B and +1.84 at 2B, +18.68 over official M+ (8B), and +32.27 over official Metis. Retrained EvoEmbedding and δ-Mem land at 38.74 and 29.95.

The 4B model does not win every column. MemBench is 84.34 vs 82.64, LongMemEval 47.40 vs 42.20, PersonaMem-128 53.60 vs 43.50, PersonaMem-1M 48.00 vs 33.60. LoCoMo is 67.01 vs 69.55, below full context. PersonaMem-1M carries the average. RAG scores higher on LongMemEval (52.40 vs 47.40) because it pastes raw text back in, and still trails by 7.20 on the five-benchmark average. On a constructed million-token HotpotQA set, MemOnce-4B scores 59.40 against RAG-4B at 52.20.

With K=0, short window only, the average is 36.83. K=16 reaches 59.72, K=64 peaks at 60.07, and K=128 falls back to 58.86.

General tasks under a 32K memory load:

MethodMMLUGSM8KGPQAAverage
Qwen3.5-4B72.8192.0032.8365.88
Full-weight SFT51.9740.5022.7338.40
EvoEmbedding68.6439.5034.8547.66
Metis71.7134.8523.5043.35
δ-Mem73.4691.0033.3365.93
MemOnce72.5991.0034.3465.98

Full-weight SFT, EvoEmbedding, and Metis drop 27.48, 18.22, and 22.53 points. δ-Mem holds a 65.93 general average and scores only 29.28 on memory. MemOnce's general average is 65.98, with the best memory score, and the backbone stays frozen while it generates.

At 1M tokens the active cache is about 25MB. Hybrid KV exceeds 32GB, a 1313× cut. The same figure puts a standard Transformer near 144GB, about 4.5× that 32GB line. Prefill goes from 1.38s at 32K to 41.36s at 1M, 6.9× faster than the hybrid and 35.8× faster than M+. Throughput is 29.3 tokens/s against 8.4 for full context, about 3.5×. EvoEmbedding already reaches 29.1 tokens/s, so throughput is close. At 128K, retrieve-and-load takes 64.24ms and 20MB. M+ takes 772.50ms and 1150MB. RAG-Rewrite takes 1094.30ms.

As a retriever, the 1024-d end-of-segment index scores 69.21 Recall@10 and 53.06 NDCG@10 overall, ahead of BGE-M3 and of Qwen3-Embedding-4B at 2560 dimensions. As a reranker, with All-MiniLM pulling 256 candidates and 20 kept, A-MEM moves from 43.57 to 60.78 and LightMem from 40.58 to 53.90. Qwen3-Reranker-4B reaches 60.39 and 52.40 on the same two systems.

Why it matters

The base weights stay frozen. What gets added is a LoRA that runs only while memory is written, an index head, and a few KV decoders. A 1M interaction does not keep a full KV cache on GPU, and it does not need a full-weight finetune. The general average is 65.98 against a 65.88 base.

From-scratch training leads the Transformer by under a point of commonsense accuracy. The gap that matters is the post-trained memory score, paired with an active cache that does not grow with length. The index works for retrieval because contrastive supervision is in the training loss.

Limitations

Scratch training stops at 1B. Runs at 7B and above are not in the paper. Long-horizon coding and multi-step tool use are not tested. A memory-benchmark score does not say the loop works inside an agent.

The paper calls MemOnce the first native memory model to beat full context. That sentence is true of the five-benchmark average. On LoCoMo the 4B model scores 67.01 against 69.55 for full context. PersonaMem-1M supplies most of the positive margin.

The 1313× figure compares the active GPU cache, not total storage. The persistent bank still grows as length divided by 8, on CPU or SSD. At 1M that is about 125,000 final-layer vectors. Prefill at 1M still takes 41.36 seconds.

Training sequences average about 7,000 tokens, and nine tenths fall under about 16,000, while evaluation reaches 1M. Evidence turns were labeled by a teacher. Official M+ is an 8B model compared with a 4B MemOnce, and the fair retrains do not include it. Open answers depend on an LLM judge. LoCoMo is ten long dialogues. Titans is missing from the pretraining comparison: the code was not public, and the reproduction was unstable to optimize.

Terms

Source

Related papers

All paper explainers