Running a 35B AI Model on a 6GB GPU
An 8-year-old card, no hardware upgrade, five flags that actually matter.
A 35-billion-parameter model sounds like it needs a GPU nobody reading this owns. It doesn't. The test rig here is about as unimpressive as it gets: a GTX 1060 with 6GB of VRAM on PCIe Gen 3, a four-core i3-8100 with no hyperthreading, and 24GB of plain DDR4. If your machine is newer than that — and it almost certainly is — everything below runs faster for you. This is the floor, not the ceiling.
Why This Model Fits at All
The model is Qwen 3.6 35B A3B, a mixture-of-experts (MoE) design. It has 35 billion total parameters, but only about 3 billion are active for any given token — the model picks 8 out of 256 "expert" sub-networks to wake up per word. A dense model fires every parameter for every token; an MoE model only fires a handful of specialists per token, which means most of it can sit in cheap system RAM instead of expensive VRAM and still be fast — if you tell it to.
The naive approach — splitting the model roughly in half between GPU and CPU — loads, but crawls at around 3 tokens per second, a sentence every 20-30 seconds. Every CPU-resident layer carries its full expert blocks with it, and each token pays the cost of shuttling that data across the PCIe bus. That's the baseline the flags below fix.
Five Flags, in Order
1. Split by expert, not by layer. Keep the small, fast-firing parts on the GPU and push the giant, mostly-sleeping expert blocks onto the CPU. llama.cpp's --n-cpu-moe 41 pins every layer's experts to system RAM while everything else stays on the card. Same hardware, one flag: 3 tok/s → 10 tok/s.
2. Load the whole model into RAM upfront. By default, llama.cpp memory-maps the model file and pages chunks in from disk as needed, which stalls every time an unloaded expert gets called. --no-mmap forces the entire file into RAM at load time instead. No retraining, no quantization: 10 tok/s → 13.5 tok/s.
3. Give the GPU back its free VRAM. Lowering --n-cpu-moe from 41 to 35 pulls six more layers' worth of experts back onto the GPU, trading some context-window budget for more work on the fast chip. Context drops to ~64K tokens, but speed goes 13.5 tok/s → 17 tok/s.
4. Compress the context cache, not the model. Every token seen gets stored as key/value pairs in a cache that grows linearly with context length — that's what ate the VRAM budget in step 3. An aggressive-but-near-lossless compression scheme (4-bit keys, 3-bit values, taking advantage of this model's 8:1 attention ratio) recovers that budget: context goes from 64K back up to 256K tokens — four times the model's original training context — on the same 6GB card, at the same 17 tok/s.
5. Lock the experts in RAM. This one isn't about speed — it's about a setup that survives more than a demo. Without memory locking, the OS quietly pages idle experts back out to disk after hours of uptime, causing random stutters. Enabling mlock (which needs permission at the container, Docker, and llama.cpp level — miss one and it silently falls back) tells the kernel not to touch that RAM. Day-one speed doesn't change; what changes is that it runs for a week without degrading.
What Didn't Work: Speculative Decoding
Speculative decoding usually works by running a small "drafter" model alongside the big one — the small model guesses several tokens ahead, and the big model verifies them in one batched pass. It's a legitimate speedup technique in many setups. Here, it made things slower: 17 tokens/sec dropped to 11.
Two architectural reasons killed it for this model. Because it's mixture-of-experts, each token in a batch can call a different set of experts, so verifying eight draft tokens at once meant fetching from dozens of different experts across the PCIe bus instead of one clean batch — verification turned into memory thrash. And roughly three-quarters of this model's layers are state-space layers, which compute one position at a time and depend on the step before it, so they can't be parallelized across a draft window the way standard transformer layers can. Not every optimization technique transfers across architectures.
The Full Picture
| Stage | Speed | Context |
|---|---|---|
| Naive layer split (baseline) | ~3 tok/s | — |
| + Expert-aware split | ~10 tok/s | — |
| + No mmap | ~13.5 tok/s | — |
| + Rebalance to GPU | ~17 tok/s | 64K tokens |
| + Compressed KV cache | ~17 tok/s | 256K tokens |
Five configuration flags, no hardware upgrade: a 35-billion-parameter model, 256,000 tokens of context, 17 tokens per second, on a GPU older than most AI startups. The hardware most people already own can run far more than the AI press implies — once you understand what a mixture-of-experts model actually needs from your GPU versus your system RAM.