500K tokens on a 16 GB card: we ran the numbers on JetBrains' KV cache trick
JetBrains has released a llama.cpp fork that runs the open model Inkling 2 Mini with 500,000 tokens of context on a 16 GB graphics card. The trick is a two-tier cache: a heavily compressed version sits in VRAM, the exact version in system RAM. We calculated how much RAM that costs and compared JetBrains' numbers with simpler alternatives.

What this is about
Long contexts on home PCs rarely fail because of the model itself. They usually fail because of the KV cache, the scratch memory where a language model keeps a kind of note for every token it has already read so it doesn't have to recompute everything. That memory grows with every token. Put an entire code repository into the context and it quickly gets bigger than the model.
On December 4, 2026, JetBrains presented a solution, both as a preview in its offline coding agent Junie Local and as a llama.cpp fork on GitHub: JetBrains-Hardware/llama.cpp, branch inkling2-mini-500k. The goal is to fit Inkling 2 Mini from Thinking Machines with 500,000 tokens of context onto a 16 GB graphics card. According to JetBrains, it even runs faster than stock llama.cpp. We explain how the trick works and calculate the RAM requirements that coverage so far hasn't mentioned. We also check how the vendor's numbers compare with simpler alternatives.
The model: why Inkling 2 Mini suits the trick
Inkling 2 Mini was released on November 20, 2026, with open weights under the Apache 2.0 license. It's a mixture-of-experts model with 26.4 billion parameters, of which only 3.4 billion are active per token. Mixture-of-experts means only a small part of the network works on each token, here 8 of 128 "experts". It's also a looped transformer: the middle 12 of its 24 layers run three times per token, for a total of 48 layer passes.
The key to the cache is the config.json. 20 of the 24 layers use sliding window attention, meaning they only look back at the last 1,024 tokens, so their cache stays small. Only layers 5, 11, 17 and 23 see the full context. Because 11 and 17 sit inside the loop and run three times, you get eight "global" passes whose cache grows with the context. Each has 8 KV heads with 128 dimensions each.
That lets you calculate the per-token cost: 8 passes × 2 (key and value) × 8 heads × 128 values = 16,384 numbers per token. Three independent sources confirm this. The community quantization drofn/Inkling-2-Mini-16GB-GGUF measures exactly 544 MiB more per 32,000 tokens with a q8_0 cache, which works out to 17 KiB per token. A guide on aimastery.page gives 32 KiB per token at f16. And JetBrains' own algorithm document also states 17 KiB per token in RAM.
How the two-tier cache works
The fork splits the cache of the global layers into two tiers. It builds on an observation described in the JetBrains blog: to get practically unchanged output, it's enough for attention to handle the 64 most important entries exactly. This approach is called sparse attention.
- Coarse tier in VRAM: All keys sit in video memory at an average of about 2 bits per value, all values at about 1 bit. JetBrains calls this "K2V1". That averages out to 1.5 bits per value, hence the "1.5 bit" figure in a Reddit post. According to the algorithm document, the fork allocates bits by importance per block of 8,192 tokens. Important directions get 3 to 5 bits, unimportant ones none at all.
- Exact tier in RAM: A full 8-bit copy (q8_0) sits in pinned memory. That's RAM the operating system isn't allowed to swap out, so the GPU can access it directly.
- Prediction and prefetching: The fork calculates two layers ahead which entries a layer will need. That works because the internal state changes only slowly from layer to layer. For each KV head, it picks the 1,024 most likely candidates, and the missing 8-bit rows are copied into VRAM in the background, about 300 KiB per layer according to the document. There, a buffer holds 4,096 slots per layer and head. The first four tokens always stay loaded as so-called attention sinks.
- Approximation for the rest: All entries that weren't loaded are computed from the coarse 2/1-bit codes. The most recent tokens are always handled exactly.
The basic idea isn't new. The research system InfiniGen (OSDI 2024) also predicts attention from the previous layer and loads only important entries from CPU memory. What's new is the implementation in llama.cpp for consumer graphics cards.
The math: how much RAM you need
| Context | Q8 copy in RAM | Codes in VRAM (theoretical) | Q4_0 cache fully in VRAM | BF16 cache (default) |
|---|---|---|---|---|
| 150,000 | 2.4 GiB | 0.4 GiB | 1.3 GiB | 4.6 GiB |
| 384,000 | 6.2 GiB | 1.1 GiB | 3.3 GiB | 11.7 GiB |
| 500,000 | 8.1 GiB | 1.4 GiB | 4.3 GiB | 15.3 GiB |
Our own calculation, global layers only. The sliding window caches add roughly 0.1 GiB.
The 8-bit copy isn't everything, though. According to the blog, reading in the prompt (prefill) temporarily needs another 2 GiB or so. The example command also reserves up to 2 GiB for a prompt cache with --cache-ram 2048. Our estimate for the process:
- at 150,000 tokens (the Junie Local default): about 6.5 to 7.5 GiB
- at 384,000 tokens: about 10 to 11 GiB
- at 500,000 tokens: about 12 to 13 GiB
That matches the README, which gives "about 13 GiB" of RAM at 500,000 tokens and recommends 32 GB. There's a contradiction, though: the blog names a test machine with 16 GB of RAM. Our take: with 16 GB of RAM, Windows, an IDE and a browser, 500,000 tokens will be tight. The default of 150,000 tokens, on the other hand, is realistic.
One discrepancy remains unresolved. The algorithm document gives about 2.0 GiB for the VRAM codes including tables at 500,000 tokens (roughly 4 KiB per token), but 3.1 KiB per token elsewhere. JetBrains' measured VRAM figures, meanwhile, rise by only 0.7 GiB from 32,000 to 500,000 tokens, from 14.8 to 15.5 GiB.
The vendor numbers and the simple alternatives
JetBrains used 25 coding prompts (32,000 to 384,000 tokens) to compare how often the most likely next token matches a reference. The reference was a Q8 model with a BF16 cache.
| Configuration (per JetBrains) | VRAM | Top-1 agreement | KL divergence |
|---|---|---|---|
| Q3 weights + two-tier cache | 15.2 GiB | 97.8% | 0.0082 |
| Standard Q4 KV cache | approx. 4.6 GiB more | 97.2% | 0.0101 |
| Q2 weights | – | 95.9% | 0.0212 |
Alternative 1: Q4 KV cache (--cache-type-k q4_0 --cache-type-v q4_0). This works with any llama.cpp build but needs 9 KiB per token in VRAM. At 500,000 tokens that's 4.3 GiB. Add the 12.7 GiB of weights and you're over 16 GiB before you even count compute buffers. In practice, people get much less context on 16 GB cards. With custom-tailored weights and a q8_0 cache, drofn reaches 128,000 tokens on an RTX 5060 Ti at 54 to 57 tokens per second. So you can't directly measure how the fork compares with Q4 at 500,000 tokens. JetBrains' quality comparison went up to 384,000 tokens, with more VRAM.
Alternative 2: Cache entirely in RAM (--no-kv-offload). The CPU then computes attention, and for every new token it has to read the entire global cache, which is 8.1 GiB at 500,000 tokens in q8_0. Assuming 80 GB/s of memory bandwidth (dual-channel DDR5), the theoretical ceiling is around 9 tokens per second, or around 30 at 150,000 tokens. Real-world numbers will be lower. This is our back-of-the-envelope estimate, not a measurement. In the Unsloth discussion, several users advise against exactly this. The fork, by contrast, copies only a few hundred KiB per layer over PCIe.
Speed according to JetBrains (decode, i.e. response speed): - RTX 4090 at 128,000 tokens: 102.2 vs. 82.4 tokens per second - RTX 4090 at 384,000 tokens: 75.7 tokens per second; stock llama.cpp no longer fits - RTX PRO 6000: 88.2 vs. 60.8 tokens per second; prefill 4,045 vs. 686 - DGX Spark: 30.3 vs. 14.1 tokens per second
It's unclear whether speculative decoding was used consistently across all comparisons. With speculative decoding, a small helper model proposes tokens that the large model only has to verify. The fork's example command uses the DSpark drafter for this.
On Terminal-Bench 2.1, the fork solves 44 of 88 tasks. Stock llama.cpp with a BF16 cache and 28.6 GiB of VRAM solves 40. JetBrains itself calls that a tie within the margin of variance.
How to run the fork outside Junie Local
Junie Local installs everything with a PowerShell one-liner and uses 150,000 tokens by default. If you want to use the fork directly, build the branch with CUDA as usual. Then start llama-server with the flags from the README:
LLAMA_DSPARK_KV_CAP=8192 llama-server -m Inkling-2-Mini-UD-Q3_K_XL.gguf \
-md dspark-Inkling-2-Mini-Q8_0.gguf --spec-type draft-dspark \
-ngl 99 -ngld 99 -fa on -c 500000 -b 2048 -ub 2048 -np 1 \
--kvq --kvq-prefill-free-codes --kvq-resident-cap 4096 \
-lm none --cache-ram 2048 --port 8765 --jinja
--kvq forces a single slot, q8_0 and Flash Attention, and disables context shift and cache reuse. The files are about 13.6 GB (model) and 333 MB (drafter). JetBrains recommends plugging your monitor into the integrated graphics, because otherwise Windows takes up 0.5 to 1 GiB of VRAM. The kernels are CUDA-specific, so the fork won't run on AMD or Mac. On unified-memory devices like the DGX Spark, it saves no memory according to JetBrains, but it still speeds things up.
Our verdict
Our take: JetBrains' memory math holds up. It fits the architecture, community measurements and JetBrains' own figure of 28.6 GiB for stock llama.cpp. At 500,000 tokens, 12.7 GiB of weights plus 15.3 GiB of BF16 cache works out to 28 GiB. The real cost barely gets a mention in the marketing: system RAM. 8 GiB or more of pinned RAM at full context isn't a given in 2026, with RAM prices as high as they are.
So far, the quality and speed numbers come exclusively from JetBrains, on hand-picked prompts and benchmarks. Independent tests are missing. Even the author of the Reddit post says he hasn't tried the fork himself. According to the README, the code is deliberately not yet ready for a pull request into official llama.cpp, although the authors explicitly want that. If you own a 16 GB Nvidia card, it's still worth a try. If you want to load entire repositories into a local context today, there's hardly an alternative that promises as much.
Sources
- JetBrains Junie Blog: Running Inkling-2-Mini with 500k context on a 16 GB GPU blog.jetbrains.com
- GitHub: JetBrains-Hardware/llama.cpp (Branch inkling2-mini-500k) github.com
- GitHub: kvq-algorithm.md (Algorithmus-Dokument des Forks) github.com
- Hugging Face: thinkingmachines/Inkling-2-Mini huggingface.co
- Hugging Face: Inkling-2-Mini config.json huggingface.co
- Thinking Machines: Introducing Inkling 2 Mini thinkingmachines.ai
- Hugging Face: unsloth/Inkling-2-Mini-GGUF huggingface.co
- Hugging Face: Unsloth-Diskussion „Share your model speed here“ huggingface.co
- Hugging Face: drofn/Inkling-2-Mini-16GB-GGUF huggingface.co
- mingooland: Running Inkling-2-Mini with 500k context on a 16 GB GPU mingooland.com
- Reddit r/LocalLLaMA: Jetbrains claim to be able to fit more in vram reddit.com
- KBlip: JetBrains says Inkling 2 Mini's 1.5-bit KV quantization … kblip.com
- aimastery.page: Run Inkling 2 Mini Locally aimastery.page
- DEV Community: How to Run Inkling 2 Mini Locally on a 16 or 24 GB GPU dev.to
- note.com (High U): Inkling-2-Mini-Befehle in zwei Umgebungen note.com
- llama.cpp: Server-README (Flags) github.com
- NYU Shanghai RITS: JetBrains Ships Junie Local rits.shanghai.nyu.edu
- USENIX OSDI 2024: InfiniGen usenix.org
- Hacker News: Inkling 2 Mini news.ycombinator.com
Ask the AI assistant
Questions about this article, installation or background? Our assistant knows this page and runs on our own machine, not in someone else's cloud.
The Assistant is an AI (Gemma 4) and can make mistakes – please check important details against the source. Questions are used only to generate an answer and are deleted after one hour. Please don't enter any personal data.
Comments
What do you think? Already tried it? Write it here, no sign-up needed.
Comments are public. Links aren't allowed, and we delete abusive posts. You can delete your own comment at any time in this browser. Learn more in the Privacy Policy.