LLM Inference Optimization with Asymmetric Encoder-Decoder Architectures

    This article explains how asymmetric architectures optimize large language model inference by splitting a model into a self-decoding front segment and a cross-decoding back segment. It covers cross-layer key-value reconstruction, the benefits for prefill and decode workloads, comparisons with similar designs, practical guidance for staged deployment, and the risks and boundaries of this approach.

    1. From Homogeneous Stacking to Asymmetric Division of Labor: Where the Problem Starts

    Over the past few years, the backbone of mainstream large models has become highly homogeneous: a number of structurally identical decoder blocks are stacked in sequence, and each layer performs two fundamentally different kinds of work at the same time. One is prefill, which ingests thousands of input tokens at once and is compute-intensive, highly parallel, and has high arithmetic intensity. The other is incremental decode, which generates only one token at a time and is memory-access-intensive, low in parallelism, and latency-sensitive.

    Forcing both workloads onto the same set of weights and the same execution path creates three structural conflicts:

    1. Conflicting resource profiles: Prefill consumes compute, while decode consumes bandwidth. The same batch of devices can rarely be at the optimal operating point for both at once.
    2. Asymmetric memory usage: The key-value cache (KV Cache) grows linearly with context length, while the number of layers actually involved in “understanding the input” and the number actually involved in “generating token by token” are two quantities that can be decoupled.
    3. Coarse scaling granularity: You can only replicate the entire model, with no way to scale the two stages separately. This leads to both wasted resources during peak periods and queuing delays.

    As a result, the industry has begun exploring an idea: since the two workloads have different characteristics, there is no need to force symmetry. Let the front and back halves of the model take on different responsibilities, and let prefill nodes and decode nodes run networks of different depths—this is the core motivation behind the “asymmetric architecture.” The recently discussed “self-decode front segment + cross-decode back segment” approach is a concrete embodiment of this idea.

    2. Core Mechanism Breakdown: Cross-Layer Key-Value Reconstruction

    The most critical structural design in this type of approach can be abstracted into three steps:

    • Split: Divide an L-layer model (for example, 49 layers) into a front-segment Self-Decoder (roughly the first 25 layers) and a back-segment Cross-Decoder (the remaining layers).
    • Reconstruct: The keys (K) and values (V) of the back segment are no longer computed independently from the original input. Instead, they are regenerated from the hidden states output by the front segment through a projection mapping.
    • Exit: During prefill, only the front segment needs to run to produce hidden states and exit; the back segment does not participate. During decode, the full pipeline advances token by token.

    Expressing this “path asymmetry” in pseudocode makes it more intuitive:

    1. # Stage 1: Prefill, front segment only
    2. def prefill(input_ids):
    3. h = embed(input_ids)
    4. for layer in self_decoder_layers: # first 25 layers
    5. h = layer(h)
    6. kv_cache = project_to_kv(h) # K/V reused by the back segment
    7. return h, kv_cache
    8. # Stage 2: Incremental decode, full pipeline
    9. def decode(last_h, kv_cache):
    10. for layer in cross_decoder_layers: # remaining 24 layers
    11. k, v = layer.reproject(last_h) # reconstructed from front-segment hidden states
    12. kv_cache.append((k, v))
    13. last_h = layer(last_h, kv_cache)
    14. return sample(last_h)

    The benefits can be summarized in three points: the compute cost of prefill is reduced roughly in proportion; the weight footprint on prefill instances drops accordingly; and the front and back segments can be deployed on nodes of different specifications and counts, enabling true stage-wise scaling.

    3. Comparison with Similar Designs Inspired by Generative Decoding Approaches

    It is worth noting that this idea of “reusing hidden states across layers” is not an isolated product. There are already several related threads in academia and industry: some generate a global cache in one pass for subsequent layers to share, some share keys and values across layers to compress cache size, and others reuse prefixes across requests to reduce repeated computation. What they have in common is breaking the default assumption that “every layer computes K/V independently,” replacing it with “compute once upstream, project and reuse downstream.”

    The differences mainly lie in three places: whether the split point is configurable, the number of parameters and degree of nonlinearity in the projection mapping, and whether a small number of “true decode layers” are retained to preserve expressiveness. To assess whether a solution is credible, it is recommended to focus on verifying three things: whether quality metrics such as perplexity are compared after the split, whether the extra overhead introduced by the projection layers is included in the overall accounting, and the stability curve during long-context extrapolation.

    4. Engineering Implementation: Practical Points for Staged Deployment

    1. Topology split: Separate the prefill pool from the decode pool. The former favors compute-oriented instances, while the latter favors memory- and bandwidth-oriented instances, with hidden states and the key-value cache as the transfer payload in between.
    2. Transfer cost control: The serialization, compression, and transfer latency of hidden states and the cache must be factored into the end-to-end latency budget. Use chunked pipelining and overlapping transfers when necessary.
    3. Cache lifecycle: Define cache ownership, expiration, and eviction policies clearly to avoid dangling references when passing data across stages.
    4. Observability: Instrument metrics separately for prefill queue time, cache hit rate, projection layer time, and per-token decode latency, and form a closed loop with logging services and monitoring alerts.
    5. Elastic scaling: Scale containers by stage-specific metrics, use message queues for peak shaving, and use object storage for long-lived session state.

    A sample capacity calculation can be written as:

    1. Single-request prefill cost ≈ (front-segment layers / total layers) × original prefill cost + projection layer cost
    2. End-to-end latency ≈ transfer latency + prefill latency + first-token latency + output length × per-step latency

    5. Risks and Boundaries

    The asymmetric architecture is not a free lunch. Potential costs include: model quality may show a discontinuity near the split point; if the projection mapping is too strong, it loses expressiveness, and if too weak, it degrades into near-full computation; inconsistency between the training and inference paths amplifies engineering complexity; and staged deployment imposes higher demands on networking and scheduling. A more prudent path is therefore to first run ablation experiments at small-to-medium scale, confirm the inflection point of the quality-cost curve, and then decide whether to move to production. For most teams, if context lengths are generally short, the benefits are limited; in scenarios such as long-document understanding, repository-level code analysis, and multi-turn long conversations, the cost-effectiveness of this design truly becomes apparent.