Key Design Considerations for Trillion-Parameter MoE Large Models

    This article covers three technical challenges in building trillion-parameter mixture-of-experts (MoE) models that handle visual multimodal input and million-token contexts. For each challenge, it describes a typical solution: a lower-bounded decay parameterization for linear attention, load balancing without auxiliary loss across hundreds of experts, and block-level attention residuals. It also covers the multi-stage context extension and agentic reinforcement learning post-training that support long-horizon capabilities, and it closes with engineering recommendations.

    1. Background: Three Challenges in Ultra-Large-Scale MoE Models

    In recent years, the mixture-of-experts (MoE) architecture has become the mainstream approach for overcoming the compute bottleneck of dense models. Its core idea is that a model can have a total parameter count in the trillions, while each token activates only a small subset of those parameters, on the order of hundreds of billions. This keeps computation costs manageable while greatly increasing model capacity. When a model must also support visual multimodal input and context lengths at the million-token level, three difficulties typically emerge in engineering:

    1. Efficiency of attention operators: Standard softmax attention has compute and memory costs that grow quadratically with sequence length. Linear attention reduces this complexity, but it introduces numerical stability and hardware utilization problems.
    2. Training stability with massive numbers of experts: When the number of routed experts reaches hundreds or even thousands, load imbalance, routing oscillation, and numerical anomalies in activation functions all significantly affect convergence.
    3. Long-range reasoning: Long document understanding, multi-step tool calling, and agent tasks require stable cross-layer information transfer and the ability to model long-range dependencies.

    The following sections break down typical technical solutions for each of these problems.

    2. Key Technique 1: Lower-Bounded Parameterization of Decay in Linear Attention

    2.1 The Core Problem

    Linear attention operators, such as Delta Rule-style gated linear attention, rely on a decay factor that accumulates over time. During chunk-wise (tile-based) parallel computation, the accumulated decay must be divided by or scaled by its reciprocal. The problem is that when the log value of the decay is unbounded (for example, with a negative-direction Softplus parameterization), its reciprocal can easily overflow or underflow under limited-precision formats such as BF16.

    This numerical risk has a chain of consequences. The diagonal blocks of the chunked matrix, which contain the pairwise position interactions, must follow a special computation path based on element-wise position pairs. This path cannot be reduced to a regular matrix multiplication, so the operator cannot fully use the high-throughput GEMM capability of Tensor Cores. Overall operator efficiency suffers as a result.

    2.2 Proposed Solution: Add a Lower Bound to the Decay

    The core change is very lightweight. The log-decay parameterization changes from an unbounded function to a scaled sigmoid with a lower bound, as shown below:

    1. # Pseudocode illustration
    2. g_min = -5.0
    3. log_decay = g_min * torch.sigmoid(raw_score) # Output is bounded within [-5, 0]

    Because the log-decay is confined to a bounded interval, the reciprocal scaling factor within any fixed-size tile (for example, 16 tokens) naturally falls within a numerically safe range. No runtime clamping or special branch handling is needed.

    2.3 Benefits

    • Hardware utilization: The diagonal and off-diagonal blocks both use the dense GEMM path. At the CUDA/CUTLASS implementation level, branching can be eliminated entirely, which significantly improves throughput.
    • Simpler positional encoding: Because the gated decay already handles distance-based attenuation, the model can drop explicit positional encoding (NoPE). This makes extrapolation to very long contexts more robust.
    • Minimal engineering change: The change touches only one parameterization formula. It is easy to reuse and offers strong cost-effectiveness for deploying linear attention.

    3. Key Technique 2: Large-Scale Load Balancing Without Auxiliary Loss

    3.1 Limitations of Conventional Approaches

    A common industry practice for MoE load balancing is to add an auxiliary load-balancing loss. This approach has an inherent conflict. The balancing loss competes with the primary task loss for gradients. The more experts there are and the stronger the constraint, the more the balancing term interferes with main-task quality. When the number of routed experts grows to hundreds, tuning the auxiliary loss becomes extremely sensitive.

    3.2 Quantile Balancing

    A more modern approach is quantile-based dynamic adjustment, which can be called Quantile Balancing. Instead of adding an extra loss term, the method tracks the load distribution of each expert in real time during training. Based on the quantile positions of the loads, it directly scales the routing scores. Overloaded experts have their scores lowered, and underused experts have their scores raised. In essence, this is an online feedback control system rather than loss-based optimization.

    Its advantages include:

    • No gradient interference: The main task gradient is not polluted by the balancing objective, so experts can specialize more fully.
    • Fast response: Load statistics update at every step, which allows quick adaptation to shifts in data distribution.
    • Good scalability: Balancing overhead scales approximately linearly with the number of experts, which suits extremely sparse configurations with close to a thousand experts.

    3.3 Co-design with Activation Functions

    In extremely sparse settings, some experts may receive insufficient training for long periods, and their gate values fluctuate widely. In practice, gating units are often combined with GLU-type activation functions (similar to the SiTU-GLU combination design). The gating mechanism smooths the numerical distribution of expert outputs, which further reduces training instability caused by routing jitter.

    4. Key Technique 3: Block-Level Attention Residuals and the Depth Representation Bottleneck

    4.1 Information Decay in Deep Transformers

    As model depth increases, gradients and information decay as they propagate through layers. The gains in expressive power from added depth gradually saturate. This is a common bottleneck in deep architectures.

    4.2 Block-Level Residual Sharing

    Attention Residuals pass the output of shallower attention modules forward to deeper layers in a controlled way, which enables cross-layer information reuse. Organizing the design into blocks, where residuals are shared across a group of layers, offers two additional benefits:

    • Memory and communication savings: Some intermediate activations can be reused. This reduces checkpointing and recomputation overhead and lowers communication pressure in large-scale parallel training.
    • Training stability: Deeper modules learn incremental information on top of shallower representations, so convergence is smoother.

    A simplified structure looks like this:

    1. x_l = Layer_l(x_{l-1}) + α · Attn(x_{l-k}) # α is a learnable or fixed weight

    5. Training Pipeline: Multi-Stage Context Extension and Agentic Post-Training

    5.1 Multi-Stage Length Curriculum

    Long-context capability is not achieved in a single training run. A common industry practice is to extend sequence length in stages, for example following a curriculum of 8K → 64K → 256K → 1M. After each stage extends the context, the model first adapts to the new length distribution before moving to the next stage. This prevents noisy gradients from long-sequence samples, introduced too early, from degrading short-text ability.

    5.2 Agentic Reinforcement Learning Post-Training

    After supervised fine-tuning (SFT), agentic reinforcement learning (RL) targeting long-horizon tasks is introduced. The model optimizes its policy through reward signals on tasks such as multi-step tool calling and long-document reasoning. This stage is especially important for long-context capability. It trains not only the ability to remember long inputs but also the ability to perform reliable intermediate reasoning and decision-making across long spans. It is also a key stage where current open-source models differentiate themselves on agent benchmarks.

    6. Engineering Recommendations

    For teams planning to build or reproduce a similar architecture, the following practical lessons apply:

    1. Validate operators first: Before finalizing the model, verify the numerical bounds of the linear attention operator on the target hardware. Use a bounded parameterization to remove special branches and prioritize Tensor Core utilization.
    2. Remove loss-based balancing: When the number of experts exceeds one hundred, prioritize online statistical balancing over auxiliary loss to reduce tuning effort.
    3. **Make residuals configur