Next-Generation LLM Architecture: Hybrid Evolution of Linear and Sparse Attention
This article explains how recent large language model architectures combine linear attention with sparse attention to reduce long-context inference cost. It covers a two-stage sparse attention design with a block-compressed indexer, multi-branch gated residuals, an N-gram embedding module for extra memory capacity, and a hybrid Muon and AdamW optimizer.
1. Why a “Next-Generation Architecture” Is Needed
Over the past two years, large model capabilities have improved largely by scaling parameters and training data. This approach now faces clear limits. Inference cost rises quickly with context length, and the KV cache takes up a large share of memory in long-context workloads. New architectures share three goals:
- Reduce the inference cost per token, so that the cost of long-context inference grows close to linearly.
- Increase memory capacity, so the model can still retrieve key information accurately from very long histories.
- Maintain training stability, so new structures do not significantly increase training difficulty.
A recently released preview model with a hybrid architecture, released by the community, makes a systematic upgrade around these three goals. The sections below break down its main technical points.
2. Evolution of Attention: From “Linear + Full Attention” to “Linear + Sparse Attention”
2.1 The Basic Logic of Hybrid Attention
Pure linear attention has nearly linear compute cost, but it performs poorly on tasks that need precise long-range retrieval. It compresses history into a state of fixed dimension, similar to a finite-state memory, so it cannot preserve every detail. For this reason, the industry commonly adopts a hybrid approach:
- Linear attention layers compress and pass along historical information efficiently. They handle the general gist of the history.
- Full attention layers are interleaved at a set ratio, for example 3:1, meaning one full attention layer appears every four layers. They can look back directly at original tokens and handle precise lookup.
2.2 Why Full Attention Becomes a New Bottleneck
Full attention has O(L²) complexity, and its KV cache grows linearly with sequence length. When context expands from 32K to hundreds of thousands of tokens or more, the compute and memory cost of full attention layers remains substantial, even when they make up only a small fraction of the layers.
2.3 The Sparse Attention Approach
The core idea of sparse attention is that not every query needs to attend to all historical tokens. It only computes over the important ones. A typical implementation has two steps:
# Two-stage sparse attention sketchindex_scores = indexer(query, all_history_keys) # lightweight indexer scores each history tokentop_k_keys = topk(index_scores, k=2048) # select the most important KV blocksoutput = attention(query, top_k_keys) # run exact attention only on the selected blocks
This reduces the core attention complexity from O(L²) to O(L·k). As long as k is fixed, compute cost grows approximately linearly with context length.
2.4 The Indexer Itself
A secondary problem remains. The indexer still scans all historical tokens, so as context keeps growing, the indexer becomes a new bottleneck. The newer design addresses this with block-level compression inside the indexer. Consecutive index keys (for example, 4 of them) are average-pooled into one “micro-block,” and queries score only these micro-blocks. The indexer therefore checks one quarter as many keys, which further lowers the fixed overhead of sparse retrieval.
This two-stage funnel, coarse filtering followed by precise computation, is a representative engineering pattern in long-context optimization.
3. Residual Upgrade: From Single-Path Pre-Norm to Four-Branch Gated Residuals
Traditional Transformers use a single-path Pre-Norm residual structure:
x = x + Sublayer(Norm(x))
Information flows through one main channel, and cross-layer transfer relies on simple layer-by-layer addition. The new architecture changes the residual into a multi-branch gated structure. Each residual point branches into several parallel paths. Learnable gate parameters decide dynamically how much each branch contributes to the fusion.
This design offers three benefits:
- Easing gradient propagation bottlenecks: The extra branches give gradients additional paths, which helps deep networks train stably.
- Strengthening cross-layer information flow: Different branches can carry information at different granularities or from different sources, such as shallow details and deep semantics. The gating mechanism learns when, and in what proportion, to merge them.
- Very small parameter overhead: The gate parameters are far fewer than the backbone parameters, which makes this a low-cost design with a clear return.
4. Expanding Memory Capacity: The N-gram Token Embedding Layer
This is one of the most inventive changes in the new architecture. The designers inserted a single-layer N-gram token embedding module at a specific layer, for example layer 2. It has 51B parameters but adds almost no compute per token to the main backbone.
The principle works as follows:
- N-gram embeddings act like an external local knowledge base with statistical grounding. They inject prior information about adjacent token combinations through table lookup.
- Because the module is a single layer built mainly on lookup and embedding, it does not perform dense matrix multiplication on the backbone. The extra inference compute is negligible.
- The module still expands memory capacity substantially. It gives the model richer storage for frequent token combinations and phrase-level patterns.
This “many parameters, little compute” design challenges the common assumption that parameter count roughly equals inference cost. It also reflects the broader design philosophy of sparsification and lookup-based computation.
5. Training Optimization: A Hybrid Optimizer Strategy
The optimizer moves from classic AdamW to a hybrid strategy of Muon and AdamW. A common industry practice is to assign optimizers by module:
- Muon-style optimizers, which are based on orthogonalizing matrix gradients, are applied to the two-dimensional weight matrices in attention and feed-forward networks. They make fuller use of matrix structure and accelerate convergence.
- AdamW continues to handle embedding layers, gating parameters, the N-gram embedding table, and other one-dimensional or non-matrix parameters, which keeps updates stable.
The core idea of the hybrid strategy is to let suitable optimization methods handle parameters of suitable shapes. It aims to improve training efficiency and final performance without adding substantial tuning cost.
6. Summary and Outlook
Taken together, next-generation architectures show a clear common trend:
| Dimension | Traditional Approach | Next-Generation Approach |
|---|---|---|
| Global attention | Dense O(L²) | Sparse indexing with block-level coarse filtering, O(L·k) |
| Residual structure | Single-path Pre-Norm | Multi-branch gated residuals |
| Memory capacity | Relies on backbone parameters only | External N-gram embeddings with near-zero added compute |
| Optimizer | Single AdamW | Hybrid assignment by parameter shape |
For engineering teams, the implications are clear. As inference cost constraints tighten, the combination of sparse retrieval, linear hybrid attention, and low-cost external memory is becoming a mainstream direction for long-context LLM architecture design. Understanding these mechanisms can help with model selection, deployment optimization, and fine-tuning strategy.
