RWKV-7 Stitches Document Caches in 0.65–1.55 ms per Document, but Loses Early Documents
In RAG, a model re-reads the relevant documents from scratch on every query. RWKV-7 compresses what it has read into a fixed-size state, so these states can be computed in advance and stitched together in 0.65–1.55 ms per document (on a MacBook M4 Air). In a multi-layer network, though, the stitching is approximate: early documents get lost, and building the cache adds 6–19% to reading time. So cache frequently used documents and check the answers against a regular full pass.
AI-processed from Хабр: Машинное обучение; edited by Hamidun News
Imagine a RAG system: thousands of documents, and for each query the user wants context assembled from several of them. A transformer re-reads the selected texts every time, and that costs tokens and time. The recurrent model RWKV-7 works differently: it "reads" a document and compresses it into a fixed-size state, a kind of summary.
The idea follows: compute such a summary for each document in advance, then stitch them together in the needed order without running the texts through the model again. Stitching takes 0.65–1.
55 milliseconds per document (measured on a MacBook M4 Air), while building the cache itself costs roughly 6–19% more than an ordinary reading of the document. An independent researcher checked how closely the stitched summary matches the result of ordinary sequential reading, on RWKV-7 checkpoints from 0.4B to 7.
2B. The results are mixed.
What exactly gets stitched
For each document, two things are cached: the state it produced, and the linear transformation it applies to any incoming state. Two documents are combined as a "state plus transformation" pair without re-running the text. For a single layer, this is exact algebra: the divergence from a continuous pass is no more than 2.4e-15 in fp64 and about 8e-7 in fp32 on the 7.2B model. The idea itself is not new; it has relatives such as PICASO/CASO and Priming. What is new here is that the rule was verified across all layers of real models.
In a multi-layer network, the algebra stops being exact. The inputs of the upper layers depend on all the preceding context, while the document cache was built separately. Imagine summarizing a book chapter in advance without knowing what came before: the summary will come out slightly different from one written while reading straight through. The author measured how large this gap is, using synthetic fact retrieval and tasks of picking the correct answer among candidates on SQuAD, HotpotQA, and the Russian-language SberQuAD.
What the measurements showed
Full composition is noticeably better than the simplified variants. On 7.2B it is closer to the continuous pass than the variant with diagonal transitions, across all ten cells of the independent check. Simply adding states together ("soup") loses to it in all five multi-document checks, by 1.22–4.80 units of log-probability, and the gap grows with the number of documents: addition does not account for how later documents change the meaning of earlier ones. If the answer lies in the first document, stitching beats the state from the last document alone, where the answer simply is not present, by 3.4–4.8 units (checkpoints 1.5B and 2.9B).
There are weak spots too. Early documents get lost, and this repeats on every checkpoint tested. With later documents, the outcome depends on the model: on 2.9B and 7.2B the sign of the effect differs, and the author explicitly writes that this is a difference between checkpoints, not a scaling law. One of the pre-registered predictions, a shift between 2.9B and 7.2B, was not confirmed. Such candor raises confidence in the remaining results.
Two practical observations. First: it is better to build a document cache after a text prefix rather than from scratch. Even two prefix tokens reduce the state error roughly 3–4x in the synthetic task. Plain line breaks do not help: for distant targets they can increase the error 2–6x relative to a text prefix. Second: the magnitude of the state error barely predicts whether the answer will suffer. The correlation between the error norm and harm to the answer is close to zero, so the metric "state is close to the reference" cannot replace testing on real questions.
What it costs and what to do about it
The stitching itself is cheap, but the cache is not free: building it costs 1.06–1.19 times an ordinary reading of the document. This pays off only if documents are reused in different combinations. For one-off queries there is no benefit.
Keep the limitations in mind. Timing was measured on a Mac, not on CUDA for 7.2B. The independent replication is built on three seeds. Results for a short warm-up before each cached document come from a single seed and remain exploratory: the author calls the method promising, but not confirmed. Finally, the checkpoints are different models, not one training run with different parameter counts.
Takeaway for developers: if you are building RAG or agents on recurrent models, precomputing document caches is practical, and full composition is clearly better than summing states. But do not expect an exact reproduction of ordinary reading. Cache the documents that are used often, build the cache with a meaningful text prefix, and compare the answers against a continuous pass on your own data. The author's code is on GitHub in the state-composition repository.
- Oct 28, 2026rwkv-quant: keeping one matrix in bf16 removes 39% of RWKV-7 2.9B's quantization loss
- Nov 18, 2026Token position recovered at 99% from a NoPE transformer, but only 29–42% from RWKV-7
- Oct 30, 2026Noise in Embeddings Doesn't Protect Data: 100 Known Pairs Reveal ~90% of Documents
- Nov 8, 2026RWKV-7's system prompt can be “folded” into a state: 12 times faster startup
Key Questions Answered
What exactly gets stitched?
For each document, two things are cached: the state it produced, and the linear transformation it applies to any incoming state. Two documents are combined as a "state plus transformation" pair without re-running the text. For a single layer, this is exact algebra: the divergence from a continuous pass is no more than 2.4e-15 in fp64 and about 8e-7 in fp32 on the 7.2B model. The idea itself is not new; it has relatives such as PICASO/CASO and Priming.
What the measurements showed?
Full composition is noticeably better than the simplified variants. On 7.2B it is closer to the continuous pass than the variant with diagonal transitions, across all ten cells of the independent check. Simply adding states together ("soup") loses to it in all five multi-document checks, by 1.22–4.80 units of log-probability, and the gap grows with the number of documents: addition does not account for how later documents change the meaning of earlier ones.
What it costs and what to do about it?
The stitching itself is cheap, but the cache is not free: building it costs 1.06–1.19 times an ordinary reading of the document. This pays off only if documents are reused in different combinations. For one-off queries there is no benefit. Keep the limitations in mind. Timing was measured on a Mac, not on CUDA for 7.2B. The independent replication is built on three seeds.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
