Qwen3-4B โ€” Low-RAM Quantization Benchmark (reproducible, CPU-only)

A reproducible, transparent benchmark of the base Qwen/Qwen3-4B model across the standard llama.cpp K-quantization ladder, plus an imatrix comparison โ€” measured on a single real CPU, with machine-readable data and exact reproduction steps.

No training, no fine-tuning, no modifications. These are pure GGUF conversions and quantizations of the Apache-2.0 base model. The value of this repo is the benchmark methodology and the numbers โ€” not the weights.

Why this repo exists

Most GGUF model cards on the Hub give subjective quality labels ("very high quality, recommended") with no reproducible numbers, and the few that publish perplexity are single-setup with no way to reproduce them. This repo fills that gap:

  1. Machine-readable results (data/results.tsv)
  2. Exact methodology โ€” pinned llama.cpp build + commit, fixed corpus, fixed context, fixed threads, fixed seed
  3. A CPU benchmark you can re-run (bench/run_bench.sh)
  4. The imatrix question answered for base Qwen3-4B โ€” the one comparison that separates "good quant" from "best quant," independently reproduced here on a real CPU.

Results

Perplexity on the canonical WikiText-2 test set (the exact corpus llama.cpp's own CI uses โ€” so these numbers are directly comparable to the ecosystem's), context 2048, 16 threads, all CPU (-ngl 0), seed 1. Throughput via llama-bench (512-token prompt processing pp512 and 128-token generation tg128, 5 repeats, mean reported).

Quant File size Perplexity (WikiText-2) ฮ” vs F16 pp512 (t/s) tg128 (t/s)
F16 (BF16) 8.05 GB 13.4304 โ€” 357.6 2.52
Q8_0 4.28 GB 13.4409 +0.0105 1355.9 5.04
Q6_K 3.31 GB 13.4404 +0.0099 1523.2 5.93
Q5_K_M 2.89 GB 13.5362 +0.1058 1917.1 5.64
Q4_K_M 2.50 GB 13.7304 +0.3000 2064.8 6.50
Q4_K_M + imatrix 2.50 GB 13.6760 +0.2456 1965.3 6.41
Q3_K_M 2.08 GB 15.6641 +2.2337 2142.5 6.56
Q3_K_M + imatrix 2.08 GB 14.8237 +1.3933 2308.2 5.89

Reading the table: Q8_0/Q6_K are essentially lossless (+0.01 PPL). Q4_K_M is the knee of the curve โ€” 2.5 GB (31% of BF16) for +0.30 PPL, and it's the fastest generator of the non-Q3 set. Q3_K_M is a real quality cliff (+2.23 PPL), which is exactly where imatrix earns its keep.

The imatrix question

imatrix ("importance matrix") quantization uses a calibration set (wikitext-2 wiki.train.raw, 11 MB โ€” standard practice) to learn which weight directions matter most, so the quantizer spends its bits where they count. Measured here for base Qwen3-4B (the delta vs the same non-imatrix quant):

Quant PPL without imatrix PPL with imatrix ฮ” (imatrix gain)
Q4_K_M 13.7304 13.6760 โˆ’0.054 (small)
Q3_K_M 15.6641 14.8237 โˆ’0.840 (large)

The pattern is the well-documented one, now reproduced at this scale: imatrix pays off disproportionately at low bit-counts, where every bit matters. At Q4_K_M the gain is real but small; at Q3_K_M โ€” where the plain quant is already 2.23 PPL worse than F16 โ€” imatrix recovers most of the cliff (back to +1.39). The cost is a one-time calibration pass (~3 h on this CPU; trivial on GPU) and a ~2.5 MB .dat file. Rule of thumb: run imatrix when you drop to Q3 or below. The two imatrix files let you A/B this yourself.

Benchmarks

Size vs accuracy and size vs speed (CPU-only, 16 threads). Light/dark variants render automatically from your Hub theme.

Qwen3-4B size vs accuracy and speed (light) Qwen3-4B size vs accuracy and speed (dark)

Files

File Quant Size Notes
Qwen3-4B-F16.gguf F16 8.05 GB full-precision baseline
Qwen3-4B-Q8_0.gguf Q8_0 4.28 GB near-lossless
Qwen3-4B-Q6_K.gguf Q6_K 3.31 GB K-quant (super-block scaling)
Qwen3-4B-Q5_K_M.gguf Q5_K_M 2.89 GB K-quant, "M" = mixed precision
Qwen3-4B-Q4_K_M.gguf Q4_K_M 2.50 GB workhorse โ€” runs in ~3 GB RAM
Qwen3-4B-Q4_K_M_imatrix.gguf Q4_K_M+im 2.50 GB imatrix-quantized
Qwen3-4B-Q3_K_M.gguf Q3_K_M 2.08 GB smallest plain quant
Qwen3-4B-Q3_K_M_imatrix.gguf Q3_K_M+im 2.08 GB imatrix-quantized

Machine-readable results: data/results.tsv ยท Eval corpus: data/wiki.test.raw ยท Harness: bench/run_bench.sh

How to use

pip install -U "huggingface_hub[cli]"
# grab just the file you want
hf download b4ph/qwen3-4b-lowram-bench --include "Qwen3-4B-Q4_K_M.gguf" --local-dir ./models

Run locally (llama.cpp):

llama-cli -m models/Qwen3-4B-Q4_K_M.gguf -c 4096

Any llama.cpp-based client works: LM Studio, Ollama (ollama import), llama-server, text-generation-webui, etc.

How to reproduce the numbers

Harness: llama.cpp build 10516, commit b95502ba9 (the exact build used โ€” the quantizer's behavior is version-sensitive, so pinning matters).

Hardware: 16-core x86-64 CPU (AVX-512 + VNNI), 61.6 GB RAM. GPU present (RTX 5090) but unused (-ngl 0) โ€” all numbers are pure-CPU, so they're reproducible on any comparable CPU box.

# quality axis โ€” fixed corpus, fixed ctx, fixed seed
llama-perplexity -m Qwen3-4B-<QUANT>.gguf \
  -f wiki.test.raw -c 2048 -t 16 -ngl 0 -s 1

# speed axis โ€” 512-token prompt + 128-token generation, 5 repeats
llama-bench -m Qwen3-4B-<QUANT>.gguf -p 512 -n 128 -t 16 -ngl 0 -r 5

To add imatrix quants (as done for Q4_K_M and Q3_K_M here):

# 1. generate the importance matrix from a calibration set
llama-imatrix -m Qwen3-4B-F16.gguf -f wiki.train.raw -c 2048 -t 16 -ngl 0 -o imatrix.dat
# 2. quantize using it (note: long --imatrix flag)
llama-quantize --imatrix imatrix.dat Qwen3-4B-F16.gguf Qwen3-4B-Q4_K_M_imatrix.gguf Q4_K_M

The full loop (perplexity + speed for every quant, TSV output) is in bench/run_bench.sh.

Base model

Converted from Qwen/Qwen3-4B via llama.cpp's convert_hf_to_gguf.py (at the matching build commit). Model: 36 layers, hidden 2560, GQA 32/8 heads, vocab 151936, 4.0B params, natively 262,144 context (RoPE-scaled).

Appropriate uses

  • CPU-only / low-RAM deployment of Qwen3-4B (laptops, SBCs, servers without GPUs)
  • Quantization selection: pick the smallest quant whose perplexity delta you accept
  • Benchmarking/teaching material for the sizeโ†”quality tradeoff

Out-of-scope uses

  • Any claim that these quants were trained, fine-tuned, or otherwise modified
  • Using these numbers to compare against other models (different corpus settings would be needed for a fair cross-model eval)
  • High-stakes / safety-critical deployment โ€” Qwen3-4B's own limitations apply (see the base model card)

Licensing

  • Base model: Apache 2.0 (per Qwen/Qwen3-4B's LICENSE, which is carried in this repo as LICENSE)
  • These GGUFs are derivative works of the Apache-2.0 base โ†’ Apache 2.0
  • Eval corpus: WikiText-2 (research benchmark corpus)

Community benchmark, independent of Qwen/Alibaba. Not affiliated with or endorsed by Alibaba Cloud.

Downloads last month
86
GGUF
Model size
4B params
Architecture
qwen3
Hardware compatibility
Log In to add your hardware

3-bit

4-bit

5-bit

6-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for b4ph/qwen3-4b-lowram-bench

Finetuned
Qwen/Qwen3-4B
Quantized
(313)
this model

Space using b4ph/qwen3-4b-lowram-bench 1