Ultra-Sparse Trillion-Parameter MoE and Million-Token Context: A Technical Breakdown of Attention, Experts, and Agentic Training
Long-context handling, ultra-sparse MoE, and agentic capability are no longer separate problems for LLM developers, and this article unpacks how one publicly described trillion-parameter MoE model addresses all three at once. It walks through the attention side (a lower-bounded parameterization of decay factors that unifies diagonal and off-diagonal compute paths, Gated Multi-head Latent Attention for exact retrieval under a smaller KV cache, and block attention residuals for cross-layer reuse), the expert side (latent-space MoE, SiTU-GLU, and quantile-based load balancing without an auxiliary loss), and the training pipeline (an 8K to 64K to 256K to 1M context curriculum plus million-token agentic RL). Along the way it explains the BF16 numerical reasoning behind the decay lower bound, gives pseudocode for the parameterization and the bias-based balancing rule, and closes with practical takeaways, deployment constraints, and the limits of these designs that teams should weigh before adopting them.
1. Introduction: Why Long Context, Extreme Sparsity, and Agents Have to Be Solved Together
For LLM developers, long context is no longer just a question of “how many tokens fit in a single request.” A several-hundred-page industry report, a mid-sized code repository, or a task trajectory containing dozens of tool calls can all push the context into the hundreds of thousands, or even millions, of tokens. On the other side, to obtain enough capability density under limited training and inference compute, trillion-parameter sparse mixture-of-experts (MoE) architectures are becoming a common choice for very large models, and multimodal input is steadily becoming standard for general-purpose models.
Once these three pressures are combined, the engineering challenges stop being independent:
- Every doubling of the context sharply increases the quadratic cost of attention and the memory footprint of the KV cache.
- The sparser the routing, the more easily expert load skews, the less stable training becomes, and the harder routing metrics are to interpret.
- Agentic tasks require the model to stay aligned with its objective across multi-turn reasoning, tool calls, and long-range planning, and reinforcement learning demands more sample efficiency and training stability than supervised fine-tuning.
This article uses a trillion-parameter MoE model described in a public technical report (referred to below as the “case model”) as a reference point, and breaks down its architectural thinking along four threads: attention, expert networks, the context curriculum, and agentic post-training. To be clear, the parameter counts, expert counts, and similar figures below are all taken from the public description in that report; they are included to make the design motivations easier to understand, and they are neither an evaluation nor a recommendation of any specific product. The engineering practices discussed fall into general technical territory, and developers can adapt them to their own stacks as needed.
2. The Case Model at a Glance
According to the public description in that report, the core specifications of the case model are as follows:
- Architecture: a multimodal MoE large model.
- Scale: roughly 2.8 trillion total parameters, roughly 104 billion activated parameters, an activation ratio of about 3.7%.
- Input: native support for multimodal inputs including vision, with a maximum context window of 1 million tokens.
- Attention: a combination of delta-rule linear attention (described in the report as KDA) and Gated Multi-head Latent Attention (Gated MLA), with information shared across layers via block attention residuals (Block AttnRes).
- Expert networks: a latent-space MoE with roughly 896 routed experts, using the SiTU-GLU activation and a quantile balancing (QB) mechanism.
- Training pipeline: pre-training contexts advance in stages through 8K → 64K → 256K → 1M, with million-token-scale agentic reinforcement learning (Agentic RL) added on top during post-training.
Separating “total parameters” from “activated parameters” is the key to understanding this architecture. Total parameters determine the model’s knowledge capacity; activated parameters determine the compute cost per token. An activation ratio of about 3.7% means that training such a model requires a careful trade-off between “staying extremely sparse” and “maintaining numerical stability and reliable gradients.” At deployment time, the trillion-scale parameter set has to be sharded across enough devices, and expert parallelism has to deliver the routed experts to the compute units efficiently. This directly shapes every technical choice discussed below.
Overall, the case model attempts to answer three questions at once:
- How to make million-token contexts computationally affordable.
- How to make trillion-scale sparse networks stable to train.
- How to make the model “reason far and act correctly” on long-horizon tasks.
3. The Attention Side: Making Million-Token Contexts Affordable
3.1 Lower-Bounded Decay Parameterization: Unifying the Compute Path for Diagonal and Off-Diagonal Blocks
In linear attention with a decay gate, the output can be written as:
O_t = Q_t · S_t, S_t = diag(α_t) · S_{t-1} + β_t · k_t · v_t^T
Here S_t is the state matrix propagated recursively over time, α_t ∈ (0,1) is the per-timestep decay factor, and β_t and v_t are the write strength and the value vector. Real implementations do not recurse step by step; they compute in parallel over chunks. The sequence is split into chunks, the state passed between chunks is computed first, and then the work inside each chunk is solved in parallel. The critical operation inside a chunk is inverting a strictly (unit) lower-triangular matrix D = (I − tril(diag(a)·K K^T, −1))^{-1}. If the product of decay factors between adjacent tokens inside some sub-block approaches 0, the elements of D blow up, and its inverse is prone to overflow or underflow in low-precision formats such as BF16.
The common industry workaround is to give the diagonal blocks a separate, position-by-position (position-pair) path. That approach has two problems:
- It is an element-wise operation, so it cannot call matrix-multiply acceleration units the way the off-diagonal blocks can.
- Two branches mean two kernels and two backward-pass implementations, multiplying code complexity and maintenance cost.
The case model’s solution is to rework how the decay factor is parameterized. The conventional approach generates a log-decay with Negative-Softplus, g = −softplus(x), where g ≈ x as x → −∞, meaning there is no lower bound at all. The case model instead generates it with a sigmoid scaling:
g_t = g_min · Sigmoid(x_t), x_t is a learned projection or a data-dependent score, g_min = −5 (fixed)
Because the sigmoid output lies strictly in (0,1), the log-decay g_t is confined to the interval (g_min, 0), which corresponds to a per-timestep decay factor α_t ∈ (exp(g_min), 1).
The lower bound of −5 looks like an ordinary hyperparameter, but it is in fact tied directly to the numeric range of low-precision formats. Taking the 16-token sub-block mentioned in the report as an example, the smallest accumulated log-decay inside a sub-block is about 16 × (−5) = −80. Its reciprocal is on the order of exp(80) ≈ 5.5×10³⁴, which still falls within the representable range of BF16 (whose maximum representable value is about 3.4×10³⁸). Even down at exp(−80) ≈ 1.8×10⁻³⁵, the value remains within the BF16 normal range (smallest normal value about 1.2×10⁻³⁸). Neither end underflows to zero or overflows to infinity, so the elements of the inverse matrix stay bounded.
Illustrative code (pseudocode, showing the design idea only):
# ---------- Option A: Negative-Softplus, no lower bound ----------# g = -softplus(x) --> as x -> -inf, g -> -inf, so accumulated# decay inside a sub-block can reach exp(-inf) = 0# ---------- Option B: Sigmoid scaling, with a lower bound ----------G_MIN = -5.0 # fixed lower bound in the log domaindef log_decay(x):# x: learned projection or data-dependent score# output is strictly confined to (G_MIN, 0)return G_MIN * sigmoid(x)# Inside-chunk computation (16 tokens per sub-block here)g = log_decay(x[:16]) # sequence of log-decaysa = exp(cumsum(g)) # cumulative decay: lower bound ~exp(-80) ≈ 1.8e-35D = 1 - tril(a[:, None] / a[None, :], diagonal=-1)D_inv = inverse(D) # largest element ~exp(80), still representable in BF16# Key difference from Option A: diagonal and off-diagonal sub-blocks# follow the same dense matmul path# O_diag = (D_inv @ diag(beta) @ V) * Q# O_off = (Q_weighted @ S_prev) * scale_state
This change brings three benefits:
- Diagonal blocks no longer need a special position-wise path. All sub-blocks, diagonal and off-diagonal alike, can run on matrix-multiply acceleration units, which substantially lowers kernel maintenance cost for both single-device and multi-device scaling.
- The parameterization works equally well for data-dependent gating. The model can freely learn “how much to remember, how much to forget” within
(0,1), keeping selective memory while preserving a safe numerical boundary. - Combined with a design that needs no explicit positional encoding, the model can extrapolate positions directly at 1 million tokens.
The last point is often misunderstood. In linear attention, the accumulated decay itself carries positional information of the form “the farther away, the blurrier,” so position awareness no longer depends on how an explicit positional encoding behaves outside the training range. In theory, therefore, as long as the state-propagation chain remains numerically stable over long sequences, extending beyond the training length requires no additional positional interpolation tricks. This is not a claim that training length and inference length can be pulled arbitrarily far apart; it means that position extrapolation has been reduced to a single dimension: numerical stability.
One caution when reusing this: the lower bound of −5 and the sub-block size are a coupled pair of parameters. The longer the sub-block, the lower the bound on accumulated log-decay (a 64-token sub-block, for instance, corresponds to exp(−320)). If you also insist on BF16, you have to rebalance between longer sub-blocks and a lower bound, and switching to a higher-precision accumulation type may be necessary.
3.2 Gated Multi-Head Latent Attention: Exact Retrieval on a Smaller Cache
The advantage of linear attention is that state size is independent of sequence length. The cost is that history is compressed into a fixed-size state, which is naturally a poor fit for tasks such as “pinpoint a specific span inside a long document” (for example, looking up a particular number across several documents). The case model therefore keeps full softmax attention, in the form of Gated Multi-head Latent Attention.
The core idea of Multi-head Latent Attention (MLA) is to stop caching full keys and values per head. Instead, the input is projected down to a low-dimensional latent c_t, and both keys and values are recovered from c_t through their own projection matrices. During decoding, only the latent needs to be cached, which markedly reduces the memory and bandwidth cost of the KV cache. The gate is typically applied to the attention output: each token first produces a gate vector from its own hidden state, which is then multiplied element-wise with the attention output, letting the model actively suppress the influence of irrelevant context. It can be written as:
c_t = W_c · h_tq_{t,i} = W_{q,i} · c_t, k_{j,i} = W_{k,i} · c_j, v_{j,i} = W_{v,i} · c_jg_t = Sigmoid(W_g · h_t)O_t = Concat_i(softmax(q_{t,i} K_i^T / √d) V_i) · W_o ⊙ g_t
The value of this combination in long-context settings is that each additional stretch of history costs only the storage of the latent, rather than the full KV of “number of heads × head dimension.” At the million-token scale, that difference often determines outright whether long-sequence inference fits within the existing memory budget.
In terms of division of labor, the two attention types are not either/or. Linear attention carries global information at low cost, softmax attention retrieves critical spans with high fidelity, and the gate lets the model adjust the weight between them on demand. This is a fairly typical “hybrid attention” design, and most comparable industry designs follow the same logic.
3.3 Block Attention Residuals: Opening Up the Deep-Representation Bottleneck
In a standard Transformer, every layer has its own attention and feed-forward sublayers, and information passes between layers via residual connections. The deeper the stack, the more visible two problems become:
- Attention results from shallow layers cannot be used directly by deep ones, so deep layers have to “re-discover” similar context relations.
- If every layer retains the intermediate activations that attention requires, memory use during backpropagation is substantial, and in multi-machine training with expert parallelism it also inflates activation communication.
The idea behind block attention residuals is to group several layers into a “block” based on their attention outputs, and let earlier blocks feed information directly to deeper blocks through cross-block residuals, instead of recomputing attention layer by layer. It addresses two classes of problems:
- At the representation level: a deep network is no longer just a monotone transformation of shallow representations. It can reuse the attention results of an earlier block directly, breaking the depth bottleneck where “the deeper you go, the harder it is to use new information.”
- At the system level: some layers can omit the attention sublayer, which correspondingly reduces the retention of intermediate activations and cross-device communication.
It is worth emphasizing that this kind of structure borrows the core idea of residual networks and dense connections, namely giving information a shorter path through depth. The value of the case model here is that it re-evaluates that idea in the context of very large models and long contexts: when sequences are on the order of a million tokens and depth reaches dozens or hundreds of layers, every unit of attention activation and communication saved is amplified by scale into a meaningful resource gain.
4. The Expert Side: Making Trillion-Scale Sparse Models Stable to Train
4.1 Three Stability Risks in Sparse MoE
When the number of routed experts reaches the order of 896, MoE training tends to expose three classes of risk:
- Load imbalance: a few “hot experts” get selected repeatedly while many experts are under-trained, and routing degrades into an approximation of parroting the hot experts.
- Sparse activations and gradients: each token activates only a handful of experts, so any single expert sees few gradient samples, the loss surface is not smooth, and divergence is especially likely early in training.
- Numerical and memory pressure: at the trillion-parameter scale, storing optimizer states, gradients, and activations becomes the bottleneck, and overflow and rounding errors under low precision get amplified layer by layer.
Several of the case model’s designs on the expert side are built around exactly these three risks.
4.2 Latent-Space MoE: Shrinking Expert Capacity to Cut Communication and Memory Overhead
“Latent-space MoE” can be understood as follows: rather than operating directly on the full-width hidden state, the expert network first goes through a down-projection into a lower-dimensional latent space, the experts perform their transformation there, and an up-projection returns the result to the original width. The motivation is the same as for MLA: carrying an equivalent amount of information in a lower-dimensional space reduces expert parameters, activation memory, and expert-parallel communication at the same time.
For an ultra-sparse architecture, the stability gains show up as:
- Optimizer state size drops accordingly, leaving more budget for the “trade memory for stability” tactics common in large-model training, such as larger batches and higher-precision accumulation.
- Communication volume when switching experts decreases, congestion probability for collective operations such as all-to-all drops, and the synchronization overhead caused by routing jitter shrinks as well.
4.3 SiTU-GLU: Keeping Gated Activations Well-Conditioned Under Extreme Sparsity
Mainstream feed-forward networks mostly use a gated linear unit (GLU) structure, whose output is the element-wise product of two linear transforms, one of which passes through an activation function. The activation function determines the scale and distribution of the gradients, and this is especially sensitive under extreme sparsity: if activations stay saturated in certain ranges, tokens routed through that expert receive almost no useful gradient.
SiTU-GLU belongs to the family of GLU variants, and the shared goal of these designs is to preserve nonlinear representational power while obtaining smoother, better-controlled gradient behavior. The value of such designs cannot be judged by per-token loss alone; it has to be judged by overall stability once trillion-scale parameters, sparse routing, and long training cycles are stacked together. An activation function whose differences look minor at conventional scale often sees those differences multiplied several times over under extreme sparsity.
4.4 Quantile Balancing (QB): Dynamic Load Balancing Without an Auxiliary Loss
The conventional approach to load balancing adds an auxiliary loss on top of the main objective, penalizing routing distributions in which “some experts are over-used.” It is simple and direct, but it has two side effects:
- It introduces an extra gradient term that competes with the primary objective and needs repeated tuning to keep the two in balance.
- When the auxiliary-loss coefficient is too large, the model tends to “route in order to balance,” which hurts primary-task performance.
Quantile balancing takes a different route: skip the auxiliary loss and adjust the routing scores directly. A bias term is added to each expert’s routing score and adjusted dynamically according to the quantile at which each expert’s actual load sits: experts whose load is above a high quantile get their bias lowered, and experts whose load is below a low quantile get their bias raised.
# ---------- Quantile balancing: adjust routing bias only, no auxiliary loss ----------# load: number of tokens each expert received this step (can be aggregated# into a global load via cross-device all-reduce)# bias: term added to the routing score; it affects selection only and is# not updated by gradientsdef quantile_balancing(load, bias, q_hi=0.75, q_lo=0.25, eta=1e-3):hi = quantile(load, q_hi) # e.g. the 75th percentilelo = quantile(load, q_lo) # e.g. the 25th percentileover = load > hiunder = load < lobias = bias + eta * (under.astype(float) - over.astype(float))return bias# Routing scoresscore = router_logits(x) + bias # the bias changes top-k selection onlyexpert_idx = topk(score, k=2)weights = softmax(router_logits(x).gather(expert_idx)) # combine with raw scores
QB is in the same lineage as the auxiliary-loss-free load balancing used in DeepSeek-V3: both turn balancing from a “loss term” into online feedback control over routing biases. What differs in the case model is that it uses quantiles rather than a simple mean to measure “overload,” which makes the feedback more robust when expert counts are large and the distribution is long-tailed. A mean is easily pulled up by a few extreme experts, whereas a quantile better reflects the real water level of the majority.
Three implementation points matter in practice:
- The bias update is a gradient-free online rule that pairs naturally with parallel training, but load statistics have to be synchronized across devices, or the biases will drift apart between them.
- The bias magnitude (
η) needs a decay schedule so that it converges gradually in later training, avoiding continued routing jitter. - The combination weights use the raw routing scores rather than the bias-adjusted scores, so the balancing mechanism does not affect the relative weights of the selected experts.
A schematic curve (illustrating the mechanism only, not measured data):
Expert load (relative)1.2 | ╭────╮ expert 8121.0 |·······························╯ ╰········· average load0.8 | ╭─╮0.6 | ╭───╯ ╰───╮ ╭────╮0.4 |──╯ ╰────────╯ ╰─────────── remaining experts+---------------------------------------------------> training stepPhase 1: load imbalance QB keeps lowering the hot experts' bias Phase 2: converging toward balance
5. The Training Pipeline: Context Curriculum and Agentic Reinforcement Learning
5.1 Multi-Stage Context Extension: From 8K to 1M
The case model extends its context in stages during pre-training, in the order 8K → 64K → 256K → 1M. This arrangement follows the general pattern of large-model training:
- Pre-training directly on million-token sequences makes attention cost grow quadratically with sequence length, so compute and time costs become hard to bear.
- Training signal for long-range dependencies is sparse, and early in training the model struggles to learn relations that span large stretches of text.
- Staged extension is effectively a form of curriculum learning: the model first builds a foundation in language and knowledge under short contexts, then learns level by level to stay consistent over longer distances.
Three things generally need attention at stage transitions:
- Positional encodings and extrapolation methods have to match the new context length; the positional distribution learned in a short stage cannot be applied unchanged to a long one.
- Data mixtures have to be adjusted per stage: longer stages need a higher proportion of long-range samples such as long documents and code repositories, while retaining some short samples to guard against capability regression.
- After each stage, run a length-extrapolation evaluation on representative long tasks to confirm that capability transfers smoothly with length rather than collapsing abruptly at some point.
5.2 Million-Token-Scale Agentic Reinforcement Learning
Pre-training gives the model the ability to read long inputs, but whether it can use them well depends on post-training. The case model adds million-token-scale agentic reinforcement learning on top, where the training trajectories themselves are ultra-long contexts. Compared with conventional reinforcement learning, this kind of training has three particular characteristics:
- A single trajectory routinely contains dozens of tool calls and intermediate results, with token counts easily reaching the six figures.
- Rewards usually arrive only when the task ends (whether it was completed, whether the answer was correct), which is a classic case of sparse reward.
- Errors inside a trajectory accumulate along the chain, and a single bad step can fail the whole trajectory.
Typical countermeasures include:
- Use policy-optimization methods based on within-group comparison, estimating advantages from the relative performance of multiple trajectories on the same task, which reduces reliance on absolute value estimates.
- Set constraints or penalties on things like the argument formatting of tool calls and trajectory length, so the model avoids shortcuts that “look plausible but cannot execute.”
- Split multi-turn trajectories into reusable segments for training, easing the memory and sampling cost pressure of long trajectories.
- Introduce process-level rewards (for example, whether an intermediate step retrieved the right information) to mitigate the credit-assignment problem under sparse rewards.
Agentic reinforcement learning and long-context capability reinforce each other in both directions. A long-context model can hold a more complete task trajectory, while reinforcement learning teaches the model when to retrieve, when to call a tool, and when to converge on a conclusion. That is precisely the leap that takes long context from “can read” to “can use.”
6. Engineering Takeaways: What Developers Can Reuse
Most teams do not need to copy a trillion-parameter architecture, but several designs in the case model have general engineering value:
- Prefer numerically safe parameterization over after-the-fact patching. Baking “decay and gates must be bounded” into the activation design is more thorough than adding clipping or special branches inside a kernel.
- Unifying diagonal and off-diagonal blocks onto a single matmul path is the key to production-grade linear attention performance; it is worth doing while building custom kernels rather than later.
- Prefer auxiliary-loss-free load balancing. Bias-plus-feedback schemes like QB are simple to implement and have few side effects, making them a good first thing to try when expert counts are large.
- Cross-layer and cross-block information reuse improves representation and system overhead at the same time, and is one of the structural optimizations most worth trying early in long-context models.
- Long-context capability needs curriculum-style training paired with length-extrapolation evaluation. Do not expect a single stage to get you there in one step.
If you want to run this kind of training or inference in the cloud, the requirements can be decomposed into a few general capabilities:
- Object storage to hold massive pre-training corpora, long documents, and trajectory data.
- A container platform to orchestrate multi-machine, multi-GPU training and inference jobs elastically.
- Logging, monitoring, and alerting to continuously track metrics such as loss, expert load, memory, and throughput, so numerical anomalies and routing drift in long-context training can be located quickly.
7. Limitations and Outlook
There are boundaries in the case model that deserve a sober look:
- With activated parameters at only about 3.7% of the total, inference deployment places very high demands on memory, parallel sharding, and expert-routing schedules, and small teams will find its deployment shape hard to replicate in the short term.
- Mixing linear and softmax attention requires careful tuning; an imbalanced ratio between the two degrades long-range exact retrieval.
- QB is sensitive to the choice of quantiles and to the bias update rate, and its effect weakens when there are fewer experts.
- Agentic reinforcement learning depends on high-quality task trajectories and a reliable tool environment, and designing the environment and the rewards often takes more effort than the algorithm itself.
- Evaluating long-context capability still requires vigilance about the “effective length” problem. Doing well on retrieval-style benchmarks is not the same as being equally reliable in reasoning quality on real long-horizon tasks.
Looking further ahead, attention efficiency (linear, sparse, hybrid), sparse expert scale, context length, and agentic capability are converging into a unified design space. For developers, rather than chasing the number on any single parameter, it is more productive to focus on engineering mechanisms that can be verified: numerically stable parameterization, reusable cross-layer information, controllable load feedback, and long-range capability that can actually be measured. At whatever model scale, these mechanisms deliver returns you can count on.
