Local models · faster · week of
Qwen3.6-35B on a 16 GB RTX 4070 Ti Super: 40 to 102 tokens a second
A model too big for the video card can still be fast if the parts it uses most are the ones on the card. Deciding where each part lives took one local coding model from 40 to 102 tokens a second on 16 GB.
Local models: open-weight coding models served from my own desktop with llama.cpp · private setup
I wanted open-weight coding models running on my own desktop, fast enough for an agent that calls tools in a loop. The card is an RTX 4070 Ti Super with 16 GB, next to a Ryzen 7 5700X3D and 32 GB of DDR4. The model, Qwen3.6-35B-A3B, is about 22 GB at 4-bit, so it does not fit.
What is fast enough for a coding agent?
I set the targets before measuring, all at 32,000 tokens of context:
- at least 50 tokens a second of generation, because agents write a lot of thinking and tool-call JSON
- at least 1,000 tokens a second reading the prompt; an agent's system prompt runs to 10 or 30 thousand tokens, and at 300 a second a cold 20,000-token prompt takes over a minute
- at least 64,000 tokens of usable context
- at least 98% of tool calls that parse, since one broken call derails a run
Does a 35B model fit in 16 GB of video memory?
This model is a mixture of experts: 35 billion parameters, of which about 3 billion are used for any one token. So most of it can sit in ordinary RAM, as long as the parts every token needs, and the experts used most often, are on the card.
video card, 16 GB RAM, 32 GB +------------------+ +----------------+ | attention | | all the | | context cache |<----| experts | | hot experts | | | +------------------+ +----------------+ keep about 1.5 GB free for the desktop
llama.cpp settings, one change at a time
Each run changed one setting, with the desktop in normal use, and every number went into a results file.
Two changes did most of the work. With default settings the machine ran out of RAM and kept re-reading 8.7 GB of the model from disk; turning memory mapping off ended that and doubled prompt reading, from about 500 tokens a second to 1,320. Then a cache of the most-used experts in spare video memory added 55% to generation for the same memory.
Three things did not help: computing half the cache misses on the CPU (83 down to 70; the RAM is too slow), a longer draft, and a 128K context without shrinking the cache, which spilled video memory and halved prompt reading.
Tool calls and Claude Code on a local model
Speed is no use if the tool calls come out broken. I ran nine agent-style cases five times each: 45 of 45 well-formed calls, one or two seconds per call. Then I pointed Claude Code at the local server. The first turn reads an 11,200-token system prompt in 7 seconds, later turns start in under a second, and a bug-fix task took 17 turns and 48 seconds and was correct.
A second model of the same design, Ornith 1.5, was faster and a little less careful:
- Ornith: 99 tokens a second short, 85 at 32K, 42 of 45 tool calls
- Qwen: 90 short, 72 at 32K, 45 of 45
Two things that broke
Threads got stuck. Two kinds of message made the server answer with an error: a block Claude Code sends after it looks up a tool, and images. Claude Code retries, and because the bad message stays in the history, every later turn fails too. A corrected chat template fixed the first. Loading the model's vision part on the CPU fixed the second, at about 1.5 seconds per image and no video memory.
Then Windows' own compositor crashed. At a 128K context the model held 15.8 of the card's 16 GB, and the desktop ran out. Storing the context cache at 8 bits bought back about 1.2 GB for 8% slower prompt reading and no loss in generation. The rule since: leave about 1.5 GB of video memory for the desktop.
The settings I use
These are the llama-server flags behind the final numbers, for llama.cpp build b12406 and the UD-Q4_K_XL file:
-c 131072 -ctk q8_0 -ctv q8_0 -np 1 -ngl 99 -lm none -fit off -fa on -ncmoe 30 --moe-cache-mib 3000 -b 2048 -ub 2048 --spec-type draft-mtp --spec-draft-n-max 2 --mmproj mmproj-F16.gguf --no-mmproj-offload --jinja --chat-template-file <fixed template>
After both fixes the daily setting gives 102 tokens a second on short answers, 92 at 16K and 85 at 32K, and reads prompts at about 1,900.
I'm Ovi. I recompile old Windows games to run in a browser, build a virtual GPU for Windows XP, and write tools for my own machines, with AI since 2020. Projects and the latest log