Large Language Model Architecture and Parameter Scale: A Technical Breakdown

    This article breaks down the network architecture of mainstream large language models and examines how design choices are shaped by hardware constraints such as compute, memory bandwidth, and interconnect communication. It covers total versus active parameter counts, layer configurations, four main approaches to attention optimization, fine-grained expert routing and load balancing in MoE models, and mixed-precision numerical formats. It also maps these structural decisions to accelerator and cluster planning, helping readers evaluate trade-offs in model selection, stress testing, and capacity planning.

    1. Why Architecture Deserves a Separate Discussion

    It has been ten years since the Transformer was introduced, and surveys of its architectural evolution are already common. This article does not repeat that history. Instead, it takes a different angle: disassemble the network architecture of current mainstream large language models one by one. The changes made by different model families may look scattered, but they all point to the same set of hardware constraints—compute, memory bandwidth, and interconnect communication.

    A few trends are worth keeping in mind first:

    • Total parameters have grown from the hundreds of billions range to the trillions range, but the number of parameters actually activated per token has stayed in the tens of billions.
    • Context windows have expanded from 128K to around 1M, yet the KV Cache has been compressed repeatedly.
    • The number of experts has increased from 256 to nearly 900, while routing granularity has become finer.

    These three curves move in opposite directions, which shows that the core of architecture design is not “making the model bigger,” but reallocating resources under limited bandwidth and communication budgets. Only by clarifying the causal relationships among these trade-offs can we judge the direction of next-generation models and leave headroom for accelerator and cluster planning.

    Convention: in this article, B means one billion parameters, T means one trillion parameters, and the unit of measurement is uniformly token, without a plural suffix.

    2. Overall Scale and Layer Configuration: Start With Three Numbers

    When disassembling any model, start with three numbers: total parameters, active parameters, and number of layers. Total parameters determine memory and storage footprint, active parameters determine the compute per token, and the number of layers affects serial depth and inference latency.

    The current mainstream approach is “inflate total parameters, converge active parameters.” A typical configuration is: hidden dimension in the thousands, number of layers between 60 and 90, Pre-Norm plus RMSNorm, and no extra scaling on the residual path. The benefit of increasing layers is finer feature abstraction; the cost is more fragmented pipeline parallelism splits and harder-to-eliminate bubbles.

    Illustrative configuration-reading logic:

    1. @dataclass
    2. class ModelSpec:
    3. total_params: str # e.g. "600B"
    4. active_params: str # e.g. "30B"
    5. layers: int
    6. hidden: int
    7. experts: int # 0 means a dense model
    8. top_k: int
    9. ctx_len: int # e.g. 1_000_000
    10. def estimate_kv_bytes(spec: ModelSpec, batch: int,
    11. kv_heads: int, head_dim: int,
    12. dtype_bytes: int = 2) -> int:
    13. # One copy of K and V each per layer
    14. per_token = 2 * spec.layers * kv_heads * head_dim * dtype_bytes
    15. return batch * spec.ctx_len * per_token

    The point of this code is to translate “the context is very long” into an accountable memory number. A 1M context is almost unusable under a naive implementation, which is exactly the root reason why the KV Cache compression techniques discussed later exist.

    3. Four Approaches to Reworking Attention

    Attention is the main source of long-context cost, and mainstream reworks fall into four categories.

    The first is grouped-query attention (GQA) and multi-query attention (MQA), which compress the number of KV heads to a fraction of the number of query heads. The KV Cache drops proportionally, at the cost of a slight loss in representational capacity.

    The second is low-rank joint KV compression, which projects K and V into a low-dimensional latent space before caching and reconstructs them during inference. It shrinks the cache to a fraction of its original size, but adds reconstruction computation at each step.

    The third is a sparse and sliding-window hybrid, which applies attention only within a local window plus a small number of global tokens. Complexity drops from quadratic to near-linear, at the cost of carefully designing the positions of relay tokens.

    The fourth is linear attention or state-space hybrid layers, which replace the cache that grows with length by a fixed-size state. Memory usage for long text stays constant, but precise retrieval tasks usually require keeping a small number of full-attention layers as compensation.

    A common engineering combination is: most layers use compressed or sparse attention, while a few layers retain full attention, balancing cost and information fidelity.

    4. Mixture of Experts: Fine-Grained Routing and Load Balancing

    Mixture of Experts (MoE) is the key to decoupling total parameters from compute. The core parameters are the total number of experts, the number of experts activated per token (top_k), and the routing scoring method. The trend is more experts, relatively smaller top_k, and finer routing granularity, so that each expert behaves more like a “composable operator” with a larger combination space.

    The cost of fine-grained routing is communication. Under expert parallelism, a token must be sent to the device hosting its selected expert and then sent back; the time of the two all-to-all operations often exceeds the expert’s own computation. Common mitigations include: limiting the number of cross-device experts per token, overlapping routing decisions with transfer, and using a capacity factor to control the peak load of a single expert.

    A load-balancing loss function is almost mandatory; otherwise, a few experts are selected repeatedly while the remaining devices idle. Illustration:

    1. def moe_forward(x, gate, experts, top_k=2, capacity=1.25):
    2. scores = gate(x) # [tokens, num_experts]
    3. topv, topi = scores.topk(top_k, dim=-1)
    4. topv = topv / topv.sum(-1, keepdim=True)
    5. out = torch.zeros_like(x)
    6. cap = int(capacity * x.shape[0] * top_k / experts)
    7. for e in range(experts):
    8. idx = (topi == e).nonzero()[:, 0]
    9. if idx.numel() == 0:
    10. continue
    11. idx = idx[:cap] # drop or bypass beyond capacity
    12. out[idx] += topv[idx, e].unsqueeze(-1) * experts[e](x[idx])
    13. return out

    The capacity factor is the knob for accuracy and stability: increasing it reduces dropping, while decreasing it lowers memory and communication peaks.

    5. Numerical Formats: Balancing Precision, Stability, and Throughput

    Once parameter scale reaches the T level, the numerical format directly affects whether training can proceed. Mixed precision is now widely used: matrix multiplications use low precision (8-bit floating point or lower) for throughput, accumulation and normalization keep higher precision to avoid overflow and drift, and optimizer states are saved at even higher precision.

    The difficulty of low-precision training lies in outliers. The usual practice is to keep sensitive modules (such as normalization, residual accumulation, and routing scores) in high precision, and to design separate scaling strategies for weights and activations. Inference is more aggressive: weights are quantized block by block, activations are dynamically quantized, and per-channel scaling factors are used to compress memory usage to a level that can be carried by a single card or dual cards.

    It is worth emphasizing: any quantization scheme must be validated by task-level metric regression, not by perplexity alone.

    6. How Architecture Maps to Hardware Constraints

    Translating the architecture choices above into hardware language yields a clear mapping table:

    • Large total parameters → high memory and storage pressure, requiring expert parallelism and tensor parallelism splits;
    • Small active parameters → controllable compute demand, with the bottleneck shifting to memory access and communication;
    • Long context → high KV Cache and attention memory-access pressure, requiring compression and sparsification;
    • Many experts with fine routing → high all-to-all communication pressure, requiring high-bandwidth interconnect and topology-aware scheduling.

    Therefore, when planning a cluster or accelerator, do not focus only on peak compute; also account for memory access per token, cross-device communication volume, and cache footprint. If the application is mainly long documents or repository-level code context, prioritize evaluating the implementation quality of cache compression and sparse attention; if it is mainly high-concurrency short requests, prioritize evaluating the throughput of batch scheduling and quantized inference.

    For deployment, container platforms can handle environment isolation and elastic scaling, object storage can hold model weights and datasets, and logging services and monitoring alerts can track latency, throughput, and memory levels. Baidu AI Cloud offers a relatively complete combination of such general capabilities, making it easy to plug the evaluation metrics above directly into day-to-day operations views.

    7. Conclusion

    The essence of architectural evolution is dynamic reallocation among compute, memory access, and communication. The four sets of opposite trends—rising total parameters, converging active parameters, expanding context with compressed cache, and more experts with finer routing—will persist. Mastering the analysis chain of “scale—attention—experts—numerical format—hardware mapping” allows evidence-based judgments in selection, stress testing, and capacity planning, rather than being led by a single metric.