Three Core Optimizations for Ultra-Large MoE Multimodal Models
This article covers three optimization areas for trillion-parameter-scale Mixture-of-Experts (MoE) multimodal models: training stability under extreme sparsity, attention cost at million-token contexts, and representation degradation in deep networks. For each area, it explains the design idea, key implementation points, and verification methods, and it flags which figures and claims in the source material still need official confirmation.
The parameter counts, context lengths, and expert counts in the source material have no official citation. This article keeps these figures and marks them as “per the source material.” Check the official release before citing them. This article discusses only the technology and does not evaluate any specific product.
1. Architecture Configuration and Number Definitions
The source material gives the following main configuration.
| Component | Description in the source material | Points to verify before adoption |
|---|---|---|
| Total parameters | 2.8 trillion | Whether the count includes the vision encoder |
| Active parameters | 104 billion | The number of parameters each token actually passes through |
| Routed experts | 896 | The number of experts K selected per token |
| Attention | Incremental attention fused with gated multi-head latent attention | Which layers use which attention type |
| Activation function | SiTU-GLU | How it differs from the commonly used SwiGLU |
| Context | Four-stage extension: 8K, 64K, 256K, 1M | Data volume and training steps for each stage |
Based on these numbers, each token activates about 104 billion ÷ 2.8 trillion ≈ 3.7% of the parameters. Higher sparsity lowers the compute per inference. However, each expert receives less training data, so whether the load is balanced directly affects training quality.
2. Extending Context from 8K to 1M
Training directly on 1M-token sequences is very expensive. The compute for standard attention grows with the square of the sequence length. The source material extends the length from 8K to 1M, an increase of about 122 times. Attention compute therefore grows by about 122² ≈ 15,000 times. This is the main reason for staged extension.
The source material describes four stages (8K → 64K → 256K → 1M) but does not give the configuration of each stage. Typically, each stage requires adjusting three kinds of parameters:
- The proportion of long documents in the training data;
- The scaling parameters of the position encoding, such as the RoPE base frequency;
- The batch size and learning rate.
After each stage, run a retrieval test. Insert a fact into a long text, ask the model to answer a question about it, and record the accuracy as a function of the fact’s position. If the curve drops sharply at a certain length, the extension at that stage needs adjustment.
3. Lower-Bounded Log-Decay Parameterization for Linear Attention
Linear attention replaces softmax with a recurrent form, so its compute grows linearly with sequence length. In practice, the sequence is split into chunks. Chunks pass information to each other through a recurrent state, and the computation inside each chunk is handled separately.
Let gt be the log decay at step t (g_t ≤ 0), and let b_i = Σ{t≤i} g_t be the cumulative value within the chunk. The intra-chunk output can be written as:
oi = Σ{j≤i} (q_i·k_j) · exp(b_i − b_j) · v_j
This expression splits into an exp(b_i) part and an exp(−b_j) part, which allows the computation to use matrix multiplication. The problem is that exp(−b_j) grows as j increases. If the decay is unbounded, b_j can approach negative infinity, and exp(−b_j) overflows. The intra-chunk computation would then have to fall back to an element-wise explicit path.
The source material proposes making the log decay lower-bounded:
g_t = g_min · σ(x_t), where g_min = −5
σ is the sigmoid function, and x_t comes from a linear layer applied to the hidden state. This keeps g_t in the range [−5, 0].
This lower bound leads to two conclusions, both of which can be verified:
- Within a tile of 16 tokens, |b| ≤ 80, so exp(−b) ≤ e^80 ≈ 5.5×10³⁴. BF16 and FP32 share the same exponent range, with a maximum of about 3.4×10³⁸, so they can represent this value. The FP16 maximum is 65504, about e^11, so this approach cannot use FP16 directly.
- The per-step decay factor exp(g_t) is at least e^−5 ≈ 0.0067. In other words, each step keeps at least about 0.67% of the historical state. The model cannot clear its memory in one step the way it could with unbounded decay. This is a constraint on expressive power, and ablation experiments are needed to measure its impact.
The reference implementation after the correction is below. The variable name eA_hz_th in the source material is not explained, so this article uses x throughout.
import torchG_MIN = -5.0 # Lower bound of the per-step log decayC = 16 # Tile lengthdef bounded_log_decay(x):# x: (B, H, C), obtained from the hidden states through a linear layerreturn G_MIN * torch.sigmoid(x) # Range [-5, 0]def intra_tile_scores(q, k, log_decay):# q, k: (B, H, C, D); log_decay: (B, H, C)b = torch.cumsum(log_decay.float(), dim=-1) # Cumulative log decay within the tileq_t = q.float() * torch.exp(b).unsqueeze(-1)k_t = k.float() * torch.exp(-b).unsqueeze(-1) # |b| <= 80, safe within the BF16 rangescores = q_t @ k_t.transpose(-1, -2) # (B, H, C, C)mask = torch.tril(torch.ones(C, C, dtype=torch.bool, device=q.device))return scores.masked_fill(~mask, 0.0)
This code runs in FP32 to make verification easier. When running in a BF16 kernel, check the same value ranges. The intra-chunk matrix multiplication is dense, so in principle it can use Tensor Cores. The actual speedup must be measured on your own hardware and tensor shapes.
When verifying, do three things:
- Compare against an FP32 reference using random inputs plus extreme values (for example, x set to ±50), and record the maximum absolute error;
- Count the inf and NaN values in the output, which should be zero;
- Compare training loss curves with and without this parameterization, and check whether convergence slows down.
4. Auxiliary-Loss-Free Load Balancing
In an MoE with many experts, uneven load causes some experts to be overloaded while others receive almost no training. The traditional approach adds an auxiliary loss that treats load balancing as an extra objective. The drawbacks are that its coefficient must be tuned, and it can interfere with the gradients of the main task.
One public alternative comes from the DeepSeek-V3 technical report (2024). It adds an expert bias to the routing scores. The bias affects only top-K selection and does not take part in computing the gate weights. After each training step, the bias is adjusted up or down by a fixed step size γ, depending on whether the expert is overloaded. This approach adds no auxiliary loss term.
The source material proposes a “quantile balancing mechanism,” described only by name and as “statistics and routing correction based on load quantiles.” The source material does not give the quantile value, the statistics window, or the correction formula, so this article cannot reproduce it. To understand the mechanism, at least the following questions need answers:
- What quantile q is used, and is the statistics window based on training steps or a sliding window?
- Where does the correction apply: the bias, the gate weights, or the expert capacity?
- How does it relate to the capacity factor and the token drop rate?
- How is load statistics handled during inference? Inference batches are smaller, so the noise in the load statistics increases.
To evaluate load balancing, look at three metrics: the coefficient of variation of expert load, the token drop rate, and the entropy of the routing distribution.
5. Block Attention Residuals
A standard residual connection is written as x_{l+1} = x_l + F(x_l). As the network gets deeper, information from early layers is more likely to be diluted as it passes through. This is one cause of representation degradation in deep networks.
The source material describes Block AttnRes as “directly sharing features across multiple layers,” and says it reduces peak memory and cross-layer communication overhead. The source material gives no formula, so the following is a general explanation and not a confirmed implementation of the original design. A common approach is to group layers into blocks. Within each block, ordinary residual connections are used. Later layers then apply attention over summaries of the earlier blocks.
In this design, the memory savings come from storing fewer intermediate states. For example, a model with 64 layers and a block size of 8 would store 8 block summaries instead of 64 layer outputs. This figure is only illustrative. The actual savings depend on the form of the summaries and the recomputation strategy.
To evaluate this mechanism, record the following, and compare at the same number of training tokens:
- Peak memory, which can be read with
torch.cuda.max_memory_allocated; - Time per step and throughput in tokens/s;
- Cross-device communication volume;
- Validation loss at the same number of tokens.
6. Long-Horizon Agent Training
The source material mentions that post-training uses Agentic RL at the million-token level and says it achieves top results on open benchmarks. The source material gives no scores, benchmark names, or test conditions, so this claim cannot currently be verified.
When evaluating agent capabilities, report at least the following:
- Task success rate, along with the name and version of the benchmark used, such as public agent benchmarks like SWE-bench or τ-bench;
- Average number of tool-calling turns and average token consumption per task;
- A breakdown of failure cases. Common categories include tool argument errors, long-context forgetting, and repeated calls.
7. Compute Planning for Deployment
Training a trillion-parameter-scale MoE model requires a high-performance GPU cluster, parallel file storage, and low-latency RDMA networking. Expert parallelism brings frequent all-to-all communication, and network bandwidth often becomes the bottleneck.
Below is a rough memory estimate. Storing 2.8 trillion parameters in BF16 requires about 2.8×10¹² × 2 bytes ≈ 5.6 TB for the weights. With mixed-precision Adam, each parameter also needs a master weight, first and second moments, and a gradient. The total training state is about 16 bytes per parameter, or about 45 TB. This estimate excludes activations and communication buffers, so actual requirements will be higher.
Cloud platform specifications and pricing change often. For current details when choosing a platform, check the official information from each provider.
8. Pre-Deployment Checklist
- Reusable parts: the block attention residual approach and its memory measurement method, and the numerical verification method for the lower-bounded linear attention parameterization.
- Prerequisites: confirm the parameter count definition, confirm the data mix for each context stage, and confirm that the precision in use (BF16 or FP16) meets the value range requirements.
- Risks: the quantile balancing mechanism lacks a formula and cannot be reproduced directly. The benchmark results lack a citation source. The lower-bounded decay may limit the model’s memory capacity, which ablation experiments need to verify.
