Looped Depth Meets YOCO: Architecture Design for Long-Context LLMs

    This article analyzes how combining Looped Depth with the YOCO (You Only Cache Once) architecture addresses the structural bottlenecks of looped models in long-context scenarios, including KV cache expansion, prefill compute waste, and per-token cache misalignment. It explains YOCO's split encoder-decoder design, the remaining challenge of writing intermediate states back to the global cache, and practical deployment recommendations for context layering, loop budgeting, cache governance, and evaluation.

    1. Why Looped Depth Struggles with Long Contexts

    Looped Depth reuses a set of intermediate layers across multiple passes instead of making the model deeper, allowing the same parameters to act at different logical depths. It offers near-deep-model expressiveness with fewer parameters. However, when combined with a standard decoder-only structure, three structural problems emerge.

    KV cache expansion. In a standard decoder-only model, every layer maintains its own independent Key/Value cache, so memory usage scales roughly linearly with the number of layers. Looping a subnetwork of around 28 layers twice doubles the logical depth and doubles the cache, which easily hits memory limits under long context.

    Wasted compute during prefill. In long-context agent workloads, inputs often reach hundreds of thousands of tokens. If looping happens at the front of the network, prefill must run every loop pass for each input token, even though those extra passes add little to the task of reading in the context.

    Cache misalignment from per-token dynamic looping. Ideally, simple tokens run one pass while difficult tokens run several, folding test-time compute into the structure itself. In a pure decoder-only model, however, different loop counts per token break the layer-to-layer KV correspondence, so later tokens cannot read the cache correctly.

    A common industry compromise is to reuse the first pass’s sparse KV for long-range attention, open a separate sliding window for the second pass’s KV at short range, and reuse it through a sparse index. This works, but it requires maintaining two caches and an index, raising engineering complexity and the surface area for bugs.

    2. How YOCO Works

    YOCO splits the network into two halves. The first half consumes the input and builds a global cache once. The second half maintains no global KV of its own; instead, it derives the Key/Value it needs from the earlier layers’ outputs through a mapping. The key property is that the global cache is written only once, and extending the depth afterward adds no new global cache.

    Placing the loop in the second half resolves all three pain points of Looped Depth:

    • No cache expansion: whether the second half loops 2, 4, or 8 times, global KV usage stays constant, making million-token contexts feasible.
    • No looping during prefill: the first half encodes the context in a single pass, leaving the compute budget for decode.
    • Per-token dynamic looping works: each layer in the second half reads the frozen global KV from the first half, so how many times the current token loops locally does not pollute later tokens’ read paths.

    The following pseudocode illustrates the idea: write the cache once, loop only in the second half.

    1. # First half: encode the input, write the global KV once
    2. global_kv = []
    3. for layer in encoder_layers:
    4. global_kv.append(layer.forward_with_cache(x))
    5. # Second half: derive K/V from the frozen global KV, loop any number of times
    6. h = x
    7. for step in range(num_loops): # 1/2/4/8, or decided per token
    8. for layer in decoder_layers:
    9. k, v = layer.derive_kv(global_kv, h) # does not write global cache
    10. h = layer.attend(h, k, v)

    3. The Remaining Problem: Writing Intermediate States Back

    Deep hidden states produced by the second-half loop cannot be written back to the global KV, so the next token only sees the final pass’s output and misses intermediate conclusions from earlier passes. Three compensation approaches are viable: introduce an extra state information stream that carries a low-dimensional summary of each pass along the time dimension; apply gated aggregation at the loop exit to compress multiple passes’ hidden states into a few extra cache slots; or trigger multiple passes only for high-uncertainty tokens to reduce the state that needs writing back. In practice, this extra state should be strictly bounded to a constant size to avoid reintroducing linear growth.

    4. A Neutral Product and Operations Observation

    From a release-cadence perspective, this kind of transitional model update is often tied to subscription quota adjustments and retaining existing users. It is a common operational practice in the industry rather than purely technical. What deserves developers’ attention is the quota structure itself: the nominal multiplier often differs from the actual usable amount, while off-peak or scheduled tasks, when carefully orchestrating long-chain workflows and running concurrent sub-agents reasonably, may consume far more tokens than the base quota. When choosing a model, the core metric should be “task throughput per unit cost” rather than the “nominal quota multiplier.”

    5. Deployment Checklist

    1. Layer the context: put stable, unchanging long context in the first half, and leave the parts needing multi-pass reasoning to the second-half loop.
    2. Keep the loop budget controllable: make the loop count a configuration item, connect it with monitoring, alerting, and logging services, and adjust it dynamically based on token difficulty.
    3. Govern the cache: write the global cache once, carry intermediate states with constant-size summaries, and use object storage or container platforms for elastic scaling.
    4. Unify evaluation metrics: evaluate with the dual metrics of “completion rate per unit cost + long-context recall” to avoid being misled by nominal quotas.

    In summary, combining Looped Depth with YOCO stacks two advantages: trading depth for parameters, and writing the cache only once. The cost is the extra design work needed for the intermediate-state information path. For long-context agent workloads that are prefill-heavy and decode-long, this route offers a clear engineering net positive.