You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CAGRouter.retrieve() loads the persisted KV state (load_state) and returns the corpus as context, but never generates with it. The loaded state only accelerates a subsequent generation whose prompt token-prefix matches the raw corpus_text. A typical RAGPipeline wraps context in a system prompt / chat template, so the prefix diverges and llama.cpp re-evaluates from the divergence point — the "warm cache" speedup is reduced or lost.
Additionally, benchmarks/cag_vs_rag_bench.py measures backend.generate_with_cache directly, not the router path, so its "CAG warm" numbers do not reflect what a CAGRouter user gets through retrieve().
Options to consider:
Wire generation through the router (e.g. a generate()/stream() on CAGRouter that builds the corpus-prefixed prompt and calls generate_with_cache), so the cache benefit is realized end-to-end.
Or keep the router retrieval-only and document that callers must generate against the corpus-prefixed prompt to benefit (a limitation note was added to docs/rag/cag.md at merge).
Update the benchmark to measure the router path so the published numbers are representative.
Minor related gaps from the same review: KVCacheStore has no eviction/size bound (llama states are large), and CAGRouter does not implement retrieve_mmr.
Activity
Merge #1010: CAG/RAG router with llama.cpp KV-cache backend (closes #…