Manuscript Offprint

arXiv:2610.11214

Bridging KV-Cache Quantization and Linear Attention: From Theory to Pretrained Weight Migration

Kaicheng Xiao, Liran Dong, Haotian Li, Guoliang Xing

ABSTRACT

KV-cache quantization and linear attention are two representative approaches to tackling the storage and computational costs of Transformers. KV-cache quantization compresses individual KV entries into discrete codes but retains all entries, whereas linear attention recurrently aggregates multiple historical KV contributions into a fixed-size continuous state but can introduce interference. This contrast raises the question of whether per-KV compression and multi-KV aggregation can be bridged within a single mechanism for efficient attention. We identify RAM-Net as such a bridge through soft assignments over a discrete address space. These assignments determine recurrent updates to the continuous slot state associated with each address. Under a restricted RAM-Net construction, we prove that soft address assignments extend hard quantized matching to a separable read-write overlap that locally approximates full-attention similarity and supports recurrent aggregation. These connections further enable Transformer-to-RAM-Net weight migration through a new path based on a soft-quantized intermediate construction. Across nine pretrained Transformer models from 0.3B to 7B parameters, RAM-Net recovers an average of 87.1% of the teachers' accuracy gains over random guessing across six commonsense and knowledge tasks using only a 500M-token budget per model.

1 INTRODUCTION

Transformer models have become the dominant architecture for language modeling (Vaswani et al., 2017; Brown et al., 2020). However, the memory use and per-query computation of full attention grow with context length because all historical keys and values are stored in the KV cache and accessed for each query. Two representative approaches reduce these costs in different ways. KV-cache quantization compresses individual KV entries into discrete codes (Liu et al., 2024; Savkin et al., 2025), but retains all entries, so memory still grows with context length. Linear attention instead recurrently aggregates multiple historical KV contributions into a fixed-size continuous state (Katharopoulos et al., 2020; Choromanski et al., 2021), while this aggregation can cause interference among them. This contrast raises the question of whether per-KV compression and multi-KV aggregation can be bridged within a single mechanism for efficient attention. We identify RAM-Net (Xiao et al., 2026) as such a bridge, combining a discrete address space with recurrent continuous slot states. This bridge provides a new view of efficient attention and a new path for weight migration.

We theoretically explain how RAM-Net's soft address assignments connect discrete-code quantization, full attention, and linear attention within a restricted subset of RAM-Net. These assignments generalize hard code selection in KV quantization, recovering quantized-key matching in the hard-write limit while reads remain soft. We further prove that the overlap between soft read and write assignments locally approximates the exponential dot-product similarity of full attention without reconstructing keys from discrete codes. Moreover, the address overlap is exactly separable into read

∗^{*}Equal contribution.

and write terms. This separability enables historical KV contributions to be recurrently aggregated into continuous slot states, yielding the linear-style continuous state construction.

These theoretical connections further enable practical Transformer-to-RAM-Net migration across a broad range of pretrained Transformers. Unlike prior Transformer-to-linear migration methods (Goldstein et al., 2025; Bick et al., 2024), our migration introduces a soft-quantized intermediate attention model that replaces exponential dot-product matching with separable address overlap. To construct the soft-quantized intermediate attention model, we first compress and align the Transformer's query and key projections to match its attention patterns. We then fold a codebook into the aligned projections to implement soft quantization, while copying the remaining shared parameters from the Transformer. Finally, we initialize RAM-Net with the intermediate model's parameters and progressively fine-tune it to compensate for approximation errors and architectural differences.

We evaluate the migration design on nine publicly available pretrained Transformer models covering five model families, multi-head attention (MHA) and grouped-query attention (GQA) (Ainslie et al., 2023) configurations, and scales from 0.3B to 7B parameters. With a migration budget of only 500M tokens per model, RAM-Net recovers an average of 87.1% of the teachers' accuracy gains over random guessing across six commonsense and knowledge tasks. Ablations on the intermediate construction show that the theory-guided design improves attention alignment with the teacher and generally leads to lower output error during head-level recovery. Together with the downstream gains from staged recovery under the same total token budget, these findings support the practical value of our theory-guided migration design.

References (59)