Large Language Model Architecture and Parameter Scale Explained
This article breaks down how large language model architecture has evolved as a set of trade-offs under hardware constraints. It covers the separation of total and active parameters, attention compression techniques, mixture-of-experts routing and load balancing, layered numerical precision, and KV Cache management. A mapping table links structural choices to memory, compute, and communication pressure, followed by three practical recommendations for capacity and cluster planning.
1. Why Architecture Deserves Its Own Discussion
It has been ten years since the Transformer was introduced, and surveys of its architectural evolution are far from rare. Most of them, however, stop at describing what each generation changed, without a single thread that ties the scattered modifications together. This article takes a different angle: it treats network architecture as the outcome of trade-offs made under hardware constraints.
Over the past few years, several metrics have moved in directions that do not agree with one another, and sometimes directly contradict each other:
- Total parameters have grown from hundreds of billions to the multi-trillion range, yet the parameters activated in a single forward pass have stayed in the tens of billions.
- Context windows have expanded from 128K to around 1M, yet the KV Cache has been compressed again and again.
- The number of experts has risen from 256 to nearly a thousand, while routing granularity has become finer.
Read together, these three trends point to the same set of physical constraints: compute (FLOPs), memory access (bandwidth and capacity), and communication (across cards and across nodes). Once these constraints are understood, the direction of the next generation of architectures becomes predictable, and headroom can be left for accelerator and cluster planning.
The rest of this article unfolds as a series of twelve chapters and twenty-five sections, covering more than ten mainstream model families in turn. The sections follow roughly the same order: first the scale and layer configuration, then attention, mixture of experts, and numerical formats, and finally the hardware constraints. To stay neutral, no specific vendor or model is named; only the architectural paradigms widely adopted across the industry are discussed.
2. Scale and Layer Configuration: Separating Total from Active Parameters
The “scale” of a modern LLM is no longer a single number, but at least three: total parameters, active parameters, and the effective compute per token.
A typical sparse (mixture-of-experts) configuration can be described like this:
Total parameters ≈ hundreds of B ~ several TActive parameters ≈ tens of BLayers ≈ 60 ~ 90Hidden dimension ≈ 4K ~ 8KTotal experts ≈ 256 ~ 1024Experts active per token ≈ 4 ~ 8
This design of “large total parameters, small active parameters” essentially decouples capacity from compute: capacity is carried by the expert pool, while compute is determined by routing. One direct consequence is that memory footprint and compute demand no longer grow in step. At deployment time, the former determines how large a model you can fit, and the latter determines how fast you can run it; the two must be budgeted separately.
Two other practices are common in layer configuration. One is the balance between deep-and-narrow and shallow-and-wide, where the mainstream choice leans toward deeper stacks, because depth contributes more visibly to the length of the inference chain. The other is to keep the first several layers dense and introduce sparsity only in later layers, which stabilizes representations in early training.
3. Attention: From Full to Compressed
Attention is the main source of the KV Cache and the core of memory-access pressure in long-context scenarios. The industry has evolved several parallel routes to compress it:
- Multi-head query compression: project keys and values into a low-dimensional latent space and cache the latent vectors instead of full keys and values, significantly reducing cache size.
- Grouped-query: multiple query heads share one group of key-value heads, reducing the number of heads.
- Sparse and sliding-window: interact only with a local window or a small number of global tokens, reducing complexity from quadratic to near-linear.
- Linear/hybrid attention: replace softmax attention with a linear or gated form in some layers, while keeping full attention in the rest to preserve long-range retrieval ability.
What is more common in engineering is hybrid stacking: most layers use cheap attention and a few use full attention, with the ratio typically falling between 1:3 and 1:4. This keeps the cache under control while preserving exact retrieval.
An illustrative version:
# Layer type allocation for hybrid stacking (illustrative)def build_layer_types(n_layers, full_ratio=0.25):full = max(1, int(n_layers * full_ratio))types = ["linear"] * n_layersfor i in range(full):types[int(i * n_layers / full)] = "full"return types
4. Mixture of Experts and Routing: Finer Granularity and Load Balancing
Increasing the number of experts and making routing finer is a way to raise capacity utilization at the same level of active compute. But fine granularity brings two problems that must be handled.
The first is load imbalance. Routing is naturally biased: popular experts get overwhelmed while unpopular ones sit idle. Common countermeasures include adding a load-balancing auxiliary loss during training, adding noise to routing scores to preserve exploration, and setting a per-token expert capacity limit that drops overflow.
The second is communication. Experts are spread across different devices, so a token has to fetch parameters across cards, and all-to-all communication becomes the bottleneck. In engineering, routing decisions are typically overlapped with communication, and a combination of “shared experts + fine-grained experts” is adopted: shared experts carry general capability, while fine-grained experts carry long-tail knowledge.
Routing output: top-k experts + 1 shared expertCapacity factor: 1.0 ~ 1.25 (smaller saves memory, larger is more stable)
5. Numerical Formats: Layered Precision
The choice of numerical format is likewise a product of hardware constraints. The currently prevailing approach is layered mixing:
- Compute in low-precision floating point (8-bit is mainstream) in exchange for throughput.
- Store weights and optimizer states in higher precision to keep convergence stable.
- Decide whether to reduce precision for caches and communication based on bandwidth pressure.
- Use high-precision accumulators for sensitive operations such as normalization and accumulation.
It is worth stressing that low precision is not applied globally, but selected layer by layer and even operator by operator. Misjudging a sensitive layer as one that can be downcast often shows up as loss jitter in late training rather than an outright error, which makes it very costly to diagnose.
6. Context and KV Cache: Larger Windows, Smaller Caches
As context expands from 128K to 1M, one would expect the cache to explode, yet it is held down for three reasons: attention compression reduces the per-token cache size; paged cache management reduces fragmentation; and prefix sharing means system prompts and long documents are stored only once.
In practice, this also needs to be paired with position-encoding extrapolation strategies and retrieval-based memory, splitting the “infinite window” into a combination of “long window + external retrieval.”
7. Mapping to Hardware Constraints: A Reference Table
| Architectural choice | Main pressure | Mitigation |
|---|---|---|
| Larger total parameters | Memory capacity | Sparsification, quantization, layered loading |
| Small active parameters | Compute utilization | Larger batch size, operator fusion |
| More experts | Cross-card communication | Overlapping communication with compute, expert placement optimization |
| Longer context | Memory bandwidth | Cache compression, paged management |
| Low precision | Numerical stability | Layered precision, protecting sensitive layers |
8. Three Recommendations for Planners
- Budget capacity and compute separately; do not use a single “parameter count” metric for capacity planning.
- Treat cache and communication as first-class citizens; they often become bottlenecks earlier than compute.
- Keep structural redundancy, leaving headroom for the finer routing and longer windows of the next generation.
The surface of architectural evolution looks scattered, but the core is unified: every change reallocates budget among compute, memory access, and communication. With this thread in hand, reading the architecture description of any new generation makes it quick to locate the problem it is really trying to solve.
