Asymmetric Activation and CED: Optimizing Long-Context Agent Inference

    Long-context AI Agent workloads are "read-heavy, write-short": models process tens of thousands of input tokens but generate only a few hundred output tokens. This article explains why prefill and decode phases have different bottlenecks, how asymmetric activation reduces wasted compute, how Causal Encoder-Decoder (CED) architectures compress context, and how to properly benchmark inference performance for your own workloads.

    Why Agent Workloads Are “Read-Heavy, Write-Short”

    In traditional conversations, user input and model output are roughly the same length. Agents are different. In a single task, a model may read tens of thousands of tokens of code, documents, web results, and conversation history, only to output a few hundred tokens of tool calls or decisions.

    This workload shape makes the cost difference between the two inference phases stark. The prefill phase processes the entire input at once, with compute growing linearly with input length. The decode phase generates output token by token, reading model weights and the KV cache at every step, so latency is dominated by memory bandwidth and the number of activated parameters. The two phases have different bottlenecks—optimizing only one typically improves half the picture.

    To determine whether your workload fits this pattern, track three numbers: average input tokens, average output tokens, and average turns per task. The higher the input-to-output ratio and the more turns, the larger the share of prefill and KV cache in total cost.

    The Waste of Symmetric Activation

    In conventional Mixture-of-Experts (MoE) models, each token routes to a set of experts, and input and output tokens typically follow the same routing and activation paths. This symmetric design is simple to implement and relatively stable to train.

    The problem emerges with long contexts. Prefill must process a large number of input tokens, each passing through the full activation path, so compute grows linearly with context length. But only a small fraction of the context actually needs fine-grained, token-by-token processing—the rest mainly needs to be understood, compressed, and stored as intermediate representations. Applying the same compute intensity to all tokens wastes part of the compute budget.

    The Idea Behind Asymmetric Activation

    The core idea of asymmetric activation is to design separate activation paths for the input side and the output side. When reading context, a lighter activation path quickly compresses information into intermediate representations. When generating output, a heavier path is used to preserve generation quality.

    The benefit depends on the specific configuration. The fewer activation parameters on the input side, the lower the prefill cost. But if output-side activation is also compressed, generation quality may degrade. Therefore, evaluate the two phases with separate metrics—never judge by a single aggregate number.

    Note that different models report parameters inconsistently. Some sources cite “total parameters,” others “activated parameters per token,” and some only state the activation for one phase. When reading such material, verify three things: the total parameter count, how many parameters each token activates in each phase, and which model version the numbers refer to and how they were counted. Numbers with unclear methodology should not be used directly for model selection comparisons.

    Causal Encoder-Decoder (CED): How Context Gets Compressed

    Asymmetric activation requires supporting architecture design. One approach splits the Transformer into two segments. The lower half acts as an encoder, running mainly during prefill to compress the long context into a compact representation. The upper half acts as a decoder, generating output token by token during decode.

    This split is easy to understand, but it is only an approximation of the data flow. The actual model structure must be judged together with its training approach and attention implementation.

    In this type of design, a commonly cited technique is this: instead of each decoder layer constructing its own global KV cache from its own hidden states, all layers derive the global KV cache from a projection of the encoder’s final-layer output. This offers three potential benefits:

    1. The context only needs to be fully encoded once and is reused throughout decoding, which can reduce KV cache footprint.
    2. With a unified KV source, the context representation can be more compact, fitting more effective context in the same memory.
    3. During decode, each step only involves the decoder side, making the per-token compute cost easier to control.

    But these benefits come with prerequisites. The unified projection usually requires dedicated training, or the model must learn this structure during training. Converting a standard Transformer to this architecture directly will likely degrade quality. The compressed representation also loses some detail—recall accuracy for long-range precise retrieval, numbers, and code specifics must be tested separately. When you encounter claims like “significant KV memory reduction,” ask three questions: What is the projection dimension? Was the model trained specifically for this? On which tasks was accuracy validated?

    Attention Organization: What Gets Seen and What Gets Kept

    Long-context inference typically involves two problems. The first is deciding which tokens the model should attend to, handled by sparse attention or retrieval mechanisms. The second is how to store that information cheaply once attended, which concerns KV cache organization and compression.

    The two have different roles, and combining them yields the clearest gains. Sparse retrieval alone leaves the cache large. Cache compression alone may miss critical content. A common approach in real systems is to first filter candidate content with an index, then apply compressed representations to what is retained.

    The Impact of Multimodal Input

    Natively multimodal models process text and visual tokens through a unified pipeline. Compared with bolting on a separate vision encoder and concatenating outputs, a unified path reduces cross-module data conversion and makes it easier to share caching mechanisms with text. However, image token counts are typically large and significantly increase the prefill burden. So for multimodal Agents, evaluate image token share separately in your workload analysis.

    How to Validate Performance

    Performance figures circulating online often lack test conditions. The same claim of “faster generation” can lead to completely different conclusions under short-context, low-concurrency versus long-context, high-concurrency settings. When selecting a model, benchmark with a fixed workload and record the full test conditions. Here is a template you can use directly:

    1. Test objective:
    2. Model name and version:
    3. Inference framework and version:
    4. Hardware model and count:
    5. Context length (input token distribution):
    6. Output length (output token distribution):
    7. Concurrency and request rate:
    8. Measurement tools:
    9. Metrics:
    10. - Time to First Token (TTFT): time from request submission to the first token, record P50 and P95.
    11. - Time Per Output Token (TPOT): average time per token in steady-state generation, reflecting decode efficiency.
    12. - KV cache memory usage: peak memory at the target context length, plus the cache capacity limit.
    13. - Cache hit rate: proportion of requests hitting the cache in multi-turn sessions, grouped by session turn.
    14. - Task success rate: measured on a fixed evaluation set. Speed gains must not come at the cost of quality.
    15. - Cost per task: token consumption per completed task.