r/LocalLLaMA • • 5h ago

Showcase BasinKV: Long context without the KV cache tax, No context slowdowns, drop-in RAM/NVMe KV offloading for llama.cpp, SGLang, and vLLM, no retraining, Supports models today.

Hello LocalLLaMA! Zellige AI team here to showcase and open-source our latest work:

BasinKV: a cross-engine system that runs 256K context on a 24 GB GPU, with no decode slowdown as context grows (And much more! Keep reading below.)

In the middle of the memory crunch, if you run long-context models locally, you know the pain. You end up running your favorite models heavily quantized, not because the weights don't fit, but because you want long agent sessions plus the weights. And the deeper the context gets, the slower every token becomes, because each step reads the entire KV cache. Eventually you just run out of memory or have to downsize.

BasinKV keeps only a small, fixed working set of the KV cache on the GPU (2,048 tokens by default) and stores the full history in host RAM or NVMe. A tiny GPU index works out which blocks matter next and prefetches them in the background. Your attention kernels and CUDA graphs stay completely stock.

It works with llama.cpp, SGLang, and vLLM V1, and builds on the OasisKV lookahead-prefetch work by Xiao et al. (arXiv:2608.08097), extended for newer models like the Qwen3.x hybrids.

Results (A100 80GB, Q4_K_M, llama.cpp)

  • Qwen3.6-35B-A3B @ 256K: 141 tok/s vs 95 stock (1.49x), using ~8.9 GiB less VRAM
  • Qwen3-8B @ 128K: 124 tok/s vs 54 stock (2.29x)
  • Qwen3.8-27B @ 128K: 50 tok/s vs 41 stock (1.22x)

We also ran Qwen3.6-35B-A3B at full 256K context on a single 24 GB NVIDIA L4 (84.8 MiB GPU KV+index with WHT-INT4 + SphereIndex). Decode stays basically flat, going from 69.9 tok/s on an empty context to 67.1 tok/s at 256K, and it passes passkey tests at 64K and 203K. Stock F16 KV runs out of memory starting at 64K.

Quality holds up:

  • 18/18 on multi-turn long-context coding
  • Even with stock on RepoPatch-LC (7/10 each)
  • Slightly ahead on 240K retrieval (96.2% vs 94.5%) and a LongBench v2 subset (45.0% vs 42.5%, within noise)
  • "Vibes" tests hold up too: Qwen3.8-27B on the same set of real-world tasks did within margin of error, while staying faster since it never got hit with long-context slowdowns.

Does this mean it's perfect? No. We discuss the tradeoffs in our paper.

A couple of notes

  • It isn't always the best choice: stock is still faster on one of our HBM tests (about 20%) when the full context fits in HBM. There is nuance to this, but in general BasinKV pays off when memory is the bottleneck or when you need deep context and/or large concurrency.
  • Deep pure-attention models like Qwen3-8B do better with a bigger window (4,096).
  • Tasks that count things scattered across the whole context, like RULER cwe, suffer at very small windows. We find this nearly inconsequential for the average agent workload (our "vibes" tests pass), though we can't say it's unnoticeable for every workload.

But... does it scale?

While we've mostly framed this for local rigs here, it goes far beyond single-GPU setups.

Serving multiple users? The SGLang integration reaches 581 tok/s aggregate across 16 concurrent 64K sessions (over 1M active tokens) on one A100 serving BF16 Qwen3.8-27B with native MTP (and 470 tok/s no-MTP on H100 FP8, 2.03x shorter batch wall time than stock FP8 KV). There's also a zero-fork vLLM V1 plugin for persistent RAM/NVMe prefix caches.

More details in our write-up, and happy to answer questions here. We've been very busy at Zellige AI, so stay tuned if you're interested in our upcoming release working with thinkingmachines inkling-2-mini.

Code: https://github.com/zellige-ai/basinkv Write-up: https://zellige.ai/research/basinkv-launch

For the nerds: Full Paper: https://zellige.ai/research/basinkv

127 Upvotes

37 comments sorted by

11

u/YearnMar10 4h ago

But does it work with Strata?

Edit: nice idea btw and great work (if it works!)

10

u/ghgi_ 4h ago edited 4h ago

Not out of the box today, we currently support llama.cpp, SGLang and vllm v1, That said, our C++17/CUDA core for Basin has zero ggml/PyTorch dependencies, so wiring BasinKV into Strata's CUDA backend is very doable and something we may explore or PR in the near future.

5

u/Smungus05 3h ago

Strata already supports kv streaming from ram for QFN. I use 32k in vram 256k in ram.

1

u/YearnMar10 2h ago

Same idea as proposed here?

6

u/ghgi_ 2h ago

Close! For QFN specifically, Strata already pairs Qwen3.8-Flash-Next's model-trained sparse indexer with demand-paged RAM streaming with kv resident. BasinKV brings that same bounded-VRAM idea to models without a built-in sparse indexer (like Qwen3.6-35B, Qwen3.8-27B, Qwen3-8B, Granite, etc.) using a 2K GPU window and async lookahead prefetch so it doesn't stall decode.

2

u/thesolewalker 2h ago

Wish adaptive KV streaming was a mainstream feature for llama.cpp (there is a fork that adds it for nvidia, and someone did a similar for AMD)

1

u/Smungus05 1h ago

Yeah this is a game changer for other models. Its been a great way to fit more experts in vram and cache more hot experts with adaptive expert cache. Glad to see it brought to models that don't support it.

1

u/Smungus05 1h ago

I'll take ninfer-5080 support you're taking requests

2

u/Jumpy-Operation-4615 4h ago

Exactly my thought! Although I can't complain, I am getting 50 tg/s and 750+ pp on my 2xP40 grandma's cluster, but I would happily add more ctx and speed

5

u/Additional-Point-824 4h ago

Does this also work on AMD cards? (ROCm or Vulkan)

4

u/ghgi_ 3h ago

At the current moment no, Currently internally we are close to getting llama cpp and eventually vllm supported so if your interested then watch out for that release, thats our current next target along side other engines like strata.

2

u/Additional-Point-824 3h ago

Thanks. I'll keep an eye out

3

u/BS_BlackScout 2h ago

Is there a minimum VRAM requirement (24GB) or have I misunderstood the post?

2

u/ghgi_ 2h ago

No minium, The headline example was serving qwen 3.6 35b at full 256k context with concurrency on a 24 gig gpu at full speed with ram or nvme offloading but this can work on smaller models & smaller gpus!

2

u/BS_BlackScout 2h ago

Thanks for the clarification!

2

u/aelma_z 3h ago

Wow. This gives some hope on multi-user serving with RAM kv offload? Or did i misunderstood the tech ?

1

u/ghgi_ 3h ago

On the money! Plus no slowdowns at those longer contexts

2

u/thesolewalker 3h ago

Is this cuda only or can be possible to port to vulkan/rocm? Asking on behalf of gpu poor AMD users.

3

u/ghgi_ 3h ago

At the current moment its CUDA only but this isn't a hard requirement, Currently internally we are close to getting llama cpp and eventually vllm supported for AMD so if your interested then watch out for that release, thats our current next target along side other engines like strata.

18

u/True_Requirement_891 5h ago

This is some cool work, finally I can do more than 16k CTX with Bonsai-2.5-27b on my 8gb 3070ti

5

u/rawdikrik llama.cpp 3h ago

Bonsai crew! Can't wait for the swift release

8

u/caetydid llama.cpp 4h ago

This is highly appreciated! Looking forward for it to mature and land in llama.cpp / strata and the likes.

1

u/randygeneric 2h ago

is this somehow similar to omlx's tier-2 kv-caching (ssd)?
i was on the border to fork llama-server for that, because the maintainer rejects the idea (won't happen).

2

u/ghgi_ 2h ago

From a glance, Similar on the disk caching side, and it goes a step further on active decode using a 2K GPU window and async lookahead prefetch so it doesn't stall decode.

1

u/randygeneric 2h ago

i would like to try, but i need to check first, if there are backdors/malicious behaviour.

1

u/RangersStolen 32m ago

So, any model? Gemma4 31b included? Because that would be fantastic.

1

u/ghgi_ 7m ago

Being implemented as we speak, currently it works on any standard GQA/MHA model and any linear/GDN/Mamba2 + full-attention hybrid (examples: Qwen3.8-27B, Qwen3.6-35B-A3B, IBM Granite-4.0-H, NVIDIA Nemotron-Nano-9B-v2) SWE hybrids like gemma 4 (and inkling 2 mini) should be done supported later today on llama cpp and soon after on sg/vllm

1

u/Erulogos 24m ago

Is this a Qwen specific enhancement, or will it work for other models as well?

2

u/ghgi_ 10m ago

Not Qwen-specific at all, it works on any standard GQA/MHA model and any linear/GDN/Mamba2 + full-attention hybrid, the main modern architectures not wired yet are SWA hybrids like Gemma 4/inkling 2 mini (which we're working on as we speak) and MLA/DSA models that already ship trained sparse indexers (like Qwen3.8-Flash-Next) because those already have a learned sparse indexer trained into the weights so its lower value to implement, HOWEVER, BasinKV's systems half can sit directly below their trained indexer and there is room to optimize those further aswell with its other features, the inital release is mostly covering the high value models and very shortly gemma 4 and inkling style with SWE will be as well

2

u/Rorp24 1h ago

Really cool idea on paper, but what is the catch ? Can we have the benchmark on accuracy, prefill speed and decode speed ?

1

u/nymical23 4h ago

Thank you for your work.

Will it work for EXL3 (exllamav3) quants via TabbyAPI?

1

u/selfCodingDude 4h ago

Bro WTF this is insane!

1

u/chimpera 2h ago

How would this perform at 2x 524k on 27b.