CoMem: Reusing Transformer Depth across Queries with Persistent Intermediate Residuals
Hanzuo Liu ⋅ Xuan Qi ⋅ Chunyu Liu ⋅ Yulong Wang ⋅ Rayying ⋅ key ⋅ Alex Lamb ⋅ Mingyu Gao
Abstract
Repeated queries over shared documents repeatedly execute the same lower transformer layers. We introduce \textbf{CoMem}, which makes split depth $j$ an explicit reusable-context axis: write one depth-$j$ residual per token, select a bounded chunk set, and resume only layers $[j{:}L)$. Among document-reuse systems we are aware of, CoMem jointly makes split depth a tunable serving axis and isolates it with a matched $j{=}0$ endpoint. On Qwen3-8B, $j{=}12$ reduces selected-pack Read from 931.9 to 664.4 ms ($1.403\times$), with a 3.12-point RULER cost (95\% CI $[2.36,3.93]$); a continuous-prefix oracle recovers the full gap. The resulting depth axis quantifies a quality--latency--storage trade-off; a separate same-adapter, Write-inclusive pipeline is $2.74\times$ faster. Equal-latency raw replay leads by 11.56 points with BM25, directly measuring an applicability boundary of prepaid depth rather than hiding it. CoMem stores 8 KiB/token versus 144 KiB/token for a protocol-aligned same-Qwen3 CacheBlend-style diagnostic; the cohorts and adaptation budgets are not matched. A context--position factorization identifies missing lower-layer document context as the dominant tested multikey error, and a 32-token overlap raises 92.5 to 98.5 without increasing persistent bytes or per-query Read. CoMem opens transformer depth as a measurable, tunable dimension for repeated-query long-context serving.
Chat is not available.
Successful Page Load