Architecture
~8 min readUpdated: November 2026

RebaseKV: Hiding Prefill Latency in Multi-Agent LLMs via Optimistic Cache Alignment

RebaseKV Optimistic KV-Cache Alignment Architecture in Smoke Monkey

RebaseKV (arXiv:2611.35764) is a training-free serving technique that eliminates prefill stalls at multi-agent LLM handoffs. When agent role prompts shift shared context and break exact prefix caching, RebaseKV decodes an optimistic window from RoPE-shifted inherited KV states on a high-priority CUDA stream while computing the exact KV cache concurrently, cutting TTFT by 2.95x (46 ms vs 135 ms) with zero stall.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

RebaseKV: Hiding Prefill Latency in Multi-Agent LLMs via Optimistic Cache Alignment: RebaseKV (arXiv:2611.35764) is a training-free serving technique that eliminates prefill stalls at multi-agent LLM handoffs. When agent role prompts shift shared context and break exact prefix caching, RebaseKV decodes an optimistic window from RoPE-shifted inherited KV states on a high-priority CUDA stream while computing the exact KV cache concurrently, cutting TTFT by 2.95x (46 ms vs 135 ms) with zero stall. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Examplerebasekv-pipeline-router.ts
rebasekv-pipeline-router.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Configure reasoning handoffs for optimistic KV rebase while keeping structured decision agents exact
const reasoningCritic = createAgent({
agentId: 'rebased-critic-agent',
provider: 'vllm',
model: 'Qwen/Qwen3-8B',
workspacePath: process.cwd(),
permissions: { read_file: 'allow', write_file: 'deny', run_command: 'deny' },
extraBody: {
kv_cache_mode: 'rebase_optimistic',
stream_priority: 'high',
exact_replay_window: 'auto',
},
});
const decisionMaker = createAgent({
agentId: 'exact-json-decision-maker',
provider: 'vllm',
model: 'Qwen/Qwen3-8B',
workspacePath: process.cwd(),
permissions: { read_file: 'allow', write_file: 'allow', run_command: 'ask' },
extraBody: {
kv_cache_mode: 'exact_prefix',
},
});
async function runHandoff(sharedSpec: string) {
const critique = await reasoningCritic.run(`Critique architecture spec:\n${sharedSpec}`);
const decision = await decisionMaker.run(`Emit final JSON verdict from critique:\n${critique.summary}`);
console.log('Decision:', decision.summary);
}
Video Guides

Watch: Related Video Guides

How KV Cache Speeds Up LLMs for Faster AI Models on GPUs

What is Prompt Caching? Optimize LLM Latency with AI Transformers

What Is RebaseKV? Solving Role-Prefix KV Cache Invalidation

In multi-agent pipelines, each agent receives a prompt s_m = [p_m; c; q; o_<m] where p_m is the agent's role prompt, c is shared constraints, q is the task, and o_<m are prior outputs. Because p_m sits at index 0, changing roles invalidates exact prefix trees in PagedAttention and SGLang RadixAttention, forcing every handoff to pay full prefill latency (t_prefill + t_decode) on the critical path.

RebaseKV is a training-free serving algorithm that matches shared spans via greedy n-gram matching, applies RoPE rotational shifts (k_hat_n = R_Delta k_{n-Delta}) to realign positions, and drafts K = max(2, ceil(t_prefill / t_decode)) tokens on a high-priority CUDA stream while building exact KV(s_m) concurrently.

RebaseKV Latency & Accuracy Benchmarks vs Recompute, KVCOMM & RelayCaching

Across a 5-agent pipeline on GSM8K, MMLU, and HumanEval, RebaseKV matches or exceeds prior reuse methods while eliminating prefill wait stalls.

Benchmark / ModelMethodTTFT (ms)SpeedupAccuracy / avg@4 (%)End-to-End Overhead
Qwen2.5-7B (5-Agent GSM8K)Full Recompute135 ms (P95 181)1.00x90.6% (DM exact 91.8%)Baseline
Qwen2.5-7B (5-Agent GSM8K)RebaseKV (Event-Driven)46 ms (P95 60)2.96x88.0% (91.8% DM exact)+0.4%
Qwen2.5-7B (5-Agent GSM8K)RebaseKV (No Stream Priority)92 ms (P95 97)1.49x—+1.0%
Qwen3-8B (100 GSM8K)Full Recompute159 ms (P95 202)1.00x95.3%Baseline
Qwen3-8B (100 GSM8K)RebaseKV (Fixed Window)63 ms (P95 84)2.54x94.3% (DM exact)-0.2%
GSM8K (A100 Compare)KVCOMM104.5 ms0.76x83.1%—
Multi-Agent HarnessRelayCaching58–113 ms1.88x90.5%—

Routing format-fixing agents (such as an answer-first Decision Maker or JSON tool-caller) to the exact path preserves 91.8% avg@4 (0.0 pp gap vs recompute) while earlier proposer and critic agents keep 45–46 ms TTFT.

CUDA Stream Priority Is Non-Negotiable

Running the optimistic draft on the same default CUDA stream as exact prefill cuts RebaseKV's speedup from 2.95x down to 1.49x (92 ms vs 46 ms) due to kernel queueing.

Designing Role-Aware Agent Routing & Window Sizing

To replicate RebaseKV's zero-stall behavior in custom serving harnesses, compute the optimistic window K from measured uncontended prefill-to-decode ratios and isolate structured output agents on the exact path.

python
import math

def compute_optimistic_window(t_prefill_ms: float, t_decode_ms: float) -> int:
    # Fixed window covers concurrent contended prefill across measured handoffs
    return max(2, math.ceil(t_prefill_ms / max(t_decode_ms, 1e-3)))

def route_agent_handoff(agent_role: str, emits_structured_header: bool) -> str:
    # Format-fixing agents (JSON tool-calls, single-letter grades) use exact prefill
    if emits_structured_header or agent_role in {"decision_maker", "tool_router"}:
        return "exact_kv_path"
    return "rebase_optimistic_stream"

print("Window K (135ms prefill / 22ms decode):", compute_optimistic_window(135.0, 22.0))

Accelerating Multi-Agent Swarms in Smoke Monkey Canvas

Smoke Monkey Canvas links planner, researcher, coder, and verifier nodes over shared repository state where up to 80% of prompt tokens overlap across handoffs. Applying RebaseKV-style optimistic alignment to free-form reviewer nodes while keeping tool-calling verifier nodes on exact prefixes delivers sub-50 ms handoff responsiveness on a single GPU.

Google Search Questions & Answers

Frequently Asked Questions

Q:Why does exact prefix caching miss in multi-agent LLM workflows?

Most multi-agent frameworks prepend each agent's system/role prompt `p_m` before shared context. Because prefix caches like RadixAttention require an exact token match from position 0, swapping `p_m` forces full prefill recomputation.

Q:Does RebaseKV degrade output accuracy by decoding from stale KV states?

Stale-state divergence is bounded to the short optimistic window `K` (typically 3–6 tokens). Routing format-fixing agents (like JSON callers or final decision makers) to the exact path matches full-recompute accuracy (91.8% vs 91.8% on GSM8K).

Q:Does RebaseKV require fine-tuning or training a separate adapter?

No. RebaseKV is completely training-free and uses RoPE positional shifts (`R_Delta`) plus high-priority CUDA stream scheduling on off-the-shelf models like Qwen2.5-7B and Qwen3-8B.

Q:How does RebaseKV compare to KVCOMM and RelayCaching?

RebaseKV achieves 26.3 ms–46 ms TTFT compared to 104.5 ms for KVCOMM on GSM8K, and reaches 2.94x speedup in the two-stream harness versus 1.88x for RelayCaching.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness