Understanding LLM Network Architecture and Parameter Scale: A Structural Breakdown
This article examines the network architecture of mainstream large language models, focusing on layer configuration, attention mechanisms, feed-forward pathways, and numerical formats. It frames four structural trade-offs—growing total parameters versus fixed active parameters, longer context versus compressed KV cache, finer expert routing, and reordered layer structures—and aligns them with three hardware constraints: compute, memory bandwidth, and inter-device communication. Readers will find pseudocode for a decoder layer, a KV cache sizing formula, and practical guidance for capacity planning.
1. Why Architecture Deserves Its Own Discussion
The Transformer has been around for more than a decade, and reviews of its structural evolution are hardly scarce. Rather than retreading that history, this article narrows the focus to the network architecture of today’s mainstream large language models (LLMs), taking each series apart to examine its layer configuration, attention form, feed-forward pathway, and numerical format.
Architecture matters because the changes vendors make look scattered on the surface but converge on the same set of constraints once they hit hardware: compute, memory bandwidth, and inter-device communication. Aligning these three with architectural choices is what makes it possible to judge where the next generation of models is heading and to leave headroom in accelerator planning.
Conventions used throughout: B means billion parameters, T means trillion parameters, and the unit of measurement is token, without a plural suffix. To avoid brand-specific implications, the discussion below refers to different technical routes as “open-source series A/B/C,” and the subject is publicly documented, general architectural characteristics.
2. Four Structural Tensions: The Main Thread for Reading LLMs
Current models reveal four trends pointing in opposite directions, and together they form the main thread of architectural design.
- Total parameters grow from hundreds of B to several T, while active parameters stay in the tens of B. Sparsification decouples capacity from compute.
- Context expands from 128K to 1M, while the KV cache is repeatedly compressed. Long-range capability and memory access cost are pulling against each other.
- The number of experts grows from 256 to 896, and routing granularity keeps getting finer. Fine granularity buys expressiveness across expert combinations.
- Layer order, residuals, and normalization placement are constantly rearranged. These look like minor tweaks, but they affect parallel partitioning and numerical stability.
3. Layer Ordering and the Feed-Forward Pathway
The mainstream approach is still alternating stacks of “attention block + feed-forward block.” The differences concentrate in three places: whether normalization sits before or after the sub-layer, whether residuals are added or combined through gated mixing, and whether a shared feed-forward layer is reused across layers.
# Pseudocode for a typical decoder layer (Pre-Norm + gated residual)h = x + Attn(RMSNorm(x))out = h + FFN(RMSNorm(h)) * gate(h) # gate is an optional residual mixing coefficient
Pre-Norm is easier to train and better suited to deep stacking; gated residuals are used to suppress gradient noise in deep networks. When the feed-forward layer is shared across layers, the weight footprint shrinks, but each layer still has to read it independently, so the memory access benefit is limited.
4. Attention Sparsification and KV Cache Compression
For long context, the bottleneck is not compute but the cache. Common techniques include sliding windows that limit the visible range, block-wise sparse sampling, low-rank or quantized compression of keys and values, and cross-layer key-value sharing. A sizing example:
KV_bytes ≈ 2 * layers * kv_heads * head_dim * seq_len * batch * bytes_per_elem
The “2” accounts for the two caches, keys and values. Reducing kv_heads by an order of magnitude, or quantizing the cache to a lower bit width, often improves long-sequence throughput more than adding compute does.
5. Mixture of Experts and Fine-Grained Routing
Sparse feed-forward splits a layer into multiple experts, with each token activating only a few of them. The trend is more experts, narrower experts, finer routing, plus shared experts that carry general-purpose capability. Load balancing is an engineering must: skewed routing turns a few experts into hotspots and slows down the whole batch.
logits = Router(RMSNorm(h)) # [tokens, num_experts]idx, w = TopK(logits, k) # fine-grained: large num_experts, moderate ky = sum(w_i * Expert_i(h) for i in idx) + SharedExpert(h)
6. Numerical Formats and Hardware Constraints
Low-precision training and inference are now the norm, and attention and feed-forward react differently to numerical formats: attention is more sensitive to numerical range, while feed-forward weights tolerate compression better. On hardware, three things have to be budgeted at the same time: cache capacity, the compute ceiling, and weight footprint.
- Cache: scales linearly with layer count and sequence length, making it the primary bottleneck for long context.
- Compute: determined by active parameters, so sparsification keeps total parameter growth from directly driving up compute.
- Communication: expert parallelism introduces cross-device All-to-All, and the finer the routing, the higher the communication frequency.
7. Practical Advice for Developers
- Start with an operator-level breakdown, listing operators, formulas, and tensor dimensions along the two paths of attention and feed-forward.
- Then budget cache, compute, and weight footprint to determine whether the bottleneck is memory access or communication.
- For capacity planning, prioritize compressing the cache and improving routing balance rather than blindly piling on compute.
- For cloud deployment, general-purpose capabilities (container platforms, object storage, monitoring and alerting, log services) can support elastic scaling and observability; general cloud infrastructure such as that offered by Baidu AI Cloud can carry this kind of workload.
8. Conclusion
Architectural differences ultimately point to the same set of hardware constraints. Aligning layer order, attention, expert routing, and residual mixing with compute, memory access, and communication yields a verifiable judgment about the next generation of models and leaves headroom for accelerator and cluster planning.
