Conditional Memory: A New Dimension of Sparsity for Large Language Models

    Conditional memory adds a second axis of sparsity to large language models, alongside mixture-of-experts. It moves part of a model's knowledge into an external lookup memory that is retrieved on demand. This article covers how the design separates memory from computation, how CPU and GPU share inference work, how it supports long-context processing and multi-turn serving, and what it suggests for future model architecture.

    Conditional Memory: A New Dimension of Sparsity for Large Language Models

    1. Background: The Knowledge Storage Problem in Large Models

    Large language models face a central tension: their knowledge capacity and their computational cost are tightly linked. In dense architectures, all knowledge is compressed into the weights of the neural network, and each inference pass activates all or most of those parameters. Giving a model more knowledge therefore requires more parameters, and more parameters raise the compute cost of both training and inference.

    Mixture-of-experts (MoE) architectures introduced the first path to sparsity through conditional computation. Each forward pass activates only a subset of expert networks, which keeps per-pass compute manageable even when the total parameter count is large. However, MoE addresses computational sparsity. Knowledge remains distributed and implicitly encoded in the weights, so retrieving it still requires expensive matrix operations.

    Conditional memory was proposed to open a second axis of sparsity: memory sparsity. The core idea is that not all knowledge is needed in every inference step. Part of that knowledge can be moved out of the weights and into a separate memory module, then retrieved and used only when needed.

    2. Core Principle: A Scalable Lookup Structure as Memory

    2.1 From Remembering to Looking Up

    The key innovation of the conditional memory architecture is a scalable lookup structure that serves as an external memory module. This module organizes knowledge in a form similar to a key-value memory table. During training, the model learns to write part of its factual and pattern-based knowledge into the table. During inference, it retrieves relevant entries based on the current context and injects the results into the computation.

    This design resembles how people combine working memory with external notes. The brain handles reasoning and integration, which corresponds to dense computation on the GPU. Detailed facts are recorded externally, in the memory table held in host memory. They can be looked up quickly when needed without being memorized in full.

    2.2 Performance Gains at Equal Parameters and Compute

    The main value of this architecture is better model performance under strict constraints of equal parameters and equal compute. The approach works in three parts:

    1. Knowledge offloading: Declarative knowledge that would otherwise occupy weight capacity moves to the memory table. The freed parameter budget can go to reasoning and compositional generalization, which depend more on computation.
    2. Retrieval instead of computation: Lookup operations have much lower computational complexity than large matrix multiplications. Inexpensive memory retrieval replaces costly floating-point operations, which redistributes the compute budget.
    3. Linear capacity scaling: Expanding the memory table does not require adding layers or increasing hidden dimensions. In principle, knowledge capacity grows linearly with memory footprint, while inference compute stays nearly unchanged.

    Experiments show notable gains on tasks including knowledge retrieval, logical reasoning, code generation, and math problem solving. The advantage is especially clear in scenarios that require precise factual recall.

    3. Separating Storage from Compute: Collaborative CPU-GPU Inference

    3.1 Division of Labor

    The conditional memory architecture separates storage from compute:

    • GPU (compute side): Handles dense computation such as attention and feed-forward networks. These tasks demand high compute, but their data access patterns are regular.
    • CPU (retrieval side): Handles lookups in the memory table. The table resides in host memory (DRAM), and the CPU performs key matching and reads the matching entries.

    3.2 Parallel Pipeline Design

    The real advantage of separating storage from compute lies in parallelism. Because retrieval and computation are decoupled, the system can run inference as a pipeline. While the GPU computes layer N, the CPU can prefetch the memory entries that layer N+1 may need. With suitable scheduling and prefetch strategies, retrieval latency can be hidden behind compute time, so retrieval adds little to overall latency.

    3.3 Easing GPU Memory Pressure

    This design brings an important engineering benefit: it significantly reduces GPU memory requirements. GPU memory capacity has become a major bottleneck for deploying large models. Keeping most of the knowledge in lower-cost, easily expanded host memory means:

    • Models with larger knowledge capacity can be deployed on the same hardware.
    • Memory allocation across inference clusters can be more flexible, which can lower the total cost of ownership.
    • Edge and heterogeneous deployments have new possibilities.

    Organizations that want to deploy large models on their own infrastructure can combine this storage-compute separated architecture with general-purpose container platforms, object storage, and monitoring and alerting tools. Together, these components can form an efficient inference service platform.

    4. Long-Context Capability: Retrieving Information Across a Million Tokens

    Combining conditional memory with sparse attention gives the model the ability to process very long contexts. The approach works like a two-level index:

    • Sparse attention builds selective dependencies within a sequence. This avoids the quadratic compute cost of full attention.
    • Memory lookup quickly locates information in contexts longer than one million tokens. It works as an external index for very long text.

    Together, these two levels let the model take in the whole input and also find the right details in long documents, large codebases, and complex multi-turn conversations.

    5. Supporting Engineering: Inference Framework and Training Architecture

    5.1 Dual-Path Inference Framework

    Model responses slow down over long multi-turn conversations. To address this, the supporting inference framework uses a dual-path design. Stable historical context is processed on one path, and the dynamic incremental computation runs on another. This avoids reprocessing the entire history on every turn. The approach matters most for online services. In a conventional architecture, latency accumulates as a conversation grows longer. Separating the two paths keeps response latency more stable and predictable.

    5.2 Coordination with the Training Architecture

    Architectural innovation depends on training methods. The conditional memory architecture works with a high-performance training architecture released earlier. Training must address several challenges:

    • Differentiable retrieval: Lookup is inherently discrete. Techniques such as gating, soft addressing, or the straight-through estimator make it differentiable, which enables end-to-end training.
    • Stable memory writes and updates: Memory table contents keep changing during training. Update strategies must avoid overwriting existing knowledge and prevent catastrophic forgetting.
    • Load balancing: As with MoE, the system must prevent degenerate “hot entries” that are accessed excessively while others stay idle for long periods.

    6. Open-Source Ecosystem and Outlook

    The memory module of this architecture was open-sourced alongside the paper, giving the community a reproducible base that can be extended. Looking further ahead, conditional memory represents an important direction in LLM architecture: decoupling parameters, computation, and memory.

    Directions to watch include:

    1. Dynamic editing of memory: An external memory table naturally supports adding, updating, and deleting knowledge. This offers a lighter path than fine-tuning for knowledge updates, error correction, and removal of private data.
    2. Tiered storage: Borrowing from storage systems, hot knowledge can stay in GPU memory, warm knowledge in host memory, and cold knowledge on disk or remote storage, forming a multi-level memory hierarchy.
    3. Integration with retrieval-augmented generation (RAG): Conditional memory can be seen as built-in RAG. The boundary between the two and the ways to combine them merit further study.

    7. Conclusion

    Conditional memory adds a scalable lookup structure to LLMs, opening a sparsity path separate from conditional computation. Its main features are separating storage from compute, CPU-GPU collaborative inference, retrieval over contexts of a million tokens, and better performance at equal parameters and equal compute. These features show the potential of this direction. For developers, understanding how computation and memory can be decoupled helps in tracking how next-generation model architectures are evolving. It also supports more forward-looking decisions in model selection, inference deployment, and system design.