Asymmetric Activation Architecture: Speeding Up Long-Context Reasoning

    Agent workloads are increasingly read-heavy and write-light, so symmetric MoE activation wastes compute on prefill. This article explains asymmetric activation, causal encoder–decoder splits, shared KV, two-level sparse indexing, evaluation metrics beyond tokens per second, and practical rollout steps.

    1. The cost structure of agent workloads is “read a lot, write less”

    Inference traffic has shifted. Early chat apps mixed short inputs and short outputs, so prefill and decode were similar in cost. Agent workloads—coding tools, document understanding, multi-turn tool use—often ingest hundreds of thousands of tokens while generating only thousands to tens of thousands.

    Prefill processes every input token; decode generates one token at a time. In a symmetric MoE, both stages share the same activation path and attention construction. Sparsity tuned for decode does not fully pay off in prefill, and long-context compression is paid again in decode.

    The architectural question is whether prefill and decode can use different compute paths and different activation budgets.

    2. Asymmetric activation: two budgets for two stages

    Asymmetric activation assigns different activated-parameter budgets to the two stages. Illustrative (not product) numbers:

    Dimension Symmetric activation (classic MoE) Asymmetric activation (encoder–decoder style)
    Input-side activation Same as output side Much smaller than output side
    Output-side activation Same as input side Larger than input side
    Fit Balanced in/out Long input, short output

    Prefill is highly parallel; even a smaller activation budget can saturate hardware. Decode is memory-bound: one token per step, dominated by weight and KV movement. Raising decode activation for capacity often has a better cost–benefit ratio.

    A simplified FLOPs sketch (attention and kernels omitted):

    1. def estimate_flops(n_in, n_out, act_in, act_out, d_model):
    2. # Illustrative estimate; ignores attention and kernel overhead
    3. prefill = 2 * n_in * act_in * d_model
    4. decode = 2 * n_out * act_out * d_model
    5. return prefill, decode
    6. # Typical long-context agent: read 200K, write 20K
    7. p, d = estimate_flops(200_000, 20_000, 8e9, 16e9, 4096)
    8. print(f"prefill share {p/(p+d):.1%}") # input side dominates total compute

    The larger the input share, the more you gain by shrinking prefill activation. Doubling decode activation is often a small slice of the total budget.

    3. Causal encoder–decoder split: compact context representations

    Asymmetry usually needs a structural split, often called a causal encoder–decoder:

    • Lower layers as encoder: run in prefill and compress long context into a compact representation.
    • Upper layers as decoder: dominate decode.
    • Global KV from the encoder’s last-layer projection: decoder layers do not each build a full global KV from their own hidden states; they share that projection.

    Sharing is the compactness win. Classic stacks keep a full global KV per layer; memory and bandwidth grow with depth. One shared projection stores global KV once.

    1. # Sketch: decoder layers share the encoder’s last-layer global KV
    2. enc_hidden = encoder_last(concat(lower_layers(x))) # [B, S, d]
    3. gk, gv = proj_k(enc_hidden), proj_v(enc_hidden) # a single global KV
    4. for layer in decoder_layers:
    5. lk, lv = layer.build_local_kv(x) # local window only
    6. k = torch.cat([lk, gk], dim=-2)
    7. v = torch.cat([lv, gv], dim=-2)
    8. x = layer.attn(x, k, v)

    The split is lossy: compressing context is an information bottleneck, especially for precise localization and verbatim citation (exact retrieval, line-by-line document compare). Local-window attention and explicit retrieval channels are typical compensations.

    4. Shared KV and two-level sparse indexing

    Attention is often reorganized along two axes: KV sharing (reuse one key–value representation across layers or modalities) and two-level sparse indexing (coarse block candidates, then token-level selection inside blocks).

    Two-level indexing pushes attention from roughly quadratic in sequence length toward linear. Level one can rank blocks from summaries or compressed reps; level two scores tokens inside candidates. High prefix-cache hit rates further amortize repeated long-context work.

    5. Native multimodality and a unified representation space

    Native multimodality is not “bolt on an encoder at inference.” Text, image, audio, and similar modalities share representation space and attention during pretraining, avoiding extra projection and alignment at runtime. For agents, screenshots, UIs, charts, and code can be reasoned over in one context instead of a multi-stage pipeline.

    6. Co-design of model and agent framework

    Gains often come from co-design: prompt layout, tool protocols, and context-trimming policies trained for a specific agent stack. End-to-end latency and token use can improve more than isolated benchmark scores. Evaluate models on real frameworks and real task mixes.

    7. Evaluation: do not stop at tok/s

    Useful dimensions include:

    • TTFT: prefill-dominated for long context; drives perceived lag.
    • TPOT: true decode speed.
    • End-to-end time: tools, retries, framework overhead.
    • Total tokens vs. output tokens: faster vs. cheaper.
    • Cache hit rate: prefix reuse dominates cost and latency.
    • Task success rate: speed without quality is not a win.

    Reusable log template:

    1. {
    2. "workload": "long_context_agent",
    3. "input_tokens": 0,
    4. "output_tokens": 0,
    5. "ttft_ms": 0,
    6. "tpot_ms": 0,
    7. "e2e_seconds": 0,
    8. "cache_hit_rate": 0.0,
    9. "task_success_rate": 0.0
    10. }

    8. Engineering rollout

    1. Profile the workload: input/output token distributions and cache reuse; confirm long-in / short-out.
    2. Baseline: same tasks and metrics for TTFT, TPOT, E2E, success.
    3. Small-traffic canary: host inference on a container platform, archive eval sets in object storage, watch latency percentiles and failures with logs and alerts; use a queue to shed peaks if needed.
    4. Cost attribution: compute, storage, and cache hits per task, not only per-token price.
    5. Fallback: local windows or explicit retrieval for precise-search tasks that asymmetric activation may hurt.

    On the cloud, general capabilities (containers, object storage, logging, monitoring) can host this eval and canary path. Baidu AI Cloud is one example of such building blocks; choose against your own workload profile.

    9. Conclusion

    Asymmetric activation, encoder–decoder splits, shared KV, and two-level sparse indexing all align architecture cost with a read-heavy agent mix: cheap prefill, solid decode—often better than stacking parameters. Information bottlenecks and task-fit limits remain. Stage evaluation and canaries; do not trust a single speed number.