Demystifying Modern LLM Architecture and Parameter Scale: Attention, MoE, and Hardware Constraints
This article breaks down the network architecture of current mainstream large language models, covering total versus active parameters, layer configuration, attention variants, mixture-of-experts routing, and numerical precision. It explains how structural choices map to compute, memory bandwidth, and interconnect limits, and provides operator-level formulas and a reusable checklist for capacity planning. Readers will gain a practical framework for translating model structure into compute, cache, and weight-memory budgets.
1. Why Architecture Deserves Its Own Discussion
It has been ten years since the Transformer was introduced, and the evolution of its architecture has already been covered by multiple surveys. This article does not repeat that history. Instead, it focuses on the concrete network configurations of today’s mainstream large language models, unpacking their scale, attention patterns, feed-forward paths, and numerical precision layer by layer.
Architecture is discussed separately because changes from different vendors may look scattered, but on hardware they converge on the same set of constraints: compute, memory bandwidth, and interconnect communication. Mapping these three constraints to architectural parameters explains a series of seemingly contradictory observations:
- Total parameters have grown from hundreds of B to several T, while active parameters have stayed in the tens of B.
- Context windows have expanded from 128K to 1M, yet the KV Cache keeps getting compressed.
- The number of experts has increased from 256 to nearly a thousand, while routing granularity has become finer.
Conventions used below: B means one billion parameters, T means one trillion parameters, the unit of measurement is uniformly token without a plural suffix. The article is organized by model family. Each section first covers scale and layer configuration, then discusses attention, mixture of experts, and numerical format in order, and finally maps them to hardware constraints. Each section ends with an operator-level breakdown that lists operators, formulas, and tensor dimensions along the attention and feed-forward paths, with cache, compute, and weight-size accounting given in the notes.
2. Scale Coordinates: Total Parameters, Active Parameters, and Layer Configuration
To judge a model’s architecture, start with three numbers: total parameters, active parameters, and layer count. Total parameters set the lower bound of weight memory, active parameters determine the multiply-accumulate work per token, and layer count affects both serial depth and communication rounds.
The current mainstream approach can be summarized as “sparsification + deep and narrow”:
Total parameters P_total ≈ hundreds of B ~ several TActive parameters P_active ≈ tens of B (decoupled from total parameters)Layers L ≈ 60 ~ 100+Hidden dimension d_model ≈ 4K ~ 8KExpert count E ≈ 256 ~ 896 (some designs are finer)Activated experts per token k ≈ 4 ~ 8
The direct benefit of sparsification is that floating-point work in training and inference depends only on active parameters, while weight size still scales with total parameters. This creates an accounting rule that must be settled in advance: the compute budget is sized by active parameters, while the memory and bandwidth budget is sized by total parameters. The two cannot be mixed.
3. Attention: From Full KV to Multiple Compression Forms
Attention is the main source of long-context cost. With standard multi-head attention, KV Cache size grows linearly with layer count and sequence length:
KV_bytes ≈ 2 × L × n_kv_head × d_head × seq_len × bytes_per_value
Mainstream designs converge on three directions, usually combined:
- Fewer KV heads: multi-query/grouped-query attention lets multiple query heads share one set of keys and values, reducing KV heads from dozens to single digits.
- Low-rank compression: project keys and values into a low-dimensional latent space for caching, then up-project during inference, significantly reducing cache size.
- Sparse or block attention: a local window plus a small number of global tokens, combined with gated decay in linear attention, brings memory access for long sequences back into a manageable range.
One engineering caveat: compression changes the operator’s memory-access ratio. Attention that was originally compute-bound becomes memory-bound at extremely low KV head counts. At that point, the key to improving compute-unit utilization is no longer peak floating-point performance, but cache capacity and bandwidth.
4. Mixture of Experts: Fine-Grained Routing and Load Balancing
The feed-forward path has evolved from a dense FFN to a sparse mixture of experts. The core formula can be written as:
h = Σ_{i∈TopK(x)} g_i · Expert_i(x), Σ g_i = 1
The evolution centers on three points:
- Finer and more experts: each expert has a smaller hidden dimension, the expert count rises, and routing shifts from “selecting a few large modules” to “selecting a batch of small modules”.
- Always-on shared experts: some experts are permanently active for all tokens and handle general transformations, while routed experts only fill in the differences.
- Balance loss and capacity factor: an auxiliary loss distributes tokens as evenly as possible across experts, preventing individual experts from overheating and causing pipeline stalls.
The cost of fine-grained routing is communication: tokens must be rearranged across devices according to routing results, and All-to-All data volume is directly related to k, E, and sequence length. Therefore, expert parallelism, tensor parallelism, and pipeline parallelism must be tuned jointly rather than each optimized independently.
5. Numerical Formats: The Triangle of Precision, Stability, and Throughput
Low precision is the most direct way to increase throughput, but the architecture must support it. A common approach is to use low-bit floating point or integers for weights and activations, keep accumulators at high precision, and retain higher precision for sensitive layers (normalization, routing scores, output projection); optimizer states and master weights are stored separately as high-precision copies.
# Illustration: forward skeleton with mixed precision (pseudocode)def forward(x):x = rms_norm(x, dtype=high)q, k, v = proj(x, dtype=low) # low-precision projectiono = attn(q, k, v, accum=high) # high-precision accumulationh = rms_norm(o, dtype=high)y = moe(h, topk=8, accum=high) # routing scores stay high precisionreturn y
Note that the above is only a generic illustration. Vendors differ in exact bit widths, scaling granularity, and which layers retain higher precision. Selection should be based on published technical specifications, and uniformity should not be assumed.
6. Hardware Constraint Accounting: A Reusable Operator-Level Checklist
To translate architecture into a resource budget, fix it into a table and fill it in section by section:
| Path | Key Operators | Main Bottleneck | Accounting Focus |
|---|---|---|---|
| Attention | Projection, scoring, weighted sum | Bandwidth/cache | KV Cache size, sequence length |
| Feed-forward | Routing, expert matrix multiply | Compute/communication | Activated experts, All-to-All volume |
| Normalization and residual | RMS normalization, element-wise add | Bandwidth | Intermediate activation read/write count |
| Output | Output projection, sampling | Bandwidth | Vocabulary size, batch size |
Three accompanying estimation formulas:
Weight size ≈ P_total × bytes_per_paramCompute per token ≈ 2 × P_active (forward)Cache size ≈ 2 × L × n_kv_head × d_head × seq_len × bytes_per_value
7. Trend Outlook and Planning Headroom
Looking at these architectural choices together, three trends emerge: total parameters keep rising while active parameters stay restrained; context keeps getting longer while the cache keeps being compressed; experts get finer while routing gets cheaper. All three point to the same thing: the bottleneck is shifting from raw compute to bandwidth, cache capacity, and interconnect efficiency.
For teams planning accelerators or selecting clusters, it is advisable to reserve headroom in three areas: cache capacity (for longer contexts), interconnect bandwidth (for finer-grained routing), and operator adaptation (for switching numerical formats). For cloud-based deployments, first evaluate whether general capabilities such as container platforms, high-performance storage, logging services, and monitoring and alerting are in place, then work through the table above item by item to avoid a resource mismatch after an architecture upgrade.
As the saying goes, only after playing a thousand tunes can one understand sound; only after examining a thousand swords can one recognize a weapon. Every small adjustment to the architecture must ultimately be cashed out at the operator level as a concrete resource bill. Only when the bill is clear can selection and planning rest on solid ground.
