MemOnce: A Scalable Memory Architecture for LLMs That Cuts 1M-Context GPU Memory by 1000x

MemOnce uses compact memory representations and cross-layer sparse retrieval for a linear-complexity long-context memory architecture.
MemOnce is a new memory architecture for long-horizon LLM interaction that solves both the linear memory growth and quadratic complexity of standard Transformer KV caching and the detail loss of linear-time architectures. It caches only a small fraction of the last layer's hidden states as compact memory, dynamically decoding them back into the KV cache, while cross-layer sparse attention retrieves relevant memories with the index computed once across layers. At 1M context with Qwen3.5-4B, it cuts memory state caching 1313x and prefill latency 6.9x while improving throughput 3.5x.
Why Large Models Need a New Memory Architecture
When deploying large language models for long-horizon, continuous interactions, the model needs to retain reusable memory states for subsequent reasoning. Standard Transformers save history through layer-by-layer, token-level KV caching, causing GPU memory to grow linearly with context while computational complexity rises quadratically. Another class of linear-time architectures compresses history into a fixed-size state, but struggles to retain fine-grained details. MemOnce is a foundational architecture proposed to resolve this contradiction, enabling models to learn scalable memory states.

KV cache (Key-Value Cache) is a core optimization mechanism during Transformer inference. In the autoregressive generation process, the attention computation for each new token needs to interact with the Key and Value vectors of all historical tokens. To avoid redundant computation, the standard approach is to store the K and V tensors of each layer and each historical token in GPU memory—this is the KV cache. Its cost is that memory usage is proportional to context length and number of layers: double the context, double the cache; the more layers, the larger the per-token cache. Therefore, in long-context scenarios, the KV cache often becomes the dominant portion of GPU memory usage, sometimes even exceeding the model weights themselves. Understanding this is key to seeing why MemOnce—which "caches only a small fraction of the last layer's hidden states"—can deliver order-of-magnitude memory savings.
Two Core Designs: Memory Encoding-Decoding and Sparse Attention
MemOnce's core innovation rests on two synergistic designs.
Memory Encoder-Decoder
This design caches only a small fraction of the last layer's hidden states as a compact memory representation, rather than storing the full layer-by-layer KV cache. When needed, these memory representations are dynamically decoded back into the KV cache for use by attention layers. This "load-on-demand" approach dramatically reduces resident GPU memory usage.
Memory Sparse Attention
For each continuing input, MemOnce adaptively retrieves relevant memory representations, and the sparse index is computed only once across all layers—rather than independently per layer. Coupled together, the two designs enable efficient on-the-fly memory loading and KV cache decoding, significantly reducing GPU memory footprint and achieving linear time complexity.
The contrast between linear-time architectures and quadratic complexity is key to understanding MemOnce's positioning. Standard Transformer self-attention must compute the relevance of each token to all other tokens, with O(n²) computation where n is sequence length; the KV cache avoids redundant computation, but memory remains O(n). So-called linear-time architectures (such as various recurrent neural networks and state space models) compress history into a fixed-size hidden state, with O(1) or O(n) computation per step and memory that does not grow with context. However, their fixed state capacity is limited, making it hard to precisely trace fine-grained details, and their long-range retrieval ability is weak. MemOnce attempts to take the best of both: using compact memory representations to control memory and computation, while preserving accessible detailed information through dynamic decoding and sparse retrieval—approaching the fine-grained memory capability of Transformers while maintaining linear complexity.
Experimental Results: Comprehensive Optimization of Memory, Latency, and Throughput
The research team conducted extensive experiments across different model scales, context lengths, and training paradigms (pretraining and post-training adaptation), with MemOnce outperforming Transformers and other architectures in all cases.
The most striking results come from adapting Qwen3.5-4B: at 1M context length, memory state caching is reduced by 1313x, prefill latency is reduced by 6.9x, throughput increases by 3.5x, and overall memory performance improves by 5.77%. These figures show that MemOnce not only alleviates the memory pressure of long contexts but also substantially improves inference efficiency.
Prefill latency and throughput are two key metrics for measuring long-context inference efficiency. The prefill phase refers to the process in which the model processes the input prompt and builds the KV cache; its duration grows with input length and directly determines how long users wait for the first token—in long-context scenarios, prefill is often the primary source of latency. Throughput refers to the number of tokens or requests the system can process per unit time, reflecting overall server-side efficiency. MemOnce's reported 6.9x reduction in prefill latency and 3.5x throughput improvement mean that on the same hardware, it can both respond to users faster and serve more concurrent requests. The "1313x reduction in memory state caching" refers to a massive reduction in the amount of data held in resident GPU memory for storing historical memory, directly alleviating the memory wall in long-context deployment.
Zero-Shot Generalization Capability
Beyond language modeling, MemOnce also demonstrates zero-shot generalization to downstream representation tasks, achieving results competitive with specialized models. This means the memory states learned by the architecture are not solely serving generation tasks but possess a degree of general representational value.
Implications for Long-Context Deployment
MemOnce's value lies in addressing two pain points of long-context scenarios simultaneously: the memory wall and the latency wall. Traditional KV cache solutions inflate memory linearly as context expands, while linear-time architectures sacrifice detail. Through a combination of "compact memory representation + dynamic decoding + cross-layer shared sparse index," MemOnce achieves linear complexity while preserving fine-grained information. For AI applications requiring continuous interaction and long-term memory (such as agents and dialogue systems), this architecture provides scalable underlying support.
However, MemOnce remains a research-stage foundational architecture, and its stability in real production environments, integration cost with existing inference frameworks, and generalization boundaries across different modality tasks still require further validation.
One-line Summary
MemOnce uses compact memory representations and cross-layer sparse retrieval to achieve a linear-complexity long-context memory architecture.
Paragraph Summary
MemOnce is a novel memory architecture for long-horizon, continuous interaction with large models, designed to simultaneously solve the linear memory growth and quadratic computational complexity of standard Transformer KV caching, as well as the difficulty linear-time architectures face in retaining fine-grained details. Its core design has two parts: a memory encoder-decoder that caches only a small fraction of the last layer's hidden states as a compact memory representation, dynamically decoding them back into the KV cache when needed; and memory sparse attention that adaptively retrieves relevant memories for each input, with the sparse index computed only once across layers. Experiments show that at 1M context with Qwen3.5-4B, memory state caching is reduced by 1313x, prefill latency by 6.9x, throughput improves by 3.5x, and overall memory performance improves by 5.77%. In addition, MemOnce generalizes zero-shot to downstream representation tasks.
Related articles

COP31 Climate Talks End Without Agreement Over Fossil Fuels and Finance Disputes
COP31 climate talks failed to reach agreement over fossil fuel phase-out and climate finance disputes. This article analyzes the core conflicts behind the breakdown and its impact on global climate governance.

TEA-Bench-BR: Can Coding Agents Turn Branching Clinical Guidelines into Correct Code?
TEA-Bench-BR evaluates coding agents on converting Brazilian autism screening clinical guidelines into code. The 31B model solves over 77%, but drops to 57.4% in English, with input validation as the main failure point.

Higher-Order Attention: Breaking Through the Information Bottleneck of Autoregressive Language Models
This article explores how higher-order attention mechanisms enhance the information content of autoregressive language models, covering conditional mutual information decomposition, consecutive-token correlation, and the generalized maximum entropy principle, along with their prospects in contrastive decoding.