Metadata-Version: 2.4
Name: basinkv
Version: 0.1.1
Summary: Bounded-VRAM sparse KV serving (SphereIndex, WHT-INT4, tiered RAM/NVMe prefix caches, and 1-hop successor co-fetch) for llama.cpp, SGLang, and vLLM V1
Author: Zellige AI
License-Expression: Apache-2.0
Project-URL: Homepage, https://zellige.ai
Project-URL: Repository, https://github.com/zellige-ai/basinkv
Project-URL: Documentation, https://github.com/zellige-ai/basinkv/tree/main/docs
Project-URL: Issues, https://github.com/zellige-ai/basinkv/issues
Keywords: llm,inference,kv-cache,vllm,sglang,sparse-attention,quantization,long-context
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Environment :: GPU :: NVIDIA CUDA
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: torch>=2.4
Provides-Extra: vllm
Requires-Dist: vllm>=0.19.1; extra == "vllm"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: matplotlib>=3.8; extra == "dev"
Requires-Dist: setuptools>=77; extra == "dev"
Dynamic: license-file

# BasinKV

**Sparse KV offloading to host RAM and NVMe for `llama.cpp`, SGLang, and vLLM V1. No retraining, no new weights, and stock FlashAttention / FlashInfer decode kernels inside CUDA graphs.**

Long-context serving hits a memory wall because the KV cache grows linearly with context. BasinKV caps each full-attention head at a fixed GPU working set (`W = 2,048` tokens by default), keeps the full KV history in pinned host RAM or on NVMe, scores evicted blocks on the GPU, and prefetches the blocks it needs over PCIe while earlier layers compute. The resident GPU buffers have static shapes, so the engine's own attention kernels and full-model CUDA graphs run without modification.

**Naming.** BasinKV is [Zellige](https://zellige.ai)'s open-source implementation and extension of the **OasisKV** lookahead-prefetch architecture by Can Xiao, Sukmin Cho, and colleagues ([arXiv:2608.08097](https://arxiv.org/abs/2608.08097), 2026). All measurements here come from our implementations. For v0.1 compatibility, the Python package, CLI flags, config keys, and class names keep the `oasiskv` namespace (`--oasiskv`, `--enable-oasiskv`, `OasisKVConnector`).

| I want to... | Go to |
|---|---|
| Check whether my model is supported | [Supported models](#supported-models) and [`docs/SUPPORTED_MODELS.md`](docs/SUPPORTED_MODELS.md) |
| Copy a working launch command | [Quickstart](#quickstart) |
| Tune presets or understand a limitation | [`docs/TINKERING_AND_TUNING.md`](docs/TINKERING_AND_TUNING.md) |
| See measured speedups and VRAM savings | [Benchmarks](#benchmarks) |
| Install an engine integration in detail | [`integrations/README.md`](integrations/README.md) |
| Browse every doc, paper, and figure | [`docs/README.md`](docs/README.md) |
| Work on the code (humans or coding agents) | [`AGENTS.md`](AGENTS.md) |

---

## Which engine should I use?

| Goal | Engine | How it attaches | Starting preset | Guide |
|---|---|---|---|---|
| **Local long context (64K to 256K+)** on 24 GB to 80 GB GPUs (`-np 1..256`) | `llama.cpp` | Pinned wiring patch (`ca123ba76`) | `--oasiskv-index quest --oasiskv-alpha 0.25 --oasiskv-kv-quant int8 --oasiskv-cap 8` | [`integrations/llamacpp/`](integrations/llamacpp/README.md) |
| **Multi-user serving** at high concurrency, optional `NEXTN` MTP and cold sparse prefill | SGLang | Exact-anchor installer `apply_wiring.py` (`a3f0bff5`) | `"pcie_quant": "int8"`, `"index_quant": "int8"`, `"quest_alpha": 0.25`, `"transfer_cap_c": 16` | [`integrations/sglang/`](integrations/sglang/README.md) |
| **RAM/NVMe prefix caching** on unmodified `vllm serve` | vLLM V1 | Out-of-tree `KVConnectorBase_V1` plugin (Mode 1) | `"cache_mode": "mixed"`, `"pcie_quant": "int8"` | [`integrations/vllm/`](integrations/vllm/README.md) |

Precision in one paragraph: **`int8` host KV with Quest `int8` (`alpha = 0.25`)** is the quality default for sparse decode. It matched uncompressed BF16 runner-up logit margins in our H100 ablation while halving host RAM and PCIe traffic. Switch to **`wht_int4` host KV with `SphereIndex` (`sphere_int4`, `beta = 0.10`)** when host RAM, NVMe, or GPU index VRAM is the bottleneck (`1.97x` smaller host KV, `3.82x` smaller GPU index). SGLang and vLLM also accept lossless BF16 (`"pcie_quant": "none"`). On pure full-attention models with 32+ layers (`Qwen3-8B`, Llama 3), raise the working set to `4096` tokens. Full tradeoffs: [`docs/TINKERING_AND_TUNING.md`](docs/TINKERING_AND_TUNING.md#3-knobs-tradeoffs--tuning-matrix).

---

## Quickstart

### `llama.cpp` (single user or parallel slots)

```bash
git clone https://github.com/ggml-org/llama.cpp.git /tmp/llama.cpp
git -C /tmp/llama.cpp checkout ca123ba76311290ec6ab041dd2058fed8d9f03d2
python3 integrations/llamacpp/apply_llamacpp_wiring.py /tmp/llama.cpp

# CUDA architectures: 80 = A100, 86 = RTX 30xx, 89 = L4 / RTX 4090, 90 = H100, 120 = RTX 5090
cmake -S /tmp/llama.cpp -B /tmp/llama.cpp/build-cuda \
  -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="86;89" -DCMAKE_BUILD_TYPE=Release
cmake --build /tmp/llama.cpp/build-cuda --target llama-server llama-bench llama-cli -j

# Qwen3.6-35B-A3B (GDN hybrid) at 256K, quality preset
/tmp/llama.cpp/build-cuda/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
```

The same preset works for the other live-verified GGUF families. Swap the model and context:

```bash
# Gemma 4 26B-A4B (SWA + D = 512 global layers; Gemma 4 31B and Gemma 3 27B use the same flags), 128K
/tmp/llama.cpp/build-cuda/bin/llama-server \
  -m gemma-4-26B-A4B-it-UD-IQ4_NL.gguf -ngl 99 -c 131072 -fa on -np 1 \
  --oasiskv --oasiskv-resident 2048 --oasiskv-cap 8 --oasiskv-index quest --oasiskv-kv-quant int8

# Gemma 4 E4B (Shared-KV tail layers), 128K on a 24 GB card
/tmp/llama.cpp/build-cuda/bin/llama-server \
  -m gemma-4-E4B-it-Q4_K_M.gguf -ngl 99 -c 131072 -fa on -np 1 \
  --oasiskv --oasiskv-resident 2048 --oasiskv-cap 8 --oasiskv-index quest --oasiskv-kv-quant int8

# gpt-oss 20B (D = 64 + learned sinks): stay on Quest + INT8
/tmp/llama.cpp/build-cuda/bin/llama-server \
  -m gpt-oss-20b-Q4_K_M.gguf -ngl 99 -c 131072 -fa on -np 1 \
  --oasiskv --oasiskv-resident 2048 --oasiskv-cap 8 --oasiskv-index quest --oasiskv-kv-quant int8

# Qwen3-8B and other pure full-attention models: double the working set
/tmp/llama.cpp/build-cuda/bin/llama-server \
  -m Qwen3-8B-Q4_K_M.gguf -ngl 99 -c 131072 -fa on -np 1 \
  --oasiskv --oasiskv-resident 4096 --oasiskv-cap 8 --oasiskv-index quest --oasiskv-kv-quant int8
```

For the high-compression tier (tight host RAM or GPU index VRAM), replace `--oasiskv-index quest --oasiskv-kv-quant int8` with `--oasiskv-index sphere --oasiskv-beta 0.10 --oasiskv-kv-quant wht_int4`.

`--oasiskv-alpha` defaults to auto (`0.25` for `D >= 256`, `1.0` below), so it can be omitted. `llama.cpp` supports both single-sequence (`-np 1`, full decode CUDA graphs) and parallel slots (`-np 2..256`, both default unified `-kvu` and `--no-kv-unified`) with lazy per-slot host allocation; GPU hot slabs and block indexes scale with `-np`. To run concurrent requests on `llama-server`, pass `-np 4` (or omit `-np` to use the server default of 4 slots). All flags, the prompt cache, and current limits: [`integrations/llamacpp/README.md`](integrations/llamacpp/README.md).

### SGLang (multi-user)

```bash
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

# Qwen3.8-27B-FP8 at 256K with NEXTN MTP (speculative decoding requires --max-running-requests)
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

# Gemma 4 26B-A4B / E4B, Gemma 3, gpt-oss (paged SWA hybrids): supports OKVP1 ram/nvme/mixed prefix cache
python3 -m sglang.launch_server \
  --model-path google/gemma-4-26B-A4B-it --context-length 131072 \
  --enable-oasiskv --attention-backend oasiskv --disable-radix-cache --page-size 16 \
  --oasiskv-config '{"resident_tokens":2048,"transfer_cap_c":8,"pcie_quant":"int8","index_quant":"int8","quest_alpha":0.25,"lazy_host_slabs":true,"streaming_prefill":true,"cache_mode":"mixed","prefix_cache_dir":"/tmp/basinkv_gemma4","prefix_cache_ram_gb":4.0,"prefix_cache_nvme_gb":32.0}'
```

Config key reference and more presets: [`integrations/sglang/README.md`](integrations/sglang/README.md). Hook-by-hook wiring: [`integrations/sglang/WIRING_PATCH.md`](integrations/sglang/WIRING_PATCH.md).

### vLLM V1 (zero-fork prefix cache)

```bash
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_nvme_gb": 64.0
  }
}'
```

Set `pcie_quant` explicitly: the vLLM code default is `wht_int4`. Mode 1 caches every KV group of dense, SWA, and recurrent hybrid models (`MambaSpec`: Mamba2 / Gated DeltaNet stored losslessly at exact token boundaries alongside quantized full-attention KV; live-verified on `ibm-granite/granite-4.0-h-micro` on unmodified vLLM `0.34.0`). Mode 2 (sparse decode, needs three upstream hooks): [`integrations/vllm/README.md`](integrations/vllm/README.md).

---

## Supported models

Full matrix with per-checkpoint evidence: [`docs/SUPPORTED_MODELS.md`](docs/SUPPORTED_MODELS.md).

| Model family | Examples | `llama.cpp` | SGLang | vLLM V1 |
|---|---|---|---|---|
| **Dense GQA / MHA** (`D` 64 to 512) | `Qwen3-8B`, Llama 3.1/3.3, Mistral, Phi-4 | Yes | Yes | Yes |
| **Recurrent + full-attention hybrids** | Qwen3.5/3.6/3.8 (GDN), Granite-4.0-H, Nemotron-H, Jamba, Falcon-H1 | Yes | Yes | Live-verified (`Granite-4.0-H-Micro`, `v0.34.0`); GDN/Mamba2 architecturally supported |
| **SWA + full-attention hybrids** (`D <= 512`) | Gemma 4 31B / 26B-A4B (`D = 512`), Gemma 2/3 (`logit_cap`), gpt-oss 20B/120B (`sinks`) | Live-verified | Live-verified (incl. `OKVP1` `ram`/`nvme`/`mixed` on paged `SWAKVPool`) | Live-verified (`SupportsHMA`, `v0.34.0`) |
| **Shared-KV tail layers** (`num_kv_shared_layers > 0`) | Gemma 4 E4B / E2B, Gemma 3n | Live-verified on E4B | Live-verified on E4B | Architecturally supported (`SupportsHMA`) |
| **Looped ShortConv + SWA + relative bias** | Inkling 2 Mini (`D = 128`, `rel_extent = 1024`) | Live-verified | Wired and kernel-tested (`cache_mode = "off"`) | Planned |
| **Multi-head latent attention (MLA)** | DeepSeek-V3/R1, GLM-5, Kimi K2 | Rejected at init | Rejected at init | Rejected at init |

---

## Benchmarks

Every number below comes from [`docs/summaries/benchmark-track-a-oasiskv.md`](docs/summaries/benchmark-track-a-oasiskv.md), which records the exact setup for each run.

### `llama.cpp` (single-user decode)

| Model & context | Hardware | Stock baseline | **BasinKV** | Quality check |
|---|---|---|---|---|
| `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** |
| `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 |
| `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`) |
| `Gemma 4 31B` Q4_K_M (`D = 512`, dense) @ 128K | A100-SXM4-80GB | 32.84 tok/s (`10 GiB` global KV) | **41.33 tok/s (1.26x)** (`Sphere+WHT4`) / `38.49` (`Quest+INT8`), `160 MiB` hot KV | 100% short parity; 30K passkey: **PASS** (both tiers) |
| `Gemma 4 26B-A4B` IQ4_NL (`D = 512`) @ 128K | A100-SXM4-80GB | 98.45 tok/s | **115.30 tok/s (1.17x)** (`Sphere+WHT4`) / `109.93` (`Quest+INT8`) | 100% short parity; 30K passkey: **PASS** (both tiers) |
| `Gemma 4 E4B` Q4_K_M (`num_kv_shared_layers = 18`) @ 128K | NVIDIA L4 (24 GB) | 31.69 tok/s | **61.46 tok/s (1.94x)** (`Sphere+WHT4`) / `57.50` (`1.81x`, `Quest+INT8`); **`95.1 tok/s`** agg @ `-np 4` | 100% short parity; 30K passkey & `-np 4` 4/4 concurrent passkeys: **PASS** |
| `Gemma 3 27B` Q4_K_M @ 128K | A100-SXM4-80GB | 37.88 tok/s | **46.47 tok/s (1.23x)** (`Quest+INT8`) / `46.39` (`1.22x`, `Sphere+WHT4`) | 100% short parity; 30K passkey: **PASS** (both tiers) |
| `gpt-oss 20B` Q4_K_M (`D = 64` + `sinks`) @ 128K | A100-SXM4-80GB | 140.25 tok/s | **142.84 tok/s** (`Quest+INT8`) / **168.74 (1.20x)** (`Sphere+WHT4`) | 100% short parity; 31K passkey: **PASS** (`Quest+INT8`) |
| `Inkling 2 Mini` Q4_K_M (looped + SWA) @ 64K / 128K | A100-SXM4-80GB | 59.39 tok/s @ 64K | **64.36 tok/s (1.08x)** @ 64K; **1.07x** @ 128K | 100% short parity; 35K passkey: **PASS** (both tiers) |

### SGLang (multi-user serving)

| Workload | Hardware | Stock baseline | **BasinKV** | Quality check |
|---|---|---|---|---|
| `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 |
| `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 |
| 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 (`D = 64..512`) | **40/40** RULER fields (64K to 240K) |
| SWA + Shared-KV hybrids (`Gemma 4 26B-A4B`, `Gemma 4 E4B`, `Gemma 3 27B`, `gpt-oss 20B`) | 1x A100-80GB | Stock baseline | **`82.95 t/s`** (`26B-A4B`), **`72.22 t/s`** (`E4B` Shared-KV), **`24.75 t/s`** (`Gemma 3 27B`) | 100% exact short parity & 28K passkeys: **PASS** (4/4 models) |

### vLLM V1 (zero-fork prefix cache)

| Workload | Hardware | Stock baseline | **BasinKV** | Quality check |
|---|---|---|---|---|
| `OKVP1` prefix cache (`Qwen3-8B`, `v0.19.1`) | 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 |
| `SupportsHMA` (`Gemma 4 26B-A4B`, `Gemma 3 4B`, `v0.34.0`) | A100-SXM4-80GB | `3.26 s` (`26B-A4B`) / `2.52 s` (`3-4B`) cold | **`0.85 s` warm (`3.84x`)** / **`0.69 s` restart (`wht_int4`, `736 MB`)**; **`0.61 s` (`4.14x`)** on `3-4B` | 4/4 passkeys **PASS** per tier; `1.97x` smaller on disk (`wht_int4` vs `int8`) |

### Figures

![Flat decode throughput across context depth in llama.cpp on A100-80GB PCIe](docs/figures/fig2_llamacpp_scaling.svg)

![Qwen3.6-35B-A3B Q4_K_M at 256K on a 24 GB NVIDIA L4](docs/zellige/figures/fig6_l4_24gb_256k.png)

![SGLang multi-user throughput on Qwen3.8-27B BF16 (1x A100-80GB)](docs/figures/fig1_sglang_throughput.svg)

![H100 FP8 aggregate decode throughput and B = 16 batch wall times](docs/zellige/figures/fig1_h100_fp8_roofline.png)

![Quality preservation vs host and disk KV footprint compression](docs/figures/fig3_quality_memory_pareto.svg)

![Tiered RAM and NVMe prefix cache speedup](docs/figures/fig4_prefix_cache_speedup.svg)

---

## How it works

- **Fixed GPU working set** ([`src/oasiskv/pool.py`](src/oasiskv/pool.py)): sink blocks, retrieved sparse blocks, and a local ring live in static physical pages (`W = 2,048` tokens per head by default), so FlashAttention, FlashInfer, and CUDA graphs run unmodified.
- **Partial-RoPE radius weight `alpha = 0.25`** ([`src/oasiskv/selector.py`](src/oasiskv/selector.py)): on BF16 `Qwen/Qwen3.8-27B` (`D = 256`, 64 RoPE + 192 NoPE dims) the non-rotary box radius averages `2.70x` the midpoint magnitude (`1.898` vs `0.704`). Lowering `alpha` to `0.25` raises per-step Top-8 recall from `29.9%` (unweighted Quest) and `82.5%` (`alpha = 0.50`) to `95.5%` (`93.2%` GQA max) and restores 128K RULER from `0/5` to `5/5`.
- **`SphereIndex`** ([`src/oasiskv/sphere_index_cuda.py`](src/oasiskv/sphere_index_cuda.py)): randomized Walsh-Hadamard rotated INT4 centroid, FP32 scale, and two FP16 subspace radii (`r_rope`, `r_nope`) in `136 B/blk` at `D = 256` (`7.53x` smaller than BF16 min/max).
- **`WHT-INT4` host KV** ([`src/oasiskv/wht_int4_kv.py`](src/oasiskv/wht_int4_kv.py)): per-vector orthonormal WHT plus symmetric 4-bit quantization (`D/2 + 4` bytes per K or V vector), `1.97x` smaller than INT8 (`3.88x` smaller than BF16) at `D = 256` with `<0.5%` decode speed difference.
- **Successor co-fetch** ([`src/oasiskv/selector.py`](src/oasiskv/selector.py)): before top-k, each eligible block's score propagates one hop forward (`score'[b + 1] = max(score[b + 1], nextafter(score[b], -inf))`) at zero VRAM cost, so cues that straddle a block boundary fetch both halves (`0/30` live boundary failures on H100).
- **Persistent prefix caches and sparse prefill** ([`src/oasiskv/prefix_cache.py`](src/oasiskv/prefix_cache.py), [`src/oasiskv/sparse_prefill.py`](src/oasiskv/sparse_prefill.py)): content-addressed SHA-256 block-chained `OKVP1` / `OKVS1` snapshots in RAM or NVMe (including hybrid recurrent state), plus an optional fused Triton block-sparse prefill kernel (`-10.50 s` cold TTFT at 240K on H100).

Full method, ablations, and roofline analysis: [technical paper](https://zellige.ai/research/basinkv) ([markdown](docs/paper/oasiskv_v2_paper.md)). Shorter overview: [launch post](https://zellige.ai/research/basinkv-launch) ([markdown](docs/paper/basinkv_launch_post.md)).

---

## Repository layout

| Path | Contents |
|---|---|
| [`src/oasiskv/`](src/oasiskv/) | Engine-agnostic Python/CUDA core: config, tiered pool, Quest and `SphereIndex` scorers, `WHT-INT4`, UVA gather, Triton sparse prefill, `OKVP1` prefix cache. |
| [`integrations/`](integrations/README.md) | Cross-engine feature matrix, install steps, and upstream PR checklists. |
| [`integrations/llamacpp/`](integrations/llamacpp/README.md) | Standalone C++17/CUDA core, pinned upstream patch, installer, CUDA test suite. |
| [`integrations/sglang/`](integrations/sglang/README.md) | SGLang pool, coordinator, attention backend, MTP draft ring, and `apply_wiring.py`. |
| [`integrations/vllm/`](integrations/vllm/README.md) | vLLM V1 `OasisKVConnector` (Mode 1) and `OasisVllmAttentionBackend` (Mode 2). |
| [`docs/`](docs/README.md) | User guides, technical paper, raw benchmark log, figures. |
| [`benchmarks/oasiskv/`](benchmarks/oasiskv/README.md) | Live serving benchmarks, paper evaluation harness, microbenchmarks. |
| [`scripts/`](scripts/) | Figure generators. |
| [`tests/`](tests/) | CPU and CUDA unit, regression, parity, and release tests. |

## Tests

```bash
pip install -e ".[dev]"
pytest tests/ -q                            # CPU suite; CUDA tests skip without a GPU
make -C integrations/llamacpp host-check    # llama.cpp C++17 header check, no nvcc needed
```

GPU kernel suites and live serving smoke tests: [`docs/TINKERING_AND_TUNING.md`](docs/TINKERING_AND_TUNING.md#4-testing--verification-commands).

## License

Apache-2.0. See [`LICENSE`](LICENSE).
