MoE and Sparse Attention: Inside Open-Source LLM Architectures

    This article explains how to evaluate open-source LLM architecture claims by separating total and active parameters in MoE models, estimating KV cache costs, and assessing multi-token prediction and dynamic sparse attention. It also outlines data quality checks and a deployment checklist so teams can verify performance and risks on their own workloads.

    1. Start with the Data Source

    Technical reports for open-source LLMs often present evaluation scores, parameter scale, and architecture details together. When reading this material, the first step is to confirm where the data comes from. The source analysis reports a set of figures: about 744 billion total parameters, about 40 billion activated per inference, 256 experts, 80 layers, and about 28.5 trillion training tokens. These figures have not been verified. Before formal citation, return to the official technical report and confirm the model name, release date, and statistical scope.

    Evaluation scores also depend on definitions. The same composite index may rank models differently with a different test set or evaluation version. When judging model strength, observe knowledge, reasoning, code, math, instruction following, and long context together, and record the version and sample size for each test.

    2. Mixture-of-Experts: Calculate Total and Active Parameters Separately

    A mixture-of-experts (MoE) model splits the feed-forward network into multiple experts, and a router selects a small number of experts for each token to participate in computation. The model’s knowledge capacity is determined by total parameters, while per-inference cost is mainly determined by activated parameters.

    When evaluating an MoE model, distinguish the following metrics:

    Metric Meaning Impact on cost
    Total parameters Sum of parameters in all experts and shared layers Determines weight storage footprint
    Activated parameters Parameters actually involved in computation per token Determines per-token compute
    Number of experts and experts selected per token Size of the expert pool and number of experts chosen by routing Affects routing complexity and communication volume
    Layers Network depth Affects serial computation latency

    MoE has three main engineering challenges.

    The first is load balancing. If many tokens concentrate on a few experts, the devices holding those experts become overloaded while other devices sit idle. You can count the proportion of tokens received by each expert and observe the ratio of the maximum to the average. A persistently high ratio indicates routing imbalance.

    The second is cross-device communication. Experts are distributed across multiple GPUs, and tokens routed to remote experts require cross-device transfer. Communication scheduling for expert parallelism directly affects throughput.

    The third is training stability. An auxiliary loss weight that is too large may suppress the language modeling objective, while a weight that is too small may lead to expert collapse, where a few experts handle most tasks.

    3. Low-Rank Latent Attention: Compressing the KV Cache

    During inference, the model must store the keys and values of historical tokens, known as the KV Cache. Under standard multi-head attention, cache size can be roughly estimated as follows:

    KV Cache bytes ≈ 2 × layers × KV heads × head dimension × sequence length × batch size × bytes per element

    Longer context and higher concurrency increase cache footprint. Low-rank latent attention first compresses keys and values into a low-dimensional latent space. The cache stores only the compressed representation and restores it during computation. Cache footprint therefore falls, and the same GPU can serve more requests or longer context. The cost is extra projection computation, so measure actual latency rather than looking only at memory.

    The source analysis notes that the benefit of the attention structure is related to the optimizer. When researchers trained the full attention projection matrices, they found that a certain global orthogonalization optimization method was not necessarily better than grouped-query attention. The team then tried splitting the matrix by attention head and optimizing head by head. The intuitive meaning is to reduce interference between different heads. However, the specific applicability, ablation results, and optimizer name should be based on the original report.

    A practical judgment follows: architecture changes should be evaluated together with training methods. Theoretical memory savings alone are not enough to show the final effect.

    4. Multi-Token Prediction: Training Signal and Inference Gains

    Traditional autoregressive models predict only the next token at each step. Multi-token prediction lets the model learn multiple subsequent tokens at the same position. The main output still handles the next token, while auxiliary outputs handle farther positions.

    The benefit appears first on the training side. Each position provides more supervision signals, making it easier for the model to learn code structure, phrase combinations, and the continuous relationships between reasoning steps. Inference-side gains depend on the inference mechanism. Only with speculative decoding or similar parallel verification methods can auxiliary-head predictions translate into actual speedup. Without such support, training gains do not automatically become faster generation.

    The risks are also clear. The farther the prediction target, the more uncertain it becomes, and the auxiliary loss may conflict with the main objective. Validation can compare three groups: a baseline using only the main objective, a version with multi-token auxiliary loss, and a version with an adjusted auxiliary loss weight. Metrics should include basic language modeling loss, code and math benchmark performance, and inference acceptance rate.

    5. Dynamic Sparse Attention: Selecting Historical Tokens

    In standard attention, each token computes relevance against all historical positions, and computation grows approximately quadratically with sequence length. Sparse attention computes only a subset of positions. Common selection methods include:

    • Local window: only the most recent tokens are used; this is simple but distant information may be lost.
    • Fixed interval: historical positions are sampled at a fixed stride; coverage is broad but content-independent.
    • Global tokens: a small number of summary positions are retained and accessible to all tokens.
    • Dynamic retrieval: positions are scored by content, and the most relevant history blocks are selected.

    The advantage of dynamic methods is that selection is content-related, which suits long documents with complex structure. The cost is that the selection step itself requires computation, and a wrong selection can miss critical information. Missed detection usually appears as factual omissions, citation errors, or interrupted multi-hop reasoning.

    When evaluating sparse attention, design tests such as:

    • Needle-in-a-haystack: insert a key fact at different lengths and depths, and measure recall.
    • Cross-paragraph QA: the answer depends on two distant paragraphs; measure whether both pieces of evidence are used.
    • Multi-hop reasoning: an intermediate conclusion depends on the previous retrieval result; observe which hop fails.
    • Comparison with dense attention: compare accuracy gaps on the same samples and record memory and latency.

    Set an acceptable accuracy drop and memory-saving target before testing, then decide whether to adopt the method. Explaining results after the fact has lower credibility.

    6. Training Data: Quality and Mix Matter More Than Total Volume

    The source analysis mentions that model training uses about 28.5 trillion tokens, with pretraining and mid-training serving different roles. Pretraining handles language, knowledge, code, and basic reasoning. Mid-training reinforces capabilities such as long context, math, tool calling, and instruction following.

    Common data processing steps include:

    1. Exact and near deduplication to reduce memorization caused by repeated samples.
    2. Quality filtering to remove low-quality web pages and templated text.
    3. Evaluation-set contamination detection to check whether training corpora overlap with test questions, commonly using n-gram matching and similarity retrieval.
    4. Mix adjustment to allocate proportions by language, domain, and task type, with small-scale experiments to validate the effect.

    These steps do not have a universal pass line. Teams need to judge them against their own data and target tasks.

    7. Pre-Deployment Checklist

    For enterprise selection, break metrics into measurable items:

    • First-token latency: measure with fixed input length and concurrency; record P50 and P95.
    • Sustained generation speed: count output tokens per second, distinguishing single-request and high-concurrency scenarios.
    • Long-context memory growth: test along an input-length gradient and compare against KV Cache estimates.
    • Expert load: record the token share per expert and monitor the max-to-average ratio.
    • Quantization loss: compare accuracy before and after quantization on the same evaluation set.
    • Task accuracy: build internal test sets for business scenarios instead of directly reusing public leaderboards.

    Cloud deployment also needs container orchestration, elastic scaling, request queuing, cache management, log auditing, and failure recovery. The model is only one part of the service chain, and production experience often depends on how these parts work together.

    8. Selection Conclusions and Risk Boundaries

    Selection can reference three conclusions:

    1. When memory and concurrency become bottlenecks, prioritize KV Cache compression methods and use measured throughput as the basis.
    2. When long-document tasks account for a high share, sparse attention is worth validating, but it must pass miss-detection tests.
    3. For in-house training, architecture changes should be ablated together with the optimizer and data mix.

    There are also three risk boundaries: public numbers need source verification; evaluation scores represent performance only on a specific test set; and any conclusion about speedup or memory savings should be re-measured on your own workload.

    For developers, understanding how MoE, KV Cache, multi-token prediction, and sparse attention work supports long-term judgment better than memorizing a single model score.