Conditional Memory and Sparse Compute: A New Division of Labor in LLM Architecture
Large language models mix two kinds of work: retrieving stable, repeated patterns and dynamically composing new answers. This article explains how conditional memory complements mixture-of-experts (conditional compute), how short n-gram lookups work, why “constant-time” lookup is not the same as constant latency, how capacity should be balanced, and what training, evaluation, and deployment actually need to measure.
Why LLMs Need a Separate Memory Path
Large language models do two different jobs at once. One is recognizing frequent expressions, calling up stable associations, and recovering knowledge that appears repeatedly. The other is multi-step reasoning over context, handling constraints, and producing new answers. The first is highly repetitive; the second needs dynamic computation.
In a typical attention model, both jobs mostly share the same network parameters. Even a high-frequency term or a fixed phrase often still goes through many layers before the model forms an internal representation. That does not mean the model has no memory. It means memory is usually implicit in the weights, without an explicit, addressable access path.
Mixture-of-experts (MoE) eases the tension between capacity and compute: the model can hold many expert parameters while activating only a subset per input. What it mainly answers is which networks participate in computation. It does not directly answer which stable information can be obtained by lookup.
A useful research direction is therefore to give local, repeatedly accessed patterns to a memory module, and leave understanding, composition, and reasoning to dynamic compute. Complementary conditional memory and conditional compute rest on that split of duties.
Conditional Compute vs. Conditional Memory
Conditional compute is on-demand activation. For a given token position, a router selects some expert networks, runs them, and merges the results into the backbone. Total parameters can be large; only a fraction is used for a single pass.
Conditional memory is on-demand access. The system generates addresses from the input, reads related vectors from a memory table, and uses context to decide whether those vectors should contribute.
The difference is more than “compute versus table lookup”:
- Access target. Conditional compute reads executable transform parameters. Conditional memory reads representations tied to certain input patterns.
- Cost structure. Experts mainly consume arithmetic. Memory lookup depends more on address generation, data movement, cache hit rate, and memory bandwidth.
- Functional boundary. Experts can apply complex transforms to the input. Memory tables are better at carrying repeated patterns and cannot finish arbitrary reasoning from a single read.
Conditional memory is not a replacement for experts. It adds another sparse access path. The two can share a training objective while taking different computational roles.
How Short-Sequence Lookup Memory Works
One workable design uses a short contiguous sequence of tokens as the retrieval cue—an n-gram fragment. Near the current position, the model maps such fragments to addresses and reads vectors from one or more tables.
A technical term may be split across several tokens. A single token is often ambiguous; a neighboring fragment more stably points to that term’s local semantic pattern. The memory module uses that repetition so the backbone does not keep rebuilding the same associations.
A conceptual dataflow is:
input tokens → local fragments → memory addresses → read vectors → context-aware fusion → update backbone representation.
Three steps matter.
Address mapping. Independent entries for every possible fragment explode combinatorially, so hashing (or similar maps) is used to bound table size. Different fragments can land in the same slot (collisions). Multiple maps, mixed fragment lengths, and later context filtering can mitigate this; they do not fully eliminate collisions.
Vector reads. Entries are usually trained continuous vectors, not natural-language facts shown to users. They are internal representation resources, not database records.
Fusion. A retrieved vector is not automatically useful. A fixed phrase may appear under negation; a term may be polysemous. The model still has to gate memory by context.
What “Constant-Time Lookup” Means
A fixed number of address computations and array reads can be constant-time with respect to table size at the algorithm level: growing the table does not require scanning every entry.
That is not the same as constant end-to-end inference latency.
Wall-clock time still depends on how many tables are accessed, how much data is read, cache hits, and which storage tier holds the memory. Cross-device movement can dominate.
Single-position lookup is also not the same as processing a full sequence. Even if cost per position is roughly fixed, more tokens still mean more work.
Engineering evaluation should not report only arithmetic FLOPs. Fuller metrics include bytes read, bandwidth utilization, cache hit rate, batch throughput, and tail latency. A cheap-arithmetic module can still slow inference via random memory access.
Why Memory Might Help Reasoning
Memory is often framed as better knowledge recall, but it may also help reasoning indirectly by reallocating internal work.
If shallow layers spend a lot of capacity reconstructing common phrases, entity links, and fixed expressions, later layers may still receive weak representations. With a memory path, some stable associations can enter the backbone earlier, so later layers spend more capacity on relations, conditions, and multi-step derivation.
“Effective depth” here is not more physical layers. At the same depth, less work may go to reconstructing basic patterns, and a larger share of compute may serve harder tasks.
Attention capacity may also be freed: if some local dependencies are handled by short-sequence memory, attention can focus more on cross-paragraph links and long-range integration.
These accounts need experiments. Gains might also come from extra representation capacity, optimizer dynamics, or training setup. A single overall score does not prove that the reasoning mechanism itself changed.
Balancing Memory and Compute
More memory capacity does not automatically keep improving results. Under a fixed budget, tables and experts compete for parameters, storage, and training resources.
Too little memory, and stable patterns are still rebuilt in the backbone. Too much, and dynamic compute is squeezed, hurting novel problems and hard constraints.
That is why capacity-allocation studies can show better middle settings and worse extremes. A U-shaped curve must specify the y-axis: if it is loss or error, a lower middle is better; if it is accuracy, the curve may reverse.
The best mix is not a universal constant. Knowledge-heavy, math, and long-document tasks need different amounts of static association vs. dynamic compute. Data repetition, model scale, and hardware bandwidth also shift the sweet spot. Treat allocation as an architecture search variable, not a fixed ratio.
Training and Evaluation Design
To test whether gains really come from conditional memory, hold data, token budget, backbone, optimization, and eval protocol as constant as possible.
Compare at least three resource views:
- total parameters (overall capacity);
- parameters actually accessed or activated per token (sparsity);
- real hardware cost (compute, memory traffic, communication, latency).
Equal total parameters does not mean equal cost; equal arithmetic does not mean equal throughput. For production, measured cost matters more than a single theoretical number.
Cover multiple abilities: knowledge tasks for stable recall; reasoning tasks for benefits beyond direct memorization; long-context tasks for distant integration; out-of-distribution tasks for over-reliance on frequent fragments.
Ablations can turn off the memory path, shrink tables, change fragment length, or alter fusion. Score seen vs. unseen expressions separately so pattern replay is not mistaken for generalization.
Deployment Issues That Are Easy to Miss
Storage layout. Large tables may not fit in fast device memory. Hierarchical storage trades capacity, caching, and read latency.
Training updates. Access is often skewed: hot entries update a lot, rare ones may be undertrained. Optimizer-state memory is also non-trivial at large table sizes.
Hot spots and collisions. Frequent fragments can concentrate traffic and hurt parallelism; hash collisions can force unrelated patterns to share a representation. Use access stats and ablations.
Knowledge governance. Addressable tables do not automatically provide provenance, access control, or precise edits. A fact may be spread across vectors; changing one slot can affect other patterns.
For internal documents, changing policy, or answers that need citations, external retrieval and business rules may still be required. Internal memory is about representation access efficiency, not a drop-in auditable knowledge system.
When It Is Worth Using
For jargon-heavy work with clear repeated patterns, conditional memory is worth a focused evaluation. For highly dynamic, latest-fact, or permission-sensitive work, prefer knowledge update paths and external retrieval.
A practical path is: set a baseline, verify the source of gains at limited scale, then grow capacity and measure real serving cost. Test inputs should vary length, concurrency, and traffic mix—not only offline averages.
The main architectural idea is a reliable split of labor: repeated patterns need not always be reconstructed by deep compute, and complex derivation should not be replaced by a simple lookup. A useful design makes memory access and dynamic compute complementary, with a verifiable trade-off among accuracy, generalization, latency, and storage.
