Long-Context LLM Architecture Evolution: Sparse Attention and Cross-Layer Index Reuse

    As large language models expand from handling thousands of tokens to context windows of up to one million tokens, inference cost and memory usage have become critical challenges. This article examines how Multi-Head Latent Attention (MLA), Dynamic Sparse Attention (DSA), and cross-layer index reuse work together to reduce KV-cache pressure and redundant computation. It also discusses the engineering value of this design for million-token inference and cloud deployment.

    As large language models continue to improve, the demand for long-context understanding has grown from a few thousand tokens to context windows reaching one million tokens. However, the exponential increase in context length creates significant inference costs and memory pressure. A recently shared architecture diagram for a new-generation large language model reveals an important evolution in its underlying design. Building on the core components of its predecessor, the architecture introduces a cross-layer index reuse mechanism that offers a practical approach to reducing the cost of long-context inference.

    This article breaks down the key technologies behind the architecture and explains their potential engineering value.

    1. The Evolution of Attention: Combining MLA and DSA

    To understand the architecture’s innovations, it is useful to first review two of its foundational technologies: Multi-Head Latent Attention (MLA) and Dynamic Sparse Attention (DSA). These mechanisms optimize the traditional Transformer architecture from two complementary perspectives: memory compression and computational complexity.

    Multi-Head Latent Attention (MLA)

    In standard multi-head attention, the key-value (KV) cache grows rapidly as the sequence length increases and can become the primary memory bottleneck. MLA addresses this issue by using low-rank projections to map high-dimensional key-value pairs into a lower-dimensional latent space for storage.

    During inference, the model reconstructs the full key and value representations from the latent vectors only when they are required for attention computation. This “decompress on demand” strategy substantially reduces the size of the KV cache without eliminating the model’s ability to represent complex information. As a result, it provides a foundation for loading extremely long contexts within limited GPU memory.

    Dynamic Sparse Attention (DSA)

    The computational complexity of standard self-attention is O(N²). When the sequence length reaches the million-token scale, performing dense attention across all tokens becomes impractical.

    Dynamic Sparse Attention is designed to address this limitation. Its central idea is that, for long documents, each token does not need to interact densely with every other token. Instead, a dynamic indexer evaluates the current token and selects the Top-K most relevant tokens. Attention computation is then performed only among these selected tokens.

    This dynamic routing approach reduces the computation from a global operation to a localized one, significantly lowering the cost of processing long sequences.

    2. Breaking the Bottleneck: Cross-Layer Index Reuse

    Although DSA reduces the computational complexity of each individual layer, a deep network may contain dozens or even hundreds of layers. If every layer independently runs a complete Top-K indexer to identify relevant tokens, the accumulated indexing cost can still be substantial.

    To address this problem, the new-generation architecture introduces a core optimization: cross-layer index reuse.

    From Per-Layer Computation to Cross-Layer Sharing

    The mechanism is based on the observation that neighboring layers often show continuity and stability when extracting semantic features. Therefore, it may not be necessary to recalculate the sparse-attention Top-K indices at every layer.

    Rather than running the complete indexing process independently in each layer, the architecture uses a block-based strategy. For example, the full indexer may run once every four layers to identify the Top-K tokens most relevant to the current token. The following three layers then reuse the same token indices for sparse attention instead of performing another selection step.

    This approach preserves the sparse-attention pattern while reducing the frequency of indexer execution.

    Why Cross-Layer Reuse Is Reasonable

    Different layers in a deep neural network generally perform different levels of abstraction. Earlier layers tend to capture local lexical and syntactic features, while deeper layers progressively model global semantic and logical relationships.

    Within a limited depth range, such as four consecutive layers, the model’s judgment about which tokens are important and relevant is often relatively stable. Recalculating the indices at every layer can therefore introduce redundant computation. It may also cause attention routing to fluctuate because of minor changes or noise in individual layer representations.

    Cross-layer reuse reduces the indexer’s execution frequency by approximately three quarters when one index calculation is shared across four layers. From a mathematical perspective, this is similar to applying a local smoothness constraint to the attention pattern across network depth. Rather than weakening long-context modeling, the design can help make feature extraction more stable and robust.

    3. Performance Benefits and Cloud Engineering Value

    Cross-layer index reuse can provide immediate engineering benefits for long-context inference.

    Lower Cost for Million-Token Inference

    In a one-million-token inference scenario, attention indexing can account for a significant portion of computation time and resource consumption. Reducing the indexing frequency to 25% of the original rate can substantially decrease the number of floating-point operations required during inference.

    For enterprises processing long-document summaries, large code repositories, and other high-concurrency workloads, this can improve system efficiency under the same hardware conditions. The system may support more concurrent requests while also reducing the latency of individual inference tasks. As a result, million-token inference can move from being merely technically feasible toward becoming more practical for production use.

    Coordinating the Model Architecture with Cloud Infrastructure

    A lightweight and efficient architecture also creates new opportunities for optimization at the cloud infrastructure layer. When deployed with high-performance computing instances and container platforms, the benefits of cross-layer reuse can be further amplified.

    For example, GPU container clusters provided by Baidu AI Cloud can support elastic scheduling of computing resources. For models that use cross-layer reuse to reduce instantaneous computational peaks, more precise resource allocation may improve concurrent throughput per node.

    Monitoring, alerting, and logging services can also help developers track how index reuse affects memory usage and inference latency during deployment. Teams can then adjust batch sizes based on observed runtime behavior. This coordination between algorithm-level innovation and general-purpose cloud AI infrastructure can support more efficient deployment of long-context models in enterprise production environments.

    4. Conclusion

    The evolution of long-context model architectures continues to focus on efficiency. MLA reduces memory pressure by compressing the KV cache, DSA lowers attention complexity through dynamic token selection, and cross-layer index reuse further eliminates redundant indexing computation.

    By sharing token indices across neighboring layers, a new-generation large model architecture offers a practical design pattern for reducing the high cost of one-million-token inference. The combination of algorithmic insight and careful engineering optimization points toward a promising direction for deploying large language models with increasingly long context windows at scale.