Modern LLM Architecture Explained: Structural Evolution and Parameter Scaling
This article breaks down how modern large language models are engineered, moving beyond historical surveys to examine the network structures used in today's mainstream models. It shows how seemingly different design choices all converge on three hardware constraints — compute, memory bandwidth, and communication — and walks through total versus activated parameters, Mixture of Experts (MoE) routing, attention mechanisms from MHA to MQA/GQA and low-rank KV compression, fine-grained expert routing with shared and routed experts, context extension from 128K to 1M tokens via RoPE, numerical precision from FP32 down to BF16/FP16 and FP8, and quantization. It closes with practical guidance for teams planning to deploy or scale LLM infrastructure, helping readers understand the "contradictory yet coherent" logic behind model selection, deployment planning, and accelerator decisions.
1. Overview: Three Hardware Constraints Behind Structural Change
The Transformer architecture is more than a decade old, and improvements to it have appeared continuously, with many surveys already available. Rather than retelling that history, this article focuses on the engineering of today’s mainstream large language models and dissects their network structures one by one.
Looking at structure on its own matters because the changes from different vendors look wildly different on the surface, yet all ultimately converge on the same set of hardware constraints: compute, memory bandwidth, and communication overhead. Understanding the causal chain among these trade-offs is what lets us judge the direction of the next generation of models and leave headroom for accelerator selection and cluster planning.
A few conclusions run through the whole article and are expanded later:
- Parameter scale: total parameters have grown from hundreds of billions to trillions, yet the parameters actually activated and computed in each forward pass have long stayed around a few tens of billions;
- Context length: context has expanded from 128K to 1M tokens, yet the accompanying KV Cache has been repeatedly compressed;
- Expert scale: the number of experts has grown from 256 to nearly 900, while routing granularity has become finer and finer.
These three trends look contradictory, but they share the same goal: to expand a model’s knowledge capacity as much as possible under a limited compute and memory budget, while keeping the actual cost of inference under control.
2. Parameter Scale: Total vs. Activated Parameters
To understand modern models, start with two key metrics.
- Total parameters: all the parameters the model’s weights occupy. This determines the upper bound on the model’s knowledge capacity and the lower bound on storage and memory usage.
- Activated parameters: the parameters that are actually invoked for computation in a single forward pass.
In early dense architectures, the two were equal — every parameter took part in computation for every token. As models scaled into the trillions, keeping all parameters active at once became an unacceptable compute and memory-bandwidth burden. Mainstream designs therefore shifted to sparse activation, with the Mixture of Experts (MoE) as the typical example.
The core idea of MoE is “division of labor”: split the feed-forward layer into several parallel expert sub-networks, where each token is processed by only the few experts selected by a router. Total parameters can then be made very large (to hold massive knowledge), while activated parameters per token are kept small — so compute scales roughly with activated parameters.
A useful mental model: total parameters determine “how much the model knows,” while activated parameters determine “how much compute each step of reasoning costs.” Decoupling the two is precisely why today’s large models can expand capacity under a limited inference budget.
3. Attention: From Multi-Head to Shared Key-Value
The attention layer is the other core of the Transformer. Its main line of development is “how to reduce the memory-access cost of the KV Cache without sacrificing expressive power.”
Standard Multi-Head Attention (MHA) maintains separate Key and Value caches for every attention head. During inference, generating each token requires reading all historical KV, and this memory access often becomes the bottleneck in long-context scenarios. Two approaches have emerged to ease this:
- Reduce the number of KV heads: Multi-Query Attention (MQA) lets all heads share a single K/V group; Grouped-Query Attention (GQA) is a compromise that groups several query heads to share K/V. Fewer K/V heads mean a smaller KV Cache and lower memory-access pressure.
- Compress the KV representation: low-rank projection compresses Key/Value into a low-dimensional latent space before caching, approximating the original KV with a few dimensions and further cutting memory traffic. This kind of approach significantly reduces memory usage while preserving long-context capability.
So “longer context” and “a compressed KV Cache” are not in conflict: the former requires remembering more history, while the latter requires doing so at lower cost. The two are balanced through smarter encoding.
4. Fine-Grained Routing in Mixture of Experts
The second direction of MoE evolution is routing granularity. Early MoE used fewer, “wider” experts; current mainstream designs favor “more experts, each narrower, with only a very small number selected per token.” This fine-grained design brings several benefits:
- More flexible combinations: more, smaller experts let tokens be assigned more precisely to the right sub-networks, improving specialization.
- Higher sparsity: total expert count rises while the activated top-k stays small (e.g., only a few experts are active), pushing the share of activated parameters down further.
- Better load balance: combined with a load-balancing loss and routing constraints, this helps mitigate the problem of “a few popular experts being called repeatedly while most sit idle.”
Engineering practice also often divides experts into shared experts and routed experts: shared experts carry general-purpose capability and are open to all tokens, while routed experts carry specialized capability and are activated on demand. This combination strikes a good balance between capacity and efficiency.
5. Context Length Extension and Positional Encoding
Extending context from 128K to 1M tokens is not as simple as “opening the window wider” — it involves the extrapolation ability of positional encoding and the memory-access cost of attention.
The mainstream approach builds on Rotary Position Embedding (RoPE) and its variants: by scaling or interpolating the position-dependent rotation angles, positional relationships learned on the short sequences seen during training can be extrapolated to longer inference sequences. The extrapolation strategy for positional encoding directly determines the stability of long-context tasks such as long-document question answering and codebase understanding.
At the same time, long context amplifies the complexity of attention to something related to the square of the sequence length. So the KV compression, sparse attention, and chunked attention techniques mentioned earlier often need to be used together with long-context schemes.
6. Numerical Precision: Balancing Compute Density and Memory Usage
Numerical format is the bridge between algorithms and hardware. Different precisions each make trade-offs in compute density, memory usage, and numerical stability:
- FP32: numerically stable but expensive; generally no longer used for the main training of large models.
- BF16 / FP16: the primary precision for current training and inference, balancing dynamic range and compute efficiency.
- FP8 and other low precisions: introduced in parts of training and inference to further raise per-unit compute throughput, but with higher demands on numerical stability, usually requiring a suitable scaling strategy.
The value of low precision is not just “compute faster” but also “fit more and move more”: a smaller bit width means lower memory usage and lower memory-bandwidth demand, which is especially critical for memory-bound inference. Quantization (such as weight quantization, activation quantization, and KV Cache quantization) is a related inference-acceleration technique; the core idea is to push resource costs as low as possible while keeping accuracy loss controllable.
7. Hardware Constraints: The Triple Test of Compute, Memory, and Communication
Returning to the opening conclusion — every structural change ultimately points to hardware. The correspondence between model architecture and hardware can be understood along three dimensions:
- Compute: total floating-point operations are mainly determined by activated parameters and token count. The point of sparse activation is to make compute grow with activated parameters rather than total parameters.
- Memory bandwidth: decoding during inference is autoregressive, computing only one token per step. Here the bottleneck is often not compute but memory — the speed of moving weights and the KV Cache from memory to the compute units. This explains why KV compression and low-precision storage matter so much.
- Communication: MoE experts are usually distributed across different devices. Tokens must be routed to the device hosting the target expert and their results returned, which generates a large amount of All-to-All communication. The finer the routing granularity, the more complex the communication scheduling and the higher the demands on high-speed interconnect.
A model’s structure therefore cannot be judged in isolation from the hardware it runs on. The same MoE may need completely different optimal routing and partitioning strategies on a cluster with ample interconnect bandwidth versus a bandwidth-constrained environment.
8. Practical Recommendations
For teams deploying or planning large-model infrastructure in their own environments, the analysis above can be distilled into a few practical guidelines:
- Identify the bottleneck type first: determine whether the workload is compute-bound or memory-bound (decoding tasks are usually the latter) before deciding where to focus optimization.
- Balance capacity and cost: use MoE to trade off between total and activated parameters, tuning based on how sensitive the business is to “breadth of knowledge” versus “cost per step.”
- Prioritize KV management: for long-context scenarios, specifically evaluate the memory usage of the KV Cache, and enable compression or paged management when necessary.
- Choose precision as needed: on the training side, focus on convergence and stability; on the inference side, focus on throughput and latency. Quantization strategies should be based on measurements rather than copied from experience.
- Evaluate end to end: measure architecture decisions against the overall “compute — memory — communication” budget to avoid local optima that create global bottlenecks.
When running these models in the cloud, teams can rely on general-purpose capabilities — container platforms for elastic scaling, object storage for model weights and datasets, message queues to decouple training and inference tasks, and logging services with monitoring and alerting to keep operations observable. Together these form the foundation for large-scale deployment of large models. Platforms such as Baidu AI Cloud offer this kind of general infrastructure across the categories above and can support the full pipeline from training to inference.
Summary
The architectural evolution of modern large language models is essentially a search for the best trade-offs under three constraints: compute, memory, and communication. Total parameters surge toward the trillions to expand knowledge capacity, while activated parameters stay lean to control inference cost; context keeps lengthening while the KV Cache is continuously compressed; experts grow more numerous and routing grows finer. Understanding this “seemingly contradictory yet self-consistent” design logic is the prerequisite for good decisions on model selection, deployment planning, and accelerators.
