Modern LLM Architecture: Evolution, Sparse Activation, and Parameter Scale

    Modern large language models are no longer simple stacks of identical Transformer layers. This article explains how dense and mixture-of-experts architectures, attention and KV-cache design, expert routing, context extension, numerical formats, and hardware constraints shape real deployment costs. It also provides a practical evaluation framework based on capacity, compute, memory, structure, context, deployment, and quality metrics.

    1. Why LLM Architecture Needs a Fresh Look

    Large language models are commonly built on the Transformer, but after years of evolution, today’s mainstream models are no longer simple stacks of identical attention layers and feed-forward networks. Model design increasingly centers on three core goals:

    1. Improve model capability under a limited compute budget.
    2. Support longer context at lower inference cost.
    3. Reduce memory, bandwidth, and communication pressure during training and deployment.

    As a result, analyzing a model cannot rely only on total parameter count. More meaningful metrics include total parameters, the number of parameters actually activated per inference, layer count, hidden dimension, attention head configuration, number of experts, experts selected per token, context length, and data types used.

    Modern models range from billions of parameters to hundreds of billions or even trillions. At the same time, many models use sparse activation so that a single token accesses only a subset of parameters. This preserves large model capacity while controlling the number of multiply-accumulate operations required for each computation.

    2. Model Scale Is More Than “Total Parameters”

    2.1 Dense Models

    In a dense model, every input token passes through the main parameters in all layers. Its parameter count can be roughly expressed as:

    [
    P \approx P{\text{embedding}}+L(P{\text{attention}}+P_{\text{FFN}})
    ]

    Here, (L) is the number of network layers. The attention part consists of projection matrices, while the feed-forward network usually accounts for a larger share of parameters.

    Dense models have a simple structure and a stable compute path, making them suitable for high-throughput training and inference. However, as model scale grows, compute and memory usage grow together, leading to higher deployment costs.

    2.2 Mixture-of-Experts Models

    Mixture-of-experts (MoE) models split the traditional feed-forward network into multiple expert modules and use a router to select a small number of experts for each token. Two concepts must be distinguished:

    • Total parameter count: the sum of all expert parameters and shared parameters.
    • Activated parameter count: the parameters actually involved in computation for a single token.

    For example, a model may have hundreds of experts, but each token selects only two or four of them. In this way, total model capacity can be very large while per-inference compute remains close to that of a medium-sized dense model.

    However, sparsity is not free. Expert routing introduces additional overhead from token reordering, cross-device communication, load balancing, and cache management. If experts are distributed across different accelerators, communication time may become a major bottleneck.

    3. Typical Network Components and Key Changes

    3.1 Token Embeddings and Output Layer

    The model first splits input text into tokens and maps them to vectors through an embedding matrix. In the output stage, a linear projection maps hidden states to vocabulary space.

    To reduce parameter count, some models share weights between the input embedding matrix and the output projection matrix. In large models, however, the input vocabulary, output vocabulary, and hidden dimension can all be large, so the embedding layer can still occupy considerable storage.

    3.2 Attention Layers

    The attention mechanism models dependencies between different positions. Its basic form is:

    [
    \text{Attention}(Q,K,V)=\text{softmax}\left(\frac{QK^T}{\sqrt{d}}\right)V
    ]

    In practical models, attention architecture has seen several optimization directions:

    • Reduce the number of key and value heads to lower KV cache size.
    • Share part of the keys and values across multiple query heads.
    • Combine local windows with global attention.
    • Extend the manageable context length through position encoding.
    • Block attention computation to reduce memory usage of intermediate matrices.

    For long-context inference, the KV cache often becomes a more likely memory bottleneck than model weights. Each time a new token is generated, the keys and values corresponding to previous tokens must be stored. If context length, layer count, batch size, and cache dimension all increase at the same time, memory demand grows rapidly.

    3.3 Feed-Forward Networks

    A feed-forward network usually contains two or three linear transformations and uses gated activation functions to enhance expressiveness. Its parameter count is often higher than that of the attention part, which is why it is the main location for introducing expert structures.

    In expert models, each expert generally has an independent feed-forward network, while attention layers and some normalization modules remain shared. This design increases model capacity without replicating the entire network multiple times.

    3.4 Normalization and Residual Connections

    Normalization layers stabilize training, while residual connections help information propagate across layers. Current mainstream practice often places normalization before sublayers or uses improved normalization methods to mitigate gradient instability in deep network training.

    Although these modules have few parameters, they directly affect training convergence, numerical stability, and low-precision inference. They cannot be ignored simply because their parameter share is small.

    4. Expert Routing Determines the Real Efficiency of Sparse Models

    The core of an expert model is not only how many experts it has, but also how the router selects experts.

    4.1 Routing Process

    For each token, the router computes preference scores for each expert and then selects the highest-scoring experts. The tokens are then redistributed to the corresponding devices, experts perform computation, and the original order is restored afterward.

    An ideal routing mechanism should satisfy the following:

    • Each token can select suitable experts.
    • The number of tokens received by each expert is roughly balanced.
    • Cross-device transfer is minimized.
    • Important tokens are not dropped due to capacity limits.
    • Routing results remain stable during training.

    4.2 Load Balancing

    If a large number of tokens concentrate on a few experts, popular experts become overloaded while cold experts are not sufficiently trained. Common approaches include adding balancing losses, setting expert capacity limits, introducing routing noise, or adopting finer-grained routing strategies.

    However, a higher degree of balance is not always better. Overly strong balancing constraints may disrupt the natural matching between tokens and experts, reducing model capability. Engineering practice therefore needs to find a trade-off among routing quality, communication overhead, and load balancing.

    4.3 Fine-Grained Experts

    Some designs split a single large expert into more small experts and select fewer modules for each token. This increases combination flexibility, but also brings more routing metadata, scheduling operations, and communication requests.

    From a hardware perspective, the more experts there are, the more easily matrix multiplications become small-batch and fragmented tasks. If each expert receives too few tokens, a reduction in theoretical compute may not translate into actual latency reduction.

    5. New Problems Introduced by Context Length Extension

    As context extends from tens of thousands of tokens to hundreds of thousands or even longer, the challenges models face go beyond position encoding.

    First, the complexity of attention computation is closely related to sequence length. Even with efficient attention implementations, long sequences still increase memory access and scheduling pressure.

    Second, the KV cache grows with context. Its size can be approximated as:

    [
    M{\text{KV}}\propto B\times L\times S\times H{\text{KV}}\times D\times 2
    ]

    Here, (B) is batch size, (L) is layer count, (S) is context length, (H_{\text{KV}}) is the number of key-value heads, (D) is the dimension of each head, and the final 2 represents the key and value parts.

    Therefore, reducing KV head count, using lower-precision storage, adopting paged caching, and reusing similar prefixes are common optimization directions. For online serving, cache management capability often directly affects concurrency and time to first token.

    6. Numerical Formats and Training Stability

    Modern large models typically do not use high-precision formats throughout. Training must balance numerical stability and computational efficiency, while inference focuses more on memory usage and throughput.

    Common strategies include:

    • Use higher precision for some sensitive computations.
    • Use low precision for matrix multiplication.
    • Use different formats for activations, weights, and caches.
    • Scale or clip outliers.
    • Retain higher precision for critical reduction operations.

    Low precision is not simply a matter of reducing data bit width. Factors that truly affect results also include quantization granularity, scaling factors, outlier distribution, and the sensitivity of different layers. For long-context and expert models, the KV cache and routing scores also require separate evaluation of numerical errors.

    7. Hardware Constraints in Training and Inference

    7.1 Compute Bottlenecks

    Dense models usually make it easier to utilize matrix multiplication units efficiently. Expert models may be affected by small matrices, dynamic routing, and irregular batches. Hardware needs to support both high-throughput matrix operations and flexible data movement.

    7.2 Memory Bottlenecks

    Memory is used not only to store weights, but also to hold activations, gradients, optimizer states, and the KV cache. During training, optimizer states may be much larger than the model weights themselves; during inference, memory usage is mainly affected by weights, cache, and concurrent requests.

    7.3 Communication Bottlenecks

    When a model is split across devices, inter-layer transfer, expert dispatch, and result aggregation all consume bandwidth. For sparse models, communication patterns are dynamic, and traditional methods that optimize only contiguous matrix computation may not be sufficient.

    System design therefore usually needs to consider:

    • Device memory capacity.
    • Interconnect bandwidth between devices.
    • Collective communication efficiency.
    • Request scheduling strategy.
    • Tiered storage of weights and caches.
    • Overlapped execution of computation and communication.

    8. How to Evaluate a Large Language Model

    It is recommended to build a unified evaluation table from the following dimensions:

    1. Capacity metrics: total parameters, activated parameters, layer count, and hidden dimension.
    2. Compute metrics: compute per token, tokens generated per second, and time to first token.
    3. Memory metrics: weight size, activation footprint, and KV cache size.
    4. Structure metrics: attention type, number of experts, routing count, and shared-layer ratio.
    5. Context metrics: maximum context length, long-text stability, and cache management method.
    6. Deployment metrics: supported precision formats, parallelism methods, device count, and scaling efficiency.
    7. Quality metrics: language understanding, code generation, reasoning, tool use, and long-document processing capability.

    Among these, parameter count reflects only one aspect of model capacity and cannot be directly equated with effectiveness. With the same total parameter count, different data quality, training strategies, routing mechanisms, and inference optimization approaches may produce significant differences.

    Several relatively clear directions can be observed from current architectural changes.

    First, models will continue to expand total capacity while controlling per-inference compute through sparse activation. Second, attention will be further optimized for long context, and KV cache compression and tiered management will become baseline capabilities. Third, model architecture will increasingly account for hardware characteristics, and co-design between algorithms and chips will become tighter. Fourth, low-precision training and inference will evolve from simply compressing weights to holistic optimization of activations, caches, routing, and communication. Fifth, model evaluation will shift from “parameter scale competition” to “effective capability per unit cost.”

    Overall, the core tension in modern large language models has shifted from simply pursuing larger networks to balancing capacity, compute, memory access, communication, and service quality. Understanding these structural trade-offs is necessary to accurately judge the real deployment cost of a model and to provide a reliable basis for planning training clusters, inference clusters, and specialized accelerators.