Deleting a record read at inference time is important for language model assistants when a user has entered wrong or sensitive information. Softmax attention can drop the keys and values of the record, but linear attention mixes every token into fixed-size recurrent states without per-token entries. We identify two limitations of the existing remedies: (i) replay reprocesses everything read after the record, and (ii) cheaper remedies subtract a difference saved when the record is read and miss the record's effect on later tokens. We propose Unwrite, which addresses both limitations by maintaining the record-free state alongside the model as it reads the text. Specifically, Unwrite runs the model on a copy of its state that skips the record and stores the difference between the two states at low rank. This copy reads every later token in the same forward pass as the model and thus captures the record's effect on these tokens. While needing neither the text nor a checkpoint, a single deletion is one addition that equals replay at full rank on purely recurrent models. Empirically, Unwrite matches replay on answers on three linear attention models and removes more of the record's effect than attention masking on a hybrid model. Since its extra work is done during reading, a deletion takes about 1.4 ms and is up to $739\times$ faster than checkpoint replay on Gated DeltaNet 1.3B.
The reference is the record-free state $\mathbf{M}^-_T$: the state the same model reaches on the same context with the record omitted. We write $\mathbf{M}^+_t$ for the state of the run that read the record and align the two runs by the tokens after the record, so that both read $x_{\tau+1}, \ldots, x_T$. Let $\bm{\Delta}_t = \mathbf{M}^+_t - \mathbf{M}^-_t$ be the difference between the two runs in one head of one layer.
$$\bm{\Delta}_T = \underbrace{\bm{\Delta}_\tau\, \bm{\Phi}_{\tau+1:T}}_{\text{initial condition response}} \; + \; \underbrace{\sum_{s=\tau+1}^{T} \mathbf{F}_s\, \bm{\Phi}_{s+1:T}}_{\text{forced response}}$$
The first term is what the record wrote, carried forward by the transitions of the run that read it. The second term did not exist when the record was written. A later token produces a different key, value or gate when the record is present, because the layers below it computed different hidden states.
Subtraction saves $\bm{\Delta}_\tau$ when the record ends and subtracts it at time $T$. Propagation carries $\bm{\Delta}_\tau$ through the record-present transitions, $\bm{\Delta}_\tau \bm{\Phi}_{\tau+1:T}$, and subtracts it. It keeps the first term and drops the second. Thus, its error is the forced response. Replay keeps every term by recomputing $\mathbf{M}^-_T$, at the price of the record-free text and a forward pass over everything read after the record.
When a record begins, Unwrite copies the current state into a second row of the batch, the counterfactual row $\widehat{\mathbf{M}}$. The record-present row reads the record. The counterfactual row does not. Without any approximation, $\widehat{\mathbf{M}}_t = \mathbf{M}^-_t$ for every $t \ge \tau$: the counterfactual row is replay, performed while the text is read rather than after a deletion request. The truncation is applied when the record ends and then every $k$ tokens. At deletion time $T$ the record-present state is replaced by $$\mathbf{M}^{\mathrm{Unwrite}}_T = \mathbf{M}^+_T + \mathcal{P}_r\bigl(\widehat{\mathbf{M}}_T - \mathbf{M}^+_T\bigr),$$ a single addition per head that needs neither the text of the record nor the text read after it.
On TOFU contexts Unwrite with $r = 32$ leaves a residual effect of about $1\%$ on all three models at both lengths. Propagation matches replay on these answers too. They differ in the state, where Unwrite leaves a smaller residual than propagation on all three models at both lengths.
| GLA 340M | GDN 340M | GDN 1.3B | ||||
|---|---|---|---|---|---|---|
| Method | 128 | 1024 | 128 | 1024 | 128 | 1024 |
| (a) Residual effect (%) → 0 | ||||||
| Record present | 100.0 | 100.0 | 100.0 | 100.0 | 100.0 | 100.0 |
| Replay | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Instruction-only (quote) | 155.8 | 419.0 | 117.0 | 225.6 | 105.3 | 112.4 |
| Instruction-only (neutral) | 89.5 | 89.7 | 89.1 | 89.8 | 99.7 | 101.9 |
| Subtraction | −19.9 | −110.9 | −15.8 | −82.0 | −9.5 | −24.9 |
| Propagation | 0.2 | −0.6 | 0.2 | 0.1 | 0.1 | −0.3 |
| Unwrite ($r{=}16$) | 4.1 | 4.9 | 5.1 | 4.9 | 6.4 | 4.1 |
| Unwrite ($r{=}32$) | 0.9 | 1.1 | 0.8 | 0.9 | 0.8 | 0.7 |
| Unwrite ($r{=}64$) | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
| (b) Residual difference ↓ | ||||||
| Subtraction | 1.745 | 3.258 | 1.016 | 1.885 | 1.648 | 3.504 |
| Propagation | 0.359 | 0.419 | 0.251 | 0.318 | 0.354 | 0.451 |
| Unwrite ($r{=}16$) | 0.302 | 0.283 | 0.321 | 0.354 | 0.433 | 0.471 |
| Unwrite ($r{=}32$) | 0.163 | 0.160 | 0.167 | 0.215 | 0.264 | 0.321 |
| Unwrite ($r{=}64$) | 0.052 | 0.061 | 0.069 | 0.117 | 0.130 | 0.188 |
Deleting one TOFU record (test contexts, $k{=}64$). 128 and 1024: tokens after the record. Negative residual effects overshoot replay. Bold and underlined: closest and second closest to replay in each column; a column is not marked where its closest value and the next distinct value differ by less than the larger of their 95% intervals. Entries that tie at the closest printed value are all marked.
In the needle data the retained needle repeats the key string of the target needle, and the probe for its number asks for that key string. Therefore, the retained needle is where collateral damage shows. Unwrite with $r = 32$ does none: the retained needle's loss matches that of replay on all three models, and the first generated number is the retained needle's as often as after replay. Propagation also removes the target needle, but its collateral damage is as large as the effect of leaving the record in place, and larger on both Gated DeltaNet models.
| 1K context | GDN 1.3B | |||||
|---|---|---|---|---|---|---|
| Method | GLA 340M | GDN 340M | GDN 1.3B | 2K | 4K | 8K |
| (a) First generated number is the retained needle's (%) → replay | ||||||
| Record present | 43.0 | 70.0 | 32.0 | 56.0 | 45.0 | 36.0 |
| Replay | 74.0 | 73.0 | 100.0 | 96.0 | 92.0 | 66.0 |
| Instruction-only | 3.0 | 22.0 | 6.0 | 5.0 | 2.0 | 1.0 |
| Subtraction | 12.0 | 0.0 | 5.0 | 2.0 | 1.0 | 0.0 |
| Propagation | 47.0 | 51.0 | 38.0 | 58.0 | 50.0 | 30.0 |
| Unwrite ($r{=}16$) | 73.0 | 73.0 | 99.0 | 93.0 | 92.0 | 61.0 |
| Unwrite ($r{=}32$) | 73.0 | 74.0 | 100.0 | 97.0 | 92.0 | 65.0 |
| Unwrite ($r{=}64$) | 74.0 | 72.0 | 100.0 | 96.0 | 92.0 | 66.0 |
| (b) Retained-needle loss increase over replay (nats/token) → 0 | ||||||
| Record present | 0.27 (0.04) | 0.19 (0.03) | 0.24 (0.02) | 0.18 | 0.18 | 0.20 |
| Instruction-only | 0.61 (0.08) | 0.28 (0.04) | 0.15 (0.02) | 0.21 | 0.33 | 0.51 |
| Subtraction | 0.83 (0.12) | 1.75 (0.13) | 1.07 (0.07) | 1.32 | 1.60 | 1.81 |
| Propagation | 0.25 (0.06) | 0.30 (0.04) | 0.39 (0.03) | 0.30 | 0.35 | 0.48 |
| Unwrite ($r{=}16$) | 0.01 (0.01) | 0.00 | 0.00 | 0.00 | 0.00 | 0.01 |
| Unwrite ($r{=}32$) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Unwrite ($r{=}64$) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| (c) Target-needle residual (%) → 0 | ||||||
| Propagation | −7.6 | 2.9 | −1.0 | −0.5 | −0.2 | −0.4 |
| Unwrite ($r{=}16$) | 2.3 | 1.7 | 3.9 | 3.0 | 3.2 | 2.4 |
| Unwrite ($r{=}32$) | 0.2 | 0.3 | 0.3 | 0.4 | 0.4 | 0.4 |
| Unwrite ($r{=}64$) | 0.0 | 0.1 | 0.0 | 0.1 | 0.1 | 0.2 |
| (d) Residual difference ↓ | ||||||
| Propagation | 0.848 | 0.849 | 1.014 | 1.005 | 1.006 | 1.005 |
| Unwrite ($r{=}16$) | 0.313 | 0.347 | 0.436 | 0.424 | 0.424 | 0.428 |
| Unwrite ($r{=}32$) | 0.169 | 0.203 | 0.289 | 0.289 | 0.298 | 0.309 |
| Unwrite ($r{=}64$) | 0.064 | 0.105 | 0.167 | 0.175 | 0.189 | 0.204 |
KVEraser needle data. (b) At 1K, the half-width of the 95% interval in parentheses, omitted where it rounds to zero. (d) Mean over items. The instruction, which leaves the record in place, is not ranked. Bold and underlined: closest and second closest to replay in each column of (a) and (b); bold: closest in (c) and (d). A column is not marked where its closest value and the next distinct value differ by less than the larger of their 95% intervals (bootstrap over items; not shown except in (b) at 1K).
Hybrid models such as Kimi Linear and Qwen3.5 interleave recurrent layers with full-attention layers, which keep one key and one value per token. On the Kimi contexts with Qwen3.5, propagation alone does nothing: the record stays in the attention cache and the lift is as large as with the record present. Attention masking removes most of the lift, and masking + propagation removes more. At the ranks selected on calibration contexts, Unwrite and Unwrite with tracked attention leave a lift of about $0.005$ nats per token.
| Kimi contexts | Qwen contexts | TOFU | ||||
|---|---|---|---|---|---|---|
| Method | Lift → 0 | $\Delta$AUC → 0 | Short ↓ | Long ↓ | 128 → 0 | 1024 → 0 |
| Record present | 2.5742 (0.1186) | 98.9 | 1.000 | 1.000 | 100.0 | 100.0 |
| Replay | 0.0000 | 0.0 | 0.000 | 0.000 | 0.0 | 0.0 |
| Instruction-only | 2.4127 (0.1141) | 98.9 | 1.357 (0.023) | 1.747 (0.031) | 100.7 (0.5) | 101.6 (0.4) |
| Propagation | 2.5755 (0.1184) | 98.9 | 0.522 (0.007) | 0.579 (0.005) | 99.2 (0.3) | 99.8 (0.1) |
| Attention masking | 0.0813 (0.0137) | 14.5 | 1.000 | 1.000 | 7.8 (1.0) | 2.1 (0.4) |
| + propagation | 0.0174 (0.0065) | 3.4 | 0.522 (0.007) | 0.579 (0.005) | 1.0 (0.3) | 0.2 (0.3) |
| Unwrite ($r{=}16$)$^{\ast}$ | 0.0049 (0.0053) | −0.1 | 0.335 (0.013) | 0.476 (0.008) | 1.0 (0.2) | 0.4 (0.3) |
| Unwrite ($r{=}32$) | 0.0037 (0.0054) | −0.3 | 0.285 (0.015) | 0.447 (0.009) | 0.4 (0.2) | 0.2 (0.3) |
| Reference: Unwrite with tracked attention (not ranked) | ||||||
| $r{=}8$$^{\ast}$ | 0.0053 (0.0019) | 1.6 | 0.332 (0.006) | 0.406 (0.007) | 1.8 (0.2) | 0.6 (0.1) |
| $r{=}32$ | −0.0006 (0.0006) | −1.4 | 0.095 (0.002) | 0.148 (0.003) | 0.2 | 0.1 |
Qwen3.5-4B-Base. Kimi contexts: lift (nats/token) and $\Delta$AUC, the relative difference of the AUC from that of replay (%), on the 40 evaluation contexts. Qwen contexts: the per-layer relative error, short and long suffix. TOFU: residual effect (%) on the test contexts. In parentheses, the half-width of the 95% interval, omitted where it rounds to zero. $^{\ast}$Rank selected on calibration contexts. Instruction-only uses the forget prompt of on the Kimi contexts and the quote prompt of KVEraser on the Qwen contexts and TOFU. Bold and underlined: closest and second closest to replay in each column except lift, $\Delta$AUC and 1024 tokens, whose closest and next distinct values differ by less than their intervals. Entries that tie at the closest printed value are all marked. The interval of $\Delta$AUC (bootstrap over contexts) is not shown.
We time the deletion of one record on GDN 1.3B on one H200 GPU, in float32 as in the accuracy runs. Unwrite deletes a record in a time that does not depend on the number of tokens read after it, since it adds the product of the stored factors to the state and copies one convolution cache. Checkpoint replay takes up to $739$ times as long as Unwrite after 16K tokens. Over a whole read, one tracked record therefore costs about four times a replay of the same text at $k = 256$.
@article{qiao2026unwrite,
title = {Unwrite: Deleting Records from Linear Attention Memory without Replay},
author = {Qiao, Yihao and Hu, Sihao},
journal = {arXiv preprint arXiv:2612.04321},
year = {2026}
}