MemOnce: A Scalable Memory Architecture for Large Language Models
Organizations: Nanjing University · University of Science and Technology of China
Abstract
Deploying large language models (LLMs) in long-horizon and continual interactions requires maintaining reusable memory states for future inference, posing challenges for existing architectures. Standard Transformers accumulate layer-wise, token-level KV caches, incurring linear GPU memory growth and quadratic computational complexity as the context expands. In contrast, linear-time architectures compress history into fixed-size states, but struggle to retain fine-grained details. We introduce MemOnce, a foundation architecture that learns scalable memory states for language models. MemOnce is based on two core designs: (a) Memory encoder-decoder: it caches only a small subset of final-layer hidden states as compact memory representations and dynamically decodes them back into KV caches for attention layers; (b) Memory sparse attention: for each continual input, MemOnce adaptively retrieves relevant memory representations, with the sparse indices computed only once across layers. Coupling these two designs enables efficient on-the-fly memory loading and KV cache decoding, drastically reducing the GPU memory footprint and achieving linear-time complexity. We conduct extensive experiments to show that MemOnce outperforms Transformers and other architectures across varying model sizes, context lengths, and training paradigms (pretraining and post-training adaptation). In particular, adapting Qwen3.5-4B with MemOnce reduces memory state cache by 1313 and prefill latency by 6.9 at 1M context, and improves throughput by 3.5 and overall memory performance by +5.77%. Finally, MemOnce generalizes zero-shot to downstream representation tasks, achieving competitive results against specialized models.
Figures & tables
| Model | State Cache | Prefilling Time |
| Transformer ( Vaswani et al., 2017 ) | ||
| GDN ( Yang et al., 2025 ) | ||
| SWA ( Beltagy et al., 2020 ) | ||
| YOCO ( Sun et al., 2024b ) | ||
| M+ ( Wang et al., 2025a ) | ||
| MemOnce |
| Model | Wiki. | LMB. | LMB. | PIQA | Hella. | Wino. | ARC-e | ARC-c | SciQ | BoolQ | Avg. |
| ppl | ppl | acc | acc | acc_n | acc | acc_n | acc_n | acc | acc | ||
| Transformers & Attention Variants | |||||||||||
| Transformer ( Vaswani et al., 2017 ) | 20.90 | 33.24 | 35.2 | 65.7 | 40.4 | 51.5 | 52.4 | 28.2 | 83.2 | 58.2 | 51.85 |
| SWA ( Beltagy et al., 2020 ) | 20.52 | 32.69 | 34.5 | 65.6 | 41.0 | 51.4 | 50.1 | 27.4 | 83.2 | 59.7 | 51.60 |
| MLA ( Liu et al., 2024 ) | 23.07 | 33.37 | 34.2 | 67.0 | 39.7 | 50.7 | 50.6 | 27.7 | 83.2 | 61.9 | 51.87 |
| Linear & Recurrent Architectures | |||||||||||
| Model | Size | MemBench | LoCoMo | LongMemEval | PersonaMem-128 | PersonaMem-1M | Mem. Avg. |
| ( 4K) | ( 21K) | ( 115K) | ( 128K) | ( 1M) | |||
| Full Context Baselines | |||||||
| Qwen3.5-2B | 2B | 72.69 | 64.35 | 41.00 | 45.00 | 23.60 | 49.33 |
| Qwen3.5-4B | 4B | 82.64 | 69.55 | 42.20 | 43.50 | 33.60 | 54.30 |
| Native Memory Models | |||||||
| -Mem ( Lei et al., 2026 ) | 4B | 46.72 | 16.88 | 11.20 | 40.00 | 31.60 | 29.28 |
| Model | Mechanism | MMLU | GSM8K | GPQA | Gen. Avg. |
| Qwen3.5-4B | Full Context | 72.81 | 92.00 | 32.83 | 65.88 |
| Qwen3.5-4B | Model Weight | 51.97 | 40.50 | 22.73 | 38.40 -27.48 |
| EvoEmbedding ( Nie et al., 2026a ) | Soft Prompt | 68.64 | 39.50 | 34.85 | 47.66 -18.22 |
| Metis ( Zhang et al., 2026 ) | Linear State | 71.71 | 23.50 | 34.85 | 43.35 -22.53 |
| -Mem ( Lei et al., 2026 ) | Linear State | 73.46 | 91.00 | 33.33 | 65.93 +0.05 |
| MemOnce (Ours) | KV Cache | 72.59 | 91.00 | 34.34 | 65.98 +0.10 |
| Model | Size | Dim | Metric | ESG-Reports | LoCoMo | LongMemEval | REALTALK | QASPER | PeerQA | CovidQA | MLDR | Overall |
| BGE-M3 | 1.2B | 1024 | R@10 | 51.00 | 55.70 | 77.80 | 52.40 | 66.40 | 37.30 | 87.20 | 97.00 | 65.60 |
| Qwen3-Embedding-4B | 4B | 2560 | R@10 | 57.90 | 41.30 | 58.70 | 42.70 | 72.90 | 36.00 | 93.20 | 96.00 | 62.30 |
| MemOnce (Ours) | 4B | 1024 | R@10 | 72.55 | 52.54 | 86.18 | 44.14 | 76.47 | 35.38 | 88.39 | 98.00 | 69.21 |
| BGE-M3 | 1.2B | 1024 | N@10 | 35.90 | 41.80 | 65.60 | 42.00 | 44.20 | 28.20 | 65.10 | 77.00 | 50.00 |
| Qwen3-Embedding-4B | 4B | 2560 | N@10 | 40.80 | 29.90 | 47.10 | 34.50 | 50.20 | 27.20 | 76.70 | 77.80 | 48.10 |
| MemOnce (Ours) | 4B | 1024 | N@10 | 55.82 | 38.68 | 72.75 | 31.78 | 53.64 | 25.05 | 64.68 | 82.09 | 53.06 |
| System | Method | Single-hop | Multi-hop | Temporal | Open | Overall |
| A-MEM | Original | 42.91 | 13.71 | 32.29 | 56.48 | 43.57 |
| + Reasoning | 43.26 | 15.26 | 35.42 | 58.98 | 45.52 +2.0 | |
| + Qwen3-Reranker-4B | 61.70 | 22.12 | 43.75 | 76.46 | 60.39 +16.8 | |
| + MemOnce (Ours) | 66.31 | 33.96 | 46.88 | 70.75 | 60.78 +17.2 | |
| LightMem | Original | 41.13 | 23.36 | 41.67 | 46.85 | 40.58 |
| + Reasoning | 48.23 | 24.92 | 39.58 | 49.94 | 43.77 +3.2 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Configuration | Pre-training | Post-training |
| Backbone | MemOnce | Qwen3.5 |
| Training Paradigm | Scratch | LoRA (rank ) |
| Training Dataset | FineWeb-Edu-10B | MemOnce-1M |
| Max Sequence Length | K | K |
| Block Size | ||
| Parallel Encoding Chunks |
| Linear State | Ratio | PIQA | Hella. | Wino. | ARC-E | ARC-C | SciQ | BoolQ | LAMB. | Avg. |
| Persisted | 0.669 | 0.419 | 0.527 | 0.531 | 0.288 | 0.814 | 0.617 | 0.360 | 0.5280 | |
| 0.673 | 0.416 | 0.493 | 0.525 | 0.278 | 0.845 | 0.600 | 0.376 | 0.5259 | ||
| 0.664 | 0.416 | 0.511 | 0.510 | 0.264 | 0.831 | 0.609 | 0.366 | 0.5213 | ||
| 0.668 | 0.418 | 0.522 | 0.516 | 0.281 | 0.836 | 0.613 | 0.350 | 0.5255 | ||
| Discarded | 0.676 | 0.422 | 0.496 | 0.524 | 0.275 | 0.847 | 0.619 | 0.352 | 0.5263 | |
| 0.668 | 0.414 | 0.518 | 0.514 | 0.290 | 0.835 | 0.590 | 0.360 | 0.5235 |
| Model | Top- | MemBench | LoCoMo | LongMemEval | PersonaMem-128 | PersonaMem-1M | Mem. Avg. |
| MemOnce-4B | 72.49 | 20.06 | 14.00 | 40.20 | 37.40 | 36.83 | |
| MemOnce-4B | 84.94 | 65.06 | 47.00 | 53.60 | 48.00 | 59.72 | |
| MemOnce-4B | 84.64 | 66.23 | 45.20 | 53.60 | 48.80 | 59.69 | |
| MemOnce-4B | 84.34 | 67.01 | 47.40 | 53.60 | 48.00 | 60.07 | |
| MemOnce-4B | 84.94 | 65.97 | 45.60 | 51.00 | 46.80 | 58.86 |
| System | Encode | Search & Load | Read | Total Latency | Data Transfer |
| RAG-Rewrite [ Ma et al., 2023 ] | 1081.84 ms | 0.46 ms | 12.00 ms | 1094.30 ms | 0.13 MB |
| M+ [ Wang et al., 2025a ] | — | 772.50 ms | — | 772.50 ms | 1,150.00 MB |
| MemOnce (Ours) | 60.39 ms | 3.85 ms | — | 64.24 ms | 20.00 MB |
| Model | Params | Val PPL | WT2 | WikiText | LAMB. | PTB | PIQA | Hella. | Wino. | ARC-E | ARC-C | SciQ | BoolQ | LAMB. | Avg. |
| 150M Scale | |||||||||||||||
| Transformer | 146M | 12.65 | 16.55 | 25.64 | 36.49 | 171.91 | 0.642 | 0.362 | 0.519 | 0.475 | 0.253 | 0.799 | 0.579 | 0.294 | 0.4904 |
| GDN [ Yang et al., 2025 ] | 174M | 12.82 | 17.26 | 31.22 | 37.40 | 246.51 | 0.642 | 0.355 | 0.516 | 0.470 | 0.259 | 0.786 | 0.569 | 0.283 | 0.4850 |
| YOCO [ Sun et al., 2024b ] | 152M | 12.63 | 16.39 | 29.35 | 36.98 | 225.30 | 0.632 | 0.330 | 0.530 | 0.460 | 0.249 | 0.787 | 0.600 | 0.250 | 0.4798 |
| MemOnce ( ) | 158M | 12.64 | 16.77 | 25.81 | 36.17 | 166.99 | 0.648 | 0.355 | 0.514 | 0.469 | 0.250 | 0.791 | 0.581 | 0.306 | 0.4893 |
| MemOnce ( ) | 158M | 12.46 | 16.14 | 23.40 | 36.55 | 171.67 | 0.646 | 0.364 | 0.506 | 0.474 | 0.253 | 0.791 | 0.548 | 0.311 | 0.4866 |
| Model | Size | MemBench | LoCoMo | LongMemEval | PersonaMem-128 | PersonaMem-1M | Mem. Avg. |
| ( 4K) | ( 21K) | ( 115K) | ( 128K) | ( 1M) | |||
| Qwen3.5-4B (Full Context) | 4B | 82.64 | 69.55 | 42.20 | 43.50 | 33.60 | 54.30 |
| RAG [ Lewis et al., 2020 ] | 4B | 70.69 | 45.06 | 52.40 | 51.00 | 45.20 | 52.87 |
| MemOnce (Ours) | 4B | 84.34 | 67.01 | 47.40 | 53.60 | 48.00 | 60.07 |
| Model | Size | With Mem. ( ctx ) | No Mem. ( noctx ) | Gain ( ) |
| Full Context & Retrieval Baselines | ||||
| Qwen3.5-2B | 2B | 23.80 | 8.60 | +15.20 |
| Qwen3.5-4B | 4B | 26.60 | 10.60 | +16.00 |
| RAG [ Lewis et al., 2020 ] | 4B | 52.20 | 15.60 | +36.60 |
| Native Memory Models | ||||
| -Mem [ Lei et al., 2026 ] | 4B | 21.60 | 10.60 | +11.00 |
| Method | Prefill Time (s) | Prefill FLOPs (Throughput) | Decode (tok/s) | Active Memory Cache | Offloaded SSD/CPU |
| 32K Context Length | |||||
| Qwen3.5 (Baseline) | 0.87 | 308T (354 TF/s) | 26.5 | 1.05 GB | — |
| M+ [ Wang et al., 2025a ] | 24.40 | 466T (19 TF/s) | 24.8 | 2.50 GB | 4.60 GB |
| -Mem [ Lei et al., 2026 ] | 2.24 | 634T (283 TF/s) | 21.6 | 4.5 KB | — |
| EvoEmbedding [ Nie et al., 2026a ] | 5.02 | 525T (105 TF/s) | 28.2 | 2.6 MB | — |
| Metis [ Zhang et al., 2026 ] | 4.22 | 221T (52 TF/s) | 27.5 | 80.1 MB | — |
| Model | Params | Val PPL | WT2 | WikiText | LAMB. | PTB | PIQA | Hella. | Wino. | ARC-E | ARC-C | SciQ | BoolQ | LAMB. | Avg. |
| Transformers & Attention Variants | |||||||||||||||
| Transformer | 516M | 10.57 | 13.16 | 19.83 | 31.55 | 127.64 | 0.661 | 0.422 | 0.509 | 0.505 | 0.287 | 0.832 | 0.542 | 0.359 | 0.5146 |
| Transformer | 365M | 10.97 | 13.68 | 20.90 | 33.24 | 134.34 | 0.657 | 0.404 | 0.515 | 0.524 | 0.282 | 0.832 | 0.582 | 0.352 | 0.5185 |
| SWA | 365M | 11.00 | 13.72 | 20.52 | 32.69 | 131.13 | 0.656 | 0.410 | 0.514 | 0.501 | 0.274 | 0.832 | 0.597 | 0.345 | 0.5160 |
| MLA [ Liu et al., 2024 ] | 387M | 11.20 | 13.93 | 23.07 | 33.37 | 135.89 | 0.670 | 0.397 | 0.507 | 0.506 | 0.277 | 0.832 | 0.619 | 0.342 | 0.5187 |
| Linear & Recurrent Architectures | |||||||||||||||
| Paradigm | Active Memory Mechanism | State Cache | State Optimization | Theoretical Property under Eq. ( 13 ) |
| Transformer | Full KV cache | End-to-end | , but depth-time redundancy | |
| Linear / GDN | Recurrent matrix | Local + outer | grows with due to rank bottleneck | |
| MemOnce (Ours) | Indexed decoded via on demand | End-to-end | via query-conditioned sparsity |
Memory-Augmented Language Models
Memory-augmented language models combine persistent or temporary memory with neural computation to retain, retrieve, and use information beyond the active context.
See all 315 papers