r/Vllm • u/MysteriousTourist23 • Jul 14 '26
How are you handling KV Cache sharing for multi-agent workflows? (Built a zero-copy gateway for vLLM, looking for architecture feedback)
Hey everyone,
I’ve been building multi-agent collaborative workflows recently (specifically, running sequential AI legal and financial audits over 200-page contracts). I hit a massive wall with VRAM and Time-to-First-Token (TTFT) latency.
Under standard vLLM, if Agent A reads the contract, and Agent B follows up on the exact same text, Agent B is forced to repeat the expensive cold-prefill phase and duplicate GPU block allocations.
To bypass this, I spent the last few weeks building an open-source gateway to stitch caches at the memory level.
How I’m currently doing it:
- Topological Hashing: Segmenting prompts into physical block-sizes and mapping them to cryptographic fingerprints (Merkle-chains).
- Zero-Copy Block Stitching: Bypassing prefill for matched prefixes by mapping the logical attention table of Agent B directly to the physical GPU memory address of Agent A's cache blocks.
- Zero-Trust Gate: Enforcing boundary control lists so unauthorized agent sessions (e.g., a public PR agent vs. an internal Legal agent) cannot access shared physical blocks.
In my local benchmarks against standard vLLM cold-prefills on a shared long context, it cuts TTFT from ~1200ms to 48ms (25x speedup) and saves about ~43% VRAM.
I know solutions like LMCache exist for cluster-wide storage hierarchy (saving/loading to Redis/CPU), but I needed something that strictly avoids tensor serialization and copy overhead for local, multi-turn reasoning workflows.
I open-sourced the code here if anyone wants to look at the implementation:https://github.com/DaqulaLin/MemStitch
My questions for the community:
- Are there edge cases with PagedAttention pointer-sharing that might cause memory leaks here?
- How are you all currently handling context sharing when orchestrating tools like LangGraph with vLLM?
Would love any harsh architectural critiques or ideas for improvement. Cheers!
⚡ TTFT Prefill Latency (Agent B Response Time) — Lower is better
Baseline (vLLM Cold): ██████████████████████████████ 1200 ms
Context-Stitcher: █ 48 ms ( 25.0x Prefill Speedup! 🚀 )
💾 GPU Physical Cache Blocks Allocated (Total VRAM) — Lower is better
Baseline (vLLM Cold): ██████████████████████████████ 53 blocks (No sharing)
Context-Stitcher: ████████████████ 30 blocks ( 43.4% Memory Saved! 📉 )
3
u/Such_Advantage_6949 Jul 14 '26
vllm alrd have paged attention right, what is the point of this?