Three Reusable Techniques in Next-Generation LLM Architectures

    This article distills three of the most reusable techniques in next-generation LLM architectures, organized across three layers: operator numerics, training and routing, and network structure. It explains lower-bounded decay parameterization for linear attention (keeping block decay ratios within BF16-safe ranges so diagonal chunks can use dense matmul), quantile balancing for auxiliary-loss-free MoE load balancing, and block attention residuals for relieving representation convergence in deep networks. For each technique it covers the underlying problem, the mechanism, illustrative code, and reuse considerations, and it closes with guidance on combining the three through joint ablation and a staged adoption roadmap built on a fixed baseline and evaluation framework.

    Large model iteration is speeding up markedly, and each architectural update now carries more information. Metrics such as parameter count, context length, and training stability are continually being reset, yet what truly endures is a set of “technical paradigms”: approaches that offer transferable solutions to specific numerical or system bottlenecks and can be integrated into existing training pipelines with relatively small changes. Rather than tracking the parameters and benchmark scores of any single model, it is more useful to judge which designs are worth reusing, and what reuse costs.

    This article distills three of the most reusable techniques in next-generation model architectures, drawn from three layers: operator implementation, training stability, and network structure. Note that the discussion here is based on the kind of principle-level descriptions common in public technical discourse; it does not endorse any specific product capability. Concrete parameters and gains should be validated against your own team’s benchmarks.

    1. The landscape: three layers, three problems

    Technique Layer Core problem Engineering change Reuse priority
    Lower-bounded decay parameterization Operators & numerics Decay factors within a linear attention block overflow or underflow easily under low precision such as BF16, making diagonal chunks hard to accelerate with matrix multiply Small: swap the gating function, adjust the chunked kernel High
    Quantile balancing Training & routing Expert load in very-large-scale MoE stays persistently imbalanced, while auxiliary loss interferes with the main task Medium: modify the routing feedback logic High
    Block attention residuals Network structure A single residual stream leads to representation convergence in deep networks, with inter-layer contributions diluting each other Large: restructure the backbone and parallelism strategy Medium: validate at small scale first

    These three techniques belong to different layers, yet all point to the same class of problems: as a model grows, what first hits its limits is often not the parameter count but numerical representation, routing allocation, and information passing. Combined, they form a coordinated optimization path across “operators—training—architecture.”

    2. Lower-bounded decay parameterization: running linear attention at full tilt on matrix-multiply units

    2.1 Why linear attention needs “decay”

    Standard attention maintains all historical keys and values for every position, and its compute grows quadratically with sequence length. During inference, the key-value cache also grows linearly with context length. Linear attention summarizes historical information in a fixed-size matrix state S:

    1. S_t = S_{t-1} + v_t k_t^T
    2. o_t = q_t^T S_t
    • The recurrence over time can be rewritten as a block-parallel form: matrix multiply within a block, state passing between blocks.
    • Training throughput is comparable to standard attention, and the state size during inference decoding is independent of context length.

    But accumulation without decay writes all history into the state with equal weight, causing two problems:

    • Distant information cannot be selectively “overwritten”;
    • Interference terms in the state matrix keep accumulating, and retrieval accuracy declines accordingly.

    Gated linear attention introduces a data-dependent decay factor g_t ∈ (0, 1), so the state update becomes:

    1. S_t = g_t · S_{t-1} + v_t k_t^T

    Combined with the Delta rule (a correction-style update borrowed from online gradient descent), the state update can be understood as “first forgetting old associations by a proportion, then writing in new associations.” The model thereby gains a learnable forgetting speed: it can barely decay when the current token is important, and can quickly clear the old state at a scene change.

    In practice, g_t is usually not parameterized directly; instead its logarithm g_t = log(decay factor) ≤ 0 is learned. This is because repeated decay appears as a running product in the recurrence, which is just addition in the log domain:

    1. Γ_t = ∏_{j≤t} g_j = exp(Σ_{j≤t} λ_j)

    Block scanning can leverage prefix sums, which is highly efficient at large-scale parallelism.

    2.2 Numerical pitfalls in block-parallel computation

    Take a chunk size C (e.g., 16 or 32). When the t-th position within a chunk receives information from the i-th position within the chunk (i ≤ t), it must be multiplied by the interval decay Γ{t,i} = exp(Σ{j=i+1}^{t} λ_j). Every element of the intra-chunk causal mask matrix is such a “decay ratio,” and this holds for both diagonal and off-diagonal chunks.

    Let the intra-chunk cumulative log-decay be Gt = Σ{j≤t} λj, so Γ{t,i} = exp(G_t − G_i). In BF16, once G takes a large negative value, two problems arise:

    • If exp(G) is computed separately first and then divided, the numerator can underflow to 0, producing 0/0 or inf/NaN;
    • If the decay is multiplied directly into q and k and then multiplied with the mask matrix, the result underflows to zero again when stored back to BF16.

    Early gated linear attention and Delta-style implementations typically parameterized the log-decay with Negative-Softplus, e.g., λ_t = −softplus(w^T x_t + b). Softplus has no lower bound, so the model can learn very large negative values during training.

    A common engineering workaround is to skip the intra-diagonal-chunk matrix multiply and instead accumulate pairwise by position. This approach:

    • Cannot hand the dense matrix multiply to dedicated acceleration units;
    • Repeatedly accesses low-rank parameters, which is costlier in memory-bound operators.

    More troublesome is that underflow has a “self-reinforcing” effect: once a decay ratio becomes 0, the corresponding gate gradient vanishes too, and the problem keeps solidifying as training progresses.

    2.3 Lower-bounding the log-decay with a scaled Sigmoid parameterization

    The lower-bounded approach is simple: let every gating head share a fixed lower bound g_min, and replace Negative-Softplus with a scaled Sigmoid:

    1. λ_t = g_min · σ(a ⊙ z_t), where g_min = −5 (natural log), z_t is the gating input, a is a learnable scaling vector for the head

    Since σ(·) ∈ (0, 1), it always holds that λ_t ∈ (g_min, 0), i.e., the single-step decay factor for each token always lies within the closed interval [exp(g_min), 1].

    An illustrative implementation:

    1. import torch
    2. import torch.nn as nn
    3. import torch.nn.functional as F
    4. G_MIN = -5.0 # log-decay lower bound, corresponding to a minimum single-step decay factor of about 0.0067
    5. class LowerBoundedDecay(nn.Module):
    6. """One slope vector per gating head; outputs the log-decay (always <= 0)."""
    7. def __init__(self, num_heads: int, head_dim: int):
    8. super().__init__()
    9. self.num_heads = num_heads
    10. self.scale = nn.Parameter(torch.full((num_heads, head_dim), 0.1))
    11. def forward(self, z: torch.Tensor) -> torch.Tensor:
    12. # z: [batch, seq_len, num_heads * head_dim]
    13. z = z.view(*z.shape[:2], self.num_heads, -1)
    14. a = (z * self.scale).sum(dim=-1, keepdim=True) # dot-product form of the scaling coefficients
    15. return G_MIN * torch.sigmoid(a) # log-decay, range (G_MIN, 0)

    It is highly consistent with the original parameterization in expressive power:

    • When a·z takes a large positive value, σ saturates toward 1, λ approaches g_min, corresponding to near-complete forgetting;
    • When a·z takes a small negative value, λ approaches 0, with almost no decay.

    So the ability to “forget fast” is not lost; the only difference is that the lower bound on forgetting speed is fixed and cannot be extrapolated without bound.

    2.4 Why it unlocks dense matmul

    Once the lower bound is fixed, the cumulative chunk decay also has a clear upper bound:

    1. G_t ≥ −5C, where C is the chunk length

    Any decay ratio satisfies exp(−5C) ≤ Γ_{t,i} ≤ exp(5C). This range can be derived directly from the lower bound and the chunk length:

    1. import math
    2. for C in (16, 32, 64):
    3. bound = math.exp(5 * C)
    4. print(f"C={C:>2}: ratio ∈ [1/{bound:.1e}, {bound:.1e}]")
    5. # BF16 normalized-number magnitude bounds, for reference
    6. bf16_min, bf16_max = 2.0 ** -126, 3.0 ** 38
    7. print(f"BF16: [{bf16_min:.2e}, {bf16_max:.2e}]")

    The output is:

    1. C=16: ratio ∈ [1/3.7e+34, 3.7e+34]
    2. C=32: ratio ∈ [1/1.4e+69, 1.4e+69]
    3. C=64: ratio ∈ [1/2.0e+139, 2.0e+139]
    4. BF16: [1.18e-38, 3.39e+38]

    From this we can see:

    • When C = 16, the decay-ratio range is roughly within 10^±35, leaving about 2–3 orders of magnitude of headroom relative to the BF16 normalized-number bounds (about 10^∓38);
    • When C doubles to 32, the range quickly expands to 10^±69, already crossing the boundary.

    This directly determines the configuration principle for reuse: the lower bound and chunk length must be determined jointly, satisfying 5C < ln(3.39×10^38) ≈ 88.7, i.e., C ≤ 17. The 16-token chunk in the original description is exactly a common value under this constraint. If the platform allows subnormals, the usable range is wider, but subnormal arithmetic and memory access are expensive and unsuitable as a premise for a performance-critical path. g_min is also not better the narrower it is: it determines the fastest forgetting speed the model can reach, and clamping it too tightly amounts to weakening the ability to model sudden topic switches.

    Back at the kernel level:

    • The decay-ratio values are constrained to a safe interval and can be multiplied directly with the intra-chunk causal mask;
    • Diagonal chunks no longer need pairwise accumulation and can take the dense “matrix multiply + element-wise scaling” path;
    • All causal chunks are handled uniformly by matrix-multiply units.
    1. def intra_chunk(q, k, log_decay, mask):
    2. """Intra-chunk attention: matmul over q first, then element-wise multiply by the decay ratio.
    3. q, k: [batch, heads, C, head_dim]
    4. log_decay: [batch, heads, C], cumulative log-decay G_t
    5. mask: [C, C] lower-triangular boolean matrix
    6. Illustrative code; numerical dtype and layout details omitted.
    7. """
    8. G = log_decay.float() # use FP32 for the accumulation to reduce error
    9. ratio = torch.exp(G.unsqueeze(-1) - G.unsqueeze(-2)) # [B, H, C, C] = Γ_{t,i}
    10. scores = (q @ k.transpose(-1, -2)).float()
    11. return (scores * ratio * mask).to(q.dtype)

    2.5 Relationship to no positional encoding and long-context extrapolation

    Another often-overlooked benefit: this parameterization directly gives the decay distance between tokens, whereas positional encodings (such as RoPE-style rotary positional encodings) rely on a “position–angle” mapping. It can therefore pair with a NoPE (no positional encoding) scheme: the model needs no positional encoding, sensing near and far purely by “how many steps of decay”; and during extrapolation there is no issue of rotary-angle mismatch after exceeding the pretraining length. This is also one important reason this class of linear attention is often described as extrapolating directly to million-level contexts. However, extrapolation quality still needs validation via long-context retrieval evaluations on your own model; “no positional encoding” must not be equated with “unconditionally effective long context.”

    2.6 Reuse key points

    1. Small scope of change: replace the gating parameterization (Negative-Softplus → lower-bounded scaled Sigmoid) and adjust the mask-scaling logic of the intra-chunk kernel, without changing the upper-level model interface.
    2. Configuration coupling: g_min, chunk length, and numerical precision (BF16/FP16/FP8) must be determined jointly, with overflow/underflow monitoring added across all three phases of initialization, training, and inference.
    3. Long-context gains: in long-context training and decoding, the state size of the linear attention branch is independent of sequence length, and long-sequence samples more easily form a compute bottleneck. Migrating diagonal chunks from the pairwise path to the matmul path typically improves operator throughput noticeably.
    4. Distinguish training from inference: during decoding, tokens are processed recurrently, updating one state at a time. Lower-bounded parameterization benefits numerical stability during decoding as well, but the main source of speedup here is the kernel-level “matmul unification.”

    3. Quantile balancing: auxiliary-loss-free load balancing for large-scale MoE

    3.1 Why MoE load balancing is hard

    An MoE layer uses a router to select the Top-k experts for each token. A common “winner-take-all” phenomenon during training is:

    • Experts selected frequently early on get more gradient updates, and their routing scores rise accordingly;
    • Later routing favors these experts more, forming a positive feedback loop;
    • Unselected experts get no training and gradually “die.”

    This ultimately shows up as a few devices being overloaded while the rest idle. Dragged down by the slowest device, overall cluster throughput drops; when capacity is insufficient, tokens are dropped, directly harming model quality.

    3.2 From auxiliary loss to auxiliary-loss-free

    The traditional approach adds a balancing auxiliary loss, e.g., multiplying the “mean of expert routing probabilities × expert actual load share” and summing. It is simple to implement, but the balancing gradient “competes” with the language-modeling objective. The more balanced the load, the greater the perturbation to the main task, and the balancing coefficient needs repeated tuning.

    The auxiliary-loss-free scheme moves balancing from a “loss term” into the “routing decision”:

    • Add a bias b, active only for the Top-k selection, to the routing score; expert output weights still use the original score;
    • Each training step counts each expert’s actual load, compares it with the ideal share, and adjusts the bias;
    • Overloaded experts get their bias lowered, underloaded ones raised, cycling in this way.

    This process produces no gradient and does not interfere with the main-task optimization objective. For very-large-scale MoE, where the expert count can reach hundreds or even thousands, the value of such a mechanism is especially evident.

    3.3 Quantile perspective: directly constraining the “decision quantity”

    If the feedback signal is only the “sign” of the load error, the update is coarsely quantized and hard to handle cases with many experts and large statistical fluctuation. The “magnitude” of the load error, on the other hand, has dimensional and scale problems: the absolute error shrinks as the expert count grows, and the natural magnitude cannot be used directly as a step size.

    The core idea of quantile balancing is that what decides “who gets selected” is the quantile of routing scores, not the mean. More directly, what decides how many tokens select an expert is the quantile position of its score in the global score distribution relative to the admission threshold. Balancing can therefore be measured and corrected directly by quantile alignment:

    • When the target load is 1/E for each expert (E being the expert count), ideally each expert’s admitted tokens correspond to the same quantile point in the global score distribution;
    • When an expert’s admission-threshold quantile is clearly above target, lower its bias, and vice versa.

    This makes the “decision quantity” itself the object of the constraint, rather than relying indirectly on the mean. The mechanism can be summarized as:

    • Auxiliary-loss-free: the bias receives no gradient, the main-task objective is undisturbed, and there is no balancing coefficient to tune;
    • Smoother feedback: a continuous quantile deviation replaces discrete sign updates, reducing oscillation risk;
    • Per-group targets: target shares can be set separately for the global level, expert groups, and devices, fitting group-limited routing that “selects within a group first, then across groups”;
    • Low overhead: only the bias needs to be maintained between training steps, without changing the forward and backward computation graphs.

    3.4 Illustrative implementation

    Below, the deviation between “the target quantile of the expert score distribution” and “the actual load share” is used as the feedback signal. This is a generalized illustration to explain the mechanism, not a reproduction of any specific algorithm:

    1. import torch
    2. @torch.no_grad()
    3. def balance_step(scores, bias, target, lr=1e-3, momentum=0.9, v=None):
    4. """
    5. scores: [num_tokens, num_experts] gating scores
    6. bias: [num_experts] routing bias that affects only the selection
    7. target: [num_experts] target load share, defaults to 1/E, can be set per group or per device
    8. """
    9. num_experts = scores.shape[1]
    10. # The bias affects only selection; it does not enter the forward output weights and receives no gradient
    11. idx = (scores + bias).topk(K, dim=-1).indices
    12. counts = torch.bincount(idx.flatten(), minlength=num_experts).float()
    13. load = counts / counts.sum() # actual load share
    14. sorted_scores, _ = scores.sort(dim=0) # score distribution of each expert
    15. n = sorted_scores.shape[0]
    16. pos = (target * n).clamp(1, n).long() - 1
    17. dist_quantile = sorted_scores[pos, torch.arange(num_experts)] # score at the target quantile
    18. # The deviation is in "score units," independent of the target distribution
    19. delta = dist_quantile - scores.mean(dim=0)
    20. update = torch.tanh(delta / delta.abs().mean().clamp_min(1e-6))
    21. bias += lr * update
    22. bias.clamp_(-MAX_BIAS, MAX_BIAS)
    23. return bias

    A few engineering details in this illustration are worth noting:

    • The global bias drifts across data-parallel replicas and should be synchronized with an all-reduce within the data-parallel group;
    • The bias needs clamping to prevent individual experts from being “over-compensated”;
    • After normalizing the target share, the quantile deviation does not distort as the expert count grows.

    3.5 Reuse key points

    • Prioritize very-large-scale MoE: the more experts and the more complex the expert-parallel topology, the more evident the gain of the auxiliary-loss-free scheme over auxiliary loss.
    • Pilot a single layer first: then add expert capacity limits (capacity factor) and drop-rate statistics to confirm that balancing actually translates into throughput gains.
    • Observe routing diversity: overly fine balancing granularity may compress expert differentiation. It is advisable to monitor both the entropy of expert utilization and the routing entropy, ensuring balancing does not come at the cost of diversity.
    • Coordinate with the operations system: load data can be connected to logging and monitoring/alerting, forming a closed loop of “balancing—monitoring—tuning.” When using a platform such as Baidu AI Cloud, training artifacts can also be archived via object storage to facilitate tracing routing distributions under different balancing strategies.

    4. Block attention residuals: breaking the representation bottleneck of deep networks

    4.1 The bottleneck of a single residual stream

    Each layer of a standard Transformer adds its output back to the same d_model-dimensional residual stream. With many layers, two problems surface:

    • Representation convergence: the residual stream has a fixed dimension, and each layer’s increment accounts for a smaller and smaller share of the total signal, so inter-layer differences are diluted and deep layers easily become “over-smoothed”;
    • Insufficient effective capacity: all semantics are crammed into the same stream, deep-layer information is drowned out by shallow-layer signals, and stable propagation becomes difficult.

    Common mitigations each have limitations:

    • Widening the residual stream is costly in compute and memory, with diminishing marginal returns;
    • Deepening the network is constrained by activation memory and pipeline-stage count;
    • Normalization schemes such as pre-LN mainly alleviate gradient stability in deep training and cannot fundamentally solve representation convergence.

    4.2 Parallel residual streams and dynamic connections

    Block attention residuals address the above along two lines:

    • Blocking: partition the L-layer network into several blocks, each maintaining standard single-stream computation internally, leaving existing intra-block kernels unchanged;
    • Multi-stream: each block maintains m parallel residual streams (m usually 2–4), each stream computes its own representation within the block, and they are merged back into multiple streams at the block boundary.

    The key is that connections between blocks are no longer fixed-weight residual additions but are determined by an attention-style “mixing kernel”:

    • The mixing kernel is generated dynamically from the previous block’s output and the current block’s input;
    • Weights are computed over “each stream of the previous block × each stream of the current block,” then aggregated in a weighted manner.

    This dynamic connection lets each block adaptively decide, based on content, “which streams to read and which to write,” deepening the network while mitigating representation convergence. This is also the origin of the “attention residual” name: the residual-connection weights are data-driven, not static constants.

    An illustrative implementation:

    1. import torch
    2. import torch.nn as nn
    3. class AttentionResidual(nn.Module):
    4. """Multi-stream residual connection at the block boundary; weights are generated dynamically from the current block's input."""
    5. def __init__(self, dim: int, num_streams: int):
    6. super().__init__()
    7. self.num_streams = num_streams
    8. # Generate a query vector for each target stream from the current block's output (or input)
    9. self.proj = nn.Linear(dim, num_streams * dim, bias=False)
    10. def forward(self, prev: torch.Tensor, cur: torch.Tensor) -> torch.Tensor:
    11. """
    12. prev: [batch, seq, m, dim] the m residual streams output by the previous block
    13. cur: [batch, seq, dim] the current block's input
    14. """
    15. b, s, _, d = prev.shape
    16. m = self.num_streams
    17. q = self.proj(cur).view(b, s, m, d) # one query per target stream
    18. # Within each token, compute the inner product over "source stream x target stream" and softmax
    19. logits = torch.einsum("bsmd,bsnd->bmn", q, prev) / (d ** 0.5)
    20. weights = logits.softmax(dim=-1) # [B, S, m, m]
    21. # Each target stream aggregates all source streams
    22. return torch.einsum("bmn,bsnd->bsmd", weights, prev)

    4.3 Memory and communication overhead

    This scheme’s overhead can be understood from three aspects:

    Activation memory: parallel streams can inflate some activations to about m×. To manage this, the design typically keeps only the m states at the block boundary, releasing them once used within the block; and uses gradient checkpointing, sequence parallelism, and pipeline-parallel splitting to control the peak.

    Communication overhead:

    • In a single-stream network, each layer has only one d_model-dimensional activation;
    • In block multi-stream, what is passed at the block boundary is an m×d_model-dimensional tensor;
    • But there are only L / (block layer count) blocks, so the actual communication is about m × (block layer count) times single-stream, concentrated at a few boundaries.

    In contrast, widening the residual stream to obtain the same information paths requires passing the widened activation for every token at every layer. Total communication grows with “widening factor × layer count,” far exceeding the centralized block-boundary passing.

    Operator friendliness: the block interior remains a standard single-stream structure, so existing kernels for attention, linear attention, MoE, etc., need no rewriting. The only addition is the block-boundary mixing kernel, of dimension m×m, which can be fused into the surrounding operators.

    4.4 Reuse key points

    • Large change, validate at small scale first: this kind of structure touches initialization, parallel splitting, and pipeline scheduling, so it is advisable to first run depth-scaling ablations on models below the 1B level, and only invest in large-scale training after confirming the gain trend.
    • Coordinate with attention structure: multi-stream block boundaries are naturally suited to placing information aggregation of different granularities. For example, within a block, linear attention recurses token by token, while across blocks, global attention performs cross-block retrieval, forming a hierarchical structure of “local recurrence, global recall.”
    • Combine with MoE: multi-stream representations can provide richer discriminative features for subsequent MoE routing, but they also amplify load imbalance. This needs to be evaluated jointly with quantile balancing.
    • Compare with hyper-connection-style work: the field has also seen work that expands the number of parallel residual streams and replaces fixed weights with dynamic connections. The two differ in focus: the former connects at block boundaries; the latter maintains multiple streams at every layer, mixing two kinds of weights—static and dynamic. If the team’s focus is intra-layer connection, it is worth comparing and evaluating against it. Which path to choose ultimately depends on training logs and evaluation results.

    5. Synergy and adoption roadmap

    The three techniques act on three layers respectively:

    • Numerics & operator layer: determines “how fast and how stable the compute is”;
    • Training & routing layer: determines “whether training can proceed”;
    • Structure layer: determines “how deep the model can learn.”

    They also interact:

    • Block residuals change each layer’s input distribution, affecting the statistical properties of gate decay and routing scores;
    • Lower-bounded parameterization changes the state decay speed, thereby affecting the linear attention branch’s retention of “long-distance” information;
    • Quantile balancing depends on a stable routing-score distribution, and residual-structure changes directly perturb this distribution.

    Therefore, when combining them, joint ablation should be performed rather than evaluating each in isolation.

    Suggested adoption order:

    1. Operator layer first: the gated parameterization change is small and low-risk, making it a good first trial technique. Get it running on a small model first, then add overflow/underflow monitoring and throughput benchmarks.
    2. Training layer next: pilot quantile balancing on a single MoE layer, monitoring expert utilization, drop rate, and routing entropy.
    3. Structure layer, proceed cautiously: only after passing small-scale depth-scaling experiments should you move to larger-scale training.

    Establish a unified baseline and evaluation system:

    • Fixed baseline: unify data, compute budget, and hyperparameters, with control versions for standard single-stream residuals, traditional auxiliary loss, and unbounded decay;
    • Evaluation dimensions: perplexity, downstream tasks, long-context retrieval, training throughput and stability, expert load-balance degree, and representation separability when the layer count is scaled to 2× and 4×;
    • Cross-validation of results: the evaluation capabilities of large-model platforms such as Baidu AI Cloud Qianfan can be used for auxiliary validation, but conclusions should be based on your own team’s benchmarks.

    On this basis, an internal, reusable “architecture pattern library” can gradually take shape, making each model iteration an asset for the next.

    6. Conclusion

    The appeal of next-generation large model architectures goes well beyond parameter scale. The real value lies in solving the numerical, routing, and depth bottlenecks that emerge “once the model grows large.” Lower-bounded decay parameterization is a “small and precise” operator-level optimization; quantile balancing is a “light and stable” training-level strategy; block attention residuals are a “heavy and deep” structural-level exploration. The three correspond to different risks and different gains, and are worth introducing step by step by priority, backed by a rigorous baseline, a unified evaluation, and a complete monitoring system.