Find your next open-source project

Search by name, purpose, or keyword, or paste a GitHub URL. Start with / to search agent skills (e.g. /pdf)

zellige-ai/basinkv

Machine LearningModel serving

Offload sparse KV cache to host RAM and NVMe for long-context inference in llama.cpp, SGLang, and vLLM.

129
9
Python
NOASSERTION
2 days old
+28 stars in 5h

What it does

BasinKV addresses the KV-cache memory wall in long-context LLM serving. Instead of keeping every token's KV cache resident in GPU memory, it caps each full-attention head at a fixed GPU working set, stores the full history in pinned host RAM or on NVMe, scores evicted blocks on the GPU, and prefetches needed blocks over PCIe while earlier layers compute. Because the resident GPU buffers have static shapes, stock FlashAttention / FlashInfer kernels and CUDA graphs can run unmodified.

The project is the open-source implementation and extension of the OasisKV lookahead-prefetch architecture by Can Xiao, Sukmin Cho, and colleagues (paper); for v0.1 compatibility, the Python package and flags keep the oasiskv namespace. It integrates with three engines: llama.cpp (via a pinned upstream patch), SGLang (via an exact-anchor installer), and vLLM V1 (as an out-of-tree KV connector plugin). SGLang and vLLM also support persistent RAM/NVMe prefix caching, including hybrid recurrent and sliding-window attention states.

Quick start

For SGLang, install the package, clone the pinned SGLang revision, apply the wiring script, then launch with the BasinKV attention backend:

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

Then serve a supported model with the matching flags, for example Qwen3.8-27B-FP8 at 256K:

python3 -m sglang.launch_server \
  --model-path Qwen/Qwen3.8-27B-FP8 --context-length 262144 --max-running-requests 16 \
  --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

The llama.cpp path requires checking out a specific upstream commit and patching it before building with CUDA, while the vLLM path installs the package and registers the OasisKVConnector plugin via --kv-transfer-config; full commands are in the quickstart, with per-engine details in the integration docs.

Supported models and tuning

The support matrix covers dense GQA/MHA models (Qwen3-8B, Llama 3.x, Mistral, Phi-4), recurrent+full-attention hybrids (Qwen3.5/3.6/3.8 GDN, Granite-4.0-H, Jamba, Falcon-H1), SWA+full-attention hybrids (Gemma 2/3/4, gpt-oss), and shared-KV tail layers (Gemma 4 E4B/E2B). Multi-head latent attention models such as DeepSeek-V3/R1 are rejected at init; see the supported models table for the per-engine evidence.

The default quality preset is int8 host KV with Quest int8 (alpha = 0.25). When host RAM, NVMe, or GPU index VRAM is the bottleneck, switch to wht_int4 host KV with SphereIndex. For pure full-attention models with 32+ layers, the working set should be raised to 4096 tokens. Detailed tradeoffs are in the tuning matrix.

Constraints

The integrations are pinned to specific upstream revisions: the llama.cpp patch targets commit ca123ba76, SGLang targets a3f0bff5, and vLLM was verified on 0.19.1 and 0.34.0. CUDA build flags and the -np slot count matter for llama.cpp, and for SGLang prefix cache must stay off for SWA hybrids. MLA models are not supported. Benchmarks in the README come from the authors' implementations on specific hardware (L4, A100, H100) and are not a guarantee for other setups. The project is licensed Apache-2.0 (LICENSE) despite the repository metadata reporting NOASSERTION.

HotRepo's take

BasinKV entered HotRepo's new-project list on 2026-12-03 with 10 stars gained in roughly 1.5 hours, reaching 111 stars and 8 forks. That is a short window, so the record only shows early interest rather than sustained traction. The more substantive signal is the engineering depth: pinning upstream commits for three engines, reporting live-verified per-checkpoint results, and publishing both a paper and a benchmark log indicates a serving-library project aimed at people running long-context inference, not a general-audience tool.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.

You might also like

  1. Prefrontal-AI/latent-sparse-attentionResearch code for Latent Sparse Attention, an SGLang plugin that speeds up long-context prefill, decode and training.Python133
  2. ggml-org/llama.cppRuns LLM and VLM inference locally across CPUs, GPUs and phones without a Python stack.C++132,253
  3. Betelgeuse-AI/BetelgeuseA C++/CUDA llama.cpp fork that streams MoE experts from NVMe to run large models on a 12 GB RTX 3060.C++111
  4. dayuwang401/SCR-VLResearch code that reuses KV cache after mid-context edits in video LLMs, cutting cache rebuild time for Qwen-VL models.Python106
  5. vllm-project/vllm-ascendHardware plugin that runs vLLM inference on Huawei Ascend NPUs for serving LLMs and multimodal models.Python3,105