Scaling Law and MoE in Practice: How Open-Source Large Models Evolve
This article examines the engineering evolution of an open-source large model series through four connected layers: Scaling Law–based compute and data allocation, fine-grained Mixture-of-Experts architecture, low-rank KV-cache compression, and efficiency techniques such as mixed-precision training, load balancing, and multi-token prediction. It explains the trade-offs behind each design and highlights practical lessons for building, evaluating, and deploying large language models under limited compute budgets.
1. Why Understanding Model Evolution Matters More Than Studying a Single Version
Large language models are not designed as one-time, finished products. They evolve through continuous iteration across data, architecture, and training strategy. Looking only at the final form of a particular version makes it difficult to distinguish core innovations from transitional engineering solutions.
This article traces the key developments in the open-source model series across four layers:
- Pretraining: Using Scaling Laws to guide the allocation of compute and data;
- Model architecture: Using fine-grained MoE to increase parameter capacity without proportionally increasing inference cost;
- Attention mechanisms: Compressing the KV cache to reduce the cost of long-context inference;
- Training and inference strategies: Improving efficiency through mixed-precision training, load-balancing optimization, and multi-token prediction.
These layers are closely connected and address a common question: how can a model achieve stronger capabilities and lower serving costs under a limited compute budget?
2. How to Apply Scaling Laws Correctly: Prioritize Data Quality
Early discussions of Scaling Laws often reduced the idea to a simple rule: larger models and more data generally produce better results. The first technical report in this model series revisited that conclusion and emphasized a critical condition:
Scaling Laws are effective, but they depend on high-quality data.
Before launching large-scale training, the team first used smaller experiments to fit Scaling Law curves and determine the optimal balance between model size and data volume under a given compute budget. The results showed that when data quality is sufficiently high, the same amount of compute should be used to increase model size first, rather than continuously adding more training data.
This decision has several practical implications:
- Better predictability before training: Smaller-scale experiments can verify whether the loss curve behaves as expected before major resources are committed.
- Data engineering comes first: More effort should be invested in cleaning, deduplication, and curriculum-style data mixing instead of blindly expanding the corpus.
- A foundation for later versions: This methodology was carried forward into subsequent versions and became part of the infrastructure for the entire model series.
# Scaling Law workflow (pseudocode)1. Collect and clean candidate corpora, then build data pools by quality level2. Fit loss = f(N_params, D_tokens, C_compute) on small- and medium-scale models3. Given a compute budget C, solve for the optimal (N, D) combination4. Start large-scale pretraining with the selected hyperparameters5. Monitor training against the predicted curve to detect deviations
3. The Core MoE Challenge: Larger Experts Can Mix More Knowledge
Mixture-of-Experts (MoE) replaces the feed-forward network (FFN) in a Transformer. Its basic idea is to make the total parameter count very large while activating only a subset of parameters for each token. This allows the model to expand its capacity while keeping inference compute roughly stable.
Traditional MoE designs often use a small number of large experts. For example, with eight experts, each token may activate the top two. This approach creates two problems:
- Knowledge becomes mixed within each expert: Because each expert contains many parameters, it may need to learn multiple types of knowledge, reducing specialization.
- Experts may become redundant: Different experts can learn the same general knowledge, lowering overall parameter utilization.
4. Fine-Grained and Shared Experts: Key MoE Improvements
To address these issues, the model series introduced two complementary design choices.
1. Splitting Experts into Fine-Grained Units
Instead of using a small number of large experts, the design divides them into a larger number of smaller experts and increases the number of experts selected by the top-K router. Conceptually, the design changes from “select two of eight large experts” to “select more experts from a larger pool of smaller experts.”
This provides several benefits:
- Each expert has fewer parameters and can specialize more easily;
- Tokens can be combined with experts in more diverse ways, improving expressive capacity;
- The failure or underutilization of an individual expert has less impact on the overall model.
2. Adding Shared Experts
General knowledge, such as common syntax and basic factual patterns, is placed into one or more shared experts. Every token passes through the shared experts, while routed experts focus on more specialized knowledge.
This design can:
- Reduce redundancy between routed experts;
- Allow selected experts to focus on domain-specific and fine-grained knowledge instead of repeatedly learning common information.
# Simplified fine-grained MoE feed-forward layerclass FineGrainedMoE(nn.Module):def __init__(self, d_model, n_shared, n_routed, top_k):self.shared = [FFN(d_model) for _ in range(n_shared)]self.routed = [FFN(d_model) for _ in range(n_routed)]self.gate = Router(d_model, n_routed)self.top_k = top_kdef forward(self, x):# Every token passes through the shared expertsout = sum(expert(x) for expert in self.shared)# Select the top_k fine-grained experts according to routing scoresweights, ids = self.gate.topk(x, self.top_k)for w, i in zip(weights, ids):out = out + w * self.routed[i](x)return out
3. The Evolution of Load Balancing
Another challenge in MoE training is routing collapse: too many tokens are sent to a small number of experts, leaving other experts undertrained. Early implementations commonly used an auxiliary loss to force a more balanced distribution. However, this auxiliary loss can conflict with the primary training objective.
Later versions moved toward auxiliary-loss-free load balancing. Instead of adding another loss term to the optimization target, the router dynamically adjusts each expert’s routing bias. This balances the workload without interfering with the main gradient path, improving training stability and model quality.
5. Attention-Side Improvements: KV-Cache Compression for Efficient Long Contexts
MoE reduces the cost of the FFN component, but standard multi-head attention (MHA) can still create a large KV cache during long-context inference. Each attention head stores independent keys and values for historical tokens, so memory usage grows linearly with sequence length and can become a major inference bottleneck.
The model series addresses this issue through low-rank KV compression:
- Project K and V into a low-rank latent space, and cache the compressed latent vectors instead of complete multi-head K/V representations;
- During decoding, use an up-projection to reconstruct the keys and values required by each attention head;
- Fuse shared-prefix computations during attention to avoid repeated work.
This approach provides several benefits:
- A substantially smaller KV cache, reducing memory pressure during long-context inference;
- Lower inference cost, making large-parameter models easier to serve on limited hardware;
- Preserved multi-head attention capability, because compression is applied during projection rather than to the final attention output.
Combined with MoE, this design makes it possible to achieve all three goals at once: a large total parameter count, a moderate number of active parameters, and manageable memory usage.
6. Further Improvements to Training and Inference Efficiency
Beyond architectural changes, the model series continued to improve efficiency through engineering techniques:
- Mixed-precision training: Use lower-precision formats for matrix multiplication while retaining higher-precision accumulation and keeping critical parameters at higher precision. This reduces memory and bandwidth requirements without sacrificing training stability.
- Multi-token prediction (MTP): During training, predict multiple future tokens at the same time. This provides natural support for speculative decoding during inference and can also improve representation learning.
- Exploration of more aggressive formats such as FP8: Manage precision separately for weights, activations, and gradients to further reduce communication and storage costs.
Together with MoE and KV compression, these techniques form a complete cycle for reducing both training and inference costs.
7. Practical Lessons for Developers
Several transferable lessons can be extracted from this evolution path:
- Run Scaling experiments before making large investments: Using small-scale experiments to calibrate the relationship between model size, data, and compute is essential for controlling cost and risk.
- Data quality determines the upper bound of Scaling: Cleaning, deduplication, and data mixing often provide greater value than simply adding more data.
- Separate capacity from compute: MoE shows that high model capacity and low inference cost can coexist, provided that expert specialization and load balancing are properly addressed.
- Optimization bottlenecks shift over time: Once MoE reduces the cost of the FFN, the KV cache can become the new bottleneck. This leads naturally to attention-side compression. Optimization should therefore be based on the entire inference pipeline.
- Co-design training objectives and inference strategies: Multi-token prediction supports both training and inference acceleration, avoiding a situation where optimization is considered only after training has finished.
8. Conclusion
The evolution of this open-source model series is fundamentally a technology path centered on efficiency. High-quality data provides the foundation, while Scaling Laws guide model-size decisions. Fine-grained MoE and shared experts expand parameter capacity while controlling the number of active parameters. Low-rank KV compression addresses the memory bottleneck of long-context inference, and load balancing, mixed precision, and multi-token prediction further reduce costs.
Understanding the motivations and trade-offs behind these designs is more valuable than memorizing the configuration of any single model version. They reveal general principles for balancing capability, compute, memory, and serving cost in large-model development, and provide a practical framework for building or selecting such systems.
