Technical Deep Dive: Building Ultra-Scale Sparse Multimodal MoE Models
This article breaks down the engineering challenges of ultra-scale sparse multimodal Mixture-of-Experts (MoE) models, focusing on a ~2.8 trillion total parameter architecture with ~104 billion activated parameters per token. It examines practical solutions across attention layers, sparse feed-forward layers, cross-layer information flow, training curricula, and post-training. Readers will learn how bounded gating decay enables dense tensor core utilization, how quantile-based balancing removes auxiliary losses, and how block-level attention residuals reduce overhead for million-token contexts.
1. Why Ultra-Scale Sparse Multimodal Models Are a Technical Focus
Over the past two years, the growth in large model capabilities has increasingly relied on the stacking of three curves: the parameter scale curve, the context length curve, and the task shape curve (moving from single-turn Q&A to long-horizon agents). When these three curves rise simultaneously, training and inference systems tend to break in three places at once: the memory and compute overhead of attention computation, load imbalance in massive expert routing, and representation degradation in deep networks under long sequences.
A typical technical approach is a sparse multimodal architecture with about 2.8 trillion total parameters and about 104 billion activated parameters per token. It natively fuses visual inputs and progressively advances the context from thousands of tokens to the million level. The attention layers use a hybrid of gated low-rank latent attention and incremental linear attention, while attention residuals share information across layers. The feed-forward layers adopt a sparse structure containing hundreds to over a thousand routed experts, combined with smooth gating activations and an auxiliary-loss-free load balancing mechanism. Below, this type of solution is broken down into transferable engineering modules and examined one by one.
2. Attention Layers: Fully Utilizing Tensor Cores with Linear Attention
2.1 Pain Point: Why Diagonal Blocks Are “Special”
Linear attention and incremental (Delta-type) updates require the reciprocal of the cumulative decay factor within a chunk during block computation. If the decay takes unbounded values in logarithmic form (for example, negative softplus), the reciprocal is prone to overflow or underflow under the finite precision of BF16. An engineering compromise is to route diagonal blocks through a separate “position-pair” computation path, at the cost of more branches, difficult operator fusion, and the inability to run everything through dense matrix multiplication.
2.2 Mechanism: Adding a Lower Bound to the Decay
Changing the logarithmic decay from an unbounded function to a bounded function with a lower bound is a key move in this type of solution. After fixing the lower bound (for example, -5), the reciprocal scaling within any 16-token chunk is locked into a safe numerical range, and diagonal and non-diagonal blocks can uniformly call dense tensor core matrix multiplication.
# Illustration: bounded gating decay parameterization (pseudocode)g_min = -5.0log_decay = g_min * sigmoid(scale * proj(x)) # bounded to avoid reciprocal explosionstate = decay * state + k.transpose(-1, -2) @ v # unified dense GEMM
There are three benefits: operator branches converge, throughput improves, and it naturally fits a no-position-encoding design, so extrapolating to million-level contexts does not rely on additional position interpolation techniques.
2.3 Hybrid and Gating: Balancing Global and Local
Pure linear attention still has shortcomings on precise retrieval tasks, so a common practice is to alternately stack global attention and linear attention in a certain ratio, and introduce per-channel gating on top of low-rank latent (low-rank compressed key-value representations) to suppress noise accumulation in irrelevant dimensions. Engineering-wise, the memory footprint and dequantization overhead of the low-rank cache need to be jointly tuned with the chunk size.
3. Sparse Feed-Forward Layers: Keeping 896 Experts from “Starving”
3.1 Quantile Balancing: Removing the Auxiliary Loss
The traditional approach relies on a load balancing auxiliary loss, but it competes with the main task gradient and is hard to tune. The idea of quantile balancing is to dynamically adjust the capacity threshold of each expert based on the historical quantiles of routing scores, so that the intake of each expert converges without an extra loss term. The engineering key is to estimate statistics with a sliding window and decouple the update frequency from the learning rate to avoid jitter.
# Illustration: quantile-based dynamic capacity thresholdq = quantile(scores_history, target_load_ratio) # sliding window estimationassign = topk(scores - q, k=experts_per_token) # threshold shift for balancing
3.2 Smooth Gating Activation and Training Stability
Using a smooth gating activation (a sigmoid gate multiplied by a linear term) in the feed-forward intermediate layer gives more stable gradients than the classic gated linear unit under extreme sparsity. Combined with routed expert grouping, expert parallelism, and communication overlap, the communication pressure of “fully interconnected experts” can be reduced to an acceptable range.
4. Cross-Layer Information: Block Attention Residuals
The representation bottleneck of deep networks comes from “information only flowing between adjacent layers.” Splitting the attention output into blocks and injecting residuals across several layers (block-level attention residuals) preserves fine-grained information while keeping memory and communication overhead at block granularity. Compared with per-token residuals, it significantly reduces cross-layer cache fragmentation and bandwidth usage.
5. Training Curriculum: Progressive Advancement from 8K to 1M
Context extension should not be done in one step. The industry generally adopts a progressive curriculum: first solidifying language and visual alignment in short contexts, then gradually relaxing to tens of thousands, hundreds of thousands, and up to a million tokens, adjusting chunk size, parallel partitioning strategy, and learning rate at each stage. On the multimodal side, attention must be paid to the ratio of image-text tokens and the tiling strategy for high-resolution inputs to avoid visual tokens squeezing out the long-range modeling budget.
6. Post-Training: Million-Token Agent Reinforcement Learning
Long-horizon agent capabilities are mainly obtained through post-training. Reusable practices include: primarily using verifiable rewards with preference optimization as a supplement; splitting trajectories by “step” for credit assignment; and using retrieval and tool calls to construct task environments that can be automatically judged. Engineering-wise, sampling throughput is often the bottleneck, requiring asynchronous sampling and experience reuse.
7. Implementation Advice and General Cloud Capabilities
To reproduce similar capabilities on your own platform, you can combine general capability categories: a container platform to host elastic training and inference clusters, object storage to save corpora and checkpoints, a message queue to decouple sampling and training, and logging services with monitoring and alerting to track loss, routing entropy, and throughput anomalies. Baidu AI Cloud can provide corresponding support in these general categories; refer to the official documentation for specifics. The overall recommendation is to prioritize three changes: “bounded decay,” “auxiliary-loss-free balancing,” and “block-level residuals.” They have low engineering intrusion and certain benefits, making them the three most worthwhile things to do first for long-context sparse models.
