Architecture
~9 min readUpdated: November 2026

SWGDN: Pseudo-Query Sliding-Window Attention in Gated Delta Networks (arXiv:2611.33257)

SWGDN Sliding-Window Gated DeltaNet architecture diagram illustrating W=4 pseudo-query Q/K/V mixing feeding the Test-Time Regression state matrix S_t

SWGDN (arXiv:2611.33257) replaces static depthwise short convolutions in Gated DeltaNet-2 and Kimi Delta Attention (KDA) with lightweight pseudo-query sliding-window attention (W=4). By constructing content-dependent local Q/K/V learning pairs before the unchanged chunkwise recurrent kernel, SWGDN2-G1 jumps S-NIAH-2 1K accuracy from 62.0% to 99.4% and cuts 4K prefill+decode latency 12.1%.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

SWGDN: Pseudo-Query Sliding-Window Attention in Gated Delta Networks (arXiv:2611.33257): SWGDN (arXiv:2611.33257) replaces static depthwise short convolutions in Gated DeltaNet-2 and Kimi Delta Attention (KDA) with lightweight pseudo-query sliding-window attention (W=4). By constructing content-dependent local Q/K/V learning pairs before the unchanged chunkwise recurrent kernel, SWGDN2-G1 jumps S-NIAH-2 1K accuracy from 62.0% to 99.4% and cuts 4K prefill+decode latency 12.1%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleswgdn-pseudo-query-mixer.ts
swgdn-pseudo-query-mixer.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Configure an architecture-research & kernel-benchmarking agent for SWGDN2-G1 / SWKDA-G1
const kernelAgent = createAgent({
agentId: 'swgdn-kernel-benchmarker',
provider: 'openai',
baseUrl: process.env.VLLM_BASE_URL ?? 'http://127.0.0.1:8000/v1',
apiKey: 'local-vllm',
model: 'inclusionAI/Ling-3.2-air',
workspacePath: process.cwd(),
tools: ['filesystem', 'terminal', 'search'],
permission: 'ask-default',
});
kernelAgent.on('permission.required', (event) => {
const cmd = String(event.data.args?.command ?? '');
const allow = ['read_file', 'write_file', 'grep', 'glob'].includes(event.data.toolName) ||
(event.data.toolName === 'run_command' && cmd.startsWith('pytest'));
kernelAgent.resolvePermission(event.data.toolCallId, allow ? 'allow' : 'deny');
});
async function main() {
const res = await kernelAgent.run(
'Implement PseudoQueryWindowMixer (W=4, G=1) replacing nn.Conv1d in layers/gated_deltanet.py, run pytest tests/test_swgdn_equivalence.py, and benchmark 4K decode latency.'
);
console.log('Kernel verification status:', res.status);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

NVIDIA fixed a FLAW in LINEAR ATTENTION nobody was talking about (Gated DeltaNet-2)

Hybrid Attention and Gated DeltaNet: How 2026 LLMs Actually Work

What Is SWGDN? Local Pair Construction for Test-Time Regression

Sliding-Window Gated DeltaNet (SWGDN, arXiv:2611.33257) replaces the fixed depthwise conv1d (W=4) in Delta-Rule linear attention architectures—specifically Gated DeltaNet-2 (GDN2) and Kimi Delta Attention (KDA)—with pseudo-query-driven sliding-window attention. Keeping the recurrent state update and chunkwise parallel kernels untouched, it lets overlapping windows reinforce salient associations across consecutive gradient steps.

Under the Test-Time Regression (TTR) view, linear attention maintains a matrix S_t fitting S k_t ≈ v_t via online gradient descent. Existing architectures (GDN, KDA, GDN2, MesaNet) focus on the update step itself while feeding Q, K, V through static short convolutions whose coefficients depend solely on relative offset. When a subject token shifts from t-2 to t-3 due to an adverb (*"Yesterday Alice thanked Bob"* vs *"Alice warmly thanked Bob"*), static convolutions cannot dynamically track it.

Pseudo-Query Sliding-Window Mixing Mechanics (W = 4)

For each head and branch X ∈ {Q, K, V}, SWGDN learns a compact pseudo-query tensor p^{X,g} of shape G x d (G=1 shares one pseudo-query per head; G=16 or 64 splits channels). Applying RMSNorm + RoPE to p^{X,g} and pre-mixing keys k_i within causal window W_t = {max(1, t-3), ..., t} produces content-dependent weights a^{X,g}_{t,i} = softmax((p^{X,g}_t)^T k_i / sqrt(d)) and mixed outputs x_tilde = SiLU(sum a^{X,g}_{t,i} x_i). At the 340M/15B scale, SWGDN2-G1 cuts 1-token adjacent K/V pair distance in Layer 1 from 1.168 to 0.677 (1.237 -> 0.689 in Layer 18 of SWKDA-G1), turning sequential writes into approximate multi-step SGD on key associations.

Language Modeling, RULER Needle-in-a-Haystack & Real-World Recall

Trained from scratch at 340M parameters on 15B FineWeb tokens, SWGDN2-G1 and SWKDA-G1 beat both fixed-convolution baselines and DynamicConv across perplexity, zero-shot reasoning, RULER NIAH, and six recall-heavy QA tasks.

340M / 15B FineWeb, Recall & Latency Benchmarks

Model VariantFineWeb PPL ↓Wiki PPL ↓Zero-Shot Avg ↑6-Task Recall Avg ↑4K Prefill + Decode (s) ↓
GDN2 (Baseline)11.618029.607444.69%19.36%92.005 s
GDN2 + DynamicConv11.471328.905144.52%19.19%106.960 s
SWGDN2-G1 (1 group/head)11.465728.891645.00%20.23%80.888 s (-12.1%)
SWGDN2-G64 (1 per channel)11.447329.132445.15%19.50%80.561 s
KDA (Baseline)11.115727.418445.62%19.91%78.871 s
SWKDA-G1 (1 group/head)10.924327.014146.11%21.63%66.919 s (-15.2%)

On RULER needle-in-a-haystack tests, SWGDN2-G1 jumps S-NIAH-2 (1K) from 62.0% to 99.4%, while SWGDN2-G64 boosts S-NIAH-1 (4K) from 56.8% to 87.8%. On real-world recall tasks, SWKDA-G1 gains +4.41pp on SWDE (15.66% -> 20.07%) and +4.62pp on FDA (3.18% -> 7.80%).

Why SWGDN Decodes Faster Than `conv1d` & PyTorch Implementation

Measured on an NVIDIA RTX 6000D (BS=1, FP32 weights + BF16 autocast), SWGDN2-G1 and SWKDA-G1 lower both prefill latency (0.044s -> 0.038s on GDN2; 0.041s -> 0.034s on KDA) and full 4K cached decode latency (-12.1% and -15.2%), whereas DynamicConv slows 4K decode down to 106.960 s. During training at BS=16, 2K, throughput stays at 85.3% (SWGDN2-G1) and 83.5% (SWKDA-G1).

python
import torch
import torch.nn as nn
import torch.nn.functional as F

class PseudoQueryWindowMixer(nn.Module):
    """Drop-in replacement for W=4 depthwise conv1d in GDN2/KDA (G=1 default)."""
    def __init__(self, num_heads: int, head_dim: int, window_size: int = 4, groups: int = 1):
        super().__init__()
        self.W = window_size
        self.G = groups
        self.d_g = head_dim // groups
        # Learned pseudo-queries for Q, K, V branches: (3, num_heads, G, d_g)
        self.pseudo_q = nn.Parameter(torch.randn(3, num_heads, groups, self.d_g) * 0.02)
        self.k_norm = nn.RMSNorm(self.d_g)
        self.p_norm = nn.RMSNorm(self.d_g)

    def forward(self, q: torch.Tensor, k: torch.Tensor, v: torch.Tensor):
        # q, k, v: (B, T, H, D) -> unfold causal window of length W=4 and score against k
        # Returns SiLU-activated mixed (q_tilde, k_tilde, v_tilde) for unchanged GDN2/KDA kernel
        raise NotImplementedError("Apply RoPE on window offsets 0..W-1, softmax over W, then F.silu")

Choose G=1 for Optimal Accuracy-to-Memory Ratio

Sharing a single pseudo-query per head (SWGDN2-G1 / SWKDA-G1) captures virtually all perplexity and NIAH gains while avoiding the extra training memory overhead of per-channel G=64 heads (+2.24 GiB at 32K sequence length).

Implications for Hybrid Linear-Attention Agents in Smoke Monkey Harness

Modern open-weight agent models—including Ling-3.2-air (35 KDA layers with short_conv_kernel_size: 4), Haru-4B (24 linear_attention layers with conv_kernel: 4), and Nemotron-Labs-Image-30B-A3B (Mamba-2 conv_kernel: 4)—all rely on static W=4 short convolutions before recurrent updates. SWGDN proves a general recipe for next-generation agent architectures:

  1. Higher Associative Recall Without Growing KV Cache: Content-dependent K/V window mixing preserves O(1) recurrent state size during long multi-file coding loops while sharply improving needle retrieval (S-NIAH-2 +37.4pp).
  2. Drop-In Pre-Training & Mid-Training Upgrade: Teams training custom domain linear-attention checkpoints in Smoke Monkey Harness R&D loops can swap conv1d for PseudoQueryWindowMixer(G=1) without touching Triton chunkwise kernels.
  3. Faster Local Long-Context Prefill: Lowering 4K cached decode overhead by 12–15% directly speeds up iterative test-fix loops in local workstations.
Google Search Questions & Answers

Frequently Asked Questions

Q:How does SWGDN differ from standard Gated DeltaNet-2 and Kimi Delta Attention?

SWGDN leaves the recurrent state update equations and chunkwise parallel kernels completely unchanged. It only replaces the static W=4 short depthwise convolutions on Q, K, and V with content-dependent sliding-window attention scored by learned pseudo-queries.

Q:Why does SWGDN reuse pre-mixing projected keys across all three branches?

In Test-Time Regression, keys act as the regression inputs that determine state update directions. Scoring Q, K, and V against RMSNorm+RoPE projected keys lets the K and V branches reinforce the same salient token across overlapping windows.

Q:What accuracy gains does SWGDN achieve on RULER and real-world recall benchmarks?

At 340M/15B scale, SWGDN2-G1 raises S-NIAH-2 (1K) from 62.0% to 99.4%, SWGDN2-G64 lifts S-NIAH-1 (4K) from 56.8% to 87.8%, and SWKDA-G1 raises 6-task generative recall average from 19.91% to 21.63% (+4.41pp on SWDE, +4.62pp on FDA).

Q:Does replacing conv1d with sliding-window attention slow down inference?

No—on an RTX 6000D, SWGDN2-G1 reduces 4K prefill+decode latency by 12.1% (92.005 s to 80.888 s) and SWKDA-G1 reduces KDA latency by 15.2% (78.871 s to 66.919 s), whereas DynamicConv slows GDN2 down to 106.960 s.

Q:Which pseudo-query grouping setting (G1, G16, or G64) should I use?

G1 (one shared pseudo-query per head in each Q, K, V branch) captures virtually all recall and perplexity improvements with minimal parameter and memory overhead.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness