Million-Token MoE Multimodal LLM Architecture: Linear Attention Stability, Quantile Load Balancing, and Cross-Layer Attention Residuals
This article examines the engineering patterns behind a representative trillion-parameter sparse multimodal model with native visual input and one-million-token context. It analyzes three core techniques: bounded decay parameterization for numerically stable linear attention, quantile-based auxiliary-loss-free load balancing for hundreds of routed experts, and cross-layer attention residuals that alleviate depth bottlenecks and reduce KV-cache pressure. It also reviews staged context extension and million-token agent reinforcement learning, then distills practical guidance for teams building long-context, sparsely activated large models.
Introduction: The Dual Challenge of Ultra-Long Context and Ultra-Large Sparse Models
Large-model technology has recently advanced along two main axes. One is the continuous expansion of context length, from thousands of tokens to the million-token level. The other is sparse expansion of parameter scale through Mixture-of-Experts (MoE) architectures, pushing total parameter counts toward the trillions while keeping inference cost roughly unchanged. The intersection of these two directions is where engineering becomes hardest: ultra-long sequences cause attention computation and memory overhead to grow sharply, while massive numbers of experts make training stability and load balancing extremely fragile.
This article uses the methods revealed in a representative publicly disclosed technical report as a reference point. The model described there is an MoE multimodal model with about 2.8 trillion total parameters, about 104 billion activated parameters, native visual input, and a one-million-token context window. The article systematically unpacks three core techniques behind it: lower-bounded linear-attention decay parameterization, quantile-based auxiliary-loss-free load balancing, and cross-layer attention residual structures. The value of these techniques is not limited to any single model; they provide reusable engineering patterns for any team working on long-context, sparsely activated large models.
1. Numerical Stability in Linear Attention: Lower-Bounded Decay Parameterization
1.1 Background
To control computational complexity at million-token lengths, the industry commonly replaces some full-attention layers with linear attention or its variants, such as incremental attention and gated incremental networks. These methods use chunked parallel computation to exploit matrix-multiplication accelerators. In practice, however, there is a hidden numerical trap: the computation requires scaling by the reciprocal of a cumulative decay factor, and that decay factor is typically parameterized by an unbounded negative Softplus function. When the position span within a sequence chunk is large, the decay amount can approach zero, and its reciprocal can severely overflow or underflow in low-precision formats such as BF16.
The direct consequence is that the diagonal causal tile cannot use the unified matrix-multiplication path and must fall back to an explicit position-pair computation branch. This not only slows down diagonal-tile processing significantly but also complicates operator implementation: two types of tiles in the same layer require two separate code paths.
1.2 Solution: Setting a Safe Lower Bound for Decay
The core idea is elegant: change the decay parameterization from an unbounded form to a lower-bounded form. Specifically, the log decay amount is expressed as a fixed lower bound multiplied by a Sigmoid gate, so the decay gate value equals a preset minimum, such as -5, multiplied by the Sigmoid activation output. In this way, the cumulative decay range within any small chunk, such as 16 tokens, is strictly locked within a safe interval, and its reciprocal scaling factor never overflows.
1.3 Benefits
This change requires very little code but delivers significant engineering benefits:
- Diagonal and non-diagonal blocks can use a completely unified matrix-multiplication computation path, fully utilizing hardware matrix units.
- It eliminates the risk of training loss spikes caused by low-precision numerical anomalies.
- Operator implementation is greatly simplified, reducing the cost of subsequent optimization and maintenance on custom kernels.
For developers, the lesson is this: when designing any sequence operator with cumulative multiplicative factors, check the numerical range of those factors first and use bounded parameterization to eliminate precision risk at the root rather than patching it afterward.
2. Training Stability with Massive Experts: Quantile-Based Load Balancing
2.1 The Difficulty of Traditional Approaches
When the number of routed experts in an MoE model expands to nearly one thousand, as in this model’s roughly 896 routed experts, load balancing becomes critical to whether training converges. The classic approach introduces an auxiliary load-balancing loss that forces the number of tokens received by each expert to be roughly uniform. However, there is an inherent optimization conflict between the auxiliary loss and the main task loss: too strong a balancing constraint harms the model’s expert specialization, while too weak a constraint fails to prevent a few experts from being over-routed, the so-called winner-takes-all problem. This can lead to gradient pathology and even training collapse. Under extreme sparsity, where each token activates only a very small number of experts, the problem is further amplified.
2.2 Quantile Balancing Mechanism
The model adopts an auxiliary-loss-free dynamic balancing approach. Instead of relying on an additional loss term, it uses quantile statistics of routing scores to dynamically adjust routing bias or gating thresholds, pulling each expert’s load back toward a target quantile in real time. Its advantages are:
- The main task optimization objective remains clean, allowing experts to differentiate into semantic subspaces they are good at.
- The balancing response is immediate and step-by-step, rather than relying on slow propagation through loss gradients.
- Training remains stable even with close to one thousand experts and extremely high sparsity, which is a notable validation among comparable practices.
2.3 Implications for Engineering Practice
For teams building their own MoE training frameworks, it is advisable to treat load balancing as an independent online control problem rather than a loss-function design problem. Monitoring each expert’s routing-frequency distribution, computing quantile deviation, and dynamically correcting routing bias is a more controllable and tunable path than tuning auxiliary-loss weights.
3. Breaking the Depth Bottleneck: Attention Residuals
3.1 Representation Degradation in Deep Transformers
As layer count increases, the residual stream in a standard Transformer is gradually diluted by the outputs of each layer. Deep modules find it difficult to directly access the original features from shallow layers, creating the so-called depth representation bottleneck. At the same time, under ultra-long context, the attention KV cache at each layer creates enormous memory and cross-device communication pressure.
3.2 Cross-Layer Attention Residuals
The Attention Residuals mechanism introduced by the model allows attention modules in later layers to directly read attention outputs or key-value states from several previous layers in a chunked manner, forming a cross-layer information-sharing channel. The effect is twofold. On one hand, deep layers can bypass the layer-by-layer attenuation of the residual stream and directly obtain fine-grained information from shallow layers, mitigating representation degradation. On the other hand, key-value states can be reused across layers, reducing repeated computation and storage overhead. Combined with gated multi-head latent attention, which compresses keys and values into a low-rank latent space, this further reduces KV-cache size and brings the memory footprint of million-token inference into an acceptable range.
4. Training Methodology: Staged Context Expansion and Agent Post-Training
4.1 Staged Context Extension
Pretraining from scratch directly at a million-token length is computationally infeasible. The model uses progressive context-window expansion: first completing main knowledge learning at 8K length, then extending to 64K and 256K, and finally completing long-range capability alignment at 1M length. This curriculum-style arrangement aligns with industry consensus: short-sequence stages have high compute utilization and enable sufficient learning, while long-sequence stages require only a small amount of data for the model to learn remote dependency modeling. Key practical details include adjusting the rotary position embedding frequency base as the window expands, as well as designing the data mixture ratio for each stage.
4.2 Million-Token Agent Reinforcement Learning
The ultimate value of long-context capability appears in agent scenarios: the model needs to plan, call tools, and integrate multi-turn information across ultra-long trajectories. In post-training, the model introduces million-token-level agent reinforcement learning, optimizing rewards on real long-horizon task trajectories to address typical failure modes in long-range reasoning, such as goal drift and forgetting of intermediate information. The implication for application developers is that long-context capability does not equal long-context usability. Targeted post-training and evaluation are necessary for the model to perform reliably in real agent workflows.
5. Practical Recommendations and Conclusion
Taken together, the reusable experience from this kind of trillion-parameter MoE long-context model can be summarized in four points. First, linear-attention-style operators should use bounded parameterization to eliminate low-precision numerical risk at the source. Second, load balancing for ultra-large expert sets should use online quantile control instead of auxiliary losses. Third, cross-layer residuals combined with low-rank KV compression are an effective combination for alleviating both the depth bottleneck and memory pressure. Fourth, long-context training should follow a staged curriculum and use agent reinforcement learning for last-mile alignment.
For enterprise developers, training and deploying such models places extremely high demands on infrastructure, including compute scheduling, object storage, container platforms, and monitoring and alerting. Mature cloud infrastructure can carry elastic resource provisioning, distributed training orchestration, and inference-service stability, allowing teams to focus on model algorithms and business innovation. The race toward ultra-long context and ultra-large sparse models has only just begun. Mastering these underlying paradigms is far more valuable in the long run than chasing any single model version.
