zellige-ai/basinkv
Sparse KV offload for long-context LLM serving with a fixed GPU working set
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
BasinKV extends existing inference engines rather than replacing the serving stack. Its sparse decode path keeps a fixed GPU working set per full-attention head: attention-sink blocks, retrieved blocks, and a ring of recent tokens share static pages managed by src/oasiskv/pool.py. Full KV history is offloaded to pinned host RAM or NVMe. The selector scores evicted blocks on the GPU and prefetches selected blocks over PCIe while earlier layers compute. Static buffer shapes let the engine retain its stock FlashAttention or FlashInfer decode kernels and CUDA graphs on supported paths.
The implementation separates block selection (selector.py), the CUDA SphereIndex (sphere_index_cuda.py), host KV encoding (wht_int4_kv.py), and persistent prefix reuse (prefix_cache.py). Integration depth differs by engine: llama.cpp and SGLang use pinned wiring patches, whereas vLLM V1 loads an out-of-tree KVConnectorBase_V1 plugin for Mode 1 prefix caching. Mode 2 sparse decode is a separate path requiring three upstream hooks. The distribution is named basinkv, while v0.1 retains the oasiskv namespace in code and launch flags.
Key Capabilities & Differentiators
The model matrix covers dense GQA/MHA and selected recurrent or sliding-window attention hybrids. Verified paths include Qwen models and Gemma 4 E4B on llama.cpp and SGLang, and Granite 4.0 H Micro state caching on vLLM 0.34.0. vLLM Mode 1 can persist hybrid state alongside attention KV, preserving the recurrent state losslessly at exact token boundaries. Compatibility is engine-specific: Inkling 2 Mini is live-verified on llama.cpp, wired and kernel-tested on SGLang with caching off, and planned for vLLM. MLA models are rejected at initialization across all three engines.
The sparse path supports Quest selection, SphereIndex, and one-hop successor co-fetch for cues spanning block boundaries. In a BF16 Qwen3.8-27B partial-RoPE ablation, setting alpha to 0.25 raised per-step top-8 recall from 29.9% with unweighted Quest to 95.5% and recovered 5/5 128K RULER cases from 0/5. On an A100-80GB PCIe, llama.cpp decoded Qwen3.6-35B-A3B Q4_K_M at 256K at 141.12 tok/s versus 95.01 tok/s stock, with 22.4 GiB versus 31.5 GiB measured VRAM. These are results for specific model, engine, and hardware combinations, not general throughput or quality guarantees.
Trade-offs & Limitations
Stock dense attention avoids block selection and host transfers. Prefer it when KV already fits at the target concurrency and predictable latency or full-history attention matters more than VRAM savings. Native FP8 KV is an intermediate baseline where available: it reduces GPU residency without introducing sparse retrieval. BasinKV trades resident KV for GPU index memory, host capacity, and PCIe traffic. Prefetch can overlap with compute, but weights, index memory, and prefill allocations remain outside the fixed KV-page budget. In llama.cpp, hot slabs and indexes also scale with -np.
Start with Quest and INT8 host KV when retrieval quality matters most. Move to SphereIndex with WHT-INT4 when host RAM, NVMe capacity, or GPU index memory is the binding constraint, and retest quality on your workload. Dense models such as Qwen3-8B and Llama 3 can warrant 4,096 resident tokens instead of 2,048. Evaluate retrieval and task accuracy together with time to first token and tail latency under concurrency: passkeys and decode throughput alone do not establish production parity. The patched paths also carry an upgrade burden that the vLLM Mode 1 connector avoids, at the cost of not offering sparse decode.
Hardware & Deployment Guide
This is a self-hosted stack targeting Linux with Python 3.10 or later and CUDA-capable NVIDIA GPUs for the sparse serving paths. For llama.cpp, pin commit ca123ba76311290ec6ab041dd2058fed8d9f03d2, run integrations/llamacpp/apply_llamacpp_wiring.py, and build the CUDA targets with CMake. SGLang uses editable installs and integrations/sglang/apply_wiring.py against pinned commit a3f0bff5babfe18d3862e134449cd8fd11fcb84a; the sparse launch selects --attention-backend oasiskv and disables RadixCache. The supplied SWA hybrid preset also leaves prefix caching off and does not use MTP.
For unmodified vLLM V1, install basinkv or use an editable checkout, disable native prefix caching in the supplied setup, and pass OasisKVConnector through --kv-transfer-config. Start with explicit RAM and NVMe budgets and choose the KV encoding deliberately: the sample mixed-tier preset uses INT8, while the connector defaults to WHT-INT4. The package manifest identifies version 0.1.0 as Beta, and no GitHub release is listed. Treat the pinned checkouts and verified vLLM configurations as the starting point for upgrade testing rather than assuming compatibility with newer engine versions.
Self-hosted NVIDIA GPU long-context serving where dense KV exhausts VRAM, or vLLM V1 deployments that explicitly need RAM/NVMe prefix reuse without patching the engine.
The model uses MLA, your workload requires exact full-history attention or stock KV already meets the target, or you need sparse decode but cannot maintain engine patches.
Quick Start & Installation
pip install basinkv # or `pip install -e .` from a checkout; registers the vLLM plugin entry point # Qwen3-8B, RAM + NVMe tiered prefix cache (verified on vLLM 0.19.1) vllm serve Qwen/Qwen3-8B --no-enable-prefix-caching --kv-transfer-config '{ "kv_connector": "OasisKVConnector", "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 } }' # Gemma 4 / Gemma 3 multi-group SWA + full attention (SupportsHMA, verified on vLLM 0.34.0) vllm serve google/gemma-4-26B-A4B-it --no-enable-prefix-caching --kv-transfer-config '{ "kv_connector": "OasisKVConnector", "kv_role": "kv_both", "kv_connector_extra_config": { "cache_mode": "nvme", "pcie_quant": "wht_int4", "prefix_cache_dir": "/tmp/basinkv_cache_gemma4", "prefix_cache_
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| basinkv ★ | 177 | +45 | Python | — | Sparse KV offload for long-context LLM serving with a fixed GPU working set |
| DeepInfer | 27.7k | +1.3k | Python | Apache-2.0 | An accelerator-tuned offline inference engine for DeepSeek-V4.1-Flash |
| vllm | 98.2k | +435 | Python | Apache-2.0 | Paged-KV inference engine for high-throughput, self-hosted LLM serving |
| sglang | 39.4k | +237 | Python | Apache-2.0 | Self-hosted inference runtime for serving LLMs and multimodal models across acce |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/zellige-ai/basinkv.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about basinkv
Does installing the vLLM connector enable sparse decode?
What should I size beyond the resident GPU KV window?
What should a commercial self-hosting review cover?
When is stock dense or reduced-precision KV the better choice?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy