Understanding Mixture of Experts (MoE) Architecture: Fine-Grained Expert Segmentation and Shared Expert Isolation

    This article breaks down the core engineering principles behind Mixture of Experts (MoE) architecture, focusing on fine-grained expert segmentation and shared expert isolation. It explains how MoE decouples total parameter count from per-token computation, the trade-offs of sparse activation, and key practices for deployment such as load balancing auxiliary loss, routing stability, and parallelism. Readers will gain a clear understanding of how to evaluate MoE versus dense models based on activation parameters, memory budget, routing balance, and latency targets.

    1. Why Mixture of Experts?

    A large model’s capability ceiling is closely tied to its parameter count, but dense architectures face an unavoidable tension: every increase in parameter scale raises training and inference compute almost in lockstep. The value of Mixture of Experts (MoE) is that it decouples “total parameters” from “per-token compute”—a model can hold a very large parameter pool while each token passes through only a small fraction of it.

    One class of open-source MoE architectures (released in early 2024, supporting both Chinese and English, and free for commercial use) exemplifies this idea: it uses fine-grained expert segmentation and shared expert isolation, trading sparse computation for more economical training costs. This approach has been adopted by later models across a range of parameter scales (such as 2B, 16B, 145B, and up to 671B total parameters with roughly 37B activated per token) and extended to cross-modal scenarios like vision-language. This article strips away specific product attributes and discusses only the general engineering principles behind it.

    2. Breaking Down the Two Core Strategies

    2.1 Fine-Grained Expert Segmentation

    Traditional MoE uses a small number of experts, each of which is quite “wide.” The fine-grained approach splits each expert into smaller pieces and increases their number—for example, splitting one large expert into four small ones. The benefits are threefold:

    • Larger combination space: Top-K routing selects among more small experts, and the number of combinations grows combinatorially, giving the model stronger expressive power.
    • Smoother routing: Each expert carries less knowledge, so the damage caused by a misselection is smaller.
    • More thorough specialization: Small experts more easily differentiate into clear functional boundaries.

    The cost is a higher frequency of routing decisions and finer-grained communication, making the approach more sensitive to parallelism strategy.

    2.2 Shared Expert Isolation

    Fine-grained segmentation brings a side effect: if all knowledge is computed only when “selected,” then the general capabilities every token needs (grammar, common sense, language structure) get repeatedly relearned, wasting capacity. Shared expert isolation addresses this by carving out a group of always-on shared experts dedicated to general knowledge, while the rest are routed experts that carry separable specialized knowledge.

    A formal expression can be written as:

    1. # Illustration: fusing shared experts and routed experts
    2. def moe_layer(x, shared_experts, routed_experts, router, top_k=2):
    3. h_shared = sum(expert(x) for expert in shared_experts) # always active
    4. logits = router(x) # [batch, n_routed]
    5. weights, idx = topk_softmax(logits, k=top_k)
    6. h_routed = 0
    7. for w, i in zip(weights, idx):
    8. h_routed = h_routed + w * routed_experts[i](x)
    9. return h_shared + h_routed

    The point of isolation is this: once the shared part absorbs common knowledge, the routed parameters no longer each need to “relearn the same thing,” which increases effective capacity under the same total parameter count.

    3. Benefits and Costs of Sparse Activation

    The benefits are clear: total parameters determine knowledge capacity, while activated parameters determine compute cost, and the two can be designed independently. The same architecture can be trimmed to different scales such as 2B, 16B, or 145B, and on the inference side, throughput can be gained by lowering the activation volume.

    The costs must also be faced squarely:

    • Memory bottleneck shift: All expert weights must stay resident, so memory usage is determined by total parameters rather than activated parameters.
    • Load imbalance: A few popular experts get overused while the rest sit nearly idle, lowering actual compute utilization.
    • Routing jitter: Unstable routing in early training can cause experts to fail to differentiate.
    • Communication overhead: Under expert parallelism, tokens must be rearranged and transferred between devices.

    4. Key Practices for Engineering Deployment

    1) Load balancing auxiliary loss. Add a balancing term to the routing loss that penalizes skewed distribution, pushing the selection probability of each expert toward uniformity.

    1. # Illustration: load balancing auxiliary loss
    2. def aux_loss(prob_matrix, topk_index, n_experts):
    3. # prob_matrix: routing probabilities; topk_index: selected expert IDs
    4. f = one_hot(topk_index, n_experts).mean(dim=0) # actual assignment ratio
    5. p = prob_matrix.mean(dim=0) # average routing probability
    6. return n_experts * (f * p).sum()

    2) Routing stability design. Noise injection can smooth early decisions, or a capacity factor can cap how much a single expert carries, with overflow tokens passed through a residual direct connection to avoid information loss.

    3) Parallelism and deployment. Expert parallelism needs to be combined with tensor parallelism and pipeline parallelism; on the inference side, high-frequency experts can be cached and co-located, combined with container platforms for elastic scaling and with logging and monitoring/alerting services to observe expert hit distribution.

    4) Trade-offs with dense models. If the task domain is narrow and latency-sensitive, a small dense model is more cost-effective; if you need large capacity, multi-task, multilingual, and cross-modal expansion, MoE offers better cost-performance.

    From early fine-grained segmentation plus shared isolation, to later combining larger total parameters with lower activation volume, to integrating reinforcement learning results with the inference layer, and to the dual-version strategy of previewed new series (one favoring capability ceiling, one favoring response efficiency), the main thread has stayed unchanged: use sparsification to decouple capacity from compute, and use shared structure to keep general capabilities from being diluted. The takeaway for developers is that when choosing a model, don’t look only at total parameters—evaluate activation parameters, memory budget, routing balance, and business latency targets together.