Artificial Ignorance

How to Run Qwen4-35B-A3B on an 8GB, 12GB or 16GB GPU (llama.cpp Guide)

Yes, Qwen4-35B-A3B runs on an 8GB, 12GB or 16GB graphics card. It is a mixture-of-experts model with 35 billion parameters but only about 3 billion active per token, so with llama.cpp you keep the small, always-used part on the GPU and move most of the “expert” weights into system RAM with --n-cpu-moe. Qwen4 adds one new piece: a 20-billion-parameter n-gram table that llama.cpp reads from your SSD on demand instead of loading into memory. The result is that the recommended 4-bit file, a 36GB download, needs about 25GB of VRAM and RAM together. In practice that means 32GB of system RAM for 4-bit, or 16GB of RAM for a 3-bit file.

Below I explain what changed from Qwen 3.6, which file to download for your RAM, the exact commands for 8GB, 12GB and 16GB cards, how to tune them, the thinking levels, how much of the 1M-token context you can afford, the built-in speed-up called MTP, and what speed to expect. Model details come from Qwen’s own model card and configuration, and file sizes from Unsloth’s Qwen4 guide, all checked on 5 December 2026. Where a number is my own calculation, I say so.

Running Qwen4-35B-A3B on an 8 GB, 12 GB or 16 GB graphics cardA grid of expert blocks with only a few lit, beside three storage tiers: a small graphics card, system memory and an SSD that holds the 20 billion parameter n-gram table.LOCAL AI GUIDEQwen4 35B.8 GB card.Qwen4-35B-A3B with llama.cpp8 GB12 GB16 GB35B total, 3B active, 1M-token context.The 20B n-gram table stays on your SSD.8 of 256 experts per layer, per tokenVRAMattention,cache, hotexpertsRAMmost of therouted expertsSSDn-gram table(engram),read on demandartificialignorance.net
01

What Qwen4-35B-A3B is, and what changed from Qwen 3.6

Qwen4-35B-A3B is the first medium-sized model of Qwen’s fourth generation, released on 4 December 2026 under the Apache 2.0 licence. The name tells you most of what matters: 35B is the total number of parameters and A3B means about 3 billion are active for each token. According to the official model card, it also includes a vision encoder, so it reads screenshots and photos, and it supports a native context of 1,048,576 tokens.

If you followed my Qwen 3.6 35B-A3B guide, most of the method carries over. Wondering whether to switch at all? My Qwen4 vs Qwen 3.6 comparison answers that first. The expert layout is the same, so the same --n-cpu-moe trick works. Three things are different, and two of them change how you run it:

Qwen 3.6 35B-A3BQwen4-35B-A3B
Parameters35B total, 3B active35B total, 3B active, plus a 20B n-gram embedding and a 2B MTP module
Layers and experts40 layers, 256 experts, 8 routed + 1 shared40 layers, 256 experts, 8 routed + 1 shared
AttentionLinear attention in 3 of every 4 layers, full attention in 10 layersGated DeltaNet in 3 of every 4 layers, Qwen Sparse Attention in 10 layers
Native context262,144 tokens1,048,576 tokens
Thinking controlOn or offFour levels: xhigh, high (default), low and off
4-bit UD-Q4_K_XL file22.4GB36.2GB download, about 24.7GB in memory
NeedsAny recent llama.cppllama.cpp with Qwen4 support, merged on 3 December 2026

The n-gram embedding. This is the part that confuses people when they see a 36GB download for a model that is supposed to fit in 25GB. Qwen added a lookup table of 10 million common two-word and three-word sequences (bigrams and trigrams), each stored as a 2,048-number vector, which comes to about 20 billion parameters. It is injected once, at layer 2. The model card says it “improves model quality without extra compute or accelerator memory overhead”. Unsloth calls it the engram. Because each token only looks up a handful of rows, llama.cpp does not need to load it: it maps the file and reads the rows it needs from disk.

Sparse attention. The 10 full-attention layers now use Qwen Sparse Attention: a small indexer picks the most relevant 2,048 tokens of the past for each new token, instead of looking at all of them. The cache layout is the same as Qwen 3.6 (2 key-value heads of size 256), so memory per token stays tiny, but long prompts get faster.

MTP in every file. Qwen 3.6 also had a multi-token prediction head, a small extra layer that guesses the next tokens ahead of time. What is new is that Unsloth ships it inside every Qwen4 GGUF, so llama.cpp can use it for speculative decoding with two flags. I cover it in section 12.

02

Why a 35B model fits on an 8GB card

A dense 35B model would need all 35 billion weights for every token it writes. Qwen4-35B-A3B does not. Each of its 40 layers holds 256 small experts, and a router picks only 8 of them for each token, plus one shared expert that is always on. From the model configuration, the routed experts make up the large majority of the weights, yet a single token touches only about 1 billion of them. That is why you can split the model across three kinds of storage and still get usable speed:

Where llama.cpp keeps each part of Qwen4-35B-A3BThree tiers. The graphics card holds attention, shared experts, embeddings, the context cache and the experts of the last few layers. System RAM holds most routed experts, chosen with --n-cpu-moe. The SSD holds the 20 billion parameter n-gram table, which llama.cpp reads on demand.THREE PLACES, THREE JOBSGraphics card (VRAM)Used for every token, so it belongs on thefastest memory.Attention and linear-attention layersShared experts, embeddings, output layerContext (KV) cacheExperts of the last few layersabout 3 GB + cacheSystem RAMHolds what a token only touches a slice of:8 of 256 experts per layer.Routed experts of the first N layersChosen with --n-cpu-moe NAbout 0.54 GB per layer at 4-bitup to 21.6 GB at 4-bitSSD (lazy-loaded)A huge lookup table. Each token reads only afew rows of it.20B-parameter n-gram embeddingCalled the engram by UnslothRead from disk on demand11.5 GB file, ~0 GB RAM
Everything used for every token sits on the GPU. Experts sit mostly in system RAM. The n-gram table stays on the SSD.
On the GPU

Attention and linear-attention layers, shared experts, embeddings, the output layer and the context cache. About 3GB of the 4-bit file, used for every token, plus the experts of as many layers as you have room for.

In system RAM

Routed experts of the layers you send to the CPU with --n-cpu-moe. Each token needs only 8 of the 256 experts in a layer, so the CPU reads roughly half a gigabyte per token, not 20GB.

On the SSD

The 11.5GB n-gram table of the 4-bit download. With --lazy-mode on llama.cpp reads just the rows each token needs. Windows keeps recently read parts in its file cache, which uses spare RAM but is given back whenever an app needs it.

What this means for you

Your VRAM decides speed. Your system RAM decides which file you can use. Your SSD needs space for the whole download, about 37GB for 4-bit, and should be an NVMe or SATA SSD rather than a hard drive.

The context cache also stays small. Three out of every four layers use Gated DeltaNet, a form of linear attention with a fixed-size memory of about 63MB in total by my calculation. Only the 10 sparse-attention layers keep a cache that grows with the conversation, and they use just 2 key-value heads. Section 11 puts numbers on it.

03

What you need before you start

PartMinimumComfortable
Graphics cardNVIDIA with 8GB VRAM (RTX 3060 Ti, 3070, 4060, 4060 Ti 8GB, 5060)12GB (RTX 3060 12GB, 4070, 5070) or 16GB (RTX 4060 Ti 16GB, 4070 Ti Super, 4080, 5060 Ti 16GB, 5070 Ti, 5080)
System RAM16GB with a 3-bit file32GB with the 4-bit file, 48GB or more for 5-bit and 6-bit
Free disk space30GB for a 3-bit file40GB or more on an NVMe SSD
Softwarellama.cpp with Qwen4 support (any release from 3 December 2026 on)The latest llama.cpp release, kept up to date

The rule that matters most: VRAM plus system RAM must be larger than the resident size of the file, with a few gigabytes left for Windows and your other apps. Unsloth’s Qwen4 guide lists the total memory each quantisation needs: about 10 to 11GB for 1-bit, 12 to 16GB for 2-bit, 17 to 19GB for 3-bit, 21 to 25GB for 4-bit, 26 to 28GB for 5-bit, 29 to 31GB for 6-bit and 41GB for 8-bit. These totals already assume the n-gram table stays on the SSD.

Here is how that works out for common combinations. The picks are mine, based on Unsloth’s sizes and leaving about 4 to 6GB of RAM for Windows:

Your PCTotal memoryFile I would useNotes
8GB card + 16GB RAM24GBUD-IQ3_XXS (17.2GB)Close the browser and other heavy apps; keep context at 32K
8GB card + 32GB RAM40GBUD-Q4_K_XL (24.7GB)The best balance on an 8GB card
12GB card + 16GB RAM28GBUD-Q3_K_XL (19.4GB)Unsloth’s pick for a 16GB GPU, and it fits here too
12GB card + 32GB RAM44GBUD-Q4_K_XL (24.7GB)Room for 64K context and the vision file
16GB card + 16GB RAM32GBUD-IQ4_XS (20.5GB)Unsloth reports 95.2% accuracy for this file in its tests
16GB card + 32GB RAM48GBUD-Q4_K_XL or UD-Q5_K_XLQ5 only if you rarely need more than 64K context

AMD and Intel cards work too, through llama.cpp’s Vulkan, ROCm or SYCL builds, and every flag in this guide applies to them. The commands below use the NVIDIA CUDA build because it is what most people have. Apple Silicon Macs share one pool of memory, so the GPU and RAM split does not apply there; follow Unsloth’s Mac instructions instead.

04

The whole setup at a glance

The whole Qwen4-35B-A3B setup in five stepsCheck that VRAM plus RAM is bigger than the resident model size and that an SSD has 40 GB free; get a llama.cpp release from 3 December 2026 or later; pick UD-Q4_K_XL with 32 GB of RAM or UD-IQ3_XXS with 16 GB; run the command with the engram on SSD and experts split by --n-cpu-moe; tune and save the command.THE WHOLE SETUP AT A GLANCE1Check memoryVRAM + RAM bigger thanthe resident size; 40 GBfree on an SSD2Get llama.cppAny release from 3 Dec2026 on. CUDA build pluscudart zip3Pick a fileUD-Q4_K_XL with 32 GBRAM, UD-IQ3_XXS with 16GB4Run the commandEngram on SSD, expertssplit with --n-cpu-moe5Tune and saveLower --n-cpu-moe untilVRAM is nearly full,keep a .bat file
Bookmark this: the five steps that matter, in order. Each one has its own section below.
05

Step 1: pick the right file for your memory

Quantisation shrinks a model by storing each weight with fewer bits. Unsloth’s “UD” (dynamic) files keep the most sensitive layers at higher precision, so they hold up better than plain quantisation at the same size. For Qwen4 there are two sizes to look at: the download, which includes the n-gram table, and the resident size, which is what actually has to fit in your VRAM and RAM.

Which Qwen4-35B-A3B GGUF file to pick for your memoryResident memory with the n-gram table on SSD: UD-IQ2_XXS 11.9 GB, UD-IQ3_XXS 17.2 GB, UD-Q3_K_XL 19.4 GB, UD-IQ4_XS 20.5 GB, UD-Q4_K_XL 24.7 GB and UD-Q5_K_XL 27.8 GB. Downloads are larger because they include the n-gram table.PICK THE FILE BY TOTAL MEMORY, NOT BY GPUresident weights (VRAM + RAM)downloadUD-IQ2_XXS11.9 GB16 GB total memory, last resort23.4 GBUD-IQ3_XXS17.2 GB8 GB card + 16 GB RAM28.7 GBUD-Q3_K_XL19.4 GB12 GB card + 16 GB RAM30.9 GBUD-IQ4_XS20.5 GB24 GB RAM, or 16 GB card + 16 GB32.0 GBUD-Q4_K_XL24.7 GB32 GB RAM: the sweet spot36.2 GBUD-Q5_K_XL27.8 GB32 GB RAM + 16 GB card43.2 GBSizes from Unsloth's Qwen4 quant table, with the n-gram table on disk. Keep 4 to 6 GB of RAM free for Windows and your apps.
Choose by total memory (VRAM + RAM), not by GPU. The bar shows what must fit in memory; the right column is the download.
FileDownloadResident in VRAM + RAMWho it is for
UD-IQ1_M22.3GB10.8GBEmergency only; Unsloth notes small quants can loop
UD-IQ2_XXS23.4GB11.9GBUnsloth’s pick for 12GB of total memory
UD-IQ2_M26.6GB15.1GBBetter than IQ2_XXS if you have the room
UD-IQ3_XXS28.7GB17.2GB8GB card + 16GB RAM
UD-Q3_K_XL30.9GB19.4GB12GB card + 16GB RAM; Unsloth’s pick for 16GB GPUs
UD-IQ4_XS32.0GB20.5GB16GB card + 16GB RAM, or 24GB total
UD-Q4_K_XL36.2GB24.7GBThe sweet spot with 32GB RAM
UD-Q5_K_XL43.2GB27.8GB16GB card + 32GB RAM, short context
UD-Q6_K50.9GB29.2GB48GB RAM or more

All sizes are from Unsloth’s quantisation table, with the n-gram table kept on disk. For every file up to 4-bit, the table itself is the 11.5GB second part of the download, stored at IQ4_NL precision. Larger files ship it at higher precision: Q5 files use a 15.4GB version and Q6 files a 21.8GB Q8_0 version.

How much quality do you lose? Unsloth tested its files on GSM8K, MATH-500, CRUXEval-O and MMLU-Pro with thinking on. It reports 95.0% for UD-Q4_K_XL against 95.3% for the full BF16 model, 95.2% for UD-IQ4_XS, 94.0% for UD-Q3_K_XL and 89.6% for the tiny UD-IQ1_S. Unsloth also reports perfect scores on the RULER long-context test at 32K, 64K and 128K for its 3-bit and 4-bit files. Those are Unsloth’s own measurements, but they match what I would expect: 4-bit is very close to the original, 3-bit is fine for everyday use, and below 3-bit you start to notice mistakes.

  • 32GB RAM: UD-Q4_K_XL. Best quality that leaves room for Windows and a browser.
  • 24GB of total memory: UD-IQ4_XS. Nearly the same accuracy in Unsloth’s tests, 4GB smaller.
  • 16GB RAM with an 8GB card: UD-IQ3_XXS. Good for chat and simple coding; keep the context short.
  • Want to show it images? Also get mmproj-BF16.gguf (0.9GB). Section 13 explains how.
  • Avoid Unsloth’s non-UD names for the same size unless you have a reason; the UD versions scored better in Unsloth’s tests.

The files live in Unsloth’s Hugging Face repository. llama.cpp’s own team also publishes plain Q4_K_M and Q8_0 files in the ggml-org repository, which work the same way. The model is released under Apache 2.0, so you can use it for personal and commercial work.

06

Step 2: install a llama.cpp that knows Qwen4

Qwen4 needs a llama.cpp build with support for its new architecture. According to Unsloth and the ggml-org model page, that support arrived in pull request #33626, merged on 3 December 2026. Any release after that works. Older builds fail with an error about an unknown model architecture.

  1. Download two zip files

    Open the llama.cpp releases page. For an NVIDIA card, take the CUDA build and the matching CUDA runtime from the same release. In release b13016 from 5 December 2026 they are named llama-b13016-bin-win-cuda-12.4-x64.zip and cudart-llama-bin-win-cuda-12.4-x64.zip. RTX 50 owners can use the CUDA 13.5 pair instead.

  2. Unzip both into one folder

    For example C:\llama. There is no installer; the folder is the program.

  3. Check that it runs

    Open PowerShell in that folder (Shift + right-click in the folder, then Open in Terminal) and run the version command below. The date of the release you downloaded must be 3 December 2026 or later.

.\llama-server.exe --version

If you have an AMD card on Windows, take the Vulkan zip instead; it needs no runtime download. On Linux, build from source with CUDA turned on:

git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --target llama-server llama-cli

The flags in the rest of this guide are the same on Windows and Linux. On Linux, replace the backtick at the end of each line with a backslash and drop the .\ and .exe.

07

Step 3: download the model

You have two options. The simplest is to let llama.cpp download it for you the first time you start the server, using -hf. It fetches both parts of the file and the vision projector, and stores them in its cache folder. The commands in the next section use this method.

If you want the files in a folder you choose, for example on a second SSD with more space, download them with the Hugging Face command-line tool. Install it once with pip install -U huggingface_hub, then:

hf download unsloth/Qwen4-35B-A3B-GGUF `
  --include "UD-Q4_K_XL/*" "mmproj-BF16.gguf" `
  --local-dir D:\models\Qwen4-35B-A3B-GGUF

The 4-bit download arrives as two parts: Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf, which holds the model, and the second part, which is the n-gram table. Point llama.cpp at the first part and it finds the second automatically. Then use -m with that path instead of -hf in the commands below:

-m D:\models\Qwen4-35B-A3B-GGUF\UD-Q4_K_XL\Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf

Put the files on an SSD. The n-gram table is read from disk while the model writes, so on a hard drive every token waits for the disk. If the folder is on a hard drive, move it before you blame the model for being slow.

08

Step 4: the commands for 8GB, 12GB and 16GB cards

The flag that makes a small card work is --n-cpu-moe N. According to the llama.cpp server documentation, it keeps the mixture-of-experts weights of the first N layers on the CPU. Qwen4-35B-A3B has 40 layers, and at 4-bit each layer of experts is about 0.54GB, so each step you lower N moves another half gigabyte onto the GPU.

I worked out a safe starting value for each card. The numbers below are my estimate from the file sizes, leaving about 0.8GB for Windows and the display, plus room for the compute buffers. They should load first time; section 9 shows how to fine-tune them.

How an 8, 12 and 16 GB card fills up with Qwen4-35B-A3B at 4-bitOur estimate for UD-Q4_K_XL. Each card holds about 0.8 GB for Windows, 3.1 GB of model core, the context cache and compute buffers. What is left holds whole layers of experts: about 4 layers on 8 GB, 11 on 12 GB and 17 on 16 GB, which means --n-cpu-moe 36, 29 and 23.STARTING POINTS FOR UD-Q4_K_XL (OUR ESTIMATE)Windows + driverModel coreContext cacheBuffersExpert layers8 GB cardModel core4 expert layers--n-cpu-moe 368 GB12 GB cardModel core11 expert layers--n-cpu-moe 2912 GB16 GB cardModel core128K cache (8-bit)17 expert layers--n-cpu-moe 2316 GBEach layer of 4-bit experts is about 0.54 GB. Vision (mmproj) adds about 0.9 GB more if you keep it on the card.
My starting points for UD-Q4_K_XL. The blue part is whole layers of experts; everything to its left is used for every token.

8GB card with 32GB of RAM (4-bit, 32K context):

.\llama-server.exe `
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL `
  --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU `
  --n-cpu-moe 36 --no-mmproj `
  -c 32768 -np 1 -fa on -ctk q8_0 -ctv q8_0 `
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 `
  --port 8080

8GB card with 16GB of RAM (3-bit, 16K context). Each 3-bit layer of experts is smaller, about 0.36GB, so more of them fit:

.\llama-server.exe `
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-IQ3_XXS `
  --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU `
  --n-cpu-moe 32 --no-mmproj `
  -c 16384 -np 1 -fa on -ctk q8_0 -ctv q8_0 `
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 `
  --port 8080

12GB card with 32GB of RAM (4-bit, 64K context):

.\llama-server.exe `
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL `
  --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU `
  --n-cpu-moe 29 --no-mmproj `
  -c 65536 -np 1 -fa on -ctk q8_0 -ctv q8_0 `
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 `
  --port 8080

16GB card with 32GB of RAM (4-bit, 128K context):

.\llama-server.exe `
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL `
  --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU `
  --n-cpu-moe 23 --no-mmproj `
  -c 131072 -np 1 -fa on -ctk q8_0 -ctv q8_0 `
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 `
  --port 8080

When the server says it is listening, open http://127.0.0.1:8080 in your browser. llama.cpp has its own chat page there, so you can start talking to the model straight away. Here is what each flag does:

FlagWhat it does
-hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XLDownloads (first time) and loads that file. Replace with -m path if you downloaded it yourself.
--load-mode mmapMaps the file into memory instead of copying it. Required for the next flag.
--lazy-mode onReads rows of very large lookup tables from disk on demand. This is what keeps the n-gram table on the SSD. The default, auto, does the same for tables over 4GiB.
-ot per_layer_token_embd=CPUTells llama.cpp to keep the n-gram table (its internal name is per-layer token embedding) on the CPU side, never on the GPU. This is Unsloth’s recommended setting.
--n-cpu-moe NKeeps the expert weights of the first N of the 40 layers in system RAM. Lower N puts more on the GPU: faster, but more VRAM.
--no-mmprojSkips the 0.9GB vision projector that -hf would otherwise load. Remove it if you want image input.
-c 32768Context size in tokens. Always set it: if you leave it out, llama.cpp takes the size from the model, which for Qwen4 is 1M tokens.
-np 1One conversation slot. With several slots, the context is shared between them, which you do not want on a small card.
-fa onFlash attention: less memory for the cache and faster long prompts. Needed for an 8-bit cache.
-ctk q8_0 -ctv q8_0Stores the context cache in 8-bit instead of 16-bit, halving its size with very little quality cost.
--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0Qwen’s recommended sampling for thinking mode, from the model card.
--port 8080The address the server listens on: http://127.0.0.1:8080. Only your own PC can reach it unless you add --host.

The first start takes a while because of the download. After that, loading takes from a few seconds to about a minute, depending on your SSD.

09

Step 5: tune it for your card

The starting values are deliberately cautious. Your card may have more room, especially if you have no other programs on the GPU. Tuning takes ten minutes and is worth it, because every layer of experts you move onto the GPU makes each token a little faster.

  1. Open Task Manager

    Go to Performance, then GPU, and watch Dedicated GPU memory. On Linux, run nvidia-smi in a second terminal.

  2. Start the server and send a long prompt

    Paste in a long document and ask for a summary, so the cache and buffers reach their full size. Memory use at idle is lower than in real use.

  3. Lower --n-cpu-moe by 1 or 2

    Restart with the smaller number. Repeat while dedicated memory stays at least 0.5GB below the card’s total during that long prompt.

  4. Step back one if it fails

    If loading fails with an out-of-memory error, or the speed suddenly drops because Windows starts sharing system memory with the GPU, go back to the last number that worked.

  5. Save the command

    Put the final command in a file called qwen4.bat (replace the backticks with ^, or put everything on one line) so you can start it with a double-click.

Watch for shared GPU memory. On Windows, an NVIDIA card that runs out of VRAM can quietly spill into system RAM instead of failing. Everything still works, but speed can fall by half or more. If Task Manager shows shared GPU memory climbing while the model runs, raise --n-cpu-moe by 1 or 2.

What about automatic fitting? Recent llama.cpp builds have --fit, which is on by default. It adjusts any settings you have not set yourself so the model fits in VRAM, leaving a 1GB margin by default. If you leave out --n-cpu-moe and -c, it will try to do the job for you. I still prefer setting both: you know exactly what you get, and the result does not change when you update llama.cpp.

The GPU expert cache. llama.cpp also has --moe-cache-mib N, which reserves N megabytes of VRAM as a cache for the experts that live in system RAM. Experts that the router picks often stay on the GPU, so fewer have to be read from RAM. Unsloth reports that on its test machine this almost doubled decoding speed: from 53 to 95 tokens per second with 8GB of VRAM, and from 70 to 127 with 16GB. Unsloth does not list the exact cache size it used, so treat this as something to experiment with. My suggestion is to raise --n-cpu-moe by 2 to free about 1GB, then add --moe-cache-mib 1024, and compare the speed on the same prompt.

When to raise --n-cpu-moe

Loading fails, the first long prompt crashes the server, shared GPU memory climbs, or you want a longer context or the vision file.

When to lower it

Task Manager shows more than 1GB of dedicated memory free during a long prompt, and no shared memory in use.

10

Thinking levels and sampling settings

Qwen4 thinks before it answers by default. Unlike Qwen 3.6, which could only switch thinking on or off, Qwen4 has four levels, according to the model card. llama.cpp passes the level to the model with --reasoning-effort, or you can switch thinking off completely with --reasoning off:

LevelFlagWhen to use it
xhigh--reasoning-effort xhighHard maths, tricky bugs, planning. Slowest, and uses the most context.
high (default)nothing, or --reasoning-effort highMost coding and analysis work.
low--reasoning-effort lowQuick questions where you still want a short check.
off--reasoning offChat, writing, translation, summaries. Answers start at once.

Qwen recommends different sampling settings for thinking and non-thinking use. The commands above use the thinking values. For non-thinking mode, replace the sampling line with this one, which adds a presence penalty to stop repetition:

--reasoning off --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.0 --presence-penalty 1.5

On an 8GB card, thinking costs you twice: it takes time, and the thinking text fills the context. The model card allows up to 262,144 tokens of reasoning on hard tasks, which no small card can hold. For everyday use on 8GB I would run with --reasoning-effort low or --reasoning off, and start a separate server with high for the hard problems.

The model card also notes that Qwen4 keeps its earlier thinking in the conversation by default (preserve_thinking is on). That helps agents and long coding sessions stay consistent, but it also means the context fills faster. If you run long chats, my posts on context compaction thresholds and Open WebUI compaction show how to keep them under control.

Using one of the smallest files (UD-IQ1_S, UD-IQ1_M or UD-IQ2_XXS)? Unsloth found that these sometimes loop. It recommends --min-p 0.01 and --presence-penalty 1.5 for them, in both modes.

11

How much of the 1M-token context can you afford?

Qwen4 supports 1,048,576 tokens natively, about 750,000 words. Whether you can use that depends on memory, and here Qwen4 is unusually frugal. Only 10 of its 40 layers keep a growing cache, and each stores 2 key-value heads of 256 numbers. From the configuration, I calculate about 20KB per token with a 16-bit cache, and half that with -ctk q8_0 -ctv q8_0. The sparse-attention indexer stores a small extra set of keys, which I have left out because it is a fraction of the total.

How much memory the Qwen4-35B-A3B context cache needsOur calculation from the model configuration: 10 full-attention layers, 2 key-value heads, head size 256. About 0.67 GB at 32K tokens, 1.34 GB at 64K, 2.7 GB at 128K, 5.4 GB at 256K, 10.7 GB at 512K and 21.5 GB at 1M with a 16-bit cache, and half that with an 8-bit cache.CONTEXT CACHE SIZE (OUR CALCULATION)16-bit cache8-bit cache (-ctk q8_0 -ctv q8_0)32K0.67 GB0.34 GB64K1.34 GB0.67 GB128K2.68 GB1.34 GB256K5.37 GB2.68 GB512K10.74 GB5.37 GB1M21.47 GB10.74 GBOnly 10 of 40 layers keep a growing cache. The other 30 use linear attention with a fixed state of roughly 63 MB per conversation.
My calculation from the model configuration. The 8-bit column is what the commands in this guide use.
Card (4-bit file)Context I would start withCache at 8-bitLongest that is realistic
8GB32K tokens0.34GB64K, with --n-cpu-moe raised by 1
12GB64K tokens0.67GB128K, with --n-cpu-moe raised by 2
16GB128K tokens1.34GB256K, with --n-cpu-moe raised by 3
Any card, cache in RAMUp to 1M tokens10.7GB of system RAMUse -nkvo; slow, but possible with 64GB RAM

The trade is simple: every gigabyte of cache on the GPU is a gigabyte less for experts. About 0.54GB of cache costs you one layer of experts, which is one step up on --n-cpu-moe. For most people, 32K to 128K is the right range. A 32K context already holds a long chat or a few source files.

The -nkvo flag keeps the whole cache in system RAM instead. That frees VRAM for experts but makes long prompts slower, because attention then runs on the CPU. It only makes sense when you really need a very long context and have the RAM for it.

One more thing: a long context is not just memory. Reading a 100K-token document takes time before the first word appears, even with sparse attention. On a small card, expect long documents to take minutes, not seconds, to read in. Short chats feel instant.

12

MTP: the free speed-up built into every file

Multi-token prediction (MTP) is a small extra layer, 2 billion parameters in the original model, that guesses the next one or two tokens before the main model confirms them. When the guess is right, you get two or three tokens for the price of one pass. According to Unsloth, every one of its Qwen4 GGUF files already includes the MTP head, so there is no separate download. In its 4-bit files the head is about 0.59GB; in files up to 3-bit, 0.49GB.

Switch it on with two flags added to any command above:

--spec-type draft-mtp --spec-draft-n-max 2

The second flag sets how many tokens the head guesses ahead. Unsloth measured how often the guesses are accepted: about 0.89 with one token ahead, 0.68 with two and around 0.5 with three. It recommends two, and found depths of three and four slower than two. On its test hardware, MTP made decoding about 1.2 to 1.35 times faster with the 4-bit file, with code gaining more than prose because code is more predictable.

When it may not help

On an 8GB card already at its limit, the 0.6GB head costs you one layer of experts. The speed-up and the loss can cancel out. Test both with the same prompt and keep whichever is faster.

When MTP helps

Your GPU has spare room for the extra head, and you mostly generate code, structured text or long answers. Expect the biggest gain when most experts are on the GPU.

To compare, look at the timing line the server prints after each answer, or the speed shown under each reply in the built-in chat page. Use the same prompt, with thinking off, so the answers are the same length.

13

Showing it images: the vision projector

Qwen4-35B-A3B is multimodal: it can read screenshots, photos, charts and scanned pages. The image part lives in a separate file called the vision projector, or mmproj. Unsloth provides it in BF16, F16 and F32; the BF16 and F16 versions are about 0.9GB.

When you use -hf, llama.cpp downloads and loads the projector automatically. That is why the commands above include --no-mmproj: on a small card, 0.9GB is nearly two layers of experts. To use images, remove --no-mmproj and raise --n-cpu-moe by 2. If you downloaded the files yourself, add --mmproj followed by the path to mmproj-BF16.gguf.

On an 8GB card there is another option: --no-mmproj-offload keeps the projector in system RAM. Images then take longer to process, but you keep all your VRAM for the language model. Once loaded, you can drag an image into the built-in chat page, or send it through the OpenAI-compatible API as an image URL or base64 data.

14

What speed to expect

Speed depends far more on your system RAM and CPU than on the GPU, because the experts that live in RAM are read for every token. Each token needs about 1 billion expert parameters, roughly 0.57GB at 4-bit, and most of that comes from RAM when you have a small card.

The only published numbers I can point to are Unsloth’s. With the 4-bit file, Unsloth reports 53 tokens per second with 8GB of VRAM and 70 with 16GB, rising to 95 and 127 with the expert cache switched on. Those figures come from Unsloth’s own test machine, which almost certainly has faster RAM and a faster CPU than a typical gaming PC, so treat them as a ceiling rather than a promise.

What you will noticeWhat decides itWhat helps
Writing speed (tokens per second)System RAM bandwidth and the share of experts on the GPUDual-channel DDR5, lower --n-cpu-moe, the expert cache, MTP
Waiting before the first wordPrompt length and GPU computeShorter prompts, a faster GPU, flash attention
Pause before every answerThinking--reasoning-effort low or --reasoning off
Slow start-upSSD speedKeep the files on an NVMe SSD

My own rough expectation for an ordinary desktop, based on how similar 3B-active models behave: comfortably faster than you can read on DDR5, and slower but still usable on DDR4 or a laptop with single-channel memory. If your speed is far below that, the usual causes are shared GPU memory (section 9), a hard drive, or a single RAM stick running in single-channel mode.

A quick way to measure is the timing line the server prints after every reply. It shows prompt processing and generation speed separately, so you can see which one is slow and fix the right thing.

15

Using it from other apps and coding tools

llama-server speaks the same API as OpenAI, so most AI apps can use it. Point them at http://127.0.0.1:8080/v1 with any text as the API key. You can test it from PowerShell:

$body = '{"model":"qwen4","messages":[{"role":"user","content":"Explain mixture of experts in two sentences."}]}'
Invoke-RestMethod -Uri http://127.0.0.1:8080/v1/chat/completions -Method Post `
  -ContentType "application/json" -Body $body | Select-Object -ExpandProperty choices
  • Open WebUI, LibreChat and similar chat apps: add an OpenAI-compatible connection with the address above.
  • Coding agents and editors: use the same address as a custom OpenAI endpoint. Tool calling works because llama.cpp uses the model’s own chat template by default.
  • Your own scripts: any OpenAI client library works; only the base URL changes.
  • Agents that read large tool outputs: keep an eye on context. My guide to keeping JSON tool output safe during compaction applies here too.

Everything runs on your own PC. Nothing leaves it unless you open the server to your network yourself with --host 0.0.0.0; if you do, also set --api-key so not just anyone on the network can use it.

16

Ollama, LM Studio and Unsloth Desktop

You do not have to use llama.cpp directly. The alternatives are easier to start with, but each gives you less control over where the model lives, which is exactly what a small card needs.

AppHow to startGood forLimits on a small card
Ollamaollama run qwen4One command, quick first tryThe qwen4 download is 36 to 37GB, and I found no per-tensor or --n-cpu-moe control
LM StudioSearch for Qwen4-35B-A3B and pick a GGUFA friendly chat windowNeeds an update with Qwen4 support; check its settings for an expert offload option
Unsloth DesktopSearch unsloth/Qwen4-35B-A3B-GGUF in its Model hubPicks where the engram goes for youNewer and less widely used than the others
llama.cppThe commands in this guideFull control: experts, engram, cache, MTPMore typing; no installer

The Ollama library page lists tags for the default file, q4_K_M, BF16 and NVFP4 versions, all with the full 1M context. Because Ollama manages memory for you, I could not confirm how it handles the n-gram table or experts on an 8GB card, so I would not start there with a small GPU. On 16GB with 32GB of RAM, it is a reasonable first try.

Unsloth Desktop, according to Unsloth, chooses where to keep the engram automatically and can also serve an API. If you are new to local AI and find the command line off-putting, it is the easiest route that still understands Qwen4’s three-tier layout. For more beginner-friendly tools, see my list of the best free AI tools for low-end PCs.

17

If something goes wrong

ProblemLikely causeFix
Error about an unknown model architecturellama.cpp is too oldDownload a release from 3 December 2026 or later
Out of memory while loading--n-cpu-moe too low or context too largeRaise --n-cpu-moe by 2, or halve -c
Uses 30GB or more of RAMThe n-gram table was loaded into memoryAdd --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU
Huge memory use with no -cContext defaulted to 1M tokensAlways set -c, for example -c 32768
Very slow, GPU nearly idleVRAM spilled into shared memory, or a hard driveRaise --n-cpu-moe; move the files to an SSD
Windows becomes sluggishNot enough RAM left overUse a smaller file or close other apps
Long pause before every answerThinking is on (default high)Add --reasoning-effort low or --reasoning off
Answers repeat or loopSampling settings or a very small fileUse Qwen’s values; for 1-bit and 2-bit files add --min-p 0.01 --presence-penalty 1.5
Cannot send imagesVision projector skippedRemove --no-mmproj or add --mmproj with the file path
Download stops part-wayNetwork or disk spaceRun the same command again; it resumes. Check you have 40GB free
Command fails in PowerShellLine breaksEach line except the last must end with a space and a backtick
18

Common questions

Can I run Qwen4-35B-A3B with 16GB of system RAM?

Yes, with the 3-bit UD-IQ3_XXS file and at least an 8GB card. Close the browser and other heavy apps, and keep the context at 16K to 32K.

Does it work on a 6GB card?

It can load with --cpu-moe, which keeps all experts in RAM, and a short context, but there is little VRAM left for speed. I would treat 8GB as the practical minimum.

Why is the download so much bigger than the memory it needs?

About 11.5GB of the 4-bit download is the n-gram table. With the flags in this guide it stays on the SSD and is read a few rows at a time.

Is Qwen4 better than Qwen 3.6 35B-A3B?

Unsloth says so: it calls it the strongest model under 50B and reports 61.8 on DeepSWE v1.1 and 21.2 on Terminal-Bench 4.1. Those are their figures; try both on your own tasks.

Will it wear out my SSD?

No. The n-gram table is only read, never written, and reading does not wear an SSD the way writing does.

Can I use the full 1M context on 16GB?

Not on the GPU. At 8-bit the cache alone is about 10.7GB. With -nkvo and 64GB of system RAM it is possible, but slow.

Is it free for commercial use?

Yes. Qwen releases it under the Apache 2.0 licence. Check the model card for the exact terms.

Can I fine-tune it on my PC?

Not on an 8 to 16GB card in any practical way. Unsloth supports training Qwen4, but a 35B model needs far more memory to train than to run.

Does this work on a laptop?

Yes, if it has an 8GB or larger NVIDIA GPU and 32GB of RAM. Laptops are often slower because of single-channel RAM and power limits. With less, see my guide to running a local LLM on an 8GB laptop.

Is my data private?

Yes. llama.cpp runs everything on your own PC and sends nothing anywhere, unless you open the server to the network yourself.

19

Your next step

If you have 32GB of RAM, download UD-Q4_K_XL and start with --n-cpu-moe 36 on an 8GB card, 29 on 12GB or 23 on 16GB, keeping the three engram flags in every command. Then lower the number until Task Manager shows the GPU nearly full without touching shared memory. Those few flags are the difference between a 36GB download that will not load and a 35B model you can use every day.

Sources: Qwen4-35B-A3B model card, model configuration, Unsloth GGUF files, Unsloth Qwen4 guide, ggml-org GGUF files, llama.cpp server options, llama.cpp releases, llama.cpp Qwen4 support pull request, Ollama qwen4 library page.