Understanding CED Architecture: Why It Makes LLM KV Cache So Much Cheaper

    This article breaks down the CED (Encoder-in-Decoder) architecture introduced in a recent lightweight LLM technical report and explains why it can dramatically cut KV cache costs. It reviews how standard Decoder-only models use KV caching, shows how CED compresses the prompt into a small set of anchors so that decode-time cache size is decoupled from prompt length, and clarifies why CED remains a single unified model rather than a two-tower Encoder-Decoder design. It also covers the tradeoffs, the memory/throughput/scheduling benefits, and practical guidance for evaluating and adopting this kind of architecture in production.

    1. Introduction: Why Inference Cost Is the Core Bottleneck for LLM Adoption

    In recent years, the inference cost of large language models has been a key factor limiting their large-scale adoption. As model parameter counts and context windows keep growing, the KV cache (Key-Value Cache) used during inference consumes GPU memory that grows linearly, or even faster. Common industry optimizations—context parallelism, paged cache management, cache quantization—mostly work at the level of “how to manage the cache” and rarely touch the more fundamental question of “how to reduce the cache itself at the architecture level.”

    A recent technical report on a new-generation lightweight model proposed an architecture called CED (Encoder-in-Decoder), which has sparked wide discussion. At first glance, some assumed the model had abandoned the mainstream Decoder-only approach in favor of an early Encoder-Decoder dual-tower design. But a careful reading of the report shows this is not the case: the entire model is still a single unified network, with no separate Encoder and Decoder models. So what exactly is CED, and why does it make the cache “cheap”? This article systematically unpacks the question.

    2. Background: The Decoding Process and KV Cache in Decoder-only Architectures

    To understand the motivation behind CED, we first need to review the inference process of the mainstream Decoder-only architecture.

    2.1 The Basic Autoregressive Decoding Flow

    Decoder-only models generate text autoregressively: each time a token is generated, it is fed into the model and computes attention together with the historical context. If the Key and Value projections for all historical tokens were recomputed at every step, the computation would grow quadratically with sequence length. So the industry widely adopts KV caching: the Key and Value tensors of historical tokens are cached at each layer, and subsequent decoding steps only compute the Query, Key, and Value of the new token, then perform attention against the cached K and V.

    Illustrative inference pseudocode:

    1. for step in range(max_new_tokens):
    2. q, k, v = model.forward(new_token, position=cur_pos)
    3. kv_cache.append(k, v) # Append to the cache
    4. attn_out = attention(q, kv_cache) # Attend over all historical K/V
    5. new_token = sample(attn_out)

    2.2 What Makes Up the Cost of the KV Cache

    The GPU memory used by the KV cache can be roughly estimated as:

    1. cache size ≈ 2 × num_layers × num_kv_heads × head_dim × seq_len × bytes_per_value × batch_size

    As shown, its footprint is proportional to sequence length and concurrent batch size. In production scenarios with long context and high concurrency, the KV cache often takes up the bulk of an inference instance’s GPU memory, directly leading to:

    1. High unit cost: memory is filled by the cache, so batch size cannot be increased and compute utilization stays low;
    2. Limited concurrency: the number of requests a single instance can serve simultaneously is constrained by cache capacity;
    3. Especially expensive for long context: the cache grows linearly with context length, so costs climb sharply for long documents, multi-turn conversations, and agent-style applications.

    This is the essence of an “expensive cache”: it not only occupies memory but also squeezes throughput.

    3. The Core Idea of CED: Making the Prompt Portion “Cache-Free”

    3.1 Key Observation: Not All Tokens Have Equal Cache Value

    An important fact is that in an inference request, the input prompt portion (system prompts, retrieved documents, conversation history, tool descriptions, and so on) is accessed repeatedly at every decoding step, yet its token representations are fixed within a given request. In a traditional Decoder-only model, however, the prompt portion and the generated portion are treated equally—both maintain a full KV cache and participate in causal attention, and each generated token must attend to every prompt position one by one.

    The insight behind CED is this: process the prompt portion in an Encoder-like manner in a single pass, compress it into a small number of “anchor” representations, and during decoding cache only the K/V of these anchors rather than the K/V of every prompt token. As a result, no matter how long the prompt is, the cache size that must be maintained during decoding is decoupled from prompt length and depends only on the number of anchors and the number of already-generated tokens.

    3.2 Why It Is Still a Single Model, Not a Dual Tower

    It is worth emphasizing that CED does not return to the early “one Encoder model + one Decoder model” dual-tower structure (like classic Seq2Seq translation models, where the prompt is encoded by a separate Encoder into a sequence of hidden states, which a separate Decoder then reads via cross-attention). The implementation described in the technical report is done within the same Transformer network:

    • The model as a whole is still a unified Decoder-only backbone, with shared parameters and a single structure;
    • During the forward pass, the prompt is compressed and aggregated into a fixed number of memory slots through an internal mechanism;
    • The generation phase decodes in the standard autoregressive way, with attention reading information from the cached slots.

    In other words, “Encoder” here refers to a computational paradigm for processing the input segment (no cache dependency, one-time aggregation), not a separate network entity. This is also why a first read of the technical report can easily lead to misunderstanding.

    3.3 Comparison: Traditional Approach vs. CED

    Dimension Traditional Decoder-only full cache CED architecture
    Cache size Grows linearly with prompt length Largely decoupled from prompt length
    Long-context cost High, easily memory-constrained Significantly reduced
    Prefill compute Regular per-token compute Adds compression/aggregation overhead
    Attention access Fine-grained per token Indirect via anchors
    Best-fit scenarios Short context, optimal precision Long prompts, multi-turn, agent scenarios

    As shown, CED is essentially an architecture-level tradeoff of “trading controllable information compression for a large reduction in cache cost.”

    4. Why CED Makes the Cache “Cheap”: Benefits on Three Levels

    4.1 Memory Level: An Order-of-Magnitude Drop in Cache Footprint

    Suppose a prompt is 10,000 tokens long and compresses to only a few hundred anchors; then the KV cache for that request can shrink by more than an order of magnitude. This means the same memory can host more concurrent requests, or support longer context inputs.

    4.2 Throughput Level: Larger Batches, Higher Compute Utilization

    The reduction in cache directly frees up memory, allowing the inference engine to increase batch size. For autoregressive inference—a typical memory-access-bound workload—a larger batch significantly amortizes the average compute and memory-access cost per token, and the per-token inference price drops accordingly.

    4.3 Scheduling Level: Friendlier Cache Swapping and Reuse

    In real serving, multi-turn conversations often want to reuse the KV cache from the previous turn (prefix cache reuse). With CED, each turn’s cache anchors are a fixed, compact representation, so reuse and swapping happen at a finer granularity and are simpler to manage, lowering system complexity and cost in long-session scenarios.

    5. Tradeoffs: There Is No Free Lunch

    For rigor, the tradeoffs of CED must be discussed:

    1. Information compression loss: compressing tens of thousands of tokens into a few anchors inevitably risks information loss, which may reduce precision for tasks that require exact localization (such as quoting text verbatim or pinpointing a specific number in a long document);
    2. Prefill overhead: compression and aggregation require extra computation, so for short prompts the benefit may be marginal or even negative;
    3. Task fit: the biggest gains come from “read-heavy, write-light” scenarios where the prompt is far longer than the output—long-document QA, multi-turn conversation, agent tool calls; short-input, verbatim-retrieval tasks need careful evaluation.

    So the industry is more likely to take this path: within a unified tech stack, offer model variants with different positioning (such as a lightweight Flash version and a high-precision Pro version) that make differentiated architecture choices for different workload characteristics, letting users pick per scenario.

    6. Practical Guidance: How Developers Should Evaluate and Choose

    For developers and architects deploying LLMs in production, this kind of new architecture is best evaluated from the following angles:

    1. Profile your own workload: analyze the distribution of prompt lengths, output lengths, and the share of multi-turn requests in production; if the prompt-to-output ratio is high, cache-optimization architectures yield significant benefits;
    2. Build a precision regression baseline: construct an evaluation set from real business data, focusing on long-context exact-retrieval use cases, and compare output quality between the old and new architectures;
    3. Combine with cloud inference capabilities: mainstream cloud platforms (such as Baidu AI Cloud’s inference services and container platforms) generally provide elastic scaling, cache management, and monitoring/alerting; combining architecture-level cache optimization with platform-level resource scheduling is what turns the cost advantage into real business value;
    4. Migrate gradually: validate stability and cost of the new architecture on non-critical paths first, then ramp up gradually.

    7. Conclusion

    The emergence of the CED architecture marks a shift in LLM cost optimization from purely engineering techniques (quantization, paging, parallelism) toward architecture-level innovation. It does not overturn the Decoder-only paradigm; instead, it introduces an “Encoder-style” input-processing idea within it, loosening the coupling between the KV cache and prompt length at the root. For developers, understanding the “compression and tradeoff” thinking behind such architectures matters more than memorizing any specific solution—on the balance between cost and precision, there is no universal optimum, only the choice that matches your own workload characteristics.