BasinKV, Drop-In RAM/NVMe KV Offloading for Llama.cpp, SGLang, vLLM Zellige released BasinKV, an open-source sparse KV-cache offloading system for llama.cpp, SGLang and vLLM that keeps a fixed 2,048-token working set of KV blocks per full-attention head in GPU memory and moves full history to pinned host RAM or NVMe. On a 24 GB NVIDIA L4 running Qwen3.6-35B-A3B Q4_K_M at 256K context, where stock llama.cpp hits CUDA OOM from 64K, BasinKV held the entire GPU KV cache plus index in 84.75 MiB and decoded from 69.86 tok/s at depth 0 to 67.12 tok/s at 256K with 255/256 CUDA graphs reused; on an A100-80GB it reached 141.12 tok/s versus a 95.01 tok/s stock baseline at 256K. BasinKV is an extension of the OasisKV lookahead-prefetch architecture (Xiao et al., arXiv:2608.08097), requires no retraining or new weights, and runs FlashAttention, FlashInfer and full-model CUDA graphs unmodified. BasinKV: Long Context Without the KV Cache Tax - Published - Authors - Zellige - Reading time - 8 min - inference - kv-cache - long-context - systems - open-source Drop-in sparse KV offloading to RAM and NVMe for llama.cpp, SGLang, and vLLM. No retraining, no new weights, and huge concurrency headroom with unmodified attention kernels inside CUDA graphs. Contents6 Published by Zellige 2026-11-30 . BasinKV is our open-source implementation and extension of the OasisKV lookahead-prefetch architecture Xiao et al., arXiv:2608.08097 . For all 19 benchmark tables, McNemar significance tests, and roofline derivations, read the full technical paper https://zellige.ai/research/basinkv . Long-context serving hits the same memory wall on both local workstations and datacenter GPUs: KV cache grows linearly with sequence length, forcing stock engines to OOM or serialize batches while reading gigabytes of cold history on every decoded token. BasinKV keeps a fixed-size working set of KV blocks per full-attention head in GPU memory 2,048 tokens by default , offloads the full KV history to pinned host RAM or NVMe INT8 by default, uncompressed BF16 when RAM is abundant, or rotated 4-bit WHT-INT4 for maximum compression , scores evicted blocks on GPU Shrunk-Box Quest INT8 with alpha = 0.25 by default, or 136-byte SphereIndex for tightest VRAM , and prefetches newly needed blocks asynchronously over PCIe UVA behind layer compute. Because the resident GPU buffer has a static shape, FlashAttention, FlashInfer, and full-model CUDA graphs run unmodified . Flat decode throughput and bounded VRAM On bare-metal A100-80GB PCIe in llama.cpp , BasinKV keeps decode throughput nearly flat through 128K and 256K while stock slows down as the KV cache grows. WHT-INT4 halves host RAM and NVMe footprint relative to INT8 with less than 0.5% difference in decode speed: That fixed GPU footprint carries directly to tighter cards. On a 24 GB NVIDIA L4 23,034 MiB total / 22,614 MiB ECC-usable , where Qwen3.6-35B-A3B-UD-Q4 K M weights alone take 20.60 GiB , stock llama.cpp hits CUDA OOM starting at 64K. BasinKV keeps the entire 256K GPU KV cache plus index in 84.75 MiB 1.29 GiB in pinned host RAM , decodes flat from 69.86 tok/s d = 0 to 67.12 tok/s 256K with 255/256 CUDA graphs reused, and passes live llama-server -c 262144 passkey retrieval at 64K 59.5 tok/s , 21,327 MiB peak and 203K 60.4 tok/s , 21,885 MiB peak . Results across llama.cpp, SGLang, and vLLM V1 | Engine & workload | Hardware | Stock baseline | BasinKV | Quality check | |---|---|---|---|---| | llama.cpp Qwen3.6-35B-A3B Q4 K M @ 256K | NVIDIA L4 24 GB | CUDA OOM from 64K | 67.12 tok/s , 84.8 MiB GPU KV+idx 21.4 GiB peak | Live 64K & 203K passkeys: PASS | | llama.cpp Qwen3.6-35B-A3B Q4 K M @ 256K | A100-80GB PCIe | 95.01 tok/s 31.5 GiB | 141.12 tok/s 1.49x , 22.4 GiB -8.91 GiB | 18/18 iterative coding; 96.2% retrieval @ 240K | | llama.cpp Qwen3-8B Q4 K M @ 128K | A100-80GB PCIe | 54.28 tok/s | 124.29 tok/s 2.29x | 16/18 coding W = 4,096 | | SGLang Qwen3.8-27B BF16, B = 16 x 64K 1.02M tok | 1x A100-80GB | OOM w/ MTP ~97 no-MTP cap | 581.4 tok/s w/ native MTP, 18.13 GB free | 16/16 unique passkeys | | SGLang Qwen3.8-27B-FP8 , B = 16 x 64K 1.02M tok | 1x H100-80GB | 358.0 tok/s FP8 KV 264.8 s / 33.9 BF16 KV | 470.4 tok/s 1.31x , 130.3 s wall 2.03x vs FP8 KV | 16/16 passkeys; 5/5 64K RULER | | SGLang cold block-sparse prefill @ 240K | 1x H100-80GB | 43.88 s dense streaming TTFT | 33.38 s -10.50 s via fused Triton + UVA gather | 40/40 RULER fields 64K to 240K | | vLLM V1 zero-fork OKVP1 prefix cache Qwen3-8B | A100-80GB PCIe | 961.4 ms repeated request | 456.5 ms RAM / 702.4 ms NVMe 728.4 ms post-restart | 1.94x smaller on disk vs INT8 | In SGLang on H100 with FP8 weights, Qwen3.8-27B-FP8 at B = 16 x 64K hits 470.4 tok/s and cuts batch wall time in half against stock FP8 KV 130.3 s vs 264.8 s , while keeping resident KV near 2 GiB on Qwen3.6-35B-A3B-FP8 where stock's full 20 GiB KV still fits inside H100 HBM at B = 16 . In vLLM V1 0.19.1 , our zero-fork KVConnectorBase V1 plugin drops directly into stock vllm serve to persist rotated 4-bit prefix caches to RAM or NVMe OKVP1 across process restarts, cutting on-disk snapshots by 1.94x and speeding up NVMe hits by 1.36x over INT8: Try it Repository paths and CLI flags in v0.1 retain the oasiskv namespace. Clone BasinKV, then run the steps below from inside its folder: git clone https://github.com/zellige-ai/basinkv && cd basinkv 1. llama.cpp git clone https://github.com/ggml-org/llama.cpp git -C llama.cpp checkout ca123ba76311290ec6ab041dd2058fed8d9f03d2 python3 integrations/llamacpp/apply llamacpp wiring.py llama.cpp cmake -S llama.cpp -B llama.cpp/build -DGGML CUDA=ON -DCMAKE CUDA ARCHITECTURES="86;89" cmake --build llama.cpp/build --target llama-server llama-bench -j ./llama.cpp/build/bin/llama-server -m Qwen3.6-35B-A3B-UD-Q4 K M.gguf \ -ngl 99 -c 262144 -b 1024 -ub 1024 -fa on -np 1 \ --oasiskv --oasiskv-resident 2048 --oasiskv-cap 8 \ --oasiskv-index quest --oasiskv-alpha 0.25 --oasiskv-kv-quant int8 2. SGLang pip install -e . git clone https://github.com/sgl-project/sglang.git /tmp/sglang git -C /tmp/sglang checkout a3f0bff5babfe18d3862e134449cd8fd11fcb84a pip install -e /tmp/sglang/python python3 integrations/sglang/apply wiring.py /tmp/sglang integrations/sglang python3 -m sglang.launch server \ --model-path Qwen/Qwen3.8-27B-FP8 --context-length 262144 \ --enable-oasiskv --attention-backend oasiskv --disable-radix-cache --page-size 16 \ --oasiskv-config '{"resident tokens":2048,"sink blocks":4,"local blocks":8,"transfer cap c":16,"pcie quant":"int8","index quant":"int8","quest alpha":0.25,"successor cofetch":true,"lazy host slabs":true,"streaming prefill":true,"draft ring window":4096,"draft ring sink":64}' \ --speculative-algorithm NEXTN --speculative-num-steps 3 \ --speculative-eagle-topk 1 --speculative-num-draft-tokens 4 \ --enable-linear-replayssm-spec 3. vLLM V1 zero-fork prefix cache vllm serve Qwen/Qwen3-8B --kv-transfer-config '{ "kv connector": "OasisKVConnector", "kv connector module path": "integrations.vllm.oasiskv connector", "kv role": "kv both", "kv connector extra config": { "cache mode": "mixed", "pcie quant": "int8", "prefix cache dir": "/tmp/basinkv cache", "prefix cache ram gb": 4.0, "prefix cache nvme gb": 32.0 } }' The zero-fork vLLM V1 plugin persists host KV formats only none , int8 , or wht int4 , with no Quest or SphereIndex block index. For tight host RAM, NVMe budgets, or maximum multi-user concurrency, switch to the high-compression tier: --oasiskv-index sphere --oasiskv-beta 0.10 --oasiskv-kv-quant wht int4 in llama.cpp , "pcie quant": "wht int4", "index quant": "sphere int4", "sphere beta": 0.10 in SGLang, or "pcie quant": "wht int4" in vLLM. In SGLang and vLLM with abundant host RAM, "pcie quant": "none" keeps uncompressed BF16. Five technical pieces behind the numbers 1. Partial-RoPE radius weight alpha = 0.25 . Qwen3.x hybrids put 64 rotary and 192 non-rotary dimensions in each full-attention head. On native BF16 Qwen/Qwen3.8-27B , the non-rotary box radius averages 2.70x the midpoint magnitude 1.898 vs 0.704 , drowning dot-product signal under unweighted Quest alpha = 1.0 , 29.9% Top-8 recall, 0/5 RULER at 128K . Dropping the radius weight to alpha = 0.25 raises per-step Top-8 recall from 82.5% OasisKV Eq. 3 alpha = 0.50 sum to 95.5% 93.2% under GQA max and restores 5/5 RULER with 48/48 greedy prefix parity. 2. SphereIndex 136 bytes/block, 7.53x smaller than BF16 min/max . Instead of storing per-block BF16 min/max bounds 1,024 B/blk at D = 256 , SphereIndex rotates the block centroid with a fixed randomized Walsh-Hadamard transform, quantizes it to symmetric INT4, and appends two FP16 subspace radii r rope , r nope . At D = 256 , Top-8 salient-event recall improves from 61.8% to 70.2% while cutting index memory 7.53x . 3. WHT-INT4 rotated host KV 1.97x smaller than INT8 . Each offloaded K and V vector is Hadamard-rotated and quantized to symmetric 4-bit D/2 + 4 bytes/vector , cutting synthetic outlier L2 error 3.9x vs naive INT4 and doubling host concurrency and NVMe cache density at equal decode speed. 4. Engine plumbing that respects CUDA graphs. Static fixed-shape GPU slabs, lazy host slab allocation guarded by /proc/meminfo , a ring-mapped FP8 draft KV pool for hybrid NEXTN MTP, direct-to-host streaming prefill, an optional fused Triton block-sparse prefill kernel -10.50 s at 240K , and atomic CRC32-checked OKVP1 / OKVS1 prefix snapshots including recurrent states for hybrids . 5. Best-effort 1-hop successor b + 1 co-fetch for induction heads. Running BasinKV live in coding agents exposed a block-sparse failure mode: when a multi-token cue