Understanding Sparse Mixture-of-Experts LLM Architecture: Total vs. Activated Parameters

    This article breaks down how sparse Mixture-of-Experts (MoE) architectures separate total parameter count from activated parameters, and why that distinction drives capacity planning. It explains the routing mechanism, the asymmetric memory and compute costs, key training and inference engineering considerations, and a practical workflow for sizing deployments. Readers will learn to evaluate memory, compute, and interconnect needs together instead of treating parameter count as a compute metric.

    1. From “Parameter Scale” to “Activation Scale”: A Necessary Clarification

    When discussing ultra-large language models, the most common misreading is equating “total parameter count” with “compute per pass.” Take a typical sparse Mixture-of-Experts architecture in the industry: the model has roughly 671 billion (671B) total parameters, yet processing each token activates only about 37 billion parameters. The two numbers differ by nearly 18x, and this ratio is not marketing language but a direct result of architectural design.

    Understanding this is the prerequisite for all subsequent capacity planning, cost estimation, and performance testing. It can be summarized in one sentence: total parameter count determines “knowledge capacity and memory footprint,” while activated parameter count determines “the compute and memory-access cost per token.”

    The difference can be expressed with illustrative pseudocode:

    1. # Dense model: every token passes through all parameters
    2. def dense_forward(token, all_params):
    3. return matmul(token, all_params) # compute ∝ total parameter count
    4. # Sparse MoE: route first, then compute only the selected experts
    5. def moe_forward(token, experts, router, top_k=2):
    6. scores = router(token) # gating scores, minimal overhead
    7. idx = topk(scores, k=top_k) # select k experts
    8. out = 0
    9. for i in idx:
    10. out += scores[i] * experts[i](token) # compute ∝ k × single-expert size
    11. return out

    2. How Sparse Mixture-of-Experts Works

    The core idea of sparse MoE is to replace a single wide, dense feed-forward layer with several smaller, independent “expert” subnetworks, then use a lightweight gating network (Router/Gate) to dynamically select a few experts for each token.

    The workflow breaks down into four steps:

    1. Scoring: The gating network computes each expert’s match score against the input hidden state and outputs a set of weights.
    2. Selection: A top-k strategy keeps the highest-scoring experts; the rest do not participate in the forward pass this time.
    3. Weighted aggregation: The selected experts’ outputs are summed with their gating weights, keeping the gradient path and numerical scale stable.
    4. Residual connection: The aggregated result is added to the outputs of other layers such as attention, preserving information flow through the deep network.

    The benefit of this design is direct: while the total parameter scale expands substantially and the model’s knowledge capacity increases significantly, the floating-point operations per token are kept close to the level of a small dense model. In other words, you trade memory for capacity, not compute for capacity.

    3. Asymmetric Memory and Compute Costs

    This is where engineering practice most easily goes wrong. MoE decouples “compute” from “memory,” and the two must be accounted for separately:

    • Memory side (estimated by total parameters): All expert weights must stay resident, because you cannot predict which expert the next token will route to. Roughly estimating 671B total parameters at half precision (2 bytes), the weights alone are about 1.34TB, not yet counting the KV cache, activations, and framework overhead.
    • Compute side (estimated by activated parameters): Only about 37B parameters participate in matrix operations per token, so the compute demand per request is significantly lower than a dense model of the same total scale.

    This leads to an important inference: the deployment bottleneck for MoE is usually memory capacity and inter-card interconnect bandwidth, not raw compute. In multi-card setups, experts are distributed across devices, and tokens must be routed to the target card. Communication volume rises with concurrency and top-k, which is the fundamental reason MoE clusters are more sensitive to high-speed interconnect.

    4. Key Engineering Points for Training and Inference

    During training, three things need close attention:

    • Load balancing: Gating tends toward “winner-take-all,” where a few experts are overused while others sit idle. The common industry practice is to add an auxiliary balancing loss and inject noise into the routing logits to encourage exploration.
    • Numerical stability: Gating weights need normalization and reasonable truncation to avoid weight explosion that causes gradient oscillation; in mixed-precision training, routing and normalization usually keep higher precision.
    • Capacity factor: A buffer capacity is set for each expert. Too small drops tokens; too large wastes memory, so it must be balanced between throughput and quality.

    During inference, the focus shifts to scheduling and resource matching:

    • Batching strategy: Tokens from different requests activate different experts, so requests should be aggregated along the expert dimension to improve matrix-operation efficiency.
    • Cache management: The KV cache grows linearly with context length; for long-context scenarios, account for the cache before the weights.
    • Elastic scaling: Since the bottleneck is memory and bandwidth, scaling evaluations should use “the number of expert shards each card can hold” as the unit, rather than looking at compute metrics alone.

    5. A Practical Capacity Evaluation Workflow

    It is recommended to run a quantitative evaluation in the following order, avoiding guesswork in选型:

    1. Define business metrics: context length, concurrency, first-token latency, and throughput targets.
    2. Estimate memory: weights (total parameters × bytes per precision) + KV cache + activations and framework reserve, usually leaving another 15%~25% headroom.
    3. Estimate compute: derive per-token compute from activated parameters, then work backward from the target throughput to the required compute.
    4. Evaluate interconnect: confirm whether multi-card/multi-node bandwidth can handle the extra communication from routing.
    5. Validate with load testing: run canary load tests with a real corpus distribution, and observe latency percentiles rather than averages.

    When deploying in the cloud, you can combine a container platform for orchestration and elastic scaling, object storage to hold model files, and logging and monitoring/alerting systems to track latency and memory levels; the general cloud product categories offered by Baidu AI Cloud can serve as the foundation for this kind of architecture.

    6. Summary of Common Misconceptions

    • Misconception 1: Treating total parameter count as a compute metric, leading to a severely overestimated hardware budget.
    • Misconception 2: Looking only at average latency while ignoring jitter in long-tail requests caused by uneven expert routing.
    • Misconception 3: Neglecting balancing strategies, so expert utilization polarizes after long-term operation.
    • Misconception 4: In long-context scenarios, counting only weights and not the KV cache, causing overflow immediately after launch.

    The value of the sparse Mixture-of-Experts architecture lies in trading a controllable activation scale for greater model capacity. What truly determines success is not the numbers on the parameter sheet, but whether you bring memory, bandwidth, and routing behavior into the same evaluation framework.