Anatomy of Modern LLM Architectures: Layer Design, Attention, MoE Routing, and Parameter Scale
This article breaks down the structure of modern large language models across twelve mainstream model families, focusing on four design dimensions that separate them: layer ordering, attention sparsification, expert routing, and residual mixing. It explains how seemingly scattered architectural changes converge on the same hardware constraints—compute, memory bandwidth, and inter-card communication—and covers key trends such as rising total parameters with stable activated parameters, expanding context windows paired with compressed KV Cache, finer-grained expert routing, and lower-precision numerical formats with block-level scaling. Each section includes operator-level estimates of cache footprint, compute, and weight size, along with a sample Python snippet and four practical recommendations for capacity planning.
1. Why Structure Deserves Its Own Discussion
The Transformer was proposed a decade ago, and the evolution of its structure is hardly short of surveys. What truly deserves separate discussion is how changes that look scattered across different model families ultimately converge on the same set of hardware constraints: compute, memory bandwidth, and inter-card communication.
Four trends summarize the current landscape:
- Total parameters are moving from hundreds of B to several T, while activated parameters per forward pass remain at tens of B.
- Context windows have expanded from 128K to 1M, yet KV Cache is repeatedly compressed.
- The number of experts has grown from 256 to nearly a thousand, while routing granularity keeps getting finer.
- Numerical formats have shifted from half precision to lower bit widths, with block-level scaling now standard.
These four trends constrain one another. Clarifying their causal relationships is necessary to judge the direction of next-generation structures and to leave headroom for accelerator capacity planning. This article uses twelve mainstream model families as samples, breaking down their layer configurations, attention patterns, mixture-of-experts designs, and numerical formats one by one, with operator-level estimates of cache, compute, and weight size at the end of each section.
Convention: B and T denote billion and trillion parameters respectively; the article uses “token” as the unit throughout, without a plural suffix.
2. Four Design Dimensions That Truly Create Separation
2.1 Layer Ordering
Layer ordering determines how operators are arranged in the pipeline. Three common approaches exist: strict alternation of attention and feed-forward layers; inserting sparse attention every few layers to amortize long-sequence overhead; and replacing feed-forward layers entirely with mixture-of-experts layers while keeping a few dense layers at shallow depths to stabilize early training. Layer ordering also affects parallelism strategy—attention layers prefer splitting along the sequence dimension, feed-forward layers prefer the hidden dimension, and more complex interleaving means more reordering and communication.
2.2 Attention Sparsification
The bottleneck for long context is memory access, not compute. Mainstream techniques include sliding windows to limit the visible range, compressing multi-head key-value projections into low-rank latent variables to shrink the cache, using sparse indexing for coarse filtering before fine computation, and sharing key-values across layers. Whether a scheme is worthwhile depends on its “cache bytes per thousand tokens,” not the window length it claims.
2.3 Expert Routing
The combination of fine-grained experts plus shared experts has become consensus: route to more, smaller experts, then let a few resident shared experts carry general capabilities. The key metrics are activation ratio and load-balancing loss. A lower activation ratio means larger weight size, higher weight transfer and host-side memory pressure; finer routing means more all-to-all communication packets.
2.4 Residual Mixing
Changes on the residual side are the easiest to overlook but directly affect numerical stability: gated residuals, per-token adaptive mixing coefficients, and low-precision accumulation paired with high-precision normalization all balance “saving bandwidth” against “not diverging.”
3. Structure Highlights by Model Family (Neutral Description)
Since different families disclose different levels of detail, the following is organized into two categories: “original architecture diagrams already public” and “schematic diagrams drawn from technical specifications,” with undisclosed parts noted in figure captions.
- A DeepSeek-style family: from V3 to subsequent iterations, the main line is compressing key-value projections into latent variables and replacing feed-forward with fine-grained experts, with activated parameters stable at tens of B and total parameters rising stepwise.
- A Qwen-style family: the Max and Flash-Next branches from 3.5 to 3.8 differ mainly in layer ordering and cache strategy; the flagship branch targets capability ceilings, while the lightweight branch targets throughput and cost.
- A long-context-style family: K2.5 to K3.1 Pro focuses on attention sparsification and finer routing granularity under ultra-long context.
- A Xiaomi-style family MiMo-V2.5 and V2.6: a typical sample of small activation and many experts.
- A Meituan-style family LongCat-Flash and 2.0: reorders layers to gain pipeline efficiency.
- A Zhipu-style family GLM-5 to 5.3-Flash: flagship and lightweight branches share a backbone, differing in layer count and expert count.
- A MiniMax-style M3 and M3.1 Flash: representative of residual mixing and low-precision accumulation.
- A Hunyuan-style Hy4, a StepFun-style Step 5 Preview, a Mistral-style Large 3 and Large 4, a Meta-style Muse Spark Open, and Ling 2.0: each makes different tradeoffs in expert count, context length, and numerical format.
Note: the above is only a structural cross-comparison and does not constitute a recommendation or review of any specific product.
4. Operator-Level Estimation: Converting Structure into Resources
Using hidden dimension d, layer count L, sequence length s, batch size b, and activated expert count k as examples, a first-order estimate can be made with sample code:
def estimate(d, L, s, b, kv_bytes, ffn_bytes, k=1):# KV cache bytes per thousand tokenskv_per_1k = 1000 * kv_byteskv_total = b * s * kv_bytes# Weight size (expert part scaled by activation ratio)weights = L * ffn_bytes * k# Feed-forward compute (2 multiply-adds approximation)flops_ffn = 2 * b * s * L * ffn_bytesreturn kv_per_1k, kv_total, weights, flops_ffn
Three quantities matter: cache bytes per thousand tokens determine whether long context is feasible; weight size determines host-side memory and load time; activated compute determines accelerator selection. Underestimating any one of them will surface as throughput collapse during stress testing.
5. Four Practical Recommendations for Capacity Planning
- Define activated parameters and activation ratio first, then work backward to the total parameter ceiling to avoid weight transfer becoming the bottleneck.
- Use “cache bytes per thousand tokens” as a unified metric for context capability, combined with paged cache and quantization compression.
- Design routing granularity and communication topology together; fine-grained experts must match high-bandwidth interconnects.
- Numerical format changes must be paired with stability validation; low-precision accumulation needs high-precision normalization and key accumulation paths preserved.
Structural evolution has no endpoint, but the constraints are certain. Putting layer ordering, attention, routing, and residuals on the same resource ledger is the only way to make verifiable tradeoffs among compute, memory access, and communication.
