Recurrent Computation and Shared Caching: An Architectural Evaluation for Long-Context Models

    This article examines how recurrent computation and shared caching behave in long-context language models. It separates three concerns that are often conflated—parameter sharing, computation reuse, and history-state sharing—and explains why introducing recurrence into a standard autoregressive attention stack can inflate the key-value cache. It then presents a decoupled design that separates memory construction from recurrent reading, discusses the conditions under which prefill can skip recurrence, weighs the benefits and costs of per-token dynamic recurrence, and proposes a concrete evaluation methodology and implementation order. The goal is to help developers judge whether added computation yields verifiable quality gains while keeping cache growth, prefill semantics, and serving efficiency under control.

    1. Evaluating Recurrent Architectures Requires More Than “A Few Layers Run Multiple Times”

    The core idea of recurrent computation is to apply the same set of network layers to a hidden state over multiple rounds, increasing the model’s effective computational depth. What distinguishes it from simply adding more layers is that different rounds can share parameters, but the computation process does not automatically share all intermediate states.

    For example, a compute module executed for two consecutive rounds may not increase the parameter count, yet the amount of computation, temporary activations, attention state, and inference scheduling overhead can all change. Evaluating this kind of architecture therefore requires answering three separate questions:

    1. Are parameters shared? This determines the weight storage footprint.
    2. Is computation repeated? This determines actual compute consumption.
    3. Is history state shared? This determines cache size during long-context inference.

    These three must not be conflated. “Achieving deeper computation with fewer parameters” does not mean “lower inference cost,” nor does it mean “the long-context cache will not grow.”

    The most valuable core question in the original technical discussion is where the recurrent module should sit and what relationship it should have with historical memory. Rather than evaluating one specific model, it is better to abstract this into a general architectural question: How can recurrent computation increase the processing depth of the current state without letting the history cache inflate in step with the number of rounds?

    2. Why Recurrence in a Standard Autoregressive Architecture May Increase the Cache

    2.1 The key-value cache stores historical computation results

    During autoregressive generation, the current token must read information from previous tokens through attention. To avoid recomputing the entire history for every generated token, inference systems typically store the keys and values produced by each attention layer; these states form the key-value cache.

    Ignoring special compression and sharing strategies, the storage footprint can be approximated as:

    Cache size ≈ 2 × batch size × history length × number of cached layers × number of key-value heads × per-head dimension × bytes per element

    Here the factor of 2 corresponds to keys and values respectively. This expression ignores memory alignment, paging management, metadata, and differences across layer structures, but it is enough to show the main growth factors.

    In long-context scenarios, the history length keeps increasing. If every recurrent round introduces a set of historical key-value states that must be stored independently, then the cache size may grow with the number of rounds.

    2.2 Sharing weights does not mean key-value states can be shared

    Even if two rounds use the same weights, as long as they receive different hidden states, the keys and values they produce are usually different too. Therefore, identical parameters do not justify treating the caches of different rounds as the same data.

    In one direct implementation, the first round’s current state reads the first round’s history cache, and the second round’s current state reads the second round’s history cache. Here, increasing the number of rounds means maintaining more historical states.

    But this is not an inevitable outcome for all recurrent models. Whether the cache must be stored per round depends on the attention structure, the state-update rules, and the training approach. A rigorous statement would be: Directly introducing recurrence into a standard attention module may cause round-dependent cache growth; the specific magnitude of growth must be analyzed against the implementation.

    2.3 Hybrid caching can mitigate the problem but adds system complexity

    One compromise is to distinguish long-range history from short-range context:

    • Long-range information uses fewer shared, compressed, or sparse states;
    • Short-range information retains more fine-grained, round-dependent states;
    • Retrieval or indexing reduces the number of historical positions actually accessed.

    This design can control part of the storage and access cost, but the semantics of each cache must be made explicit. For example, which round’s representation the long-range history retains, how the local window updates, and whether the index still applies to subsequent rounds.

    In particular: An index can be reused, but that does not mean the retrieval results remain valid. Once recurrent updates change the query representation, the existing index or candidate set may fail to cover the newly relevant positions, so training design, index refreshing, or quality validation is needed to ensure effectiveness.

    The difficulty of such schemes therefore lies not only in the model structure but also in cache consistency, position management, and inference-kernel implementation.

    3. Decoupling Input Encoding from Recurrent Reading

    A more suitable approach for controlling recurrent cache growth is to separate “building historical memory” from “reading historical memory.”

    The model can be abstracted into two parts:

    • Memory construction module: processes the input and produces key-value states that later computation can read.
    • Iterative computation module: updates the current hidden state and reads existing memory through attention, but does not rebuild a complete global history cache for every round.

    The conceptual structure can be expressed as:

    Input sequence → memory construction module → shared historical memory
    Current hidden state → iterative computation module → reads shared memory → updates hidden state

    The point here is not the number of modules, nor is it necessary to split the network evenly in half; the point is to establish a clear read/write boundary.

    3.1 The number of rounds and global memory capacity can be decoupled

    If each iteration only updates the query and the current hidden state and reads the same historical key-value memory, then increasing the number of rounds need not increase the capacity of this global memory.

    Let the shared memory capacity be M and the number of rounds be R. Under the conditions above, the global memory capacity can stay at M rather than growing with R.

    However, total GPU memory may still change. Extra rounds can increase the temporary workspace, the current-token state, and certain local caches. Training also involves saving activations for backpropagation. Therefore, “the global history cache does not grow with the number of rounds” is a local conclusion and must not be extended to “all memory overhead stays constant.”

    3.2 Shared memory does not make attention computation free

    Each iteration still needs to read memory, compute attention, and update state. Even with a fixed cache size, runtime and memory-bandwidth consumption may still grow with the number of rounds.

    For long history sequences, if every round performs dense global attention, recurrent computation may make cache reads a clear bottleneck. In that case, local attention, sparse reads, memory compression, or other validated access optimizations still need to be considered.

    Therefore, this architecture mainly solves the repeated-storage problem and does not automatically solve the repeated-read problem.

    3.3 The memory producer may also need its own cache

    Which module generates the shared memory, and how that module handles new tokens, must also be made explicit. If the memory construction module contains autoregressive attention, it may itself maintain a history cache.

    A complete evaluation should account for the following overhead together:

    • The history state of the memory construction module;
    • The shared keys and values read by the iterative module;
    • The local state of the iterative module;
    • Index, paging, and scheduling metadata;
    • Temporary workspace during inference.

    It is not valid to observe only that the latter part has no independent global cache and then infer that the whole system has no long-context storage pressure.

    4. Whether Prefill Can Skip Recurrence Depends on Dependencies

    Long-context inference is usually divided into two phases.

    The prefill phase processes the existing prompt and establishes the state needed for subsequent generation; the token-by-token generation phase keeps producing new tokens on top of the existing state.

    An attractive design is to build the shared memory mainly during prefill and leave more iterative computation to the generation phase. This could reduce the computation spent on repeated modules for long prompts.

    But this benefit has clear conditions.

    If the generation of subsequent memory depends on the representation of the prompt after multiple rounds of iteration, then prefill cannot skip these iterations directly. Otherwise, the cache content changes, and what the generation phase reads is no longer the state the model originally defined.

    Only when the architecture has already decoupled memory construction from subsequent recurrence, or when the model has been trained to allow fewer rounds during prefill, is it possible to reduce the iterative cost of this phase.

    It is also worth checking whether training and inference are consistent. If the prompt always goes through full recurrence during training but recurrence is temporarily omitted at inference, model quality may degrade.

    Therefore, “whether prefill needs recurrence” should be treated as an architectural property that must be proven, not a capability that comes naturally with shared caching.

    5. Per-Token Dynamic Recurrence: Potential and Cost Coexist

    A fixed number of rounds assigns the same compute budget to every token, but tokens differ in generation difficulty. Dynamic recurrence aims to let easy positions stop earlier and complex positions perform more state updates.

    However, token difficulty cannot be judged by surface type alone. Punctuation may involve key structural constraints, and common words may carry important choices in reasoning. Practical stopping strategies usually need to combine the model’s internal state, changes in the prediction distribution, or a trained control mechanism.

    5.1 Stopping conditions must be quality-calibrated

    Signals that can be studied include:

    • The magnitude of change in the hidden state between adjacent rounds;
    • Whether the output distribution is stabilizing;
    • The model’s predictive uncertainty;
    • A purpose-trained stopping-discrimination signal.

    None of these signals is a naturally reliable answer. For example, a stable output distribution may just mean the model keeps insisting on the same wrong judgment over multiple rounds. Therefore, it is necessary to verify whether the stopping strategy harms factual accuracy, instruction following, or long-range dependency handling.

    5.2 Dynamic recurrence makes batching irregular

    Requests in the same batch may need different numbers of rounds. How finished requests exit and how still-computing requests are regrouped both affect device utilization.

    If all requests simply wait for the slowest one, the theoretical compute savings of dynamic recurrence may not translate into actual throughput gains. A more reasonable implementation needs to support active-request filtering and batch regrouping while controlling the overhead of these operations themselves.

    5.3 A compute budget and fallback mechanism are needed

    A dynamic strategy should have a maximum round budget to prevent individual requests from occupying resources indefinitely. For cases that reach the budget without meeting the stopping condition, the system can end the iteration and output, or enter a predefined fallback flow.

    These strategies need to be evaluated together with task-quality goals; a drop in the average number of rounds alone should not be the success criterion.

    6. Evaluation Methodology for Long-Context Tasks

    Long-context agent tasks may involve document retrieval, dialogue history, task planning, and execution feedback. For such applications, architectural evaluation should cover at least the following dimensions.

    6.1 Memory: measure the peak, not just the formula

    Record peak GPU memory under different history lengths, batch sizes, and round counts, distinguishing weights, history cache, temporary workspace, and management overhead.

    In particular, check whether memory fragmentation appears as history grows, and whether dynamic batching adds extra reserved space. Identical theoretical cache capacity does not guarantee identical peak GPU memory in real runs.

    6.2 Latency: measure the two phases separately

    Prefill time, first-token latency, subsequent-token latency, and end-to-end completion time should be recorded separately.

    Recurrence may improve quality but raise generation latency; prefill optimization may also be offset by subsequent repeated reads. Only phase-by-phase measurement can locate the actual gains and bottlenecks.

    6.3 Quality: verify that long-range information is actually used

    Supporting a very long input does not mean reliably using the information within it. Tests should cover long-range fact extraction, multi-segment information combination, conflict resolution, and changes in information position.

    For agent tasks, it is also worth verifying whether the model can distinguish valid history from stale state, avoiding treating an already-invalid execution result as a current fact.

    6.4 Scalability: observe real serving load

    Single-request experiments do not fully represent online serving. Concurrency and length-distribution changes should be added to observe tail latency, throughput, cache-management efficiency, and the scheduling cost introduced by dynamic recurrence.

    Any ultra-long-context capability should be based on the full configuration and measured results; one cannot infer stable handling of a specific length merely from “shared caching.”

    In practice, start by establishing a baseline with a fixed number of rounds, confirm that the computation semantics and cache reads/writes are correct, and then introduce optimizations step by step.

    Step 1: Draw a state-dependency graph, making explicit what each module reads and writes and which states must be preserved across tokens.

    Step 2: Verify the output quality of the shared-memory scheme under short context, ruling out cache-reuse or position-management errors.

    Step 3: Gradually increase the context length, recording the cache-growth curve, access overhead, and quality changes.

    Step 4: Verify whether reducing prefill rounds changes the memory semantics, and evaluate the corresponding training design.

    Step 5: After the fixed-round scheme is stable, introduce dynamic stopping and compare compute cost and serving latency under the same quality target.

    This order avoids modifying the model structure, the caching mechanism, and the scheduling strategy all at once, which would make problems hard to localize.

    8. Conclusion

    The value of recurrent computation is to increase effective computational depth while sharing parameters; the value of shared historical memory is to reduce the repeated storage of historical states. Combining the two has potential, but the benefits rest on clear state dependencies and read/write boundaries.

    For developers, the most important judgment is not “how many rounds” or “how many layers,” but whether the added computation brings verifiable quality gains, whether cache growth is controlled, whether prefill optimization preserves the model’s semantics, and whether dynamic scheduling can deliver efficiency gains under real load.

    Only by placing computation, storage, quality, and serving performance within the same evaluation framework can one make a reliable judgment about long-context recurrent architectures.