Open-Source LLM Architecture Evolution and Engineering Practice: A Complete Guide

    This article breaks down the architecture of modern open-source large language models and the engineering practices needed to deploy them. It explains why total and activated parameters must be evaluated separately, how Multi-head Latent Attention (MLA) and Dynamic Sparse Attention (DSA) reduce KV cache pressure, how Multi-Token Prediction (MTP) improves training signals and enables speculative decoding, and what low-precision training adds to optimizer stability. It also covers three-layer evaluation, capacity and cost modeling, and a practical deployment checklist.

    1. Why Total Parameters and Activated Parameters Must Be Evaluated Separately

    The most common mistake when assessing very large models is treating total parameter count as a direct proxy for inference cost. The core idea of the Mixture-of-Experts (MoE) architecture is to decouple capacity from computation: the model holds a large parameter pool for storing knowledge, but each token is routed to only a few experts, so the parameters that actually participate in matrix multiplications are far fewer than the total.

    Take a recent generation of open-source models as an example: roughly 744B total parameters, about 40B activated per token, 256 experts, and 80 layers. Compared with the previous generation (355B total, 32B activated), the total parameter count doubled while activated parameters grew only slightly. This means knowledge capacity expanded substantially, while the growth in inference compute stayed relatively modest.

    In practice, you need a two-perspective evaluation table:

    Perspective Key Metrics What It Affects
    Capacity Total parameters, expert count, data volume Knowledge coverage, training cost, GPU memory usage
    Compute Activated parameters, sequence length, concurrency Per-request latency, throughput, cost per token

    A frequent misconception is that total parameters determine GPU memory while activated parameters determine speed. A more accurate statement: total parameters together with precision determine weight memory and host memory requirements; activated parameters together with the attention implementation determine compute and bandwidth pressure; and the KV cache grows linearly with concurrency and context length, often becoming the real bottleneck in long-context scenarios.

    2. Attention Mechanisms: From Multi-Head to Latent Compression

    Traditional multi-head attention must cache the Key/Value of every layer under long contexts, and memory usage rises linearly with sequence length. Multi-head Latent Attention (MLA) takes a different approach: it compresses Key/Value into a low-dimensional latent space, caches only the compressed representation, and projects it back up during computation, substantially shrinking the cache. The intuition matches low-rank decomposition — a small number of latent variables carry information that can be approximated.

    Illustrative pseudocode (expressing the idea only, not a specific implementation):

    1. # Core idea of low-rank latent caching
    2. c = W_down @ x # compress to a low-dimensional latent representation; cache only c
    3. k = W_up_k @ c # project back up during computation
    4. v = W_up_v @ c
    5. score = softmax(q @ k.T / sqrt(d))
    6. out = score @ v

    The practical gains show up in three places: lower memory usage for long contexts, higher concurrency within a batch, and friendlier cache reuse across layers and across requests. The cost is the loss of expressive power from compression, which the model must adapt to during training rather than bolting on at inference time.

    3. Sparse Attention: From “Attend to Everything” to “Attend on Demand”

    Adding Dynamic Sparse Attention (DSA) on top of latent compression is a natural next step. The logic is to first run a lightweight relevance scoring pass, select the few key positions most relevant to the current query, and then compute exact attention only over that subset. This reduces complexity from something quadratic in sequence length to something proportional to the number of selected positions.

    Three implementation points matter:

    1. The selector must be cheap enough, otherwise the compute saved is consumed by selection overhead.
    2. Training and inference must stay consistent, avoiding the distribution drift caused by “full attention in training, sparse attention in inference.”
    3. A small number of global or local window channels should be preserved so that long-range dependencies are not cut off entirely.

    The benefits are clearest in long-document question answering, repository-level code understanding, and multi-turn long conversations. In short-input, high-concurrency scenarios, the gains are diluted by routing and scheduling overhead, so this needs to be measured rather than assumed.

    4. Multi-Token Prediction: Denser Training Signals and Speculative Decoding

    Multi-Token Prediction (MTP) delivers value on two levels. During training, having the model predict several future tokens in a single forward pass provides a denser supervision signal at every position, improving sample efficiency and representation quality. During inference, the extra prediction heads can act as a draft model, working with verification-based decoding (speculative decoding) to verify multiple candidates at once, reducing latency while keeping the output distribution unchanged.

    Pseudocode sketch:

    1. # Speculative decoding: the draft proposes, the main model verifies
    2. draft = mtp_head.propose(ctx, k=4)
    3. probs = main_model.verify(ctx, draft)
    4. accepted = accept_prefix(probs, draft) # accept only tokens that match the distribution

    Note that the speedup depends on the acceptance rate, which correlates strongly with task entropy: code completion and structured output have high acceptance rates, while open-ended creative tasks have lower ones. MTP is therefore better treated as a switchable latency optimization rather than something enabled by default everywhere.

    5. Optimizers and Training Stability: New Variables from Low Precision

    In large-scale training, optimizer states (first and second moments) often occupy as much memory as the weights, sometimes more. Partially lowering the precision of the optimizer update and grouping parameters (for example, using different update strategies for matrix-shaped and vector-shaped parameters) can significantly cut memory and communication overhead.

    Low precision, however, introduces new sources of instability that require supporting measures:

    • Loss scale drift: use dynamic range management so updates are not drowned out by noise.
    • Outliers in gradients and activations: clip or rescale abnormal channels.
    • Uneven routing load: expert capacity factors and load-balancing loss need continuous monitoring.
    • Degradation of sparse attention selection: monitor selection and coverage rates to prevent the model from attending to only a few positions.

    A practical stability dashboard should include at least: gradient norm percentiles, expert load entropy, routing drop rate, attention selection rate, and the number of loss spikes. Without these metrics, problems in very large training runs often surface only hours or even days later, when rollback costs are extremely high.

    6. Evaluation: Why a Single Leaderboard Is Not Enough for Model Selection

    Composite intelligence index evaluations compress multidisciplinary capability into a single score, which is convenient for horizontal comparison but says nothing about business fit. A more reliable approach is three-layer evaluation:

    1. General capability layer: benchmarks for reasoning, knowledge, math, and code to confirm the baseline.
    2. Scenario capability layer: a small but high-fidelity evaluation set built from your own enterprise corpus, covering long documents, structured extraction, tool calling, and so on.
    3. Engineering capability layer: first-token latency, cost per token, concurrency ceiling, long-context degradation curve, and failure retry rate.

    It is worth stressing that a capability gap still exists between open-source models and the top closed-source models, but the gap has narrowed markedly, and for most routine tasks open-source options are already a viable substitute. The selection decision should come from scenario evaluation plus cost accounting, not from leaderboard rank.

    7. Deployment and Cost: Translating Architecture Features into a Resource Ledger

    The core of the deployment stage is converting architecture parameters into resource requirements:

    • Weight memory ≈ total parameters × bytes per parameter (accounting for compression from quantization).
    • KV cache ≈ layers × cache dimension × sequence length × concurrency × bytes; sparse and low-rank compression can cut this term significantly.
    • Expert routing brings bandwidth and scheduling pressure, requiring high-speed interconnect and sensible parallel partitioning (combinations of tensor, pipeline, and expert parallelism).
    • Elastic scaling should be driven by two metrics, queue length and first-token latency, rather than CPU utilization alone.

    For cloud deployment, you can combine a container platform to host inference services, object storage for models and datasets, a message queue to smooth request spikes, and logging plus monitoring and alerting to close the observability loop. Baidu AI Cloud offers a fairly complete combination of these general capabilities, which lets teams focus their effort on the model and the scenario itself.

    8. Deployment Checklist

    • Set a dual budget for total and activated parameters, accounting for memory and compute separately.
    • For long-context scenarios, validate the actual degradation curve of attention compression and sparse strategies first.
    • Treat multi-token prediction as a switchable latency optimization, with the enabled scope decided by task entropy.
    • Build a training stability dashboard covering gradients, routing, and attention selection.
    • Adopt the three-layer evaluation system and make the final decision with your own scenario data.
    • Base the cost model primarily on first-token latency and cost per token, paired with an elastic scaling strategy.

    Overall, the value of the new generation of open-source models lies not in any single parameter but in whether the whole combination — large capacity, low activation, sparse attention, dense training signals, and low-precision optimization — delivers a better cost-performance curve for your business. Understanding the role and the cost of each design is what makes reliable trade-offs possible in a real system.