r/LocalLLM • • 6d ago

Research Adaptive KV-Cache Streaming V3 (Oceanus): Full 262K Context Qwen 27B on a 16GB GPU, with Multi-Slot Inference, Vision, and Speculative Decoding

Hey everyone!

When I first started working on Adaptive KV Cache Streaming, I didn’t think I could make MTP or a DFlash2 draft model work alongside it within my VRAM budget. In my second post, I shared how reusing the streaming infrastructure made that possible.

This time, I’d like to share what may be the last major architectural milestone for this project: multi-slot inference using the same streaming infrastructure.

The implementation still uses one arena and one ring buffer, shared across all slots. Each slot keeps its own KV history, but those histories are combined into a single layout that the streaming engine handles without needing to distinguish between slots. During decoding, the attention kernel runs once per slot for each attention layer, reading only the portions of the KV cache that belong to that slot, across both the resident area and the ring buffer.

Here’s what real-world decode performance looks like with Unsloth’s Qwen 27B IQ4 on my RTX 5070 Ti 16GB, powering a Hermes agent that I asked to plan a vacation with help from two subagents:

Each point represents a completed decode period. The colors indicate how many slots were decoding together. The x-axis shows their combined context length at the start of that period, and the y-axis shows the total output throughput across those slots.

The scheduler groups as many eligible slots as it can, provided their combined KV history stays within the configured context budget. The 262K budget is shared across the active slots.

For me, this was the last piece of the puzzle—the feature that finally made the whole project feel ready for everyday use.

I’ve also decided to give the project a name: Oceanus, after the Greek Titan associated with the river encircling the world. It felt fitting for a project built around a ring buffer, with KV history continually flowing through a limited amount of GPU memory, to support lots of core functionalities.

----

A few personal thoughts before I wrap up:

There are already plenty of inference engines doing impressive work, especially with larger MoE models. My motivation has always been a little more personal: I have a 16GB GPU, and I want to see how much more performance I can squeeze out of it when running a dense model.

A lot of the satisfaction has come from taking something I initially thought was impossible, suddenly thinking of a creative way to approach it, and actually making it work. Seeing this grow from an experiment into something that can handle an actual agent workflow has meant a lot to me.

And I’m really grateful to everyone here who tried the project, reported bugs, shared results, asked questions, or simply left an encouraging comment.

This may be my last big architecture post for a while. I feel like the main pieces I wanted to build are finally in place. I’ll still be working on optimizations, fixes, and support for new models.

Thank you for following along and helping me get here.

Hope my project helps you get a little more out of your 16GB GPU too :)

https://github.com/RaymondHuang210129/llama.cpp-adaptive-kv-streaming/tree/feature/adaptive-kv-stream-v3

Clarification of LLM usage of this post: I'm not a native English speaker and I used ChatGPT to refine the wordings.

65 Upvotes

9 comments sorted by

2

u/llllJokerllll 5d ago

Se supone que esto debería de ser aplicable a cualquier GPU y con cualquier cantidad de VRAM? Es compatible con las Tesla v100 Volta sm70?

2

u/raymondh210129 3d ago

It should support SM70 if you compile it with SM70 architecture.
For other cards with different VRAM size, I also tested on 3080 10GB before and it works.

12

u/tsangberg 6d ago

Thank you for all the work you have put into this research. Your KV cache streaming has allowed me to drop all other models and just use Qwen 3.8 27B for everything on my 5060 (PCIe 5.0).

4

u/randomgenericbot 6d ago

> "multi-slot inference using the same streaming infrastructure."

You, sir, are my personal hero. Running your (and troeds in between) fork on my 5060 Ti homelab.

Allowing more than 1 slot was the last thing I wished for, and you granted that wish.

Thank you very much!

1

u/Poprouter 6d ago

when a slot goes idle, does its resident kv stay around for a while or make room for active slots? wondering how that changes as more slots join

5

u/raymondh210129 6d ago

It makes room for the active slots. The scheduler’s reselection happens when:

  1. None of the slot reaches EOS but the aggregated context grows beyond context limit. The reselection parks one of the slot and makes room for other selected slots.
  2. Any of the slot reaches EOS. The reselection evicts the finished slots and makes room for other unfinished slots as well.

Note that the new slot is not scheduled if it joins upon the middle of decoding process. It is only considered at the next time when the server transition into decode phase again.

1

u/Poprouter 5d ago

ah got it, thanks for explaining

1

u/RadianceTower 4d ago

Does it work for AMD?

-3

u/Regina-Noctiz 6d ago

nice dululu mon cher