[KongchangAI]
· 1 min read· 865 words

Unwrite: Precise Deletion of Linear Attention Memory Without Replay

Unwrite: Precise Deletion of Linear Attention Memory Without Replay

Unwrite achieves fast, precise memory deletion in linear attention models using record-free states and low-rank differences.

Linear attention mixes tokens into a fixed-size recurrent state, so records cannot be deleted by discarding key-value pairs as in softmax attention. Replay reprocesses everything after the record at high cost; subtraction only removes the difference saved at read time, missing later effects. Unwrite maintains a record-free state in sync during reading, captures the record's influence on later tokens, and stores state differences in low-rank form. Deletion needs no original text or checkpoints; on pure recurrent models it is one addition, equivalent to full-rank replay. Results match replay quality, remove more influence than attention masking on hybrid models, take ~1.4 ms, and are up to 739× faster than replay on Gated DeltaNet 1.3B.

Linear attention models, when they need to delete user misinputs or sensitive information during inference, traditionally must either replay all subsequent computation or only crudely subtract the difference saved when the record was read. A recent study, Unwrite, proposes a method that maintains a "record-free state," storing state differences in low-rank form without requiring the original text or checkpoints, enabling fast and precise record deletion.

The Challenge of Memory Deletion in Linear Attention

Softmax attention can delete records by discarding key-value pairs, but linear attention mixes each token into a fixed-size recurrent state with no per-token entries. Existing remedies have two clear flaws: replay reprocesses everything after the record, incurring large computational overhead; the cheaper subtraction method only subtracts the difference saved when the record was read, missing the record's influence on subsequent tokens.

Linear Attention and Recurrent State

Linear attention approximates softmax attention with kernel functions, rewriting the attention computation into a recursive form: the model maintains a fixed-size state matrix, updating it with the outer product of each incoming token's key and value, and the output is obtained by multiplying the current query with this state. This makes inference memory usage independent of sequence length, at the cost of all token information being mixed and compressed into the state, with no per-token key-value entries retained. Consequently, the intuitive deletion approach in softmax attention—"discard the corresponding key-value pair"—fails in linear attention; one must reverse-subtract a token's contribution from the mixed state, and that contribution has already been amplified and propagated through subsequent tokens' reads.

Unwrite's Core Mechanism

Unwrite maintains, in sync while the model reads text, a "record-free state" that skips the target record. Specifically, it runs on a copy of the model state that reads in sync with the main model during each subsequent token's forward pass, thereby capturing the record's influence on those tokens. The difference between the two states is stored in low-rank form.

The key advantage: deletion requires neither the original text nor checkpoints. On pure recurrent models, a single deletion requires just one addition, equivalent to full-rank replay.

Low-Rank Difference Storage

Low-rank means a matrix can be approximated as the product of two thinner matrices, storing it with far fewer elements than the original matrix. In Unwrite, the difference between the main state and the record-free state is essentially produced only by the deleted record and its subsequent interactions, and its effective rank is typically far smaller than the state dimension, so it can be compactly saved via low-rank decomposition. Deletion then only requires recomposing the low-rank factors and subtracting them from the main state, avoiding the GPU memory overhead of saving a full state copy and keeping the computation per deletion small. Whether the low-rank approximation is sufficiently accurate depends on the rank structure of the record's influence; comparison with full-rank replay results in experiments tests this approximation.

Experimental Results and Performance

On three linear attention models, Unwrite's answer quality is comparable to replay methods; on hybrid models, it removes more record influence than attention masking. Because the extra work is already done during the read phase, deletion takes only about 1.4 milliseconds, up to 739 times faster than checkpoint replay on Gated DeltaNet 1.3B.

Unwrite method diagram

Gated DeltaNet and Hybrid Models

Gated DeltaNet is a class of gated incremental linear attention architectures that update state via the delta rule and introduce gating to control decay of old information, performing close to Transformer on long-sequence modeling and often used in efficient inference models. This paper uses its 1.3B parameter version as a large-scale benchmark, showing the method remains effective on real-scale models. Hybrid models refer to architectures containing both linear attention layers and standard softmax attention layers, where the softmax layers can mask records via attention masking but the linear layers cannot; thus hybrid models are exactly the key scenario for testing whether Unwrite can compensate for deletion capability in the linear part.

Application Prospects

Unwrite provides an efficient memory deletion solution for language model assistants, especially suited to scenarios requiring real-time handling of user sensitive information. Its low-rank difference storage and replay-free nature allow privacy protection and computational efficiency to be balanced in large-scale deployment.

One-line Summary

Unwrite uses record-free states and low-rank differences to achieve fast, precise memory deletion in linear attention models.

Paragraph Summary

Linear attention mixes tokens into a fixed-size recurrent state, unable to delete records by directly discarding key-value pairs like softmax attention. Replay methods must reprocess everything after the record, incurring large computational overhead; subtraction methods only subtract the difference saved when the record was read, missing its influence on subsequent tokens. Unwrite maintains in sync, while reading text, a record-free state that skips the target record, capturing the record's influence on subsequent tokens, and stores the difference between the two states in low-rank form. Deletion requires neither original text nor checkpoints; on pure recurrent models, a single deletion requires just one addition, equivalent to full-rank replay. Experiments show its answer quality is comparable to replay, it removes more influence than attention masking on hybrid models, deletion takes about 1.4 milliseconds, and it is up to 739 times faster than replay on Gated DeltaNet 1.3B.

#Unwrite#linear attention#memory deletion#record-free state#low-rank difference#Gated DeltaNet#replay-free#privacy protection
Share:

Related articles