Thirty-Five Billion Parameters, Twelve Gigabytes, One Stubborn Card: Qwen4-35B-A3B Lives on a 2020 RTX 3080 Ti
A 24 GB card from 2020 just ran a 35-billion-parameter model at over 300 tokens a second, with a 256K context and vision loaded at the same time. That was the RTX 3090. This is what happened when the same model was asked to live on half the memory — a 12 GB RTX 3080 Ti — and the two dead ends it took to get there.
The reference: 319.6 tok/s on a 3090
On a single 24 GB RTX 3090, Qwen4-35B-A3B (UD-IQ4_XS) runs at 319.6 tok/s on code and 288.8 tok/s on prose, with a 256K context (262,144 tokens), native multi-token prediction, and vision all loaded at once. All 10,240 of 10,240 MoE experts sit in VRAM (23,954 of 24,576 MiB used), the KV cache is full int8, the 20B n-gram table stays in RAM, and the 858 MiB vision tower runs on CPU. Prefill hits 2,496.9 tok/s at pp2048 and 3,006.4 tok/s at pp8192. Pure T=1 decode without MTP is 181.4 tok/s. For scale, Qwen3.8-Flash-Next manages 90–93 tok/s on the same card, and Unsloth's day-zero llama.cpp numbers on an RTX 5090 were 165–192 tok/s.
The question was whether any of that survives on the 12 GB card in our hot_house box. The model file is 32.9 GB. The card has 12 GB. Something has to give — and the first thing that gave was the software, not the hardware.
Dead end one: the fork that runs the 8B cannot load Qwen4 at all
Our 8B model, Sparrow, runs on TheTom's llama-cpp-turboquant fork, so the obvious first move was to write Qwen4 a config for the same port, using the run configs from this site's own StudentLLM and TurboQuant-with-MTP write-ups: 256K context, int8 KV, native MTP, vision on CPU, MoE experts spilling to RAM with --n-cpu-moe 30. The config was written, and the load was genuinely tried three times. It fails on two independent incompatibilities no config can fix.
First, the fork has no qwen4 pre-tokenizer. Its vocabulary knows only qwen2 and qwen35 — a search across every branch shows no commit ever added qwen4, so the load dies with unknown pre-tokenizer type: 'qwen4'. Second, the tensor layout is wrong: the fork's qwen4exp loader wants separate blk.N.hc_attn_down.weight tensors per layer, but the unsloth export ships the fused layout, blk.N.hc_attn_down_inject.weight, in all 41 blocks. No fork branch has the fused layout either.
One probe got interesting: overriding the tokenizer metadata to qwen2 got past the vocabulary, then died on the tensor dimensions — and even that would have forced qwen2 tokenization semantics onto a qwen4 tokenizer, which is unvalidated and possibly subtly wrong. The fork's qwen4exp support simply predates the current unsloth export format on both counts. No config-only path exists for this model file on that fork.
Dead end two, resolved: build upstream
Upstream llama.cpp master has both pieces — the qwen4 pre-tokenizer and the fused *_down_inject tensors — so the fix was to build it from source: commit fb8774a7, CUDA 13.5, arch 86;89, Release, BUILD_SHARED_LIBS=OFF so the fork's shared libraries that Sparrow depends on are untouched. The server binary lives at /root/qwen4/llama-server-upstream; the fork install at /usr/bin/llama-server was never touched.
Two gotchas in the build, both worth recording. First, LLAMA_BUILD_TOOLS=OFF excludes the server target entirely — the build dies with No rule to make target 'llama-server' — so tools must stay on even though the tests and examples are off. Second, upstream has no --no-mmap flag at all; the fork config's --no-mmap is an invalid argument error here and has to come out.
Build it yourself: compiling upstream llama.cpp
Here is the whole build, exactly as run on this box, so anyone can duplicate it. The machine is ParrotOS (Debian-based), 24 CPU threads, 78 GB of RAM, an RTX 3080 Ti with the NVIDIA 620.70.06 driver. The build took roughly ten minutes on 24 threads. Allow about 40 GB of free disk for the model plus the build tree.
First, the prerequisites — every one of these was verified installed on the box before the build, with the exact versions shown. They install from stock apt, pinned to those versions so a reader gets the same set:
sudo apt update && sudo apt install \
git=1:2.47.3-0+deb13u1 \
cmake=3.31.6-2 \
gcc=4:14.2.0-1 g++=4:14.2.0-1 build-essential=12.12 \
libssl-dev=3.5.9-1~deb13u1 openssl=3.5.9-1~deb13u1 \
libcurl4-openssl-dev=8.21.0-2~bpo13+1 \
zlib1g-dev=1:1.3.dfsg+really1.3.1-1+deb13u1 \
libzstd-dev=1.5.7+dfsg-1+deb13u1 \
pkg-config=1.8.1-4That is git 2.47.3, cmake 3.31.6, gcc/g++ 14.2.0 with build-essential 12.12, OpenSSL 3.5.9 with libssl-dev 3.5.9, libcurl4-openssl-dev 8.21.0, zlib1g-dev 1.3, libzstd-dev 1.5.7, and pkg-config 1.8.1. The version strings are the full Debian ones, epoch and revision suffix included — 1:2.47.3-0+deb13u1 rather than just 2.47.3 — because that is what apt pins on. One of them, libcurl4-openssl-dev 8.21.0, comes from backports (~bpo13+1); on ParrotOS that repo is enabled by default, on stock Debian 13 you need trixie-backports enabled for that one package, and everything else is in main. The whole pinned set was test-installed with apt-get -s install on this box and resolves cleanly.
CUDA does not come from stock apt. It comes from NVIDIA's own repo, which is how this box got it — version 13.5, installed at /usr/local/cuda-13.5 with nvcc 13.5.37 and the 620.70.06 driver:
wget https://developer.download.nvidia.com/compute/cuda/repos/debian13/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install cuda-toolkit-13-5=13.5.0-1
# installs to /usr/local/cuda-13.5; check with /usr/local/cuda-13.5/bin/nvcc --versionTwo warnings you can safely ignore: cmake complains that ccache is not found (it only speeds up rebuilds) and that NCCL is not found (it only matters for multiple GPUs; this is one card).
Clone upstream and pin the exact commit — master moves fast, and this is the commit the numbers in this article were measured against:
git clone https://github.com/ggml-org/llama.cpp.git /root/llama.cpp-upstream
cd /root/llama.cpp-upstream
git checkout fb8774a7
# commit fb8774a79f7138415cb6d48d5fc85c632bfcdc0f, Dec 4, 2026Put nvcc on PATH first — a non-interactive shell does not have it, and without it the CUDA backend silently never configures:
export PATH=/usr/local/cuda-13.5/bin:$PATHThen configure and build. This is the exact build script used, /root/qwen4/build-upstream.sh:
cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="86;89" \
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \
-DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TOOLS=ON
cmake --build build -j"$(nproc)" --target llama-serverWhat each of those means, in plain words: GGML_CUDA=ON turns on the CUDA backend; CMAKE_CUDA_ARCHITECTURES="86;89" targets sm_86, this card; Release is the optimised build; BUILD_SHARED_LIBS=OFF builds everything static, which matters — it keeps the build from installing shared libraries into /usr/lib that would clobber the fork's libraries that Sparrow depends on; tests and examples are off because they are not needed; LLAMA_BUILD_TOOLS=ON must stay on, because that is the switch the server target lives behind — turn it off and the build dies with No rule to make target 'llama-server'.
The build downloads one thing from the internet while it runs: the prebuilt web UI (llama-ui b13001) from Hugging Face, so the machine needs network access at build time. Install the binary somewhere of its own — not over the fork:
cp build/bin/llama-server /root/qwen4/llama-server-upstream
chmod +x /root/qwen4/llama-server-upstreamVerify it:
/root/qwen4/llama-server-upstream --version
# version: 1.1.1-dev (build 1, commit fb8774a)
# built with GNU 14.2.0 for Linux x86_64The binary is 157 MB and dynamically links the CUDA runtime, cuBLAS, OpenSSL, zlib and zstd from the system — ldd on it shows libcudart.so.13 and libcublas.so.13 from /usr/local/cuda-13.5, so the CUDA toolkit has to stay installed wherever the server runs, not just at build time.
Then the model itself. The files are the unsloth UD-IQ4_XS export plus the vision projector, downloaded from Hugging Face with resume and retries, and verified against their sha256s:
cd /root/models/qwen4-35b-a3b
BASE=https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF/resolve/main
curl -L --retry 5 --retry-all-errors -C - -o Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf $BASE/UD-IQ4_XS/Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf
curl -L --retry 5 --retry-all-errors -C - -o Qwen4-35B-A3B-UD-IQ4_XS-00002-of-00002.gguf $BASE/UD-IQ4_XS/Qwen4-35B-A3B-UD-IQ4_XS-00002-of-00002.gguf
curl -L --retry 5 --retry-all-errors -C - -o mmproj-F16.gguf $BASE/mmproj-F16.gguf
# shard 1: 20,516,282,464 bytes, sha256 513d029c…
# shard 2: 11,520,258,240 bytes, sha256 419b9385…
# mmproj: 899,283,200 bytes, sha256 3805de49…To confirm the whole thing works, start the service (the config for it is in the next section) and check health, then ask it something:
systemctl enable --now qwen4
curl -s http://127.0.0.1:8082/health
# {"status":"ok"}
curl -s http://127.0.0.1:8082/v1/chat/completions -H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Say hello"}],"max_tokens":64}'
# expect a coherent completion; nvidia-smi should show ~10,246 MiB used at loadThe config that runs
The final config is the hotconfig pattern, adapted to 12 GB: 256K context, 16 GPU layers, the first 30 MoE layers' experts in RAM, native MTP, int8 KV cache, vision projector on CPU, token embedding on CPU. In full: --n-gpu-layers 16 --n-cpu-moe 30 --spec-type draft-mtp --cache-type-k q8_0 --cache-type-v q8_0 --mmproj mmproj-F16.gguf --no-mmproj-offload -c 262144 --flash-attn on. Sparrow is stopped — this box only really runs one LLM at a time — and the server runs as a service on port 8082. At load it uses 10,246 of 12,288 MiB of VRAM, with about 2 GB of headroom, and roughly 6 GB of the 78 GB of system RAM.
The run config, in full
This is the exact script running on the box, /root/qwen4/run-qwen4.sh, nothing trimmed. Copy it as-is and it works, provided the model files and the binary are where the paths say they are:
#!/bin/bash
# Qwen4-35B-A3B UD-IQ4_XS on hot_house (RTX 3080 Ti 12GB) — port 8082
# Upstream llama.cpp (fb8774a7) — /root/qwen4/llama-server-upstream.
# TheTom fork CANNOT load this model (no qwen4 pre-tokenizer, fused HC
# tensor layout); upstream has both. Fork binary at /usr/bin/llama-server
# is untouched — this script uses the upstream build only.
#
# Tunables (env): QWEN4_CTX (default 262144), QWEN4_NGL (default 16),
# QWEN4_NCPUMOE (default 30), QWEN4_SPEC (default draft-mtp),
# QWEN4_KV (default q8_0).
set -e
MODEL=/root/models/qwen4-35b-a3b/Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf
MMPROJ=/root/models/qwen4-35b-a3b/mmproj-F16.gguf
CTX=${QWEN4_CTX:-262144}
NGL=${QWEN4_NGL:-16}
NCPUMOE=${QWEN4_NCPUMOE:-30}
SPEC=${QWEN4_SPEC:-draft-mtp}
KV=${QWEN4_KV:-q8_0}
exec /root/qwen4/llama-server-upstream --jinja \
-m "$MODEL" \
--mmproj "$MMPROJ" --no-mmproj-offload \
--host 0.0.0.0 --port 8082 \
--fit off \
--n-gpu-layers "$NGL" \
--n-cpu-moe "$NCPUMOE" \
--spec-type "$SPEC" --spec-draft-n-max 2 \
--chat-template-kwargs '{"preserve_thinking":true}' \
-c "$CTX" --parallel 1 \
--flash-attn on \
--context-shift --swa-full \
--repeat-penalty 1.12 \
--cache-type-k "$KV" --cache-type-v "$KV" \
-b 1024 -ub 512 \
-ot per_layer_token_embd=CPU \
--temp 0.7And the service that runs it, /etc/systemd/system/qwen4.service:
[Unit]
Description=Qwen4-35B-A3B UD-IQ4_XS local LLM (llama-server, 256K ctx, port 8082)
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root
ExecStart=/root/qwen4/run-qwen4.sh
Restart=always
RestartSec=10
StandardOutput=append:/root/qwen4/qwen4.log
StandardError=append:/root/qwen4/qwen4.log
[Install]
WantedBy=multi-user.targetWhat the flags do, in plain words. -m points at shard one; llama.cpp loads shard two itself. --mmproj loads the 858 MiB vision projector, and --no-mmproj-offload keeps it on the CPU — the vision tower never touches the GPU. --host 0.0.0.0 --port 8082 is the listener. --fit off disables the automatic memory fit, because the layout below is set explicitly. --n-gpu-layers 16 is the whole game on a 12 GB card: only 16 of the 41 layers live on the GPU. --n-cpu-moe 30 puts the MoE experts of the first 30 layers in system RAM instead. --spec-type draft-mtp --spec-draft-n-max 2 is native multi-token prediction, the draft model built into the weights. --chat-template-kwargs '{"preserve_thinking":true}' keeps the model's reasoning stream in the API response instead of stripping it. -c 262144 is the 256K context and --parallel 1 serves one sequence at a time. --cache-type-k q8_0 --cache-type-v q8_0 is the int8 KV cache. -b 1024 -ub 512 are the prompt and micro-batch sizes. -ot per_layer_token_embd=CPU keeps the token embedding off the GPU. --temp 0.7 is the default sampling temperature — the benchmarks in this article were run at temperature 0. One flag is a no-op and worth knowing: --swa-full does nothing for Qwen4; the server log says so.
Five environment variables tune it without editing the script: QWEN4_CTX (262144), QWEN4_NGL (16), QWEN4_NCPUMOE (30), QWEN4_SPEC (draft-mtp), QWEN4_KV (q8_0). Start it with systemctl enable --now qwen4; it restarts itself on failure and logs to /root/qwen4/qwen4.log. And remember the one-LLM rule: stop Qwen4 with systemctl stop qwen4 before restarting Sparrow, and vice versa — 12 GB of VRAM does not hold both.
The measured numbers
All numbers are medians of three runs, temperature 0, measured through the server's own /completion timings. Decode is a 512-token generation off a 1,024-token prompt — code from bch.c, prose from War and Peace. Prefill is a prompt-only pass at 2,048 and 8,192 tokens.
| 3080 Ti, 12 GB | 3090, 24 GB | ||
|---|---|---|---|
| Decode, code, MTP | 21.1 tok/s | 319.6 | 15.1x slower |
| Decode, prose, MTP | 20.3 tok/s | 288.8 | 14.2x slower |
| Prefill pp2048 | 371.9 tok/s | 2,496.9 | 6.7x slower |
| Prefill pp8192 | 441.8 tok/s | 3,006.4 | 6.8x slower |
| Decode, code, T=1 (no MTP) | 12.3 tok/s | 181.4 | 14.8x slower |
| Decode, prose, T=1 (no MTP) | 12.7 tok/s | — |
Two things are worth saying plainly. First, MTP works exactly the same way here as on the 3090: it buys 1.72x on code (21.1 vs 12.3) and 1.60x on prose, against the 3090's 1.76x — the feature is fine, the hardware is the gap. Second, prefill holds up far better than decode (6.7x behind, not 15x), because prefill parallelises across the prompt while decode is one token at a time through a model that mostly lives on the CPU.
Why so much slower, in one sentence: only 16 of the 41 layers are on the GPU and the MoE experts of the first 30 layers are in system RAM, so most of each token's compute runs on 24 CPU threads, while the 3090 holds all 10,240 experts in VRAM. The 32 GB model cannot fit in 12 GB of VRAM, and no config changes that arithmetic.
One more limit worth naming: the 3080 Ti in this box is power-limited to 250 W. Raising the limit might buy another 3–4 tok/s of decode — that is an estimate, not a measurement — but the card is staying at 250 W, so the numbers above are the numbers at 250 W.
The tuned variant that crashed
One more config was tried and is worth reporting as a negative: 64K context, 24 GPU layers, 20 CPU-MoE layers. It loaded at 11,874 of 12,288 MiB — 97% of VRAM — and then crashed on the very first decode, a CUDA out-of-memory inside the graph compute. 414 MiB of headroom is not enough; the load-time number lies, because the draft context and activations need room the load doesn't show. The 256K config with 2 GB of headroom is the stable one, and the tuned variant is not viable.
The honest bottom line
Qwen4-35B-A3B runs on a 12 GB card from 2020, with the full 256K context, native MTP, and vision — and it is fifteen times slower at decode than the same model on a 24 GB 3090. That is not a failure of the model or the software: it is the VRAM wall, measured. At 21 tok/s it is usable for long-context work where you care more about the context than the speed, and at 372–442 tok/s of prefill it chews through long prompts respectably. But if decode speed is what you want, the answer is the same as it was before this experiment: you need the VRAM. Half the memory costs you fifteen times the speed — and that, measured rather than assumed, is the whole story.
Links: the model is unsloth/Qwen4-35B-A3B-GGUF on Hugging Face; the build is upstream llama.cpp at commit fb8774a7; the fork that couldn't load it is TheTom/llama-cpp-turboquant. The run config lives at /root/qwen4/run-qwen4.sh on the box, the server on port 8082.