Linear Attention MoE LLMs: How to Evaluate Three Core Design Techniques

    This article examines three design techniques that recur in large language models combining linear attention with ultra-scale mixture-of-experts (MoE) for long-context support: lower-bound decay parameterization, quantile load balancing, and chunked attention residual. It explains the real bottleneck each technique addresses, which layer each one changes, and what new constraints each introduces. Readers will find the underlying motivation (quadratic attention cost, linear KV-cache growth, and MoE load imbalance), the mechanism and mathematical reasoning behind each technique, engineering reuse checklists, a side-by-side comparison, and a three-step framework for judging any new architectural design. The core takeaway: start from the bottleneck, make the smallest change that secures the most certain benefit, and prepare observable, rollback-ready engineering measures for every trade.

    1. The Bottom Line: How to Read These Three Designs

    Every generation of LLM architecture is, at its core, answering the same question: how to achieve sufficiently long context, sufficiently large parameter capacity, and sufficiently strong representational power under limited compute, memory, and interconnect bandwidth. A recently published large language model technical report combines linear attention with ultra-scale mixture-of-experts (MoE) to support very long context. Three of its designs are highlighted as the most reusable: lower-bound decay parameterization, quantile load balancing, and chunked attention residual.

    Judging designs like these has little to do with how novel they sound. What matters is whether they can answer three questions: What real bottleneck does it solve? Which layer does it change? What new constraints does it introduce? This article takes each design in turn.

    Technique Layer affected Core bottleneck Scope of change Reuse value Prerequisites for adoption
    Lower-bound decay parameterization Operator and numerical precision The decay factor overflows/underflows under chunked parallelism, and the diagonal block cannot use matmul acceleration Minimal, a single parameterization swap High Compute numerical bounds for the target precision and chunk size
    Quantile load balancing Distributed training Skewed expert load, and the auxiliary loss interferes with the main task Small, an online correction to routing scores High Global statistics sync, bias-magnitude constraint, and monitoring
    Chunked attention residual Model structure Deep representation bottleneck, memory and communication cost Moderate, a structure-level change Medium-high Medium-scale ablation validation

    Overall, the first two deliver certain benefits at controllable cost and are worth trying first. The third’s benefit and cost both depend on model scale and parallelism strategy, so it should be gated on experimental validation.

    2. Background: Why These Three Techniques Appear Together

    To understand these three designs, first look at the three pressures they jointly face.

    1. Attention compute grows quadratically. The cost of standard self-attention grows with the square of sequence length. For causal attention, ignoring the scaling factor:

    1. FLOPs ≈ 2 * B * H * L^2 * d / 2 = B * H * L^2 * d

    where B is batch size, H is the number of attention heads, L is sequence length, and d is the per-head dimension. The division by 2 comes from the causal mask: on average each query can only see half of the keys. Going from 4K to 256K, the length grows 64x and this term grows to roughly 4096x.

    2. The key-value cache grows linearly. During decoding, every position must cache its key and value, using 2 * B * H * L * d * dtype_bytes of memory. Going from 4K to 1M context, this term grows 256x as well.

    3. MoE load is uneven. MoE splits the feed-forward layer into multiple experts, activating only a few per token to trade sparsity for parameter capacity. Under expert parallelism, each expert sits on a different device, so once the routing distribution skews, the device holding a hot expert becomes the shortest stave in the barrel and the rest can only idle and wait. Meanwhile, the all-to-all communication between devices sends each token to the device holding its selected expert, and is a well-known cost driver in training.

    This architecture is a direct response to those pressures:

    • Most layers use linear attention (including Delta-rule variants), where both computation and state update grow linearly with sequence length, and decoding only maintains a fixed-size recurrent state;
    • A few layers keep standard attention to provide precise retrieval;
    • The feed-forward layers use ultra-scale MoE to trade controllable activation compute for parameter capacity.

    But lower-complexity linear attention only delivers its promise when the operator implementation is efficient enough. MoE only fully exploits device compute when the load is balanced enough. And a deeper model only adds cost if the deep layers fail to learn anything new. These three hurdles map to three layers, and give rise to the three designs below.

    3. Lower-Bound Decay Parameterization: Making Linear Attention “Fast and Faithful”

    3.1 The Problem: The Reciprocal of the Decay “Explodes,” So the Diagonal Block Gets Its Own Path

    For intuition, here is a simplified recurrence for the linear-attention state update without the Delta rule:

    1. S_t = Diag(a_t) @ S_{t-1} + v_t k_t^T, o_t = S_t q_t

    Here S_t is the recurrent state matrix of shape d×d; k_t, v_t, and q_t are the key, value, and query vectors of the t-th token. a_t∈(0,1) is a per-token decay coefficient that controls how fast the old state is forgotten.

    To improve long-range memory, one family of methods adds a gated decay mechanism that writes the coefficient as a_t = exp(g_t):

    • When g_t is close to 0, the state barely decays, equivalent to long memory;
    • The more negative g_t is, the faster the forgetting and the stronger the short memory.

    The problem shows up in the chunked-parallel computation during training. A causal sequence can be split into fixed-length chunks; the state transitions within each chunk are independent and can be batched, and chunks are then stitched together with one scan recurrence. The within-chunk output needs the cumulative term of relative decay: between an offline chunk in and an online chunk out, the coefficient is exp(Σ g). From the offline chunk’s point of view, the influence of every token in the online chunk is re-amplified by exp(-Σ g) — this factor is the reciprocal of the decay. If g_t can approach negative infinity without bound, Σ g can be arbitrarily small, and its reciprocal must overflow under finite precision.

    Batched implementations usually handle this in one of two ways:

    • Accumulate the decay as a negative log, do the matmul in the log domain, and take the exponential once at the end;
    • Compute exp(Σ g) per token and then do an element-wise multiply.

    Neither avoids the exponential. Underflow drives the state to zero; overflow yields Inf or NaN.

    In practice this is usually dodged with chunking and truncation, at the cost that the diagonal block (where query and key fall in the same chunk) cannot be written as a pure matmul. The reason: within a chunk, the earliest and latest tokens span the widest decay range, so the cumulative term is most prone to underflow and must switch to a per-position pairwise computation (the position-pair path). Such implementations cannot fully use tensor cores, or require a custom kernel. The more branches and special paths there are, the harder it is to guarantee efficient operator execution on a GPU.

    The original scheme parameterizes log-decay with Negative-Softplus, whose theoretical lower bound is negative infinity. That is natural mathematically but, in engineering terms, pushes the numerical-safety problem down to the implementation layer.

    3.2 The Mechanism: Confining Log-Decay to an Interval with a Lower Bound

    The change can be summarized as:

    1. Log-decay: Negative-Softplus(w·h_t) → g_min * Sigmoid(a·w·h_t + b)

    With g_min = -5, the output falls in (g_min, 0):

    • The lower bound corresponds to the fastest forgetting: a single step multiplies by at most exp(-5)≈0.0067, preventing log-decay from drifting toward negative infinity;
    • The upper bound 0 corresponds to no forgetting: as the Sigmoid saturates, g_t→0, and long memory is preserved;
    • Learnable slope a and bias b control the overall forgetting speed: a larger a saturates to the extremes more easily; b can be initialized negative so forgetting is stronger early in training, which suits long-sequence learning.

    Using the maximum allowed decay rate to define an effective memory length:

    1. H = -1 / ln(min a) = 1 / |g_min|

    With g_min fixed at -5, H is about 0.2 tokens. That is, the model can freely tune memory duration between 0.2 and infinity. This bound is not arbitrary — it must guarantee that, within a fixed-size chunk, the reciprocal of the decay always stays in a safe range.

    3.3 The Math: Why a Lower Bound Removes the Numerical Hazard

    Let the chunk size be L and the cumulative decay of the t-th token be Γt = exp(Σ{i≤t} g_i). Since each g_i∈(g_min, 0):

    1. exp(L * g_min) ≤ Γ_t < 1
    2. 1 < 1/Γ_t ≤ exp(-L * g_min) = exp(L * |g_min|)

    Numerical safety requires 1/Γ_t not to exceed the maximum representable value M of the target format:

    1. L * |g_min| ≤ ln(M)

    bfloat16 and float16 are both 16-bit but allocate bits differently: the former uses 8 exponent bits and 7 mantissa bits, the latter 5 exponent bits and 10 mantissa bits. Their maximum representable values differ by 19 orders of magnitude:

    Numeric format Max representable value ln(M)
    bfloat16 ≈3.39×10^38 ≈88.7
    float16 65504 ≈11.1

    Plugging in L=16, g_min=-5, we get 16×5=80:

    • Under bfloat16, 80<88.7, leaving about 10% headroom, so both diagonal and off-diagonal computations of a 16-token chunk need no special handling and can use matmul instructions directly;
    • Under float16, 80 far exceeds 11.1, and the headroom requirement cannot be met. If you still want 16-token chunks, |g_min| must be no more than 11.1/16≈0.7.

    This example reveals a frequently overlooked fact: whether a parameterization is feasible is fundamentally a matching problem between it and the target numeric format and chunk size. Change the precision and you must recompute the parameters.

    Worth noting: the lower bound also caps the model’s forgetting-speed limit. If a business scenario requires “complete forgetting within one step” (e.g., resetting the state at document boundaries), a single global g_min may not suffice, and you also need document-level resets or stronger state constraints.

    3.4 The Benefit: Diagonal and Off-Diagonal Share One Fast Path

    The original idea is to have every causal block — diagonal or off-diagonal — call the same dense matmul. The benefit shows up at three levels:

    1. Operator level. Removing the special branch for the diagonal block leaves the kernel with a single main path. This makes constant folding, instruction scheduling, and register planning easier, getting closer to peak hardware throughput;
    2. Parallelism and memory level. Chunking produces more uniform parallel granularity and more regular memory access patterns, making operator fusion and memory reuse easier;
    3. Long-context level. The original claims this mechanism naturally supports a no-positional-encoding setup that extrapolates to million-token context. This deserves a measured view:
      • The recurrent form of linear attention has no inherent max-length limit;
      • Without explicit positional encoding, positional information is mostly encoded implicitly by the data-driven decay;
      • But “can extrapolate” is not the same as “effective after extrapolating.” Long-context quality still depends on whether positional information is sufficiently encoded implicitly, and on whether the retrieval-strong standard-attention layers are distributed sensibly;
      • Structural extrapolation ability must be tested in long-context evaluations, not inferred from complexity alone.

    3.5 Reuse Checklist: Minimal Change, Maximum Benefit

    Reusing this design only requires changing the decay parameterization, yet the benefit lands directly on compute utilization, making it the most certain of the three:

    • Confirm that training and inference precision is bfloat16; if you use float16 or a lower-precision format, recompute chunk size and g_min;
    • Hard-code the chunk size and decay lower bound in the code, to avoid independent tuning of the two causing an out-of-range condition;
    • During backprop, compute gradients for the exponential and its reciprocal separately, and check that the gradients, like the forward pass, stay in the safe range;
    • Keep the recurrence of the chunked scan on the same numerical convention as the chunked matmul, to avoid a precision seam at the boundary.

    4. Quantile Load Balancing: Turning “Balance” from a Goal into a Process

    4.1 The Problem: The “Seesaw” of the Auxiliary Loss

    Classic MoE (going back to the sparsely-gated MoE of 2017) generally uses a load-balancing auxiliary loss:

    1. L_aux = alpha * N * sum(f_i * P_i)

    where N is the number of experts, f_i is the fraction of tokens assigned to expert i, P_i is expert i’s average routing probability, and alpha is the weight. Its flaws are structural:

    • Two objectives pull against each other. Too large an alpha, and routing sacrifices model quality for “good balance,” tending to send tokens to weaker experts; too small, and it cannot suppress skew;
    • Parameter sensitivity. The optimal alpha depends on model scale, expert count, and data distribution, and often needs re-tuning when moved to a new configuration;
    • Explicit gradient conflict. The auxiliary loss adds directly onto the routing gradient, entangling with the main task’s optimization direction in ultra-scale training;
    • A need to fade out. In practice alpha is often reduced or even removed late in training, introducing an extra scheduling hyperparameter.

    This motivated auxiliary-loss-free approaches: treat the bias on the routing score as an online-tunable control variable. If an expert is overloaded, lower its bias; if underloaded, raise it. Quantile balancing builds on this, updating the bias with respect to a chosen quantile of the expert load.

    4.2 The Mechanism: Using a Quantile as an “Adaptive Yardstick”

    The control loop can be summarized as:

    1. Count the tokens assigned to each expert within a window to get the load distribution;
    2. Take a target quantile of that distribution as the reference (e.g., the median);
    3. Update each expert’s routing bias according to the gap between the reference and the expert’s actual load;
    4. The updated bias enters the routing score and influences the next expert selection.

    Illustrative pseudocode:

    1. # Illustrates the control logic only; implementation must fit the specific framework
    2. bias = zeros(num_experts) # routing bias, initialized to 0
    3. for step in training_steps:
    4. probs = softmax(router_logits, dim=-1)
    5. # top-k routing: select experts by biased score, weight by original probability to keep the forward pass unbiased
    6. topk_idx = topk(probs + bias, k)
    7. topk_w = gather(probs, topk_idx)
    8. topk_w = topk_w / topk_w.sum(-1, keepdim=True)
    9. # count tokens assigned to each expert within the window
    10. load = bincount(topk_idx) / (num_tokens * k)
    11. target = quantile(load, 0.5) # median as the reference, illustrative value
    12. bias += update_rate * (target - load)
    13. bias = clamp(bias, -max_bias, max_bias) # constrain magnitude to avoid over-suppression

    From a control-theory view, this is a discrete-time integral controller: the current bias equals the accumulated historical error. Mathematically the static router can be understood as “an integrator of error times the sampling interval,” and the bias plays a role similar to the integral term in an incremental PID algorithm.

    Why a quantile instead of the mean? There’s a line often quoted in attention: “if you use attention, you have to pay attention.” The same holds for MoE routing: the mean gets pulled up or down by a few extreme hot experts. Using the median as the reference keeps more than half of the experts’ load on one side, then lets the bias push the distribution toward balance; meanwhile, outlier experts in the upper and lower tails deviate farther from the reference and get a stronger adjustment signal. The reference quantile is configurable to control “how many experts are allowed to deviate from the target.”

    One more detail: the bias is used only for selection, not for the forward output weighting. Otherwise a “boosted” expert would be amplified further by its bias, breaking the mathematical unbiasedness of the forward pass.

    4.3 The Benefits: Three “No”s

    • No contamination of the main objective. The bias does not participate in backprop, the computation graph for routing quality matches standard MoE, and the main-task gradient no longer mixes in the balancing constraint;
    • No reliance on late-training scheduling. Balancing is done online by the controller, with no need to design an annealing schedule for the auxiliary loss;
    • Relative robustness to hyperparameters. The controller’s gain mainly affects convergence speed, and the reference quantile only sets balancing strength, so there’s no need to trade off quality against balance repeatedly as with alpha.

    These three points matter especially for ultra-scale MoE: the larger the model, the higher the cost of re-tuning and trial and error.

    4.4 Engineering Points: Auxiliary-Loss-Free Is Not Risk-Free

    • Statistics must be global. Under data parallelism, every device must share the same view of global load; otherwise different replicas push opposite biases on the same expert, they cancel out during iteration, and the control loop fails. Under expert parallelism, also account for the extra communication of bias sync — typically aggregate load across ranks and update uniformly;
    • Constrain the bias magnitude. Clamping the bias to bounds prevents an expert from being over-suppressed and “starved,” and also prevents an expert from being persistently boosted into chronic overload;
    • Consider long-range distribution drift. The topic distribution of pretraining data changes over time, and the control loop’s tracking speed must match. Use a sliding window for load statistics, and balance window length against update step size: too short a window and statistical noise is high; too long and it can’t keep up with drift;
    • Keep capacity factor as a backstop. Load balancing is statistical in nature. Instantaneous crowding can still occur within a single batch, and tokens that exceed an expert’s capacity get dropped. This loss depends on the capacity factor, batch size, and task characteristics — not on the balancing strategy;
    • Add monitoring. Track four metrics: the coefficient of variation of per-expert load, the ratio of max load to median load, the absolute value and rate of change of the bias, and the token-drop rate. They also serve as the basis for judging whether the balancing strategy is working or over-suppressing.

    5. Chunked Attention Residual: Redistributing Information Along Depth

    5.1 The Problem: There Is Only One Residual Stream

    A standard Transformer treats the residual stream as a single-lane main trunk, and every layer’s sublayer outputs add back to the same trunk:

    1. x_{l+1} = x_l + Attn(LN(x_l)) + FFN(LN(x_l + Attn(LN(x_l))))

    This design is simple and efficient, but has two structural limits along depth:

    1. Information overwrites itself. As layers stack up, the residual stream is continuously overlaid with new information, and early local features (like word form and local collocations) are easily diluted. When a deep module wants to use concrete details from a shallow layer, it can only get them indirectly through this already-mixed trunk — what the original calls the “deep representation bottleneck”;
    2. High storage and communication cost. Backprop needs each layer’s forward input; once layers are split across devices (e.g., pipeline parallelism), inter-layer activations must also be transferred between devices. The more layers, the greater the memory and communication pressure.

    Prior improvements mostly use cross-layer shortcuts that send shallow outputs straight to deep layers. This eases information dilution but introduces many inter-layer connections into the computation graph. In pipeline parallelism, cross-device dependencies break the clean boundaries between stages, increasing bubbles and complicating scheduling.

    5.2 The Mechanism: Self-Contained Within a Chunk, Selective Communication Across Chunks

    Chunked attention residual raises the depth-direction “trunk” from single-layer granularity to chunk granularity:

    • Within a chunk. A chunk is a self-contained compute unit; layers within it still stack in the standard way, with normal residuals between them;
    • Across chunks. Besides receiving the previous chunk’s output, each chunk also extracts information from a “chunk summary” aggregated over the current and previous chunks, then fuses it with the trunk;
    • Hierarchy. At the chunk level, this forms a multi-level residual connection rather than one flat chain of layers.

    This idea is akin to hierarchical feature fusion in convolutional networks: shallow layers lean toward local detail, deep layers toward global semantics, and multi-level fusion lets deep layers use shallow representations directly too. A sketch:

    1. blocks = [Block_1(x0), Block_2(x1), ..., Block_N(x_{N-1})]
    2. for i in range(N):
    3. # chunk i: input is the trunk output plus the chunk summary
    4. summary_i = BlockSummary(h_0, ..., h_{i-1}, x_i)
    5. x_{i+1} = Block_i(x_i, summary_i)
    6. def BlockSummary(h_prev, x):
    7. K, V = [Proj(h) for h in h_prev] # historical chunk summaries as keys/values
    8. return Attn(Q=Proj(x), K=K, V=V) # current chunk output as query

    BlockSummary here is illustrative; the summary can come from earlier chunks’ outputs, or from a chunk’s attention outputs or intermediate states.

    5.3 The Benefits: Memory, Communication, and Expressiveness

    • Memory and communication organized by chunk. Intermediate results are stored and transferred across devices at chunk granularity:
      • Within-chunk activations can be recomputed per chunk, keeping only chunk-boundary inputs for backprop;
      • Cross-chunk dependencies happen at chunk boundaries, at coarse granularity, easy to coalesce for communication;
      • In pipeline parallelism, each stage maps to several chunks, giving cleaner split boundaries;
    • Stronger expressiveness. Deep layers can directly query shallow chunk summaries, easing the “deep layers forget local detail” problem; meanwhile a cross-chunk query is essentially a shallow cross-layer attention, giving the model an explicit cross-depth information path;
    • Synergy with linear attention. The recurrent state rolls forward within a chunk, and information passes across chunks via summaries, forming a “within-chunk temporal + across-chunk information” division of labor.

    5.4 Costs and Constraints: Think Them Through Up Front

    • The summary “information bottleneck.” Too small a summary loses key details; too large and compression and communication costs rise. Summary dimension needs ablation to balance;
    • Number of cross-chunk communications. If every chunk reads all previous chunks’ summaries, communication count grows with chunk count. In practice you can read only summaries within a fixed window, or aggregate once every few chunks;
    • Fit with MoE and pipelines. Place summary aggregation points at device boundaries so they align with the parallel split;
    • Implementation complexity. Compared with the first two, this is a structure-level change. The training framework’s forward, backward, recompute, and parallelism strategies all need adaptation, and regression-test cost is clearly higher.

    6. Side-by-Side Comparison and Selection Advice

    Dimension Lower-bound decay parameterization Quantile load balancing Chunked attention residual
    Layer changed Parameterization / operator Routing strategy / training loop Model structure
    Code change size Minimal Small Moderate
    Certainty of benefit High High Medium-high, depends on scale and task
    Main risk Precision-chunk mismatch Unsynced load statistics, bias overshoot Implementation complexity, summary-capacity tradeoff
    Suggested validation Numerical-boundary tests + operator performance benchmark Load-metric monitoring + training-stability comparison Medium-scale ablation

    When rolling out, rank by “change cost, certainty of benefit, implementation risk”: do low-risk, high-certainty changes first, then use experimental data to test the high-risk ones.

    7. A Reusable Evaluation Framework: Judging an Architectural Design in Three Steps

    Though different in form, these three designs share a methodology. For any new architecture, judge it in three steps:

    1. Is the bottleneck real? Estimate the magnitude from first principles. For example, use B * H * L^2 * d and 2 * B * H * L * d * dtype_bytes to estimate attention’s compute and memory growth, and use the coefficient of variation of expert load to judge whether skew is really present;
    2. Which layer does the change land on? Operator, training strategy, or model structure? The shallower the layer, the more certain the benefit and the smaller the regression risk;
    3. What is the cost? Every design makes a trade: lower-bound decay parameterization trades a “forgetting-speed cap” for “numerical safety”; quantile load balancing trades “online-control complexity” for “no tuning, no auxiliary loss”; chunked attention residual trades “implementation complexity and summary bandwidth” for “a clearer deep information path and cleaner parallel boundaries.”

    The same framework applies to bringing such designs into training and inference on Baidu AI Cloud:

    • Operator-level changes can rely on a container platform, distributing and versioning quickly as images;
    • Load metrics can plug into logging and monitoring/alerting services, setting threshold alerts on expert-load deviation and bias-magnitude changes;
    • Training artifacts and checkpoints can be stored in object storage for easy experiment reproduction and version rollback.

    8. Evaluation Advice: Don’t Be Fooled by a Single Metric

    The effect of an architectural design should be validated across multiple dimensions. Suggested coverage:

    • Numerical validation. Build test sequences containing extreme decay values, compare linear-attention output error against a full-attention reference under bfloat16, focusing on chunk boundaries;
    • Long-context retrieval. Use synthetic retrieval tasks (like locating specific information in long text), evaluated across different context lengths and depths;
    • Load balancing. Compare the coefficient of variation, the max-to-median load ratio, and the drop rate before and after;
    • Compute utilization. Use operator benchmarks for throughput, and take vendor-tool-measured actual utilization (like a GPU’s SM utilization) as a reference, to distinguish “saved memory” from “ran faster”;
    • Perplexity decomposition. Split overall perplexity into token-level and long-range parts, to judge whether capacity gains come from stronger memory or worse balance.

    9. Summary

    Lower-bound decay parameterization, quantile load balancing, and chunked attention residual act on three layers — operator, distributed training, and model structure — forming a mutually reinforcing set:

    • Lower-bound decay parameterization makes linear attention truly “computable”;
    • Quantile load balancing makes ultra-scale MoE truly “splittable”;
    • Chunked attention residual makes deep networks truly “propagate deeply.”

    For developers, more important than remembering these three names is the mindset behind them: start from the bottleneck, use the smallest change to leverage the most certain benefit, and prepare observable, rollback-ready engineering measures for every trade. As architecture evolution accelerates, what endures round after round of technical updates is exactly this bottleneck-driven, data-grounded evaluation ability.