DBAttention: Database-Backed Attention with External Key–Value Memory for Persistent, Near-Unbounded Context Inference

Autoregressive language models keep every past key and value in accelerator memory. This key–value (KV)cache is what makes decoding fast, and it is also what makes long context expensive: its footprint grows linearlywith sequence length, so the context window of a deployed model is bounded by the smallest memory in the servingpath. Increasing the nominal context limit does not remove the constraint, and it does not resolve context rot, inwhich a model fails to use information that is technically inside its window.This paper presents DBAttention, an attention mechanism in which the model holds no KV cache. Each attentionblock writes the keys and values of the current chunk into a database, keyed by session, layer and block, and fetchesthe rows its access policy allows inside the attention computation. Two policies are supported: an exact policy thatfetches the whole stored history for a layer, and a windowed policy that keeps a bounded working set, which is howcontext can exceed the device’s native limit. Because K/V state is addressed rather than scanned, retrieval cost isindependent of stored history size: measured fetch latency is 0.036 ms median and 0.056 ms at p95 over a store of200,000 rows, with fetched rows byte-identical to stored rows.We implement DBAttention in Ryno-0.8B, a 805.6M-parameter model, and evaluate it on a single 8 GB device.An 8,192-token prefill exhausts GPU memory with a model-resident cache; with DBAttention the same prefill com-pletes at a peak of 1.61 GB, with the store growing to 54.1 MB. Peak memory moves from 1.56 GB to 1.68 GB whilecontext grows sixteenfold, and greedy argmax is unchanged at every length where a native reference exists. We alsoreport two results that correct common assumptions: sharing one database across all layers does not reduce storage(168.5 MB either way for 40,000 rows), and only 6 of the model’s 25 blocks require rows at all, since the remaining18 carry a constant-size recurrent state. A stored context of two million tokens therefore costs 49.2 GB at fp16 orapproximately 17.7 GB with int8 rows, not the 204 GB a per-layer-everywhere projection implies.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-11-25
DOI
https://doi.org/10.5281/zenodo.24529786
Primary Topic
Topic Modeling
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

DBAttention: Database-Backed Attention with External Key–Value Memory for Persistent, Near-Unbounded Context Inference

Irfan Mahir
Zenodo (CERN European Organization for Nuclear Research)
Topic Modeling
article

DBAttention: Database-Backed Attention with External Key–Value Memory for Persistent, Near-Unbounded Context Inference

Irfan Mahir
article en

Abstract

Autoregressive language models keep every past key and value in accelerator memory. This key–value (KV)cache is what makes decoding fast, and it is also what makes long context expensive: its footprint grows linearlywith sequence length, so the context window of a deployed model is bounded by the smallest memory in the servingpath. Increasing the nominal context limit does not remove the constraint, and it does not resolve context rot, inwhich a model fails to use information that is technically inside its window.This paper presents DBAttention, an attention mechanism in which the model holds no KV cache. Each attentionblock writes the keys and values of the current chunk into a database, keyed by session, layer and block, and fetchesthe rows its access policy allows inside the attention computation. Two policies are supported: an exact policy thatfetches the whole stored history for a layer, and a windowed policy that keeps a bounded working set, which is howcontext can exceed the device’s native limit. Because K/V state is addressed rather than scanned, retrieval cost isindependent of stored history size: measured fetch latency is 0.036 ms median and 0.056 ms at p95 over a store of200,000 rows, with fetched rows byte-identical to stored rows.We implement DBAttention in Ryno-0.8B, a 805.6M-parameter model, and evaluate it on a single 8 GB device.An 8,192-token prefill exhausts GPU memory with a model-resident cache; with DBAttention the same prefill com-pletes at a peak of 1.61 GB, with the store growing to 54.1 MB. Peak memory moves from 1.56 GB to 1.68 GB whilecontext grows sixteenfold, and greedy argmax is unchanged at every length where a native reference exists. We alsoreport two results that correct common assumptions: sharing one database across all layers does not reduce storage(168.5 MB either way for 40,000 rows), and only 6 of the model’s 25 blocks require rows at all, since the remaining18 carry a constant-size recurrent state. A stored context of two million tokens therefore costs 49.2 GB at fp16 orapproximately 17.7 GB with int8 rows, not the 204 GB a per-layer-everywhere projection implies.

Zenodo (CERN European Organization for Nuclear Research)
Topic Modeling
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon
DBAttention: Database-Backed Attention with External Key–Value Memory for Persistent, Near-Unbounded Context Inference — Irfan Mahir · Zenodo (CERN European Organization for Nuclear Research) (2026) | TGRS Research Map | TGRS