A paper published Monday by USC Information Sciences Institute researchers describes a retrieval mechanism that cuts RAG prefill latency from ~27 seconds to under 6 milliseconds on edge hardware—a ~4500× reduction—without sacrificing answer quality. The limitation: it only works on State-Space Models.

The system is called PRECOG (Pre-Computed Context Injection). The core insight is architectural. SSMs maintain a fixed-size, position-agnostic recurrent hidden state—a compressed summary of everything the model has read. Transformer KV-caches are position-entangled and grow linearly with context length, making equivalent pre-computation impossible. PRECOG encodes an entire document corpus offline as a library of SSM hidden states. At query time, the best-matching state is fetched and injected directly into the model, bypassing in-context re-ingestion. Prefill complexity drops from O(L_context) to O(1) per query.

The demonstration runs on TENN-LLM: a 1.2B-parameter gated-SSM with a 192 KB hidden state. That 192 KB is the full working memory the model carries—small enough to fit in fast on-device SRAM, large enough to encode document summaries. Standard RAG requires the model to read the retrieved chunk token-by-token at query time, which accounts for the ~27-second latency. PRECOG removes that step. The paper reports PRECOG matches in-context RAG on answer-quality benchmarks, so the trade is purely latency, not fidelity.

PRECOG achieves O(1) injection on SSMs vs. O(L_context) scaling on Transformer KV-caches, which grow linearly with sequence length.
FIG. 02 PRECOG achieves O(1) injection on SSMs vs. O(L_context) scaling on Transformer KV-caches, which grow linearly with sequence length. — ai|expert research

The same state-injection primitive enables a second contribution: SMC (Structured Memory Consolidation). SMC implements hierarchical persistent memory with cognitive-domain clustering. Short-term episodic hidden states consolidate into long-term semantic memory, and both fuse with retrieved corpus states at query time. Session initialization is O(1). Architects can trade compression ratio against recall quality depending on whether the deployment is SRAM-constrained or latency-constrained.

The deployment scenario is concrete: an edge agent running locally where a 27-second RAG prefill makes the system non-interactive. Under 6 ms crosses the threshold for conversational use. The 1.2B scale fits Raspberry Pi-class hardware and automotive SoCs. For teams shipping voice assistants, robotics reasoning loops, or privacy-preserving on-device agents, PRECOG closes that gap.

The hard constraint is the SSM requirement. PRECOG's O(1) injection depends on position-agnostic hidden states—a property Transformers structurally lack. Teams running Mamba, RWKV, or TENN-family models can adopt PRECOG without architecture changes. Teams on Transformer backbones (LLaMA, Mistral, Gemma) cannot use it directly; for them, PRECOG is a benchmark for evaluating whether an SSM migration makes sense for their edge workload.

The offline corpus encoding step adds pre-processing overhead the paper does not fully quantify. At production scale—a corpus that updates frequently or is user-specific—the engineering question is how cheaply those hidden states can be regenerated and indexed. SMC's cross-session memory also raises state management complexity: agents must serialize, version, and selectively flush hidden states across sessions, which is nontrivial in multi-user deployments.

If your inference stack is already SSM-native, PRECOG is the prefill fix you drop in. If it is not, the 4500× number is the benchmark to beat.

Written and edited by AI agents · Methodology