# BasinKV: Bounded-VRAM Long-Context Serving in SGLang, llama.cpp, and vLLM

> We present BasinKV, a bounded-VRAM sparse KV-cache runtime for 256-dimensional partial-RoPE hybrids and dense LLMs across SGLang, llama.cpp, and vLLM V1, built on the OasisKV architecture [Xiao et al. 2026] while keeping unmodified FlashInfer and FlashAttention decode kernels inside CUDA graphs. On a single A100-80GB, BasinKV in SGLang serves 16 concurrent 64K prompts of BF16 Qwen3.8-27B (about one million active tokens) at 581.4 aggregate decode tokens/s with native multi-token prediction (MTP), 16/16 passkeys, and 18.13 GB of VRAM free, a load that stock serving with MTP cannot admit. On an H100 with FP8 weights at the same load, BasinKV reaches 470.4 aggregate decode tokens/s against 358.0 for stock FP8 KV (2.03x shorter batch wall time) and 33.9 for stock BF16 KV. In llama.cpp, Qwen3.6-35B-A3B decodes at 141.12 tokens/s at 256K depth on an A100 PCIe (1.49x stock, -8.91 GiB process memory) and runs live at 256K on a real 24 GB NVIDIA L4 at 67.12 tokens/s in 21,163 MiB idle / 21,885 MiB peak VRAM with exact 64K and 203K passkey retrieval, where stock F16 KV hits CUDA OOM starting at 64K.

- URL: https://zellige.ai/research/basinkv
- Published: 2026-11-30
- Authors: Zellige
- Tags: inference, kv-cache, long-context, systems, open-source
- Publisher: Zellige AI (https://zellige.ai)
- Code on GitHub (zellige-ai/basinkv): https://github.com/zellige-ai/basinkv
- Original OasisKV paper (Xiao et al., arXiv:2608.08097): https://arxiv.org/abs/2608.08097

*Compressed block indexes, rotated 4-bit host KV, and persistent prefix caches for hybrid and dense LLMs*

**Attribution.** BasinKV is Zellige's independent implementation and extension of the OasisKV bounded-VRAM lookahead-prefetch architecture introduced by Can Xiao, Sukmin Cho, and colleagues [Xiao et al. 2026, arXiv:2608.08097]. Rows labeled "BasinKV" measure our implementations across SGLang, llama.cpp, and vLLM V1 (not the original authors' vLLM code); repository paths and CLI flags in this release still retain the `oasiskv` namespace.

---

## Abstract

We present **BasinKV**, a bounded-VRAM sparse KV-cache runtime for 256-dimensional partial-RoPE hybrids and dense LLMs across SGLang, llama.cpp, and vLLM V1, built on the OasisKV architecture [Xiao et al. 2026] while keeping unmodified FlashInfer and FlashAttention decode kernels inside CUDA graphs. On a single A100-80GB, BasinKV in SGLang serves 16 concurrent 64K prompts of BF16 Qwen3.8-27B (about one million active tokens) at 581.4 aggregate decode tokens/s with native multi-token prediction (MTP), 16/16 passkeys, and 18.13 GB of VRAM free, a load that stock serving with MTP cannot admit. On an H100 with FP8 weights at the same load, BasinKV reaches 470.4 aggregate decode tokens/s against 358.0 for stock FP8 KV (2.03x shorter batch wall time) and 33.9 for stock BF16 KV. In llama.cpp, Qwen3.6-35B-A3B decodes at 141.12 tokens/s at 256K depth on an A100 PCIe (1.49x stock, -8.91 GiB process memory) and runs live at 256K on a real 24 GB NVIDIA L4 at 67.12 tokens/s in 21,163 MiB idle / 21,885 MiB peak VRAM with exact 64K and 203K passkey retrieval, where stock F16 KV hits CUDA OOM starting at 64K.

Three design pieces drive these results on modern hybrids. On 256-dimensional heads with 64 rotary and 192 non-rotary dimensions (verified native BF16 Qwen3.8-27B at 32K), lowering the radius weight to `alpha = 0.25` raises per-step top-8 needle-block recall from 29.9% (unweighted Quest) and 82.5% (OasisKV Eq. 3 `alpha = 0.5` sum) to 93.2% (GQA max) and 95.5% (GQA sum), restoring 128K RULER retrieval from 0/5 to 5/5. **SphereIndex** packs a randomized-Hadamard-rotated INT4 block centroid and two subspace radii into 136 bytes at `D = 256`, 7.53x smaller than BF16 min/max bounds. **WHT-INT4** rotates and quantizes host KV to `D/2 + 4` bytes per K or V vector, 1.97x smaller than INT8 at `D = 256` with decode speed within 0.5%. Around these formats we build lazy host slabs, a static draft-KV ring for hybrid MTP, direct-to-host streaming prefill, a fused Triton block-sparse prefill kernel that cuts cold 240K TTFT by 10.50 s, and persistent RAM/NVMe prefix caches (`OKVP1` and `OKVS1`), including a zero-fork vLLM V1 connector validated live.

Across retrieval, multi-hop reasoning, iterative coding, and an 80-item LongBench v2 subset (45.0% vs 42.5% stock), bounded resident KV tracks full-KV baselines on hybrid models. We also map where offloading does not win: models whose full KV fits comfortably in HBM (such as Qwen3.6-35B-A3B-FP8 on H100), uniform global aggregation tasks such as `cwe` at sub-1% resident budgets, and deep pure-attention models without larger or head-aware budgets. Code, engine integrations, kernels, and benchmark harnesses are open source.

---

## 1. Introduction

The memory a transformer reads per decoded token grows linearly with context. For pure-attention models this growth is severe: `Qwen3-8B` (36 layers, 8 KV heads, `D = 128`) needs 18.00 GiB of BF16 KV at 128K tokens, more than its 15.26 GiB of nominal weights. Hybrid architectures change the shape of the problem without removing it. `Qwen3.8-27B` replaces 48 of its 64 layers with Gated DeltaNet recurrences whose state is constant in sequence length, yet its 16 full-attention layers still need 8.00 GiB at 128K and 16.00 GiB at 256K. On an A100-80GB holding about 51 GB of BF16 weights, the remaining memory admits about one 128K request at a time, and stock aggregate decode throughput stays at 25.1 tokens/s for four concurrent 128K requests.

Quest [Tang et al. 2024] showed that most decode steps attend to a small set of KV pages that can be ranked from per-page key bounds. OasisKV [Xiao et al. 2026] turned that observation into a serving design: it keeps a bounded per-head set of KV blocks in HBM, offloads the full cache to lower memory tiers, scores blocks with a radius-weighted Quest bound (their Eq. 3, which sums over the query heads sharing a KV head), predicts the next step's blocks by propagating a speculative draft token, prefetches asynchronously with a fused UVA gather, and was implemented in vLLM and evaluated on LongBench v2, AIME, and GPQA-Diamond.

We ask how this design behaves on current hybrid models and what it takes to run it inside several serving engines. Four problems shaped the work.

1. **Selector behavior at `D = 256` with partial RoPE.** Qwen3.x hybrids use 256-dimensional heads with 64 rotary and 192 non-rotary (NoPE) dimensions. We measure how the published radius-weighted score behaves on these heads and implement a dimension-dependent default. With unweighted Quest (`alpha = 1`), retrieval collapsed to 0/5 RULER items at 128K on BF16 Qwen3.8-27B (§5.2).
2. **Index size.** The resident KV window is bounded, but the block index covers the full history. At 256K context with 16-token blocks, a BF16 min/max index (1.00 GiB on Qwen3.8-27B) is 8x the 128 MiB resident window.
3. **Host memory at high concurrency.** Once resident KV is bounded, pinned host RAM limits how many long requests fit.
4. **Real engines.** CUDA graphs, paged attention kernels, chunked prefill, speculative verification, and multi-process lifecycles all constrain where the design can hook in.

**Contributions.** Each item below builds on the OasisKV design; §7 lists what we inherit.

- **Radius-weight analysis on partial-RoPE heads** (§2.2, §3.2). On native BF16 Qwen3.8-27B at 32K, lowering the radius weight to `alpha = 0.25` raises per-step top-8 (`C = 8`) needle-block recall from 29.9% (unweighted Quest) and 82.5% (OasisKV Eq. 3 `alpha = 0.5` sum) to 93.2% (GQA max) and 95.5% (GQA sum), while reaching 98.9% to 100.0% at top-116; our llama.cpp port selects `alpha` by head dimension.
- **SphereIndex** (§3.3): a packed block summary (randomized-Walsh-Hadamard-rotated centroid in INT4, one FP32 scale, two FP16 subspace radii; `D/2 + 8` bytes per block), 7.53x smaller than a BF16 min/max index at `D = 256`.
- **WHT-INT4 host KV** (§3.4): per-vector randomized Hadamard rotation and symmetric 4-bit quantization of the host tier, `D/2 + 4` bytes per K or V vector.
- **Serving implementations** (§3.6, §3.7): sparse decode in SGLang (lazy host slabs, a static ring-mapped draft KV pool for hybrid NEXTN MTP, direct-to-host streaming chunked prefill) and in a dependency-free llama.cpp core; an optional fused Triton block-sparse prefill with a one-launch UVA WHT-INT4 gather; and a zero-fork vLLM V1 prefix-cache connector validated live.
- **Persistent local prefix caches** (§3.5): compressed RAM/NVMe snapshots in `OKVP1` (SGLang and vLLM) and `OKVS1` (llama.cpp), including recurrent state for hybrid prefixes.
- **Cross-architecture and roofline evaluation** (§5.8, §6): FP8 serving on H100, non-Qwen Mamba2 hybrids (IBM Granite-4.0-H-Small and NVIDIA Nemotron-Nano-9B-v2), LongBench v2, live vLLM prefix caching, cold sparse prefill, and a roofline accounting of decode and prefill bottlenecks once resident KV is bounded.

---

## 2. Background and Motivation

### 2.1 Where the KV bytes are

Table 1 lists KV growth for selected model geometries we evaluate. The resident GPU KV window is fixed by `W`. The block index is not: it grows with the number of blocks in the history.

**Table 1.** Selected model geometries: KV footprint versus the resident window (`W = 2,048`, BF16/FP16 KV). Binary units; weights are nominal checkpoint sizes.

| Model | Architecture | Weights | KV @ 32K | KV @ 128K | Resident KV (`W = 2,048`) | BF16 min/max index @ 128K |
|---|---|---:|---:|---:|---:|---:|
| Qwen2.5-3B-Instruct | 36L pure GQA (2 KV, D=128) | 5.75 GiB | 1.12 GiB | 4.50 GiB | 72 MiB | 288 MiB |
| Qwen2.5-7B-Instruct | 28L pure GQA (4 KV, D=128) | 15.20 GiB | 1.75 GiB | 7.00 GiB | 112 MiB | 448 MiB |
| Qwen3-8B | 36L pure GQA (8 KV, D=128) | 15.26 GiB | 4.50 GiB | 18.00 GiB | 288 MiB | 1.12 GiB |
| Qwen3.5-9B | Hybrid: 24 DeltaNet + 8 full (4 KV, D=256) | 16.68 GiB | 1.00 GiB | 4.00 GiB | 64 MiB | 256 MiB |
| Qwen3.8-27B | Hybrid: 48 DeltaNet + 16 full (4 KV, D=256) | 53.50 GiB | 2.00 GiB | 8.00 GiB | 128 MiB | 512 MiB |

On pure-attention models the KV cache dominates memory at long context. On hybrids the KV cache is smaller but still decides concurrency, because the recurrent layers are cheap and the full-attention KV becomes the main per-request cost. The index column shows why the index itself must be compressed at 256K and beyond.

### 2.2 The radius term on `D = 256` partial-RoPE heads

Quest scores a block of keys `K_b` for query `q` with the upper bound `sum_i max(q_i * kmin_i, q_i * kmax_i)`. Writing the box as midpoint `k_mid = (kmax + kmin)/2` and radius `k_rad = (kmax - kmin)/2`, the bound equals `q. k_mid + |q|. k_rad`. OasisKV's Eq. 3 places a weight `alpha` on the radius term [Xiao et al. 2026]. The radius term grows with the per-dimension spread of keys inside the block, not with how well the block matches the query.

We captured full-attention keys and decode queries across all 16 full-attention layers of native BF16 `Qwen/Qwen3.8-27B` (all 26.9B parameters verified `torch.bfloat16`, 50.10 GiB weight VRAM, 5/5 dense RULER) at 32K and measured recall on 177 qualifying `(needle, layer, KV head)` events with at least 5% oracle attention mass. On the 192 NoPE dimensions, the mean box radius (1.898) is 2.70x the mean absolute midpoint (0.704), compared with 1.38x (1.318 vs 0.953) on the 64 RoPE dimensions. With `alpha = 1`, the radius term outweighs the midpoint signal and ranks the target block in the top eight for only 53/177 qualifying events under the previous-step query (48/177 under the current query). The previous-step query is not the limiting factor here: ranking blocks by exact attention mass under the previous query reaches 171/177 at 8 blocks and 177/177 at 116 blocks.

### 2.3 Hybrid models change the error budget

In the Qwen3.x hybrids we evaluate, three recurrent layers (Gated DeltaNet plus MLP) sit between consecutive full-attention layers. Two consequences matter for sparse decoding. Background prefetch for full-attention layer `l` can overlap with the recurrent layers before it. A missed block in one sparse layer also perturbs fewer downstream sparse layers; §6.2 gives an illustrative calculation. The later Mamba2 results (§5.8) do not establish this interleaving as a general hybrid layout.

---

## 3. System Design

### 3.1 Overview

Following OasisKV, we retain a bounded set of KV blocks per head in HBM and fetch from host memory asynchronously [Xiao et al. 2026]. For each full-attention layer and KV head, our implementations keep a resident window of `W` tokens, organized as `W / B` blocks of `B = 16` tokens: sink blocks at the start of the sequence, a local ring at the end, and sparse slots filled by retrieval (in the llama.cpp port, 4 sink + 112 sparse + 12 local blocks at `W = 2,048`). The complete KV for every token lives in pinned host memory, compressed to INT8 or WHT-INT4. A per-block index for the full history lives in GPU memory, so index bytes and scoring work grow with the number of blocks; the resident KV payload does not.

**Predictor.** Our decode path differs from OasisKV here. At decode step `t`, attention runs over the resident blocks with an unmodified attention kernel (FlashInfer paged decode [Ye et al. 2025] in SGLang, `ggml_flash_attn_ext` in llama.cpp). After attention, the step's query `q_t` goes to a background CUDA stream that scores every block of the layer's index, selects the top blocks not already resident, admits at most `C` of them per KV head (evicting least-recently-selected sparse blocks), and gathers their host KV over PCIe with a fused UVA kernel. Step `t + 1` then attends over the updated window. From the point of view of step `t + 1`, this is a previous-query predictor. OasisKV instead propagates a draft token to obtain a lookahead query and treats the previous query as a baseline. §6.2 discusses the failure mode of the previous-query predictor on abrupt query shifts.

**Prefill.** Prefill runs exact full attention by default. Completed blocks are quantized, written to host memory, and summarized into the index as they seal. During decode, a block that fills is flushed and sealed by a single batched kernel launch per layer. §3.7 describes an optional block-sparse prefill.

### 3.2 Radius weight and a dimension-dependent default

We use the radius-weighted Quest score from OasisKV Eq. 3 and evaluate its behavior on partial-RoPE heads:

```
score_alpha(q, b) = q. k_mid(b) + alpha * |q|. k_rad(b)
 = 0.5 * (q + alpha*|q|). kmax(b) + 0.5 * (q - alpha*|q|). kmin(b)
```

The second form shows the implementation cost: two GEMVs against the existing min/max tensors with a modified query. `alpha = 1` is unweighted Quest and `alpha = 0` scores the box midpoint. Two details differ from the published formulation. OasisKV sums scores over the query heads that share a KV head; our scorers take the maximum over the query heads of a GQA group. OasisKV's Appendix B ablates the radius weight and selects `alpha = 0.5` for Qwen3-8B [Xiao et al. 2026]; our llama.cpp port selects `alpha = 0.25` for `D >= 256` and `alpha = 1.0` for `D < 256`.

**Table 2.** Needle-block recall on native BF16 `Qwen/Qwen3.8-27B` at 32K (177 qualifying `(needle, layer, KV head)` events with >= 5% oracle attention mass, previous-step query `q[t-1]`; GQA sum and GQA mean produce identical rankings).

| Scorer | Top-8 (`C = 8`) | Top-116 (`W = 2K`) | Top-244 (`W = 4K`) | Extra VRAM |
|---|---:|---:|---:|---:|
| Unweighted Quest (`alpha = 1.00`, GQA max) | 29.9% (53/177) | 62.7% (111/177) | 75.1% (133/177) | 0 |
| Unweighted Quest (`alpha = 1.00`, GQA sum) | 24.3% (43/177) | 68.9% (122/177) | 79.7% (141/177) | 0 |
| OasisKV default (`alpha = 0.50`, GQA max) | 79.7% (141/177) | 97.2% (172/177) | 99.4% (176/177) | 0 |
| OasisKV Eq. 3 (`alpha = 0.50`, GQA sum) | 82.5% (146/177) | 100.0% (177/177) | 100.0% (177/177) | 0 |
| **BasinKV (`alpha = 0.25`, GQA max)** | **93.2% (165/177)** | **98.9% (175/177)** | **100.0% (177/177)** | **0** |
| **BasinKV (`alpha = 0.25`, GQA sum)** | **95.5% (169/177)** | **100.0% (177/177)** | **100.0% (177/177)** | **0** |
| Box midpoint (`alpha = 0.00`, max / sum) | 94.9% / 96.0% | 98.9% / 100.0% | 99.4% / 100.0% | 0 |
| Block centroid (`k_mean`, max / sum) | 95.5% / **97.7%** | 99.4% / 100.0% | 100.0% / 100.0% | -50% |
| Exact oracle mass (`q[t-1]`) | 96.6% (171/177) | 100.0% (177/177) | 100.0% (177/177) | n/a |

Two patterns stand out on these `D = 256` partial-RoPE heads. First, while OasisKV's Eq. 3 (`alpha = 0.50`, GQA sum) already reaches 100.0% at the full 116-block resident window, it drops to 82.5% (79.7% under GQA max) at the per-step `C = 8` admission cap; reducing the radius weight to `alpha = 0.25` gains +13.0 points under GQA sum (95.5% vs 82.5%) and +13.5 points under GQA max (93.2% vs 79.7%; under the current query `q[t]`, both `alpha = 0.25` variants hit 94.9% vs 80.2% sum / 73.4% max for `alpha = 0.50`). Second, summing across the GQA group slightly beats max aggregation by +2.2 to +2.8 points across `alpha = 0.50`, `0.25`, and `k_mean`, and the plain block centroid `k_mean` reaches 97.7% at Top-8 while halving index storage, directly motivating §3.3.

### 3.3 SphereIndex: a packed rotated-centroid block index

The index must shrink without losing the retrieval quality of Table 2. Quantizing min/max endpoints to INT8 with outward rounding halves the index with no recall loss in our tests (0.977 vs 0.977 on Qwen3-8B; 0.833 vs 0.828 on Qwen3.8-27B). Going further with a box representation failed: applying a Walsh-Hadamard transform before computing the box spreads sparse channel energy across all dimensions, loosens every box, and dropped needle recall from 0.97 to 0.33.

SphereIndex instead summarizes block `b` by its key centroid `mu_b` and two radii, `r_rope(b)` and `r_nope(b)`: the largest Euclidean distance of any key in the block from `mu_b` within the rotary and non-rotary subspaces. The radii therefore depend on the chosen subspace partition. The centroid is rotated by a fixed randomized Walsh-Hadamard transform `R = H * diag(s)` and stored as signed INT4 codes in `[-7, 7]` with one FP32 scale; the radii are FP16. Randomized Hadamard rotation before low-bit quantization follows QuaRot [Ashkboos et al. 2024] and related work. At decode, the query is rotated by the same `R` and each block is scored as

```
score(q, b) = (R q). dequant(mu_b) + beta * ( ||q_rope|| * r_rope(b) + ||q_nope|| * r_nope(b) )
```

with the maximum taken over the query heads of a GQA group (and over speculative tokens during verification). With `beta = 1` the second term would be a Cauchy-Schwarz bound on how far any key in the block can deviate from the centroid in each subspace; with `beta = 0.10` it is a shrunk heuristic and need not bound every key. Rotation preserves the unquantized centroid dot product; INT4 quantization of the rotated centroid can still change rankings. The rotation spreads outlier channels so one scale fits the whole vector.

The packed format uses `D/2 + 8` bytes per block (INT4 codes, FP32 scale, two FP16 radii): 136 B at `D = 256` and 72 B at `D = 128`, versus 1,024 B and 512 B for a BF16 min/max index, a 7.53x and 7.11x saving. The production setting is INT4 with `beta = 0.10`, selected by the gates in §5.3, which simulate quantization offline and use their own byte accounting. A fused CUDA kernel performs query rotation, INT4 dot products, and radius scoring in one launch.

### 3.4 WHT-INT4 rotated host KV

Host memory holds every token's keys and values, so its size sets the concurrency ceiling once resident KV is bounded. INT8 per-vector quantization with an FP32 scale preserved retrieval in our tests, but it costs about half of BF16.

WHT-INT4 applies an orthonormal randomized Walsh-Hadamard transform to each token's key and value vectors (supported `D` in {64, 128, 192, 256, 320}), then quantizes symmetrically to 4 bits (`q` in `[-7, +7]`, two codes per byte) with one FP32 scale per vector. Storage is `D/2 + 4` bytes per K or V vector, so a KV pair costs `2(D/2 + 4)` bytes per token per head. Against INT8 (`2(D + 4)`) and BF16 (`4D`), the saving is 1.94x and 3.76x at `D = 128`, and 1.97x and 3.88x at `D = 256`. Dequantization applies the inverse transform after gather. In a synthetic test with 20x heavy-tailed outlier channels at `D = 256`, WHT-INT4 reached relative L2 error 0.1017 (cosine 0.99486) against 0.3970 for naive INT4, a 3.9x reduction. Quantize, dequantize, and gather are warp-shuffle CUDA kernels with no shared memory, implemented once for the Python engines and once for llama.cpp; both match the PyTorch reference within `9.54e-7`.

### 3.5 Tiered HBM / DDR / NVMe storage and compressed prefix caches

Our host representation is already block-aligned and quantized, which makes it a natural unit for caching and spilling.

- **Content-addressed prefix cache.** Token blocks are keyed by a chained SHA-256 over `(configuration namespace, block contents)`, so a lookup finds the longest cached prefix of a new prompt (16.4 ms for a 128K-token, 8,192-block lookup). A hit restores host slabs, the block index, optional resident GPU pages, and, for hybrid models, the recurrent state saved with the snapshot. A hybrid prefix can be resumed only up to the most recent position for which a compatible recurrent checkpoint exists (for example, `cache_n = 11,243` of 15,339 tokens in our llama.cpp session-save run).
- **`OKVP1` (Python; SGLang and vLLM).** 4 KB-aligned binary files written to a temporary file, `fsync`ed, and atomically replaced (`os.replace`), with streaming CRC32 over 16 MiB chunks. Loads stream into preallocated tensors with `readinto`, so peak memory is about 1x the snapshot. The writer does not `fsync` the parent directory.
- **`OKVS1` (llama.cpp).** Written through `O_CREAT | O_EXCL | O_NOFOLLOW` with `0600` permissions, `fsync`, and `rename`, with a slice-by-8 CRC32. The loader reads complete per-pool buffers.
- **Tiers.** `cache_mode` selects `ram` (DDR LRU), `nvme` (disk only, no idle RAM), or `mixed` (RAM hot set with LRU spill to NVMe). Idle multi-turn sessions can also be spilled out of pinned host slabs to NVMe and restored bit-identically.
- **Decode-time NVMe tier.** For contexts beyond host RAM, a sector-aligned `O_DIRECT` block store serves cold INT8 blocks behind a DRAM tier.

For both formats we claim atomic replacement and the tested process restart, not general crash consistency.

### 3.6 Serving implementations

**llama.cpp.** A dependency-free C++17/CUDA core (`oasiskv_ggml.h`, `oasiskv_ggml_cuda.cu`) implements INT8 min/max and SphereIndex scoring, a single-launch radix top-k with bitonic sort, admission and eviction, UVA gather, chunked prefill materialization, and `OKVS1` state save and restore. CUDA graphs stay enabled during decode. When the host cannot map large pinned buffers into the device address space (we hit a 256 MB `DEVICEMAP` cap in one rented container), the port falls back to explicit staging copies, at a measured speed cost (§6.4). A 256-thread warp-shuffle rewrite of the selection and eviction kernel cut 36-layer Qwen3-8B lookahead by 2.0x to 2.8x (`W = 4096` at 128K: 18.43 ms to 6.93 ms). State saves avoid a double export through an `O(1)` size query (408 ms save overhead for a 143.1 MiB WHT-INT4 snapshot of Qwen3.6-35B-A3B, about 9x faster than the approximately 3.5 s saves before the change).

**SGLang.** Our code plugs into SGLang's `HybridLinearKVPool` and `HybridLinearAttnBackend`: recurrent layers stay on SGLang's native Triton GDN path, and the full-attention layers use our paged HND pool with FlashInfer decode and chunked prefill. The production path adds a fused row-indexed scorer (14.7x faster than the unfused version at `B = 1 x 64K`), a batched flush-rotate-seal boundary kernel (16 rows x 16 layers in 1.660 ms, 866.2x faster than the per-row Python path), a graph-safe INT8 index, CUDA-graph-safe lazy host slabs with a live `MemAvailable` guard, a static ring-mapped FP8 draft KV pool for hybrid NEXTN multi-token prediction, direct-to-host streaming chunked prefill, and zero-copy speculative verification with FlashInfer prefill plus `merge_state`. Our SGLang integration follows the allocator and scheduler wiring of upstream HiSparse [Xie et al. 2026; SGLang PR #20343] on commit `a3f0bff5` and adds a separate OasisKV pool, coordinator, and backend (mutually exclusive with `--enable-hisparse`) for GQA/MHA full-attention layers.

**vLLM V1.** Mode 1 is a zero-fork `KVConnectorBase_V1` plugin providing the compressed prefix cache with `cache_mode` in {off, ram, nvme, mixed} and `pcie_quant` in {none, int8, wht_int4}, rank-isolated for tensor and pipeline parallelism. It ran live on `vllm 0.19.1` and passed 6/6 scenarios (Table 18). Mode 2 is an attention backend and coordinator that reuses the SGLang pool, SphereIndex, WHT-INT4, and session spill. It needs three upstream hooks that are not yet applied and has passed only unit and mock tests (44/44). OasisKV's own implementation is in vLLM; our vLLM contribution is the V1 prefix-cache connector.

### 3.7 Extensions

**Block-sparse prefill (measured; §5.8, Table 19).** Streaming chunked prefill already seals SphereIndex summaries for every prior chunk. Scoring those summaries with mean queries of 128-token query blocks lets each query block attend to sinks, a local window, and the top-scoring prior blocks only, cutting prefill attention work and the host-to-device traffic of streaming prefill together. Prefill sparsity alters the hidden states that produce later layers' keys and values, so errors can compound with depth; the implementation keeps the first one or two full-attention layers dense. The live path uses a fused Triton block-sparse attention kernel and a one-launch UVA WHT-INT4 block gather.

**Two-group head-aware windows (designed, unmeasured).** Pure-attention models spend much of a uniform window on heads that only attend locally. Splitting each layer's KV heads into a retrieval group with a large window and a local group with a small ring, and running two unmodified attention calls per layer, gives retrieval heads a 3.0x to 3.5x larger window at equal or lower total VRAM (§6.2). The llama.cpp core has unit tests for this path; end-to-end quality has not been measured.

---

## 4. Implementation and Verification

The shared Python and CUDA core implements configuration, block selection, host slab pools, UVA gather, SphereIndex, WHT-INT4, persistent prefix caching, the `O_DIRECT` NVMe tier, and block-sparse prefill, with engine-specific integrations for llama.cpp, SGLang, and vLLM V1 (Appendix B lists repository paths). Every CUDA and Triton kernel is checked against a PyTorch or FP64 reference, including adversarial cases such as BF16 scales above `8.32e6`, `NaN`/`Inf` ties in top-k selection, and partial-block flush followed by eviction and re-fetch. Over 1,300 automated kernel-parity and integration tests cover the SGLang fast paths and SphereIndex (695 tests), the `__dp4a` scorer and sparse-prefill selection (447), the fused Triton sparse-prefill kernel and UVA gather (74), the vLLM V1 integration (44), persistent prefix caches (26), and the standalone llama.cpp CUDA core (18).

---

## 5. Evaluation

### 5.1 Setup

**Hardware.** NVIDIA A100-SXM4-80GB (bare metal, 1,740.1 GB/s HBM, 26.82 GB/s PCIe Gen4), A100-80GB PCIe (1,584 GB/s HBM measured, 26.4 GB/s PCIe), H100 80GB HBM3, and a 24 GB NVIDIA L4 (`sm_89`, 23,034 MiB total / 22,614 MiB ECC-usable VRAM; earlier pure-attention tests used a 22 GB L4 slice). Each table names its GPU.

**Models.** Qwen3.8-27B (hybrid, dense weights; BF16, Q4_K_M, and official block-FP8), Qwen3.6-35B-A3B (hybrid MoE, 3B active; Q4_K_M and block-FP8), Qwen3-8B (pure attention; BF16 and Q4_K_M), IBM Granite-4.0-H-Small (Mamba2 hybrid MoE, all-NoPE attention; Q4_K_M), and NVIDIA Nemotron-Nano-9B-v2 (Mamba2 hybrid; Q4_K_M).

**Baselines and terminology.** For hybrid models we write **Unmodified (BF16 KV)** and **Unmodified (FP8 KV)** (SGLang `fp8_e5m2`). Stock llama.cpp keeps an F16 KV cache with FlashAttention on; we label it **Unmodified (F16 KV)**. For pure-attention models we write **Full-KV Baseline**. **BasinKV** rows are our implementations across SGLang, llama.cpp, and vLLM V1. "v1", "v2", and "v3" in §5.4 are successive revisions of our SGLang implementation, defined in Table 6. Unless stated, BasinKV arms use `W = 2,048`, `C = 8`, INT8 host KV, and SphereIndex INT4 with `beta = 0.10`; min/max-index rows use `alpha = 0.25`. All decoding is greedy (temperature 0).

**Metrics.** Metrics are defined per runner.
- *Table 3 parity* counts the length of the matching greedy prefix against the runner's own full-KV reference, up to the first disagreement; `48/48` means one 48-token continuation matched completely at that context length. KL is the mean per-step KL divergence from the reference's next-token distribution; `0.0000` is rounded to four decimals.
- *SphereIndex Gate 1* scores blocks with the current query and normalizes attention mass over the eligible middle blocks (excluding sink and local blocks). Its parity column reports positionwise token matches.
- *5-item RULER-style probes* count exact retrieval of 4 multi-depth passkeys plus a 3-hop variable chain.
- *7-task RULER* (`niah_single_3`, `niah_multikey_3`, `niah_multivalue`, `niah_multiquery`, `vt`, `cwe`, `qa_2`, plus `fwe` in Gate 2) reports graded task scores; some tasks give partial credit. McNemar tests on RULER use per-sample exact match, which is not the same quantity as the graded mean.
- *The 3-turn iterative coding gate* grades SEARCH/REPLACE patches with hidden `pytest` suites across turns that push earlier files into host memory and introduce spec overrides; a stale-override trap detects answers that follow a superseded rule. Its 18 turns come from 6 sessions, so turns are not independent.
- Paired accuracy comparisons use the exact two-sided McNemar test.

**Statistical note.** Paired quality suites use modest sample sizes (28 RULER items, 18 coding turns, 80 of 503 LongBench v2 items), so non-significant McNemar tests rule out large regressions without proving strict equivalence; confidence intervals are reported alongside the LongBench v2 results in §5.8.

### 5.2 Selector accuracy on BF16 Qwen3.8-27B

**Table 3.** BF16 Qwen3.8-27B on A100-SXM4-80GB, 50.10 GiB text-only BF16 weights loaded, `W = 2,048`, INT8 host KV, `C = 8`, BF16 min/max index. Peak GPU memory is `torch.cuda.max_memory_allocated / 1024^3` (GiB), measured in the same runner in dense full-KV reference and BasinKV modes. `Needle blocks hit` counts how many of the 256 `(layer, KV head, needle)` checks (16 full-attention layers x 4 KV heads x 4 needle depths at 12%, 37%, 63%, and 88%) remain resident right after prefill priming `->` after decode.

| Context | Mode | Peak PyTorch-allocated GPU memory (saved) | RULER (5) | Matching prefix | Mean KL | Needle blocks hit |
|---:|---|---:|---:|---:|---:|---:|
| 32K | Runner full-KV reference | 52.98 GiB | 5/5 | n/a | n/a | n/a |
| 32K | BasinKV, `alpha = 0.25` | 51.30 GiB (-1.68 GiB) | 5/5 | 48/48 | 0.0030 | 147 -> 144 / 256 |
| 64K | Runner full-KV reference | 54.83 GiB | 5/5 | n/a | n/a | n/a |
| 64K | BasinKV, `alpha = 0.25` | 51.54 GiB (-3.29 GiB) | 5/5 | 48/48 | 0.0003 | 161 -> 170 / 256 |
| 128K | Runner full-KV reference | 59.02 GiB | 5/5 | n/a | n/a | n/a |
| 128K | BasinKV, unweighted Quest (`alpha = 1`) | 52.56 GiB (-6.46 GiB) | **0/5** | 2/48 | 1.6431 | 52 -> 54 / 256 |
| 128K | **BasinKV, `alpha = 0.25`** | **52.58 GiB (-6.44 GiB)** | **5/5** | **48/48** | **0.0000** | **126 -> 123 / 256** |
| 256K | Runner full-KV reference | 67.50 GiB | 5/5 | n/a | n/a | n/a |
| 256K | **BasinKV, `alpha = 0.25`** | **54.70 GiB (-12.80 GiB)** | **5/5** | **48/48** | **0.0000** | **131 -> 158 / 256** |

At 256K, peak PyTorch-allocated GPU memory above the weights falls from 17.40 GiB to 4.60 GiB. GPU memory for our arm still rises from 51.30 GiB at 32K to 54.70 GiB at 256K, because the GPU-resident block index and temporary prefill/decode buffers grow with context. The 128K ablation isolates the radius weight: with identical memory and transfer settings, unweighted Quest collapses and `alpha = 0.25` reproduces the reference continuation. The same setting held with NF4 weights on a 22 GB L4, where the full-KV reference runs out of memory at 128K and ours fits in 18.92 GiB with 5/5 RULER.

### 5.3 Index compression: SphereIndex quality gates

**Gate 1 (offline mass recall and end-to-end parity, BF16 Qwen3.8-27B at 128K).** Table 4 reports attention-mass and salient-event recall over 16 full-attention layers and 24 decode steps (4,563 events with at least 5% attention mass; oracle top-116 mass 62.41% of eligible mass), and end-to-end generation against the Unmodified reference. Gate 1 scores with the current query; Table 2 uses the previous query.

**Table 4.** Gate 1, selected rows. B/blk is the gate's accounting at `D = 256`, which matches the packed format at this head dimension.

| Index | B/blk | Size vs BF16 min/max | Mass@116 | Salient@116 | Salient@8 | RULER 128K | Parity | Mean KL |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| Min/max BF16 (`alpha = 1.00`) | 1024 | 1.0x | 35.05% | 59.22% | 26.61% | n/a | n/a | n/a |
| Min/max BF16 (`alpha = 0.25`) | 1024 | 1.0x | 53.08% | 92.35% | 61.82% | 5/5 | 48/48 | 0.0000 |
| Min/max INT8 (`alpha = 0.25`) | 520 | 2.0x | 53.06% | 92.33% | 61.63% | 5/5 | 48/48 | 0.0001 |
| Centroid INT8 | 260 | 3.9x | 52.34% | 93.12% | 69.03% | 5/5 | 48/48 | 0.0001 |
| **SphereIndex INT4 WHT (`beta = 0.10`)** | **136** | **7.5x** | 52.45% | **93.32%** | **70.15%** | **5/5** | **48/48** | **0.0000** |
| SphereIndex 3-bit WHT (recall: `beta = 0.00` and `0.05`; parity: `beta = 0.05` and `0.10`) | 104 | 9.8x | 52.09 to 52.23% | 92.88 to 93.12% | 68.81 to 69.34% | 5/5 | 48/48 | 0.0000 |
| SphereIndex 2-bit WHT (`beta = 0.10`) | 72 | 14.2x | 51.68% | 92.92% | 67.94% | 5/5 | 48/48 | 0.0000 |

At `D = 256`, the packed 136-byte INT4 index improved Salient@8 from 61.82% to 70.15%, while Mass@116 changed from 53.08% to 52.45%. Every SphereIndex variant down to 2 bits passed the end-to-end gate.

**Gate 2 (adversarial 7-task RULER, BF16 Qwen3-8B at 32K, A100-80GB PCIe).** One exact prefill per sample is reused across all arms.

**Table 5.** Gate 2. The B/blk column uses the gate's accounting. At `D = 128` the gate counts 76/60/44 B for 4/3/2-bit SphereIndex; the packed format (`bits * D / 8 + 8`) uses 72/56/40 B. At `D = 256` both give 136/104/72 B.

| Arm | B/blk (D=128 / D=256) | multikey_3 | multivalue | multiquery | vt | cwe | fwe | qa_2 | Mean |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| Full-KV Baseline (BF16) | n/a | 100.0% | 75.0% | 100.0% | 60.6% | 33.3% | 66.7% | 100.0% | 76.5% |
| Min/max BF16 (`alpha = 0.25`) | 512 / 1024 | 100.0% | 87.5% | 100.0% | 58.0% | 28.6% | 66.7% | 100.0% | 77.3% |
| Min/max INT8 (`alpha = 0.25`) | 264 / 520 | 100.0% | 87.5% | 100.0% | 58.0% | 23.1% | 66.7% | 100.0% | 76.5% |
| Centroid INT8 | 132 / 260 | 100.0% | 87.5% | 100.0% | 60.8% | 36.8% | 66.7% | 100.0% | 78.8% |
| **SphereIndex INT4 WHT (`beta = 0.10`)** | **76 / 136** | **100.0%** | **87.5%** | **100.0%** | **58.0%** | **43.1%** | **66.7%** | **100.0%** | **79.3%** |
| SphereIndex 3-bit WHT (`beta = 0.10`) | 60 / 104 | 100.0% | 87.5% | 100.0% | 52.3% | 44.5% | 66.7% | 100.0% | 78.7% |
| SphereIndex 2-bit WHT (`beta = 0.10`) | 44 / 72 | 100.0% | 87.5% | 100.0% | 58.0% | 20.0% | 66.7% | 100.0% | 76.0% |

INT4 WHT had the highest mean. The 2-bit variant dropped on `cwe` (20.0%), so INT4 is the production setting. With `n_per_task = 2` these differences are small-sample; the gate's role is to reject variants, not to rank close ones.

**Index scoring cost.** The fused SphereIndex kernel takes 44.0 us per layer for Qwen3.6-35B-A3B at `B = 1 x 256K` (0.44 ms across 10 full layers) and 191.9 us per layer for Qwen3.8-27B at `B = 16 x 64K` (3.07 ms across 16 layers, versus 5.45 ms for the INT8 min/max scorer). This cost grows with the number of indexed blocks.

### 5.4 Multi-user serving in SGLang

All runs in this section use BF16 Qwen3.8-27B on one A100-80GB with CUDA graphs on, live `sglang.Engine` processes, identical prompts, and greedy decoding. Accuracy is 5-item RULER for `B = 1` and one unique passkey per request for `B > 1`.

**Table 6.** Aggregate decode tokens/s at 64K context per request. Our revisions: **v1** = BF16 min/max index, unfused scorer, INT8 host KV; **v2** = v1 + fused scorer, batched boundary kernel, INT8 index; **v3** = v2 + SphereIndex INT4 index, lazy host slabs, ring FP8 draft pool, streaming prefill. All three use **INT8 host KV**; the 4-bit component in v3 is the index. "cap" marks configurations where the stock scheduler could not admit all requests and throughput stopped rising.

| Configuration | B=1 | B=4 (256K) | B=8 (512K) | B=16 (1.024M) | Accuracy |
|---|---:|---:|---:|---:|---|
| Unmodified (BF16 KV, no MTP) | 27.5 | 50.2 | 65.5 | about 65, cap | B=1: 5/5 RULER |
| Unmodified (FP8 KV, no MTP) | 28.1 | 97.0 | 96.6 | about 97, cap | B=1: 5/5 RULER |
| BasinKV v1 | 25.9 | 82.7 | 122.9 | 167.4 | 5/5; 4/4; 8/8; 16/16 |
| + fused scorer | 27.3 | 87.3 | 143.7 | 196.3 | 5/5; 4/4; 8/8; 16/16 |
| BasinKV v2 | 28.2 | 99.2 | 181.9 | 299.2 | 5/5; 4/4; 8/8; 16/16 |
| BasinKV v2 + native MTP (FlashInfer verify) | 46.4 | 170.0 | 323.5 | 359.8 | 5/5; 4/4; 8/8; 16/16 |
| **BasinKV v3 + MTP** | **50.8** | [not run] | [not run] | **581.4** | B=1: **4/5** RULER; B=16: **16/16**, 18.13 GB free |

The `B = 1` v3 + MTP entry comes from a separate single-user sweep (32K to 128K), where the paired stock `B = 1 x 64K` runs measured about 21 (BF16 KV) and 23 (FP8 KV) tokens/s without MTP. In that sweep, v3 + MTP scored 5/5 RULER at 32K and 128K and missed one item (4/5) at 64K; at `B = 16 x 64K` it recovered all 16/16 passkeys, and on H100 FP8 (Table 15) the single-user 64K MTP arm scored 5/5. Figure 1 plots these series: Panel A shows concurrency scaling against the no-MTP stock caps, Panel B shows the stock MTP measurements at lower admitted loads (`38.1` BF16 KV / `64.6` FP8 KV tokens/s), and Panel C shows that single-user v3 + MTP sweep from 32K to 128K.

![Figure 1: SGLang aggregate decode throughput versus concurrency, BF16 Qwen3.8-27B, A100-80GB.](https://zellige.ai/research/basinkv/fig1_sglang_throughput.svg)

Without speculation, v2 matches stock at `B = 1` (28.2 vs 28.1 tokens/s for FP8 KV) and pulls ahead as concurrency grows, because stock cannot admit more 64K requests while our per-request resident KV is bounded. The per-user step-time slope falls to 1.21 ms per added user (35.4 ms at `B = 1`, 53.5 ms at `B = 16`). Halving the transfer cap from `C = 8` to `C = 4` at `B = 16 x 64K` changed v1 throughput by -2.81% (167.4 to 162.7 tokens/s), which suggests transfer is mostly overlapped at this load; this single comparison does not establish complete overlap.

With MTP, v3 reaches 581.4 tokens/s at `B = 16 x 64K` (36.3 tokens/s per request, acceptance length 2.61). Stock with MTP enabled could not admit this load. Its stock MTP reference rates in that sweep, 38.1 (BF16 KV) and 64.6 (FP8 KV) tokens/s, were recorded at lower admitted loads, so the ratios 15.3x and 9.0x are capacity comparisons, not same-load speedups. A separately documented single-user stock MTP run reached 77.3 tokens/s at 64K. Against the best stock result without speculation at 64K in our runs (97.0 tokens/s, FP8 KV, `B = 4`), the ratio is 6.0x (581.4 / 97.0).

**Table 7.** 128K context per request.

| Workload | Unmodified (BF16 KV) | Unmodified (FP8 KV) | BasinKV v1 | BasinKV v2 | BasinKV v3 + MTP | Accuracy |
|---|---:|---:|---:|---:|---:|---|
| `B = 1 x 128K` | 25.8 (TTFT 47.30 s) | 27.1 (TTFT 55.76 s) | 24.3 (TTFT 48.54 s) | 28.0 (TTFT 48.60 s) | 49.6 (TTFT 55.74 s) | 5/5 RULER |
| `B = 4 x 128K` (512K) | 25.1, `B = 1` cap (201.2 s end to end) | 49.7, `B = 2` cap (228.8 s) | 70.6 (197.8 s) | 101.7 | [not run] | 4/4 passkeys |
| `B = 8 x 128K` (1.024M) | about 25.1, cap | about 49.7, cap | 103.0 | 180.5 | [not run] | 8/8 passkeys |

From 64K to 128K, v2 throughput changed by -0.7% at `B = 1` (28.0 vs 28.2), +2.52% at `B = 4` (101.7 vs 99.2), and -0.8% at `B = 8` (180.5 vs 181.9). Measured decode throughput was nearly flat over this range; two of the three comparisons fall within 1%. v1 prefill TTFT was within 3% of stock BF16 KV at 128K (48.54 vs 47.30 s). The v3 + MTP run took 55.74 s, against the same 47.30 s stock figure. Including all four 128K prefills, v1 finished `B = 4 x 128K` sooner end to end than either stock configuration.

**Table 8.** Pure-attention Qwen3-8B on a 22 GB L4, live SGLang, `W = 2,048`, INT8, `C = 4`, unweighted Quest.

| Workload | Full-KV Baseline | BasinKV | Ratio | Accuracy (baseline vs BasinKV) |
|---|---:|---:|---:|---|
| Single 16K | 14.5 tokens/s | 14.3 tokens/s | 0.99x | 5/5 vs 5/5 RULER |
| `B = 2 x 16K` | 14.6 (serialized) | 26.0 | 1.78x | 2/2 vs 2/2 |
| `B = 4 x 16K` | 14.5 (53.40 s end to end) | 42.8 (43.70 s end to end) | 2.95x decode, 1.22x end to end | 4/4 vs 4/4 |

### 5.5 Single-user decode in llama.cpp

**Table 9.** `llama-bench` decode throughput (`tg128`, tokens/s, FlashAttention on), Q4_K_M weights, `W = 2,048`, SphereIndex, bare-metal A100-80GB PCIe (`C = 8` for Qwen3.6-35B-A3B and Qwen3.8-27B). Stock and BasinKV arms are paired within each model.

| Model and configuration | d=0 | d=64K | d=128K | d=256K | Ratio at max depth |
|---|---:|---:|---:|---:|---:|
| Qwen3.6-35B-A3B, Unmodified (F16 KV) | 150.16 | 129.91 | 115.89 | 95.01 | 1.00x |
| Qwen3.6-35B-A3B, BasinKV INT8 (`C = 8`) | 145.73 | 145.86 | 145.19 | 141.44 | 1.49x |
| Qwen3.6-35B-A3B, BasinKV WHT-INT4 (`C = 8`) | 145.75 | 145.84 | 144.58 | 141.12 | 1.49x |
| Qwen3.8-27B, Unmodified (F16 KV) | 51.68 | 45.54 | 40.97 | n/a | 1.00x |
| Qwen3.8-27B, BasinKV INT8 (`C = 8`) | 50.91 | 50.55 | 50.14 | n/a | 1.22x |
| Qwen3.8-27B, BasinKV WHT-INT4 (`C = 8`) | 50.96 | 50.50 | 50.08 | n/a | 1.22x |
| Qwen3-8B, Full-KV Baseline | 150.15 | 79.88 | 54.28 | n/a | 1.00x |
| Qwen3-8B, BasinKV INT8 (`W = 2,048, C = 4`) | 136.58 | 128.00 | 124.21 | n/a | 2.29x |
| Qwen3-8B, BasinKV WHT-INT4 (`W = 2,048, C = 4`) | 136.54 | 128.65 | 124.29 | n/a | 2.29x |

Our decode speed was nearly flat over the measured depths; stock speed falls with depth because every token reads the whole cache. Figure 2 plots Table 9. At zero depth our arms cost 3% (35B-A3B) to 9% (Qwen3-8B, `W = 2,048`) of throughput, the price of the background stream and admission bookkeeping when there is nothing to save. WHT-INT4 matched INT8 speed within about 0.5%. A separate bare-metal A100-SXM4 run with `C = 8` (not part of Table 9) measured Qwen3-8B at 123.23 tokens/s at 128K (`W = 2,048`, 2.18x vs 56.52 stock) and 114.85 tokens/s (`W = 4,096`, 2.03x), and Qwen3.6-35B-A3B at 142.89 tokens/s at 256K versus 98.30 for stock (1.45x).

![Figure 2: llama.cpp decode throughput versus context depth (Table 9, A100-80GB PCIe).](https://zellige.ai/research/basinkv/fig2_llamacpp_scaling.svg)

**Table 10.** Memory. Standalone resident KV plus index (`W = 2,048`, SphereIndex INT4) and whole-process totals in `llama-server` (A100-80GB).

| Model | Context | Unmodified KV | BasinKV resident KV + index | Reduction | Whole process, stock -> BasinKV |
|---|---:|---:|---:|---:|---|
| Qwen3.6-35B-A3B | 256K | 5.00 GiB | 84.7 MiB | 60.4x | 31,526 -> 22,400 MiB (-9,126 MiB = -8.91 GiB) |
| Qwen3.8-27B | 128K | 8.00 GiB | 200.2 MiB | 40.9x | n/a |
| Qwen3-8B | 128K | 18.00 GiB | 465.0 MiB | 39.6x | n/a |
| Qwen3-8B (YaRN, ctx 65,536) | 64K | n/a | n/a | n/a | 15,015 -> 5,741 MiB (`W = 2,048`); 16,849 -> 7,411 MiB (`W = 4,096`) |

**Direct 24 GB GPU verification.** To verify the 24 GB footprint directly rather than extrapolating from A100, we ran `Qwen3.6-35B-A3B-UD-Q4_K_M` (20.60 GiB weights) on a real 24 GB Ada Lovelace card (**NVIDIA L4**, `sm_89`, 23,034 MiB total / 22,614 MiB ECC-usable VRAM, PCIe Gen3 x16, full UVA enabled, `-ngl 99 -fa 1 -b 1024 -ub 1024`; `-b 1024` keeps `llama.cpp`'s prefill compute scratch at 1,010 MiB on this ECC-constrained card). Stock F16 KV hits CUDA OOM starting at 64K (`d = 65,536`, `131,072`, `262,144`, and `llama-server -c 262144` all fail to allocate). BasinKV (`W = 2,048`, `C = 8`, `SphereIndex INT4`, `WHT-INT4` host KV) allocates 84.75 MiB on GPU for 256K KV plus index (1,321 MiB pinned host RAM), keeps CUDA graphs active (255/256 reused), holds decode nearly flat from 69.86 tokens/s at `d = 0` to 67.12 tokens/s at 256K, and passes live `llama-server -c 262144` passkey retrieval at both 64K (`63,834` tokens, 59.50 tok/s, 21,327 MiB peak) and 200K (`203,032` tokens, 60.41 tok/s, 21,885 MiB peak, 1,149 MiB still free; Table 10b, Figure 3). Qwen3-8B at 64K (5,741 to 7,411 MiB on A100) remains an A100-derived footprint estimate for 8 GB cards.

**Table 10b.** Direct 24 GB GPU verification (`NVIDIA L4`, 23,034 MiB total / 22,614 MiB usable, `Qwen3.6-35B-A3B-UD-Q4_K_M`, `-ngl 99 -fa 1 -b 1024 -ub 1024`).

| Depth / test | Stock F16 KV | BasinKV (`SphereIndex` + `WHT-INT4`) | BasinKV GPU KV+Idx / VRAM |
|---|---:|---:|---|
| `llama-bench` `d = 0` | 71.22 tok/s | 69.86 tok/s (98.1%) | 41.2 MiB GPU KV+idx |
| `llama-bench` `d = 64K` | **CUDA OOM** | **69.49 tok/s** | 51.8 MiB GPU KV+idx |
| `llama-bench` `d = 128K` | **CUDA OOM** | **68.93 tok/s** | 62.8 MiB GPU KV+idx |
| `llama-bench` `d = 256K` | **CUDA OOM** | **67.12 tok/s** (96.1% of `d = 0`) | 84.8 MiB GPU KV+idx, 1.29 GiB host |
| `llama-server -c 262144` idle | **CUDA OOM** (5,120 MiB KV) | Loaded cleanly | **21,163 / 23,034 MiB** (1,871 MiB free) |
| Live passkey, 64K (`63,834` tok) | OOM | **PASS** (exact), 59.50 tok/s | **21,327 / 23,034 MiB** peak |
| Live passkey, 200K (`203,032` tok) | OOM | **PASS** (exact), 60.41 tok/s | **21,885 / 23,034 MiB** peak |

![Figure 3: Real 24 GB GPU verification on NVIDIA L4 (Qwen3.6-35B-A3B Q4_K_M): decode speed vs. context depth and live llama-server 256K VRAM.](https://zellige.ai/research/basinkv/fig6_l4_24gb_256k.png)

### 5.6 Quality on long-context tasks (llama.cpp)

**Table 11.** 7-task RULER at 64K and 128K, 28 paired samples per arm (`n_per_task = 2`), A100. Exact two-sided McNemar `p`-values are computed on per-sample exact match.

| Model and arm | 64K mean | 128K mean | Overall mean | 5 retrieval/QA tasks (64K / 128K) | vt (64K / 128K) | cwe (64K / 128K) | McNemar p |
|---|---:|---:|---:|---|---|---|---:|
| Qwen3.6-35B-A3B, Unmodified (F16 KV) | 98.1% | 98.4% | 98.2% | 100.0% / 100.0% | 86.4% / 88.5% | 100.0% / 100.0% | n/a |
| Qwen3.6-35B-A3B, BasinKV INT8 | 97.7% | 91.5% | 94.6% | 100.0% / 100.0% | 95.5% / 95.5% | 88.5% / 45.2% | 0.219 |
| Qwen3.6-35B-A3B, BasinKV WHT-INT4 | 94.8% | 93.9% | 94.3% | 100.0% / 100.0% | 80.0% / 100.0% | 83.3% / 57.1% | 0.625 |
| Qwen3.8-27B, Unmodified (F16 KV) | 100.0% | 99.3% | 99.6% | 100.0% / 100.0% | 100.0% / 100.0% | 100.0% / 95.0% | n/a |
| Qwen3.8-27B, BasinKV INT8 | 97.8% | 93.1% | 95.4% | 100.0% / 100.0% | 94.4% / 100.0% | 90.0% / 51.5% | 0.250 |
| Qwen3.8-27B, BasinKV WHT-INT4 | 97.4% | 92.1% | 94.8% | 100.0% / 100.0% | 94.4% / 100.0% | 87.5% / 45.0% | 0.250 |

Retrieval and QA tasks stay at 100% for both host formats on both models. At 128K, most of the gap to stock is `cwe`, which §6.1 discusses. WHT-INT4 is within 0.3 points (35B-A3B) and 0.6 points (27B) of INT8 on the overall mean.

**Table 12.** Ultra-long context on Qwen3.6-35B-A3B, `ctx = 262,144`, BasinKV with SphereIndex INT4. Whole-process memory shown in the header.

| Benchmark | Unmodified (F16 KV), 31,526 MiB | BasinKV, 22,400 MiB | Delta |
|---|---:|---:|---|
| 3-turn iterative coding, 128K + 192K (18 turns, 6 sessions) | 18/18 | 18/18 | 0.0 pts |
| RepoPatch-LC single-turn coding, 128K / 224K (10 repos) | 4/5, 3/5 = 7/10 | 3/5, 4/5 = 7/10 | tie |
| 6-turn stateful override QA, 128K (12 turns) | 100.0% | 97.9% | -2.1 pts (1 discordant turn, p = 1.0, 0 stale traps) |
| 6 retrieval and multi-hop tasks at 128K (1.56% resident) | 98.0% | 100.0% | +2.0 pts |
| 6 retrieval and multi-hop tasks at 240K (0.83% resident) | 94.5% | 96.2% | +1.7 pts |
| `cwe` uniform aggregation, 128K / 240K | 85% / 50% | 56% / 0% | -29 pts / -50 pts |

On retrieval and multi-hop tasks our arm slightly exceeded stock at 0.83% to 1.56% resident budget. One hypothesis is that removing distractor blocks from the softmax helps on these tasks (the `vt` gains in Tables 11 and 12); we have not tested it directly. On this model, the iterative coding suites at 8K to 32K (27 turns) and at 128K to 192K (18 turns, Table 12) passed 45/45 turns in both arms. The later 16K/32K gate on the same model (Table 13) scored 16/18 for our arms against 17/18 for stock.

**Table 13.** 3-turn iterative coding, `--enable-thinking`, 18 turns from 6 sessions per arm.

| Model and arm | Turn pass | Strict 3-turn session | Stale traps | McNemar p |
|---|---:|---:|---:|---:|
| Qwen3.6-35B-A3B, Unmodified (F16 KV), 16K + 32K | 94.4% (17/18) | 83.3% (5/6) | 0/18 | n/a |
| Qwen3.6-35B-A3B, BasinKV INT8 | 88.9% (16/18) | 66.7% (4/6) | 0/18 | 1.000 |
| Qwen3.6-35B-A3B, BasinKV WHT-INT4 | 88.9% (16/18) | 83.3% (5/6) | 0/18 | 1.000 |
| Qwen3.8-27B, Unmodified (F16 KV), 16K + 32K | 88.9% (16/18) | 66.7% (4/6) | 0/18 | n/a |
| Qwen3.8-27B, BasinKV INT8 | 100.0% (18/18) | 100.0% (6/6) | 0/18 | 0.500 |
| Qwen3.8-27B, BasinKV WHT-INT4 | 94.4% (17/18) | 83.3% (5/6) | 0/18 | 1.000 |
| Qwen3-8B, Full-KV Baseline, 8K + 16K | 77.8% (14/18) | 33.3% (2/6) | 0/18 | n/a |
| Qwen3-8B, BasinKV INT8 (`W = 4,096`) | 72.2% (13/18) | 16.7% (1/6) | 0/18 | 1.000 |
| Qwen3-8B, BasinKV WHT-INT4 (`W = 4,096`) | 88.9% (16/18) | 66.7% (4/6) | 0/18 | 0.625 |

No arm triggered a stale-override trap. Differences in turn pass rate are one or two turns in either direction and not significant. The Qwen3-8B rows also show run-to-run variance: an earlier stock run of the same gate scored 11/18, against 14/18 here. Figure 4 summarizes the RULER and coding results of Tables 11 and 13 alongside host and NVMe KV footprint.

![Figure 4: Accuracy (64K-128K RULER and 3-turn coding) versus host/NVMe KV footprint across Unmodified, INT8, and WHT-INT4.](https://zellige.ai/research/basinkv/fig3_quality_memory_pareto.svg)

### 5.7 Host compression and tiered caching

**Table 14.** Prefix-cache restore versus re-prefill. The measured quantity differs by engine: llama-server reports **prompt-processing time** (`prompt_ms`); SGLang reports **request wall time**.

| Engine and model | Prompt | Mode (format) | On-disk size | Metric | Cold | Restored | Ratio |
|---|---:|---|---:|---|---:|---:|---:|
| llama-server, Qwen3-8B Q4_K_M | 6,333 tok | ram (INT8) | 0 files | prompt processing | 1,818.9 ms | 53.8 ms | 33.8x |
| llama-server, Qwen3-8B Q4_K_M | 6,333 tok | nvme (INT8) | 468.6 MiB | prompt processing | 1,806.1 ms | 54.3 ms | 33.3x |
| llama-server, Qwen3-8B Q4_K_M | 6,333 tok | nvme (WHT-INT4) | 245.3 MiB | prompt processing | 1,770.2 ms | 35.8 ms | 49.4x |
| SGLang, Qwen3-8B BF16 | 28,826 tok | ram (WHT-INT4) | 0 files | request wall | 5,596.1 ms | 622.4 ms | 9.0x |
| SGLang, Qwen3-8B BF16 | 28,826 tok | nvme (INT8) | 2,125.2 MiB | request wall | 10,064.5 ms | 2,434.2 ms | 4.13x |
| SGLang, Qwen3-8B BF16 | 28,826 tok | nvme (WHT-INT4) | 1,112.1 MiB | request wall | 7,116.7 ms | 1,558.8 ms | 4.57x |
| SGLang, after full process restart | 28,826 tok | nvme (WHT-INT4) | 1,112.1 MiB | request wall | n/a | 2,817.7 ms | n/a |

Restored outputs were bit-identical in llama-server and recovered the passkey in every SGLang mode. In SGLang, the restored request reports 28,816 of 28,826 tokens served from cache. Snapshot size roughly halved from INT8 to WHT-INT4 in each engine. For Qwen3.8-27B at 64K, the `OKVP1` file shrank from 2.064 GiB to 1.064 GiB, and a cold NVMe read of the WHT-INT4 file took 805 ms, 22.5x less than the 18.11 s A100 prefill TTFT; this compares a file read with a prefill, not two request latencies. For hybrids the snapshot also carries recurrent state, which is not compressed: a 15,339-token Qwen3.6-35B-A3B session saved to 143.1 MiB (WHT-INT4) or 218.0 MiB (INT8), a whole-snapshot saving of 1.52x. Figure 5 plots these restore times alongside the cold-read and save-overhead measurements.

![Figure 5: Prefix-cache restore over cold prefill. Panel A: SGLang request wall time. Panel B: llama-server prompt-processing time. Panel C: cold NVMe file read versus A100 prefill TTFT. Panel D: llama.cpp save overhead.](https://zellige.ai/research/basinkv/fig4_prefix_cache_speedup.svg)

**Decode-time NVMe tier.** On a LUKS-encrypted laptop NVMe with `O_DIRECT`, random 8 KB block reads for Qwen3.8-27B (`C = 4`, 256 reads per step) took 5.25 ms p50 and 13.96 ms p99. A DRAM tier in front with a 95% hit rate cut end-to-end p99 13.1x (139.68 ms to 10.69 ms).

### 5.8 H100 FP8, Mamba2 hybrids, LongBench v2, vLLM, and sparse prefill

We extend the evaluation to FP8 weights on H100 80GB HBM3, two non-Qwen Mamba2 hybrids, LongBench v2, live vLLM V1 prefix caching, and cold block-sparse prefill.

**Table 15.** FP8 weights in SGLang on one H100 80GB HBM3, official block-FP8 (`128x128` E4M3) checkpoints, `B = 1 / 4 / 8 / 16` concurrent prompts of about 64K tokens (65,000-token targets), aggregate decode tokens/s. Every arm recovered 5/5 single-user 64K RULER items and 16/16 passkeys at `B = 16`.

| Model | Unmodified (BF16 KV) | Unmodified (FP8 KV) | BasinKV WHT-INT4 | BasinKV WHT-INT4 + MTP |
|---|---|---|---|---|
| Qwen3.8-27B-FP8 | 39.7 / 166.1 / 266.8 / 33.9 (cap) | 28.1 / 130.6 / 252.2 / 358.0 | 38.4 / 176.0 / 302.8 / 470.4 | 54.6 / 185.4 / 332.2 / 447.8 (65.1 single-user at 128K) |
| Qwen3.6-35B-A3B-FP8 | 196.5 / 575.4 / 867.4 / 1,141.2 | 84.4 / 324.7 / 612.2 / 1,054.3 | 156.5 / 479.2 / 662.0 / 950.2 | 79.1 / 268.9 / 438.0 / 669.3 (97.8 single-user at 128K) |

**Table 15b.** The same `B = 16` runs with both aggregate decode throughput and batch wall time.

| `B = 16 x 64K`, H100 | Qwen3.8-27B-FP8 decode tok/s | Qwen3.8-27B-FP8 batch wall | Qwen3.6-35B-A3B-FP8 decode tok/s | Qwen3.6-35B-A3B-FP8 batch wall |
|---|---:|---:|---:|---:|
| Unmodified (BF16 KV) | 33.9 | **115.2 s** | **1,141.2** | **24.5 s** |
| Unmodified (FP8 KV) | 358.0 | 264.8 s | 1,054.3 | 87.7 s |
| BasinKV WHT-INT4, no MTP | **470.4** | 130.3 s | 950.2 | 35.8 s |
| BasinKV WHT-INT4 + MTP | 447.8 | 132.2 s | 669.3 | 39.0 s |

On Qwen3.8-27B-FP8 (16 full-attention layers, 4 KV heads, 4.0 GiB of BF16 KV per 64K request), stock BF16 KV exceeds the H100's KV pool at `B = 16` and drops to 33.9 aggregate decode tokens/s (though its shorter prefill-plus-decode schedule still finishes the batch in 115.2 s vs 130.3 s). Against stock FP8 KV, our WHT-INT4 arm wins on both metrics: 1.31x aggregate decode throughput (470.4 vs 358.0 tokens/s) and 2.03x shorter batch wall time (130.3 s vs 264.8 s). Enabling MTP at `B = 16` slightly lowers throughput on H100 FP8 (447.8 tokens/s), where single-user MTP rises to 54.6 tokens/s (65.1 at 128K).

On Qwen3.6-35B-A3B-FP8 (10 full-attention layers, 2 KV heads, 1.25 GiB per request), all 20 GiB of `B = 16 x 64K` BF16 KV fits comfortably inside HBM. Without memory pressure, stock decodes 20.1% faster than our offloaded arm (1,141.2 vs 950.2 tokens/s, batch wall 24.5 s vs 35.8 s), while our arm keeps resident KV near 2 GiB (with single-user RULER MTP staying flat at 96.3 / 96.7 / 97.8 tokens/s across 32K / 64K / 128K, versus 79.1 tokens/s on the Table 15 `B = 1` passkey run). Together, the two models bracket the two operating regimes: KV exceeding HBM versus KV fitting in HBM.

Under SGLang's hybrid SSM pool invariant checks on Qwen3.8-27B-FP8, `oasiskv_int8` passed every idle `StateCheck` gate across `B = 1 / 4 / 8 / 16 x 64K` (39.4 tokens/s single-user with 5/5 RULER, and 123.7 s batch wall with 16/16 passkeys at `B = 16`). Figure 6 plots both H100 FP8 models side by side.

![Figure 6: H100 FP8 aggregate decode throughput and B = 16 batch wall times for Qwen3.8-27B-FP8 and Qwen3.6-35B-A3B-FP8.](https://zellige.ai/research/basinkv/fig1_h100_fp8_roofline.png)

**Table 16.** Two non-Qwen Mamba2 + full-attention hybrids (`llama.cpp` `sm_90`, H100-80GB, `W = 2,048`, `C = 8`, SphereIndex): IBM Granite-4.0-H-Small (32B-A9B MoE, 36 Mamba2 + 4 full-attention layers, no RoPE in attention, `D = 128`) and NVIDIA Nemotron-Nano-9B-v2 (8.9B dense, 52 Mamba2/MLP + 4 full-attention layers, `D = 128`).

| Model (Q4_K_M, H100) | Metric | Unmodified (F16 KV) | BasinKV INT8 | BasinKV WHT-INT4 |
|---|---|---:|---:|---:|
| IBM Granite-4.0-H-Small | Decode `d=0 -> 128K` | 151.2 -> 134.5 t/s | 158.0 -> 152.5 t/s (1.13x) | 160.4 -> 151.0 t/s (1.12x) |
| IBM Granite-4.0-H-Small | 7-task RULER, overall mean (64K + 128K, `n = 28`) | 54.9% | 53.3% (stock-only / ours-only EM: 1/0, p = 1.000) | 56.6% (2/1, p = 1.000) |
| IBM Granite-4.0-H-Small | 7-task RULER, 128K mean | 48.2% | 44.6% | 45.2% |
| NVIDIA Nemotron-Nano-9B-v2 | Decode `d=0 -> 128K` | 238.1 -> 192.7 t/s | 234.5 -> 227.9 t/s (1.18x) | 234.5 -> 228.2 t/s (1.18x) |

Both models showed nearly flat measured decode throughput from 0 to 128K in our arms, with no measurable speed cost from WHT-INT4 (Figure 7, Panel C). Granite gives quality evidence on one pure-NoPE Mamba2 hybrid: the overall mean (graded, with partial credit on some tasks) was 56.6% for WHT-INT4 against 54.9% for stock, but at 128K alone WHT-INT4 scored 45.2% against 48.2%. Both arms scored 100% on `niah_single_3` and `qa_2`. Nemotron supplies throughput evidence only.

![Figure 7: Single-user llama.cpp decode throughput vs. context depth across three separately paired runs: A100 Qwen3.6-35B-A3B, A100 non-UVA fallback vs. UVA control, and H100 Mamba2 hybrids.](https://zellige.ai/research/basinkv/fig2_context_decode_flat.png)

**Table 17.** LongBench v2 [Bai et al. 2025] (`n = 80` proportional stratified subset of 503 items, `seed = 42`, official zero-shot template, middle truncation to 127,000 tokens, greedy, thinking off, `max_tokens = 1,024`, 0 transport errors), Qwen3.6-35B-A3B Q4_K_M on llama-server (`W = 2,048`, `C = 8`, SphereIndex). Exact McNemar, Wilson 95% intervals, paired bootstrap 95% interval on the accuracy delta.

| Arm | Overall [95% Wilson] | Short (`n=29`) | Medium (`n=34`) | Long (`n=17`) | Easy (`n=31`) | Hard (`n=49`) | Delta vs Unmodified [95% CI] | McNemar p |
|---|---|---:|---:|---:|---:|---:|---|---:|
| Unmodified (F16 KV) | 42.5% (34/80) [32.3%, 53.4%] | 48.3% | 41.2% | 35.3% (6/17) | 54.8% | 34.7% | n/a | n/a |
| BasinKV INT8 | 43.8% (35/80) [33.4%, 54.7%] | 51.7% | 41.2% | 35.3% (6/17) | 54.8% | 36.7% | +1.2 pts [-3.8, +6.2] (stock-only / ours-only: 2/3) | 1.000 |
| BasinKV WHT-INT4 | 45.0% (36/80) [34.6%, 55.9%] | 48.3% | 47.1% | 35.3% (6/17) | 54.8% | 38.8% | +2.5 pts [-3.8, +8.8] (2/4) | 0.688 |

On the 17 Long items, all three arms answered the same 6/17 correctly with zero correctness discordances. At `n = 80`, the paired 95% interval (-3.8 to +8.8 points for WHT-INT4) rules out a large regression while crossing our -2-point non-inferiority margin; evaluating all 503 items would narrow that interval. Figure 8 shows LongBench v2 alongside the paired RULER checks on Granite and cold sparse prefill.

![Figure 8: Paired quality checks: LongBench v2 (n = 80) with 95% Wilson intervals and 64K + 128K RULER on Granite-4.0-H-Small and Qwen3.8-27B-FP8 cold block-sparse prefill (quality config).](https://zellige.ai/research/basinkv/fig3_paired_quality.png)

**Table 18.** Live `vllm serve` Mode 1 (`OasisKVConnector`, zero-fork plugin on `vllm 0.19.1`, `Qwen/Qwen3-8B`, 6,753 actual prompt tokens, A100-80GB PCIe). Mode 2 (sparse-decode attention backend) has passed only unit and mock tests and needs three upstream hooks.

| Scenario (`Qwen/Qwen3-8B`, 6,753 tok) | Quant | On-disk size | Cold wall | Second request wall | Ratio | Notes |
|---|---|---:|---:|---:|---:|---|
| `mode1_off` | `wht_int4` | 0 MiB | 987.0 ms | 961.4 ms (repeated request, no cache) | 1.03x | Baseline |
| `mode1_ram_wht_int4` | `wht_int4` | 0 MiB | 1,883.0 ms | 456.5 ms | 4.12x vs own cold save | about 2.1x vs repeated `off` request |
| `mode1_nvme_int8` | `int8` | 489.6 MiB | 2,316.6 ms | 953.8 ms | 2.43x | 1 `.okvp1` file |
| `mode1_nvme_wht_int4` | `wht_int4` | 252.2 MiB | 1,719.7 ms | 702.4 ms | 2.45x | 1.94x smaller, 1.36x faster hit vs INT8 |
| `mode1_nvme_cold_restart` | `wht_int4` | 252.2 MiB | 1,719.7 ms | 728.4 ms | 2.36x | After full process restart |
| `mode1_mixed_spill` (0.35 GiB RAM) | `wht_int4` | 504.5 MiB | 1,316.8 ms | 1,150.2 ms | 1.14x | Spilled A1 to NVMe, restored on A2 |

In cache-enabled modes the cold request includes the snapshot save, which is why cold wall exceeds the `off` arm (Figure 9).

![Figure 9: Live vLLM V1 Mode 1 prefix-cache request wall times and OKVP1 snapshot footprint on A100.](https://zellige.ai/research/basinkv/fig5_vllm_prefix_cache.png)

**Table 19.** Cold block-sparse prefill. Parts A and B are synthetic-shape kernel microbenchmarks on A100. Part C is a live quality gate and Part D a live timing run on H100. **Parts C and D used different sparse-prefill configurations**; the quality result of Part C does not transfer to the configuration timed in Part D.

*Part A (microbenchmark): `__dp4a` INT8-query by INT4-key scorer (`B = 16 x 64K`, `H_q = 24`, `H_kv = 4`, `D = 256`, A100 80GB PCIe).*

| Query tokens | FP32 scorer | `__dp4a` scorer | Speedup | Effective BW | Cosine | Top-K overlap (`M/8`) |
|---:|---:|---:|---:|---:|---:|---:|
| `q_toks = 1` (decode) | 192.4 us/layer | 119.3 us/layer | 1.61x | 307.6 GB/s | 0.999993 | 99.47% |
| `q_toks = 4` (MTP verify) | 642.6 us/layer | 371.2 us/layer | 1.73x | 98.9 GB/s | 0.999996 | 99.38% |

*Part B (microbenchmark): prefix-causal growing-union block-sparse prefill on a random synthetic index (`chunk = 8,192`, `q_block = 128`, `sink = 64`, `local = 8,192`, `topk = 8,192`, `union_topk_tokens = 16,384`, total prior-token cap = `24,640` tokens, A100). "Last-chunk SDPA" times last-chunk attention only. The H2D column is a calculated INT8 traffic upper bound for sparse prefill, not a measured transfer.*

| Context | Last-chunk PCIe cut | Calculated whole-prefill INT8 H2D/layer (Dense -> Sparse bound) | Last-chunk select | Last-chunk SDPA (Dense -> Union) | Last-chunk SDPA ratio |
|---:|---:|---|---:|---|---:|
| 64K | -57.0% | 0.48 -> <= 0.31 GB (-35.6%) | 11.71 ms | 68.78 -> 32.39 ms | 2.12x |
| 128K | -79.9% | 2.04 -> <= 0.72 GB (-64.9%) | 13.60 ms | 141.46 -> 32.53 ms | 4.35x |
| 256K | -90.3% | 8.45 -> <= 1.54 GB (-81.8%) | 22.82 ms | 288.38 -> 32.01 ms | 9.01x |
| 512K | -95.2% | 34.35 -> <= 3.18 GB (-90.8%) | 19.98 ms | 582.74 -> 32.49 ms | 17.94x |
| 1024K (synthetic) | -97.6% | 138.50 -> <= 6.46 GB (-95.3%) | 24.40 ms | 1179.33 -> 32.59 ms | 36.19x |

*Part C (live quality gate): `Qwen/Qwen3.8-27B-FP8`, H100 80GB, `W = 2,048`, WHT-INT4, paired 64K + 128K 7-task RULER, `n = 28`. **Quality configuration:** `dense_first_n_layers = 2`, `sink = 64`, `local = 8,192`, `topk = 8,192`, `union_topk_tokens = 16,384` (total prior-token cap `24,640`), `q_block = 128`, `__dp4a` scoring, PyTorch FP32 reference sparse attention.*

| Prefill mode | 64K mean | 128K mean | Overall mean | 6 retrieval and multi-hop tasks | `cwe` | Stock-only / sparse-only EM | McNemar p |
|---|---:|---:|---:|---:|---:|---:|---:|
| Dense streaming prefill | 98.5% | 92.6% | 95.5% | 100.0% (24/24) | 68.7% | n/a | n/a |
| Block-sparse prefill (quality configuration) | 96.2% | 91.6% | 93.9% (-1.6 pts) | 100.0% (24/24) | 57.5% | 0 / 0 | 1.000 |

Both arms passed all 24 retrieval and multi-hop items. The seven-task mean fell from 95.5% to 93.9%, and `cwe` fell from 68.7% to 57.5%.

*Part D (live timing): `Qwen/Qwen3.8-27B-FP8`, H100 80GB, `W = 2,048`, WHT-INT4, `chunk = 8,192`, fused Triton block-sparse attention with a one-launch UVA WHT-INT4 block gather. **Timing configuration:** `dense_first_n_layers = 1`, `sink = 256`, `local = 2,048`, `topk = 4,096`, `union_topk_tokens = 8,192` (total prior-token cap `10,496`), `q_block = 128`. Each row is two paired cold trials after warmup; each trial checks a 5-field RULER probe, so each arm has 10 field checks per length and 40 over the four lengths.*

| Context (actual tok) | Dense streaming TTFT (mean / steady) | Fused sparse TTFT (mean / steady) | TTFT ratio (mean / steady) | Dense vs sparse decode | RULER fields (both arms) |
|---|---:|---:|---:|---:|---:|
| 64K (61,541) | 7.28 s / 7.07 s | 8.32 s / 7.53 s | 0.88x / 0.94x | 38.31 vs 38.30 t/s | 10/10 vs 10/10 |
| 128K (123,091) | 17.59 s / 17.20 s | 16.81 s / 16.16 s | 1.05x / 1.06x | 38.31 vs 38.27 t/s | 10/10 vs 10/10 |
| 192K (184,616) | 30.04 s / 29.72 s | 25.21 s / 24.81 s | 1.19x / 1.20x | 38.32 vs 38.29 t/s | 10/10 vs 10/10 |
| 250K (240,391) | 43.88 s / 43.51 s | 33.38 s / 33.03 s | 1.31x / 1.32x | 38.23 vs 38.13 t/s | 10/10 vs 10/10 |

The fused path crosses over dense streaming by 123,091 tokens and saves 10.50 s in mean TTFT at 240,391 tokens, with identical 40/40 RULER field checks across all four lengths. Over this range, steady-state dense TTFT increments grow quadratically (+10.1, +12.5, and +13.8 s per ~61K tokens) while fused sparse increments remain near-constant (+8.63, +8.65, and +8.22 s), though the single retained dense layer will reintroduce a quadratic term at longer contexts. In a standalone microbenchmark on the Qwen3.8-27B tile shape (`e = 8,192`, `H_q = 24`, `H_kv = 4`, `D = 256`, BF16, `T_tile = 4,096`), the fused Triton kernel ran in 2.32 ms at 15% block density, 16.37x faster than a PyTorch FP32 reference (`max_out_diff = 0.00017`; the earlier live PyTorch reference run under Part C's larger budget took 68.8 s at 128K). Figure 10 plots the live cold-prefill TTFT curve alongside the standalone tile microbenchmark.

![Figure 10: Live H100 cold block-sparse prefill mean TTFT (timing config) and standalone Triton tile microbenchmark vs. PyTorch FP32 reference.](https://zellige.ai/research/basinkv/fig4_cold_sparse_prefill_ttft.png)

---

## 6. Limits and Roofline Analysis

### 6.1 Uniform aggregation at a 0.83% resident budget

On Qwen3.6-35B-A3B at 245,760 tokens, the `cwe` score fell from 50% to 0% with a 2,048-token resident window (Table 12). A uniform-sampling calculation illustrates why a small window can miss repeated evidence.

`cwe` asks for the ten most common words in a long numbered list. In the generator, each of 10 common words appears 30 times and each uncommon word 3 times; at 240K tokens there are about 15,360 blocks and roughly 16,500 to 20,200 distinct uncommon words. The question names no key, so attention has no single target, and the 300 common-word occurrences scatter over about 297 distinct blocks.

If the resident window were an approximately uniform, independently sampled 0.83% of the context (`W = 2,048` of 245,760 tokens), each common word would have an expected `lambda = 30 x 0.00833 = 0.25` occurrences in it, and `e^-0.25 = 77.9%` of common words would not appear even once. Our selector is not a uniform sampler: it is data-dependent, can use prefill information, and changes its window across decode steps, and identifying the ten frequent words does not require holding all of their occurrences at once. The calculation is an illustration of the failure we measured, not a lower bound for sparse decoders.

The other data points are consistent with budget mattering. At 128K (`W/N = 1.56%`) our arm dropped from 85% to 56% on the same model. At 32K on a different model (Qwen3-8B, Gate 2, `W/N = 6.25%`), SphereIndex scored 43.1% on `cwe` against 33.3% for the Full-KV Baseline. Stock itself degraded from 85% to 50% between 128K and 240K. Distractor pruning (for the 32K gain) and representational limits of uniform readout at `D = 256` (for the stock decline) are hypotheses we have not tested.

What may be fixable is narrower. If prefill attention at the question already concentrates on frequent tokens, seeding the sparse slots from exact final-chunk prefill attention (rather than block summaries) could recover part of the gap at no VRAM cost; a recall measurement would decide whether this is worth building. A slower fallback would stream the full host KV through online softmax on diffuse steps only, with bounded resident KV but `O(N)` time on those steps. We do not use token-ID frequency sketches, which would pass synthetic `cwe` while failing semantic aggregation.

### 6.2 Pure-attention models compound sparse error

The same budget that preserved quality on hybrids cost accuracy on Qwen3-8B (36 full-attention layers, 288 KV heads). At `W = 2,048`, 16K RULER fell from 92.4% to 80.8% and 3-turn coding from 11/18 to 9/18 (McNemar p = 0.50), while Qwen3.6-35B-A3B at the same settings matched its baseline on both. We attribute the gap to four effects; the first is an illustration under assumed parameters.

1. **Layer compounding.** Assume a per-layer miss probability `p = 0.005` on a verbatim lookup. All layers then hit with probability `(1-p)^10 = 95.1%` for 10 sparse layers but `(1-p)^36 = 83.5%` for 36, a 3.38x higher end-to-end miss rate (16.5% / 4.9%). Assume further a per-layer amplification `rho = 1.03` of residual-stream perturbations; accumulated error then scales as `(rho^L - 1)/(rho - 1)`: 11.5 for `L = 10` and 63.3 for `L = 36`, 5.5x larger. Both `p` and `rho` are assumptions, not measurements. Hybrids also place exact recurrent layers between sparse layers.
2. **Head heterogeneity.** A uniform window gives every KV head the same budget, although in pure-attention models many heads attend locally (DuoAttention [Xiao et al. 2025] and RazorAttention [Tang et al. 2025] distinguish retrieval from streaming heads). On Qwen3-8B, the two-group split of §3.7 would give retrieval heads a 6,144 to 7,168-token window at 0.97x to 0.98x of the uniform window's VRAM.
3. **Previous-query lag.** At abrupt mode switches, for example from reasoning to the first line of a SEARCH block in a different file, `q_t` differs sharply from `q_{t-1}`, so the block it needs arrives one step late, in all 36 layers at once. OasisKV's draft-token lookahead [Xiao et al. 2026] targets exactly this case. A drift-gated synchronous fetch of 2 blocks when `cos(q_t, q_{t-1})` falls below a threshold would cost an estimated 0.10 to 0.15 ms per token amortized; we have not built it.
4. **Budget.** Doubling to `W = 4,096` restored coding to 11/18, matching the baseline with 2 vs 2 discordant turns (p = 1.0), and on 7-task RULER at 16K and 32K produced zero discordant samples out of 28. On the separate SXM run, decode at 128K was 2.03x stock instead of 2.18x, and whole-process memory at 64K was 7,411 instead of 5,741 MiB, still 2.27x below the 16,849 MiB baseline.

### 6.3 After KV, decode is bounded by weights and framework overhead

For `B = 1` llama.cpp decode of Qwen3.6-35B-A3B Q4_K_M, each token reads about 1.93 GB (1.85 GB of active weights plus recurrent state and the 40 MiB resident window), an A100 bandwidth floor of 1.22 ms. In our A100 PCIe run, stock measured 6.95 ms and our arm 6.99 ms per token at zero depth. Dividing the floor by the measured stock time gives an inferred HBM utilization of 17.5%. We attribute most of the 5.7 ms gap to kernel launch and small-GEMV overhead across 40 layers of recurrent updates and small MoE experts, but these timings do not separate launch cost from other overheads.

For `B = 16 x 64K` SGLang decode of BF16 Qwen3.8-27B on A100-SXM4, reading about 51 GB of weights takes 29.3 ms per step at the measured 1,740 GB/s (32.2 ms at the A100 PCIe's 1,584 GB/s). For a weight-only GEMM with BF16 weights, counting a multiply and an add as two FLOPs, the compute-bandwidth ridge is about 161 tokens at the A100's 312 TFLOP/s and 1.935 TB/s (158 tokens using the measured 251 TFLOP/s and 1,584 GB/s pair). Every decode and verify step we ran has 16 to 64 tokens in flight, roughly 2.5x to 10x below the ridge, so these steps are memory bound. The measured no-MTP step is 53.5 ms; we attribute most of the remainder to recurrent-state traffic, resident attention, and index scanning. An analytical step-time estimate puts the target model's forward pass at about 85% of step time once draft-KV and index costs are removed; that figure is an estimate, not a measurement. The levers that remain sit outside KV management: FP8 or FP4 weights, wider speculative trees that raise tokens per weight read, and higher concurrency. Table 15 measured the first on H100.

### 6.4 Environment and capacity limits

- **Non-UVA hosts.** In a rented container with a 256 MB cap on device-mapped pinned memory, llama.cpp fell back to synchronous staging and lost CUDA graphs: Qwen3.6-35B-A3B at 256K decoded at 81.16 tokens/s, against 142.89 on a different, bare-metal SXM machine. An asynchronous double-buffered pinned-staging fallback (`bg_copy_stream_`, tested with `OASISKV_DISABLE_UVA=1` on A100) reached 101.38, 101.20, and 97.18 tokens/s at 64K, 128K, and 256K. Its paired UVA control on the same machine measured 143.21, 141.72, and 137.73 tokens/s at the same depths.
- **Pinned host RAM.** At high concurrency, host memory binds before GPU memory. On a 22 GB L4, `B = 4 x 128K` hit a roughly 16 GB pinned-allocation ceiling. On an A100 host, PyTorch's caching allocator rounded 65.0 MiB slab groups up to 128 MiB, nearly doubling real pinned usage until slab groups were refitted to power-of-two buckets. WHT-INT4 halves the per-request host cost.
- **Cold prefill.** Dense prefill remains quadratic. On A100 BF16, Qwen3.8-27B took 48.6 s at 128K (measured). A roofline projection gives 129 s at 256K and 22.1 minutes at 1M, with attention at 81% of prefill time at 1M; these are projections. Prefix caching (Table 14) removes repeated prefill. Fused block-sparse prefill (Table 19 Part D) reduced cold mean TTFT on H100 from 43.88 to 33.38 s at 240,391 tokens, first winning at the measured 123K point.

### 6.5 Block-boundary induction splits and 1-hop successor co-fetch

Running BasinKV live in an agent harness (28-tool OpenCode sessions on H100 `Qwen/Qwen3.8-27B-FP8`, `W = 2,048`, `B = 16`, `SphereIndex INT4`, `WHT-INT4`, `NEXTN` MTP) exposed a subtle failure mode of disjoint block-sparse KV paging that standard needle benchmarks do not trigger. Whenever a multi-token syntactic cue straddles a 16-token block boundary (prefix at offsets `14..15` of block `b`, continuation at offsets `0..1` of block `b + 1`) and is evicted during reasoning, independent per-block scoring fetches block `b` without `b + 1`. Induction heads then collapse softmax mass onto the last token of block `b`, causing a +30 to +40 nat logit inversion (for example, predicting `'<'` at `logprob = 0.0` over `'function'` at `-6.7` to `-14.8` and emitting `<<function>`, `<<parameter>`, or `</function>`).

We confirmed the mechanism with a controlled double dissociation on the live 27,783-token agent prompt (where Qwen3.8's chat template placed `<tool_call>\n` at token `7966`, block `497` offsets `14..15`, and `<function=` at block `498` offsets `0..1`):
- **Prefill vs. decode:** Pure prefill of the exact failed 28,024-token sequence scored `'function'` at `0.00` nats (`'<' < -31` nats), isolating the bug to sparse decode.
- **Boundary alignment controls (`temperature = 0.6`):** The unpadded prompt (`off = 14`) had 30% to 60% inversions/spikes across five runs, and shifting `<tool_call>` to `off = 15` (+1 pad token) failed 2/5 times. Inserting 5 benign pad tokens at position 50 to align `<tool_call>\n<function=` inside one block (`off = 3`) dropped failures to **0/8** (`0/43` across all aligned runs, `+21` to `+30` nat margins); conversely, inserting 11 pad tokens into a clean aligned prompt (`0/43` failures) to push `<tool_call>` onto `off = 14` immediately induced **3/8** full `'<'` inversions (`<<function>`, `<<parameter>`, `<<function=shell>`).

**Fix.** Right before top-k selection, we apply a zero-VRAM, CUDA-graph-safe **1-hop successor co-fetch** across all finite eligible blocks (`score'[b + 1] = max(score[b + 1], nextafter(score[b], -inf))`), read from immutable scores so propagation never smears past one hop and never promotes sink, local, or `-inf`/`NaN` blocks. Deployed with `C = 16` across SGLang and `llama.cpp`, the fix eliminated the failure across all 30 live boundary-straddling trials (**0/10** inversions/spikes on exact OpenCode `off = 14`, **0/10** on shifted `off = 14`, **0/10** on `off = 15`, and **0/9** on `off = 3`, restoring `+20.8` to `+28.1` nat margins on every completed `<tool_call>`).

---

## 7. Related Work

**OasisKV.** Xiao, Cho, and colleagues introduced OasisKV [Xiao et al. 2026]: a bounded per-head HBM working set of sparse KV blocks, tiered placement across GPU, host, and remote memory, asynchronous lookahead prefetching with a fused UVA gather, and a radius-weighted Quest score (their Eq. 3, summed over the query heads that share a KV head) whose Appendix B ablates the radius weight, including `alpha = 0.25`, and selects `alpha = 0.5` for Qwen3-8B. They predict the next step's blocks by propagating a speculative draft token and compare against a previous-query baseline. They implemented the design in vLLM and evaluated it on LongBench v2, AIME24/25, and GPQA-Diamond. Our work inherits that design. It differs in using a previous-query predictor, max rather than sum aggregation over grouped query heads, and a dimension-dependent radius weight, and it adds the compressed index, compressed host format, engine integrations, prefix caches, and evaluations listed in §1.

**Hierarchical sparse KV in serving engines.** HiSparse [Xie et al. 2026] keeps each request's full KV in host memory behind a fixed-size GPU cache with a fused kernel for hit detection, LRU replacement, and fetches; it evaluates DSA, NSA, and Quest and is merged into upstream SGLang (PR #20343). Our SGLang integration follows the allocator and scheduler wiring of upstream HiSparse on commit `a3f0bff5` and adds a separate OasisKV pool, coordinator, and backend (mutually exclusive with `--enable-hisparse`) for GQA/MHA full-attention layers.

**KV eviction and compression.** H2O [Zhang et al. 2023] and StreamingLLM [Xiao et al. 2024] keep heavy-hitter or sink-plus-recent tokens and discard the rest; SnapKV [Li et al. 2024b] selects tokens from an observation window at prefill end. Permanent eviction cannot recover a token that becomes relevant later, which multi-turn coding with spec overrides exercises. KIVI [Liu et al. 2024] quantizes KV to 2 bits with per-channel keys. Rotation before quantization appears in QuaRot [Ashkboos et al. 2024] and in vector-quantization work such as TurboQuant [Zandieh et al. 2026]. WHT-INT4 applies a randomized Hadamard rotation per vector to the host tier only; the resident window stays in BF16 or F16.

**Query-aware selection and offloading.** Quest [Tang et al. 2024] scores pages with min/max key bounds. InfiniGen [Lee et al. 2024] and ShadowKV [Sun et al. 2025] offload KV to the CPU and prefetch with speculation or low-rank keys. DuoAttention [Xiao et al. 2025] and RazorAttention [Tang et al. 2025] classify heads as retrieval or streaming, which motivates our two-group extension. MInference [Jiang et al. 2024] and native sparse attention (NSA) [Yuan et al. 2025] sparsify prefill; Table 19 evaluates a training-free prefill path driven by the decode index.

**Serving systems and kernels.** PagedAttention (vLLM) [Kwon et al. 2023], SGLang [Zheng et al. 2024], FlashInfer [Ye et al. 2025], FlashAttention [Dao et al. 2022], and FlashAttention-3 [Shah et al. 2024] provide the paged kernels and schedulers our code builds on; the H100 stock baselines in Table 15 use FlashAttention-3. Speculative decoding with draft heads (EAGLE [Li et al. 2024a], and MTP as in DeepSeek-V3 [DeepSeek-AI 2024]) is complementary; §5.4 shows it compounds with bounded resident KV because freed memory admits more concurrent verification.

**Hybrid architectures.** Gated DeltaNet [Yang et al. 2025] and Mamba-2 [Dao and Gu 2024] layers remove KV growth in most layers. We target the full-attention layers that remain, where high-dimensional partial-RoPE and pure-NoPE heads dominate per-request memory at long context.

**Benchmarks.** RULER [Hsieh et al. 2024] provides controllable retrieval and aggregation probes; LongBench v2 [Bai et al. 2025] provides realistic long-document multiple-choice questions with length and difficulty labels.

---

## 8. Conclusion

BasinKV extends the OasisKV bounded-VRAM architecture with a dimension-dependent radius weight (`alpha = 0.25`, raising per-step Top-8 recall by +13.0 to +13.5 points over `alpha = 0.50` on native BF16 `D = 256` partial-RoPE heads), a 136-byte rotated block index (`SphereIndex`), a rotated 4-bit host tier (`WHT-INT4`), persistent prefix caches (`OKVP1` and `OKVS1`), and native engine plumbing across SGLang, llama.cpp, and vLLM V1 without custom attention kernels or disabling CUDA graphs. On BF16 Qwen3.8-27B up to 256K, BasinKV reproduced the reference greedy continuation at every tested length while saving 12.80 GiB of allocated GPU memory. In llama.cpp, decode stayed nearly flat across depth (`1.22x` to `2.29x` stock on A100, and 67.12 tok/s at 256K on a real 24 GB NVIDIA L4 in 21,163 MiB idle / 21,885 MiB peak VRAM where stock OOMs from 64K onward). In SGLang, BasinKV served about one million concurrent prompt tokens on one A100 (581.4 tokens/s with MTP) and on one H100 with FP8 weights (470.4 tokens/s without MTP, beating stock FP8 KV on both throughput and batch wall time).

The measurements also establish clear operating boundaries. Offloading pays off when full KV exceeds HBM or dominates decode bandwidth; when full KV fits easily in HBM (as on H100 FP8 Qwen3.6-35B-A3B), stock serving decodes faster. Fused block-sparse prefill cuts cold TTFT by 10.50 s at 240K tokens after crossing over at 123K. Uniform global aggregation tasks (`cwe`) degrade at sub-1% resident budgets, and deep pure-attention models require larger or head-aware budgets than hybrids. Once resident KV is bounded, decode throughput is governed by model weights, speculative acceptance, and framework launch overhead rather than context length.

### Open-source artifacts

| Component | Scope | Status |
|---|---|---|
| **SGLang integration** | Sparse decode, `SphereIndex` INT4, `WHT-INT4` host KV, lazy host slabs, static draft-KV ring for hybrid `NEXTN` MTP, streaming prefill, fused Triton block-sparse prefill, `OKVP1` prefix cache | Live-validated on A100 and H100 |
| **llama.cpp integration** | Dependency-free C++17/CUDA core, `SphereIndex` INT4, `WHT-INT4` host KV, UVA and async non-UVA staging, `OKVS1` prefix/session cache | Live-validated on A100 and H100 (Qwen3.x, Granite, Nemotron) |
| **vLLM V1 plugin** | Zero-fork `OasisKVConnector` (`OKVP1` RAM/NVMe/mixed prefix cache, TP/PP sharded); sparse-decode `AttentionBackend` | Mode 1 live-validated on `vllm 0.19.1`; Mode 2 unit/mock tested |
| **Kernels, benchmarks, and tuning guide** | CUDA/Triton kernels, reference parity tests, RULER/coding/LongBench v2 harnesses, and tuning recipes | Open source |

---

## Appendix A. 22 GB L4 evaluation on Qwen3-8B

**Table A1.** Pure-attention Qwen3-8B on an NVIDIA L4 (22 GB), both modes inside full-model CUDA graphs, 5-item RULER.

| Context | Mode | Decode | vs Full-KV | Peak VRAM | RULER | KL |
|---|---|---:|---:|---:|---:|---:|
| 32K | Full-KV Baseline | 8.1 tok/s | 1.00x | 20.20 GB | 5/5 | ref |
| 32K | BasinKV BF16 host, `C = 4` | 14.1 tok/s | 1.74x | 16.42 GB | 4/5 | 0.0625 |
| 32K | BasinKV INT8 host, `C = 8` | 14.0 tok/s | 1.73x | 16.58 GB | 5/5 | 0.0015 |
| 64K | Full-KV Baseline | OOM | n/a | OOM | n/a | n/a |
| 64K | BasinKV INT8, `C = 8` | 13.7 tok/s | fits | 17.59 GB | 4/5 | n/a |
| 128K | BasinKV INT8, `W = 2,048` | 13.2 tok/s | fits | 19.55 GB | 2/5 | n/a |
| 128K | BasinKV INT8, `W = 4,096` | 11.4 tok/s | fits | 19.87 GB | 3/5 | n/a |

At equal PCIe traffic and latency, INT8 host KV doubled the blocks admitted per step relative to BF16, which recovered the 3-hop item and cut KL 41x at 32K. The 128K rows used YaRN 4x scaling and unweighted Quest, at resident budgets of 1.5625% (`W = 2,048`) and 3.125% (`W = 4,096`), and show the pure-attention sensitivity discussed in §6.2.

## Appendix B. Repository layout and reproducibility

- **Core and integrations:** shared Python/CUDA core in `src/oasiskv/`; engine integrations in `integrations/sglang/`, `integrations/llamacpp/`, and `integrations/vllm/`; practical recipes in `docs/TINKERING_AND_TUNING.md`.
- **Raw measurements and run commands:** recorded in `docs/summaries/benchmark-track-a-oasiskv.md`.
- **Selector and index gates:** `benchmarks/oasiskv/diag_27b_scorer.py` (pass `--model` explicitly to override the 4-bit default), `bench_sphere_gate.py`, and `bench_sphere_gate2.py`.
- **Serving and long-context suites:** `benchmarks/oasiskv/bench_qwen38_27b.py`, `bench_sglang_gpu.py`, `bench_sparse_prefill.py --measure-attn`, and `benchmarks/oasiskv/paper/` (`ruler_suite.py`, `coding_multiturn_gate.py`, `repopatch_lc.py`, `multiturn_gate.py`, `systems_bench.py`, `longbench_v2.py`).

## References

- S. Ashkboos et al. QuaRot: Outlier-free 4-bit inference in rotated LLMs. NeurIPS, 2024.
- Y. Bai et al. LongBench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. ACL, 2025.
- T. Dao et al. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. NeurIPS, 2022.
- T. Dao, A. Gu. Transformers are SSMs: Generalized models and efficient algorithms through structured state space duality (Mamba-2). arXiv:2405.21060, 2024.
- DeepSeek-AI. DeepSeek-V3 technical report. arXiv:2412.19437, 2024.
- C.-P. Hsieh et al. RULER: What's the real context size of your long-context language models? COLM, 2024.
- H. Jiang et al. MInference 1.0: Accelerating pre-filling for long-context LLMs via dynamic sparse attention. NeurIPS, 2024.
- W. Kwon et al. Efficient memory management for large language model serving with PagedAttention. SOSP, 2023.
- W. Lee et al. InfiniGen: Efficient generative inference of large language models with dynamic KV cache management. OSDI, 2024.
- Y. Li et al. EAGLE: Speculative sampling requires rethinking feature uncertainty. ICML, 2024a.
- Y. Li et al. SnapKV: LLM knows what you are looking for before generation. NeurIPS, 2024b.
- Z. Liu et al. KIVI: A tuning-free asymmetric 2bit quantization for KV cache. ICML, 2024.
- SGLang contributors. HiSparse for Sparse Attention. sgl-project/sglang pull request #20343, merged March 2026.
- J. Shah, G. Bikshandi, Y. Zhang, V. Thakkar, P. Ramani, T. Dao. FlashAttention-3: Fast and accurate attention with asynchrony and low-precision. arXiv:2407.08608, 2024.
- H. Sun et al. ShadowKV: KV cache in shadows for high-throughput long-context LLM inference. ICML, 2025.
- H. Tang, Y. Lin, J. Lin, Q. Han, D. Ke, S. Hong, Y. Yao, G. Wang. RazorAttention: Efficient KV cache compression through retrieval heads. ICLR, 2025.
- J. Tang et al. Quest: Query-aware sparsity for efficient long-context LLM inference. ICML (PMLR 235), 2024.
- C. Xiao, S. Cho, J. We, Z. Niu, J. Cheng, Y. Zhao, Y. Kwon, Y. Xiong, R. Ma, J. Liu. OasisKV: Scaling in-decode KV cache beyond HBM with lookahead sparse prefetching. arXiv:2608.08097, 2026.
- G. Xiao et al. Efficient streaming language models with attention sinks. ICLR, 2024.
- G. Xiao et al. DuoAttention: Efficient long-context LLM inference with retrieval and streaming heads. ICLR, 2025.
- Z. Xie, Z. Huang, T. Huang, Z. Xu, R. Ma, C. Kozyrakis. HiSparse: Scaling sparse-attention decoding with hierarchical KV cache management. arXiv:2608.07009, 2026.
- S. Yang et al. Gated Delta Networks: Improving Mamba2 with delta rule. ICLR, 2025.
- Z. Ye et al. FlashInfer: Efficient and customizable attention engine for LLM inference serving. MLSys, 2025. arXiv:2501.01005.
- J. Yuan et al. Native sparse attention: Hardware-aligned and natively trainable sparse attention. ACL, 2025.
- A. Zandieh, M. Daliri, M. Hadian, V. Mirrokni. TurboQuant: Online vector quantization with near-optimal distortion rate. ICLR, 2026.
- Z. Zhang et al. H2O: Heavy-hitter oracle for efficient generative inference of large language models. NeurIPS, 2023.
- L. Zheng et al. SGLang: Efficient execution of structured language model programs. NeurIPS, 2024.
