The gate and the short conv
How the hidden state decides how much memory to let in, why the demo takes a signed square root, and what the dilated causal conv adds.
The lookup can't see context
The rows come from the last few tokens only. A hash collision brings back another n-gram's memory, and even a correct read can be wrong for this document - “bank” after “river” versus after “central”. The hidden state at this position knows much more, so Engram lets it decide.
The gate
The memory e (all rows, concatenated) is projected to a key and compared with the hidden state h, which plays the query:
Then value = gate · W_V e. With hyper-connections (the paper uses 4 streams) each stream has its own key projection and norms, so its own gate; the value projection is shared.
Why the square root
RMSNorm makes both vectors length √d, so z = cos · √d. At d = 1,024 that is 32 · cos: a cosine of 0.2 already gives σ(6.4) = 0.998. The signed square root brings the same input to σ(2.53) = 0.926, so the gate stays graded across a wider range of agreement. Drag the width up and compare the curves:
Quick check
What shape is the gate for hidden states [b, s, d] with one stream?
A short conv over the gated values
The last step runs a depthwise causal convolution over RMSNorm(value), then adds it back:
y[12] = w0·v[3] + w1·v[6] + w2·v[9] + w3·v[12] → SiLU
Receptive field: 10 tokens.
With dilation 3, the conv lines up with trigram boundaries: it mixes the memories of the previous non-overlapping trigrams into this one. The paper's ablation found that removing it “only marginally degrades performance” - it is the least important of the parts.
Quick check
Kernel 4, dilation 3, output position t = 10. Which positions does it read?