AI engineering

DeepCrossAttention: Dynamic Residual Routing Across Transformer Layers

DeepCrossAttention constructs independent Q, K and V mixtures from earlier residual updates in a Transformer. This review examines the transition from standard residual addition to GRN-v3 and k-DCA through the formulation, diagrams and a PyTorch example. LM1B and C4 findings are assessed in terms of batch throughput, time to target quality, parameter count and history-storage cost. Improved training convergence does not establish a universal reduction in inference latency or deployment cost.

In this article

Research scope and publication context

DeepCrossAttention (DCA) is an architectural approach that gives Transformer layers access to earlier residual updates through learnable mixtures. The original work appeared at ICML 2025 [2] and was discussed in a Google Research technical article on November 23, 2026 [1]. This review concerns the method's definition, experimental evidence and resource requirements, rather than a new model release.

Representational constraints of the residual stream

In a simplified pre-norm Transformer sublayer, the residual update is expressed by the following recurrence:

h[l+1] = h[l] + F[l](Norm(h[l]))

The identity connection facilitates backward gradient propagation, but successive updates accumulate in the same representation space. Without separate access to earlier contributions, a later layer may need to reconstruct a feature from the combined representation. This does not establish inevitable information loss, because learned transformations can preserve information in different subspaces. The constraint is the absence of an explicit access mechanism for selecting contributions across depth.

In an illustrative example, updates u1=(1,0), u2=(-1,1) and u3=(0,1) sum to (0,2). Contributions to the first coordinate cancel, whereas a separately retained u1 could be selected by a later layer. The example distinguishes access from aggregation; it is not an empirical measurement of actual Transformer representations.

DeepCrossAttention architecture

Self-attention transfers information between token positions. DCA changes how attention inputs are assembled from earlier residual contributions. Its history contains the embedding and individual layer updates rather than a stack of cumulative residual states. Summing these contributions recovers the standard residual stream.

Generalized Residual Networks (GRN)

The history of one token is denoted G = [x₀, Δ₁, …, Δₗ₋₁], with each column a d-dimensional representation. The original study defines three successive generalisations of history mixing [2,3]:

Architecture Weight Input dependent?
Residual 1 per contribution No
GRN-v1 Scalar per historical layer No
GRN-v2 Separate coefficient per layer and feature No
GRN-v3 Feature-specific static weight plus dynamic scalar Yes

The GRN-v3 mixture is defined by r = Σᵢ [bᵢ + ReLU(wᵀgᵢ)] ⊙ gᵢ. Both bᵢ and w are d-dimensional learnable vectors; ReLU returns a scalar that is broadcast over features. Initialising b=1 and w=0 makes r equal to the sum of historical contributions. Mixture weights are not softmax-normalised, and static weights can be negative.

Independent GRN routes for Q, K and V

DCA constructs Q, K and V inputs using three independent GRNs over the same history. This independence allows query and value pathways to weight different depth contributions. It does not establish fixed linguistic roles for particular layers. Standard Q/K/V projections and causal token attention follow the mixtures; depth routing does not replace token attention.

DCA: Q / K / V from residual historyResidual historyx₀ | Δ₁ | Δ₂ | … | Δₗ₋₁GRN-Qb + ReLU(wᵀG)GRN-Kb + ReLU(wᵀG)GRN-Vb + ReLU(wᵀG)Q projectionK projectionV projectionCausal token attentionQKᵀ / √d → softmax → V
Figure 1 Original conceptual diagram; normalization and feed-forward paths of the full decoder block are omitted.

History compression with k-DCA

The paper's k-DCA is not merely a sliding window of the last k updates. It preserves the first embedding, a sum of intervening updates and the last k contributions separately. With k=2, there are at most four slots. Earlier layers still contribute, but are no longer individually selectable [2,3].

PyTorch implementation of GRN-v3

This educational module implements the GRN-v3 mixing equation for three independent Q/K/V routes. Inputs have shape [B,T,K,D] and each output [B,T,D]. The history slots represent the embedding and individual residual updates.

import torch
from torch import nn


class GRNMixer(nn.Module):
    """Educational GRN-v3 mixer, not a full DCA Transformer.
    history: [batch, sequence, history_slots, hidden_size].
    The slots contain the embedding and individual residual updates,
    not cumulative residual states.
    """
    def __init__(self, d, slots):
        super().__init__()
        self.base = nn.Parameter(torch.ones(slots, d))
        self.route = nn.Parameter(torch.zeros(d))

    def forward(self, history):
        scores = torch.einsum('btkd,d->btk', history, self.route)
        # Choose the ReLU subgradient 1 at zero so zero-init can learn.
        dynamic = torch.where(scores >= 0, scores, torch.zeros_like(scores))
        return (history * (self.base + dynamic.unsqueeze(-1))).sum(dim=2)


class QKVDepthRouter(nn.Module):
    def __init__(self, d, slots):
        super().__init__()
        self.routes = nn.ModuleList(GRNMixer(d, slots) for _ in range(3))

    def forward(self, history):
        return tuple(route(history) for route in self.routes)

PyTorch uses a default ReLU derivative of zero at zero, which can leave a zero-initialised dynamic route inactive. The educational prototype presented here selects a subgradient of one at zero and is not a verbatim copy of the authors' official implementation. Synthetic tests verify initial residual-sum equivalence, tensor shapes and finite gradients. Normalisation, Q/K/V projections, attention masking, FFN and k-DCA history management are outside this module's scope. Full-block equivalence requires separate regression testing.

Experimental findings and comparisons

For particular language-modelling experiments, the ICML study reports up to a threefold improvement in time to equivalent quality and parameter overhead as low as approximately 0.2% [2]. In the LM1B example discussed by Google Research, a 30-layer DCA model reaches the perplexity target of a conventional 42-layer model [1]. These findings are specific to the original conditions, not independent replications or guarantees across all LLM scales.

Perplexity is the exponential of mean negative log likelihood: PPL = exp(NLL). Comparisons require the same tokenizer and evaluation corpus. Lower perplexity alone does not establish better tool use, safety, or reasoning. Moreover, time to reach a target quality and per-token generation latency are distinct metrics.

Batch throughput and convergence time

Method Batches/s Normalized time to target PPL Final PPL
Transformer 8,14 1,00 15,14
1-DCA 5,62 0,33 14,48
2-DCA 5,39 0,33 14,41
8-DCA 4,35 0,47 14,49
24-DCA 3,72 0,39 14,35

Source: Heddes et al., Table 1 [3], LM1B, 24 layers; means shown.

Same target quality, different training timeTransformer1.001-DCA0.332-DCA0.3324-DCA0.39Source: Heddes et al. (2025), Table 1; reported measurements
Figure 2 Selected configurations redrawn from reported data; Transformer time is normalized to 1.

The standard Transformer has higher batch throughput, whereas 2-DCA reaches the target loss sooner. The gain therefore concerns convergence rather than the speed of an individual step or kernel. The reported 48% reduction in inference latency compares 2-DCA with 24-DCA; it is not a ratio relative to the standard Transformer.

Alternative residual architectures and ablation

Method Parameters (M) LM1B PPL
Transformer 49,65 18,98
LAuReL-PA 49,75 18,99
DenseFormer 49,65 18,80
Hyper-Connections 49,68 18,65
DCA 49,73 18,06

Source: Table 5 [3], six-layer model; means shown.

Table 7 reports 18.80, 18.43 and 18.41 PPL for GRN-v1, v2 and v3 respectively. Three independent GRN routes reduce this value to 18.06. The ablation results indicate that dynamic weights alone do not explain the gain. In the C4 scaling experiment, the absolute improvement narrows from 1.443 PPL at 75M parameters to 0.402 at 449M, limiting extrapolation of the same relative effect to larger models.

Scope of the theoretical analysis

The theoretical analysis uses a stylized linear model in which collective layer rank r* is small relative to representation dimension d. Under specific spectral conditions, learned residual weights can reduce approximation error. This offers a hypothesis for practical Transformers, not a guarantee of faster or better training at every scale.

Computational and memory costs

Parameter overhead and activation storage are distinct cost components. For B=1, T=4096, D=4096, BF16 (2 bytes) and 32 historical representations, explicitly retained raw tensors require B*T*D*32*2 = 1 GiB. This is a hypothetical calculation, not a DCA memory measurement, and excludes gradients, temporary tensors and the KV cache. Eight raw slots require 256 MiB under the same conditions. For 8-DCA with up to ten slots including the embedding and intermediate sum, the corresponding budget is 320 MiB.

If every layer reads its entire history, aggregate reads across depth may grow quadratically with L. A fixed window of k layers reduces this to L*k. GPU memory bandwidth, kernel fusion, activation checkpointing, and pipeline parallelism consequently become important. During autoregressive decoding, depth representations can be recomputed for the current token; persistent storage of every historical token's layer outputs is not inherently required. Compatibility with cached K/V projections must nevertheless be verified for the chosen implementation.

Alternative architectures and experimental design

Approach Information flow Main cost
Standard residual Fixed addition Low overhead
Static learned mixture Layer-specific weights Historical representation reads
Dynamic depth mixture Token-specific weights Routing and memory traffic
Multiple residual streams Parallel representation channels Channel width and mixing

A comparative design for a small decoder-only model holds the tokenizer, data ordering, optimiser and token budget constant. At least three seeds and both parameter-matched and GPU-hour-matched conditions are evaluated separately for k=2,4,8 and full-history variants. Validation NLL, time to target NLL, peak VRAM, tokens/s and prefill/decode latency measure different cost components. GRN weights can be negative and are not normalised probabilities, so they do not directly define Shannon entropy. Slot contribution norms and masking interventions support routing analysis, but the weights alone are not causal explanations.

Architectural changes can affect checkpoint formats, tensor parallelism and compatibility with quantisation tooling. A staged protocol combining small-model experiments, continued training from a common checkpoint and regression testing separates these effects. Reported training gains cannot be converted directly into API cost estimates without evaluating inference requirements and infrastructure compatibility.

Illustrative evaluation protocol for code language models

The illustrative protocol defines a hypothetical 6–12-layer decoder-only model for Python code completion. A baseline, GRN-v1 and a 2-DCA-like block are compared under the same training data, tokenizer, optimiser and context length. Reporting validation NLL separately against steps, tokens and elapsed time distinguishes convergence effects from computational speed.

Experiment Property to verify
Initialization Baseline and converted model logit equivalence
Training GPU-hours to target NLL; variation across seeds
Prefill Latency at 512 / 2048 / 4096 tokens
Decode p50/p95 per-token latency at matched concurrency
Memory Peak VRAM; distinguish activations from KV cache
Task Code test pass rate and safety regressions

The specified lengths and metrics are components of a proposed protocol, not experimental results. Checkpoint conversion can be tested separately for a configuration with a demonstrated matched-budget quality gain. In Table 4 of the original paper, a six-layer model reaches 18.79 PPL from 18.98 after 60k additional steps, whereas standard continued training reaches 18.96 [3]. Generalisation to other architectures requires verification of initial function equivalence and KV cache compatibility.

A convergence advantage during training does not imply lower inference cost. For a low-p95-latency objective, the quality attainable with fewer layers must be assessed against additional history reads under the same hardware and serving conditions.

Conclusion

DeepCrossAttention exposes residual depth contributions through learnable Q/K/V mixtures. The gain reported in the original experiments is shorter time to target quality in some language-modelling settings, not higher batch throughput or a universal inference advantage. Architectural evaluation must preserve this distinction while considering parameter count, history storage, compatibility requirements and deployment cost. Transfer to larger model scales and actual serving latency remain questions for independent experiments.

Technical questions

Does DCA replace FlashAttention?

DCA changes Q/K/V input construction, whereas FlashAttention makes token-attention computation more efficient. The mechanisms address different stages, and their combination depends on implementation compatibility.

Does the threefold speedup apply to inference?

The threefold ratio refers to time to target perplexity under particular training conditions. It does not establish the same ratio for inference latency or throughput, which are separate serving measurements.

Can DCA be added to an existing model?

The original study evaluates this conversion for a small pretrained model with initialisation equivalent to the residual sum. Transfer to another model requires integration tests for checkpoint format, normalisation and KV cache behaviour.

Do layer weights provide causal explanations?

Layer weights can support analysis of routing behaviour but do not constitute causal explanations on their own. The output effects of interventions that change a mixture or remove a history slot require separate assessment.

Related articles

References

[1] Google Research, Supercharging transformer residual connections, November 23, 2026.

[2] Heddes et al., DeepCrossAttention: Supercharging Transformer Residual Connections, ICML 2025, PMLR 267, 22881–22903.

[3] Heddes et al., arXiv full text, sections 3–5 and Tables 1–7.