The Second Dimension of LLM Sparsity: Conditional Memory

    This article introduces conditional memory as a second dimension of large language model sparsity that complements conditional computation in MoE architectures. It explains why standard Transformers lack a native knowledge lookup primitive, how conditional memory enables constant-time O(1) retrieval through hashed N-gram keys, and how the study frames the design choice as a sparsity allocation problem with a U-shaped scaling curve. It also covers the equal-parameter, equal-FLOPs results at 27 billion parameters, the larger-than-expected gains on reasoning and code benchmarks, and a practical checklist of engineering costs, boundaries, and validation steps.

    1. The Starting Point: Capacity Grew, but Retrieval Is Still Simulated

    Over the past few years, the main line of large language model scaling has been dominated by the Mixture-of-Experts (MoE) architecture. Its core idea is conditional computation: each input activates only a subset of expert networks, so total parameter count can grow substantially while the compute for a single forward pass stays within an acceptable range. This approach has been validated repeatedly, and its engineering ecosystem is relatively mature.

    Zoom out, though, and a structural gap appears: mainstream Transformer architectures have no native knowledge lookup primitive. When a model needs to answer “what is this fact,” it can only produce the knowledge through layer after layer of matrix multiplications and attention operations. Retrieval is an inefficient byproduct simulated by the computation process, not a first-class citizen at the architecture level.

    This leads to three costs that have long been underestimated:

    • Parameter budget mismatch: a large share of parameters is spent carrying static facts that could be expressed with a more compact structure.
    • Diluted effective depth: shallow layers are forced to do memory reconstruction work, squeezing the layers and compute actually available for multi-step reasoning.
    • Incomplete scaling laws: tuning only the “compute sparsity” knob cannot answer what the optimal split between memory and computation should be.

    Conditional memory is the second sparsity dimension proposed to address this gap. It is complementary to conditional computation: one handles dynamic reasoning, the other handles static knowledge access.

    2. The Core Idea: Bringing Lookup Back to O(1)

    The practical module behind conditional memory modernizes the classic N-gram embedding idea. The classic approach counts local fragment co-occurrence and maps each fragment to a vector; the modernized version adds three engineering constraints:

    1. Constant-time addressing. Local fragments in the input serve as keys, and a hash mapping locates the memory slot directly, so lookup complexity is O(1) and does not grow linearly with memory capacity.
    2. Capacity decoupled from compute. The memory table can be made very large, but only a handful of slots are read per pass, so the extra compute from scaling stays approximately constant.
    3. Decoupled from the backbone. The memory module attaches as a pluggable side component next to the backbone network, with a minimal read/write interface that makes replacement and ablation easy.

    Illustrative pseudocode (structure only, not a specific implementation):

    1. # Pseudocode: constant-time lookup for conditional memory
    2. def engram_lookup(tokens, mem_table, top_k=2):
    3. keys = extract_ngram_keys(tokens, n=3) # local fragments as keys
    4. idx = stable_hash(keys) % mem_table.size # O(1) addressing
    5. vec = mem_table.gather(idx) # read only a few slots
    6. return fuse(vec, top_k) # fuse with backbone hidden states

    The key point is that the benefit of this structure does not come from a “bigger table” but from a constant lookup path. That is also the fundamental reason it can stack with conditional computation without the two consuming each other’s budget.

    3. Sparsity Allocation: A U-Shaped Tradeoff Curve

    The study formalizes the problem as sparsity allocation: with a fixed total parameter budget, how much goes to neural computation and how much to static memory. The observed scaling trend is U-shaped—neither extreme (pure computation or pure memory) is optimal, an intermediate ratio performs best, and that ratio shifts in a predictable way as scale changes.

    The practical value of this trend is that it turns architecture design from empirical trial and error into extrapolable planning: given a target scale and compute budget, you can estimate the rough memory-to-compute ratio before training, reducing expensive full-scale comparison experiments.

    Under strictly equal-parameter, equal-FLOPs conditions, scaling the memory module to 27 billion parameters delivered overall performance clearly better than a pure MoE baseline. The methodological point deserves separate emphasis: equal parameters and equal compute are the baseline requirement for judging whether a new dimension genuinely adds value; otherwise it is easy to misread the gains from scaling as gains from architecture.

    4. An Unexpected Finding: Gains Beyond Knowledge Tasks Are Larger for Reasoning and Code

    By intuition, the memory module should mainly benefit knowledge-type tasks, and measurements confirm this: on knowledge evaluations, MMLU improved by about 3.4 and CMMLU by about 4.0.

    More notable is that the gains on general reasoning and code/math tasks were even more pronounced: BBH improved by about 5.0, ARC-Challenge by about 3.7, HumanEval by about 3.0, and MATH by about 2.4.

    The explanation offered is mechanistic: once the burden of reconstructing static knowledge is lifted from the shallow layers, the network’s effective depth increases and more layers can focus on composition, constraint satisfaction, and multi-step derivation. In other words, memory does not replace reasoning; it frees up compute for reasoning. This conclusion is especially relevant for teams working on reasoning enhancement and tool-call orchestration: externalizing knowledge and deepening reasoning can be two sides of the same thing.

    5. Engineering Practice: Costs, Boundaries, and a Checklist

    Every new dimension has a cost, and conditional memory is no exception. Account for four types of overhead before adopting it:

    • Storage overhead: memory table size directly determines memory footprint, so weigh resident memory against remote loading.
    • Addressing stability: hashing and key construction must be consistent across batches and nodes, otherwise hidden “same key, different slot” errors appear.
    • Read/write bandwidth: constant-time lookup assumes random reads are fast enough, so storage media and network topology become the real bottleneck.
    • Fusion strategy: where the memory vector fuses with backbone hidden states (shallow, deep, or every layer) needs its own ablation and cannot simply inherit a default configuration.

    An executable validation order: first run a small-scale equal-parameter comparison to confirm the direction of the U-curve’s inflection point; then fix the ratio and scale up; finally ablate the memory module separately to distinguish “capacity gains” from “structural gains.”

    On the infrastructure side, the requirements this structure places on general cloud capabilities are clear: high-throughput object storage for sharding and versioning memory tables, a container platform to host heterogeneous inference replicas, and logging plus monitoring and alerting to track hit rates and tail latency. General-purpose capability categories are sufficient; no proprietary interfaces are required.

    6. Trend Outlook: Sparsity Moving from One Dimension to Two

    Viewed together, conditional computation and conditional memory show that LLM sparsity is moving from a “single knob” to a two-dimensional plane: one dimension decides how much to compute per pass, the other decides how much to remember per pass. This split makes scaling laws more complete and architecture evaluations more comparable.

    Three practical recommendations for R&D teams: first, write equal-parameter and equal-compute comparisons into the experiment standard; second, evaluate knowledge-type and reasoning-type tasks separately so a single metric does not mask structural gains; third, reserve interfaces and operational paths for “externalized knowledge” during system design. Whoever brings both sparsity dimensions into a unified design language earlier is more likely to achieve higher compute efficiency in the next round of the scale race.