Efficient Training and Open-Source Practices for Large-Scale Mixture of Experts (MoE) Models

    This article explores the engineering methodologies for training large-scale Mixture of Experts (MoE) language models, using a representative open-source case as a reference. It covers architectural design, large-scale data organization, multi-dimensional parallel training, cost-efficiency trade-offs, capability evaluation, and deployment optimization. The case study highlights a model with 671 billion total parameters and 37 billion activated parameters, trained on 14.8 trillion tokens, achieving competitive performance against closed-source models while maintaining a controllable R&D budget.

    The core value of large-scale Mixture of Experts (MoE) language models lies in expanding total model capacity through sparse activation while keeping the computation per token within an acceptable range. A representative open-source case demonstrates this: with approximately 671 billion total parameters, 37 billion activated parameters per token, and pre-training on roughly 14.8 trillion tokens, the training utilized 2048 high-performance accelerators. The total training consumed about 2.788 million GPU hours (with 2.664 million for pre-training), costing just over five million USD in R&D. Compared to the previous baseline, the generation speed increased by approximately 3x, achieving performance close to mainstream closed-source models across multiple benchmarks, with particularly outstanding results in math and Chinese tasks. Rather than promoting a specific product, this article uses this case as a reference to discuss general engineering methods for large-scale MoE models, spanning architecture design, data organization, parallel training, and open-source deployment.

    1. Background and Design Objectives

    To improve capabilities in traditional dense models, developers typically increase layers, width, or training tokens. However, this parameter growth proportionally increases per-token computation and inference costs. The MoE architecture decouples model capacity from computation through a design of “large total parameters, small activated parameters”: each token passes through only a few expert networks, and a router selects the experts. This enhances model expressiveness under limited compute but introduces new challenges such as routing stability, expert load balancing, cross-device communication, and memory consumption.

    Therefore, the design goals for large-scale MoE training generally include four aspects: first, maximizing effective parameter capacity within a given compute budget; second, ensuring training throughput and accelerator utilization; third, controlling communication, memory, and checkpointing overhead; fourth, making inference deployment operationally viable after open-sourcing. The “671B total parameters, 37B activated parameters” combination in the case study is essentially a balance between capacity and efficiency: total parameters determine the learnable knowledge capacity, while activated parameters determine the forward computation scale per token, jointly affecting training costs and inference latency.

    2. MoE Architecture and Sparse Activation Mechanism

    An MoE layer typically consists of multiple expert networks and a router. For an input token, the router outputs scores for each expert, selects the top-k experts, and performs weighted computation. The schematic pseudocode is as follows:

    1. # Pseudocode: MoE forward pass and load balancing loss
    2. def moe_forward(x, experts, router, top_k=2):
    3. logits = router(x)
    4. probs = softmax(logits)
    5. topk_prob, topk_idx = topk(probs, k=top_k)
    6. topk_prob = topk_prob / sum(topk_prob)
    7. y = 0
    8. for p, idx in zip(topk_prob, topk_idx):
    9. y += p * experts[idx](x)
    10. aux_loss = load_balance_loss(probs, topk_idx)
    11. return y, aux_loss

    This pseudocode illustrates three key aspects of MoE: routing scoring, top-k selection, and weighted aggregation. In engineering, capacity factors, drop strategies, and load balancing auxiliary losses must be added to prevent a few experts from being over-selected while others remain idle. Severe expert load imbalance can cause some accelerators to wait, leading to communication congestion and reduced effective throughput. Therefore, large-scale MoE training often requires simultaneous optimization of routing algorithms and parallel layouts to ensure expert computation is distributed as evenly as possible.

    3. Large-Scale Pre-training Data Organization

    A pre-training scale of 14.8 trillion tokens means that data quality, deduplication, proportioning, and training curriculum are more important than simply accumulating volume. Common practices include: multi-source corpus cleaning, deduplication, and quality filtering; sampling and proportioning by language, domain, and task type; targeted enhancement for critical capabilities like math, code, and Chinese; and adjusting data distribution in the mid-to-late stages of training to increase exposure of high-value samples. For models excelling in Chinese and math, more detailed design is required in corpus proportioning, tokenizer coverage, format specifications, and multi-step reasoning data.

    Additionally, large-scale training requires a reproducible data pipeline: sample deduplication must be stable, shard ordering must be traceable, and the system must recover based on global steps after interruptions. The data pipeline should also match training throughput to prevent accelerators from idling due to insufficient data loading. For open-source models, the transparency of data proportions and cleaning rules also affects external reproduction and secondary development efficiency.

    4. Thousand-GPU Scale Parallel Training System

    Training on a scale of 2048 high-performance accelerators typically requires combining multiple parallel strategies: data parallelism to scale the global batch size; tensor parallelism to split single-layer matrix computations; pipeline parallelism to partition model layers; and expert parallelism to distribute different experts across devices. The key challenge in MoE models is the all-to-all communication introduced by expert parallelism: tokens must be routed to the devices hosting the target experts, computed, and then aggregated back. If communication and computation do not overlap, throughput will drop significantly.

    Engineering optimizations usually include: overlapping communication and computation pipelines; dynamically adjusting capacity factors based on expert load; using mixed-precision training and activation recomputation to reduce memory; sharding checkpoints for saving and asynchronous uploading; and implementing fast restarts and checkpoint resumption for failed tasks. Estimating based on the approximately 2.788 million total GPU hours and 2.664 million pre-training GPU hours, even a few percentage points of improvement in system utilization can result in substantial cost differences. Thus, the competitiveness of large-scale MoE stems not only from model architecture but also from the stability and scheduling efficiency of the training system.

    5. Cost, Efficiency, and Stability Trade-offs

    The R&D cost of just over five million USD in the case study indicates that under specific hardware scales and engineering optimizations, large-scale MoE training can enter a relatively controllable budget range. However, cost control should not look solely at single-card pricing; it must also consider effective throughput, fault recovery, data loading, communication overhead, and evaluation iteration costs. The approximately 3x improvement in generation speed typically comes from a combination of structural sparsification, inference batching, caching, and parallel decoding; on the training side, more attention is given to MFU (Model FLOPs Utilization), communication ratio, and checkpoint overhead.

    Regarding stability, full-link monitoring is necessary: loss curves, gradient norms, expert load distribution, communication latency, memory usage, data loading delays, and hardware error rates. For MoE, it is especially crucial to monitor expert collapse and routing drift to prevent capability degradation in the later stages of training. Checkpointing strategies should balance frequency and storage costs, supporting layer-by-layer and expert-by-expert shard recovery to reduce restart costs.

    6. Capability Evaluation and Open-Source Value

    Achieving performance close to mainstream closed-source models across multiple benchmarks indicates that large-scale MoE is highly competitive in general capabilities; the outstanding performance in math and Chinese tasks suggests that data proportioning and training curricula significantly impact vertical capabilities. Evaluation should not only look at total scores but also cover reasoning, long-context, code, multilingual, factual consistency, and safety. For open-source models, external developers are more concerned with weight availability, inference efficiency, fine-tuning costs, and deployment barriers.

    The value of open-sourcing is primarily reflected in three aspects: first, lowering the barrier for research and secondary development; second, promoting public accumulation of inference optimization, evaluation methods, and safety governance; third, enabling enterprises to build private deployment solutions on general infrastructure such as object storage, container platforms, logging services, and monitoring/alerting. The specific scope of openness should be subject to release notes; it should not be assumed that all training details are fully disclosed.

    7. Deployment and Inference Optimization Recommendations

    When deploying MoE models, memory capacity and expert routing overhead are the main bottlenecks. Common approaches include: partitioning weights via expert parallelism; implementing tiered caching or offloading for low-traffic experts; using dynamic batching to improve throughput; controlling KV cache for long-context scenarios; and selecting top-k and capacity factors based on business latency targets. If the business primarily involves Chinese or math tasks, routing and sampling parameters can be calibrated on evaluation sets, but not at the expense of general safety.

    8. Risks and Boundaries

    Large-scale MoE still faces risks such as routing instability, expert load imbalance, insufficient long-tail capabilities, limited evaluation coverage, and safety compliance. Open-sourcing does not equate to ready-for-production use; enterprises still need to conduct evaluations, fine-tuning, red-teaming, and monitoring based on their business data. Cost data should also be understood as engineering results under specific conditions and cannot be simply extrapolated as a universal price for all scenarios.

    Overall, efficient training of large-scale Mixture of Experts models is a systems engineering effort: architecture determines the capacity and computation boundaries, data determines the capability ceiling, parallel and communication optimization determines training efficiency, and evaluation and deployment determine final usability. Trading sparse activation for parameter capacity and engineering optimization for controllable costs is the most reusable methodology in the open-source practices of such models.