Özer Cem KELAHMETKELAHMET
Articles · Research

MemOnce explained: a 25 MB memory that beats full context for a 4B model at 1M tokens

A Nanjing University and USTC team says its MemOnce architecture lets a 4B Qwen model remember a million tokens with a cache of about 25 MB, and score higher on memory benchmarks than the same model reading everything. Here is how it works and what the numbers mean.

Download Markdown
At a glance
Reading time
16 min
Sections
8
Code examples
1
Tables
3
Sources
6
Published
24 Nov 2026
In 30 seconds
What changed
MemOnce paper posted to arXiv
Why it matters
For teams building assistants that live for weeks or months with one user, MemOnce suggests memory can be part of the model rather than a separate service.
What to do
Read the tables, not only the abstract

Every chat assistant that "remembers" you has to store that memory somewhere. A standard transformer stores it as a key-value (KV) cache: two vectors per token, per layer. That cache grows with every word, and at a million tokens it no longer fits on one GPU. The usual alternatives either compress history into a fixed-size state, which forgets details, or bolt on an external search system, which is slow and loses the model's own view of the text.

A paper posted to arXiv on 20 November 2026, "MemOnce: A Scalable Memory Architecture for Large Language Models", proposes a middle path. It keeps only a small fraction of the model's final-layer hidden states as memory, looks up the relevant pieces once per new query, and rebuilds per-layer KV caches from them on demand. The authors report that a Qwen3.5-4B model adapted this way scores 60.07 on an average of five memory benchmarks, against 54.30 for the same model given the full history in its context window. At 1M tokens they report an active GPU cache of about 25 MB, where a plain transformer's KV cache passes 32 GB.

If those results hold up, the paper matters for anyone building long-running assistants or agents: memory could become cheap enough to keep per user, without a separate retrieval stack. This article explains the method, the measured results, and the gaps a careful reader should note.

What happened

MemOnce paper posted to arXiv (20 November 2026)

Chang Nie, Chaoyou Fu and Caifeng Shan of Nanjing University, with Songlin Liu and Yiqing Hu of the University of Science and Technology of China, posted the paper as arXiv 2611.27973 in the cs.CL area. It was featured on the Hugging Face daily papers list for 23 November. A project page links to a GitHub repository and a Hugging Face model page.

The paper makes three main claims, all self-reported:

  • Pretraining from scratch at 0.15B to 1.0B parameters on FineWeb-Edu, MemOnce is competitive with a standard transformer and eight other architectures on perplexity and zero-shot accuracy.
  • Post-training an existing Qwen3.5 model with lightweight LoRA adapters, MemOnce beats the full-context model on five memory benchmarks spanning 4K to 1M tokens. The authors call it "the first native memory model to surpass full-context baselines".
  • Efficiency: the abstract reports a 1313× smaller memory state cache, 6.9× faster prefill and 3.5× higher decoding throughput at 1M context. The detailed text gives the active cache as about 25 MB.

The question the paper asks

The authors set three goals that existing designs do not meet together: accurate recall of details, inference time that grows linearly with context, and a bounded GPU cache during continual use.

Think of three ways to remember a long meeting. A transformer keeps a full recording of every word at every level of understanding; recall is perfect but the storage is huge. A recurrent or linear model such as Mamba or Gated DeltaNet keeps one running summary in a fixed notebook; storage is constant, but early details get overwritten. A retrieval system keeps transcripts in a filing cabinet and searches them; storage is cheap, but the search runs outside the model and the results come back as raw text that must be read again.

MemOnce tries to keep short, high-quality notes taken by the model itself, find the right notes once, and expand them back into the format the model's attention layers need. If you want a refresher on why the transformer's record is so large, the KV cache simulation shows how it grows token by token and layer by layer.

How MemOnce works

The architecture has three parts: a backbone, a memory encoder-decoder, and memory sparse attention.

The backbone: mostly linear, with a few attention blocks

By default MemOnce uses a hybrid stack. Each stage has three linear-time blocks (for example Gated DeltaNet) followed by one Memory Sparse Attention block. The linear blocks handle local, recent text cheaply. The attention blocks are where long-range memory enters. Hybrid stacks of this kind are also how several open models reach long context, as covered in our piece on how open models reach 1M tokens.

Writing memory: keep the tail of each segment, from the last layer only

The input is cut into segments (128 tokens per chunk in pretraining, 512 in post-training). After the model processes a segment, MemOnce keeps only the trailing 1/r of that segment's final-layer hidden states. With the default r = 8, a 512-token chunk becomes 64 memory vectors. In the paper's notation the memory bank is:

G_t = Concat( h^L for the last n_i / r tokens of each earlier segment i )

Two choices drive the savings. First, only the final layer is stored, not every layer, which removes a factor of L (the number of layers). Second, only one token in r is kept. The authors describe the persistent memory saving as "Lr×". The intuition is that the last tokens of a segment, at the top of the network, have already read the whole segment, so they act like a summary written by the model.

Decoding memory: rebuild per-layer keys and values on demand

Attention layers need keys and values, not hidden states. MemOnce uses small layer-specific projections to turn the retrieved memory M_t into a KV cache for each attention layer l:

K^l = K_Proj^l(M_t), V^l = V_Proj^l(M_t)

The authors argue that sharing one identical KV across all layers would limit what each layer can read, so each layer gets its own lightweight decoder. Decoding happens only when needed, so the full multi-layer cache never sits in GPU memory.

Reading memory: retrieve once, reuse in every layer

The memory bank is split into a long-term pool and a short-term window of the most recent entries. In post-training the window holds 1,024 compressed tokens across 16 chunks, about 8K raw tokens. For the long-term pool, MemOnce picks the top-K chunks by cosine similarity between a projection of the current query's last hidden state and a projection of each memory entry:

M_t^long = Top-K over m_i of Sim( φ(h_t^L), φ(m_i) )

The active memory is the retrieved chunks plus the short-term window. The default is K = 64 chunks. The key design point is in the name: the routing indices are computed once per query and reused across all layers. Earlier methods such as M+ recompute retrieval layer by layer or token by token. The authors report end-to-end retrieval and loading in 64.2 ms, which they say is more than 12× faster than M+'s layer-wise retrieval and more than 17× faster than a RAG pipeline.

A library analogy helps. M+ is like walking back to the catalogue on every floor of the library. MemOnce looks up the shelf numbers once at the front desk, then every floor uses the same slip.

Training data

For post-training the authors built MemOnce-1M, about one million multi-turn conversations. Each sample has between 3 and 464 earlier rounds followed by a target question. A teacher model, Qwen3.5-35B-A3B, writes a reference answer and marks which earlier turns hold the evidence. Those labels supervise both the language-modelling loss and the retrieval loss. Mean sample length is 7,099 tokens, with a 90th percentile of 16,426. During post-training the LoRA adapters are active only when encoding memory; the backbone stays frozen when generating answers.

The measured results

All numbers below are reported by the authors. Accuracy on the memory benchmarks is judged by an LLM (DeepSeek-V4.1-Flash, used as a strict judge), which is common practice but adds its own noise.

Pretraining from scratch

On FineWeb-Edu, the authors trained small models under unified configurations and compared ten architectures. Selected rows from their Table 2:

Model Wiki ppl (lower is better) LAMBADA ppl 8-task avg accuracy
Transformer 20.90 33.24 51.85
Hybrid (linear + attention) 19.56 32.61 51.99
GDN 26.03 33.37 52.31
YOCO 24.38 35.18 51.97
MemOnce r = 8 21.08 32.45 52.35
MemOnce r = 1 19.28 32.69 52.63

The gains are small. MemOnce with r = 1 has the best Wiki perplexity and average accuracy, but MemOnce with the default r = 8 is slightly worse than the transformer on Wiki perplexity (21.08 against 20.90) and slightly better on accuracy. The reasonable reading is "no loss from compressing memory", not "a better language model".

Memory benchmarks after post-training

The five benchmarks are MemBench, LoCoMo, LongMemEval, PersonaMem-128K and PersonaMem-1M. Averages from Table 3:

Model Size Memory average
Qwen3.5-4B, full context 4B 54.30
Qwen3.5-2B, full context 2B 49.33
M+ 8B 41.39
EvoEmbedding 4B 39.15
δ-Mem 4B 29.28
Metis 4B 27.80
MemOnce 2B 51.17
MemOnce 4B 60.07

The headline "+5.77%" is the difference in points between 60.07 and 54.30. The "+18.68" over M+ and "+32.27" over Metis are also point differences in the average. MemOnce-4B scores 84.34 on MemBench and 67.01 on LoCoMo. The authors also retrained three of the baselines on their own data (marked with a dagger in the paper); those scores stay between 29.95 and 38.74, so the gap is not only a data advantage.

Why could a compressed memory beat the full context? The paper's framing is that the retrieval step filters noise: instead of attending over a million tokens of old chat, the model sees 64 relevant chunks plus the recent window. Anyone who has tried to find one fact in a very long document will recognise the effect.

General ability is preserved

A common failure of memory methods is that they damage the model's normal skills. Table 4 tests MMLU, GSM8K and GPQA while 32K tokens of memory are loaded:

Method Mechanism Average Change
Qwen3.5-4B Full context 65.88 baseline
Full fine-tune on memory Model weights 38.40 −27.48
EvoEmbedding Soft prompt 47.66 −18.22
Metis Linear state 43.35 −22.53
δ-Mem Linear state 65.93 +0.05
MemOnce KV cache 65.98 +0.10

MemOnce and δ-Mem both keep general reasoning intact. MemOnce does so while scoring about twice as high as δ-Mem on the memory benchmarks.

Efficiency at long context

The authors report that prefill latency grows linearly, from 1.38 s at 32K tokens to 41.36 s at 1M. At 1M tokens that is 6.9× faster than their Hybrid baseline and 35.8× faster than M+. Transformer and Hybrid KV caches exceed 32 GB at 1M tokens, while MemOnce keeps its active GPU cache near 25 MB. The ratio of those two figures is consistent with the abstract's 1313× claim, although the paper's main text does not spell out the exact baseline used for that number. The project page gives decoding throughput as 29.3 tokens per second at the 3.5× speed-up.

Retrieval as a side effect

Because MemOnce learns to retrieve, its memory vectors double as embeddings. On the authors' retrieval test it reaches recall@10 of 69.21 and NDCG@10 of 53.06, against 65.60 and 50.00 for BGE-M3 and 62.30 and 48.10 for Qwen3-Embedding-4B. Used as a reranker inside two existing memory systems on LoCoMo, it lifts A-MEM from 43.57 to 60.78 and LightMem from 40.58 to 53.90. Those test sets are the authors' choice, so treat the comparison as indicative. For background on how embedding retrieval and reranking normally work, see our RAG types explainer.

Ablations

The authors report that raising r from 1 to 8, and separately discarding the linear blocks' recurrent states across segments, each cost less than 0.3% accuracy. That supports the claim that final-layer hidden states alone carry enough information. K = 64 retrieved chunks was the best balance between coverage and noise in their sweep.

Limits stated and unstated

The authors list two limits. Pretraining from scratch stopped at 1B parameters, so scaling to 7B and beyond is untested. And downstream agent performance "remains to be fully validated", especially for long-horizon coding and multi-step tool use.

A careful reader would add several more:

  • The benchmarks are conversational. MemBench, LoCoMo, LongMemEval and PersonaMem test recall of facts from long chats. They do not test reasoning that needs many scattered details at once, such as summarising a whole codebase.
  • Training data comes from a teacher. The evidence labels in MemOnce-1M come from Qwen3.5-35B-A3B. Errors in those labels would teach the retriever the teacher's blind spots.
  • Top-K retrieval can miss. Any system that reads 64 chunks can fail when the answer depends on chunk 65. Full context does not have that failure mode, even if it has others.
  • The judge is an LLM. Scores depend on a single judge model's strictness.
  • Comparison baselines are small memory methods. The paper does not compare against a strong RAG system tuned for the same benchmarks, beyond the latency comparison.

What it means in practice

For teams building assistants that live for weeks or months with one user, MemOnce suggests memory can be part of the model rather than a separate service. A 25 MB per-user memory state is small enough to store per account and load on demand, in the same way a session file is loaded today. That changes the cost picture described in our article on agent memory with threads and long-term stores, where memory today usually means summaries and vector search glued on from outside.

It also connects to a family of research ideas. Memorilla compresses a document store into a handful of memory tokens for a frozen model, and Titans and MIRAS learn memory at test time. MemOnce's distinct move is to keep many small notes and retrieve among them, instead of squeezing everything into one fixed state.

For serving teams, the important number is the active cache. If a long session costs 25 MB instead of tens of gigabytes, many more concurrent sessions fit on a GPU. The trade-off is a retrieval step and a small decoding cost on every query.

What to do now

  1. Read the tables, not only the abstract. The "+5.77%" is a point difference on a five-benchmark average; check the per-benchmark rows that match your use case.
  2. Test on your own long sessions. Build a held-out set of real multi-week conversations with known facts and measure recall before trusting any memory method.
  3. Compare against a tuned RAG baseline. Before adopting a native memory model, measure your current retrieval pipeline on the same questions; the paper does not do this for accuracy.
  4. Track failures beyond top-K. Log questions where the answer needed more evidence than the retrieved chunks hold; these are the cases a compressed memory will miss.
  5. Watch general-skill regressions. Run a small MMLU or GSM8K check with memory loaded, as the authors do, whenever you change the memory system.
  6. Budget memory per user. Estimate storage at roughly tens of megabytes per active long session and plan where those states live between requests.
  7. Check the code and weights release. The project page links a repository and a model page; confirm what is actually released and under which licence before planning around it.
  8. Keep an eye on agent tasks. The authors say coding and tool use are untested; if those are your workload, wait for results there.

Risks and open questions

Will it scale? Pretraining stopped at 1B parameters. Hybrid designs sometimes behave differently at 30B and above, and the benefit of a filtered memory may shrink as stronger models handle long context better.

Is the judge reliable? All memory scores rely on one LLM judge. A second judge or human spot checks would make the gap over full context more convincing.

What happens with adversarial or conflicting memory? A user who corrects a fact later in a conversation creates two memories. The paper does not test whether retrieval picks the newer one.

Privacy of stored states. Compact hidden-state memory is not human-readable, but it may still be decodable. Teams that store per-user memory need deletion and access rules, as they would for transcripts.

Watch next: independent replication at larger scale, results on long-horizon coding agents, and whether major open model families adopt a retrieve-once, decode-on-demand memory layer.

Frequently asked questions

What is MemOnce in one sentence?

MemOnce is a memory architecture for language models that stores a small fraction of final-layer hidden states as compact memory, retrieves the relevant pieces once per query, and turns them back into per-layer key-value caches on demand. It was posted to arXiv on 20 November 2026 by researchers at Nanjing University and USTC.

How much memory does it save?

The authors report an active GPU cache of about 25 MB at 1M tokens, against more than 32 GB for a standard transformer or hybrid model. The abstract states this as a 1313× reduction in the memory state cache. The persistent store shrinks by a factor of the number of layers times the compression ratio, which defaults to 8.

Does it really beat reading the full context?

On the authors' five memory benchmarks, the Qwen3.5-4B model with MemOnce averages 60.07 against 54.30 for the same model with full context. The likely reason is that retrieval filters out irrelevant history. These are self-reported results on conversational benchmarks and have not been independently replicated.

Does it hurt normal model skills?

According to the paper, no. With 32K tokens of memory loaded, MemOnce averages 65.98 on MMLU, GSM8K and GPQA, against 65.88 for the base model, because the backbone stays frozen when generating answers. Full fine-tuning on the same memory dropped the average to 38.40.

How is it different from RAG?

RAG retrieves raw text and puts it back into the prompt, so the model must read it again. MemOnce retrieves the model's own compressed hidden states and decodes them directly into keys and values, skipping that re-reading. The authors report its retrieval and loading take 64.2 ms, more than 17× faster than the RAG pipeline they tested.

Summary

MemOnce, posted on 20 November 2026 by a Nanjing University and USTC team, keeps one in eight final-layer hidden states as memory, retrieves the relevant chunks once per query, and decodes them into per-layer KV caches. The authors report that a Qwen3.5-4B model adapted with LoRA reaches a 60.07 memory-benchmark average against 54.30 for full context, keeps general reasoning intact, and runs at 1M tokens with an active cache of about 25 MB and 6.9× faster prefill than a hybrid baseline. The results are self-reported, pretraining stopped at 1B parameters, and agent tasks are untested, but the design offers a concrete path to cheap per-user memory inside the model itself.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 24). MemOnce explained: a 25 MB memory that beats full context for a 4B model at 1M tokens. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/memonce-compact-memory-kv-cache

BibTeX
@online{kelahmet2026memonce,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{MemOnce explained: a 25 MB memory that beats full context for a 4B model at 1M tokens}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/memonce-compact-memory-kv-cache}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open