advanced · Session 16

Gated DeltaNet and selective forgetting

Add decay and write gates to correctable memory.

120 min6 mechanismscausal lab

What you will be able to do

Open the lab

Study method

Study this session as a causal investigation. Before every formula or interaction, write what you expect to change and what must remain fixed. During the calculation, retain units, shapes, and intermediate values so an error can be located without restarting at random. After the result, translate the number or state into one sentence about system behavior. Always finish with a counterexample or boundary value. This discipline separates understanding a mechanism from merely recognizing its vocabulary and makes the lab reproducible by another learner. Record the evidence that changed your initial prediction.

Build the mechanism step by step

1. Why forget

The problem: A document changes topic at token 500; the delta memory keeps everything. The old topic’s associations keep answering the new topic’s queries — session 13’s superposition returns, not through nearby keys but through sheer accumulation over time.

The idea: Reverse the reflex: forgetting is a function, not a failure. A fixed-capacity memory that never frees anything eventually distinguishes nothing; erasing the stale is exactly what keeps the present readable.

Why / at what price: Forgetting frees capacity and bounds the past’s influence. The price, obvious but real: what has decayed is gone — a fact stated at token 10 and needed at token 10,000 must have been rewritten in between, or it no longer exists.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

2. Decay gate

The problem: Fine, forget — but how fast? A fixed rate would be wrong everywhere: a dialogue wants to hold 50 tokens, a contract 5,000. Forgetting must be driven by content, not by a global constant.

The idea: A gate α_t ∈ [0,1], produced at every token, multiplies the state before the write: S′ = α_t·S_{t−1}. At 0.8 a trace follows 1 → 0.8 → 0.64, and its half-life is ln(0.5)/ln(0.8) ≈ 3.1 tokens. The model learns when to tighten or open the gate.

S_t=α_t S_{t−1}+update_t

Why / at what price: Forgetting becomes measurable — a half-life — and contextual. The price: decay is global. Row 2 of the trace, never rewritten, decays anyway; whatever is not regularly rewritten evaporates, relevant or not.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

3. Write gate

The problem: Symmetrically: does every token deserve to write? A redundant “the” writing at full strength wastes capacity and pushes the state toward interference; a critical correction written timidly corrects nothing.

The idea: β_t doses the delta correction: S_t = S′ + β_t k eᵀ. In the trace, β = 0.5 applies only half the error — exactly (1−β)·e remains. β ≈ 0 ignores, β = 1 fully corrects, decided token by token.

Why / at what price: Two independent gates: α decides what stays, β what enters — fine-grained, and learned. The price: two settings that can compensate each other; diagnosing “memory too short” requires separating α’s effect from β’s.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

4. Stability

The problem: These recurrences run 100,000 times in a row. A gate at 1.05 — 5% too much — multiplies the state by 7 in 40 tokens, by 131 in 100. And the same code with correct-then-decay ordering produces different numbers: two models for one formula.

The idea: Stability rests on binding details: α bounded in [0,1] — not merely |α| ≤ 1, a negative α would flip the sign each step —, normalized keys, and a declared operation order: decay, read, correct.

Why / at what price: These constraints make the recurrence safe at arbitrary length. The price: nothing is cosmetic — an implementation writing S = αS + βk eᵀ without stating the order is irreproducible. The details are the architecture.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

5. Effective capacity

The problem: S is still 2×2 — yet α = 0.99 and α = 0.80 yield radically different memories. If the physical size never moves, what exactly does this model’s “memory” measure?

The idea: The right quantity is useful lifetime: half-life ≈ 69 tokens at α = 0.99, ≈ 3.1 at α = 0.80, 1.0 at α = 0.5. Effective capacity combines S’s size, forgetting, and key separation — not the advertised maximum context length.

Why / at what price: Half-life gives an honest language for comparing memories — and for reading announcements: “1 M token context” says nothing about what survives 1,000 steps. The price: it is an average; actual retention depends on the learned gates, hence on content.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

6. Connection to Mamba

The problem: Two families — SSMs (Mamba) and gated delta memories — advertise the same pitch: fixed state, input-dependent gates, long context. Should you conclude they are interchangeable, and benchmark one to choose the other?

The idea: The overlap is real: recurrence plus learned controls. So is the difference: the delta memory READS its state (v̂ = S′ᵀk) and writes the error; a classical SSM filters the signal with no associative read. Same family of motivations, distinct equations.

Why / at what price: The parallel guides intuition and tool transfer (chunking, gates). The price of the easy analogy: non-transferable conclusions — a Mamba result proves nothing about Gated DeltaNet, and vice versa. Comparing requires both implementations, same task, same budget.

Understanding check

Name the input, transformed state, output, and one required assumption. Then compare your chain with the explanation above.

Development from the course source

Chapter 11 — Forgetting: Gated DeltaNet and the Mamba connection

11.1 Why forgetting helps

Goal: prevent old information from occupying memory forever. A gate is a learned number, often between 0 and 1, that controls how much information passes.

Intuition: A whiteboard is useful because we can partly erase outdated notes before writing new ones.

Step by step

  • Apply broad decay: S ← αS, where α is near 1 to remember and near 0 to forget strongly.

  • Apply the targeted delta correction for the current key.

  • Use β to control write strength.

Worked example: if S contains 10 and α=0.8, decay leaves 8 before the new write. Repeating 0.8 decay gives 10, 8, 6.4, 5.12… Old influence fades smoothly.

Why it matters: Forgetting is selective resource management. It can improve effective capacity when old details are no longer useful.

Quick check: Does α=1 erase memory? Answer: No; it keeps the old state unchanged before the new write.

11.2 Connection to Mamba

Goal: place gated recurrent memory in a broader family. Mamba is a selective state-space model: it carries a fixed-size state through sequence time and lets input-dependent controls decide what to retain and inject.

Intuition: Both systems resemble a running scientific experiment: keep a state, decay or transform it, add new evidence, and produce an output.

Step by step

  • Shared theme: recurrent fixed-size state.

  • Shared theme: learned, input-dependent gates.

  • Important difference: Delta-style memory explicitly uses key-value association and correction; Mamba is usually written with state-space equations.

Worked example: The connection is conceptual, not an assertion that the two architectures are identical.

Why it matters: Recognizing families helps us compare design choices without collapsing distinct mechanisms into one name.

Quick check: What is the shared central idea? Answer: a learned fixed-size state updated as the sequence advances.

Complete worked case

With α=0.8, a trace of value 1 becomes 0.8 then 0.64 without new writes. Correction β=0.5 then adds only half the observed error.

Reading method: write the data, state every object shape, perform one transformation, and interpret the result before continuing.

Validity boundary

The Mamba parallel is conceptual. It does not imply Gated DeltaNet and Mamba are interchangeable.

Evidence status: Established: the delta rule, exponential decay, and the half-lives computed here. Pedagogical: the α, β values and the 2×2 matrices of the trace. Reported: the exact gate choices of named models.

Quick checks

1. What does Why forget?

Reverse the reflex: forgetting is a function, not a failure. A fixed-capacity memory that never frees anything eventually distinguishes nothing; erasing the stale is exactly what keeps the present readable.

2. What does Decay gate?

A gate α_t ∈ [0,1], produced at every token, multiplies the state before the write: S′ = α_t·S_{t−1}. At 0.8 a trace follows 1 → 0.8 → 0.64, and its half-life is ln(0.5)/ln(0.8) ≈ 3.1 tokens. The model learns when to tighten or open the gate.

3. What does Write gate?

β_t doses the delta correction: S_t = S′ + β_t k eᵀ. In the trace, β = 0.5 applies only half the error — exactly (1−β)·e remains. β ≈ 0 ignores, β = 1 fully corrects, decided token by token.

4. What does Stability?

Stability rests on binding details: α bounded in [0,1] — not merely |α| ≤ 1, a negative α would flip the sign each step —, normalized keys, and a declared operation order: decay, read, correct.

Sources and evidence boundary

Scope: Established: the delta rule, exponential decay, and the half-lives computed here. Pedagogical: the α, β values and the 2×2 matrices of the trace. Reported: the exact gate choices of named models.