Linear Attention, Visualized Moonshot released Kimi K3, a 2-trillion-parameter model with a 1-million-token context window, in July 2026, using its linear-attention variant Kimi Delta Attention (KDA). The model trails only Claude Fable 5 and GPT-5.6 Sol across its evaluation suite, according to Moonshot. KDA and NVIDIA's Nemotron 3, which combines softmax attention with Mamba-2 recurrent layers, both offer linear-time sequence mixing during training and fixed-state decoding, though with some loss of expressiveness. In July 2026, Moonshot released Kimi K3 https://www.kimi.com/blog/kimi-k3 , a 2T-parameter model with a 1M-token context window. K3 uses Moonshot's linear-attention variant, Kimi Delta Attention KDA . Moonshot reports that it trails only Claude Fable 5 and GPT-5.6 Sol across its evaluation suite. NVIDIA had already made a similar choice in Nemotron 3 https://arxiv.org/abs/2512.20856 , which combines softmax attention with Mamba-2 recurrent layers. KDA and Mamba-2 use different recurrences. Both offer linear-time sequence mixing during training and fixed-state decoding, although this efficiency comes with some loss of expressiveness. In this post, we visualize the path from self-attention to the linear-attention variants used in recent models. Self-attention recap Given hidden states $H$, three learned projections produce queries, keys, and values: where $Q,K\in\mathbb R^{n\times d k}$ and $V,O\in\mathbb R^{n\times d v}$, with $n$ denoting the sequence length. Each query $q t$ represents a linear functional on the key space: Evaluating it at $k j$ produces the scalar score $\langle q t,k j\rangle$. Softmax normalizes these scores into weights, and $o t$ is the weighted sum of the corresponding values. Self-attention is quadratic The attention operation uses two matrix multiplications over the sequence: Masking and softmax add $\mathcal O n^2 $ work, so the attention operation costs which is quadratic in the sequence length. A direct implementation stores the $n\times n$ score matrix. FlashAttention avoids materializing this matrix in off-chip memory, but the computation remains quadratic. Optional: Attention vs. FFN For model width $d$ and FFN expansion factor $e$: For $e=4$, the full attention layer attention operation + input/output projections costs more than the FFN when $n 2d$; the attention operation alone does so when $n 4d$. Naïve linear attention The quadratic cost comes from multiplying $Q$ by $K^{\mathsf T}$ first, which produces an $n\times n$ score matrix. If we remove softmax, matrix multiplication is associative, so we can change the order of computation: The left-hand order compares every query with every key before mixing the values. The right-hand order first summarizes all key–value pairs in the $d\times d$ matrix $K^{\mathsf T}V$, then applies each query to that summary. It never constructs an $n\times n$ matrix. The two matrix multiplications now cost Together, they require approximately $4nd^2=\mathcal O nd^2 $ work, which is linear rather than quadratic in the sequence length. This computation is not causal: the shared summary $K^{\mathsf T}V$ contains key–value pairs from the entire sequence, so every query can read the future. The causal version is At first glance, the causal mask appears to prevent direct reassociation of the full matrix product. However, row $t$ of $O$ depends only on $q t$, $K {1:t}$, and $V {1:t}$, as shown below. Hover a row of $O$ to trace its prefix computation. Once the masked columns are removed, row $t$ becomes an ordinary matrix product over a prefix: We call the product of the key and value prefixes the state $S t$: $S t$ is a fixed-size linear map from key space to value space. Moving from one token to the next adds exactly one outer product, so we can build this state recurrently instead of recomputing the entire prefix: Each recurrent step costs $\mathcal O d^2 $, so processing $n$ tokens costs $\mathcal O nd^2 $. The cost is linear in the sequence length, hence the name linear attention. Optional: Linear attention as an RNN This recurrence defines an RNN with a matrix-valued hidden state $S t$. Each key–value pair updates $S t$. The query $q t$ reads $S t$ to produce $o t$. This recurrent view is the idea behind Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention https://arxiv.org/abs/2006.16236 . The recurrent form reduces the arithmetic complexity, but it uses GPUs inefficiently: Large activation memory. A direct autograd implementation saves every $d\times d$ state $S t$ for the backward pass. The $n$ saved states require $\mathcal O nd^2 $ memory. Sequential token updates. Computing $S t$ requires $S {t-1}$. This dependency prevents the GPU from updating different tokens in parallel. Poor Tensor Core utilization. Tensor Cores accelerate tiled matrix multiply-accumulate operations. The outer product $k t^{\mathsf T}v t$ has shape $ d\times1 1\times d $, so its reduction dimension is only one. This shape does not fill the Tensor Core tiles along the reduction dimension. Chunkwise algorithm To solve these problems, we introduce the chunkwise algorithm. It uses the parallel form $\bigl QK^{\mathsf T}\odot M\bigr V$ within each chunk and the recurrent form $S {\mathrm{out}}=S {\mathrm{in}}+K^{\mathsf T}V$ between chunks. Assume $C$ divides $n$. Split the sequence into $n/C$ chunks of $C$ consecutive tokens. Let $Q r,K r,V r\in\mathbb R^{C\times d}$ denote chunk $r$. Block the causal matrix Let $A=QK^{\mathsf T}\odot M$. Partition $A$ into $C\times C$ blocks and partition $V$ and $O$ into $C\times d$ blocks. Let $A {r,s}$ denote block $ r,s $ of $A$. In block row $r$, blocks to the left contain earlier chunks, the diagonal block contains the current chunk, and blocks to the right contain future tokens. A n×n in C×C blocks The output for chunk $r$ splits into history and local contributions: The local block keeps a $C\times C$ causal mask because tokens in the chunk have different prefix lengths. The history blocks need no mask because every token in chunk $r$ may read every token in an earlier chunk. Compress the history Let $K {