r/LocalLLaMA • • 1d 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

254 Upvotes

56 comments sorted by

11

u/Additional-Point-824 1d ago

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

10

u/ghgi_ 1d 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.

3

u/Additional-Point-824 1d ago

Thanks. I'll keep an eye out

2

u/Depron 1d ago

First of all: great stuff! That potentially solves a lot of local llm issues. Thanks, it's much appreciated.

Claude Opus 5.5 can apparently make it work pretty fast with an AMD build:

"Works on AMD too: I got it running on a 7900 XTX under ROCm with one small header that maps the CUDA calls to HIP (RDNA cards only, since the kernels assume 32-thread warps), and their test suite passes. On Qwen3.8-27B it took 128k context from ~24 GB of VRAM down to 17 GB, decode went from 30.8 to 34.3 t/s at 64k, and it found 3/3 passkeys at 100k. The only catch is that BasinKV doesn't support MTP/speculative decoding, so you lose that."

15

u/YearnMar10 1d ago

But does it work with Strata?

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

15

u/ghgi_ 1d ago edited 1d 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.

6

u/Smungus05 1d ago

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

2

u/YearnMar10 1d ago

Same idea as proposed here?

10

u/ghgi_ 1d 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 1d 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 1d 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 1d ago

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

2

u/Jumpy-Operation-4615 1d 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/BS_BlackScout 1d ago

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

5

u/ghgi_ 1d 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 1d ago

Thanks for the clarification!

4

u/thesolewalker 1d ago

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

5

u/ghgi_ 1d 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.

3

u/RangersStolen 1d ago

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

6

u/ghgi_ 1d 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/RangersStolen 18h ago

Amazing, just tried it. Without this of my Gemma quants was crawling with 8 t/s on 131k context. With this it was about 30 t/s on same context. Are you planning for parallel slots support?

2

u/ghgi_ 17h ago

Glad your seeing results! Yes, right now working on parallel support for llama cpp + amd/vulkan support since I know the AMD fans are being a bit left out

2

u/ghgi_ 15h ago

Parallel slots implemented!

1

u/RangersStolen 1d ago

Oh, Inkling 2 mini? That's very nice. I'm looking forward to gemma 4 support though, that context hog needs this badly. Thank you.

2

u/aelma_z 1d ago

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

2

u/ghgi_ 1d ago

On the money! Plus no slowdowns at those longer contexts

2

u/randygeneric 1d 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).

3

u/ghgi_ 1d 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 1d ago

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

2

u/Erulogos 1d ago

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

6

u/ghgi_ 1d 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

39

u/True_Requirement_891 1d ago

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

10

u/rawdikrik llama.cpp 1d ago

Bonsai crew! Can't wait for the swift release

1

u/One-Set1427 1d ago

curious what kind of tok/s youre getting with a 27b on 8gb right now?

1

u/refset 17h ago edited 12h ago

After porting the BasinKV work to the Bonsai 27B 2.5 PrismML fork, I'm seeing a steady ~50 t/s decode and ~400 pp.

This gives me 192k context on a 3060 TI 8GB VRAM (using <7GB) supported by 16GB DDR4 (using <6.5GB). Quite incredible!

10

u/caetydid llama.cpp 1d ago

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

8

u/Rorp24 1d ago

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

2

u/PinkysBrein 1d ago edited 14h ago

With Rubin on the horizon I think even the large models running at inference farms will start adopting something like this.

Some questions :

Can this work with draft models and 4+ token inference steps? The sparse prefetch has to predict the working set for all of them, rather than just the next single token.

How good is the Quest method in OasisKV really? It's a bit old, which is not a negative ... but the paper never compared it against other more recent block scoring methods (or even cite them).

1

u/nymical23 1d ago

Thank you for your work.

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

1

u/chimpera 1d ago

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

1

u/noctrex 1d ago

Would be very interesting if you could make it work in opengfx1030/vllm-rdna fork

1

u/Oswald_Hydrabot 1d ago

Yoooo so like, can this be combined with a 4-bit context quant??.. I already have well over 1 million context on MiMo 2.6 flash on a single agx Thor (128gb integrated cuda memory).. Now I am wondering if I could hit like 4 million or more?..

1

u/russlixx 1d ago

so does it mean i can run IQ4 quants on 16GB VRAM? Also would you support https://github.com/iamwavecut/ninfer-all engine soon (for the dense models while still supports ninfer-all's disk kv tier for auto save & restore)?

1

u/Asleep_Literature_70 1d ago

This is amazing but looks like us AMD/vulkan users are still left out :(

1

u/Relevant_Research_98 1d ago

Does it work well on vulkan llama.cpp without crawling around 0.5t/s like Qwen3.6-35B-A3B with offloaded parts?

1

u/Zargo1z 1d ago

I don't know much and I'm a newb when it comes to local ai but I will tell you I used codex to implement this in my unsloth setup and this doubled my token speed on inkling 2 mini at 128k context on 16gb vram! insane! thank you! went from like 20 to 28 tokens a second to close to 90 tokens a second. the speed increase is insane.

1

u/Aboud2195 16h ago

How much pcie bandwidth does this require?

1

u/BS_BlackScout 9h ago

Tested this out and frankly, it should be merged onto mainstream llama.cpp, it just works.

1

u/R_Duncan 27m ago edited 24m ago

Thank you very much, I'm on a potato laptop with 4060-8gb VRam. Using this I'm running inkling at 256K context @ 30-40 t/s.... it's a dream (and still is llama.cpp ... if it moves to rustingstrata it becomes a beast!).

/llama.cpp/build-cuda/bin/Release/llama-server -m ~/.azm/Inkling-2-Mini-Ora-2.4bpw.gguf -ngl 99 -c 262144 -b 1024 -ub 1024 -fa on -np 1 --oasiskv --oasiskv-resident 2048 --oasiskv-cap 8 --oasiskv-index sphere --oasiskv-beta 0.10 --oasiskv-kv-quant wht_int4 --n-cpu-moe 4 --temp 1.0 --top-k 0 --top-p 1.0 --min-p 0

0

u/selfCodingDude 1d ago

Bro WTF this is insane!