Answers · How models work
Why can a linear recurrence be computed as a convolution?
In shortBecause a linear recurrence adds up past inputs with fixed decaying weights, and that weighted sum is a convolution with the recurrence's impulse response.
A linear recurrence can be computed as a convolution because its state at any step is a fixed weighted sum of all earlier inputs. The weights are the powers of the carry factor, so they are the impulse response of a filter, and convolving the input with that response produces the same state.
Take one slot first, with carry factor and input written in with weight : . Unrolling by hand gives , then , then . The coefficient on the input from steps ago is , so the state is the causal convolution , plus a term from whatever the slot held before the sequence began.
With diagonal, that matrix sum splits into one independent sum per slot. Slot has its own factor , so its contribution from steps back is , and the whole layer is a bank of convolutions sharing an input but not a kernel. The kernel for slot is the sequence multiplied by the row of that writes into that slot. A readout above the recurrence may mix the slots again, but that is position-by-position work and does not change the convolution property of the carry.
A general linear carry matrix also gives a convolution, with matrix-valued kernel , but diagonal makes it a bank of scalar convolutions. The diagonal choice is a modelling choice for independent timescales, not a condition for convolution to exist. Linearity and a fixed carry are the conditions.
The local filter guess
The natural guess is that convolution means a short local filter, so a recurrence that carries state forever cannot be one. That guess fails because a convolution kernel does not have to be short. For and the kernel is ; it never becomes zero, it only decays. The filter has infinite support. What makes it cheap is that the infinitely many taps are generated by one number and can be applied by a scan or by an FFT, not that the kernel is short.
The impulse response is not hidden far away. Feed a single one at time zero and zeros afterwards. The state at step is , because each step multiplies what is left by . Convolving any input with that response is therefore identical to running the recurrence on that input. The recurrence is the filter, written in the time domain as a loop rather than as a list of taps.
The decay rate is the kernel
Close to one, the kernel decays slowly and the convolution reaches far back. At the tap at lag is , and the slot has lost half of an impulse after steps. At the same calculation gives steps. The kernel is longer by a factor of about a hundred while the carry factor has moved only from nine tenths to nine hundred and ninety nine thousandths.
Direct convolution would cost for steps, an FFT would cost , and running the recurrence costs . Those are three ways to apply the same kernel. The recurrence is usually preferred in a model because it is causal, streaming and needs only the current state; the convolution form is preferred for analysis and for parallel training over a whole sequence. Either way the numbers produced are the same, up to floating point.
For a bank of slots, the impulse response is not one kernel but a list of kernels, one per slot. That is why a layer can hold a fast summary and a slow summary at the same time: each slot convolves the same input with a different geometric kernel.
Where it stops being a convolution
The equivalence depends on the carry being linear and fixed. If changes with , the state is still a weighted sum of past inputs, but the weight on lag is a product of different factors and there is no single kernel to convolve with. If a nonlinearity sits inside the recurrence, superposition fails and the state is no longer a convolution of the input at all. The initial state also contributes , which is a decaying term separate from the input convolution.
Worth keeping
- The kernel of a linear recurrence is the sequence of powers of its carry factor.
- Convolution does not require a short kernel; an exponentially decaying kernel has infinite support.
- If the carry changes over time or a nonlinearity sits inside the loop, the fixed-kernel convolution description fails.
Where this goes next
This question is one step of Models That Carry a Memory, a course that works through its subject from the beginning. The page that teaches this part of it is A Linear Recurrence Done Properly, and it reads the whole way through whether or not you have an account.
What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.
Read that pageThe whole courseOther questions people ask about this
- Why does a transformer need a cache that grows with sequence length?A transformer stores the key and value for every token it has already seen so later tokens can look back at them, and that store grows with the conversation.
- How can a model remember a sequence without keeping every past input?A model can remember a sequence by keeping a fixed-size block of numbers and rewriting it at every step from its old value and the new input.
- How does a gate let information pass through unchanged?A gate lets old information take a direct additive route through the steps, with a learned fraction deciding how much survives each step.
- What is actually stored in the state that a model carries forward?It is a fixed-size block of numbers rewritten at each step from its old value and the new input, not a stored copy of earlier inputs.
- Why does the model get stuck repeating the same sentence over and over?The model is not stuck in a memory loop: once it has written a phrase, that phrase is in its context and makes writing it again more likely, so a decoder that always picks the top word cannot leave.
- Why does diffusion add Gaussian noise instead of any random corruption?Diffusion adds Gaussian noise because Gaussian errors combine exactly: each step keeps the spread fixed and gives a closed-form noisy picture at any later step, which makes the reverse step learnable.