Trillion-Parameter MoE Multimodal Models: Architecture, Attention Design, and Training Stability Practices
This article uses a 2026 technical report on a trillion-parameter mixture-of-experts (MoE) multimodal model as a reference case study. It covers how the design distributes work across three dimensions — sparse parameters (~2.8T total, ~104B activated per token), hybrid attention (lower-bounded decay linear attention plus gated MLA), and cross-layer residual sharing (Block AttnRes) — and how it keeps ultra-sparse training stable with quantile balancing instead of an auxiliary loss. It also walks through the numerical analysis behind the lower-bounded decay trick, a four-stage 8K-to-1M context extension curriculum with million-token agentic reinforcement learning, and a practical checklist spanning operators, memory, communication, observability, and inference. Readers will find three concrete, independently verifiable techniques that can be piloted in existing LLM training pipelines.
Three Engineering Problems Arriving at the Same Time
Over the past few years, large models have evolved rapidly along the axes of “more parameters, longer context, more modalities,” and trillion-parameter MoE models have moved from papers to open source. A 2026 technical report on a trillion-parameter MoE multimodal model offers a fairly representative design sample:
- Roughly 2.8 trillion total parameters, with only about 104 billion activated per token;
- Native multimodal input covering both vision and text;
- A context window spanning 1 million tokens.
According to the report, the model uses multi-stage pretraining, where each stage continues training on top of the previous stage’s weights, with context length advancing from 8K to 1M. After pretraining, it adds million-token-scale agentic reinforcement learning as post-training.
The architecture described in the report preserves its route choices, stability tricks, and engineering tradeoffs in full, which makes it a good subject for study. For teams planning to build their own LLM infrastructure or do secondary development, the problems behind these designs are largely shared:
- Training stability: When there are hundreds to thousands of experts and routing is extremely sparse, how do you prevent some experts from being starved while others get selected repeatedly?
- Long-context efficiency: Standard attention scales quadratically with sequence length. How can million-token context be affordable?
- Depth and multimodal fusion: As layers increase, can deep networks fully exploit the fine-grained information from shallow layers? How does the vision modality cooperate with long text inside one mechanism?
The conclusion list comes first, followed by a section-by-section walkthrough. Below, this generation of design is referred to collectively as “trillion-scale MoE multimodal models.”
Conclusions at a Glance
| Dimension | Key design | Problem addressed |
|---|---|---|
| Parameter scale | MoE architecture, ~2.8T total parameters, ~104B activated per token | Expand model capacity within an affordable compute budget |
| Modality and context | Native multimodality, context covering 8K→64K→256K→1M | Unified modeling of text and images; support for very long documents and codebases |
| Attention (1) | Linear attention with lower-bounded decay parameterization | Numerical underflow, non-vectorizable diagonal blocks, length extrapolation |
| Attention (2) | Gated multi-head latent attention (Gated MLA) | Compress the KV cache, stabilize the attention distribution |
| Cross-layer information | Block-level attention residual (Block AttnRes) | Deep-representation bottleneck, lower memory and communication overhead |
| Expert network | ~900 routed experts plus a shared expert, with GLU-family activations | Balance capacity and efficiency at high sparsity |
| Load balancing | Quantile Balancing (QB), no auxiliary loss | Expert routing collapse, auxiliary loss interfering with the main task |
| Training strategy | Progressive context extension + million-token agentic RL | Long-sequence training stability, long-horizon task capability |
Three Techniques Most Worth Reusing
- Lower-bounded decay: A very small parameter change that solves the diagonal-block parallelism and numerical-underflow bottleneck of linear attention on GPU matrix-multiply units.
- Quantile Balancing (QB): Fast dynamic load balancing in large-scale MoE training without introducing an auxiliary loss.
- Block AttnRes: Breaks the deep-Transformer representation bottleneck while reducing memory usage and cross-layer communication overhead.
1. Overall Architecture: Decomposing the Pressure with “Sparse Compute + Hybrid Attention + Cross-Layer Sharing”
The trillion-scale model in this report is not a single-technology breakthrough but a set of coordinated designs. It can be summarized as a division of labor across three dimensions.
Parameter dimension: trading sparsity for capacity. In an MoE structure, each feed-forward sub-layer consists of multiple routed experts plus one shared expert that always participates in computation. In the report, the number of routed experts reaches 896. Each token selects a few experts via the routing module, while the remaining experts only occupy memory and produce no computation. The ratio of 2.8T total parameters to 104B activated parameters is close to 27:1, meaning each token uses less than 4% of the parameters. Model capacity can then grow with the number of experts while per-token compute stays roughly controllable.
Attention dimension: mixing linear and gated latent attention. Linear-attention operators replace an explicit attention matrix with a recurrent state, reducing the complexity of sequence modeling from quadratic to linear, and they come with decay-based forgetting built in. Gated MLA (Gated Multi-Head Latent Attention) compresses Key/Value projections into a low-dimensional latent space, sharply shrinking the KV cache, while a gating factor stabilizes the output. Combining the two guarantees precise retrieval of long-range information while keeping memory and bandwidth costs under control.
Depth dimension: cross-layer information sharing. Block AttnRes lets the output of the current attention sub-block act on multiple subsequent layers at once, alleviating the “deeper is better at reasoning, worse at remembering details” problem.
There are also two supporting designs that are easy to overlook but directly determine whether training can run through:
- A smooth, deformable variant introduced into the GLU-family activation functions, acting somewhat like a temperature coefficient to make gating smoother and gradients more stable;
- Context extended stage by stage from 8K→64K→256K→1M, then layered with million-token-scale agentic reinforcement learning.
One general principle can be distilled at the architecture level: let different mechanisms handle what they are best at. Linear attention handles cheap global state updates, gated latent attention handles precise information lookup, MoE handles capacity expansion, cross-layer residuals handle deep information flow, and reinforcement learning turns long context into long-horizon task capability.
2. Innovation One: Lower-Bounded Decay, Unblocking Linear Attention at the Kernel Level
This is the technique most worth reusing across engineering teams, because the change surface is small and the payoff is clear.
2.1 Background: Recurrent States and Chunked Parallelism
Linear attention with a forget gate is usually written in recurrent form:
S_t = Γ_t ⊙ S_{t-1} + K_t^T V_tO_t = Q_t S_t
Here S is the state matrix, Γ is the per-channel decay factor (0~1), and ⊙ denotes element-wise multiplication.
With sequence length L, computing token by token in serial leaves GPU parallelism on the table. Practical implementations therefore adopt chunked parallelism: split the sequence into chunks of length C (for example 16 or 64).
- Within a chunk: one matrix multiplication computes all the attention-like results inside the chunk.
- Across chunks: only a single state matrix is passed along, so the cost scales linearly with sequence length.
In many implementations, the within-chunk “query × key” matrix must be multiplied by the state contribution, which requires the reciprocal of the cumulative decay to “restore” the components in the state that came from earlier tokens.
2.2 Numerical Underflow and Diagonal-Block Degeneration
If a channel’s decay is close to 0 (history is forgotten quickly), then within a chunk of length C the cumulative decay Γ_cum shrinks dramatically, and its reciprocal grows just as dramatically. This can overflow even in FP32; with BF16 it gets worse:
- BF16 has an 8-bit exponent, the same as FP32, but its mantissa has only 7 bits, so the relative error after reciprocal amplification is amplified as well;
- More critically, the state elements being multiplied have often already underflowed to 0, giving 0×∞→NaN, or complete loss of a lot of state information.
A common engineering workaround is to compute only the “cross-chunk” portion with matrix multiplication and to evaluate the positions near the diagonal inside a chunk (the diagonal block) with an explicit per-position-pair loop. This does avoid the reciprocal, but at a cost:
- The smaller the diagonal block relative to the whole and the shorter the chunk, the more computation falls onto the less efficient element-wise path;
- Code branches increase, kernel implementation gets complex, and there is less room for tuning.
2.3 Mechanism: Parameterizing Log-Decay with a Bounded Sigmoid
Lower-bounded decay replaces log-decay with an unbounded negative Softplus function by a scaled sigmoid with a fixed lower bound:
g_t = g_min · σ(A · h_t) g_min = -5 (fixed)Γ_t = exp(g_t) ∈ [exp(-5), 1)
σ is the sigmoid function, h_t is the hidden representation at that position, and A is a learnable projection matrix (typically applied per channel). The meaning is: each channel can decay at most to exp(-5)≈0.0067 per position, so the decay speed has a hard lower bound.
2.4 How the Numerical Bounds Get Locked Down
Estimating with chunk length 16: within a chunk, cumulative log-decay is no smaller than 16×(-5)=-80. From this:
- Cumulative decay is no smaller than exp(-80)≈1.8×10⁻³⁵: three orders of magnitude above the smallest normal number BF16 can represent (~1.18×10⁻³⁸), so it will not underflow to 0;
- Its reciprocal is no larger than exp(80)≈5.5×10³⁴: four orders of magnitude below the largest BF16 value (~3.39×10³⁸), so it will not overflow to ∞;
- Quantization error from the reciprocal stays controllable: at that magnitude the minimum BF16 interval is about 2²²≈4.2×10²⁷, keeping relative error within 2⁻⁸≈0.39%.
This checks out against the 16-token chunk length mentioned in the source content. More importantly, the bound depends only on g_min and the chunk length, not on total sequence length. So whether the context is 64K or 1M, within-chunk computation stays inside the same safe numerical range.
2.5 Payoff: A Unified MatMul Path, with Native Support for Position-Encoding Extrapolation
- At the operator level: the diagonal block no longer needs a special branch, and all causal blocks can take the same dense matmul path, calling GPU high-throughput matrix instructions directly (such as BF16 tensor cores).
- At the throughput level: the kernel is simpler to implement, and compilers and autotuners find efficient implementations more easily; short and long sequences share the same optimization.
- At the modeling level: the recurrent state itself implicitly carries positional information, so this kind of structure can drop explicit positional encoding (NoPE). The model extrapolates better to unseen lengths, leaving room for million-token contexts.
2.6 Illustrative Code
The pseudocode below shows the three steps of “deriving bounded decay from the hidden state,” “scaling within a chunk,” and “passing state to the next chunk.” In a real implementation these steps are usually fused into a single kernel:
GMIN = -5.0 # lower bound on log-decayCHUNK = 16 # chunk length, matching the original designdef linear_attn_chunk(q, k, v, h, W_a):# 1) Bounded decay parameterization: log-decay stays in [GMIN, 0)log_g = GMIN * sigmoid(W_a @ h) # (B, H, T, D_k)decay = exp(log_g) # per-step decay in [exp(-5), 1)# 2) Cumulative decay within the chunk and its reciprocal;# numerical range is set by GMIN * CHUNKcum = cumprod_in_chunk(decay, CHUNK) # >= exp(-80), never underflows to 0inv_cum = reciprocal(cum) # <= exp(80), never overflows to infq_s = q * cumk_s = k * inv_cumattn = causal_mask(q_s @ k_s.transpose(-1, -2))out_local = softmax_scale(attn) @ v # shares one matmul path with the diagonal block# 3) State recurses across chunks along the sequence dimensionkv = k.transpose(-1, -2) @ vstate_new = cum[..., -1:] * state_prev + exp(log_g_cumsum(log_g)) * kvout_cross = q @ state_prevreturn out_local + out_cross, state_new
2.7 Engineering Recommendations
- Derive the bound from the chunk length. With g_min fixed at -5, the numerical safety matches a chunk length around 16. If the chunk length grows to 64, the cumulative log lower bound becomes -320, and the reciprocal would exceed the BF16 range. You then need to shrink the bound accordingly, or switch to FP32 accumulation. The principle is to keep C×|g_min| inside the safe range of the target precision.
- Prioritize precision on the reciprocal side. During scaling, compute the reciprocal and the scaled matrix in at least FP32, then convert the output back to BF16.
- Validate with ablations. Under the same data and the same budget, compare bounded and unbounded versions, watching both kernel throughput and final perplexity, so that efficiency is not traded for quality.
- Existing models can be upgraded lightly. Models that already use linear attention do not need to be rebuilt. You can change only the decay parameterization and do a small amount of continued pretraining, letting the numerical behavior converge gradually before switching to the unified kernel.
3. Innovation Two: Gated Multi-Head Latent Attention and Cross-Layer Residuals
3.1 Gated MLA: Compressing the KV Cache and Stabilizing the Output Distribution
The core of Multi-Head Latent Attention (MLA) is mapping each token’s Key/Value to a low-dimensional latent vector, so inference caches only that latent vector, substantially compressing the KV cache.
On top of this, the added gating factor — typically generated per head or per token — applies a smooth scaling to the attention output. It brings at least two benefits:
- It suppresses noise accumulation from irrelevant heads;
- It mitigates the “attention sinking” phenomenon, where attention concentrates too heavily on a few tokens, making the information distribution over a long context more even.
Illustrative sketch:
# Pseudocode: only cache the latent vectorc_kv = W_dkv @ h # latent vector, goes into the KV cachek = W_uk @ c_kvv = W_uv @ c_kvscores = (W_uq @ h) @ k.transpose(-1, -2) * scaleattn = softmax(causal_mask(scores))gate = sigmoid(W_g @ h) # gating factor, per head or per channelout = gate * (attn @ v) @ W_o # gating, then output projection
3.2 Division of Labor Between the Two Attention Types
Linear attention maintains a “compressed memory” continuously at very low cost, but its precise retrieval ability is limited; gated latent attention can look back at any historical position precisely, at the cost of a KV cache that grows linearly with length.
Mixing them reflects a clear division of labor:
- Most layers use linear attention to handle long-range, lower-precision information integration;
- A few layers use gated latent attention to handle precise retrieval and fine-grained alignment.
This is consistent with the mainstream industry practice of mixing linear and full attention and stacking them in fixed proportions. For real configurations, retrieval-style probe tasks can determine the position and number of precise-attention layers, for example needle-in-a-haystack retrieval or long-document question answering.
3.3 Block AttnRes: Letting Deep Layers “See” Shallow Ones
In a standard Transformer, each layer’s input comes only from the previous layer’s output. As layers grow, gradients must pass through all of them to propagate, and the fine-grained information from shallow layers is diluted layer by layer.
Block AttnRes works as follows:
- Split the attention sub-block’s input into several parallel residual streams;
- After a small-dimension projection, the current sub-block’s output is added to multiple subsequent residual streams at once;
- The next sub-block reads only one of them as its input.
# Pseudocode: block-level attention residual (DenseNet-like idea)def attn_block(res_streams, idx, n_blocks, attn, proj):x = norm(res_streams[idx]) # this block reads only one residual streamy = attn(x) # attention sub-block outputdelta = proj(y) # low-dimensional broadcast to control extra costfor j in range(idx, n_blocks): # broadcast to this and subsequent streamsres_streams[j] = res_streams[j] + deltareturn res_streams
Benefit 1: break the representation bottleneck. Every layer directly receives outputs from multiple earlier sub-blocks. Local details extracted in shallow layers are not washed out by intermediate layers, and deep layers can focus on abstract reasoning.
Benefit 2: lower memory and communication cost. Each layer only needs to store the one residual stream it is responsible for, so extra memory is about 1/n_blocks of the standard structure. Under model parallelism, activation tensors are also smaller, so cross-layer communication costs drop.
The cost is extra projection and addition operations. Practical guidance:
- Validate the benefit on a small-scale model first, then decide whether to use it in full;
- A projection dimension of 1/4 to 1/2 of the attention output dimension usually balances quality and overhead.
4. Innovation Three: Stable Training and Load Balancing for Ultra-Sparse MoE
4.1 Expert Scale and Load Imbalance
The MoE module in the report has about 900 experts, of which 896 are routed experts, plus a shared expert that always participates in computation. The routing module selects top-k experts for each token. More experts mean finer-grained “specialized knowledge,” but also a greater risk of load imbalance.
Three causes of imbalance:
- Rich-get-richer dynamics: experts slightly favored early receive more gradient updates, become stronger, and then attract even more tokens;
- Parameter desynchronization: under expert parallelism, experts on different devices update at different rates;
- Long-tail experts: some experts receive almost no tokens, effectively occupying memory for nothing.
4.2 Problems with the Traditional Auxiliary Loss
The traditional approach adds a load-balancing auxiliary loss, commonly the sum of “each expert’s selection frequency × each expert’s average routing probability.” Minimizing it pushes tokens toward a uniform distribution, but it has three drawbacks:
- The auxiliary loss competes for gradients with the language modeling objective; tasks such as win-rate prediction and code generation are sensitive to distribution shifts and can suffer;
- The weight coefficient is hard to tune — too weak and it has no effect, too strong and it damages quality;
- At inference time, if a different expert scale is used (for example after expert pruning or distillation), the auxiliary loss cannot be reused.
4.3 QB: Dynamic Balancing Without an Auxiliary Loss
The idea behind QB is to correct the routing bias online instead of relying on a loss function. Each expert maintains a bias b_i:
- Within a time window, measure the fraction of tokens selected for each expert;
- Compute a quantile of these fractions (for example the 80th percentile) as the balancing target;
- Experts above the target get their bias lowered; experts below get their bias raised;
- The bias only affects which experts a token selects; it does not participate in the weighted sum of expert outputs.
# Pseudocode: quantile-driven load balancing (illustrative)def update_bias(load, bias, q=0.8, eta=0.01):target = quantile(load, q) # quantile as the balancing targetdelta = (target - load) / (target + 1e-6)return clamp(bias + eta * delta, -1, 1)def route(h, gate, bias, top_k):logits = gate(h) # routing scoresidx = topk(logits + bias, top_k) # bias decides only "who gets selected"weight = softmax(logits[idx]) # weighting uses the original scoresreturn idx, weight
Why a quantile rather than a mean?
- A mean is easily pulled up by a few extremely imbalanced experts, causing most experts to be “judged as overloaded” and distorting the correction strength;
- A quantile reflects the load level of a “typical expert” and is more robust to long tails and short-term spikes;
- q can be adjusted dynamically: a smaller quantile early in training to pursue coverage, a larger one later to pursue balance.
In practice, QB typically updates biases every few dozen to a few hundred steps, with negligible overhead.
4.4 Activations and Sparsity: A Coordinated Design
GLU-family activations are the mainstream choice for MoE feed-forward sub-layers, in the common form of “one branch does the gating, one does the transformation, and the two are multiplied element-wise.” A smoother, learnable S-shaped variant is usually more stable than the original, because it behaves approximately linearly — neither saturating nor exploding:
- The gate value stays bounded and gradients stay smooth;
- The negative half-axis retains some slope, mitigating “dead neurons”;
- Under extreme routing sparsity (an expert serves only a handful of tokens), small-batch statistics noise is less likely to blow up gradients.
5. Training Strategy: Progressive Context Extension and Million-Token Agentic RL
5.1 Why Extend Context in Stages
Pretraining directly at 1M length is neither realistic nor cost-effective, for three reasons:
- Memory grows sharply with length: even when attention is already linear in complexity, activations and optimizer states remain enormous;
- Data supply does not match: high-quality long-text corpora are relatively scarce;
- Optimization is unstable: hyperparameters such as learning rate and weight decay need recalibration at every length.
So a four-stage curriculum of 8K→64K→256K→1M is used: the previous stage’s weights initialize the next stage, gradually acclimating the model to longer dependencies. Each stage requires attention to:
- Data mix: short samples keep participating, to avoid “catastrophic forgetting of long context”;
- Position extrapolation: if explicit positional encoding is used, base frequencies need adjusting in sync; this design uses NoPE, with decay states carrying positional information implicitly, which extrapolates better;
- Learning-rate schedule: re-warmup at every stage to avoid gradient spikes on long sequences.
5.2 Million-Token Agentic Reinforcement Learning
Pretraining answers “can the model retrieve and reason over a long context”; reinforcement learning answers “can it plan, call tools, and self-correct over long horizons.” The report’s agentic RL is carried out at million-token scale, with the training objective of getting the model to:
- maintain task state;
- call tools over multiple steps;
- recover from errors.
Key training considerations:
- Reward design: outcome rewards (did the task complete) plus process rewards (were intermediate steps sound), to avoid “reward hacking”;
- Sampling efficiency: rollouts over million-token contexts are very expensive, so “partial trajectory reuse” or asynchronous sampling is common;
- Stability: standard measures such as value-function clipping, KL divergence constraints, and advantage normalization prevent policy collapse.
6. Engineering Checklist: From Training to Inference
- Operators first. Linear attention and MoE routing are the two biggest performance hotspots; prioritize operator fusion and kernel-level optimization. Lower-bounded decay itself is an engineering trick for “making every block take the same matmul path.”
- Memory ledger. Total memory ≈ parameters + optimizer states + activations + KV cache.
- At million-token context, the KV cache must be controlled with compression schemes such as latent attention;
- Activations are amortized via recomputation and sequence parallelism;
- Experts are sharded via expert parallelism (EP).
- Communication optimization. Expert parallelism brings all-to-all communication, and Block AttnRes reduces cross-layer activation transfer volume; the two together noticeably relieve the communication bottleneck.
- Observability. Continuously monitor each expert’s selection fraction, routing entropy, gradient norm, and loss across different length buckets; the load-balancing bias update curve should be a first-class metric, not just a log line.
- Inference strategy. For long-context inference, prioritize KV cache quantization, paged caching, and request batching; multimodal input is unified into a token sequence before entering the language model, sharing one attention mechanism.
- Building on the cloud. Teams that want to build similar training/inference platforms on Baidu AI Cloud can assemble general-purpose cloud products on demand — container services, object storage, parallel file storage, logging, monitoring and alerting — to build a training pipeline that fits their own compliance and cost requirements.
7. Summary and Outlook
What is most worth remembering about this trillion-parameter MoE multimodal model report is not the parameter count itself, but the “combination punch” it throws at three hard problems:
- Long-context efficiency: lower-bounded decay brings linear attention’s diagonal blocks into one matmul path, and gated latent attention compresses the KV cache;
- Training stability: quantile balancing replaces the auxiliary loss, while smooth bounded activations and the shared expert keep sparse routing steady;
- Deep information flow: Block AttnRes lets shallow-layer details reach deep layers directly.
For developers, these three techniques share a common trait: small changes, independently verifiable, quantifiable gains — ideal candidates for incremental upgrades to existing systems.
Looking ahead, these directions are worth watching:
- Balancing sparsity against activated parameters: as experts multiply, how to ensure each one learns something meaningful;
- Adaptive ratio of linear to full attention: scheduled dynamically per layer and per task;
- Combining reinforcement learning with long context: truly applying agentic capability to very long documents and codebase-level tasks;
- Unified training and inference: making load-balancing strategies usable at inference time too.
Back to the original question: how should we view trillion-parameter MoE multimodal models? They are not a victory of any single point technology, but a system design in which “every mechanism does what it is best at.” For most teams, rather than chasing parameter scale, it is better to land one or two reusable techniques first — such as decay parameterization with numerical bounds — into their own training pipeline, and let ablations do the talking.
