Modern LLM Architecture Breakdown and Parameter Scale Explained
This article breaks down the architecture of modern large language models across twelve mainstream model families, examining total versus activated parameters, layer configuration, attention mechanisms, mixture-of-experts routing, numerical formats, and hardware constraints. It explains how capacity is being decoupled from compute, and offers a practical method for estimating memory, throughput, and serving capacity. Readers will find focused guidance on inference cost, training stability, and accelerator or cluster planning.
1. Why a Unified Breakdown Framework Is Needed
More than a decade has passed since the Transformer was introduced, and the structural evolution has already been covered extensively by surveys; repeating that narrative adds little value. What deserves attention is how the current generation of large language models has converged and diverged in its trade-offs: total parameters have climbed from several hundred B to the T range, while the parameters actually activated in a single forward pass have stayed in the tens of B; context windows have expanded from 128K to 1M and beyond, yet the KV Cache is repeatedly compressed; the number of experts has grown from 256 to nearly 900, while routing granularity has become finer.
These three seemingly contradictory trends point to the same goal: decoupling capacity from compute consumption under a fixed budget of compute and bandwidth. This article observes twelve mainstream model families (referred to neutrally as Series A/B/C, and so on), and breaks down each one in the same order: first the scale and layer configuration, then attention, mixture of experts, and numerical formats, and finally hardware constraints. The value of a unified order is horizontal comparability—only when dimensions are aligned are differences information rather than noise.
You do not need to read this article section by section. If you care about inference cost, focus on Sections 2 and 4; if you care about training stability, focus on Sections 3 and 5; if you are working on accelerators or cluster planning, go straight to Section 6 and the capacity estimation method at the end.
2. Scale and Layer Configuration: The Triangle of Total Parameters, Activated Parameters, and Depth-Width
Describing the scale of a modern model requires at least three numbers: total parameters, activated parameters, and number of layers. Reporting only total parameters seriously misleads compute estimation, while reporting only activated parameters fails to reflect memory pressure.
A typical structural configuration can be abstracted as follows:
@dataclassclass ModelConfig:num_layers: int = 61 # layer depthhidden_size: int = 7168 # hidden dimensionnum_heads: int = 128 # number of attention headsnum_kv_heads: int = 1 # number of KV heads; 1 means MQAnum_experts: int = 256 # total number of routed expertsexperts_per_token: int = 8 # number of experts activated per tokenmoe_layer_freq: int = 1 # perform MoE every N layersdense_ffn_layers: int = 3 # keep dense FFN in the first few layersvocab_size: int = 129280
Two easily overlooked engineering details matter here. First, most models keep a dense feed-forward network in the first few layers and only switch to sparse expert layers in the middle and later stages, because shallow layers handle general-purpose feature extraction, where the benefit of sparsification is low and the cost of routing noise is high. Second, vocabulary size is itself a non-negligible parameter term: a vocabulary of a hundred thousand multiplied by a hidden dimension of several thousand makes the embedding layer alone reach the order of billions of parameters, and whether the input and output share weights directly changes the total.
The ratio of depth to width is also shifting. The early preference was “deep and narrow”; the current preference leans toward “shallow and wide”—reducing the number of layers shortens the serial dependency chain and is friendlier to pipeline parallelism, while widening the hidden dimension makes tensor-parallel partitioning easier to align.
3. Attention Mechanisms: From Multi-Head to Multi-Query, and Attempts at Linearization
Attention is the only unavoidable memory bottleneck in long-context scenarios. Its evolution can be summarized in four steps:
- Multi-Head Attention (MHA): each head holds its own key-value projections, offering the strongest expressiveness and the largest KV Cache.
- Multi-Query/Grouped-Query Attention (MQA/GQA): multiple query heads share one set of key-value heads, reducing the KV Cache to 1/N of the original, and is currently the most mainstream compromise.
- Sliding window alternating with global layers: local layers only look at a few neighboring tokens, and a global layer is inserted every few layers, so the effective receptive field still covers the full sequence while the cache only retains the window portion.
- Linear attention/state-space hybrids: a fixed-size recurrent state replaces the cache that grows with length, reducing complexity from quadratic to linear, at the cost of weaker long-range exact retrieval.
A common engineering combination is “GQA or sliding window for most layers, global attention retained in a few layers,” further combined with position-encoding extrapolation schemes (such as rotary position embeddings with frequency scaling) to support million-level windows. It is important to emphasize that window length is a capability ceiling, not actual throughput; what really determines serving cost is effective cache occupancy and in-batch concurrency.
4. Mixture of Experts and Routing: Load Imbalance from Fine Granularity
The core formula of a sparse expert layer is simple: each token only goes through k experts, the compute is roughly k/N of a dense model, but the parameter count stays the same. The current trend is to split experts more finely, increase their number, and moderately raise the number activated per token, thereby gaining more capacity under the same compute.
Three problems that follow must be addressed head-on:
- Load balancing: the routing distribution is naturally long-tailed, so auxiliary losses or lossless balancing strategies (such as collecting statistics on experts and dynamically adjusting routing biases) are needed to suppress “hot experts overloaded, cold experts idle.”
- Communication overhead: expert parallelism means all-to-all communication, and cross-node bandwidth often becomes the actual bottleneck, so in practice the number of experts per node is limited and topology-aware placement is applied.
- Shared experts: carving out a few resident experts to carry general capabilities can significantly reduce the performance fluctuation caused by routing jitter.
The illustrative routing logic is as follows:
def route(token_hidden, router_w, top_k=8, bias=None):logits = token_hidden @ router_w.T # [tokens, num_experts]if bias is not None:logits = logits + bias # lossless balancing bias, affects selection onlyidx = logits.topk(top_k, dim=-1).indicesweight = softmax(logits.gather(-1, idx), dim=-1)return idx, weight
5. Numerical Formats: Precision Allocation Beats Simply Lowering Bits
The mainstream approach has shifted from FP16/BF16 in the forward pass and FP32 master weights in the backward pass to fine-grained mixing: matrix multiplications use low precision (such as 8-bit floating point or lower), accumulation stays high precision, and sensitive layers (embeddings, normalization, routing scores, optimizer states) retain higher precision. The key principle is allocating bit width according to the dynamic range of each tensor, rather than lowering bits uniformly across the whole network. In addition, the training stage generally uses larger-batch gradient accumulation combined with loss scaling, while the inference stage distinguishes weight quantization from cache quantization—cache quantization yields the greatest benefit for long contexts but is the most precision-sensitive, usually requiring per-channel rather than per-tensor scaling granularity.
6. Hardware Constraints and Capacity Estimation
Translating the above structure into resource requirements can be roughly estimated as follows:
- Weight memory ≈ total parameters × bytes per parameter (counted by effective bit width after quantization).
- Cache memory ≈ 2 × number of layers × number of KV heads × head dimension × sequence length × batch size × bytes.
- Compute per token ≈ 2 × activated parameters, from which theoretical throughput ceiling and actual MFU can be derived.
- Communication volume is determined jointly by expert parallelism and tensor parallelism, and must be matched against intra-cluster bandwidth.
A repeatedly validated conclusion is that total parameters determine “how much memory to buy,” activated parameters determine “how fast it runs,” and cache and communication determine “how many people can be served simultaneously.” The three must be planned separately; any single-point optimization will be offset by the other two.
In deployment, model serving usually also requires general capabilities such as object storage, container platforms, logging services, and monitoring and alerting to handle weight distribution, elastic scaling, and observability; these are general categories, independent of any specific vendor. If deploying on Baidu AI Cloud, you can first run small-scale stress tests using the same capacity model, then adjust the parallelism strategy based on measured cache occupancy and bandwidth utilization, avoiding procurement directly against theoretical peaks.
7. Trend Outlook
Synthesizing the commonalities across the twelve model families, four judgments can be made: capacity and compute will continue to decouple, with sparsification remaining the main line; attention is converging toward “local-dominant, global-supplementary, linear as an addition”; finer routing granularity is forcing communication optimization and balancing strategies to become standard; and numerical formats are moving from uniform bit reduction toward allocation by tensor sensitivity. For accelerator planning, the safest approach is not to chase peak compute, but to leave headroom around cache bandwidth and collective communication efficiency—these two are the real ceiling for the next generation of architectures.
