Million-Token Contexts: Attention Compression as a Paradigm Shift for LLMs

    This article examines why long context is becoming infrastructure for next-generation LLMs rather than a standalone feature. It analyzes the convergence of training recipes, the quadratic cost of attention and KV cache growth, and the architectural shift from making representations “thinner” to making sequences “shorter” through hierarchical compression. It also outlines design constraints for balancing accuracy and efficiency, proposes long-range reliability metrics, and discusses the engineering support required for production deployment.

    Over the past year or so, the capability gap between open-source and closed-source flagship models has been compressed to roughly “three to six months.” The technical report of a new-generation open-source model also acknowledged that its performance is slightly ahead of the strongest current open-source option but still behind the most advanced closed-source models. Looking only at aggregate leaderboards, a route that once stood out now appears to be blending into the crowd. But if we move from total scores to the architecture level, a more valuable signal emerges: this generation of designs has placed most of its engineering effort on restructuring attention efficiency, rather than continuing to pile on parameters and data. This article follows that thread to discuss why long context is becoming the infrastructure for next-generation large models, and what the engineering implications of “attention compression” as a paradigm-level innovation actually are.

    1. Leaderboard Convergence Is Not the End, but the Result of Training Paradigm Convergence

    Over the past year, data mixes, post-training pipelines, reinforcement learning incentive design, and related stages have become significantly more public. Methodological differences among peers have been quickly flattened. As training paradigms converge, the marginal returns from simply relying on “longer training + more data” diminish. Differences in model capability increasingly come from architecture and inference efficiency.

    Therefore, when evaluating a generation of models, aggregate leaderboards have less explanatory power. More discriminative dimensions include: effective context length per unit of compute, success rate on long-horizon tasks, and the slope of the inference cost curve as context grows. These three factors determine whether a model can support agent workflows and online post-training.

    2. Why Long Context Is Infrastructure, Not a Feature

    Two trends have pushed long context from a “selling point” to a “foundation.”

    The first is test-time scaling. Letting a model unfold a longer chain of thought during inference is a general way to improve complex reasoning performance. But attention overhead grows quadratically with sequence length. Once the chain of thought becomes long, cost and latency quickly spiral out of control.

    The second is long-horizon agent tasks. Cross-document analysis, multi-step tool calls, and repository-level code modifications all require the model to maintain a very large working memory within a single session. If context is not long enough, the task cannot close the loop. If efficiency is not high enough, commercial value is out of reach.

    Combining these two trends leads to a direct conclusion: whoever can make long context efficient first can accelerate the model’s own training iteration more quickly, because long context is a shared prerequisite for reasoning capability, task capability, and online post-training capability.

    3. The Nature of the Complexity Problem: Quadratic Terms and KV Cache

    Standard attention requires every query to interact with all keys, so computation grows quadratically with sequence length. More troublesome is that the autoregressive decoding stage needs to cache all historical keys and values (KV cache). Memory usage grows linearly with context, directly limiting batch size and concurrency.

    Industry mitigation approaches fall into roughly two categories. One is “make it thinner”: reduce the dimensionality of each token representation or the number of heads involved in computation, such as low-rank projection, shared key-value, and quantization compression. These methods reduce per-point cost, but once the sequence becomes very long, the total still accumulates linearly, and the quadratic term does not disappear.

    The other is “make it shorter”: directly reduce the number of tokens participating in global interaction and fold long sequences into shorter representations. This is the path taken by this generation of designs—the dimension being cut shifts from “representation width” to “sequence length.”

    4. From Thinner to Shorter: The Basic Structure of Hierarchical Compression

    The core idea of sequence compression is that global interaction does not have to occur at the original token granularity. A common engineering combination is “local fine-grained + global folded + sparse lookback”:

    • A local window preserves original resolution so nearby details are not lost.
    • Remote sequences are aggregated by block into compressed representations, which handle global information summarization.
    • On the query side, scoring selects a small number of the most relevant compressed blocks or original blocks for fine-grained computation.

    Illustrative pseudocode (structure only, not a specific implementation):

    1. def compressed_attention(q, k, v, block=128, topk=16, window=1024):
    2. # 1) Keep nearby tokens at original granularity
    3. k_local, v_local = k[:, -window:], v[:, -window:]
    4. out_local = softmax_attention(q, k_local, v_local)
    5. # 2) Fold remote tokens by block into compressed representations (learnable projection + pooling)
    6. k_c = learnable_pool(k[:, :-window], block) # [B, n/block, d]
    7. v_c = learnable_pool(v[:, :-window], block)
    8. # 3) Sparse selection of the most relevant compressed blocks on the query side
    9. score = q @ k_c.transpose(-1, -2) # [B, n, n/block]
    10. idx = score.topk(topk, dim=-1).indices
    11. out_global = softmax_attention(q, gather(k_c, idx), gather(v_c, idx))
    12. return out_local + gate * out_global

    The benefits of hierarchical compression are composite: the sequence length for global interaction drops by one to two orders of magnitude, the resident size of the KV cache falls accordingly, and concurrency under long context improves. The cost is that compression inevitably loses information, so the design focus should be on making compression “learnable, lookback-capable, and layered,” rather than one-shot crude pooling.

    5. The Balance Point Between Accuracy and Efficiency

    The most common failure mode of compressed attention is “mid-context information collapse”: multi-hop reasoning needs to repeatedly look back at middle evidence, and the middle is often compressed most aggressively. There are three feasible engineering constraints:

    1. Keep a lossless local channel so short-range dependencies are not polluted by compression error.
    2. Generate compressed representations with learnable modules and optimize them during pretraining, rather than attaching them at inference time.
    3. Provide a sparse lookback mechanism that allows queries to fetch key segments at original granularity on demand.

    It is important to emphasize that such structures must be trained together with the model during pretraining. Adding compression during post-training usually yields only long-context capability that “runs but is unreliable.”

    6. Evaluation Needs Different Metrics: From Total Score to Long-Range Reliability

    If evaluation still relies on aggregate leaderboards, the value of compressed long context is almost invisible. At least four types of evaluation should be added:

    • Long-range retrieval: locate scattered evidence in extremely long contexts (multi-needle rather than single-needle).
    • Multi-hop aggregation: answers require chaining multiple distant fragments.
    • Context stability: performance variance when distractor information is inserted at different positions for the same task.
    • Cost curve: the slope of latency and memory increase when effective context doubles.

    7. Engineering Support for Deployment

    For long-context capability to become a usable service, peripheral infrastructure also needs to cooperate: paging and reuse of KV cache, prefix sharing, quantization and offloading strategies, and layered monitoring and alerting for time to first token and throughput. In a cloud environment such as Baidu AI Cloud, these capabilities are typically delivered by container platforms for inference services, object storage for long documents and corpora, and logging and monitoring services for long-chain tracing and capacity alerts. These are general, composable infrastructure categories, not proprietary features of any single model.

    Conclusion

    The convergence of leaderboard scores shows that the dividend from “scaling up” is ending, while attention compression shows that real competition has shifted to effective context per unit of compute. The practical implications for developers are clear: when selecting models, do not look only at total scores—look at long-horizon task success rates and the slope of the cost curve. When building your own solution, prioritize the hierarchical structure of “local fine-grained + global folded + sparse lookback,” and put the compression module into pretraining rather than post-processing. Long context is not a feature switch; it is the foundation of next-generation model capabilities.