Zero-Fork vLLM V1 Bit-Exact Lossless 3-Tier KV Cache Engine (GPU HBM ↔ Pinned Host DRAM ↔ Linux io_uring NVMe) with 48-Layer Contiguous Super-Block cuMemcpyBatchAsync & Tri-Mode Entropy @triton.jit Codec
Modern Coding, SQL, and Computer-Use Agents exhibit a burst-pause-resume execution pattern that breaks single-turn LLM serving assumptions:
-
HBM Eviction Thrashing During Tool Pauses: An agent accumulates
8K–64Kcontext tokens across multi-step reasoning, emits atool_call(bash test suite, SQL query, browser navigation), and pauses for2–15s. Under concurrent traffic, GPU HBM evicts the paused session's KV blocks; when the tool returns, the engine must recompute the entire historical prefill from scratch, causing multi-second TTFT spikes and wasting GPU FLOPs. -
PCIe Root-Complex Contention & Host DRAM Bloat: Naive raw
BF16CPU offloading transfers100%of raw KV bytes across PCIe and burns tens of gigabytes of pinned host RAM. Worse, per-layer fragmented slabs generate$O(L \cdot B)$ DMA/IOPS storms (1.38Mops for 48-layer14Bworkloads), while synchronouswait_for_save()hooks or background NVMe writeback head-of-line blocking stallvLLM V1's overlapped execution pipeline. -
Zero-Tolerance for Lossy KV Drift & Silent Disk Corruption: Lossy KV quantization (
INT4/FP4) accumulates logit drift over multi-turn tool trajectories, breaking strict JSON schemas, SQL identifiers, or code diffs; meanwhile, multi-terabyte NVMe caches require hardware checksums and automatic self-healing against silent bit-rot.
PrismKV (v0.4) solves all three problems as a zero-fork vLLM V1 plugin (KVConnectorBase_V1 + SupportsHMA):
- Rate-Optimal Tri-Mode
@triton.jitLossless BF16 Bit-Plane Codec (3-bit + 4-bit + Raw): ExploitsBF16exponent concentration with auto-calibrated per-subchunk exponent windows (e_base=0, immune to120×attention-sink massive activations), selecting per2,048-element subchunk the tightest representation among3-bitbit-planes (7bins +1Bprefix-sum escape),4-bitnibbles (14bins + dedicated zero +1Bescape), and rawBF16fallback. Reaches1.4161×lossless compression (-29.38%bytes,93.30%of the BF16 Shannon Exponent-Entropy Limit1.5178×,max_uint16_xor == 0),13,876×faster than CPUzlib-6with325.64 GB/ssingle-pass barrier-free scatter-decode onNVIDIA A100. - Multi-Layer Contiguous
Super-BlockPacking & Zero-CopycuMemcpyBatchAsync: Coalesces allL(48) Transformer layers of each KV block on GPU into 1 contiguous~2.25 MiBSuper-Block and transfers directly between C++ pinned slabs and GPU buffers via CUDA DrivercuMemcpyBatchAsync(0hostmemcpy), slashing DMA descriptors, hash lookups, andio_uringIOPS by48×while running 4-thread parallel SSE4.2CRC-32ConD2Hcommits. - Read-Preemptive C++17 Linux
io_uringNVMe Tier + Self-Healing Quarantine: Direct<linux/io_uring.h>async NVMe engine (1,399.6 MiB/sspill write,2,726.7 MiB/spromote read +CRC-32ConA100) featuring front-of-queue read preemption (push_front), SQE background-write throttling, andflush_reads()decoupling so background writeback never blocks active KV restoration; optionalO_DIRECTsupported, with automatic corrupted-slot quarantine andvLLM V1block recomputation (get_block_ids_with_load_errors()). - True
vLLM V1Overlapped Async Load (load_kv_async=True), Multi-Bucket Triton Warmup & Prewarm Proxy: Overlaps external KV restoration behind GPU compute (WAITING_FOR_REMOTE_KVS) while preservingFULL_AND_PIECEWISECUDA Graphs, exports nativevllm:prismkv_*Prometheus metrics, and pairs with an OpenAI SSE proxy fortool_callsdemotion and proactiveprewarm.
flowchart TB
subgraph ClientLayer["Multi-Turn Agent Runtime & OpenAI SSE Proxy (prismkv.proxy)"]
Agent["Coding / SQL / Browser Agent"]
Proxy["PrismKV FastAPI SSE Proxy<br/>• Auto-detects finish_reason='tool_calls' → tool_wait<br/>• Prewarms spilled sessions (POST /v1/kv/prewarm)"]
Agent <-->|"OpenAI /v1/chat/completions"| Proxy
end
subgraph VLLMEngine["vLLM V1 Engine (v0.34.0 Zero-Fork Plugin via --kv-transfer-config)"]
Sched["PrismKVSchedulerManager (SCHEDULER + SupportsHMA)<br/>• Prefix-chained 128-bit Blake2b block keys<br/>• Async KV Load (load_kv_async=True, WAITING_FOR_REMOTE_KVS)<br/>• O(N) Append-Only Dirty-Delta save planner<br/>• Native vllm:prismkv_* Prometheus exporter"]
Compute["GPU Forward & FULL_AND_PIECEWISE CUDA Graphs<br/>• Overlapped with async KV transfers (A100 14B ITL P50 = 26.74 ms)"]
LoadPipe["Zero-Copy Super-Block Load Pipeline (load_stream)<br/>• 1 cuMemcpyBatchAsync per 48-layer Super-Block (48x fewer DMA ops)<br/>• Single-pass barrier-free @triton.jit scatter-decode (325.6 GB/s)"]
SavePipe["4-Wave Overlapped Super-Block Save Pipeline (save_stream + d2h_stream)<br/>• Tri-Mode (3-bit/4-bit/Raw) @triton.jit gather-encode + GPU coalescing<br/>• Background cuMemcpyBatchAsync + 4-thread SSE4.2 CRC-32C"]
end
subgraph NativeStorage["C++17 Native Storage Extension (prismkv._prismkv_C)"]
Slab["Tier-2: PinnedSlabPool (CUDA Pinned Host DRAM)<br/>• Page-aligned Super-Block slabs + pin_count DMA guard<br/>• Zero-copy prepare_multilayer_h2d / prepare_multilayer_d2h<br/>• Session-aware LRU demotion"]
Uring["Tier-3: UringNvmeTier (Read-Preemptive Linux io_uring)<br/>• Priority read queue + SQE write throttling + flush_reads()<br/>• SSE4.2 CRC-32C check + silent bit-rot quarantine"]
Slab <-->|"Watermark Spill & Async Prewarm"| Uring
end
Proxy -->|"Forward + session_id"| Sched
Proxy -.->|"Unix Domain Sideband IPC"| Slab
Sched -->|"Async Load / Save Plan"| LoadPipe
Sched -->|"Dirty-Delta Save Plan"| SavePipe
LoadPipe -->|"Zero-Copy Scatter"| Compute
Compute -->|"Post-Forward Stream Event"| SavePipe
Slab -->|"cuMemcpyBatchAsync H2D (-27.7%)"| LoadPipe
SavePipe -->|"cuMemcpyBatchAsync D2H (-27.7%)"| Slab
Full benchmark ledgers, design deep-dives, and reproduction scripts are documented in docs/BENCHMARK_REPORT.md, docs/ARCHITECTURE.md, benchmarks/run_live_benchmark.py, and benchmarks/bench_codec_and_uring.py.
3.1 Datacenter Tier: NVIDIA A100-SXM4-40GB + Qwen2.5-Coder-14B-Instruct (48 Layers, ~84 GiB KV Traffic)
Workload: 12 interleaved multi-turn Coding/SQL Agent sessions × 4 turns = 48 turns (bfloat16, max_model_len=16384, --num-gpu-blocks-override 1920 = 30,720 HBM tokens, 1.8s external tool pause, max_num_seqs=6, max_inflight_llm=3, temperature=0.0 greedy SSE streaming).
| Arm Configuration | Resume TTFT Mean | Resume TTFT P50 | Resume TTFT P95 | Decode ITL P50 | Throughput (turns/min) |
Wall Time | Offload Parity |
|---|---|---|---|---|---|---|---|
1. Native vLLM V1 (HBM Evict-Recompute) |
3291.3 ms |
3120.1 ms |
5297.8 ms |
26.78 ms |
36.43 |
79.06 s |
Baseline |
2. vLLM Official SimpleCPUOffload (34 GiB Raw BF16) |
1401.8 ms (-57.4%) |
1525.5 ms (-51.1%) |
1983.9 ms (-62.6%) |
26.66 ms |
64.12 (+76.0%) |
44.92 s |
100.0% |
3. PrismKV v0.4 (48L Super-Block + Tri-Mode Codec) |
1400.9 ms (-57.4%) |
1357.1 ms (-56.5%) |
1997.8 ms (-62.3%) |
26.74 ms |
65.46 (+79.7%) |
44.00 s |
100.0% (48/48) |
4. PrismKV v0.4 3-Tier (~15.9 GiB DRAM + io_uring + Prewarm) |
1801.4 ms (-45.3%) |
1613.8 ms (-48.3%) |
4315.2 ms (-18.5%) |
26.73 ms |
57.38 (+57.5%) |
50.19 s |
100.0% (48/48) |
- Headline Datacenter Result: At
14B(48-layer) scale onNVIDIA A100-SXM4-40GB,PrismKV v0.4beatsvLLM's official uncompressedSimpleCPUOffloadConnectoron both median resume TTFT (1,357.1 msvs1,525.5 ms,-11.0%faster) and total wall-clock throughput (44.00 svs44.92 s,+79.7%over NativevLLM V1), while saving23.33 GiB(23,885.3 MiB,1.3836×live lossless ratio) of PCIe bus traffic with100.0%(48/48turns) greedy token-for-token parity against uncompressedSimpleCPUOffloadConnector! Under< 50%host DRAM budget (~15.9 GiB), 3-tier read-preemptiveio_uringNVMe tiering seamlessly spills7,844and promotes15,417Super-Blocks (0CRC errors) with+57.5%higher throughput than NativevLLM V1.
| Subsystem Metric | NVIDIA A100-SXM4-40GB |
NVIDIA RTX 3060 12 GiB |
|---|---|---|
Lossless Compression Ratio (max_uint16_xor == 0) |
1.4161× (93.30% of BF16 Shannon Limit 1.5178×, 13,876× faster than zlib-6) |
1.3244× (v0.2) / 1.4161× (v0.4) |
Paged Gather + Bit-Plane Encode (@triton.jit) |
133.01 GB/s (0.126 ms / 16 MiB) |
69.69 GB/s |
Paged Single-Pass Unpack + Scatter (@triton.jit) |
325.64 GB/s (0.051 ms / 16 MiB) |
140.57–166.40 GB/s |
Single-Transfer Pinned PCIe H2D (16 MiB KV Batch) |
Raw 1.362 ms → PrismKV 1.022 ms (1.333× faster) |
Raw 1.999 ms → PrismKV 1.685 ms (1.186× faster) |
C++17 Linux io_uring NVMe Async Spill / Promote+CRC32C |
1,399.6 MiB/s write / 2,726.7 MiB/s read (0 CRC err) |
1,089.0 MiB/s write / 2,039.2 MiB/s read |
uv pip install --no-build-isolation -e .
prismkv doctor
# Verifies CUDA HostRegister pinning, cuMemcpyBatchAsync driver support, io_uring ring & SSE4.2 CRC-32CKV_CFG=$(prismkv kv-config \
--codec bitplane \
--dram-slabs 240000 \
--nvme-path /var/tmp/prismkv_tier3.bin \
--nvme-slots 520000 \
--sideband-sock /tmp/prismkv_sideband.sock)
vllm serve Qwen/Qwen2.5-Coder-14B-Instruct \
--enable-prefix-caching \
--kv-transfer-config "$KV_CFG"- Data Type Scope: The
@triton.jittri-mode lossless bit-plane codec targetsbfloat16KV caches (8-bitexponent concentration). Models runningFP8 (E4M3)KV caches have lower exponent redundancy and can set"codec": "raw"to use PrismKV's C++17PinnedSlabPool+ read-preemptiveio_uringNVMe tiering directly. - Single-Engine
TP=1Verification Scope: Current end-to-end benchmarks target single-GPU (TP=1)vLLM V1serving (A100 40GB14BandRTX 3060 12GB1.5B); multi-GPU tensor parallelism (TP>1) embedstp_szinto prefix keys and requires per-rank slab pools. - FlashAttention Reduction Tree Determinism vs Codec Bijection: Uncached varlen full-prefill (
native_recompute) and paged prefix-cached suffix-prefill (SimpleCPUOffloadConnector/PrismKV) use differentFlashAttention-2tile reduction trees onsm_80, yielding77.1%greedy match against uncached recompute for both uncompressed and compressed offload, whilePrismKVachieves100.0%(48/48) exact token parity against uncompressedSimpleCPUOffloadConnectorandmax_uint16_xor == 0bitwise KV reconstruction.
Apache License 2.0 — see LICENSE.
