MemOnce Redefines Long-Context Memory, Shrinking 1M-Token State Cache by 1,313x
Summary:MemOnce targets long-horizon and continual interaction by storing a small subset of final-layer hidden states as compact memories. A memory encoder-decoder reconstructs layer-specific KV caches on demand, while its sparse-attention selector computes retrieval indices once and reuses them across layers. The paper reports that adapting Qwen3.5-4B at a 1M-token context reduces the state cache by 1,313x, lowers prefill latency by 6.9x, raises throughput by 3.5x, and achieves linear-time complexity.
MemOnce replaces the token-level KV cache used by standard Transformers with sparse memories that can be reconstructed on demand. The goal is not merely to quantize or offload KV state, but to change the granularity at which conversation history is stored. The paper reports large gains on Qwen3.5-4B at a 1M-token context, although these remain author-reported results. Whether the approach transfers to production serving depends on retrieval quality, reconstruction overhead, and behavior under concurrent workloads.
From Token-Level KV to Reconstructable Memory
For a model with L layers, context length n, per-layer KV dimension d_kv, and b bytes per element, the KV cache is approximately:
M_KV ≈ 2 × L × n × d_kv × b
This ignores allocator and metadata overhead. GQA and MQA reduce d_kv, while quantization reduces b, but neither removes the linear growth of persistent state with context length. Full-attention prefill also grows quadratically with sequence length. With KV-cache decoding, each generated token still reads an expanding context, so long-context inference becomes constrained by HBM capacity, memory bandwidth, and attention compute.
MemOnce replaces full persistence and layer-by-layer reading with compressed storage and on-demand reconstruction.
How the Architecture Works
1. Memory Encoder-Decoder
MemOnce selects a small subset of final-layer hidden states and encodes them as compact memory representations rather than storing K and V for every token in every layer. During inference, the memory decoder expands the selected memories into the KV caches required by the attention layers.
This primarily reduces persistent state. It does not eliminate KV tensors during inference: temporarily reconstructed K/V may still occupy HBM and incur write, read, and bandwidth costs. Peak memory should therefore be reported separately for model weights, compressed memories, sparse indices, temporary KV, and workspace rather than presenting only the state-cache figure.
2. Memory Sparse Attention
For each continual input, MemOnce adaptively retrieves relevant memories and computes the sparse indices once for reuse across layers. Compared with independent nearest-neighbor or Top-k searches in every layer, this can remove repeated index work and align the historical evidence used by different layers.
The trade-off is reduced layer-specific retrieval. Shallow layers may need lexical and local structure, while deeper layers may retrieve more abstract semantics. Forcing all layers to share one index can also amplify selector mistakes. Independent per-layer retrieval, fixed Top-k, random memory, and alternative index-sharing strategies would be necessary ablations.
3. Conditions for Linear-Time Scaling
The paper claims linear-time complexity. If the number m of compressed memories is bounded or grows slowly, retrieval costs O(k), and decoding is proportional to the selected memory count k, incremental processing can avoid attending to all n historical tokens.
The asymptotic claim still depends on how memory capacity grows. If candidate memories scale linearly with n and selection scans all candidates, retrieval can become quadratic. Cross-layer reconstruction and temporary KV materialization also introduce linear work. A convincing result would require the complexity derivation, memory-growth curve, and measured scaling beyond 1M tokens rather than extrapolation from a single context length.
Why It Differs from Fixed-Size Recurrent State
Fixed-state or recurrent architectures such as Mamba-, RWKV-, and RetNet-style models compress history into bounded states, but the abstract argues that they can lose fine-grained information. MemOnce instead retains a set of independently addressable compressed memories, retrieves the evidence relevant to the current query, and reconstructs a conventional attention structure around that evidence.
The design attempts to occupy the middle ground between a single compressed state and token-level KV. It is not lossless, however. Encoder information loss, retrieval misses, and decoder errors can all prevent recovery of facts that a full KV cache would retain.
Engineering Trade-offs
- Quality and recall: Compressed memories reduce state freedom. Once the selector misses critical evidence, KV reconstruction cannot restore it. Evaluation must cover long-range fact retrieval, multi-hop reasoning, cross-segment aggregation, and faithful citation rather than relying only on perplexity.
- Reconstruction bandwidth: On-demand decoding reduces persistent memory but may add temporary KV materialization, memory copies, and cross-layer reads. HBM bandwidth, CPU offload, and SSD-backed memory can all change the benefit.
- Batch efficiency: Dynamic memory loading and sparse indices may conflict with the contiguous KV layouts and static batches expected by modern inference engines. Different memory sets per request complicate scheduling, paging, and kernel fusion.
- Training cost: The paper claims coverage of pretraining and post-training adaptation, but the abstract omits training data scale, sequence length, selector optimization, and total GPU time. If sparse Top-k selection is non-differentiable, gradient flow, load balance, and training stability also require analysis.
- Persistent-memory risk: Long-lived interaction introduces stale facts, prompt injection, cross-tenant contamination, and incomplete deletion. Compressed memories need source, version, tenant, and retention metadata rather than ordinary cache treatment.
How to Read the Reported Results
| Metric | Reported in the abstract | What still needs verification | |---|---|---| | State cache at 1M tokens | Reduced by 1,313x | Whether the baseline is full layer-wise KV and whether indices, temporary KV, weights, and host memory are included | | Prefill latency | Reduced by 6.9x | Hardware, precision, batch size, input/output lengths, and warm-cache methodology | | Throughput | Increased by 3.5x | Concurrency, decode steps, and whether retrieval and reconstruction are timed | | Overall memory performance | +5.77% | The metric definition, absolute baseline, and statistical variance are not disclosed |
The paper says experiments cover multiple model sizes, context lengths, and both pretraining and post-training adaptation. It also reports zero-shot transfer to downstream representation tasks. That suggests the learned memory mechanism may generalize beyond text generation, but it does not replace direct evaluation of million-token generation quality. In particular, the reported +5.77% cannot be interpreted as a general capability increase without a precise metric definition and absolute scores.
Benchmarking the Claim
A credible reproduction should include four baseline groups: full KV with GQA, quantized KV, sliding-window or PagedAttention systems, and fixed-state or recurrent architectures. All systems should use the same weights, precision, hardware, batch size, and input/output lengths. Measurements should separately report peak HBM, host memory, TTFT, TPOT, concurrent throughput, and cost per million tokens.
Long-context quality should be decomposed into single-fact recall, multi-hop composition, cross-document aggregation, and generation consistency. Full-context, relevant-position, and random-position controls are needed to detect position bias and shortcut retrieval. Results should include confidence intervals, train-test contamination checks, and quality-latency Pareto curves across memory capacities and Top-k sizes.
Deployment Guidance
MemOnce is most relevant to long-running agents, repository-scale code analysis, legal and scientific document processing, and tool-using systems that repeatedly revisit historical state. Existing vLLM, SGLang, and TensorRT-LLM stacks generally assume layer-contiguous KV tensors, so MemOnce is not a drop-in replacement.
A practical evaluation should proceed in five stages:
- Establish full-KV, quantized-KV, and sliding-window production baselines on identical hardware.
- Implement separate compressed-memory storage, indexing, temporary KV reconstruction, and sparse-attention kernels, timing each stage independently.
- Test quality, TTFT, TPOT, and peak memory on target workloads instead of optimizing prefill in isolation.
- Stress test concurrent requests, heterogeneous memory distributions, and dynamic lengths to validate batching efficiency and tail latency.
- Add memory update, expiry, rollback, deletion, and tenant-isolation tests before moving sensitive workloads into production.
Conclusion
MemOnce's central contribution is a learned compressed-memory path that combines sparse retrieval, cross-layer index sharing, and on-demand KV reconstruction to avoid the scaling limits of token-level history. If its million-token results reproduce under equal hardware, concurrency, and quality constraints, it could become a serious option for long-context inference and persistent agent memory. If quality degradation, reconstruction overhead, or batch fragmentation proves substantial, its advantages may remain confined to low-concurrency, extremely long-context workloads.
— END —Source: Hugging Face Daily Papers (2026-11-20)
Tags: #MemOnce #KV Cache #Sparse Attention #Long Context #Memory Architecture
Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.
Community Comments