AI

Run Qwen4-35B-A3B Locally: Ollama, llama.cpp GGUF and vLLM Tested

One RTX 4090 runs Qwen4-35B-A3B at 158 tokens per second in llama.cpp, and at 178 with a single MTP draft token. Ollama on the same card ships with a context and draft setting that spill the model into system RAM. Its out-of-the-box rate was 21 tokens per second. The Qwen4 35B A3B weights are not the problem. Two defaults are, and both take one line to fix.

Original content from computingforgeeks.com - post 203601

We measured Ollama, the Q4_K_M and Q6_K llama.cpp GGUF builds and vLLM with the FP8 checkpoint on one rented host with two RTX 4090s. The Ollama and llama.cpp runs were then repeated with Qwen3.8 27B on the same card and the same prompts (llama.cpp build b12973, measured December 2026 on Ubuntu 24.04). Every figure below is marked as ours or vendor-reported. The tables give resident VRAM and RAM per quant with the n-gram table left on disk, MTP speculative decoding on and off, and the errors each runtime threw.

Step 1: Know what Qwen4-35B-A3B actually loads

Qwen4-35B-A3B is a hybrid mixture of experts that carries two parts most local models do not: a 20B n-gram embedding table read at layer 2, and a 2B multi-token prediction (MTP) head. Those two parts explain every memory number in this article. The table is large but read sparsely, and the MTP head costs VRAM whether it helps or not.

PropertyValueSource
Active parameters per token3B (model card), about 3.8B (HF blog)Vendor, both checked 2026-12-04
Total parameters57B on the model card (35B core plus 20B n-gram table plus 2B MTP); Ollama reports 56.4BModel card; our ollama show
Layers40, in 10 blocks of 3 Gated DeltaNet plus 1 attention layerModel card
Experts256 routed, top 8 plus 1 sharedModel card
Context1,048,576 tokensModel card; our ollama show
InputText and imageModel card
LicenseApache 2.0Model card

Two sources disagree on the active count. The Qwen4-35B-A3B model card says 3B active, while the Hugging Face launch blog says about 3.8B; neither figure changes what a GPU has to hold. For sizing, the useful number is the one Ollama prints for the whole file, 56.4B parameters, because that is what has to live somewhere: VRAM, RAM or disk.

ollama show qwen4:35b-a3b output on an RTX 4090 host showing qwen4exp architecture, 56.4B parameters, Q4_K_M and thinking levels

Two lines in that output matter later. The architecture is qwen4exp, the same name mainline llama.cpp uses, so the GGUF Ollama pulls loads in llama-server unchanged. And the thinking levels Ollama exposes (false, low, medium, high, xhigh, max) are a superset of the four the model card documents, which Step 10 tests.

Step 2: Size the hardware per quant

Qwen4 VRAM needs come down to one setting: whether the n-gram table stays on disk. Lazy mode is the default in llama.cpp. With it on, the Q4_K_M build used 21.9 GB of VRAM and 1.3 GiB of process RSS on our 4090. With lazy mode off, VRAM stayed the same and RSS rose to 14.7 GiB, which is the table moving from disk into memory.

BuildFile sizeN-gram tableOur VRAM, 32K contextOur process RSSggml-org resident RAMggml-org Mac fit
Q4_K_M GGUF36.0 GB14.1 GB21.9 GB on one 4090, no offload1.3 GiB21.9 GB32 GB Mac
Q6_K GGUF51.0 GB21.8 GB23.1 GB on one 4090 with 11 layers of experts in RAM; 15.6 plus 14.7 GB on two 4090s25.1 GiB on one card, 1.7 GiB on two29.2 GB48 GB Mac
Q8_0 GGUF59.4 GB21.8 GBNot measuredNot measured37.6 GB64 GB Mac
FP8 (vLLM)39.7 GB plus 20.5 GB tablePinned host RAM21.9 GB on each of two 4090s, 8K context53 GB host RAM in usen/an/a

Of the GGUF builds, we measured Q4_K_M and Q6_K only. We did not measure Q8_0 on our 4090 hosts, so every Q8_0 figure in the table, the 59.4 GB file size included, is vendor-reported.

Everything in the ggml-org columns is vendor-reported from the original ggml-org GGUF card, read on 2026-12-04, including the claim that Q4_K_M runs on a 32 GB Mac. We had no Mac in this run, so the qwen4 32GB Mac answer here is theirs, not ours. Our VRAM column is what nvidia-smi reported with the server loaded, so it includes the KV cache and CUDA buffers on top of the weights. One unit convention for the whole article: VRAM figures in GB are the nvidia-smi MiB count divided by 1,000 (21,905 MiB reads as 21.9 GB), and process RSS is in GiB.

Read the table by asking where each byte sits. The hardware this suits, in order of comfort:

  • 24 GB GPU: Q4_K_M fits fully at 32K context with about 2.6 GB spare; Q6_K needs some experts on the CPU.
  • 16 GB GPU: Q4_K_M runs with 20 MoE layers on the CPU at 12,747 MiB of VRAM, at about 32 tokens per second on our EPYC host. A 12 GB card needs more layers on the CPU than that, which we did not measure.
  • Two 24 GB GPUs: the FP8 checkpoint fits in vLLM with tensor parallel 2, but only at an 8K context.
  • Disk: keep the GGUF on NVMe, because lazy mode reads table rows from the file on every token.

Our host had 165 GiB of RAM but the container was capped at 84.7 GiB, so the RSS figures above are what the process needed, not what the box offered. If you are choosing a card, the LLM VRAM calculator covers the general arithmetic, and the n-gram table is the one part it cannot know about.

Step 3: Run Qwen4 in Ollama

Ollama needs at least 0.40.21 here, because the model manifest declares requires 0.40.21 and older builds refuse the pull. We pinned that version so the install is repeatable. Current Ollama Linux releases ship as zstd-compressed archives, and the installer stops without the zstd binary, so install that first:

sudo apt-get install -y zstd
curl -fsSL https://ollama.com/install.sh | OLLAMA_VERSION=0.40.21 sh # pin: first release that loads qwen4exp #https://github.com/ollama/ollama/releases/tag/v0.40.21

By default the tag pulls the Q4_K_M build, 36 GB on disk including the n-gram table and the vision projector. The pull ran at around 110 MB/s from the Ollama registry on our host. That host was a container without systemd, so we started ollama serve & by hand first:

ollama pull qwen4:35b-a3b
ollama run qwen4:35b-a3b --verbose --think=false "Explain in about 300 words how Linux cgroup v2 memory.high differs from memory.max, with one example."

On one 4090, the first run reported an eval rate of 11.87 tokens per second, and later runs settled at 20.8 to 21.5. That is a seventh of what the same GGUF does in llama.cpp, and ollama ps shows why: the model is listed at 36 GB, split 39% CPU and 61% GPU, with the card nearly full.

Ollama qwen4 on one RTX 4090 at 21 tokens per second with 39%/61% CPU/GPU split, then 146 tokens per second at 100% GPU with draft_num_predict 0

Look at the model parameters for the cause. Ollama ships it with draft_num_predict 4, so it starts llama-server with --spec-draft-n-max 4 and a 32768-token context. The MTP draft context needs about 900 MiB more than the model alone. The server log shows the result: “42 layers ( 2 overflowing), 21713 MiB used”, so the fit step pushed two layers of experts to system memory. Setting draft_num_predict to 0 brought the same model back to 21 GB, 100% GPU and 146.4 tokens per second.

A better fix keeps MTP and trims the context instead. These are the runs on one 4090 at the default 32K and at num_ctx 8192, two runs each, through the API so the timing comes straight from Ollama’s counters:

Ollama setting (1x RTX 4090)PlacementDecode tok/s
Defaults: 32K context, draft 439%/61% CPU/GPU20.8 to 21.5
32K context, draft 239%/61% CPU/GPU30.6 to 34.4
32K context, draft 0100% GPU, 21 GB137.9 to 146.4
8K context, draft 4100% GPU, 22 GB128.9 to 139.0
8K context, draft 2100% GPU, 22 GB169.5 to 176.9
8K context, draft 0100% GPU, 21 GB142.4 to 147.2

Draft depth 2 at 8K context is the setting we would run on a single 24 GB card: 177 tokens per second, 20% over MTP off. Depth 4, the shipped default, was slower than no MTP at all even with the whole model on the GPU. Pass both options per request:

curl -s http://127.0.0.1:11434/api/generate -d '{"model":"qwen4:35b-a3b","prompt":"Explain in about 300 words how Linux cgroup v2 memory.high differs from memory.max, with one example.","stream":false,"think":false,"options":{"seed":42,"draft_num_predict":2,"num_ctx":8192}}'

With a second 4090 visible, Ollama picked a 262,144-token context on its own, split the model 16.0 and 16.4 GB across the two cards and ran at 111 to 117 tokens per second with the default draft of 4. That is slower than one card at 8K. We did not isolate the cause, since the 262K context and draft 4 also changed, but a layer split across two cards adds a transfer per token. A second GPU buys context length here, not speed. A vision prompt with a rendered nginx error screenshot came back with the correct cause (port 80 already in use) on the first try.

Ollama qwen4:35b-a3b on two RTX 4090s at 117 tokens per second with 262144 context, 16 GB on each card

For other models that fit this VRAM class, the Ollama models cheat sheet lists the tags we have measured, and the Inkling 2 Mini Ollama guide covers a smaller model with the same tag layout.

Step 4: Run the Qwen4 GGUF in llama.cpp

Qwen4 support landed in mainline llama.cpp, but the releases/latest entry on GitHub was v1.1.0 from 2026-11-26, which predates it and has no binaries. Prebuilt CUDA archives sit on the numbered bNNNNN tags instead, so detect the newest one rather than hardcoding it:

LLAMA_TAG=$(curl -s "https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=20" | python3 -c "import json,sys;print(next(r['tag_name'] for r in json.load(sys.stdin) if r['tag_name'].startswith('b')))")
echo "$LLAMA_TAG"

Our run printed b12973. Download the CUDA 12.8 build and its runtime libraries, unpack both, and point the loader at them:

mkdir -p ~/lcpp && cd ~/lcpp
curl -sL -o lcpp.tgz "https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_TAG}/llama-${LLAMA_TAG}-bin-ubuntu-cuda-12.8-x64.tar.gz"
curl -sL -o cudart.tgz "https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_TAG}/cudart-llama-${LLAMA_TAG}-bin-ubuntu-cuda-12.8-x64.tar.gz"
tar -xzf lcpp.tgz && tar -xzf cudart.tgz
export LD_LIBRARY_PATH=$HOME/lcpp/llama-${LLAMA_TAG}:$HOME/lcpp/cudart-llama-${LLAMA_TAG}-bin-ubuntu-cuda-12.8-x64
cd ~/lcpp/llama-${LLAMA_TAG} && ./llama --version

Since this build the archive carries a single llama binary next to the usual llama-server, with its own subcommands for serving, chatting and downloading:

version: 1.1.0-dev (build 12973, commit 59b716523)
built with GNU 13.3.0 for Linux x86_64

For Q4_K_M we pointed llama-server at the GGUF Ollama had already pulled, since it is the same qwen4exp Q4_K_M build (36.08 GB against 36.01 GB for the ggml-org file, now in the -old repo). Our host had no systemd, so Ollama ran as root and kept its blobs under ~/.ollama/models/blobs/, where the 36,078,191,648-byte file was the largest one. A normal install runs Ollama as a service. Its blobs live under /usr/share/ollama/.ollama/models/blobs/ instead, owned by the ollama group, so adjust the path and log in again after the install adds you to that group. Bigger models pulled? Pick the blob by that size. We linked it to a readable name:

mkdir -p ~/models
ln -s "$(ls -S ~/.ollama/models/blobs/sha256-* | head -1)" ~/models/Qwen4-35B-A3B-Q4_K_M.gguf

Watch the repo name here. Later on 2026-12-04, ggml-org moved the files we tested to ggml-org/Qwen4-35B-A3B-GGUF-old and reused the original name for a new conversion that ships split Q4_K and Q8_0 files and no Q4_K_M file. The card’s own commands still carry the old name, so add -old to the repo when you copy one. The old repo stores the MTP head for this quant in a separate mtp-Qwen4-35B-A3B-Q4_K_M.gguf file, which you pass with -md when you run MTP from local files. If you start from llama.cpp alone, the card’s command with the renamed repo downloads the same build, with the quant after the colon:

./llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF-old:Q4_K_M

Every llama.cpp measurement used the same server start on GPU 0 (export CUDA_VISIBLE_DEVICES=0 first on a two-GPU box, or the model splits across both) with a 32K context, then the same 300-word prompt sent three times to /v1/chat/completions with thinking off ("chat_template_kwargs":{"enable_thinking":false}) and the non-thinking sampling from the model card. Decode speed comes from the timings field of each response, VRAM from nvidia-smi and RSS from ps. The lazy-mode pair:

./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -c 32768
./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -c 32768 -lzm off -lv 4

Both runs decoded at 157 to 160 tokens per second with 21.9 GB on the card. The difference is RSS: 1.3 GiB with lazy mode on its default auto, 14.7 GiB with it off. With verbose logging, the server names the tensor that stays on disk, per_layer_token_embd.weight, and marks it “lazy read enabled” when lazy mode is on.

llama-server Qwen4-35B-A3B Q4_K_M lazy mode auto at 1.3 GiB RSS versus lazy mode off at 14.7 GiB RSS, both near 158 tokens per second

So the n-gram-on-disk trick cost nothing in decode speed here and saved 13.4 GiB of process memory. One caveat: the host would not let us drop the page cache between runs. The file was warm, so reads never waited on the disk. The saving is real for the process, but the table still sits in reclaimable page cache. Leave it on. The one case for -lzm off is a model on a slow network mount, where every table read would wait on the network. Our llama.cpp install guide covers building from source if you need a CUDA version the prebuilt archives do not ship.

Step 5: Measure MTP speculative decoding

The Ollama GGUF keeps the MTP head inside the main file, so turning it on is two flags, --spec-type draft-mtp and --spec-draft-n-max N. A local file from the ggml-org -old repo also needs its MTP file passed with -md mtp-Qwen4-35B-A3B-Q4_K_M.gguf. On the 4090, one draft token gave the best result: 177.7 tokens per second against 157.9 without MTP, a 13% gain, with 77% of drafts accepted.

./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -c 32768 -lv 4 --spec-type draft-mtp --spec-draft-n-max 1

Each request logs its acceptance rate, and the MTP draft context adds about 900 MB of VRAM over the plain run (22.8 GB against 21.9 GB):

llama-server Qwen4 MTP draft depth 1 at 177.7 tokens per second with draft acceptance 0.765 on an RTX 4090

Deeper drafts lose on this card because acceptance drops faster than the extra tokens pay back:

llama.cpp b12973, Q4_K_M, 1x RTX 4090Draft acceptanceMean accepted lengthDecode tok/s (warm)Change
MTP offn/an/a157.9baseline
MTP, 1 draft token0.771.77177.7+13%
MTP, 2 draft tokens0.491.98169.5+7%
MTP, 3 draft tokens0.432.30166.9+6%

Hugging Face reports +22% from MTP with 3 draft tokens on an Apple M5 at Q4. Unsloth ran its UD-Q4_K_XL quant with greedy sampling on an RTX 5090 and reports, at one draft token, 224.0 tokens per second on code against 174.9 without MTP (1.28x) and 205.3 on prose against 168.6 (1.22x). Both are vendor figures, read on 2026-12-04. Our +13% on prose is lower. Our sampling was not greedy, which tends to lower acceptance, so the two runs are not a like-for-like comparison. Unsloth recommends a depth of 2, but our reading of its table matches what we saw: at three draft tokens its prose rate fell to 174.9, below the one-token result.

Step 6: Offload experts when VRAM runs short

Because only 8 of 256 experts fire per token, moving expert weights to the CPU costs less than it would on a dense model. We forced 20 of the 40 MoE layers to system memory on the Q4_K_M build to stand in for a 16 GB card. VRAM fell to 12,747 MiB and decode to 31.9 to 33.5 tokens per second.

./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -c 32768 -lv 4 -fit off -ngl 99 --n-cpu-moe 20

A newer flag, --moe-cache-mib, keeps a GPU cache of the CPU-side experts that fire most. Adding a 6 GiB cache to the same split raised VRAM to 18.9 GB and decode to 142.9 to 143.6 tokens per second, more than four times faster:

./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -c 32768 -lv 4 -fit off -ngl 99 --n-cpu-moe 20 --moe-cache-mib 6144

Treat that 143 as a best case. Our benchmark repeats one prompt, so the same experts stay hot in the cache; a varied workload will miss more often. Unsloth reports 131 to 138 tokens per second with the cache against 69 to 72 without on a 24 GB card, which brackets our result from the other side. The 6 GiB cache added 6,164 MiB on our card, so on a 16 GB card start at --moe-cache-mib 2048 on top of the CPU split and raise it only while nvidia-smi shows headroom.

Q6_K is where offload stops being optional on a 24 GB card. We downloaded the Q6_K build (51.0 GB) from the ggml-org -old repo and let the llama-server fit step place it on one 4090. It projected 28,739 MiB of device memory against 23,768 MiB free, so it kept the dense weights of every layer on the card and pushed the experts of 11 layers to system RAM. Decode fell to 39.5 to 42.0 tokens per second with process RSS at 25.1 GiB, and a 2 GiB expert cache lifted that to 49.8 to 51.9. Across both 4090s the same file fit entirely on the GPUs (15.6 and 14.7 GB). It decoded at 137.5 to 138.0 tokens per second there, with RSS back down to 1.7 GiB.

One catch with that build: the original ggml-org repo, now the -old one, keeps the MTP head in separate mtp-Qwen4-35B-A3B-*.gguf files, and on 2026-12-04 it listed them for BF16, Q4_K_M and Q8_0 only, with no Q6_K sidecar. We had downloaded the main file alone, so starting it with --spec-type draft-mtp stopped the server with “context type MTP requested but model doesn’t contain MTP layers”. For MTP with a ggml-org file, pass one of those sidecars with -md. The Q4_K_M blob Ollama pulls has the head built in.

Long context is the other way to run out. At a 262,144-token context, the llama-server fit step moved experts to the CPU on its own, and decode fell to 42.9 to 45.2 tokens per second. The attention KV cache was 5,120 MiB in f16, small for that length because only 10 of the 40 layers are attention layers. Quantizing the cache to q8_0 halved it to 2,720 MiB, and with one MTP draft the run settled at 48.4 to 49.3 tokens per second:

./llama-server -m ~/models/Qwen4-35B-A3B-Q4_K_M.gguf --port 8080 -lv 4 -c 262144 -ctk q8_0 -ctv q8_0 --spec-type draft-mtp --spec-draft-n-max 1

A quarter-million tokens of context on one consumer card at about 48 tokens per second is usable for long-document work, but it is not the 178 the short-context runs show. Size the context to the job.

Step 7: Serve the FP8 checkpoint with vLLM

vLLM published a vllm/vllm-openai:qwen4 image on launch day, and the vLLM Qwen4 recipe serves Qwen/Qwen4-35B-A3B-FP8: 39.7 GB of weights on the GPU, and the 20.5 GB n-gram table in pinned host memory. That does not fit one 24 GB card, so we ran tensor parallel 2 across both 4090s inside that image (vLLM 0.1.dev26393, PyTorch 2.14). The recipe wraps the server in docker run and lets vLLM pick the context length. We ran vllm serve from a shell inside the container and kept the recipe flags apart from four we changed: --max-model-len 8192, --max-num-seqs 16, --gpu-memory-utilization 0.95 and --limit-mm-per-prompt.

On 24 GB cards the recipe flags failed to start, and so did our first adjusted start with a 32K context. Both errors are in the troubleshooting section below. The command that worked lowers the sequence limit to 16, the context to 8K and turns off the image and video encoders, which frees the memory their profiling reserves:

VLLM_USE_RUST_FRONTEND=1 vllm serve /root/fp8 --served-model-name Qwen/Qwen4-35B-A3B-FP8 \
  --tensor-parallel-size 2 --trust-remote-code --enable-prefix-caching \
  --max-model-len 8192 --gpu-memory-utilization 0.95 --max-num-seqs 16 \
  --limit-mm-per-prompt '{"image":0,"video":0}' \
  --disable-flashinfer-autotune --kv-cache-dtype nvfp4 --attention-config.indexer_kv_dtype fp8 \
  --enable-auto-tool-choice --tool-call-parser qwen4 --reasoning-parser qwen4 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}' \
  --port 8000

/root/fp8 is the downloaded FP8 checkpoint; with a token-authenticated Hugging Face cache you can pass Qwen/Qwen4-35B-A3B-FP8 directly. The NVFP4 KV cache setting from the recipe started without complaint on the 4090. Each card loaded 18.62 GiB of weights and had 2.8 GiB left for KV, enough for 14,385 tokens:

vLLM Qwen4-35B-A3B-FP8 on two RTX 4090s: 18.62 GiB per card, 14385-token KV cache, 166 tokens per second single stream with MTP

One stream decoded at 166 tokens per second with MTP and 153 without, a 9% gain at a mean accepted length of 2.21, close to the 2.25 vLLM reports on a B300. The surprise came at four concurrent streams: 255 tokens per second aggregate with MTP against 393 without. With MTP off, the KV cache grew from 14,385 to 83,700 tokens. The startup log gives the consequence: “Maximum concurrency for 8,192 tokens per request: 1.76x” with MTP against 10.22x without. Judging by wall time, only about two of the four requests ran at once with MTP on. That explains the per-stream rate below. It sits far above a quarter of the aggregate.

vLLM FP8, TP 2 on 2x RTX 4090, 8K contextKV cache1 stream tok/s4 streams, aggregate tok/s4 streams, per stream
MTP, 3 speculative tokens14,385 tokens165.7 to 166.1255.0130.1
MTP off83,700 tokens150.4 to 152.6392.6106.9

On two 24 GB cards, run vLLM without MTP if the endpoint serves more than one user, and with MTP only for a single interactive session. The vLLM cheat sheet lists the serve flags used here and the rest of the API.

Step 8: Compare Qwen4 tokens per second across runtimes

Every measured row decodes the same 300-word, non-thinking answer of about 400 tokens in a single stream, and shows the last run of that setting (the third in llama.cpp, the second in Ollama and vLLM). The hardware column matters more than the runtime name: the 4090 rows are one card unless they say two.

Runtime and settingHardwareContextDecode tok/sSource
llama.cpp Q4_K_M, MTP 1 draft1x RTX 409032K177.7Measured, Dec 2026
Ollama Q4_K_M, draft 21x RTX 40908K176.9Measured
vLLM FP8, MTP 3, TP 22x RTX 40908K166.1Measured
llama.cpp Q4_K_M, MTP off1x RTX 409032K157.9Measured
vLLM FP8, MTP off, TP 22x RTX 40908K152.6Measured
Ollama Q4_K_M, draft 01x RTX 409032K146.4Measured
llama.cpp Q4_K_M, 20 MoE layers on CPU, 6 GiB expert cache1x RTX 4090, 18.9 GB used32K142.9Measured
llama.cpp Q6_K (ggml-org), auto fit2x RTX 409032K137.5Measured
Ollama Q4_K_M, defaults2x RTX 4090256K117.1Measured
llama.cpp Q6_K, 11 layers of experts on CPU, 2 GiB expert cache1x RTX 409032K51.9Measured
llama.cpp Q4_K_M, q8_0 KV, MTP 11x RTX 4090256K48.4Measured
llama.cpp Q6_K, 11 layers of experts on CPU1x RTX 409032K39.5Measured
llama.cpp Q4_K_M, 20 MoE layers on CPU1x RTX 4090, 12.7 GB used32K31.9Measured
Ollama Q4_K_M, defaults1x RTX 409032K20.8Measured
llama.cpp UD-Q4_K_XL, no draft, greedy, prose1x RTX 5090n/a168.6Unsloth, read 2026-12-04
llama.cpp, no draftApple M5 Maxn/a91.2Unsloth, read 2026-12-04
vLLM FP8, MTP1x B300n/a514vLLM blog, 2026-12-04

Three readings of that table decide which runtime to install:

  • One 24 GB card: llama.cpp with one MTP draft and Ollama with draft 2 at 8K land within 1% of each other, though the runs differ in context and sampling (Step 10). Ollama runs llama.cpp underneath, so once its defaults stop fighting the card the two converge.
  • Two cards and several users: vLLM is not faster for one user. It earns its place at concurrency, where it batched 393 tokens per second.
  • The slow rows: the bottom of the table is the cost of each mistake, and the worst one is the Ollama default.

Speed is one axis of that choice. Our Ollama vs vLLM vs llama.cpp comparison covers the others, such as model management, API shape and multi-user serving.

Step 9: Compare Qwen4-35B-A3B with Qwen3.8 27B on one card

We pulled qwen3.8:27b into the same Ollama 0.40.21 on the same 4090 and set both models to an 8K context. Each ran two prompts, a 300-word explanation and a short bash function, once with its default MTP draft and once with MTP off:

Ollama head to head on one RTX 4090: qwen4:35b-a3b at 136 to 147 tokens per second versus qwen3.8:27b at 49 to 136 tokens per second
1x RTX 4090 (Ollama 8K, llama.cpp 32K context)Qwen4-35B-A3B (Q4_K_M, 21 GB)Qwen3.8 27B (Q4_K_M, 17 GB)
Ollama, default MTP, prose136.0 tok/s81.3 tok/s
Ollama, default MTP, code143.2 tok/s135.8 tok/s
Ollama, MTP off, prose142.6 tok/s48.8 tok/s
Ollama, MTP off, code146.8 tok/s49.1 tok/s
llama.cpp, MTP off157.9 tok/s49.8 tok/s
llama.cpp, MTP on177.7 tok/s (1 draft)87.1 tok/s (2 drafts, the only depth we ran)
Cron question, thinking off18 (wrong)Not captured
Cron question, thinking on19 (correct)19 (correct)

Qwen4 is about three times faster without MTP, which is what 3B active parameters against 27B dense should give. With MTP the dense model closes most of the gap on code, where its drafts are easy to accept, and stays at half speed on prose. Without a draft, the Qwen3.8 numbers agree with our earlier Qwen3.8 27B run on a 4090 (47.0). With MTP they do not: that run reached 102.8 to 113.2 with an Unsloth UD-Q4_K_XL quant and a separate draft file passed with -md, a different setup from the built-in head used here.

Speed is the only axis this table settles. Two prompts do not rank reasoning quality, and the 27B dense model still uses 4 GB less VRAM and needs no n-gram table on disk. We would pick Qwen4 for an interactive assistant on a 24 GB card. On a 16 GB card neither model fits whole at Q4_K_M, and Qwen4 with experts on the CPU and an expert cache (Step 6) is the one that degrades gracefully, since a dense model has no experts to move. If you want a larger Qwen without the hardware, the Qwen4-Max API guide covers the hosted route, and the Qwen3.8 Flash-Next guide the earlier MoE.

Step 10: Set reasoning effort and sampling

The model card documents four reasoning levels (off, low, high as the default, xhigh), set in vLLM through chat_template_kwargs. Ollama exposes six through think. We asked both runtimes how often a */7 cron job fires between 09:00 and 11:00 inclusive; the correct answer is 19.

Runtime and levelCompletion tokensWall timeAnswer
Ollama, think false1091.0 s18
Ollama, low2612.3 s19
Ollama, medium4113.1 s19
Ollama, high4113.2 s19
Ollama, max3582.8 s19
vLLM, enable_thinking false1322.7 s18
vLLM, reasoning_effort low2591.9 s19
vLLM, reasoning_effort high3162.2 s19
vLLM, reasoning_effort xhigh3862.7 s19

Both runtimes got it wrong with thinking off, missing the 11:00 run, and right at every thinking level. In Ollama, medium and high produced the same 411 tokens and the same text, so on this build medium appears to map to high. Low is the setting we would default to: it fixed the error for about 150 extra tokens, a second of wall time at these speeds.

In vLLM, pass the level per call in the request body:

curl -s http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"Qwen/Qwen4-35B-A3B-FP8","messages":[{"role":"user","content":"How many times does a */7 cron job run between 09:00 and 11:00 inclusive?"}],"temperature":1.0,"top_p":0.95,"chat_template_kwargs":{"reasoning_effort":"low"}}'

Sampling follows the model card, and the two modes want different values:

  • Thinking on: temperature 1.0, top_p 0.95, top_k 20. Ollama already ships these in the model, so nothing to set.
  • Thinking off: temperature 0.7, top_p 0.80, top_k 20 and presence_penalty 1.5. Set them per request whenever think is false, since the shipped defaults are the thinking ones.

Our llama.cpp runs used temperature 0.7, top_p 0.8 and top_k 20 from that second set. Our Ollama benchmarks sent think false without overriding sampling. So they ran on the shipped thinking values. The Ollama and llama.cpp rows in Step 8 differ in sampling as well as context. Keep the penalty too in real use.

Errors we hit and how to fix them

Each of these came from this run. The fix is the one that worked on the rented 4090 host.

“ERROR: This version requires zstd for extraction”

The Ollama installer printed this and stopped when pinned to 0.40.21 on a minimal Ubuntu 24.04 image, because the release archive is zstd-compressed and the image had no zstd. Install it and rerun the same command:

sudo apt-get install -y zstd

After that, the second install finished and ollama --version reported 0.40.21.

Ollama shows “39%/61% CPU/GPU” and 21 tokens per second

Ollama is running the default 32K context plus the default draft depth of 4 overflowing a 24 GB card, covered in Step 3. Either pass "num_ctx":8192 with "draft_num_predict":2, or set draft_num_predict to 0 to keep the full context without MTP. ollama ps should then read 100% GPU.

“max_num_seqs (256) exceeds available Mamba cache blocks (92)”

vLLM raised this during CUDA graph capture with the recipe flags on two 4090s. The DeltaNet layers keep a recurrent state per sequence, vLLM allocates one block per possible sequence, and after 19.06 GiB of weights per card only 0.66 GiB was left. Lower the limit with --max-num-seqs 16:

vLLM ValueError max_num_seqs 256 exceeds available Mamba cache blocks 92 on two RTX 4090s with 0.66 GiB KV cache memory

Raising gpu_memory_utilization is what the error text suggests instead, but on 24 GB cards there is no headroom left to raise.

“To serve at least one request with the model’s max seq len (32768), (0.38 GiB KV cache is needed”

With the sequence limit fixed, the next start failed here: 0.06 GiB of KV cache left after the encoder cache and CUDA graphs, against 0.38 GiB needed for one 32K request. Dropping to --max-model-len 8192 and disabling the vision encoders with --limit-mm-per-prompt '{"image":0,"video":0}' left 2.8 GiB and a 14,385-token cache. If you need images through vLLM, this model wants larger cards; on 24 GB, Ollama and llama.cpp handle vision fine.

For a card that removes most of these trade-offs, our GPU guide for LLMs ranks the options by VRAM. More memory on one card is what removes the context and draft trade-offs measured above.

Keep reading

Run Amazon Ergo Locally: Hardware Requirements and vLLM Setup AI Run Amazon Ergo Locally: Hardware Requirements and vLLM Setup Open Source LLM Comparison Table (2026) AI Open Source LLM Comparison Table (2026) Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) ARTEX AI Penetration Testing: Self-Hosted Install Guide AI ARTEX AI Penetration Testing: Self-Hosted Install Guide Best Prebuilt PC for Local AI: RTX 5070 Ti to 5090 by VRAM AI Best Prebuilt PC for Local AI: RTX 5070 Ti to 5090 by VRAM Install Qdrant on Debian 13 / 12 AI Install Qdrant on Debian 13 / 12

Leave a Comment

Press ESC to close