One Token, Many Lessons: Sliding-Window Attention within Gated Delta Networks
Organizations: Xi’an Jiaotong-Liverpool University, Suzhou, China
Abstract
Linear attention compresses historical context into a fixed-size recurrent state, reducing the computational and memory costs of long-sequence modeling. From the perspective of test-time regression (TTR), the state matrix can be viewed as an online-learned regression model, where keys and values serve as inputs and targets respectively, and queries are used to read from the model. From this perspective, the effectiveness of state learning depends not only on the update rule but also on how the key-value learning pairs used for state updates are constructed. While existing work has largely focused on how the state is updated and organized, we investigate how the learning pairs used for state updates are constructed. To this end, we propose Sliding-Window Gated DeltaNet (SWGDN), which replaces short convolutions in Delta-Rule linear attention with sliding-window attention to perform content-dependent local aggregation of projected queries, keys, and values. Our experiments show that SWGDN makes the key-value pairs used in consecutive updates more similar in both GDN2 and KDA. In SWGDN, carrying information from the same token across updates can help the recurrent state reinforce a previously learned association. The local mixing strategy can be incorporated into any Delta-Rule-based linear attention architecture without changing its state update equations or chunkwise parallel algorithms. We apply this strategy to two Delta-Rule variants, GDN2 and KDA, and experimental results demonstrate that SWGDN outperforms the original Delta-Rule baseline across multiple benchmarks.
Figures & tables
| Model | Branch | Entropy | Max. | Current | Previous |
|---|---|---|---|---|---|
| SWKDA-G1 | Q | 0.568 | 0.800 | 0.94 | 0.06 |
| K | 0.658 | 0.742 | 0.62 | 0.32 | |
| V | 0.608 | 0.764 | 0.61 | 0.35 | |
| SWGDN2-G1 | Q | 0.616 | 0.767 | 0.70 | 0.29 |
| K | 0.712 | 0.715 | 0.67 | 0.27 | |
| V | 0.730 | 0.705 | 0.52 | 0.42 |
| Layer | Offset 1 | Offset 2 | Offset 3 |
|---|---|---|---|
| KDA / SWKDA-G1 | |||
| 1 | 1.269 / 0.995 | 1.258 / 1.069 | 1.249 / 1.058 |
| 9 | 1.081 / 0.773 | 1.227 / 0.997 | 1.268 / 1.065 |
| 18 | 1.237 / 0.689 | 1.245 / 0.842 | 1.240 / 0.869 |
| GDN2 / SWGDN2-G1 | |||
| 1 | 1.168 / 0.677 | 1.168 / 0.946 | 1.142 / 1.004 |
| Layer 1 | Layer 9 | Layer 18 | ||||
|---|---|---|---|---|---|---|
| Model | Rate | Median | Rate | Median | Rate | Median |
| GDN2 | 25.0 | 38.7 | 26.2 | |||
| SWGDN2-G1 | 31.8 | 30.9 | 13.7 | |||
| KDA | 18.5 | 51.2 | 30.5 | |||
| SWKDA-G1 | 24.3 | 62.5 | 52.6 | |||
| Model | FW-Web ppl | Wiki. | LMB. | LMB. | PIQA | Hella. | Wino. | ARC-e | ARC-c | OBQA | SIQA | BoolQ | Avg. |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ppl | ppl | acc | acc | acc | acc | acc | acc | acc | acc | acc | acc | ||
| GDN2 | 11.6180 | 29.6074 | 32.1497 | 33.55 | 66.05 | 39.20 | 53.51 | 56.82 | 25.26 | 22.60 | 39.25 | 54.80 | 44.69 |
| GDN2 with DynamicConv | 11.4713 | 28.9051 | 32.2360 | 33.11 | 66.38 | 39.80 | 52.57 | 59.05 | 26.28 | 22.40 | 39.46 | 50.24 | 44.52 |
| SWGDN2-G1 | 11.4657 | 28.8916 | 29.9178 | 33.94 | 65.51 | 39.90 | 52.88 | 57.07 | 25.26 | 22.80 | 38.74 | 57.86 | 45.00 |
| SWGDN2-G16 | 11.4626 | 28.9036 | 30.4465 | 35.05 | 66.43 | 39.80 | 51.22 | 58.96 | 23.63 | 21.40 | 39.00 | 58.96 | 44.93 |
| SWGDN2-G64 | 11.4473 | 29.1324 | 31.9430 | 33.96 | 65.72 | 39.63 | 53.04 | 56.65 | 25.51 | 22.80 | 38.79 | 59.05 | 45.15 |
| GDN2 backbone | KDA backbone | ||||||
|---|---|---|---|---|---|---|---|
| Task | GDN2 | +Dyn. | G1 | G16 | G64 | KDA | G1 |
| SWDE | 16.92 | 15.03 | 16.29 | 17.19 | 15.48 | 15.66 | 20.07 |
| SQuAD | 24.66 | 24.20 | 26.64 | 23.59 | 25.03 | 26.07 | 26.41 |
| FDA | 3.18 | 2.45 | 3.18 | 2.27 | 2.27 | 3.18 | 7.80 |
| TQA | 44.91 | 46.45 | 47.45 | 46.03 | 47.16 | 47.51 | 48.76 |
| NQ | 8.08 | 8.65 | 8.49 | 8.90 | 8.20 | 8.55 | 8.90 |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Depth | Heads | State size | Local mixer | Parameters | ||||
|---|---|---|---|---|---|---|---|---|---|
| GDN2 | 18 | 16 | 64 | 64 | 1,024 | 2,816 | Depthwise conv. | 339,511,712 | |
| GDN2 with DynamicConv | 18 | 16 | 64 | 64 | 1,024 | 2,816 | DynamicConv ( ) | 346,700,192 | |
| SWGDN2-G1 | 18 | 16 | 64 | 64 | 1,024 | 2,816 | SWA | 339,345,824 | |
| SWGDN2-G16 | 18 | 16 | 64 | 64 | 1,024 | 2,816 | SWA | 340,175,264 | |
| SWGDN2-G64 | 18 | 16 | 64 | 64 | 1,024 | 2,816 | SWA | 342,829,472 | |
| KDA | 18 | 16 | 64 | 64 | 1,024 | 3,488 | Depthwise conv. | 339,216,800 |
| Mixer | Query operand | Key operand for offset | Coefficients |
|---|---|---|---|
| Short convolution | Constant scalar | Learned offset scalar | Signed, direct |
| DynamicConv | Projected current input | Learned offset vector | Signed, direct |
| Pseudo-query SWA | Learned branch/group vector | Candidate key with relative RoPE | Window softmax |
| Input-dependent QK SWA | Projected current query | Projected candidate key | Window softmax |
| Argmax frequency (%) | Mean weight (%) | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Model | Branch | ||||||||
| SWKDA-G1 | Q | 93.59 | 5.74 | 0.54 | 0.13 | 77.84 | 15.88 | 3.77 | 2.51 |
| K | 62.15 | 31.81 | 4.33 | 1.72 | 55.88 | 32.39 | 8.50 | 3.24 | |
| V | 60.86 | 35.01 | 3.73 | 0.40 | 55.36 | 35.28 | 7.58 | 1.78 | |
| SWGDN2-G1 | Q | 69.97 | 29.04 | 0.95 | 0.04 | 61.48 | 31.78 | 5.26 | 1.48 |
| K | 66.88 | 27.33 | 4.50 | 1.30 | 57.76 | 30.33 | 8.89 | 3.02 | |
| Model | Branch | Jensen gap | Mean max. | ||
|---|---|---|---|---|---|
| SWKDA-G1 | Q | 0.5679 | 0.6405 | 0.0726 | 0.8002 |
| K | 0.6582 | 0.7677 | 0.1094 | 0.7418 | |
| V | 0.6083 | 0.7618 | 0.1535 | 0.7639 | |
| SWGDN2-G1 | Q | 0.6156 | 0.7091 | 0.0935 | 0.7669 |
| K | 0.7124 | 0.8195 | 0.1071 | 0.7151 | |
| V | 0.7295 | 0.8773 | 0.1479 | 0.7054 |
| Model | Identity gap | Participation ratio |
|---|---|---|
| GDN2 | 0.0567 | 16.10 |
| GDN2 + DynamicConv | 0.0205 | 14.02 |
| SWGDN2-G1 | 0.0187 | 12.04 |
| SWGDN2-G16 | 0.0186 | 13.41 |
| KDA | 0.0400 | 11.57 |
| SWKDA-G1 | 0.0158 | 12.26 |
| Layer | Removal vs. original | Removal vs. magnitude control | Restore first | Also restore second |
|---|---|---|---|---|
| 1 | ||||
| 9 | ||||
| 18 |
Delta-Rule Linear Attention
Delta-rule linear attention updates a compact recurrent memory to retrieve and revise sequence information with linear-time processing.
See all 42 papers