Decoupling Memory from Reasoning in Large Language Models: A Conditional Memory Architecture
This article breaks down an architecture that separates memory from reasoning in large language models. It explains why parameter-based knowledge retrieval causes a compute mismatch in MoE models, how conditional memory modules use deterministic n-gram hashing and static embeddings as a complementary sparsity dimension, the U-shaped scaling relationship between experts and memory, the parameter- and FLOP-matched gains on knowledge and reasoning benchmarks, and the engineering considerations around tiered storage, cost, and risk. Readers will find the core design steps, tuning guidance, and practical tradeoffs needed to evaluate whether a memory layer belongs in their own capacity planning.
1. The Starting Problem: Compute Mismatch in Parametric Knowledge
The scaling path of today’s mainstream large language models relies heavily on conditional computation schemes such as Mixture-of-Experts (MoE): tokens are routed to a small subset of expert networks, so total parameter count can grow while activation size stays controlled. This approach solves how to make computation sparse, but it does not solve how knowledge is retrieved.
The Transformer has no native key-value lookup structure. The factual associations stored in a model’s memory can only be approximately reconstructed in a distributed way through attention and multiple feed-forward layers. As a result, a problem that is essentially equivalent to a table lookup — for example, the attribute of a low-frequency entity, or the continuation of a fixed expression — requires full inter-layer propagation and activation computation before it can be “recalled.” Compute is consumed in large quantities to simulate retrieval, rather than being spent where compositional reasoning is genuinely needed.
Two separable demands exist here:
- Knowledge fragments that must be immediate, precise, and addressable;
- Computation that is multi-step, compositional, and context-sensitive.
Forcing both into the same homogeneous neural computation is a structural source of efficiency loss.
2. The Core Idea: Adding Conditional Memory as a New Sparsity Dimension
The conditional memory module starts by modernizing the classic idea of hash-based n-gram embeddings, as a sparsity dimension that complements conditional computation. The approach boils down to four steps:
- Suffix extraction: take a suffix of length N at the current position (a character-level or byte-level n-gram) as the addressing key;
- Deterministic hashing: map the key to a finite number of slots with a fixed hash function, giving O(1) addressing complexity without relying on a learned router;
- Static embedding lookup: fetch the corresponding vector from an embedding table that consists of read-only parameters and does not participate in the per-token dynamic computation graph expansion;
- Context-gated fusion: generate gating weights from the current hidden state, apply weighted filtering to the retrieved result to suppress hash collisions and noise, then add it back into the main representation.
Illustrative pseudocode (data flow only, not a specific implementation):
def engram_layer(hidden, tail_n=3, num_slots=1 << 22):key = suffix_ngram(hidden, n=tail_n) # take the suffix n-gramslot = deterministic_hash(key) % num_slots # O(1) addressingmem = embed_table[slot] # static read-only embeddinggate = sigmoid(gate_proj(hidden)) # context-aware gatingreturn hidden + gate * mem # residual fusion
The key difference from conditional computation is that MoE routing is learned and drifts during training, whereas memory addressing is deterministic and can be precomputed offline. This yields two direct engineering benefits: addressing behavior is predictable, and the embedding table can live in host memory rather than accelerator VRAM, fetched on demand only when needed.
3. Mixed Budget: The U-Shaped Scaling Law and How to Choose the Split
The research team observed a U-shaped scaling relationship between MoE and the memory module: allocating the entire sparse parameter budget to experts, or entirely to memory, is not optimal; overall model performance is best when roughly 20%–25% of the sparse parameter budget goes to the memory module.
The practical implication is that the memory module is not an add-on decoration but a formal member that competes with expert capacity for budget. During capacity planning, both should be tuned jointly within the same budget pool, rather than fixing expert size first and giving memory the leftover space. Recommended calibration steps:
- Fix the total sparse parameter count and the training compute budget;
- Run a coarse sweep over the 10%–35% range to locate the bottom of the U-shape;
- Refine the step size near the bottom to lock in the final split;
- Record the number of hash slots and the collision rate alongside, so insufficient slots do not eat up the gains.
4. Gains at Equal Parameters and Equal Compute
Experiments on a corpus of about 26.2 billion tokens used a strict parameter-matched, FLOP-matched control setup. At the 27B scale, the improvement over a pure MoE baseline was roughly:
- Knowledge tasks: MMLU +3.4, CMMLU +4.0;
- Reasoning tasks: BBH +5.0, ARC-Challenge +3.7.
The methodological value of these numbers is higher than the absolute values: they show that, with compute held constant, the gains come from assigning tasks to more suitable mechanisms rather than from piling on resources. The fact that both knowledge-type and reasoning-type tasks benefit at the same time also indirectly confirms that separating memory from computation is not a zero-sum tradeoff.
5. Engineering Implementation: Tiered Storage and Cost Structure
Deterministic addressing gives the embedding table an “externalizable” property, which maps in engineering terms onto common storage tiers:
- Hot data: high-frequency slots placed in accelerator VRAM to guarantee access latency;
- Warm data: the full embedding table held in host memory;
- Cold data: the low-frequency portion pushed down to object storage, combined with local caching and prefetching;
- Operations: log services and monitoring alerts used to observe slot hit rate, collision rate, and the degree of gate saturation.
In elastic environments, the container platform orchestrates inference replicas, message queues absorb request spikes, and a configuration center manages hash parameters and table versions, so that “model weights” and “memory table versions” can be released and rolled back independently. The value of this path is that scaling knowledge capacity no longer necessarily means scaling VRAM.
6. Boundaries and Risks
- Hash collisions: too few slots let different n-grams contaminate each other, so the collision rate must be monitored;
- Gate degradation: if the gate stays saturated for a long time, it is equivalent to unconditionally adding noise, requiring regularization and initialization constraints;
- Knowledge freshness: lag in updating the static table introduces stale facts, requiring a versioned update process;
- Table security: an externalized memory table may carry traces of the training corpus, involving access control and redaction auditing;
- Gains depend on task distribution: scenarios dominated by long-chain reasoning with few factual lookups may see limited benefit.
7. Conclusion
Structurally separating memory from reasoning is essentially about applying different treatments by cognitive task type: addressable knowledge goes to deterministic retrieval, and the parts that need composition are left to neural computation. The stable gains achieved under equal compute, together with the cost elasticity brought by an externalizable embedding table, give this idea clear engineering value, and it may also push hardware design away from a pure pursuit of compute toward optimizing heterogeneous computing and storage hierarchies. The advice for developers is straightforward: first run a small-scale split sweep and collision-rate observation on your own corpus, then decide whether to include a memory layer in formal capacity planning.
