Optimizing LLM Architecture: Linear Attention, Load Balancing, and Residual Design
This article examines three common system bottlenecks in modern large model architecture—attention cost as sequences grow, expert load imbalance in Mixture-of-Experts models, and information reuse across deep layers—and analyzes three corresponding design directions: bounded decay for numerically stable linear attention, quantile-based load balancing for expert routing, and block-level attention residuals for selective cross-depth information reuse. It explains the underlying mechanisms, engineering risks, and trade-offs of each approach, and outlines a staged validation process covering numerical correctness, operator-level performance, training quality, and combined effects, helping developers evaluate architectural choices under concrete precision, hardware, data, and task constraints.
1. Evaluating Model Architecture: Start with Three System Bottlenecks
When assessing the technical value of a new generation of large models, the most meaningful question is not “how many new modules it uses,” but whether those modules solve real bottlenecks—and at what cost.
From training and inference practice, three categories of problems deserve particular attention:
First, as sequences grow, attention computation and intermediate state storage can quickly become the dominant cost. Linear attention attempts to compress historical information into a recurrent state, but whether its mathematical formulation maps stably onto matrix compute units directly affects real-world efficiency.
Second, although Mixture-of-Experts (MoE) models activate only a subset of parameters, they are prone to uneven expert loads. When some devices are overloaded while others sit idle, theoretical compute savings fail to translate into end-to-end gains.
Third, as networks grow deeper, information must pass through many inter-layer transformations. Standard residual connections improve optimization, but they do not guarantee that representations at every depth can be fully utilized by later layers.
Bounded decay, quantile-based load balancing, and block-level attention residuals correspond to these three problems respectively. However, they should be treated as independently researchable and separately verifiable design directions—not as a bundle of performance claims that necessarily hold together.
2. Bounded Decay: Giving Linear Attention Both Memory and Numerical Stability
2.1 Why the Recurrent State Needs Decay
A class of linear attention can be described with a simplified state recurrence:
St = α_t S{t-1} + U_t
Here, S_t is the current state, α_t is the retention coefficient for the historical state, and U_t is an update term derived from the current input. Real models may use vector- or matrix-form gating, or add more complex state corrections, but the core idea is similar: compressing history into a fixed-size state.
Typically:
α_t = exp(g_t), with g_t ≤ 0
This keeps α_t between zero and one, so historical information decays gradually over time. A g_t closer to zero corresponds to a longer memory horizon, while a large negative value favors faster forgetting.
The problem is that a recurrence that looks stable in its serial form does not guarantee that all intermediate quantities in its parallel implementation are stable.
2.2 The Risk Comes from Intermediate Expressions in Parallel Rewriting
To improve training throughput, engineering implementations often chunk the sequence and convert part of the recurrent computation into matrix multiplications. This can introduce cumulative decay terms:
Γ_t = exp(Σg_i)
Certain equivalent transformations also involve the reciprocal of Γ_t, or the ratio of two prefix-cumulative quantities.
When the cumulative log-decay becomes very negative, Γ_t may underflow, and its reciprocal may overflow. Even if the final mathematical result lies within a reasonable range, intermediate expressions may lose precision first.
Therefore, three things must be distinguished:
- Whether the recurrent form is stable;
- Whether the chunked parallel expression is stable;
- Whether the specific data types and hardware implementation are stable.
None of these can substitute for the others.
2.3 How Bounded Parameterization Reduces Risk
A general approach is to replace a negative-valued parameterization with no fixed lower bound by a bounded mapping, for example:
g_t = -c · sigmoid(z_t), c > 0
where z_t is a real number produced by the model, and c controls the maximum magnitude of the per-step log-decay. It follows that:
-c < g_t < 0
If a local block contains B positions, then in the worst case, the magnitude of the cumulative log-decay within the block is bounded by cB. For implementations that need to compute inverse scaling, the dynamic range can thus be estimated in advance.
The value of this design is not that intermediate values become “inherently safe,” but that the numerical range becomes analyzable and verifiable instead of uncontrolled.
One caveat is especially important: if the implementation still uses prefix-cumulative quantities spanning the entire long sequence, local boundedness does not automatically guarantee global safety. Block-level resets, normalization strategies, and computation order still matter.
2.4 Parameter Bounds Must Be Co-Designed with Precision
BF16 has an exponent range close to common single-precision floating-point formats, but fewer significant bits; other low-precision formats may have different range and precision constraints. Therefore, “using low precision” cannot be simplistically equated with “inevitable underflow.”
A sound design process is:
- Specify the data types used for scaling, exponentiation, multiply-add, and accumulation respectively;
- Derive the worst-case range of intermediate values within a local block;
- Check the type conversion points before and after matrix computation;
- Measure how error varies with sequence length and decay strength;
- Where necessary, use higher-precision accumulation or local rescaling.
At the same time, c is not “the smaller the better.” An overly conservative decay range may limit the ability to forget quickly, changing the model’s trade-off between local patterns and long-range dependencies.
2.5 Whether Diagonal Blocks Can Be Unified into Matrix Computation Still Requires Operator Validation
In chunked causal computation, diagonal blocks contain intra-block sequential dependency constraints, while off-diagonal blocks represent the influence of historical blocks on the current block. The two may be handled differently.
Bounded decay can potentially simplify scaling logic and reduce some special numerical handling, but it does not eliminate the causal mask, nor does it by itself prove that all blocks can execute with equal efficiency.
Actual gains also depend on:
- Whether an algebraic decomposition suitable for matrix multiplication exists;
- The proportion of masking and auxiliary operations;
- Block size and state dimension;
- The read/write cost of intermediate results;
- Thread scheduling, data layout, and compute unit utilization.
Therefore, when evaluating this kind of optimization, both operator-level latency and end-to-end latency should be reported. One cannot infer a large throughput improvement merely from a cleaner formula.
3. Quantile-Based Load Balancing: Turning Expert Routing into a Feedback Control Problem
3.1 Expert Selection and Device Utilization Are Not Naturally Aligned
MoE models typically use a router to select a small number of experts to compute for each input. The router tends to prefer experts with higher current scores, which can cause a few experts to remain persistently congested.
The consequences go beyond uneven computation: they include communication hotspots, increased waiting time, and token dropping or rerouting when capacity is exceeded.
A common approach is to add a load-balancing auxiliary loss to the training objective, but the auxiliary objective may compete with the main task objective. An alternative is to directly regulate how many inputs each expert receives through dynamic routing corrections.
3.2 Quantiles Provide a Basis for Adjusting Acceptance Ratios
Suppose an expert receives a set of candidate routing scores within a statistical window. If we want to control the proportion of inputs it accepts, we can set a threshold based on a quantile of the score distribution.
Intuitively, when an expert is overloaded, raise its acceptance threshold; when it is underloaded, lower the threshold. Another form is to maintain an updatable routing bias per expert that adjusts the raw scores.
Quantiles are not the only implementation here—they represent a class of approaches that use distributional information to regulate selection ratios. Exactly how thresholds are computed, how often they are updated, and whether cross-device aggregation is needed must all be specified explicitly.
“Auxiliary-loss-free” also does not mean “no extra mechanism.” Statistical windows, bias states, communication, and control logic all carry their own costs.
3.3 The Core Difficulty Is Stability Versus Response Speed
If corrections are too fast, the system tends to oscillate: an expert that has just been offloaded may immediately become underloaded. If corrections are too slow, the system cannot respond in time when the input distribution shifts.
In practice, the following must be considered jointly:
- Statistical window length;
- Update step size;
- Smoothing or clipping strategies;
- The number of experts activated per input;
- Expert capacity constraints;
- The frequency of cross-device statistics synchronization.
In addition, threshold selection must be coordinated with “how many expert outputs each input should receive.” Independently adjusting each expert’s threshold may leave some inputs with no expert at all, while others are accepted by too many—so deterministic selection or fallback rules are still needed.
3.4 The Balancing Objective Should Not Be Input Count Alone
Similar input counts across experts do not imply similar device latency. When experts differ in structure, inputs differ in processing cost, or the communication topology is uneven, count balance and time balance can diverge significantly.
A more complete set of metrics should include:
- Input counts per expert and their variance;
- The ratio of the busiest expert’s load to the average;
- Tail latency per step;
- Communication volume and communication wait time;
- Capacity overflow ratio;
- Main task quality and shifts in expert specialization.
The goal of load balancing is to reduce wasted waiting, not to force every expert to process exactly the same number of inputs at any cost.
4. Block-Level Attention Residuals: Making Deep Information Selectively Reusable
4.1 The Capability and Limits of Standard Residual Connections
A standard residual block is typically written as:
x_{l+1} = x_l + F_l(x_l)
It provides a relatively direct propagation path for information and gradients, and is fundamental to training deep networks. But as depth increases, information produced by different layers is continuously blended. Although later layers receive historical results, they may not be able to conveniently select the representation from a specific depth.
The idea behind attention-style residuals is to treat multiple historical representations as a candidate set and combine them with input-dependent weights, making information fusion selective.
4.2 Block-Level Design Is a Compromise Between Selectivity and Cost
If every layer retained all historical layer representations for selection, the candidate set would grow with depth, potentially causing significant memory usage and memory-access pressure.
A block-level scheme instead groups several consecutive layers together, forming representations at block boundaries that later modules can use. Subsequent modules perform weighted fusion over these block-level candidates, without directly accessing every layer’s output.
Here, “block” refers primarily to grouping along network depth—it should not be confused with chunking in sequence computation.
Potential benefits include enhanced cross-depth information access and, relative to layer-wise full-history selection, a reduced number of candidates. But this does not mean it necessarily uses less memory than a standard residual.
4.3 Memory and Communication Gains Must State the Baseline
Compared with standard residuals, attention-style fusion may add overhead for retaining historical states, computing weights, and normalization; compared with retaining all candidates layer by layer, a block-level design may reduce cost.
The same applies to communication. If candidate representations are distributed across different devices, cross-depth access may even introduce additional communication. Whether communication decreases depends on how the network is partitioned, where candidates are placed, and the parallelism strategy.
Therefore, standard residuals, layer-wise attention residuals, and block-level attention residuals should be compared separately, and advantages relative to one baseline should not be generalized into universal conclusions.
5. Long-Context Capability Cannot Be Inferred from a Single Design
Linear attention has good potential for scaling with sequence length, but a fixed-size recurrent state still constitutes an information bottleneck. A model being able to run a long-sequence computation does not mean it can accurately retain and retrieve every detail within it.
Likewise, not using explicit positional encodings does not imply reliable generalization to arbitrary lengths and position distributions. Order information may still enter the model through the recurrent structure, but whether the model can perform long-distance retrieval, multi-passage evidence integration, and position-sensitive reasoning must be validated on tasks.
Long-context evaluation should at least distinguish:
- Whether the model can run at the target length;
- Whether the running cost is acceptable;
- Whether task quality remains stable at the target length;
- Whether there is significant degradation beyond the training length.
Architecture provides possibility; training coverage and evaluation results determine the actual capability boundary.
6. How Development Teams Should Sequence Validation
A more robust implementation approach is to establish a baseline first, introduce optimizations one at a time, and only then run combined experiments.
Stage 1: Validate mathematical and numerical correctness. For linear attention, compare the recurrent implementation with the chunked implementation, covering different sequence lengths, extreme decay values, and backward gradients, and record error distributions.
Stage 2: Validate local engineering gains. Measure operator time, peak memory, extra statistics cost, and communication waiting separately, confirming that the targeted bottleneck is genuinely relieved.
Stage 3: Validate training and task quality. Observe convergence curves, long-context performance, expert utilization, and the usage of representations at different depths—guarding against local speedups that come at the cost of model quality.
Stage 4: Only then perform combined optimization. The three mechanisms may jointly change the ratio of computation to communication and may affect each other’s training dynamics, so their combined gains cannot simply be added together.
What is ultimately worth reusing is not the name of some advanced-sounding module, but a design that continuously improves quality, throughput, memory, or cost under clearly specified precision, hardware, data, and task constraints. Bounded decay emphasizes numerical controllability, dynamic balancing emphasizes resource coordination, and block-level residuals emphasize information reuse. Only by quantifying these three objectives separately can we form credible, transferable architectural judgments.
