Hi everyone!
Since November, my Qwen3.8-27B app has handled 262K tokens of context on the Olares One’s 24 GB card. There was a catch: the longer the conversation, the slower the model. At 242K it wrote 8 tokens per second. Fine for one question, painful for an agent.
This week a Reddit post about BasinKV gave me the fix. I tested it, then ported it into anaelith, my fork of Basalt. Result: 77 t/s at 242K, and the app is updated on my market.
Update, December 3. While preparing the Basalt pull request I measured what my recall tests could not see: in free generation, the selection sometimes makes the model repeat a passage of the prompt word for word (1 continuation in 6 on long books; never when the whole cache is read). The app moves to 1.0.4: the first 98,304 tokens are read exactly again, and the selection only serves the part past them (58 t/s at 242K instead of 8). Details in What about quality?; the pull request is here.
Follow-up, December 4: the copying only happens with greedy decoding, and a better block cache cuts the gap with the full read by 28 to 70 %. All in the follow-up post.
Why the 27B slowed down
For every token it has read, a language model keeps a pair of vectors (the “keys” and the “values”) in what is called the KV cache. For each new token, attention compares the current token with every key and takes a weighted average of the values. Qwen3.8-27B is a hybrid: most of its layers are GDN layers with a fixed-size state, but a quarter of them are regular attention layers, and those have a KV cache that grows with the context.
At 262K tokens, that cache does not fit in VRAM next to the weights. Basalt has an option for this, --kv-resident: the first N tokens stay on the card, the rest lives in RAM and the GPU reads it over the PCIe bus. The problem is that it reads everything in RAM for every generated token. The longer the context, the more bytes have to cross the bus:
| Context | 64K | 121K | 242K |
|---|---|---|---|
Decode, --kv-resident 98304 | 75 t/s | 32 t/s | 8.2 t/s |
BasinKV: read only what matters
BasinKV (zellige-ai, Apache 2.0) implements the OasisKV paper (arXiv 2608.08097). It starts from a simple observation: at any given moment, a token only really “looks at” a small part of the context. The rest weighs almost nothing in the attention average.
How it works:
- the cache in RAM is cut into blocks of a few dozen tokens;
- for each block, a small box stays in VRAM: the minimum and maximum of every dimension of the block’s keys;
- for each token, the box gives an estimate of the best score the block could get against the current query (the Quest score: the product with the box’s middle, plus a share of its radius);
- the best blocks are kept and copied into VRAM, and attention reads only those blocks, plus the most recent tokens.
Before touching anaelith’s code, I checked that it held up with their llama.cpp patch on the Olares One, using Qwen3.6-35B-A3B in Q4_K_M:
| Context | 0 | 32K | 64K | 128K | 192K | 256K |
|---|---|---|---|---|---|---|
| llama.cpp | 185 t/s | 158 t/s | out of memory | |||
| llama.cpp + BasinKV | 181 t/s | 177 t/s | 176 t/s | 170 t/s | 165 t/s | 158 t/s |
Almost flat up to 256K, and the needle tests (find a code hidden in a long document) all passed. On the other hand, prompt reading was half as fast as anaelith’s, and their patch supports neither speculative decoding nor several conversations at once. Hence the plan: bring the idea into anaelith instead of switching engines.
The port into anaelith: --kv-select
I rewrote the mechanism in anaelith’s attention path, in CUDA. It is turned on with --kv-select N (N = blocks kept per KV head) on top of --kv-resident, with an fp16 or int8 KV cache:
- the min/max boxes are updated as the cache fills, while the prompt is read and for every token written;
- at each step, one kernel scores every block, keeps the best N per KV head and copies them, along with the 1,024 most recent tokens, into a small VRAM buffer;
- attention reads that buffer instead of hundreds of thousands of tokens in RAM. The tokens already in VRAM are still read in full.
At 242K, the bus now carries only the chosen blocks, a few thousand tokens per layer, instead of the whole conversation at every step.
The speculative decoding trap
anaelith does not generate one token at a time: a small model proposes several tokens ahead, and the big model checks them all in one pass (a “window”). That is a good part of its speed.
My first version made one selection per window: each block was scored by its best score over all the window’s rows. On a nasty test (find 7 records among 3,750 near-identical ones, at 191K), I got 2 right answers out of 7, whatever the number of kept blocks. The confusing part:
- keeping every block gave 7 out of 7, so it was not a copy bug;
- without speculative decoding, 7 out of 7 as well;
- scoring only the window’s first row, still 2 out of 7.
The explanation: each row of the window is a different token, looking for different things. A shared selection hands some rows another row’s blocks, and a row that needed to read “item-001583” no longer sees the right block. The fix: each row picks its own best blocks, then the union is taken, first row first, capped at twice the budget. Result: 7 out of 7.
Lesson learned: an approximation that works token by token does not necessarily work for a window of tokens. Test both modes.
Results
Qwen3.8-27B (QUASAR NVFP4 pack), int8 KV cache, 262,144 context, on the Olares One. The test: a long inventory log, a question about one specific record, then a summary of about 640 tokens.
| Context | 64K | 121K | 242K |
|---|---|---|---|
Decode, old config (--kv-resident 98304) | 75 t/s | 32 t/s | 8.2 t/s |
Decode, --kv-resident 16384 --kv-select 32 | 77 t/s | 84 t/s | 77 t/s |
| Prompt reading (both) | 4,100 t/s | 2,800 t/s | 1,740 t/s |
Prompt reading does not change: the selection only applies while generating. And since only 16K tokens of cache stay on the card instead of 96K, VRAM use drops to 17.3 GB, with about 14 GB of cache in RAM at 262K.
Same effect on another model, Ornith-1.5-35B-A3B (a 35B MoE on the Qwen3.5 architecture that I’m testing but haven’t published yet): at 188K of context, 35 t/s without selection, 188 t/s with it.
What about quality?
That is the real question: reading only part of the cache changes the attention math. On my recall tests, nothing moves:
- 3 needles out of 3 and 4 out of 4, up to 251K tokens;
- 7 out of 7 on the 3,750 near-identical records at 191K, with and without
--kv-select; - at 64K, 121K and 242K, the same right answer to the speed test’s question, in both modes.
These are recall tests, not a full quality measurement. For the pull request I ran the two missing measurements, on six books from the PG19 corpus read to 100K or 200K tokens.
Teacher-forced (the book’s real continuation is imposed and the model’s probabilities are compared with and without the selection), the gap is small: KL divergence of 0.009 with --kv-select 32, same top token 95.7 % of the time. I also added a per-layer block cache: chosen blocks stay in VRAM until new ones replace them, which more than halves both the loss (0.020 without) and the bus traffic.
In free generation, though, there is a real flaw. Over 400 tokens written by the model after each book, the full read never copied the prompt. With the selection, one continuation in six repeated a passage of the book from a little earlier, word for word (91 % of the reply with a 32-block budget, 68 % on another book with 64). It is not speculative decoding, not the cache, not the size of the recent window: it is the selection itself, which keeps only the blocks closest to the query and so reinforces passages already seen. The speed test above could not show it, and neither could the teacher-forced KL, since the right text is imposed there.
What works: keep most of the context exact. With 98,304 exact tokens on the card, none of the six books repeated. That is the 1.0.4 app’s config below.
The 27B codes three pages through DeepSeek Harness
To see how it does for real, I reused the prompts from my HTML duel with the 27B behind DeepSeek Harness, DeepSeek’s open-source coding agent: one HTML file, no library, fix until the checker says OK. The agent’s context grew to about 105K tokens, and the 27B stayed between 67 and 84 t/s the whole way.

Solar system (reasoning “high”): 1,305 s, 46 tool calls, 38 KB. Orbits, Saturn’s rings, an asteroid belt, today’s date and adjustable speed. Try it here.

Neon city (reasoning “low”): 832 s, 28 calls, 33 KB. “NEON//DRIFT”, rain, a moon, three palettes, free flight on the keyboard. Try it here.

Glider simulator (no reasoning): 775 s, 92 calls, 50 KB. “Thermals”, a sailplane flight over the hills, with rising air. Try it here (Enter to take off).
Why different reasoning levels? Because Olares cuts any reply that goes through Router, its AI gateway, after 600 seconds. At ~77 t/s that is about 46,000 tokens per reply at most. At “high” and “medium”, the 27B wanted to write the city in one 40-49K-token block, reasoning included, and got cut every time. With less reasoning it writes less before acting and stays under the limit. The engine has nothing to do with it: the limit is in Olares’s route.
The 1.0.4 app
Anaelith Qwen38 27B One is at 1.0.4 on my market, with --kv-resident 98304 --kv-select 32 --kv-select-block 64 by default. Up to 98K tokens everything is read exactly, as in 1.0.1 (81 t/s at 64K); past that, the selection takes over (58 t/s at 242K instead of 8), with the repeat risk described above. 1.0.3 (only 16K exact) was faster at 242K (77 t/s) but could repeat from 100K on. If you update without having touched the engine arguments, the app moves to the new config by itself. Otherwise, set --kv-resident 98304 --kv-select 32 --kv-select-block 64 in Router (the model card’s Edit button) or in the Model Console. To read everything exactly, remove --kv-select and its options.
To install it: Market → Settings → Add source, https://orales-one-market.aamsellem.workers.dev.
The code is in aamsellem/anaelith, and I proposed it to Basalt in this pull request, with the measurements and the repeat limitation.
What I take away
- Before porting a paper, run the authors’ implementation on your own machine: an hour of llama.cpp told me the idea held, and what was missing.
- Speculative decoding changes the rules: what holds for one token does not necessarily hold for a window of tokens.
- Fast long context is useless if a reply can’t last more than ten minutes. The next limit is no longer in the engine.
- Recall tests and a teacher-forced KL are not enough: let the model write, and read what it writes.
Thanks to the zellige-ai team for BasinKV and to the OasisKV authors: the idea is theirs.
Enjoy!
Disclosure — All benchmarks in this post run on my own Olares One. If the content was useful and you’re considering one, ordering through this referral link gets you $300 off ($4,699 instead of $4,999), stackable with the $300 Black Friday discount that started November 17: $600 off in total ($4,399). I’m mentioning this out of transparency — and yes, incidentally, it helps keep the blog alive (hosting, domain, and the time I spend writing here).