Manuscript Offprint

arXiv:2611.01940

ReWY: Faster Gradient Computation for Delta-Rule Attention Family

Yi Zhang, Zhixin Zhao, Weiwei Sun, Yitao Hu, Sheng Chen, Keqiu Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yi Zhang

Tianjin University

Tianjin, China

zhang_e@tju.edu.cn

Zhixin Zhao

Tianjin University

Tianjin, China

zhao612@tju.edu.cn

Yitao Hu ∗^{*}

Tianjin University

Tianjin, China

yitao@tju.edu.cn

Sheng Chen

Tianjin University

Tianjin, China

chensheng@tju.edu.cn

Weiwei Sun

Tianjin University

Tianjin, China

sww@tju.edu.cn

Keqiu Li

Tianjin University

Tianjin, China

keqiu@tju.edu.cn

Abstract

Delta-rule linear attention underlies language-model architectures such as Kimi Linear and Qwen3-Next. Chunkwise implementations expose matrix parallelism, but their backward passes compute auxiliary adjoints that the final input gradients do not need. We present ReWY, an algebraic reformulation that reduces this work before optimizing accelerator execution. By differentiating the chunk correction as one triangular residual system, ReWY eliminates the inverse adjoint and reduces seven local WY matrix products to three. Two complementary transformations expose further reuse: centered matrix contractions replace pairwise processing of vector gates, and scalar-gate reductions reuse key-gradient products instead of forming a key Gram matrix. Together, these identities simplify the backward graph for DeltaNet, GDN, KDA, and GDN2 while preserving the recurrence and its gradients in exact arithmetic, without changing the model architecture or training objective.

We implement the reduced graph on GPUs and Ascend NPUs with schedules that balance reuse and storage. Under matched recomputation and full-saving policies, precision-qualified six-shape comparisons with frozen FLA references yield 1.15−1.81×1.15-1.81\times geometric-mean complete low-level backward speedups on NVIDIA GPUs. All four operators also achieve 1.18−1.70×1.18-1.70\times on NVIDIA H100 and NVIDIA H200 while retaining the original FP32 working matrices. A separate public-autograd evaluation on Ascend 950DT, including gradient conversions, yields 1.09−2.89×1.09-2.89\times under the available matched policies. Paired ablations establish additional ReWY gains after optimizing the complementary contractions. Complete-gradient checks validate the recorded operator cases; supplementary full-model backward measurements evaluate integration into community FLA models and an identified GDN2 layer port. These results show how simplifying an existing operator's derivative graph translates into accelerator performance.

1 Introduction

Linear attention has become a practical building block of industrial language-model architectures. Kimi Linear uses Kimi Delta Attention (KDA) in an approximately 3:1 mixture with global Multi-Head Latent Attention [11, 13]. Qwen3-Next places Gated DeltaNet (GDN) in 36 of its 48 layers, and the Qwen3.5-0.8B text backbone uses it in 18 of 24 layers [15, 16]. These models repeatedly invoke the same family of delta-rule operators to update a recurrent matrix state. Optimizing that primitive therefore addresses an existing model-computation workload shared across many layers and architectures.

The attraction of these operators is their sequence-length-independent recurrent state and linear sequence complexity. Training, however, must also expose enough parallel work to exploit accelerator matrix units. Chunkwise algorithms express causal interactions within each chunk as dense matrix operations and connect chunks through a state scan [9, 11, 19, 21]. Flash Linear Attention (FLA) provides widely used implementations of this computation; the Kimi authors release their KDA kernel through FLA itself [4, 13]. The systems question is how much work this core operator actually needs to perform, particularly in its backward pass.

A redundant derivative graph. The conventional WY decomposition is useful for parallelizing the forward pass, but differentiating its intermediate operations separately creates avoidable backward work. It forms adjoints of two auxiliary objects—a transformed key matrix and a triangular inverse—only to multiply them again into the gradients that the caller needs. Fusion and tiling can accelerate these products, but executing the same derivative graph still pays for their arithmetic and intermediate lifetimes. At chunk size 64 and key/value width 128, the local WY graph contains seven matrix products and 7.34 million dense FLOPs per chunk/head, before the common state scan and interaction gradients are counted.

∗^{*}Corresponding author.

(a) Expanded WY: 7 products

Forward operands: A, E, Z, S

Figure

(b) ReWY: 3 products

Reuse forward correction R

Same outputs: Z~,E~dir,D\tilde{Z}, \tilde{E}_{\text{dir}}, D. Common downstream work: DY,D⊤EDY, D^\top E, and the state adjoint.

Figure 1. The local backward computation graph before and after ReWY. Arrows show dependencies between computed values; forward operands appear in the node formulas. The expanded graph forms W~\tilde{W} and A~\tilde{A} (orange) and propagates the inverse adjoint through two matrix products. ReWY shares PP across the same three required gradients (green), using the forward correction RR. The graphs contain seven and three matrix products, respectively; addition, masking, and the alias Z~=P\tilde{Z} = P are not counted as products.

Eliminate work, then schedule what remains. Our key observation is that the chunk correction satisfies one triangular residual equation. Differentiating this composite map exposes a shared reverse sensitivity and makes the inverse-adjoint chain unnecessary. We call the resulting algorithm ReWY. As shown in Figure 1, ReWY reduces the local WY computation from seven products to three, removing 42.9% of its dense FLOPs at the above dimensions. The forward recurrence, attention semantics, and exact gradients remain unchanged. This is an operator algorithm change applicable to DeltaNet, GDN, KDA, and GDN2; it does not introduce a new neural-network architecture.

The reduced graph also exposes reuse in the remaining interactions. Matrix intra factors vector-gated pairwise interactions into centered matrix contractions, replacing repeated token-pair processing with matrix-unit work. Gram elimination computes scalar-gate reductions from key-gradient products that are already needed, avoiding a separate key Gram matrix. These transformations complement ReWY: the latter simplifies the coefficient producer, while the former optimize its gradient consumers. Their independent and conditional gains are measured separately.

Turning this algebra into speed requires an execution strategy. Sharing the reverse sensitivity can save products while adding memory traffic; fusing all consumers can instead extend live ranges and restrict occupancy. Our implementations select joint or separate producer–consumer schedules by device and operator, preserve existing FP32 working matrices and accumulations, and use one schedule across the evaluated shapes. Matched saving policies prevent existing FLA activation-saving support from being counted as a new algorithmic contribution. The evaluation measures the complete backward operator, rather than extrapolating a local kernel improvement to the whole computation.

Contributions. This paper makes three contributions:

  • A smaller delta-rule derivative graph. ReWY eliminates four local matrix products and the inverse adjoint while recovering all input, state, and gate gradients. We give the resulting formulas in the main text and the full equivalence proof in Appendix B.

  • Contractions and schedules. Centered matrix intra and Gram elimination remove distinct sources of repeated work. GPU and NPU schedules realize this reuse while controlling shared storage, numerical range, and intermediate lifetimes.

  • Complete-operator evaluation. Across six shapes, precision-qualified NVIDIA GPU comparisons yield complete backward speedups of 1.15–1.81×. A separate Ascend 950DT public autograd study yields 1.09–2.89×, with standalone residual and FP32 matrix-intra controls. Ascend 910C comparisons retain their stated precision qualifications. Paired Gram controls establish additional ReWY gains. Tests check every gradient, and separate allocation measurements characterize storage.

The layer fractions above motivate the operator’s relevance; they are not runtime fractions. Supplementary A800, Ascend 910C, and scoped H100/H200 full-model backward measurements in Section 4.8 quantify the latter using FLA’s existing full models and an identified GDN2 layer port. For example, the core backward accounts for 25.7–31.3% of the unmodified FLA KDA model’s measured backward interval across its input-size sweep. The paper’s main performance claim remains the complete-operator improvement; model integration measures how that improvement carries through the surrounding computation.