Modern LLM Architecture and Parameter Scale: Dense vs. Mixture-of-Experts

    This article explains how modern decoder-only LLMs are structured and how parameter counts translate into engineering costs. It distinguishes total and active parameters, embedding and output weights, KV cache, and training state; compares dense and mixture-of-experts designs; and shows how to estimate memory, latency, throughput, and capacity for model selection.

    Modern LLM Architecture and Parameter Scale: Dense vs. Mixture-of-Experts

    In engineering practice, understanding a modern large language model requires more than looking at “how many parameters it has.” Architecture, parameter composition, compute paths, and deployment cost need to be viewed together. Public model descriptions often list series and model variants, but the more transferable knowledge is this: what modules make up an autoregressive language model, where parameters are distributed, why dense and mixture-of-experts architectures produce two different accounts of “total parameters” and “active parameters,” and how these numbers affect memory, latency, throughput, and model selection.

    1. A Unified View: Architecture Defines the Compute Graph, Parameter Scale Defines Capacity and Cost

    The mainstream backbone of modern large language models is a decoder-only autoregressive Transformer stack. Its basic compute path can be summarized as follows: input tokens are mapped to vectors through token embeddings and passed through several decoder blocks. Each layer usually includes normalization, causal self-attention, a residual connection, normalization, a feed-forward network, and another residual connection. Finally, output normalization and vocabulary projection produce logits, and tokens are generated autoregressively one at a time.

    Architectural parameters typically include the number of layers, hidden dimension, number of attention heads, number of key-value heads, feed-forward intermediate dimension, vocabulary size, maximum context length, number of experts, and number of activated experts. Parameter scale should distinguish at least the following categories:

    • Total parameters: the sum of all learnable parameters in the model weights, which determines the lower bound of weight memory.
    • Active parameters: the parameter scale actually traversed by a single token during forward computation, which is closer to per-token compute cost.
    • Embedding and output parameters: vocabulary projection can consume a considerable number of parameters, especially in smaller models.
    • KV cache: not part of model weights, but it grows linearly with context length and concurrency and directly affects inference memory.
    • Training-state parameters: during training, there are also gradients, optimizer states, and activations, which are far larger than inference weights.

    A rough way to estimate parameters is: total parameters are approximately the sum of token embedding and output projection, attention projections in each layer, feed-forward networks in each layer, and normalization and other parameters. In a standard feed-forward network, a single layer contains about two large matrices; with a gated feed-forward network, it usually contains three large matrices. In the attention part, multi-head attention contains four types of projections: query, key, value, and output. With grouped-query attention or shared key-value heads, key-value projection parameters decrease. A mixture-of-experts architecture splits the feed-forward network into multiple experts and adds routing parameters. Total parameters grow with the number of experts, but each token activates only a few of them.

    Therefore, “how large is the parameter scale” has no single answer. A more effective engineering question is: How large are the total parameters? How large are the active parameters? How large is the KV cache? How long is the context? What precision and quantization strategy is used? What are the target concurrency and latency?

    2. Breaking Down the Backbone: From Attention to Feed-Forward Networks

    2.1 Decoder Stack and Residual Path

    A decoder stack consists of multiple identical or similar blocks. The number of layers determines depth, and the hidden dimension determines width. Residual connections ensure trainability in deep networks. Modern models often use pre-normalization, where normalization is applied before attention and the feed-forward network, while an identity mapping is preserved on the main residual path. Normalization methods often include root mean square normalization and similar variants, intended to improve deep-training stability. More layers increase representational depth but also add serial computation and communication overhead; greater width increases per-layer capacity but makes matrix multiplications larger. Architecture design often trades off depth, width, parallelism, and memory.

    2.2 Causal Self-Attention and KV-Head Design

    Self-attention lets each position aggregate historical context. A causal mask ensures that future tokens cannot be seen during training. Standard multi-head attention keeps independent query, key, and value projections for each head. Grouped-query attention lets multiple query heads share a set of key-value heads, reducing KV cache and inference bandwidth. Multi-query attention reduces key-value heads even further. Fewer KV heads lower memory pressure under long context and high concurrency, but may affect expressiveness and must be validated through training and evaluation.

    KV cache can be estimated with a general formula: per-token KV cache is approximately “2 × number of layers × number of KV heads × dimension per head × bytes per element.” If context length doubles, the cache approximately doubles; if concurrency doubles, the cache doubles again. Many long-context deployment bottlenecks are not in the weights but in the KV cache and attention computation.

    2.3 Positional Encoding and Long Context

    Positional encoding provides sequence-order information. Rotary positional encoding is a common approach; it injects relative position information by rotating query and key vectors. Context extension usually requires positional-encoding scaling, interpolation, or continued training, together with a long-text data mix. It is important to note that a nominal context length does not equal effective retrieval and reasoning capability at all positions. Long-context capability should be evaluated with needle-in-a-haystack retrieval, multi-hop reasoning, long-document summarization, and structured extraction tasks, not just the maximum-length number.

    2.4 Feed-Forward Networks, Activations, and Normalization

    The feed-forward network is a parameter-dense area. Gated linear units and their variants improve representational efficiency through gating branches; common forms include gating projection, up projection, and down projection. The feed-forward intermediate dimension is usually proportional to the hidden dimension, but the ratio is not fixed. Normalization layers have very few parameters, yet they affect training stability. The output layer maps hidden vectors to vocabulary space. The larger the vocabulary, the higher the output-projection and softmax cost. If input and output weights are tied, some parameters can be reduced, but this changes the coupling between embedding and output space.

    2.5 General Structure for Multimodal Extensions

    If a model accepts image, audio, or other inputs, it usually adds a corresponding encoder and uses a projection layer to align encoder outputs with the language model’s hidden space. In this case, parameter scale must distinguish the language backbone, encoder, and projection layer. Multimodal capability is not simply “adding an encoder”; it also involves training-data mix, alignment stages, and inference scheduling. Enterprise evaluation should separately examine text capability, multimodal understanding, cross-modal reasoning, and end-to-end latency.

    3. Dense vs. Mixture-of-Experts: Two Sets of Parameter Accounting

    In a dense model, every token passes through all feed-forward parameters, so total parameters and active parameters are close. A mixture-of-experts model splits the feed-forward layer into multiple experts, and a router selects top-k experts for each token. Its total parameters can include all experts, but a single token activates only a few experts, so active parameters are much smaller than total parameters. In pseudocode:

    1. for token in sequence:
    2. x = embed(token)
    3. for layer in layers:
    4. x = x + attention(norm(x))
    5. if layer.is_moe:
    6. x = x + moe_ffn(norm(x), top_k=config.top_k)
    7. else:
    8. x = x + dense_ffn(norm(x))
    9. logits = lm_head(final_norm(x))

    The advantage of mixture-of-experts is that a larger total capacity can improve model expressiveness while keeping per-token computation at a smaller active scale. But it introduces new engineering issues: all expert weights still need to be stored or sharded, so the memory floor is not necessarily low; routing may be imbalanced and require auxiliary losses or capacity control; expert parallelism introduces cross-device communication; and in small-batch inference, expert utilization may be insufficient, making batching and scheduling critical. When selecting a model, do not assume deployment is cheap just because “active parameters are small.” Look at total parameters, expert-parallel topology, batch size, and latency targets together.

    From a general engineering perspective, parameter scale can be roughly divided into several ranges. This is only a discussion framework, not specific product data:

    Scale range (illustrative) Structural characteristics Main concerns Deployment orientation
    Below 1B Mostly dense, fewer layers and smaller width Edge latency, quantization loss, vocabulary cost On-device, lightweight services, low concurrency
    1B–10B Dense or few experts Throughput, memory, long-context cache Single-node multi-GPU, medium concurrency
    Above 10B Large dense models or multi-expert structures Total-parameter memory, active-parameter compute, parallel communication Multi-GPU clusters, batch scheduling
    Very large total parameters Mixture-of-experts common Expert parallelism, load balancing, cost model Large-scale serving and specialized tasks

    4. How to Read Parameter Scale: From Spec Sheets to Engineering Metrics

    When reading a parameter table, it helps to derive secondary metrics. Weight memory is approximately “total parameters × bytes per parameter.” Inference memory must also add KV cache, temporary activations, and framework overhead. Training memory must further add gradients, optimizer states, and activation checkpointing overhead. Quantization can reduce weight memory and bandwidth, but KV cache precision, attention computation, and the output layer may still need separate optimization. The longer the context, the more prominent the KV cache; the higher the concurrency, the more total cache grows near-linearly.

    A configuration-field example can be abstractly described as follows. The values are illustrative field names only and are not parameters for any product:

    1. {
    2. "hidden_size": "D",
    3. "num_layers": "L",
    4. "num_attention_heads": "H",
    5. "num_kv_heads": "K",
    6. "ffn_intermediate_size": "F",
    7. "vocab_size": "V",
    8. "context_length": "C",
    9. "moe": {"num_experts": "E", "top_k": "A"}
    10. }

    From this, one can estimate: weight memory is roughly proportional to total parameters; per-token KV cache is roughly proportional to layers, KV heads, dimension per head, and bytes per element; per-token compute is related to active parameters and sequence length, with the attention part also growing with context. For capacity planning, enterprises should put “offline evaluation quality, online time to first token, per-token latency, throughput, concurrency, memory usage, and cost per request” into the same table instead of comparing parameter scale alone.

    5. Scaling Laws, Architectural Trade-offs, and Evaluation

    A general lesson from scale expansion is: when data quality and training sufficiency match, increasing parameters and compute usually reduces language-modeling loss, but returns diminish; when data is insufficient, blindly increasing parameters can lead to undertraining. Mixture-of-experts changes the cost curve by increasing total capacity and controlling active computation, but it places higher demands on data mix, routing stability, and distributed training. Long-context extension is not free; it requires positional-encoding adaptation, long-text training, and an evaluation system.

    Architectural trade-offs include: how to allocate depth and width; the ratio of multi-head attention to grouped key-value heads; feed-forward intermediate size; vocabulary size and multilingual coverage; dense versus mixture-of-experts; and weight precision and quantization strategy. Evaluation should cover general language capability, domain knowledge, instruction following, structured output, long-document processing, retrieval-augmented question answering, tool-calling workflows, and safety alignment, combined with A/B evaluation on real business samples. Parameter scale is only a screening condition, not the final conclusion.

    6. Selection Checklist and Common Pitfalls

    Enterprise model selection can proceed with the following checklist: define task boundaries and quality thresholds; estimate peak concurrency and context distribution; build a memory model for weights, KV cache, and temporary activations; stress-test time to first token and throughput; validate quality loss after quantization; evaluate long-context effectiveness and structured-output stability; calculate cost per request; and design gradual rollout and rollback strategies. If a mixture-of-experts structure is used, also validate expert load, batching efficiency, and cross-device communication overhead.

    Common pitfalls include: equating total parameters with the capability ceiling; equating small active parameters with low memory usage; assuming nominal context length is directly equivalent to effective long-text capability; assuming quantization has no cost; ignoring vocabulary and output-layer cost; and looking only at average latency without tail latency. A more reliable approach is: use architectural understanding to build a cost model, use business evaluation to validate quality, use stress-test data to calibrate capacity, and then decide on parameter scale and deployment form. Only in this way can reading a parameter table move from “number comparison” to “engineering decision-making.”