Home / use case

Running a 27B local coding agent on a 12 GB laptop GPU with a tiered KV cache

At a glance
Hardware
RTX 5070 Ti Laptop, 12 GB VRAM, i7-14650HX, 32 GB RAM, Windows
Models & engines
Qwen3.8-27B GSQ-RCO IQ3_XXS with MTP3, in a v3 .ninfer model
Key gotcha
Full 256K context is not validated. The dsh compaction threshold is around 184K, and a step does not read all history. A 232K random-order stress test was unstable across repeats.

What they built

Fitting a 27B model into 12 GB is only half the problem once you want a real agent with long files and tool histories, because the KV cache grows with context. Sparkle-Qwen27b-Kvmem-ninfer is the author's attempt to solve that second half on ordinary hardware.

The validated machine is an RTX 5070 Ti Laptop with 12 GB of VRAM, an i7-14650HX and 32 GB of system RAM, running Windows. The default model is Qwen3.8-27B GSQ-RCO IQ3_XXS with MTP3 speculative decoding. The stack is NInfer inference, a tiered KV cache called KVMem, and a local agent workspace called dsh, with an optional Tauri desktop UI. The code is Apache-2.0.

KVMem keeps sink, recent and retrieved pages in GPU memory and holds about 7 GiB of colder history in host RAM, restoring pages when a query scores them highly. The author is explicit that the 256K figure is a logical capacity, not full attention over 256K tokens on every step.

Setup

  • RTX 5070 Ti Laptop, 12 GB VRAM, i7-14650HX, 32 GB RAM, Windows
  • Qwen3.8-27B GSQ-RCO IQ3_XXS with MTP3, in a v3 .ninfer model
  • Default profile: RK4V4 plus GDN FP32, DeviceKV 36864, Retrieve 3840, HostKV 7168 MiB
  • Node.js 24 or later, the VC++ x64 runtime, and a CUDA 13-compatible NVIDIA driver
  • Optional Pmod desktop built with Tauri 2 and Vue 3.5

How it works

  1. The daily GPU peak is 11,220 to 11,236 MiB, leaving about 12 MiB of headroom. If you run out of memory, the first advice is to shrink the pool, not to change quantization and hope.
  2. A request goes through a cache guard that keeps the sent prefix stable, then the engine scores stored pages, restores a small set, and decodes with sink, recent and retrieved pages in VRAM.
  3. Overlap-retrieval can add a predecessor page when evidence spans two KV pages, at most eight pages per selection, without increasing the total selected pages. Filling is allowed only after the full query has been scored.
  4. MTP3 drafts three tokens for speculative decoding to cut decode steps. The dsh workspace adds edit validation, a task ledger, and a state card after significant tool results. The engine API listens on 127.0.0.1:1234/v1.

Results & numbers

  • On a 39-question short-context check, the default RK4V4 profile scored 35 out of 39 with zero prediction flips against BF16. A previous NVFP4 daily profile peaked at 11,168 MiB and scored 34 out of 39 with one flip.
  • A 110K task with 12 sequential pins finished 12 of 12, producing 733 output tokens in 275.9 seconds at a peak of 11,232 MiB. A 218K task finished 26 of 26, and a 159K task finished 16 of 16.
  • The test the author trusts most used 189,954 tokens of real content across multiple turns, with 16 code facts and 8 earlier conversation facts, and passed 24 of 24. Tool and JSON regression was 20 of 22, the same as v1.0.0. A 66K input with 3,668 output tokens completed without running out of memory.

Gotchas

  • Full 256K context is not validated. The dsh compaction threshold is around 184K, and a step does not read all history. A 232K random-order stress test was unstable across repeats.
  • The prebuilt engine covers Windows x64 with sm120a only. RTX 30 and 40 series cards need an architecture-matched build.
  • Search needs the internet, because dsh search is not an offline index. Private requests, sessions and logs stay local.
  • A known multi-image plus compaction failure remains: if it hits, start a new session. The private dsh login URL is written to a local log and should not be published. Measurements used different binaries, ports and fixtures, and are reported as fixtures, not a leaderboard.
“The weights are only half the memory problem. The KV cache is the other half, and it grows with context.”— Sparkle Qwen27b

Do it yourself

  1. You need a 12 GB NVIDIA laptop GPU in the supported architecture, Node.js 24+, the VC++ x64 runtime, a CUDA 13-compatible driver, and a v3 .ninfer model that contains MTP.
  2. Clone https://github.com/CSUNX233/Sparkle-Qwen27b-Kvmem-ninfer, run setup.ps1 with your model path, then start.cmd.
  3. The first start downloads checksum-pinned dependencies, loads weights and captures CUDA graphs. The private login URL is written to runtime/logs/dsh.stdout.log.
  4. If you run out of memory, shrink the pool toward 38,912 or 38,400 before changing quantization. After a source update, rerun setup.ps1; git pull alone does not replace the executable.
git clone https://github.com/CSUNX233/Sparkle-Qwen27b-Kvmem-ninfer.git
# then run setup.ps1 with your model path, then start.cmd
Source: Sparkle Qwen27b on DEV · Published 2026-11-19 · Added 2026-11-19. This write-up summarizes the original source; see it for full details.

Similar setups

Getting OpenCode to work with a local Ollama model by fixing the 4,096-token context

OpenCode on a local Ollama model ignored files, invented tasks or looped, because each ~23k-token request was silently cut to fit Ollama's default 4,096-token context on a 16 GB GPU.

DEV Community (Davidrs) · 2026-11-27

OpenCode on a CPU-only Intel i7 laptop talking to local Ollama coder models

Idada Osaigbovo James wires OpenCode on a Dell Latitude 5430 (i7-1265U, 32 GB RAM, Iris Xe) to Ollama’s local OpenAI-compatible API and runs Qwen2.5-Coder 1.5B/7B with no cloud subscription.

Medium · 2026-11-06

PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU

WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.

WiseProbe Blog · 2026-11-25

Sharing one local model with several users: parallel-stream tests on a 2020 Radeon RX 6900 XT

Amuro Ray measured how total and per-user speed change when 1 to 8 people share a dense 27B or a 35B-A3B MoE model through llama.cpp's llama-server on a single 16 GB Radeon card.

Amuro Ray on DEV · 2026-11-18